--------------------- PatchSet 3986 Date: 2007/01/07 05:56:51 Author: hno Branch: squid3-ipv6 Tag: (none) Log: Fixup dual-stack support Members: src/ipcache.cc:1.9.2.9->1.9.2.10 Index: squid3/src/ipcache.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ipcache.cc,v retrieving revision 1.9.2.9 retrieving revision 1.9.2.10 diff -u -r1.9.2.9 -r1.9.2.10 --- squid3/src/ipcache.cc 5 Jan 2007 16:59:24 -0000 1.9.2.9 +++ squid3/src/ipcache.cc 7 Jan 2007 05:56:51 -0000 1.9.2.10 @@ -1,6 +1,6 @@ /* - * $Id: ipcache.cc,v 1.9.2.9 2007/01/05 16:59:24 hno Exp $ + * $Id: ipcache.cc,v 1.9.2.10 2007/01/07 05:56:51 hno Exp $ * * DEBUG: section 14 IP Cache * AUTHOR: Harvest Derived @@ -402,18 +402,30 @@ assert(answers); for (k = 0; k < nr; k++) { - if (answers[k].type != ((AF_FAMILY==AF_INET6)? RFC1035_TYPE_AAAA : RFC1035_TYPE_A )) - continue; - if (answers[k]._class != RFC1035_CLASS_IN) continue; - if (answers[k].rdlength != sizeof(struct IN_ADDR)) { - debug(14, 1)("ipcacheParse: Invalid IP address in response to '%s'\n", name); - continue; - } +#if INET6 + if (answers[k].type == RFC1035_TYPE_AAAA) { + if (answers[k].rdlength != sizeof(struct in6_addr)) { + debug(14, 1)("ipcacheParse: Invalid IPv6 address in response to '%s'\n", name); + continue; + } + na++; + continue; + } +#endif - na++; +#if !defined(INET6) || defined(INET6DUALSTACK) + if (answers[k].type == RFC1035_TYPE_A) { + if (answers[k].rdlength != sizeof(struct in_addr)) { + debug(14, 1)("ipcacheParse: Invalid IPv4 address in response to '%s'\n", name); + continue; + } + na++; + continue; + } +#endif } if (na == 0) { @@ -429,12 +441,13 @@ if (answers[k]._class != RFC1035_CLASS_IN) continue; +#if !defined(INET6) || defined(INET6DUALSTACK) if (answers[k].type == RFC1035_TYPE_A) { if (answers[k].rdlength != 4) continue; -#if AF_FAMILY == AF_INET6 - xmemcpy(&i->addr.in_addrs[j], "\0\0\0\0\0\0\0\0\0xff\0xff\0\0", 12); +#ifdef INET6 + xmemcpy(&i->addr.in_addrs[j], "\0\0\0\0\0\0\0\0\0\0\0xff\0xff", 12); xmemcpy(((char *)&i->addrs.in_addrs[j++]) + 12, answers[k].rdata, 4); #else xmemcpy(&i->addrs.in_addrs[j++], answers[k].rdata, 4); @@ -443,12 +456,13 @@ debug(14, 3) ("ipcacheParse: #%d %s\n", j - 1, INET_NTOA(i->addrs.in_addrs[j - 1])); -#if AF_FAMILY == AF_INET6 +#endif +#ifdef INET6 } else if (answers[k].type == RFC1035_TYPE_AAAA) { - if (answers[k].rdlength != sizeof(struct in_addr6)) + if (answers[k].rdlength != sizeof(struct in6_addr)) continue; - xmemcpy(&i->addrs.in_addrs[j++], answers[k].rdata, sizeof(struct in_addr6)); + xmemcpy(&i->addrs.in_addrs[j++], answers[k].rdata, sizeof(struct in6_addr)); debug(14, 3) ("ipcacheParse: #%d %s\n", j - 1,