From: wessels <> Date: Wed, 9 Oct 1996 21:43:47 +0000 (+0000) Subject: multicast patch from Martin Hamilton X-Git-Tag: SQUID_3_0_PRE1~5693 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e90100aad657c4fcdece04e2352069bb49a46376;p=thirdparty%2Fsquid.git multicast patch from Martin Hamilton --- diff --git a/ChangeLog b/ChangeLog index 12230d0cc2..a976eb9597 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,6 +17,11 @@ TODO LIST before official squid-1.1: - Write Perl script to convert squid-1.0 store to squid-1.1 structure. +Changes to squid-1.1.beta6 (): + + - Fixed lots of function prototypes, etc (Ed Knowles). + - Added multicast patch (Martin Hamilton). + Changes to squid-1.1.beta5 (October 7, 1996): - Fixed coredump in storeFreeMemory(). diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 1805327b1f..f6af7fd7c3 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -1,5 +1,5 @@ /* - * $Id: cache_cf.cc,v 1.104 1996/10/09 15:34:19 wessels Exp $ + * $Id: cache_cf.cc,v 1.105 1996/10/09 15:43:49 wessels Exp $ * * DEBUG: section 3 Configuration File Parsing * AUTHOR: Harvest Derived @@ -247,6 +247,7 @@ static void parseIPLine _PARAMS((ip_acl ** list)); static void parseIcpPortLine _PARAMS((void)); static void parseLocalDomainFile _PARAMS((char *fname)); static void parseLocalDomainLine _PARAMS((void)); +static void parseMcastGroupLine _PARAMS((void)); static void parseLogLine _PARAMS((void)); static void parseMemLine _PARAMS((void)); static void parseMgrLine _PARAMS((void)); @@ -473,6 +474,7 @@ parseCacheHostLine(void) u_short icp_port = CACHE_ICP_PORT; int options = 0; int weight = 1; + int mcast_ttl = 0; int i; if (!(hostname = strtok(NULL, w_space))) @@ -491,6 +493,8 @@ parseCacheHostLine(void) options |= NEIGHBOR_NO_QUERY; } else if (!strncasecmp(token, "weight=", 7)) { weight = atoi(token + 7); + } else if (!strncasecmp(token, "ttl=", 4)) { + mcast_ttl = atoi(token + 4); } else { debug(3, 0, "parseCacheHostLine: token='%s'\n", token); self_destruct(); @@ -498,7 +502,8 @@ parseCacheHostLine(void) } if (weight < 1) weight = 1; - neighbors_cf_add(hostname, type, http_port, icp_port, options, weight); + neighbors_cf_add(hostname, type, http_port, icp_port, options, + weight, mcast_ttl); } static neighbor_t @@ -932,6 +937,14 @@ parseLocalDomainLine(void) } } +static void +parseMcastGroupLine(void) +{ + char *token = NULL; + while ((token = strtok(NULL, w_space))) + wordlistAdd(&Config.mcast_group_list, token); +} + static void parseHttpPortLine(void) { @@ -1287,6 +1300,9 @@ parseConfigFile(char *file_name) else if (!strcmp(token, "local_domain")) parseLocalDomainLine(); + else if (!strcmp(token, "mcast_groups")) + parseMcastGroupLine(); + else if (!strcmp(token, "tcp_incoming_address")) parseAddressLine(&Config.Addrs.tcp_incoming); @@ -1476,6 +1492,7 @@ configFreeMemory(void) wordlistDestroy(&Config.cache_dirs); wordlistDestroy(&Config.hierarchy_stoplist); wordlistDestroy(&Config.local_domain_list); + wordlistDestroy(&Config.mcast_group_list); wordlistDestroy(&Config.inside_firewall_list); wordlistDestroy(&Config.dns_testname_list); ip_acl_destroy(&Config.local_ip_list); diff --git a/src/comm.cc b/src/comm.cc index 1446fdbadc..08b1b48ff8 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -1,6 +1,6 @@ /* - * $Id: comm.cc,v 1.85 1996/10/09 15:34:22 wessels Exp $ + * $Id: comm.cc,v 1.86 1996/10/09 15:43:51 wessels Exp $ * * DEBUG: section 5 Socket Functions * AUTHOR: Harvest Derived @@ -902,6 +902,42 @@ comm_remove_close_handler(int fd, PF handler, void *data) safe_free(p); } +int +comm_set_mcast_ttl(int fd, int mcast_ttl) +{ +#ifdef IP_MULTICAST_TTL + debug(5, 10, "comm_set_mcast_ttl: setting multicast TTL %d on FD %d\n", + mcast_ttl, fd); + if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL, + (char *) &mcast_ttl, sizeof(char)) < 0) + debug(5, 1, "comm_set_mcast_ttl: FD %d, TTL: %d: %s\n", + fd, mcast_ttl, xstrerror()); +#endif + return 0; +} + +int +comm_join_mcast_groups(int fd) +{ +#ifdef IP_MULTICAST_TTL + struct ip_mreq mr; + wordlist *s = NULL; + + for (s = Config.mcast_group_list; s; s = s->next) { + debug(5, 10, + "comm_join_mcast_groups: joining group %s on FD %d\n", s->key, fd); + + mr.imr_multiaddr.s_addr = inet_addr(s->key); + mr.imr_interface.s_addr = INADDR_ANY; + if (setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, + (char *) &mr, sizeof(struct ip_mreq)) < 0) + debug(5, 1, "comm_join_mcast_groups: FD %d, addr: %s\n", + fd, s->key); + } +#endif + return 0; +} + static void commSetNoLinger(int fd) { @@ -922,16 +958,6 @@ commSetReuseAddr(int fd) debug(5, 1, "commSetReuseAddr: FD %d: %s\n", fd, xstrerror()); } -#ifdef TCP_NODELAY -static void -commSetTcpNoDelay(int fd) -{ - int on = 1; - if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *) &on, sizeof(on)) < 0) - debug(5, 1, "commSetTcpNoDelay: FD %d: %s\n", fd, xstrerror()); -} -#endif - static void commSetTcpRcvbuf(int fd, int size) { @@ -976,6 +1002,16 @@ commSetCloseOnExec(int fd) #endif } +#ifdef TCP_NODELAY +static void +commSetTcpNoDelay(int fd) +{ + int on = 1; + if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *) &on, sizeof(on)) < 0) + debug(5, 1, "commSetTcpNoDelay: FD %d: %s\n", fd, xstrerror()); +} +#endif + char ** getAddressList(char *name) { diff --git a/src/main.cc b/src/main.cc index 885452f238..85f5130dfb 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,5 +1,5 @@ /* - * $Id: main.cc,v 1.88 1996/10/09 15:34:32 wessels Exp $ + * $Id: main.cc,v 1.89 1996/10/09 15:43:52 wessels Exp $ * * DEBUG: section 1 Startup and Main Loop * AUTHOR: Harvest Derived @@ -363,6 +363,7 @@ serverConnectionsOpen(void) COMM_SELECT_READ, icpHandleUdp, 0); + comm_join_mcast_groups(theInIcpConnection); debug(1, 1, "Accepting ICP connections on FD %d.\n", theInIcpConnection); diff --git a/src/neighbors.cc b/src/neighbors.cc index 2010a2263b..87ed346e3d 100644 --- a/src/neighbors.cc +++ b/src/neighbors.cc @@ -1,5 +1,5 @@ /* - * $Id: neighbors.cc,v 1.61 1996/10/09 15:34:33 wessels Exp $ + * $Id: neighbors.cc,v 1.62 1996/10/09 15:43:53 wessels Exp $ * * DEBUG: section 15 Neighbor Routines * AUTHOR: Harvest Derived @@ -472,7 +472,12 @@ neighborsUdpPing(protodispatch_data * proto) PROTO_NONE); } - e->stats.ack_deficit++; + if (e->mcast_ttl > 0) { + /* XXX kill us off, so Squid won't expect a reply */ + e->stats.ack_deficit = HIER_MAX_DEFICIT; + } else { + e->stats.ack_deficit++; + } e->stats.pings_sent++; debug(15, 3, "neighborsUdpPing: %s: ack_deficit = %d\n", @@ -695,7 +700,7 @@ neighborsUdpAck(int fd, char *url, icp_common_t * header, struct sockaddr_in *fr } void -neighbors_cf_add(char *host, char *type, int http_port, int icp_port, int options, int weight) +neighbors_cf_add(char *host, char *type, int http_port, int icp_port, int options, int weight, int mcast_ttl) { struct neighbor_cf *t, *u; @@ -706,6 +711,7 @@ neighbors_cf_add(char *host, char *type, int http_port, int icp_port, int option t->icp_port = icp_port; t->options = options; t->weight = weight; + t->mcast_ttl = mcast_ttl; t->next = (struct neighbor_cf *) NULL; if (Neighbor_cf == (struct neighbor_cf *) NULL) { @@ -815,6 +821,7 @@ neighbors_init(void) e = xcalloc(1, sizeof(edge)); e->http_port = t->http_port; e->icp_port = t->icp_port; + e->mcast_ttl = t->mcast_ttl; e->options = t->options; e->weight = t->weight; e->host = t->host;