Revision: 14841 Author: adrian.chadd Date: Tue Jan 11 21:34:35 2011 Log: Convert things over to use the new ipcacheGetAddrV4() function. This allows for the underlying address type to later change without needing to change this code.
(This code will still cause assertions if they ask for an ipv4 address when there's an ipv6 address in the array; that just means the individual bits of code need to be made v6 aware.) http://code.google.com/p/lusca-cache/source/detail?r=14841 Modified: /playpen/LUSCA_HEAD_ipv6/src/comm.c /playpen/LUSCA_HEAD_ipv6/src/ipcache.c /playpen/LUSCA_HEAD_ipv6/src/multicast.c /playpen/LUSCA_HEAD_ipv6/src/neighbors.c /playpen/LUSCA_HEAD_ipv6/src/net_db.c /playpen/LUSCA_HEAD_ipv6/src/send-announce.c ======================================= --- /playpen/LUSCA_HEAD_ipv6/src/comm.c Tue Jan 11 17:46:15 2011 +++ /playpen/LUSCA_HEAD_ipv6/src/comm.c Tue Jan 11 21:34:35 2011 @@ -121,7 +121,7 @@ assert(ia->cur < ia->count); sqinet_done(&cs->in_addr6); sqinet_init(&cs->in_addr6); - sqinet_set_v4_inaddr(&cs->in_addr6, &ia->in_addrs[ia->cur]); + (void) ipcacheGetAddr(ia, ia->cur, &cs->in_addr6); if (Config.onoff.balance_on_multiple_ip) ipcacheCycleAddr(cs->host, NULL); cs->addrcount = ia->count; ======================================= --- /playpen/LUSCA_HEAD_ipv6/src/ipcache.c Wed Sep 10 05:40:34 2008 +++ /playpen/LUSCA_HEAD_ipv6/src/ipcache.c Tue Jan 11 21:34:35 2011 @@ -73,7 +73,14 @@ (int) i->addrs.count, (int) i->addrs.badcount); for (k = 0; k < (int) i->addrs.count; k++) { - storeAppendPrintf(sentry, " %15s-%3s", inet_ntoa(i->addrs.in_addrs[k]), + char buf[MAX_IPSTRLEN]; + sqaddr_t a; + + sqinet_init(&a); + ipcacheGetAddr(&i->addrs, k, &a); + (void) sqinet_ntoa(&a, buf, MAX_IPSTRLEN, SQADDR_NONE); + sqinet_done(&a); + storeAppendPrintf(sentry, " %15s-%3s", buf, i->addrs.bad_mask[k] ? "BAD" : "OK "); } storeAppendPrintf(sentry, "\n"); ======================================= --- /playpen/LUSCA_HEAD_ipv6/src/multicast.c Tue May 6 08:15:30 2008 +++ /playpen/LUSCA_HEAD_ipv6/src/multicast.c Tue Jan 11 21:34:35 2011 @@ -61,15 +61,17 @@ return; } for (i = 0; i < (int) ia->count; i++) { + struct in_addr a; + a = ipcacheGetAddrV4(ia, i); debug(7, 10) ("Listening for ICP requests on %s\n", - inet_ntoa(*(ia->in_addrs + i))); - mr.imr_multiaddr.s_addr = (ia->in_addrs + i)->s_addr; + inet_ntoa(a)); + mr.imr_multiaddr.s_addr = a.s_addr; mr.imr_interface.s_addr = INADDR_ANY; x = setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *) &mr, sizeof(struct ip_mreq)); if (x < 0) debug(7, 1) ("mcastJoinGroups: FD %d, [%s]\n", - fd, inet_ntoa(*(ia->in_addrs + i))); + fd, inet_ntoa(a)); x = setsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP, &c, 1); if (x < 0) debug(7, 1) ("Can't disable multicast loopback: %s\n", xstrerror()); ======================================= --- /playpen/LUSCA_HEAD_ipv6/src/neighbors.c Tue Aug 31 18:24:09 2010 +++ /playpen/LUSCA_HEAD_ipv6/src/neighbors.c Tue Jan 11 21:34:35 2011 @@ -546,10 +546,10 @@ host, url); echo_hdr.reqnum = reqnum; if (icmp_sock != -1) { - icmpSourcePing(ia->in_addrs[ia->cur], &echo_hdr, url); + icmpSourcePing(ipcacheGetAddrV4(ia, ia->cur), &echo_hdr, url); } else { to_addr.sin_family = AF_INET; - to_addr.sin_addr = ia->in_addrs[ia->cur]; + to_addr.sin_addr = ipcacheGetAddrV4(ia, ia->cur); to_addr.sin_port = htons(echo_port); query = icpCreateMessage(ICP_SECHO, 0, url, reqnum, 0); icpUdpSend(theOutIcpConnection, @@ -1052,7 +1052,7 @@ return; } for (j = 0; j < (int) ia->count && j < PEER_MAX_ADDRESSES; j++) { - p->addresses[j] = ia->in_addrs[j]; + p->addresses[j] = ipcacheGetAddrV4(ia, j); debug(15, 2) ("--> IP address #%d: %s\n", j, inet_ntoa(p->addresses[j])); p->n_addresses++; } ======================================= --- /playpen/LUSCA_HEAD_ipv6/src/net_db.c Tue Jan 11 17:18:58 2011 +++ /playpen/LUSCA_HEAD_ipv6/src/net_db.c Tue Jan 11 21:34:35 2011 @@ -239,7 +239,7 @@ xfree(hostname); return; } - addr = ia->in_addrs[ia->cur]; + addr = ipcacheGetAddrV4(ia, ia->cur); if ((n = netdbLookupHost(hostname)) == NULL) { n = netdbAdd(addr); netdbHostInsert(n, hostname); @@ -1047,7 +1047,7 @@ /* try IP addr */ ia = ipcache_gethostbyname(request->host, 0); if (NULL != ia) - n = netdbLookupAddr(ia->in_addrs[ia->cur]); + n = netdbLookupAddr(ipcacheGetAddrV4(ia, ia->cur)); } if (NULL == n) return NULL; ======================================= --- /playpen/LUSCA_HEAD_ipv6/src/send-announce.c Wed May 24 20:36:56 2006 +++ /playpen/LUSCA_HEAD_ipv6/src/send-announce.c Tue Jan 11 21:34:35 2011 @@ -98,7 +98,7 @@ memset(&S, '\0', sizeof(S)); S.sin_family = AF_INET; S.sin_port = htons(port); - S.sin_addr = ia->in_addrs[0]; + S.sin_addr = ipcacheGetAddrV4(ia, 0); assert(theOutIcpConnection > 0); x = comm_udp_sendto(theOutIcpConnection, &S, sizeof(S), -- You received this message because you are subscribed to the Google Groups "lusca-commit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/lusca-commit?hl=en.
