Add defines, enums and headers for MSVC
authorAlin Serdean <aserdean@cloudbasesolutions.com>
Tue, 29 Jul 2014 15:21:16 +0000 (15:21 +0000)
committerBen Pfaff <blp@nicira.com>
Tue, 29 Jul 2014 16:28:31 +0000 (09:28 -0700)
Add defines needed to compile netlink-socket.c and netlink.c.

Add a wrapper and the functionality behind it for syconf.

Add the newly created files to the noinst_HEADERS in windows/automake.mk

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
include/windows/automake.mk
include/windows/net/if.h
include/windows/netpacket/packet.h [new file with mode: 0644]
include/windows/sys/uio.h
include/windows/unistd.h

index 4d5a42c..2f1b631 100644 (file)
@@ -11,6 +11,7 @@ noinst_HEADERS += \
        include/windows/getopt.h \
        include/windows/net/if.h \
        include/windows/netdb.h \
+       include/windows/netpacket/packet.h \
        include/windows/netinet/icmp6.h \
        include/windows/netinet/in.h \
        include/windows/netinet/in_systm.h \
index 893ffe4..3a064ae 100644 (file)
 
 #define IFNAMSIZ IF_NAMESIZE
 
+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,
+#define IFLA_WIRELESS IFLA_WIRELESS
+    IFLA_PROTINFO,
+#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,
+    IFLA_VFINFO_LIST,
+    IFLA_STATS64,
+    IFLA_VF_PORTS,
+    IFLA_PORT_SELF,
+    IFLA_AF_SPEC,
+    IFLA_GROUP,
+    IFLA_NET_NS_FD,
+    IFLA_EXT_MASK,
+    IFLA_PROMISCUITY,
+#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/netpacket/packet.h b/include/windows/netpacket/packet.h
new file mode 100644 (file)
index 0000000..cf26a70
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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
+
+struct iovec
+{
+    void *iov_base;
+    unsigned int iov_len;
+};
+
+struct msghdr
+  {
+    void *msg_name;
+    socklen_t msg_namelen;
+
+    struct iovec *msg_iov;
+    size_t msg_iovlen;
+
+    void *msg_control;
+    size_t msg_controllen;
+
+    int msg_flags;
+  };
+
+#endif /* netpacket/packet.h */
\ No newline at end of file
index e69de29..b51c367 100644 (file)
@@ -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 */
\ No newline at end of file
index d9ded5a..8629f7e 100644 (file)
@@ -16,6 +16,9 @@
 #ifndef _UNISTD_H
 #define _UNISTD_H   1
 
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
 #define fsync _commit
 
 /* Standard file descriptors.  */
 #define STDOUT_FILENO   1   /* Standard output.  */
 #define STDERR_FILENO   2   /* Standard error output.  */
 
+#define _SC_UIO_MAXIOV                  2
+#define _XOPEN_IOV_MAX                 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 type)
+{
+    long value = -1;
+    long page_size = -1;
+    SYSTEM_INFO sys_info;
+    MEMORYSTATUSEX status;
+
+    switch (type) {
+    case _SC_NPROCESSORS_ONLN:
+        value = GetNumLogicalProcessors();
+        break;
+
+    case _SC_PAGESIZE:
+        GetSystemInfo(&sys_info);
+        value = sys_info.dwPageSize;
+        break;
+
+    case _SC_PHYS_PAGES:
+        status.dwLength = sizeof(status);
+        page_size = sysconf(_SC_PAGESIZE);
+        if (GlobalMemoryStatusEx(&status) && page_size != -1) {
+            value = status.ullTotalPhys / page_size;
+        }
+        break;
+
+    default:
+        break;
+    }
+
+    return value;
+}
+
 #endif /* unistd.h  */