[ovs-dev] [PATCH 08/14] socket-util: Unix socket related calls for non-windows platform.

Gurucharan Shetty shettyg at nicira.com
Wed Feb 19 23:36:19 UTC 2014


Don't try to compile Unix socket related functions for Windows.

Signed-off-by: Gurucharan Shetty <gshetty at nicira.com>
---
 lib/automake.mk   |    4 ++--
 lib/socket-util.c |    4 ++++
 lib/socket-util.h |    4 ++--
 lib/stream.c      |    4 ++++
 4 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/lib/automake.mk b/lib/automake.mk
index 4ecd61d..6c5ad8d 100644
--- a/lib/automake.mk
+++ b/lib/automake.mk
@@ -193,7 +193,6 @@ lib_libopenvswitch_la_SOURCES = \
 	lib/stream-provider.h \
 	lib/stream-ssl.h \
 	lib/stream-tcp.c \
-	lib/stream-unix.c \
 	lib/stream.c \
 	lib/stream.h \
 	lib/stdio.c \
@@ -244,7 +243,8 @@ lib_libopenvswitch_la_SOURCES += \
 else
 lib_libopenvswitch_la_SOURCES += \
 	lib/daemon.c \
-	lib/latch.c
+	lib/latch.c \
+	lib/stream-unix.c
 endif
 
 EXTRA_DIST += \
diff --git a/lib/socket-util.c b/lib/socket-util.c
index 88b8c24..4ec7201 100644
--- a/lib/socket-util.c
+++ b/lib/socket-util.c
@@ -412,6 +412,7 @@ drain_fd(int fd, size_t n_packets)
     }
 }
 
+#ifndef _WIN32
 /* Attempts to shorten 'name' by opening a file descriptor for the directory
  * part of the name and indirecting through /proc/self/fd/<dirfd>/<basename>.
  * On systems with Linux-like /proc, this works as long as <basename> isn't too
@@ -672,6 +673,7 @@ get_unix_name_len(socklen_t sun_len)
             ? sun_len - offsetof(struct sockaddr_un, sun_path)
             : 0);
 }
+#endif /* _WIN32 */
 
 ovs_be32
 guess_netmask(ovs_be32 ip_)
@@ -1197,6 +1199,7 @@ describe_sockaddr(struct ds *string, int fd,
             ds_put_format(string, "%s:%"PRIu16,
                           ss_format_address(&ss, addrbuf, sizeof addrbuf),
                           ss_get_port(&ss));
+#ifndef _WIN32
         } else if (ss.ss_family == AF_UNIX) {
             struct sockaddr_un sun;
             const char *null;
@@ -1207,6 +1210,7 @@ describe_sockaddr(struct ds *string, int fd,
             null = memchr(sun.sun_path, '\0', maxlen);
             ds_put_buffer(string, sun.sun_path,
                           null ? null - sun.sun_path : maxlen);
+#endif
         }
 #ifdef HAVE_NETLINK
         else if (ss.ss_family == AF_NETLINK) {
diff --git a/lib/socket-util.h b/lib/socket-util.h
index b4bd978..cf2f96d 100644
--- a/lib/socket-util.h
+++ b/lib/socket-util.h
@@ -40,13 +40,13 @@ int lookup_hostname(const char *host_name, struct in_addr *);
 
 int get_socket_rcvbuf(int sock);
 int check_connection_completion(int fd);
+void drain_fd(int fd, size_t n_packets);
 #ifndef _WIN32
 int drain_rcvbuf(int fd);
-#endif
-void drain_fd(int fd, size_t n_packets);
 int make_unix_socket(int style, bool nonblock,
                      const char *bind_path, const char *connect_path);
 int get_unix_name_len(socklen_t sun_len);
+#endif
 ovs_be32 guess_netmask(ovs_be32 ip);
 int get_null_fd(void);
 
diff --git a/lib/stream.c b/lib/stream.c
index b69f03c..1dfecf0 100644
--- a/lib/stream.c
+++ b/lib/stream.c
@@ -51,7 +51,9 @@ enum stream_state {
 
 static const struct stream_class *stream_classes[] = {
     &tcp_stream_class,
+#ifndef _WIN32
     &unix_stream_class,
+#endif
 #ifdef HAVE_OPENSSL
     &ssl_stream_class,
 #endif
@@ -59,7 +61,9 @@ static const struct stream_class *stream_classes[] = {
 
 static const struct pstream_class *pstream_classes[] = {
     &ptcp_pstream_class,
+#ifndef _WIN32
     &punix_pstream_class,
+#endif
 #ifdef HAVE_OPENSSL
     &pssl_pstream_class,
 #endif
-- 
1.7.9.5




More information about the dev mailing list