[ovs-dev] [PATCH 14/14] Add sockaddr_nl back to netlink-protocol.h

Alin Serdean aserdean at cloudbasesolutions.com
Fri Jul 11 01:08:48 UTC 2014


Add the structure sockaddr_nl to netlink-protocol.h for MSVC. Also remove
some warnings in netlink-socket.c when using MSVC.

Signed-off-by: Alin Gabriel Serdean <aserdean at cloudbasesolutions.com>
---
 lib/netlink-protocol.h | 10 ++++++++++
 lib/netlink-socket.c   |  4 ++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/lib/netlink-protocol.h b/lib/netlink-protocol.h
index ea1b872..2a35e6b 100644
--- a/lib/netlink-protocol.h
+++ b/lib/netlink-protocol.h
@@ -40,6 +40,16 @@
 #else
 #define NETLINK_GENERIC         16
 
+#ifdef _WIN32
+struct sockaddr_nl {
+    sa_family_t nl_family;
+    unsigned short int nl_pad;
+    uint32_t nl_pid;
+    uint32_t nl_groups;
+};
+BUILD_ASSERT_DECL(sizeof(struct sockaddr_nl) == 12);
+#endif
+
 /* nlmsg_flags bits. */
 #define NLM_F_REQUEST           0x001
 #define NLM_F_MULTI             0x002
diff --git a/lib/netlink-socket.c b/lib/netlink-socket.c
index a320895..156fe89 100644
--- a/lib/netlink-socket.c
+++ b/lib/netlink-socket.c
@@ -150,7 +150,7 @@ nl_sock_create(int protocol, struct nl_sock **sockp)
                                FILE_SHARE_READ | FILE_SHARE_WRITE,
                                NULL, OPEN_EXISTING,
                                FILE_ATTRIBUTE_NORMAL, NULL);
-    sock->fd = hConn;
+    sock->fd = (int)hConn;
 #else
     sock->fd = socket(AF_NETLINK, SOCK_RAW, protocol);
     if (sock->fd < 0) {
@@ -190,7 +190,7 @@ nl_sock_create(int protocol, struct nl_sock **sockp)
     remote.nl_pid = 0;
     if (connect(sock->fd, (struct sockaddr *) &remote, sizeof remote) < 0) {
 #else
-    if (sock->fd == INVALID_HANDLE_VALUE) {
+    if (((HANDLE)sock->fd) == INVALID_HANDLE_VALUE) {
 #endif
         VLOG_ERR("connect(0): %s", ovs_strerror(errno));
         goto error;
-- 
1.9.0.msysgit.0




More information about the dev mailing list