[SCM] Samba Shared Repository - branch master updated

Andreas Schneider asn at samba.org
Thu Oct 2 04:01:33 MDT 2014


The branch, master has been updated
       via  47f307d swrap: Bump version to 1.1.2.
       via  afe2f47 swrap: Add support for eventfd with unsigned count variable.
       via  539fa2c swrap: Add a trace message for swrap_socket().
       via  8efc095 swrap: Implement fcntl() to catch F_DUPFD.
       via  2efd5b2 swrap: Include the function name in the debug output.
       via  872e1ae swrap: Silence alignment warnings.
       via  088db7f swrap: Fix type punning warnings when loading functions.
       via  b3c72e1 swrap: Fix access to struct members in log messages.
       via  9ba259e swrap: Fix whitespace errors.
       via  a504686 swrap: Update copyright notice.
       via  9731516 swrap: Wrap fopen to detect stale file descriptors.
       via  f8584ab swrap: Use swrap_address in swrap_accept().
       via  891e837 swrap: Remove unused sockaddr_dup() function.
       via  8897474 swrap: Use swrap_address in the socket_info struct.
       via  4402ba1 swrap: Use a sockaddr_un for the unix path in socket_info.
       via  9da1ff9 swrap: Rename swrap_pcap_dump_packet().
       via  79e545b swrap: Rename swrap_pcap_get_fd().
       via  7d4c6cf swrap: Rename swrap_marshall_packet().
       via  e64ea9c swrap: Rename swrap_packet_init().
       via  c626aad swrap: Rename socket_wrapper_pcap_file().
       via  2be25ab swrap: Fix type punning warnings.
       via  95c9917 Provide a compatible declaration of CMSG_ALIGN
       via  5e70d80 SO_PROTOCOL is platform-dependent
       via  6163643 swrap: fix another discard const warning in swrap_bind()
       via  f6fe9a9 swrap: fix discard const warning in swrap_bind()
       via  bebbd28 swrap: fix discard const warning in swrap_remove_stale()
       via  a7a4779 swrap: fix build when neither HAVE_STRUCT_IN_PKTINFO nor IP_RECVDSTADDR is defined
      from  6c05cd3 s3: smb2cli: query info return length check was reversed.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 47f307d112a4eaec0d375ee1604c13ed7449b3c4
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Oct 2 07:26:35 2014 +0200

    swrap: Bump version to 1.1.2.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Matthieu Patou <mat at matws.net>
    
    Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
    Autobuild-Date(master): Thu Oct  2 12:00:14 CEST 2014 on sn-devel-104

