--- squid.FCS/src/comm.c Wed Oct 4 13:18:09 2000 +++ squid/src/comm.c Wed Jan 24 00:56:53 2001 @@ -57,6 +57,9 @@ static int commBind(int s, struct in_addr, u_short port); static void commSetReuseAddr(int); static void commSetNoLinger(int); +#ifdef SO_BINDANY +static void commSetBindAny(int); +#endif static void CommWriteStateCallbackAndFree(int fd, int code); #ifdef TCP_NODELAY static void commSetTcpNoDelay(int); @@ -179,6 +182,10 @@ commSetNoLinger(new_socket); if (opt_reuseaddr) commSetReuseAddr(new_socket); +#ifdef SO_BINDANY + if (opt_bindany) + commSetBindAny(new_socket); +#endif } if (addr.s_addr != no_addr.s_addr) { if (commBind(new_socket, addr, port) != COMM_OK) { @@ -702,6 +709,16 @@ debug(50, 1) ("commSetTcpRcvbuf: FD %d, SIZE %d: %s\n", fd, size, xstrerror()); } + +#ifdef SO_BINDANY +static void +commSetBindAny(int fd) +{ + int on = 1; + if (setsockopt(fd, SOL_SOCKET, SO_BINDANY, (char *) &on, sizeof(on)) < 0) + debug(50, 1) ("commSetBindAny: FD %d: %s\n", fd, xstrerror()); +} +#endif int commSetNonBlocking(int fd) --- squid.FCS/src/globals.h Wed Oct 4 13:18:12 2000 +++ squid/src/globals.h Tue Jan 23 21:52:48 2001 @@ -76,6 +76,7 @@ extern int debugLevels[MAX_DEBUG_SECTIONS]; extern int do_mallinfo; /* 0 */ extern int opt_reuseaddr; /* 1 */ +extern int opt_bindany; /* 1 */ extern int icmp_sock; /* -1 */ extern int neighbors_do_private_keys; /* 1 */ extern int opt_accel_uses_host; /* 0 */ --- squid.FCS/src/main.c Wed Oct 4 13:18:15 2000 +++ squid/src/main.c Tue Jan 23 21:53:53 2001 @@ -112,8 +112,11 @@ extern char *optarg; int c; - while ((c = getopt(argc, argv, "CDFNRSVYXa:d:f:hk:m::su:vz?")) != -1) { + while ((c = getopt(argc, argv, "BCDFNRSVYXa:d:f:hk:m::su:vz?")) != -1) { switch (c) { + case 'B': + opt_bindany = 0; + break; case 'C': opt_catch_signals = 0; break;