summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamba Release Account <samba-bugs@samba.org>1997-10-15 01:34:04 +0000
committerSamba Release Account <samba-bugs@samba.org>1997-10-15 01:34:04 +0000
commit4200f5a328e1934d4d9cbc4e069e723b639a49db (patch)
tree642584d845f80cfc11528322b314d71d12f16485
parent676c443d21ff8f5e659e933ee3e22cd0e79c50f3 (diff)
downloadsamba-4200f5a328e1934d4d9cbc4e069e723b639a49db.tar.gz
Added #ifdef'ed code with BIND_LOCAL_OUTPUT_SOCKET that causes
optput sockets to be bound to the same local address as input ones are. Jeremy (jallison@whistle.com)
-rw-r--r--source/lib/util.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/source/lib/util.c b/source/lib/util.c
index 459745b8b14..54b2dc08ac8 100644
--- a/source/lib/util.c
+++ b/source/lib/util.c
@@ -3035,8 +3035,26 @@ int open_socket_out(int type, struct in_addr *addr, int port ,int timeout)
if (res == -1)
{ DEBUG(0,("socket error\n")); return -1; }
- if (type != SOCK_STREAM) return(res);
+#ifdef BIND_LOCAL_OUTPUT_SOCKET
+ {
+ struct sockaddr_in sock_in;
+ /* Bind the local part of this socket to the address
+ given in the socket address parameter. */
+
+ bzero((char *)&sock_in,sizeof(sock_in));
+ putip((char *)&sock_in.sin_addr,(char *)interpret_addr2(lp_socket_address()));
+ sock_in.sin_port = 0;
+ sock_in.sin_family = PF_INET;
+
+ if (bind(res, (struct sockaddr * ) &sock_in,sizeof(sock_in)) < 0)
+ DEBUG(0,("Failed to bind local socket address for output socket. Error was %s\n",
+ strerror(errno)));
+ }
+#endif /* BIND_LOCAL_OUTPUT_SOCKET */
+
+ if (type != SOCK_STREAM) return(res);
+
bzero((char *)&sock_out,sizeof(sock_out));
putip((char *)&sock_out.sin_addr,(char *)addr);