commit afe2f47c0fd17c215857e800296de795d48c004d
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Oct 2 07:25:32 2014 +0200

    swrap: Add support for eventfd with unsigned count variable.
    
    The prototype in glibc 2.20.90 changed.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 539fa2c04f6220e72a63ab492fae298c86b00954
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Oct 2 07:24:55 2014 +0200

    swrap: Add a trace message for swrap_socket().
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 8efc0952adda9273e90ffbbc0c691c9ff4b9b947
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Oct 2 07:24:27 2014 +0200

    swrap: Implement fcntl() to catch F_DUPFD.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 2efd5b242928c2e048b5421d52e35dd2e13dca15
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Oct 2 07:23:53 2014 +0200

    swrap: Include the function name in the debug output.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 872e1ae0ef22f659f52241c753f7f9b1b6f5b279
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Oct 2 07:23:25 2014 +0200

    swrap: Silence alignment warnings.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 088db7f7b561c1b87a890359c67b551bc1a48593
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Oct 2 07:22:59 2014 +0200

    swrap: Fix type punning warnings when loading functions.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit b3c72e151f5dc479e600118dbdca2fdc006dbd83
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Oct 2 07:22:13 2014 +0200

    swrap: Fix access to struct members in log messages.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 9ba259e68aa755037a1a720da3662fe07a0a7ee4
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Oct 2 07:20:53 2014 +0200

    swrap: Fix whitespace errors.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit a5046865661f814bab8af7f84f8ebd81a62067b7
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Oct 2 07:20:15 2014 +0200

    swrap: Update copyright notice.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 9731516e7f87cc16412eb830840d0393e8a4f823
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Oct 2 07:18:48 2014 +0200

    swrap: Wrap fopen to detect stale file descriptors.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit f8584abfef0974a19547927258369b04e03d6336
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Oct 2 07:18:14 2014 +0200

    swrap: Use swrap_address in swrap_accept().
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 891e837c3c0ca3db2ae2d59d04296aa67eb25d3a
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Oct 2 07:17:42 2014 +0200

    swrap: Remove unused sockaddr_dup() function.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 889747486560e71d27c5a5255c825c4ebd62f8f9
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Oct 2 07:17:10 2014 +0200

    swrap: Use swrap_address in the socket_info struct.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 4402ba10b5afc57e72b45ce640c14764d5f0f2c7
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Oct 2 07:16:25 2014 +0200

    swrap: Use a sockaddr_un for the unix path in socket_info.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 9da1ff9ad1d7983bd11693263f3dfcd1ed9685d4
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Oct 2 07:15:38 2014 +0200

    swrap: Rename swrap_pcap_dump_packet().
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 79e545b304db8b3fa6fcb21a6f1e023e0ae0f3b4
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Oct 2 07:14:44 2014 +0200

    swrap: Rename swrap_pcap_get_fd().
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 7d4c6cf25d5f424156fa0a6f90673744c5eba18e
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Oct 2 07:14:04 2014 +0200

    swrap: Rename swrap_marshall_packet().
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit e64ea9cb79b804c299d0213b2cca207fb000a3b8
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Oct 2 07:13:10 2014 +0200

    swrap: Rename swrap_packet_init().
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit c626aad36a9757d584b9f10f0ba55dda72499c50
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Oct 2 07:11:49 2014 +0200

    swrap: Rename socket_wrapper_pcap_file().
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 2be25abcb13353c26712ec8bc50f65ad53d390d4
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Oct 2 07:09:33 2014 +0200

    swrap: Fix type punning warnings.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 95c9917c8638f1eb5480e851c8dfbb808f1687bd
Author: Jakub Hrozek <jakub.hrozek at gmail.com>
Date:   Thu Oct 2 07:05:35 2014 +0200

    Provide a compatible declaration of CMSG_ALIGN
    
    Some platforms (like OSX) do support some of the CMGS macros, but don't
    have a CMSG_ALIGN macro of their own.
    
    Signed-off-by: Jakub Hrozek <jakub.hrozek at gmail.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 5e70d80e7d7752a1df16b871d57fbcd8334a44e6
Author: Jakub Hrozek <jakub.hrozek at gmail.com>
Date:   Thu Oct 2 07:04:15 2014 +0200

    SO_PROTOCOL is platform-dependent
    
    SO_PROTOCOL is not defined on all platforms. In particular, OSX doesn't
    include it and so far I haven't found any compatible declaration.
    
    Signed-off-by: Jakub Hrozek <jakub.hrozek at gmail.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 616364378da073f841d46fb299c81adb05d5222d
Author: Michael Adam <obnox at samba.org>
Date:   Thu Oct 2 07:03:22 2014 +0200

    swrap: fix another discard const warning in swrap_bind()
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit f6fe9a997d2f5a1c504ea53886e00cfb33ec76d0
Author: Michael Adam <obnox at samba.org>
Date:   Thu Oct 2 07:02:36 2014 +0200

    swrap: fix discard const warning in swrap_bind()
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit bebbd289859cff50d63cdbe76d214b67fd33e3f8
Author: Michael Adam <obnox at samba.org>
Date:   Thu Oct 2 07:01:34 2014 +0200

    swrap: fix discard const warning in swrap_remove_stale()
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit a7a47796fd7ca1fa830a8c2644042c311b9796da
Author: Michael Adam <obnox at samba.org>
Date:   Thu Oct 2 07:00:44 2014 +0200

    swrap: fix build when neither HAVE_STRUCT_IN_PKTINFO nor IP_RECVDSTADDR is defined
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 lib/socket_wrapper/socket_wrapper.c |  824 +++++++++++++++++++++--------------
 lib/socket_wrapper/wscript          |    2 +-
 2 files changed, 506 insertions(+), 320 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/socket_wrapper/socket_wrapper.c b/lib/socket_wrapper/socket_wrapper.c
