[ovs-dev] [PATCH 13/14] Modify and add headers needed for compile
Alin Serdean
aserdean at cloudbasesolutions.com
Fri Jul 11 01:08:03 UTC 2014
Add headers structures, typedefs and defines needed to compile the files
lib/dpif-linux.c, lib/dpif.c, lib/netdev-linux.c, lib/netdev.c,
lib/netlink-socket.c, lib/netlink.c and lib/vlandev.c.
Signed-off-by: Alin Gabriel Serdean <aserdean at cloudbasesolutions.com>
---
include/windows/linux/ethtool.h | 100 ++++++++++++
include/windows/linux/filter.h | 51 ++++++
include/windows/linux/gen_stats.h | 44 +++++
include/windows/linux/if_ether.h | 23 +++
include/windows/linux/if_tun.h | 0
include/windows/linux/mii.h | 31 ++++
include/windows/linux/pkt_cls.h | 0
include/windows/linux/pkt_sched.h | 149 +++++++++++++++++
include/windows/linux/rtnetlink.h | 293 ++++++++++++++++++++++++++++++++++
include/windows/linux/sockios.h | 25 +++
include/windows/net/if.h | 317 +++++++++++++++++++++++++++++++++++++
include/windows/net/if_arp.h | 31 ++++
include/windows/net/if_packet.h | 31 ++++
include/windows/net/route.h | 47 ++++++
include/windows/netpacket/packet.h | 95 +++++++++++
include/windows/sys/epoll.h | 49 ++++++
include/windows/sys/ioctl.h | 41 +++++
include/windows/sys/socket.h | 5 +
include/windows/sys/uio.h | 22 +++
include/windows/unistd.h | 52 ++++++
20 files changed, 1406 insertions(+)
create mode 100644 include/windows/linux/ethtool.h
create mode 100644 include/windows/linux/filter.h
create mode 100644 include/windows/linux/gen_stats.h
create mode 100644 include/windows/linux/if_ether.h
create mode 100644 include/windows/linux/if_tun.h
create mode 100644 include/windows/linux/mii.h
create mode 100644 include/windows/linux/pkt_cls.h
create mode 100644 include/windows/linux/pkt_sched.h
create mode 100644 include/windows/linux/rtnetlink.h
create mode 100644 include/windows/linux/sockios.h
create mode 100644 include/windows/net/if_arp.h
create mode 100644 include/windows/net/if_packet.h
create mode 100644 include/windows/net/route.h
create mode 100644 include/windows/netpacket/packet.h
create mode 100644 include/windows/sys/epoll.h
diff --git a/include/windows/linux/ethtool.h b/include/windows/linux/ethtool.h
new file mode 100644
index 0000000..bf5ea83
--- /dev/null
+++ b/include/windows/linux/ethtool.h
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2014 Cloudbase Solutions Srl
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __LINUX_ETHTOOL_H
+#define __LINUX_ETHTOOL_H 1
+
+#define ETHTOOL_FWVERS_LEN 32
+#define ETHTOOL_BUSINFO_LEN 32
+
+struct ethtool_drvinfo {
+ UINT32 cmd;
+ char driver[32]; /* driver short name, "tulip", "eepro100" */
+ char version[32]; /* driver version string */
+ char fw_version[ETHTOOL_FWVERS_LEN]; /* firmware version string */
+ char bus_info[ETHTOOL_BUSINFO_LEN]; /* Bus info for this IF. */
+ /* For PCI devices, use pci_name(pci_dev). */
+ char reserved1[32];
+ char reserved2[12];
+ UINT32 n_priv_flags; /* number of flags valid in ETHTOOL_GPFLAGS */
+ UINT32 n_stats; /* number of u64's from ETHTOOL_GSTATS */
+ UINT32 testinfo_len;
+ UINT32 eedump_len; /* Size of data from ETHTOOL_GEEPROM (bytes) */
+ UINT32 regdump_len; /* Size of data from ETHTOOL_GREGS (bytes) */
+};
+
+/* This should work for both 32 and 64 bit userland. */
+struct ethtool_cmd {
+ UINT32 cmd;
+ UINT32 supported; /* Features this interface supports */
+ UINT32 advertising; /* Features this interface advertises */
+ UINT16 speed; /* The forced speed (lower bits) in
+ * Mbps. Please use
+ * ethtool_cmd_speed()/_set() to
+ * access it */
+ UINT8 duplex; /* Duplex, half or full */
+ UINT8 port; /* Which connector port */
+ UINT8 phy_address; /* MDIO PHY address (PRTAD for clause 45).
+ * May be read-only or read-write
+ * depending on the driver.
+ */
+ UINT8 transceiver; /* Which transceiver to use */
+ UINT8 autoneg; /* Enable or disable autonegotiation */
+ UINT8 mdio_support; /* MDIO protocols supported. Read-only.
+ * Not set by all drivers.
+ */
+ UINT32 maxtxpkt; /* Tx pkts before generating tx int */
+ UINT32 maxrxpkt; /* Rx pkts before generating rx int */
+ UINT16 speed_hi; /* The forced speed (upper
+ * bits) in Mbps. Please use
+ * ethtool_cmd_speed()/_set() to
+ * access it */
+ UINT8 eth_tp_mdix; /* twisted pair MDI-X status */
+ UINT8 eth_tp_mdix_ctrl; /* twisted pair MDI-X control, when set,
+ * link should be renegotiated if necessary
+ */
+ UINT32 lp_advertising; /* Features the link partner advertises */
+ UINT32 reserved[2];
+};
+
+/* for passing single values */
+struct ethtool_value {
+ UINT32 cmd;
+ UINT32 data;
+};
+
+
+#define ETHTOOL_GSET 0x00000001 /* Get settings. */
+#define ETHTOOL_SSET 0x00000002 /* Set settings. */
+#define ETHTOOL_GDRVINFO 0x00000003 /* Get driver info. */
+#define ETHTOOL_GLINK 0x0000000a
+
+/* Indicates what features are supported by the interface. */
+#define SUPPORTED_10baseT_Half (1 << 0)
+#define SUPPORTED_10baseT_Full (1 << 1)
+#define SUPPORTED_100baseT_Half (1 << 2)
+#define SUPPORTED_100baseT_Full (1 << 3)
+#define SUPPORTED_1000baseT_Half (1 << 4)
+#define SUPPORTED_1000baseT_Full (1 << 5)
+#define SUPPORTED_Autoneg (1 << 6)
+#define SUPPORTED_TP (1 << 7)
+#define SUPPORTED_10000baseT_Full (1 << 12)
+#define SUPPORTED_FIBRE (1 << 10)
+#define SUPPORTED_Pause (1 << 13)
+#define SUPPORTED_Asym_Pause (1 << 14)
+
+
+#endif /* linux/ethtool.h */
diff --git a/include/windows/linux/filter.h b/include/windows/linux/filter.h
new file mode 100644
index 0000000..84bdfae
--- /dev/null
+++ b/include/windows/linux/filter.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2014 Cloudbase Solutions Srl
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __LINUX_FILTER_H
+#define __LINUX_FILTER_H 1
+
+/*
+ * Try and keep these values and structures similar to BSD, especially
+ * the BPF code definitions which need to match so you can share filters
+ */
+
+struct sock_filter { /* Filter block */
+ UINT16 code; /* Actual filter code */
+ UINT8 jt; /* Jump true */
+ UINT8 jf; /* Jump false */
+ UINT32 k; /* Generic multiuse field */
+};
+
+struct sock_fprog { /* Required for SO_ATTACH_FILTER. */
+ unsigned short len; /* Number of filter blocks */
+ struct sock_filter *filter;
+};
+
+
+/* Socket filtering */
+#define SO_ATTACH_FILTER 26
+#define SO_DETACH_FILTER 27
+
+#define SO_PEERNAME 28
+#define SO_TIMESTAMP 29
+#define SCM_TIMESTAMP SO_TIMESTAMP
+
+#define SO_PEERSEC 30
+#define SO_PASSSEC 34
+#define SO_TIMESTAMPNS 35
+#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
+
+#endif /* linux/filter.h */
diff --git a/include/windows/linux/gen_stats.h b/include/windows/linux/gen_stats.h
new file mode 100644
index 0000000..5f30e60
--- /dev/null
+++ b/include/windows/linux/gen_stats.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2014 Cloudbase Solutions Srl
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __LINUX_GEN_STATS_H
+#define __LINUX_GEN_STATS_H 1
+
+struct gnet_stats_queue {
+ UINT32 qlen;
+ UINT32 backlog;
+ UINT32 drops;
+ UINT32 requeues;
+ UINT32 overlimits;
+};
+
+enum {
+ TCA_STATS_UNSPEC,
+ TCA_STATS_BASIC,
+ TCA_STATS_RATE_EST,
+ TCA_STATS_QUEUE,
+ TCA_STATS_APP,
+ TCA_STATS_RATE_EST64,
+ __TCA_STATS_MAX,
+};
+#define TCA_STATS_MAX (__TCA_STATS_MAX - 1)
+
+struct gnet_stats_basic {
+ UINT64 bytes;
+ UINT32 packets;
+};
+
+#endif /* linux/gen_stats.h */
diff --git a/include/windows/linux/if_ether.h b/include/windows/linux/if_ether.h
new file mode 100644
index 0000000..456ccb9
--- /dev/null
+++ b/include/windows/linux/if_ether.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2014 Cloudbase Solutions Srl
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __LINUX_IF_ETHER_H
+#define __LINUX_IF_ETHER_H 1
+
+#define ETH_ALEN 6 /* Octets in one ethernet addr */
+#define ETH_P_ALL 0x0003 /* Every packet (be careful!!!) */
+
+#endif /* linux/if_ether.h */
diff --git a/include/windows/linux/if_tun.h b/include/windows/linux/if_tun.h
new file mode 100644
index 0000000..e69de29
diff --git a/include/windows/linux/mii.h b/include/windows/linux/mii.h
new file mode 100644
index 0000000..1b8a18e
--- /dev/null
+++ b/include/windows/linux/mii.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2014 Cloudbase Solutions Srl
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __LINUX_MII_H
+#define __LINUX_MII_H 1
+
+/* This structure is used in all SIOCxMIIxxx ioctl calls */
+struct mii_ioctl_data {
+ UINT16 phy_id;
+ UINT16 reg_num;
+ UINT16 val_in;
+ UINT16 val_out;
+};
+
+#define MII_BMSR 0x01 /* Basic mode status register */
+#define BMSR_LSTATUS 0x0004 /* Link status */
+
+#endif /* linux/mii.h */
diff --git a/include/windows/linux/pkt_cls.h b/include/windows/linux/pkt_cls.h
new file mode 100644
index 0000000..e69de29
diff --git a/include/windows/linux/pkt_sched.h b/include/windows/linux/pkt_sched.h
new file mode 100644
index 0000000..a032ed6
--- /dev/null
+++ b/include/windows/linux/pkt_sched.h
@@ -0,0 +1,149 @@
+/*
+ * Copyright 2014 Cloudbase Solutions Srl
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __LINUX_PKT_SCHED_H
+#define __LINUX_PKT_SCHED_H 1
+
+#define TC_PRIO_BESTEFFORT 0
+
+struct tc_htb_glob
+{
+ UINT32 version; /* to match HTB/TC */
+ UINT32 rate2quantum; /* bps->quantum divisor */
+ UINT32 defcls; /* default class number */
+ UINT32 debug; /* debug flags */
+
+ /* stats */
+ UINT32 direct_pkts; /* count of non shapped packets */
+};
+
+#define TC_H_ROOT (0xFFFFFFFFU)
+
+enum
+{
+ TCA_HTB_UNSPEC,
+ TCA_HTB_PARMS,
+ TCA_HTB_INIT,
+ TCA_HTB_CTAB,
+ TCA_HTB_RTAB,
+ __TCA_HTB_MAX,
+};
+
+struct tc_ratespec
+{
+ unsigned char cell_log;
+ unsigned char __reserved1;
+ unsigned short overhead;
+ short cell_align;
+ unsigned short mpu;
+ UINT32 rate;
+};
+
+struct tc_htb_opt
+{
+ struct tc_ratespec rate;
+ struct tc_ratespec ceil;
+ UINT32 buffer;
+ UINT32 cbuffer;
+ UINT32 quantum;
+ UINT32 level; /* out only */
+ UINT32 prio;
+};
+
+enum
+{
+ TCA_HFSC_UNSPEC,
+ TCA_HFSC_RSC,
+ TCA_HFSC_FSC,
+ TCA_HFSC_USC,
+ __TCA_HFSC_MAX,
+};
+
+struct tc_service_curve
+{
+ UINT32 m1; /* slope of the first segment in bps */
+ UINT32 d; /* x-projection of the first segment in us */
+ UINT32 m2; /* slope of the second segment in bps */
+};
+/* HFSC section */
+
+struct tc_hfsc_qopt
+{
+ UINT16 defcls; /* default class */
+};
+
+#define TC_H_MAJ_MASK (0xFFFF0000U)
+#define TC_H_MIN_MASK (0x0000FFFFU)
+#define TC_H_MAJ(h) ((h)&TC_H_MAJ_MASK)
+#define TC_H_MIN(h) ((h)&TC_H_MIN_MASK)
+#define TC_H_MAKE(maj,min) (((maj)&TC_H_MAJ_MASK)|((min)&TC_H_MIN_MASK))
+#define TC_H_UNSPEC (0U)
+#define TC_H_ROOT (0xFFFFFFFFU)
+#define TC_H_INGRESS (0xFFFFFFF1U)
+
+#define TC_ACT_UNSPEC (-1)
+#define TC_ACT_OK 0
+#define TC_ACT_RECLASSIFY 1
+#define TC_ACT_SHOT 2
+#define TC_ACT_PIPE 3
+#define TC_ACT_STOLEN 4
+#define TC_ACT_QUEUED 5
+#define TC_ACT_REPEAT 6
+#define TC_ACT_JUMP 0x10000000
+
+enum
+{
+ TCA_BASIC_UNSPEC,
+ TCA_BASIC_CLASSID,
+ TCA_BASIC_EMATCHES,
+ TCA_BASIC_ACT,
+ TCA_BASIC_POLICE,
+ __TCA_BASIC_MAX
+};
+
+enum
+{
+ TCA_POLICE_UNSPEC,
+ TCA_POLICE_TBF,
+ TCA_POLICE_RATE,
+ TCA_POLICE_PEAKRATE,
+ TCA_POLICE_AVRATE,
+ TCA_POLICE_RESULT,
+ __TCA_POLICE_MAX
+#define TCA_POLICE_RESULT TCA_POLICE_RESULT
+};
+
+struct tc_police
+{
+ UINT32 index;
+ int action;
+#define TC_POLICE_UNSPEC TC_ACT_UNSPEC
+#define TC_POLICE_OK TC_ACT_OK
+#define TC_POLICE_RECLASSIFY TC_ACT_RECLASSIFY
+#define TC_POLICE_SHOT TC_ACT_SHOT
+#define TC_POLICE_PIPE TC_ACT_PIPE
+
+ UINT32 limit;
+ UINT32 burst;
+ UINT32 mtu;
+ struct tc_ratespec rate;
+ struct tc_ratespec peakrate;
+ int refcnt;
+ int bindcnt;
+ UINT32 capab;
+};
+
+#endif /* linux/pkt_sched.h */
diff --git a/include/windows/linux/rtnetlink.h b/include/windows/linux/rtnetlink.h
new file mode 100644
index 0000000..9090bf9
--- /dev/null
+++ b/include/windows/linux/rtnetlink.h
@@ -0,0 +1,293 @@
+/*
+ * Copyright 2014 Cloudbase Solutions Srl
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __LINUX_RTNETLINK_H
+#define __LINUX_RTNETLINK_H 1
+
+
+enum {
+ RTM_BASE = 16,
+#define RTM_BASE RTM_BASE
+
+ RTM_NEWLINK = 16,
+#define RTM_NEWLINK RTM_NEWLINK
+ RTM_DELLINK,
+#define RTM_DELLINK RTM_DELLINK
+ RTM_GETLINK,
+#define RTM_GETLINK RTM_GETLINK
+ RTM_SETLINK,
+#define RTM_SETLINK RTM_SETLINK
+
+ RTM_NEWADDR = 20,
+#define RTM_NEWADDR RTM_NEWADDR
+ RTM_DELADDR,
+#define RTM_DELADDR RTM_DELADDR
+ RTM_GETADDR,
+#define RTM_GETADDR RTM_GETADDR
+
+ RTM_NEWROUTE = 24,
+#define RTM_NEWROUTE RTM_NEWROUTE
+ RTM_DELROUTE,
+#define RTM_DELROUTE RTM_DELROUTE
+ RTM_GETROUTE,
+#define RTM_GETROUTE RTM_GETROUTE
+
+ RTM_NEWNEIGH = 28,
+#define RTM_NEWNEIGH RTM_NEWNEIGH
+ RTM_DELNEIGH,
+#define RTM_DELNEIGH RTM_DELNEIGH
+ RTM_GETNEIGH,
+#define RTM_GETNEIGH RTM_GETNEIGH
+
+ RTM_NEWRULE = 32,
+#define RTM_NEWRULE RTM_NEWRULE
+ RTM_DELRULE,
+#define RTM_DELRULE RTM_DELRULE
+ RTM_GETRULE,
+#define RTM_GETRULE RTM_GETRULE
+
+ RTM_NEWQDISC = 36,
+#define RTM_NEWQDISC RTM_NEWQDISC
+ RTM_DELQDISC,
+#define RTM_DELQDISC RTM_DELQDISC
+ RTM_GETQDISC,
+#define RTM_GETQDISC RTM_GETQDISC
+
+ RTM_NEWTCLASS = 40,
+#define RTM_NEWTCLASS RTM_NEWTCLASS
+ RTM_DELTCLASS,
+#define RTM_DELTCLASS RTM_DELTCLASS
+ RTM_GETTCLASS,
+#define RTM_GETTCLASS RTM_GETTCLASS
+
+ RTM_NEWTFILTER = 44,
+#define RTM_NEWTFILTER RTM_NEWTFILTER
+ RTM_DELTFILTER,
+#define RTM_DELTFILTER RTM_DELTFILTER
+ RTM_GETTFILTER,
+#define RTM_GETTFILTER RTM_GETTFILTER
+
+ RTM_NEWACTION = 48,
+#define RTM_NEWACTION RTM_NEWACTION
+ RTM_DELACTION,
+#define RTM_DELACTION RTM_DELACTION
+ RTM_GETACTION,
+#define RTM_GETACTION RTM_GETACTION
+
+ RTM_NEWPREFIX = 52,
+#define RTM_NEWPREFIX RTM_NEWPREFIX
+
+ RTM_GETMULTICAST = 58,
+#define RTM_GETMULTICAST RTM_GETMULTICAST
+
+ RTM_GETANYCAST = 62,
+#define RTM_GETANYCAST RTM_GETANYCAST
+
+ RTM_NEWNEIGHTBL = 64,
+#define RTM_NEWNEIGHTBL RTM_NEWNEIGHTBL
+ RTM_GETNEIGHTBL = 66,
+#define RTM_GETNEIGHTBL RTM_GETNEIGHTBL
+ RTM_SETNEIGHTBL,
+#define RTM_SETNEIGHTBL RTM_SETNEIGHTBL
+
+ RTM_NEWNDUSEROPT = 68,
+#define RTM_NEWNDUSEROPT RTM_NEWNDUSEROPT
+ RTM_NEWADDRLABEL = 72,
+#define RTM_NEWADDRLABEL RTM_NEWADDRLABEL
+ RTM_DELADDRLABEL,
+#define RTM_DELADDRLABEL RTM_DELADDRLABEL
+ RTM_GETADDRLABEL,
+#define RTM_GETADDRLABEL RTM_GETADDRLABEL
+
+ RTM_GETDCB = 78,
+#define RTM_GETDCB RTM_GETDCB
+ RTM_SETDCB,
+#define RTM_SETDCB RTM_SETDCB
+
+ RTM_NEWNETCONF = 80,
+#define RTM_NEWNETCONF RTM_NEWNETCONF
+ RTM_GETNETCONF = 82,
+#define RTM_GETNETCONF RTM_GETNETCONF
+
+ RTM_NEWMDB = 84,
+#define RTM_NEWMDB RTM_NEWMDB
+ RTM_DELMDB = 85,
+#define RTM_DELMDB RTM_DELMDB
+ RTM_GETMDB = 86,
+#define RTM_GETMDB RTM_GETMDB
+
+ __RTM_MAX,
+#define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1)
+};
+
+enum rtnetlink_groups {
+ RTNLGRP_NONE,
+#define RTNLGRP_NONE RTNLGRP_NONE
+ RTNLGRP_LINK,
+#define RTNLGRP_LINK RTNLGRP_LINK
+ RTNLGRP_NOTIFY,
+#define RTNLGRP_NOTIFY RTNLGRP_NOTIFY
+ RTNLGRP_NEIGH,
+#define RTNLGRP_NEIGH RTNLGRP_NEIGH
+ RTNLGRP_TC,
+#define RTNLGRP_TC RTNLGRP_TC
+ RTNLGRP_IPV4_IFADDR,
+#define RTNLGRP_IPV4_IFADDR RTNLGRP_IPV4_IFADDR
+ RTNLGRP_IPV4_MROUTE,
+#define RTNLGRP_IPV4_MROUTE RTNLGRP_IPV4_MROUTE
+ RTNLGRP_IPV4_ROUTE,
+#define RTNLGRP_IPV4_ROUTE RTNLGRP_IPV4_ROUTE
+ RTNLGRP_IPV4_RULE,
+#define RTNLGRP_IPV4_RULE RTNLGRP_IPV4_RULE
+ RTNLGRP_IPV6_IFADDR,
+#define RTNLGRP_IPV6_IFADDR RTNLGRP_IPV6_IFADDR
+ RTNLGRP_IPV6_MROUTE,
+#define RTNLGRP_IPV6_MROUTE RTNLGRP_IPV6_MROUTE
+ RTNLGRP_IPV6_ROUTE,
+#define RTNLGRP_IPV6_ROUTE RTNLGRP_IPV6_ROUTE
+ RTNLGRP_IPV6_IFINFO,
+#define RTNLGRP_IPV6_IFINFO RTNLGRP_IPV6_IFINFO
+ RTNLGRP_DECnet_IFADDR,
+#define RTNLGRP_DECnet_IFADDR RTNLGRP_DECnet_IFADDR
+ RTNLGRP_NOP2,
+ RTNLGRP_DECnet_ROUTE,
+#define RTNLGRP_DECnet_ROUTE RTNLGRP_DECnet_ROUTE
+ RTNLGRP_DECnet_RULE,
+#define RTNLGRP_DECnet_RULE RTNLGRP_DECnet_RULE
+ RTNLGRP_NOP4,
+ RTNLGRP_IPV6_PREFIX,
+#define RTNLGRP_IPV6_PREFIX RTNLGRP_IPV6_PREFIX
+ RTNLGRP_IPV6_RULE,
+#define RTNLGRP_IPV6_RULE RTNLGRP_IPV6_RULE
+ RTNLGRP_ND_USEROPT,
+#define RTNLGRP_ND_USEROPT RTNLGRP_ND_USEROPT
+ RTNLGRP_PHONET_IFADDR,
+#define RTNLGRP_PHONET_IFADDR RTNLGRP_PHONET_IFADDR
+ RTNLGRP_PHONET_ROUTE,
+#define RTNLGRP_PHONET_ROUTE RTNLGRP_PHONET_ROUTE
+ RTNLGRP_DCB,
+#define RTNLGRP_DCB RTNLGRP_DCB
+ __RTNLGRP_MAX
+};
+
+enum rtattr_type_t {
+ RTA_UNSPEC,
+ RTA_DST,
+ RTA_SRC,
+ RTA_IIF,
+ RTA_OIF,
+ RTA_GATEWAY,
+ RTA_PRIORITY,
+ RTA_PREFSRC,
+ RTA_METRICS,
+ RTA_MULTIPATH,
+ RTA_PROTOINFO, /* no longer used */
+ RTA_FLOW,
+ RTA_CACHEINFO,
+ RTA_SESSION, /* no longer used */
+ RTA_MP_ALGO, /* no longer used */
+ RTA_TABLE,
+ RTA_MARK,
+ RTA_MFC_STATS,
+ __RTA_MAX
+};
+
+/* rtm_type */
+
+enum {
+ RTN_UNSPEC,
+ RTN_UNICAST, /* Gateway or direct route */
+ RTN_LOCAL, /* Accept locally */
+ RTN_BROADCAST, /* Accept locally as broadcast,
+ send as broadcast */
+ RTN_ANYCAST, /* Accept locally as broadcast,
+ but send as unicast */
+ RTN_MULTICAST, /* Multicast route */
+ RTN_BLACKHOLE, /* Drop */
+ RTN_UNREACHABLE, /* Destination is unreachable */
+ RTN_PROHIBIT, /* Administratively prohibited */
+ RTN_THROW, /* Not in this table */
+ RTN_NAT, /* Translate this address */
+ RTN_XRESOLVE, /* Use external resolver */
+ __RTN_MAX
+};
+#define RTN_MAX (__RTN_MAX - 1)
+
+enum rt_scope_t {
+ RT_SCOPE_UNIVERSE=0,
+/* User defined values */
+ RT_SCOPE_SITE=200,
+ RT_SCOPE_LINK=253,
+ RT_SCOPE_HOST=254,
+ RT_SCOPE_NOWHERE=255
+};
+
+struct rtmsg {
+ unsigned char rtm_family;
+ unsigned char rtm_dst_len;
+ unsigned char rtm_src_len;
+ unsigned char rtm_tos;
+
+ unsigned char rtm_table; /* Routing table id */
+ unsigned char rtm_protocol; /* Routing protocol; see below */
+ unsigned char rtm_scope; /* See below */
+ unsigned char rtm_type; /* See below */
+
+ unsigned rtm_flags;
+};
+#define RTA_MAX (__RTA_MAX - 1)
+
+
+enum {
+ TCA_UNSPEC,
+ TCA_KIND,
+ TCA_OPTIONS,
+ TCA_STATS,
+ TCA_XSTATS,
+ TCA_RATE,
+ TCA_FCNT,
+ TCA_STATS2,
+ TCA_STAB,
+ __TCA_MAX
+};
+
+struct tcmsg
+{
+ unsigned char tcm_family;
+ unsigned char tcm__pad1;
+ unsigned short tcm__pad2;
+ int tcm_ifindex;
+ UINT32 tcm_handle;
+ UINT32 tcm_parent;
+ UINT32 tcm_info;
+};
+
+struct ifinfomsg {
+ unsigned char ifi_family;
+ unsigned char __ifi_pad;
+ unsigned short ifi_type; /* ARPHRD_* */
+ int ifi_index; /* Link index */
+ unsigned ifi_flags; /* IFF_* flags */
+ unsigned ifi_change; /* IFF_* change mask */
+};
+
+typedef char* caddr_t;
+
+struct rtgenmsg {
+ unsigned char rtgen_family;
+};
+
+#endif /* linux/rtnetlink.h */
diff --git a/include/windows/linux/sockios.h b/include/windows/linux/sockios.h
new file mode 100644
index 0000000..4623a29
--- /dev/null
+++ b/include/windows/linux/sockios.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2014 Cloudbase Solutions Srl
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __LINUX_SOCKIOS_H
+#define __LINUX_SOCKIOS_H 1
+
+#define SIOCGIFVLAN 0x8982
+#define SIOCSIFVLAN 0x8983
+#define SIOCGIFTXQLEN 0x8942 /* Get the tx queue length */
+#define ENOPKG 41
+
+#endif /* linux/sockios.h */
diff --git a/include/windows/net/if.h b/include/windows/net/if.h
index 893ffe4..c265f2a 100644
--- a/include/windows/net/if.h
+++ b/include/windows/net/if.h
@@ -21,4 +21,321 @@
#define IFNAMSIZ IF_NAMESIZE
+#define IFF_RUNNING 0x40
+#define IFHWADDRLEN 6
+#define IFF_TAP 0x0002
+#define IFF_NO_PI 0x1000
+#define TUNSETIFF _IOW('T', 202, int)
+
+struct ifmap
+{
+ unsigned long int mem_start;
+ unsigned long int mem_end;
+ unsigned short int base_addr;
+ unsigned char irq;
+ unsigned char dma;
+ unsigned char port;
+ /* 3 bytes spare */
+};
+
+typedef struct {
+ unsigned short encoding;
+ unsigned short parity;
+} raw_hdlc_proto;
+
+typedef struct {
+ unsigned int interval;
+ unsigned int timeout;
+} cisco_proto;
+
+typedef struct {
+ unsigned int t391;
+ unsigned int t392;
+ unsigned int n391;
+ unsigned int n392;
+ unsigned int n393;
+ unsigned short lmi;
+ unsigned short dce; /* 1 for DCE (network side) operation */
+} fr_proto;
+
+typedef struct {
+ unsigned int dlci;
+} fr_proto_pvc; /* for creating/deleting FR PVCs */
+
+typedef struct {
+ unsigned int dlci;
+ char master[IFNAMSIZ]; /* Name of master FRAD device */
+}fr_proto_pvc_info; /* for returning PVC information only */
+
+typedef struct {
+ unsigned int clock_rate; /* bits per second */
+ unsigned int clock_type; /* internal, external, TX-internal etc. */
+ unsigned short loopback;
+} sync_serial_settings; /* V.35, V.24, X.21 */
+
+typedef struct {
+ unsigned int clock_rate; /* bits per second */
+ unsigned int clock_type; /* internal, external, TX-internal etc. */
+ unsigned short loopback;
+ unsigned int slot_map;
+} te1_settings; /* T1, E1 */
+
+struct if_settings
+{
+ unsigned int type; /* Type of physical device or protocol */
+ unsigned int size; /* Size of the data allocated by the caller */
+ union {
+ /* {atm/eth/dsl}_settings anyone ? */
+ raw_hdlc_proto *raw_hdlc;
+ cisco_proto *cisco;
+ fr_proto *fr;
+ fr_proto_pvc *fr_pvc;
+ fr_proto_pvc_info *fr_pvc_info;
+
+ /* interface settings */
+ sync_serial_settings *sync;
+ te1_settings *te1;
+ } ifs_ifsu;
+};
+
+struct ifreq
+{
+ union
+ {
+ char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */
+ } ifr_ifrn;
+
+ union {
+ struct sockaddr ifru_addr;
+ struct sockaddr ifru_dstaddr;
+ struct sockaddr ifru_broadaddr;
+ struct sockaddr ifru_netmask;
+ struct sockaddr ifru_hwaddr;
+ short ifru_flags;
+ int ifru_ivalue;
+ int ifru_mtu;
+ struct ifmap ifru_map;
+ char ifru_slave[IFNAMSIZ]; /* Just fits the size */
+ char ifru_newname[IFNAMSIZ];
+ void * ifru_data;
+ struct if_settings ifru_settings;
+ } ifr_ifru;
+};
+
+#define ifr_name ifr_ifrn.ifrn_name /* interface name */
+#define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */
+#define ifr_addr ifr_ifru.ifru_addr /* address */
+#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-p lnk */
+#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
+#define ifr_netmask ifr_ifru.ifru_netmask /* interface net mask */
+#define ifr_flags ifr_ifru.ifru_flags /* flags */
+#define ifr_metric ifr_ifru.ifru_ivalue /* metric */
+#define ifr_mtu ifr_ifru.ifru_mtu /* mtu */
+#define ifr_map ifr_ifru.ifru_map /* device map */
+#define ifr_slave ifr_ifru.ifru_slave /* slave device */
+#define ifr_data ifr_ifru.ifru_data /* for use by interface */
+#define ifr_ifindex ifr_ifru.ifru_ivalue /* interface index */
+#define ifr_bandwidth ifr_ifru.ifru_ivalue /* link bandwidth */
+#define ifr_qlen ifr_ifru.ifru_ivalue /* queue length */
+#define ifr_newname ifr_ifru.ifru_newname /* New name */
+#define ifr_settings ifr_ifru.ifru_settings /* Device/proto settings*/
+
+/* Indicates what features are advertised by the interface. */
+#define ADVERTISED_10baseT_Half (1 << 0)
+#define ADVERTISED_10baseT_Full (1 << 1)
+#define ADVERTISED_100baseT_Half (1 << 2)
+#define ADVERTISED_100baseT_Full (1 << 3)
+#define ADVERTISED_1000baseT_Half (1 << 4)
+#define ADVERTISED_1000baseT_Full (1 << 5)
+#define ADVERTISED_Autoneg (1 << 6)
+#define ADVERTISED_TP (1 << 7)
+#define ADVERTISED_AUI (1 << 8)
+#define ADVERTISED_MII (1 << 9)
+#define ADVERTISED_FIBRE (1 << 10)
+#define ADVERTISED_BNC (1 << 11)
+#define ADVERTISED_10000baseT_Full (1 << 12)
+#define ADVERTISED_Pause (1 << 13)
+#define ADVERTISED_Asym_Pause (1 << 14)
+#define ADVERTISED_2500baseX_Full (1 << 15)
+#define ADVERTISED_Backplane (1 << 16)
+#define ADVERTISED_1000baseKX_Full (1 << 17)
+#define ADVERTISED_10000baseKX4_Full (1 << 18)
+#define ADVERTISED_10000baseKR_Full (1 << 19)
+#define ADVERTISED_10000baseR_FEC (1 << 20)
+#define ADVERTISED_20000baseMLD2_Full (1 << 21)
+#define ADVERTISED_20000baseKR2_Full (1 << 22)
+
+/* The forced speed, 10Mb, 100Mb, gigabit, 2.5Gb, 10GbE. */
+#define SPEED_10 10
+#define SPEED_100 100
+#define SPEED_1000 1000
+#define SPEED_2500 2500
+#define SPEED_10000 10000
+#define SPEED_UNKNOWN -1
+
+/* Duplex, half or full. */
+#define DUPLEX_HALF 0x00
+#define DUPLEX_FULL 0x01
+#define DUPLEX_UNKNOWN 0xff
+
+/* Which connector port. */
+#define PORT_TP 0x00
+#define PORT_AUI 0x01
+#define PORT_MII 0x02
+#define PORT_FIBRE 0x03
+#define PORT_BNC 0x04
+#define PORT_DA 0x05
+#define PORT_NONE 0xef
+#define PORT_OTHER 0xff
+
+/* Which transceiver to use. */
+#define XCVR_INTERNAL 0x00
+#define XCVR_EXTERNAL 0x01
+#define XCVR_DUMMY1 0x02
+#define XCVR_DUMMY2 0x03
+#define XCVR_DUMMY3 0x04
+
+/* Enable or disable autonegotiation. If this is set to enable,
+* the forced link modes above are completely ignored.
+*/
+#define AUTONEG_DISABLE 0x00
+#define AUTONEG_ENABLE 0x01
+
+/* Mode MDI or MDI-X */
+#define ETH_TP_MDI_INVALID 0x00
+#define ETH_TP_MDI 0x01
+#define ETH_TP_MDI_X 0x02
+/* Socket configuration controls. */
+#define SIOCGIFNAME 0x8910 /* get iface name */
+#define SIOCSIFLINK 0x8911 /* set iface channel */
+#define SIOCGIFCONF 0x8912 /* get iface list */
+#define SIOCGIFFLAGS 0x8913 /* get flags */
+#define SIOCSIFFLAGS 0x8914 /* set flags */
+#define SIOCGIFADDR 0x8915 /* get PA address */
+#define SIOCSIFADDR 0x8916 /* set PA address */
+#define SIOCGIFDSTADDR 0x8917 /* get remote PA address */
+#define SIOCSIFDSTADDR 0x8918 /* set remote PA address */
+#define SIOCGIFBRDADDR 0x8919 /* get broadcast PA address */
+#define SIOCSIFBRDADDR 0x891a /* set broadcast PA address */
+#define SIOCGIFNETMASK 0x891b /* get network PA mask */
+#define SIOCSIFNETMASK 0x891c /* set network PA mask */
+#define SIOCGIFMETRIC 0x891d /* get metric */
+#define SIOCSIFMETRIC 0x891e /* set metric */
+#define SIOCGIFMEM 0x891f /* get memory address (BSD) */
+#define SIOCSIFMEM 0x8920 /* set memory address (BSD) */
+#define SIOCGIFMTU 0x8921 /* get MTU size */
+#define SIOCSIFMTU 0x8922 /* set MTU size */
+#define SIOCSIFNAME 0x8923 /* set interface name */
+#define SIOCSIFHWADDR 0x8924 /* set hardware address */
+#define SIOCGIFENCAP 0x8925 /* get/set encapsulations */
+#define SIOCSIFENCAP 0x8926
+#define SIOCGIFHWADDR 0x8927 /* Get hardware address */
+#define SIOCGIFSLAVE 0x8929 /* Driver slaving support */
+#define SIOCSIFSLAVE 0x8930
+#define SIOCADDMULTI 0x8931 /* Multicast address lists */
+#define SIOCDELMULTI 0x8932
+#define SIOCGIFINDEX 0x8933 /* name -> if_index mapping */
+#define SIOGIFINDEX SIOCGIFINDEX /* misprint compatibility :-) */
+#define SIOCSIFPFLAGS 0x8934 /* set/get extended flags set */
+#define SIOCGIFPFLAGS 0x8935
+#define SIOCDIFADDR 0x8936 /* delete PA address */
+#define SIOCSIFHWBROADCAST 0x8937 /* set hardware broadcast addr */
+#define SIOCGIFCOUNT 0x8938 /* get number of devices */
+/* Routing table calls. */
+#define SIOCADDRT 0x890B /* add routing table entry */
+#define SIOCDELRT 0x890C /* delete routing table entry */
+#define SIOCRTMSG 0x890D /* call to routing system */
+#define IFF_PROMISC 0x100
+#define SIOCGARP 0x8954 /* get ARP table entry */
+#define SIOCETHTOOL 0x8946 /* Ethtool interface */
+
+#define SIOCGMIIPHY 0x8947 /* Get address of MII PHY in use. */
+#define SIOCGMIIREG 0x8948 /* Read MII PHY register. */
+#define SIOCSMIIREG 0x8949 /* Write MII PHY register. */
+
+#define SIOCWANDEV 0x894A /* get/set netdev parameters */
+/* The struct should be in sync with struct net_device_stats */
+struct rtnl_link_stats
+{
+ UINT32 rx_packets; /* total packets received */
+ UINT32 tx_packets; /* total packets transmitted */
+ UINT32 rx_bytes; /* total bytes received */
+ UINT32 tx_bytes; /* total bytes transmitted */
+ UINT32 rx_errors; /* bad packets received */
+ UINT32 tx_errors; /* packet transmit problems */
+ UINT32 rx_dropped; /* no space in linux buffers */
+ UINT32 tx_dropped; /* no space available in linux */
+ UINT32 multicast; /* multicast packets received */
+ UINT32 collisions;
+
+ /* detailed rx_errors: */
+ UINT32 rx_length_errors;
+ UINT32 rx_over_errors; /* receiver ring buff overflow */
+ UINT32 rx_crc_errors; /* recved pkt with crc error */
+ UINT32 rx_frame_errors; /* recv'd frame alignment error */
+ UINT32 rx_fifo_errors; /* recv'r fifo overrun */
+ UINT32 rx_missed_errors; /* receiver missed packet */
+
+ /* detailed tx_errors */
+ UINT32 tx_aborted_errors;
+ UINT32 tx_carrier_errors;
+ UINT32 tx_fifo_errors;
+ UINT32 tx_heartbeat_errors;
+ UINT32 tx_window_errors;
+
+ /* for cslip etc */
+ UINT32 rx_compressed;
+ UINT32 tx_compressed;
+};
+
+enum {
+ IFLA_UNSPEC,
+ IFLA_ADDRESS,
+ IFLA_BROADCAST,
+ IFLA_IFNAME,
+ IFLA_MTU,
+ IFLA_LINK,
+ IFLA_QDISC,
+ IFLA_STATS,
+ IFLA_COST,
+#define IFLA_COST IFLA_COST
+ IFLA_PRIORITY,
+#define IFLA_PRIORITY IFLA_PRIORITY
+ IFLA_MASTER,
+#define IFLA_MASTER IFLA_MASTER
+ IFLA_WIRELESS, /* Wireless Extension event - see wireless.h */
+#define IFLA_WIRELESS IFLA_WIRELESS
+ IFLA_PROTINFO, /* Protocol specific information for a link */
+#define IFLA_PROTINFO IFLA_PROTINFO
+ IFLA_TXQLEN,
+#define IFLA_TXQLEN IFLA_TXQLEN
+ IFLA_MAP,
+#define IFLA_MAP IFLA_MAP
+ IFLA_WEIGHT,
+#define IFLA_WEIGHT IFLA_WEIGHT
+ IFLA_OPERSTATE,
+ IFLA_LINKMODE,
+ IFLA_LINKINFO,
+#define IFLA_LINKINFO IFLA_LINKINFO
+ IFLA_NET_NS_PID,
+ IFLA_IFALIAS,
+ IFLA_NUM_VF, /* Number of VFs if device is SR-IOV PF */
+ IFLA_VFINFO_LIST,
+ IFLA_STATS64,
+ IFLA_VF_PORTS,
+ IFLA_PORT_SELF,
+ IFLA_AF_SPEC,
+ IFLA_GROUP, /* Group the device belongs to */
+ IFLA_NET_NS_FD,
+ IFLA_EXT_MASK, /* Extended info mask, VFs, etc */
+ IFLA_PROMISCUITY, /* Promiscuity count: > 0 means acts PROMISC */
+#define IFLA_PROMISCUITY IFLA_PROMISCUITY
+ IFLA_NUM_TX_QUEUES,
+ IFLA_NUM_RX_QUEUES,
+ IFLA_CARRIER,
+ IFLA_PHYS_PORT_ID,
+ __IFLA_MAX
+};
+#define IFLA_MAX (__IFLA_MAX - 1)
+
#endif /* net/if.h */
diff --git a/include/windows/net/if_arp.h b/include/windows/net/if_arp.h
new file mode 100644
index 0000000..ad41196
--- /dev/null
+++ b/include/windows/net/if_arp.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2014 Cloudbase Solutions Srl
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __NET_IF_ARP_H
+#define __NET_IF_ARP_H 1
+
+#define ARPHRD_ETHER 1 /* Ethernet 10/100Mbps. */
+
+struct arpreq
+ {
+ struct sockaddr arp_pa; /* Protocol address. */
+ struct sockaddr arp_ha; /* Hardware address. */
+ int arp_flags; /* Flags. */
+ struct sockaddr arp_netmask; /* Netmask (only for proxy arps). */
+ char arp_dev[16];
+ };
+
+#endif /* net/if_arp.h */
diff --git a/include/windows/net/if_packet.h b/include/windows/net/if_packet.h
new file mode 100644
index 0000000..c070bdc
--- /dev/null
+++ b/include/windows/net/if_packet.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2014 Cloudbase Solutions Srl
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __NET_IF_PACKET_H
+#define __NET_IF_PACKET_H 1
+
+struct sockaddr_ll
+{
+ unsigned short sll_family;
+ UINT16 sll_protocol;
+ int sll_ifindex;
+ unsigned short sll_hatype;
+ unsigned char sll_pkttype;
+ unsigned char sll_halen;
+ unsigned char sll_addr[8];
+};
+
+#endif /* net/if_packet.h */
diff --git a/include/windows/net/route.h b/include/windows/net/route.h
new file mode 100644
index 0000000..4fe2026
--- /dev/null
+++ b/include/windows/net/route.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2014 Cloudbase Solutions Srl
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __NET_ROUTE_H
+#define __NET_ROUTE_H 1
+
+#define RTF_UP 0x0001 /* Route usable. */
+#define RTF_GATEWAY 0x0002 /* Destination is a gateway. */
+
+/* This structure gets passed by the SIOCADDRT and SIOCDELRT calls. */
+struct rtentry
+ {
+ unsigned long int rt_pad1;
+ struct sockaddr rt_dst; /* Target address. */
+ struct sockaddr rt_gateway; /* Gateway addr (RTF_GATEWAY). */
+ struct sockaddr rt_genmask; /* Target network mask (IP). */
+ unsigned short int rt_flags;
+ short int rt_pad2;
+ unsigned long int rt_pad3;
+ unsigned char rt_tos;
+ unsigned char rt_class;
+#if __WORDSIZE == 64
+ short int rt_pad4[3];
+#else
+ short int rt_pad4;
+#endif
+ short int rt_metric; /* +1 for binary compatibility! */
+ char *rt_dev; /* Forcing the device at add. */
+ unsigned long int rt_mtu; /* Per route MTU/Window. */
+ unsigned long int rt_window; /* Window clamping. */
+ unsigned short int rt_irtt; /* Initial RTT. */
+ };
+
+#endif /* net/route.h */
diff --git a/include/windows/netpacket/packet.h b/include/windows/netpacket/packet.h
new file mode 100644
index 0000000..025cc26
--- /dev/null
+++ b/include/windows/netpacket/packet.h
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2014 Cloudbase Solutions Srl
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __NETPACKET_PACKET_H
+#define __NETPACKET_PACKET_H 1
+
+#define PF_PACKET 17 /* Packet family. */
+#define AF_PACKET PF_PACKET
+#define SOL_PACKET 263
+
+struct iovec
+{
+ void *iov_base; /* BSD uses caddr_t (1003.1g requires void *) */
+ unsigned int iov_len; /* Must be size_t (1003.1g) */
+};
+
+struct msghdr
+ {
+ void *msg_name; /* Address to send to/receive from. */
+ socklen_t msg_namelen; /* Length of address data. */
+
+ struct iovec *msg_iov; /* Vector of data to send/receive into. */
+ size_t msg_iovlen; /* Number of elements in the vector. */
+
+ void *msg_control; /* Ancillary data (eg BSD filedesc passing). */
+ size_t msg_controllen; /* Ancillary data buffer length.
+ !! The type should be socklen_t but the
+ definition of the kernel is incompatible
+ with this. */
+
+ int msg_flags; /* Flags on received message. */
+ };
+
+#undef CMSG_FIRSTHDR
+#undef CMSG_NXTHDR
+
+#define CMSG_FIRSTHDR(mhdr) \
+ ((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr) \
+ ? (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) 0)
+
+#define CMSG_NXTHDR(msg, cmsg) \
+ ( ((cmsg) == NULL) \
+ ? CMSG_FIRSTHDR(msg) \
+ : ( ( ((PUCHAR)(cmsg) + \
+ WSA_CMSGHDR_ALIGN((cmsg)->cmsg_len) + \
+ sizeof(WSACMSGHDR) ) > \
+ (PUCHAR)((msg)->msg_control) + \
+ (msg)->msg_controllen ) \
+ ? (LPWSACMSGHDR)NULL \
+ : (LPWSACMSGHDR)((PUCHAR)(cmsg) + \
+ WSA_CMSGHDR_ALIGN((cmsg)->cmsg_len)) ) )
+
+__inline unsigned int recvmsg(int sockfd, struct msghdr *msg, int flags)
+{
+ INT error = 0, retval = 0;
+ error = ReadFile((HANDLE)sockfd, msg->msg_iov[0].iov_base,
+ msg->msg_iov[0].iov_len, &retval, NULL);
+ DWORD LastError = GetLastError();
+
+ if (LastError != ERROR_IO_PENDING && !retval) {
+ retval = -1;
+ _set_errno(EAGAIN);
+ }
+ else {
+ _set_errno(EAGAIN);
+ }
+ return retval;
+}
+
+__inline unsigned int sendmsg(int sockfd, const struct msghdr *msg, int flags)
+{
+ int error = 0;
+ for (int i = 0; i < msg->msg_iovlen; i++) {
+ do {
+ error = WriteFile((HANDLE)sockfd, msg->msg_iov[i].iov_base,
+ msg->msg_iov[i].iov_len, NULL, NULL);
+ } while (error<=0);
+ }
+ return 0;
+}
+
+#endif /* netpacket/packet.h */
diff --git a/include/windows/sys/epoll.h b/include/windows/sys/epoll.h
new file mode 100644
index 0000000..de5e8dc
--- /dev/null
+++ b/include/windows/sys/epoll.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2014 Cloudbase Solutions Srl
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __SYS_EPOLL_H
+#define __SYS_EPOLL_H 1
+
+enum CPOLL_EVENTS {
+ EPOLLIN = 0x0001,
+ EPOLLOUT = 0x0002,
+ EPOLLRDHUP = 0x0004,
+ EPOLLPRI = 0x0008,
+ EPOLLERR = 0x0010,
+ EPOLLHUP = 0x0020,
+ EPOLLET = 0x0040,
+ EPOLLONESHOT = 0x0080
+};
+
+enum EPOLL_OPCODES {
+ EPOLL_CTL_ADD,
+ EPOLL_CTL_DEL,
+ EPOLL_CTL_MOD
+};
+
+typedef union epoll_data {
+ void* ptr;
+ int fd;
+ uint32_t u32;
+ uint64_t u64;
+} epoll_data_t;
+
+struct epoll_event {
+ uint32_t events;
+ epoll_data_t data;
+};
+
+#endif /* sys/epoll.h */
diff --git a/include/windows/sys/ioctl.h b/include/windows/sys/ioctl.h
index e69de29..e4257d5 100644
--- a/include/windows/sys/ioctl.h
+++ b/include/windows/sys/ioctl.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2014 Cloudbase Solutions Srl
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __SYS_IOCTL_H
+#define __SYS_IOCTL_H 1
+
+__inline int ioctl(int d, unsigned long request, ...)
+{
+ _set_errno(ENOMEM);
+ return -1;
+}
+
+int
+__inline af_inet_ioctl(unsigned long int command, const void *arg)
+{
+ _set_errno(ENOMEM);
+ return -1;
+}
+
+int
+__inline af_inet_ifreq_ioctl(const char *name, struct ifreq *ifr,
+ unsigned long int cmd, const char *cmd_name)
+{
+ _set_errno(ENOMEM);
+ return -1;
+}
+
+#endif /* sys/ioctl.h */
diff --git a/include/windows/sys/socket.h b/include/windows/sys/socket.h
index ab6e822..953a9c9 100644
--- a/include/windows/sys/socket.h
+++ b/include/windows/sys/socket.h
@@ -19,4 +19,9 @@
typedef unsigned short int sa_family_t;
+#define PF_NETLINK 16
+#define AF_NETLINK 16
+#define SO_RCVBUFFORCE 33
+#define MSG_DONTWAIT MSG_DONTROUTE
+
#endif /* sys/socket.h */
diff --git a/include/windows/sys/uio.h b/include/windows/sys/uio.h
index e69de29..e92a772 100644
--- a/include/windows/sys/uio.h
+++ b/include/windows/sys/uio.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2014 Cloudbase Solutions Srl
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __SYS_UIO_H
+#define __SYS_UIO_H 1
+
+#include <netpacket/packet.h>
+
+#endif /* sys/uio.h */
diff --git a/include/windows/unistd.h b/include/windows/unistd.h
index d9ded5a..de67621 100644
--- a/include/windows/unistd.h
+++ b/include/windows/unistd.h
@@ -16,6 +16,11 @@
#ifndef _UNISTD_H
#define _UNISTD_H 1
+#include <WinSock2.h>
+#include <stdlib.h>
+#include <time.h>
+#include <io.h>
+
#define fsync _commit
/* Standard file descriptors. */
@@ -23,4 +28,51 @@
#define STDOUT_FILENO 1 /* Standard output. */
#define STDERR_FILENO 2 /* Standard error output. */
+#define _SC_UIO_MAXIOV 2
+#define _XOPEN_IOV_MAX _POSIX_UIO_MAXIOV
+#define _POSIX_UIO_MAXIOV 16
+
+#define _SC_PAGESIZE 0x1
+#define _SC_NPROCESSORS_ONLN 0x2
+#define _SC_PHYS_PAGES 0x4
+
+__inline int GetNumLogicalProcessors(void)
+{
+ SYSTEM_INFO info_temp;
+ GetSystemInfo(&info_temp);
+ long int n_cores = info_temp.dwNumberOfProcessors;
+ return n_cores;
+}
+
+__inline long sysconf(int name)
+{
+ long val = -1;
+ long val2 = -1;
+ SYSTEM_INFO sysInfo;
+ MEMORYSTATUSEX status;
+
+ switch (name)
+ {
+ case _SC_NPROCESSORS_ONLN:
+ val = GetNumLogicalProcessors();
+ break;
+
+ case _SC_PAGESIZE:
+ GetSystemInfo(&sysInfo);
+ val = sysInfo.dwPageSize;
+ break;
+
+ case _SC_PHYS_PAGES:
+ status.dwLength = sizeof(status);
+ val2 = sysconf(_SC_PAGESIZE);
+ if (GlobalMemoryStatusEx(&status) && val2 != -1)
+ val = status.ullTotalPhys / val2;
+ break;
+ default:
+ break;
+ }
+
+ return val;
+}
+
#endif /* unistd.h */
--
1.9.0.msysgit.0
More information about the dev
mailing list