--------------------- PatchSet 4556 Date: 2007/05/15 22:30:58 Author: amosjeffries Branch: squid3-ipv6 Tag: (none) Log: Rollout IPv6 to HTCP and somewhat into dnsserver. Members: src/dnsserver.cc:1.7.4.6->1.7.4.7 src/htcp.cc:1.15.6.8->1.15.6.9 Index: squid3/src/dnsserver.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/dnsserver.cc,v retrieving revision 1.7.4.6 retrieving revision 1.7.4.7 diff -u -r1.7.4.6 -r1.7.4.7 --- squid3/src/dnsserver.cc 22 Apr 2007 07:48:22 -0000 1.7.4.6 +++ squid3/src/dnsserver.cc 15 May 2007 22:30:58 -0000 1.7.4.7 @@ -1,6 +1,6 @@ /* - * $Id: dnsserver.cc,v 1.7.4.6 2007/04/22 07:48:22 amosjeffries Exp $ + * $Id: dnsserver.cc,v 1.7.4.7 2007/05/15 22:30:58 amosjeffries Exp $ * * DEBUG: section 0 DNS Resolver * AUTHOR: Harvest Derived @@ -141,6 +141,7 @@ #include "util.h" #include "snprintf.h" +#include "IPAddress.h" #if !defined(_SQUID_AIX_) && !defined(_SQUID_MSWIN_) extern int h_errno; @@ -160,8 +161,6 @@ #define gethostbyname _res_gethostbyname #endif /* _SQUID_NEXT_ */ -static struct IN_ADDR no_addr; - /* error messages from gethostbyname() */ static char * my_h_msgs(int x) @@ -189,8 +188,7 @@ int ttl = 0; int retry = 0; int i; - - struct IN_ADDR addr; + char ntoabuf[MAX_IPSTRLEN]; if (0 == strcmp(buf, "$shutdown")) exit(0); @@ -202,9 +200,22 @@ /* check if it's already an IP address in text form. */ for (;;) { - if (safe_inet_addr(buf, &addr)) { + addr.SetEmpty(); + addr = buf; + if (addr.IsAnyAddr()) { reverse = 1; - result = gethostbyaddr((char *) &addr, 4, AF_INET); +#if USE_IPV6 + if( addr.IsIPv6() ) { + struct in6_addr ip6a; + addr.GetInAddr(ip6a); + result = gethostbyaddr(&ip6a, sizeof(struct in6_addr), AF_INET6); + } +#endif + if( addr.IsIPv4() ) { + struct in6_addr ip4a; + addr.GetInAddr(ip4a); + result = gethostbyaddr(&ip4a, sizeof(struct in_addr), AF_INET); + } } else { result = gethostbyname(buf); } @@ -254,7 +265,7 @@ xmemcpy(&addr, result->h_addr_list[i], sizeof(addr)); - printf(" %s", inet_ntoa(addr)); + printf(" %s", addr.NtoA(ntoabuf,MAX_IPSTRLEN)) ); } printf("\n"); Index: squid3/src/htcp.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/htcp.cc,v retrieving revision 1.15.6.8 retrieving revision 1.15.6.9 diff -u -r1.15.6.8 -r1.15.6.9 --- squid3/src/htcp.cc 1 May 2007 08:32:30 -0000 1.15.6.8 +++ squid3/src/htcp.cc 15 May 2007 22:30:58 -0000 1.15.6.9 @@ -1,6 +1,6 @@ /* - * $Id: htcp.cc,v 1.15.6.8 2007/05/01 08:32:30 amosjeffries Exp $ + * $Id: htcp.cc,v 1.15.6.9 2007/05/15 22:30:58 amosjeffries Exp $ * * DEBUG: section 31 Hypertext Caching Protocol * AUTHOR: Duane Wesssels @@ -607,15 +607,12 @@ htcpSend(const char *buf, int len, IPAddress &to) { int x; - char ntoabuf[MAX_IPSTRLEN]; debugs(31, 3, "htcpSend: " << to ); htcpHexdump("htcpSend", buf, len); -/* FIXME INET6 : drop temp conversion. */ sockaddr_in tmp_to; to.GetSockAddr(tmp_to); x = comm_udp_sendto(htcpOutSocket, - &tmp_to, - sizeof(struct sockaddr_in), + to, buf, len); @@ -1126,7 +1123,6 @@ IPAddress *peer; htcpDetail *d = NULL; char *t; - char ntoabuf[MAX_IPSTRLEN]; if (queried_id[hdr->msg_id % N_QUERIED_KEYS] != hdr->msg_id) { @@ -1332,7 +1328,6 @@ htcpHandleData(char *buf, int sz, IPAddress &from) { htcpDataHeader hdr; - char ntoabuf[MAX_IPSTRLEN]; if ((size_t)sz < sizeof(htcpDataHeader)) { @@ -1427,7 +1422,6 @@ { htcpHeader htcpHdr; assert (sz >= 0); - char ntoabuf[MAX_IPSTRLEN]; if ((size_t)sz < sizeof(htcpHeader)) { @@ -1474,16 +1468,10 @@ static char buf[8192]; int len; static IPAddress from; - static char ntoabuf[MAX_IPSTRLEN]; - - socklen_t flen = sizeof(struct sockaddr_in); /* Receive up to 8191 bytes, leaving room for a null */ -/* FIXME INET6 : drop temp construction */ struct sockaddr_in tmp_from; from.GetSockAddr(tmp_from); - len = comm_udp_recvfrom(fd, buf, sizeof(buf) - 1, 0, (struct sockaddr *) &tmp_from, &flen); - -/* FIXME INET6 : drop temp construction */ from = tmp_from; + len = comm_udp_recvfrom(fd, buf, sizeof(buf) - 1, 0, from); debugs(31, 3, "htcpRecv: FD " << fd << ", " << len << " bytes from " << from ); @@ -1504,16 +1492,19 @@ void htcpInit(void) { + IPAddress sendOn; + if (Config.Port.htcp <= 0) { debugs(31, 1, "HTCP Disabled."); return; } + sendOn = Config.Addrs.udp_outgoing; + sendOn.SetPort(Config.Port.htcp); enter_suid(); htcpInSocket = comm_open(SOCK_DGRAM, IPPROTO_UDP, - Config.Addrs.udp_incoming, - Config.Port.htcp, + sendOn, COMM_NONBLOCKING, "HTCP Socket"); leave_suid(); @@ -1529,8 +1520,7 @@ enter_suid(); htcpOutSocket = comm_open(SOCK_DGRAM, IPPROTO_UDP, - Config.Addrs.udp_outgoing, - Config.Port.htcp, + sendOn, COMM_NONBLOCKING, "Outgoing HTCP Socket"); leave_suid(); @@ -1616,6 +1606,7 @@ /* FIXME INET6 : drop temp conversion. */ IPAddress tmp(p->in_addr); htcpSend(pkt, (int) pktlen, tmp); + queried_id[stuff.msg_id % N_QUERIED_KEYS] = stuff.msg_id; save_key = queried_keys[stuff.msg_id % N_QUERIED_KEYS]; storeKeyCopy(save_key, (const cache_key *)e->key);