index afd9343..d5c343d 100644
--- a/lib/socket_wrapper/socket_wrapper.c
+++ b/lib/socket_wrapper/socket_wrapper.c
@@ -1,7 +1,7 @@
 /*
- * Copyright (C) Jelmer Vernooij 2005,2008 <jelmer at samba.org>
- * Copyright (C) Stefan Metzmacher 2006-2009 <metze at samba.org>
- * Copyright (C) Andreas Schneider 2013 <asn at samba.org>
+ * Copyright (c) 2005-2008 Jelmer Vernooij <jelmer at samba.org>
+ * Copyright (C) 2006-2014 Stefan Metzmacher <metze at samba.org>
+ * Copyright (C) 2013-2014 Andreas Schneider <asn at samba.org>
  *
  * All rights reserved.
  *
@@ -210,6 +210,19 @@ enum swrap_dbglvl_e {
  * without changing the format above */
 #define MAX_WRAPPED_INTERFACES 40
 
+struct swrap_address {
+	socklen_t sa_socklen;
+	union {
+		struct sockaddr s;
+		struct sockaddr_in in;
+#ifdef HAVE_IPV6
+		struct sockaddr_in6 in6;
+#endif
+		struct sockaddr_un un;
+		struct sockaddr_storage ss;
+	} sa;
+};
+
 struct socket_info_fd {
 	struct socket_info_fd *prev, *next;
 	int fd;
@@ -229,16 +242,12 @@ struct socket_info
 	int defer_connect;
 	int pktinfo;
 
-	char *tmp_path;
-
-	struct sockaddr *bindname;
-	socklen_t bindname_len;
-
-	struct sockaddr *myname;
-	socklen_t myname_len;
+	/* The unix path so we can unlink it on close() */
+	struct sockaddr_un un_addr;
 
-	struct sockaddr *peername;
-	socklen_t peername_len;
+	struct swrap_address bindname;
+	struct swrap_address myname;
+	struct swrap_address peername;
 
 	struct {
 		unsigned long pck_snd;
@@ -263,10 +272,12 @@ void swrap_destructor(void) DESTRUCTOR_ATTRIBUTE;
 # define SWRAP_LOG(...)
 #else
 
-static void swrap_log(enum swrap_dbglvl_e dbglvl, const char *format, ...) PRINTF_ATTRIBUTE(2, 3);
-# define SWRAP_LOG(dbglvl, ...) swrap_log((dbglvl), __VA_ARGS__)
+static void swrap_log(enum swrap_dbglvl_e dbglvl, const char *func, const char *format, ...) PRINTF_ATTRIBUTE(3, 4);
+# define SWRAP_LOG(dbglvl, ...) swrap_log((dbglvl), __func__, __VA_ARGS__)
 
-static void swrap_log(enum swrap_dbglvl_e dbglvl, const char *format, ...)
+static void swrap_log(enum swrap_dbglvl_e dbglvl,
+		      const char *func,
+		      const char *format, ...)
 {
 	char buffer[1024];
 	va_list va;
@@ -286,23 +297,23 @@ static void swrap_log(enum swrap_dbglvl_e dbglvl, const char *format, ...)
 		switch (dbglvl) {
 			case SWRAP_LOG_ERROR:
 				fprintf(stderr,
-					"SWRAP_ERROR(%d): %s\n",
-					(int)getpid(), buffer);
+					"SWRAP_ERROR(%d) - %s: %s\n",
+					(int)getpid(), func, buffer);
 				break;
 			case SWRAP_LOG_WARN:
 				fprintf(stderr,
-					"SWRAP_WARN(%d): %s\n",
-					(int)getpid(), buffer);
+					"SWRAP_WARN(%d) - %s: %s\n",
+					(int)getpid(), func, buffer);
 				break;
 			case SWRAP_LOG_DEBUG:
 				fprintf(stderr,
-					"SWRAP_DEBUG(%d): %s\n",
-					(int)getpid(), buffer);
+					"SWRAP_DEBUG(%d) - %s: %s\n",
+					(int)getpid(), func, buffer);
 				break;
 			case SWRAP_LOG_TRACE:
 				fprintf(stderr,
-					"SWRAP_TRACE(%d): %s\n",
-					(int)getpid(), buffer);
+					"SWRAP_TRACE(%d) - %s: %s\n",
+					(int)getpid(), func, buffer);
 				break;
 		}
 	}
@@ -328,6 +339,8 @@ struct swrap_libc_fns {
 			    socklen_t addrlen);
 	int (*libc_dup)(int fd);
 	int (*libc_dup2)(int oldfd, int newfd);
+	int (*libc_fcntl)(int fd, int cmd, ...);
+	FILE *(*libc_fopen)(const char *name, const char *mode);
 #ifdef HAVE_EVENTFD
 	int (*libc_eventfd)(int count, int flags);
 #endif
@@ -510,8 +523,9 @@ static void *_swrap_load_lib_function(enum swrap_lib lib, const char *fn_name)
 
 #define swrap_load_lib_function(lib, fn_name) \
 	if (swrap.fns.libc_##fn_name == NULL) { \
+		void *swrap_cast_ptr = _swrap_load_lib_function(lib, #fn_name); \
 		*(void **) (&swrap.fns.libc_##fn_name) = \
-			_swrap_load_lib_function(lib, #fn_name); \
+			swrap_cast_ptr; \
 	}
 
 
@@ -578,6 +592,28 @@ static int libc_eventfd(int count, int flags)
 }
 #endif
 
+static int libc_vfcntl(int fd, int cmd, va_list ap)
+{
+	long int args[4];
+	int rc;
+	int i;
+
+	swrap_load_lib_function(SWRAP_LIBC, fcntl);
+
+	for (i = 0; i < 4; i++) {
+		args[i] = va_arg(ap, long int);
+	}
+
+	rc = swrap.fns.libc_fcntl(fd,
+				  cmd,
+				  args[0],
+				  args[1],
+				  args[2],
+				  args[3]);
+
+	return rc;
+}
+
 static int libc_getpeername(int sockfd,
 			    struct sockaddr *addr,
 			    socklen_t *addrlen)
@@ -636,6 +672,13 @@ static int libc_listen(int sockfd, int backlog)
 	return swrap.fns.libc_listen(sockfd, backlog);
 }
 
+static FILE *libc_fopen(const char *name, const char *mode)
+{
+	swrap_load_lib_function(SWRAP_LIBC, fopen);
+
+	return swrap.fns.libc_fopen(name, mode);
+}
+
 static int libc_vopen(const char *pathname, int flags, va_list ap)
 {
 	long int mode = 0;
@@ -813,22 +856,15 @@ static const struct in6_addr *swrap_ipv6(void)
 }
 #endif
 
-static struct sockaddr *sockaddr_dup(const void *data, socklen_t len)
-{
-	struct sockaddr *ret = (struct sockaddr *)malloc(len);
-	memcpy(ret, data, len);
-	return ret;
-}
-
-static void set_port(int family, int prt, struct sockaddr *addr)
+static void set_port(int family, int prt, struct swrap_address *addr)
 {
 	switch (family) {
 	case AF_INET:
-		((struct sockaddr_in *)addr)->sin_port = htons(prt);
+		addr->sa.in.sin_port = htons(prt);
 		break;
 #ifdef HAVE_IPV6
 	case AF_INET6:
-		((struct sockaddr_in6 *)addr)->sin6_port = htons(prt);
+		addr->sa.in6.sin6_port = htons(prt);
 		break;
 #endif
 	}
@@ -970,7 +1006,7 @@ static int convert_in_un_remote(struct socket_info *si, const struct sockaddr *i
 
 	switch (inaddr->sa_family) {
 	case AF_INET: {
-		const struct sockaddr_in *in = 
+		const struct sockaddr_in *in =
 		    (const struct sockaddr_in *)(const void *)inaddr;
 		unsigned int addr = ntohl(in->sin_addr.s_addr);
 		char u_type = '\0';
@@ -1017,7 +1053,7 @@ static int convert_in_un_remote(struct socket_info *si, const struct sockaddr *i
 	}
 #ifdef HAVE_IPV6
 	case AF_INET6: {
-		const struct sockaddr_in6 *in = 
+		const struct sockaddr_in6 *in =
 		    (const struct sockaddr_in6 *)(const void *)inaddr;
 		struct in6_addr cmp1, cmp2;
 
@@ -1064,14 +1100,14 @@ static int convert_in_un_remote(struct socket_info *si, const struct sockaddr *i
 	}
 
 	if (is_bcast) {
-		snprintf(un->sun_path, sizeof(un->sun_path), "%s/EINVAL", 
+		snprintf(un->sun_path, sizeof(un->sun_path), "%s/EINVAL",
 			 socket_wrapper_dir());
 		SWRAP_LOG(SWRAP_LOG_DEBUG, "un path [%s]", un->sun_path);
 		/* the caller need to do more processing */
 		return 0;
 	}
 
-	snprintf(un->sun_path, sizeof(un->sun_path), "%s/"SOCKET_FORMAT, 
+	snprintf(un->sun_path, sizeof(un->sun_path), "%s/"SOCKET_FORMAT,
 		 socket_wrapper_dir(), type, iface, prt);
 	SWRAP_LOG(SWRAP_LOG_DEBUG, "un path [%s]", un->sun_path);
 
@@ -1091,7 +1127,7 @@ static int convert_in_un_alloc(struct socket_info *si, const struct sockaddr *in
 
 	switch (si->family) {
 	case AF_INET: {
-		const struct sockaddr_in *in = 
+		const struct sockaddr_in *in =
 		    (const struct sockaddr_in *)(const void *)inaddr;
 		unsigned int addr = ntohl(in->sin_addr.s_addr);
 		char u_type = '\0';
@@ -1144,7 +1180,7 @@ static int convert_in_un_alloc(struct socket_info *si, const struct sockaddr *in
 		}
 
 		/* Store the bind address for connect() */
-		if (si->bindname == NULL) {
+		if (si->bindname.sa_socklen == 0) {
 			struct sockaddr_in bind_in;
 			socklen_t blen = sizeof(struct sockaddr_in);
 
@@ -1153,15 +1189,15 @@ static int convert_in_un_alloc(struct socket_info *si, const struct sockaddr *in
 			bind_in.sin_port = in->sin_port;
 			bind_in.sin_addr.s_addr = htonl(0x7F000000 | iface);
 
-			si->bindname = sockaddr_dup(&bind_in, blen);
-			si->bindname_len = blen;
+			si->bindname.sa_socklen = blen;
+			memcpy(&si->bindname.sa.in, &bind_in, blen);
 		}
 
 		break;
 	}
 #ifdef HAVE_IPV6
 	case AF_INET6: {
-		const struct sockaddr_in6 *in = 
+		const struct sockaddr_in6 *in =
 		    (const struct sockaddr_in6 *)(const void *)inaddr;
 		struct in6_addr cmp1, cmp2;
 
@@ -1195,7 +1231,7 @@ static int convert_in_un_alloc(struct socket_info *si, const struct sockaddr *in
 		}
 
 		/* Store the bind address for connect() */
-		if (si->bindname == NULL) {
+		if (si->bindname.sa_socklen == 0) {
 			struct sockaddr_in6 bind_in;
 			socklen_t blen = sizeof(struct sockaddr_in6);
 
@@ -1206,8 +1242,8 @@ static int convert_in_un_alloc(struct socket_info *si, const struct sockaddr *in
 			bind_in.sin6_addr = *swrap_ipv6();
 			bind_in.sin6_addr.s6_addr[15] = iface;
 
-			si->bindname = sockaddr_dup(&bind_in, blen);
-			si->bindname_len = blen;
+			memcpy(&si->bindname.sa.in6, &bind_in, blen);
+			si->bindname.sa_socklen = blen;
 		}
 
 		break;
@@ -1230,12 +1266,12 @@ static int convert_in_un_alloc(struct socket_info *si, const struct sockaddr *in
 	if (prt == 0) {
 		/* handle auto-allocation of ephemeral ports */
 		for (prt = 5001; prt < 10000; prt++) {
-			snprintf(un->sun_path, sizeof(un->sun_path), "%s/"SOCKET_FORMAT, 
+			snprintf(un->sun_path, sizeof(un->sun_path), "%s/"SOCKET_FORMAT,
 				 socket_wrapper_dir(), type, iface, prt);
 			if (stat(un->sun_path, &st) == 0) continue;
 
-			set_port(si->family, prt, si->myname);
-			set_port(si->family, prt, si->bindname);
+			set_port(si->family, prt, &si->myname);
+			set_port(si->family, prt, &si->bindname);
 
 			break;
 		}
@@ -1245,7 +1281,7 @@ static int convert_in_un_alloc(struct socket_info *si, const struct sockaddr *in
 		}
 	}
 
-	snprintf(un->sun_path, sizeof(un->sun_path), "%s/"SOCKET_FORMAT, 
+	snprintf(un->sun_path, sizeof(un->sun_path), "%s/"SOCKET_FORMAT,
 		 socket_wrapper_dir(), type, iface, prt);
 	SWRAP_LOG(SWRAP_LOG_DEBUG, "un path [%s]", un->sun_path);
 	return 0;
@@ -1394,14 +1430,14 @@ static int sockaddr_convert_to_un(struct socket_info *si,
 
 	switch (in_addr->sa_family) {
 	case AF_UNSPEC: {
-		struct sockaddr_in *sin;
+		const struct sockaddr_in *sin;
 		if (si->family != AF_INET) {
 			break;
 		}
 		if (in_len < sizeof(struct sockaddr_in)) {
 			break;
 		}
-		sin = (struct sockaddr_in *)in_addr;
+		sin = (const struct sockaddr_in *)(const void *)in_addr;
 		if(sin->sin_addr.s_addr != htonl(INADDR_ANY)) {
 			break;
 		}
@@ -1440,8 +1476,8 @@ static int sockaddr_convert_to_un(struct socket_info *si,
 	return -1;
 }
 
-static int sockaddr_convert_from_un(const struct socket_info *si, 
-				    const struct sockaddr_un *in_addr, 
+static int sockaddr_convert_from_un(const struct socket_info *si,
+				    const struct sockaddr_un *in_addr,
 				    socklen_t un_addrlen,
 				    int family,
 				    struct sockaddr *out_addr,
@@ -1449,7 +1485,7 @@ static int sockaddr_convert_from_un(const struct socket_info *si,
 {
 	int ret;
 
-	if (out_addr == NULL || out_addrlen == NULL) 
+	if (out_addr == NULL || out_addrlen == NULL)
 		return 0;
 
 	if (un_addrlen == 0) {
@@ -1597,7 +1633,7 @@ union swrap_packet_payload {
 	 SWRAP_PACKET_IP_SIZE + \
 	 SWRAP_PACKET_PAYLOAD_SIZE)
 
-static const char *socket_wrapper_pcap_file(void)
+static const char *swrap_pcap_init_file(void)
 {
 	static int initialized = 0;
 	static const char *s = NULL;
@@ -1614,7 +1650,7 @@ static const char *socket_wrapper_pcap_file(void)
 	/*
 	 * TODO: don't use the structs use plain buffer offsets
 	 *       and PUSH_U8(), PUSH_U16() and PUSH_U32()
-	 * 
+	 *
 	 * for now make sure we disable PCAP support
 	 * if the struct has alignment!
 	 */
@@ -1659,17 +1695,17 @@ static const char *socket_wrapper_pcap_file(void)
 	return s;
 }
 
-static uint8_t *swrap_packet_init(struct timeval *tval,
-				  const struct sockaddr *src,
-				  const struct sockaddr *dest,
-				  int socket_type,
-				  const uint8_t *payload,
-				  size_t payload_len,
-				  unsigned long tcp_seqno,
-				  unsigned long tcp_ack,
-				  unsigned char tcp_ctl,
-				  int unreachable,
-				  size_t *_packet_len)
+static uint8_t *swrap_pcap_packet_init(struct timeval *tval,
+				       const struct sockaddr *src,
+				       const struct sockaddr *dest,
+				       int socket_type,
+				       const uint8_t *payload,
+				       size_t payload_len,
+				       unsigned long tcp_seqno,
+				       unsigned long tcp_ack,
+				       unsigned char tcp_ctl,
+				       int unreachable,
+				       size_t *_packet_len)
 {
 	uint8_t *base;
 	uint8_t *buf;
@@ -1696,16 +1732,16 @@ static uint8_t *swrap_packet_init(struct timeval *tval,
 
 	switch (src->sa_family) {
 	case AF_INET:
-		src_in = (const struct sockaddr_in *)src;
-		dest_in = (const struct sockaddr_in *)dest;
+		src_in = (const struct sockaddr_in *)(const void *)src;
+		dest_in = (const struct sockaddr_in *)(const void *)dest;
 		src_port = src_in->sin_port;
 		dest_port = dest_in->sin_port;
 		ip_hdr_len = sizeof(ip->v4);
 		break;
 #ifdef HAVE_IPV6
 	case AF_INET6:
-		src_in6 = (const struct sockaddr_in6 *)src;
-		dest_in6 = (const struct sockaddr_in6 *)dest;
+		src_in6 = (const struct sockaddr_in6 *)(const void *)src;
+		dest_in6 = (const struct sockaddr_in6 *)(const void *)dest;
 		src_port = src_in6->sin6_port;
 		dest_port = dest_in6->sin6_port;
 		ip_hdr_len = sizeof(ip->v6);
@@ -1767,14 +1803,14 @@ static uint8_t *swrap_packet_init(struct timeval *tval,
 
 	buf = base;
 
-	frame = (struct swrap_packet_frame *)buf;
+	frame = (struct swrap_packet_frame *)(void *)buf;
 	frame->seconds		= tval->tv_sec;
 	frame->micro_seconds	= tval->tv_usec;
 	frame->recorded_length	= wire_len - icmp_truncate_len;
 	frame->full_length	= wire_len - icmp_truncate_len;
 	buf += SWRAP_PACKET_FRAME_SIZE;
 
-	ip = (union swrap_packet_ip *)buf;
+	ip = (union swrap_packet_ip *)(void *)buf;
 	switch (src->sa_family) {
 	case AF_INET:
 		ip->v4.ver_hdrlen	= 0x45; /* version 4 and 5 * 32 bit words */
@@ -1805,7 +1841,7 @@ static uint8_t *swrap_packet_init(struct timeval *tval,
 	}
 
 	if (unreachable) {
-		pay = (union swrap_packet_payload *)buf;
+		pay = (union swrap_packet_payload *)(void *)buf;
 		switch (src->sa_family) {
 		case AF_INET:
 			pay->icmp4.type		= 0x03; /* destination unreachable */
@@ -1815,7 +1851,7 @@ static uint8_t *swrap_packet_init(struct timeval *tval,
 			buf += SWRAP_PACKET_PAYLOAD_ICMP4_SIZE;
 
 			/* set the ip header in the ICMP payload */
-			ip = (union swrap_packet_ip *)buf;
+			ip = (union swrap_packet_ip *)(void *)buf;
 			ip->v4.ver_hdrlen	= 0x45; /* version 4 and 5 * 32 bit words */
 			ip->v4.tos		= 0x00;
 			ip->v4.packet_length	= htons(wire_len - icmp_hdr_len);
@@ -1841,7 +1877,7 @@ static uint8_t *swrap_packet_init(struct timeval *tval,
 			buf += SWRAP_PACKET_PAYLOAD_ICMP6_SIZE;
 
 			/* set the ip header in the ICMP payload */
-			ip = (union swrap_packet_ip *)buf;
+			ip = (union swrap_packet_ip *)(void *)buf;
 			ip->v6.ver_prio		= 0x60; /* version 4 and 5 * 32 bit words */
 			ip->v6.flow_label_high	= 0x00;
 			ip->v6.flow_label_low	= 0x0000;
@@ -1858,7 +1894,7 @@ static uint8_t *swrap_packet_init(struct timeval *tval,
 		}
 	}
 
-	pay = (union swrap_packet_payload *)buf;
+	pay = (union swrap_packet_payload *)(void *)buf;
 
 	switch (socket_type) {
 	case SOCK_STREAM:
@@ -1893,7 +1929,7 @@ static uint8_t *swrap_packet_init(struct timeval *tval,
 	return base;
 }
 
-static int swrap_get_pcap_fd(const char *fname)
+static int swrap_pcap_get_fd(const char *fname)
 {
 	static int fd = -1;
 
@@ -1922,11 +1958,11 @@ static int swrap_get_pcap_fd(const char *fname)
 	return fd;
 }
 
-static uint8_t *swrap_marshall_packet(struct socket_info *si,
-				      const struct sockaddr *addr,
-				      enum swrap_packet_type type,
-				      const void *buf, size_t len,
-				      size_t *packet_len)
+static uint8_t *swrap_pcap_marshall_packet(struct socket_info *si,
+					   const struct sockaddr *addr,
+					   enum swrap_packet_type type,
+					   const void *buf, size_t len,
+					   size_t *packet_len)
 {
 	const struct sockaddr *src_addr;
 	const struct sockaddr *dest_addr;
@@ -1952,7 +1988,7 @@ static uint8_t *swrap_marshall_packet(struct socket_info *si,
 	case SWRAP_CONNECT_SEND:
 		if (si->type != SOCK_STREAM) return NULL;
 
-		src_addr = si->myname;


-- 
Samba Shared Repository


More information about the samba-cvs mailing list