Revision: 14887
Author:   adrian.chadd
Date:     Sun Jul 10 02:19:03 2011
Log:      Commit the very first pass of ipv6'ifying:

* peer code
* peer select code
* htcp code
* icp v2/v3 code
* neighbor code

Disable the peer stuff in snmp_agent for now, it needs updating
to be IPv6 happy.

The problems?

The peer state in particular doesn't have a create/destroy method
for peers, only for non-peers. The create/destroy seems to live in
the cache_cf parsing functions. It's very likely that assertions
in sqinet will fire because sqinet_init/sqinet_done haven't been
called.

Some of these will be hidden by calls to sqinet_copy() which will
init a destination sqaddr_t if the source sqaddr_t is init'ed.

Since peers may now have v4/v6 addresses, it isn't entirely clear
how this should all function. It may just function the same as a
peer with >1 IPv4 address. I'll worry about that mess later; same
as worrying about v4/v6 preferences in forward.c later.

NOTE: None of this code has been tested, so it may break very badly.
I just wanted to get the initial cut of this mess into the tree.


http://code.google.com/p/lusca-cache/source/detail?r=14887

Modified:
 /playpen/LUSCA_HEAD_ipv6/src/access_log.c
 /playpen/LUSCA_HEAD_ipv6/src/htcp.c
 /playpen/LUSCA_HEAD_ipv6/src/icp_v2.c
 /playpen/LUSCA_HEAD_ipv6/src/icp_v3.c
 /playpen/LUSCA_HEAD_ipv6/src/neighbors.c
 /playpen/LUSCA_HEAD_ipv6/src/peer_select.c
 /playpen/LUSCA_HEAD_ipv6/src/protos.h
 /playpen/LUSCA_HEAD_ipv6/src/snmp_agent.c
 /playpen/LUSCA_HEAD_ipv6/src/structs.h

=======================================
--- /playpen/LUSCA_HEAD_ipv6/src/access_log.c   Mon Sep  6 22:29:42 2010
+++ /playpen/LUSCA_HEAD_ipv6/src/access_log.c   Sun Jul 10 02:19:03 2011
@@ -1578,7 +1578,7 @@
 }

 void
-accessLogEntrySetClientAddr(AccessLogEntry *al, sqaddr_t *addr)
+accessLogEntrySetClientAddr(AccessLogEntry *al, const sqaddr_t *addr)
 {
        sqinet_copy(&al->cache.caddr2, addr);
 }
=======================================
--- /playpen/LUSCA_HEAD_ipv6/src/htcp.c Mon Sep  6 21:39:50 2010
+++ /playpen/LUSCA_HEAD_ipv6/src/htcp.c Sun Jul 10 02:19:03 2011
@@ -182,7 +182,7 @@
 #define N_QUERIED_KEYS 8192
 static u_num32 queried_id[N_QUERIED_KEYS];
 static cache_key queried_keys[N_QUERIED_KEYS][SQUID_MD5_DIGEST_LENGTH];
-static struct sockaddr_in queried_addr[N_QUERIED_KEYS];
+static sqaddr_t queried_addr[N_QUERIED_KEYS];
 static MemPool *htcpSpecifierPool = NULL;
 static MemPool *htcpDetailPool = NULL;

@@ -198,16 +198,23 @@
static ssize_t htcpBuildTstOpData(char *buf, size_t buflen, htcpStuff * stuff);
 static void htcpFreeSpecifier(htcpSpecifier * s);
 static void htcpFreeDetail(htcpDetail * s);
-static void htcpHandle(char *buf, int sz, struct sockaddr_in *from);
-static void htcpHandleMon(htcpDataHeader *, char *buf, int sz, struct sockaddr_in *from); -static void htcpHandleNop(htcpDataHeader *, char *buf, int sz, struct sockaddr_in *from); -static void htcpHandleSet(htcpDataHeader *, char *buf, int sz, struct sockaddr_in *from); -static void htcpHandleTst(htcpDataHeader *, char *buf, int sz, struct sockaddr_in *from);
+static void htcpHandle(char *buf, int sz, const sqaddr_t *from);
+static void htcpHandleMon(htcpDataHeader *, char *buf, int sz,
+  const sqaddr_t *from);
+static void htcpHandleNop(htcpDataHeader *, char *buf, int sz,
+  const sqaddr_t *from);
+static void htcpHandleSet(htcpDataHeader *, char *buf, int sz,
+  const sqaddr_t *from);
+static void htcpHandleTst(htcpDataHeader *, char *buf, int sz,
+  const sqaddr_t *from);
 static void htcpRecv(int fd, void *data);
-static void htcpSend(const char *buf, int len, struct sockaddr_in *to);
-static void htcpTstReply(htcpDataHeader *, StoreEntry *, htcpSpecifier *, struct sockaddr_in *); -static void htcpHandleTstRequest(htcpDataHeader *, char *buf, int sz, struct sockaddr_in *from); -static void htcpHandleTstResponse(htcpDataHeader *, char *, int, struct sockaddr_in *);
+static void htcpSend(const char *buf, int len, const sqaddr_t *to);
+static void htcpTstReply(htcpDataHeader *, StoreEntry *, htcpSpecifier *,
+  const sqaddr_t *);
+static void htcpHandleTstRequest(htcpDataHeader *, char *buf, int sz,
+  const sqaddr_t *from);
+static void htcpHandleTstResponse(htcpDataHeader *, char *, int,
+  const sqaddr_t *);
 static StoreEntry *htcpCheckHit(const htcpSpecifier *);
 static void htcpForwardClr(char *buf, int sz);

@@ -458,15 +465,17 @@
 }

 static void
-htcpSend(const char *buf, int len, struct sockaddr_in *to)
+htcpSend(const char *buf, int len, const sqaddr_t *to)
 {
     int x;
-    debug(31, 3) ("htcpSend: %s/%d\n",
-       inet_ntoa(to->sin_addr), (int) ntohs(to->sin_port));
+    if (do_debug(31, 3)) {
+        char sbuf[MAX_IPSTRLEN];
+       (void) sqinet_ntoa(to, sbuf, MAX_IPSTRLEN, SQADDR_NONE);
+        debug(31, 3) ("htcpSend: %s/%d\n", sbuf, sqinet_get_port(to));
+    }
     htcpHexdump("htcpSend", buf, len);
-    x = comm_udp_sendto(htcpOutSocket,
+    x = comm_udp_sendto6(htcpOutSocket,
        to,
-       sizeof(struct sockaddr_in),
        buf,
        len);
     if (x < 0)
@@ -650,17 +659,15 @@
 }

 static int
-htcpAccessCheck(acl_access * acl, htcpSpecifier * s, struct sockaddr_in *from)
+htcpAccessCheck(acl_access * acl, htcpSpecifier * s, const sqaddr_t *from)
 {
     int r;
     aclCheck_t checklist;
     memset(&checklist, '\0', sizeof(checklist));
     sqinet_init(&checklist.src_address);
-#warning HTCP needs to be made v6 aware!
-    sqinet_set_family(&checklist.src_address, AF_INET);
-    sqinet_set_v4_inaddr(&checklist.src_address, &from->sin_addr);
+    sqinet_copy(&checklist.src_address, from);
     sqinet_init(&checklist.my_address);
- sqinet_set_family(&checklist.my_address, AF_INET); /* XXX will need to be taught about "from"! -adrian */
+    sqinet_set_family(&checklist.my_address, sqinet_get_family(from));
     sqinet_set_noaddr(&checklist.my_address);
     checklist.request = s->request;
     r = aclCheckFast(acl, &checklist);
@@ -670,7 +677,8 @@
 }

 static void
-htcpTstReply(htcpDataHeader * dhdr, StoreEntry * e, htcpSpecifier * spec, struct sockaddr_in *from)
+htcpTstReply(htcpDataHeader * dhdr, StoreEntry * e, htcpSpecifier * spec,
+  const sqaddr_t *from)
 {
     htcpStuff stuff;
     static char pkt[8192];
@@ -742,7 +750,7 @@
 }

 static void
-htcpClrReply(htcpDataHeader * dhdr, int purgeSucceeded, struct sockaddr_in *from) +htcpClrReply(htcpDataHeader * dhdr, int purgeSucceeded, const sqaddr_t *from)
 {
     htcpStuff stuff;
     static char pkt[8192];
@@ -768,7 +776,7 @@
 }

 static void
-htcpHandleNop(htcpDataHeader * hdr, char *buf, int sz, struct sockaddr_in *from) +htcpHandleNop(htcpDataHeader * hdr, char *buf, int sz, const sqaddr_t *from)
 {
     debug(31, 3) ("htcpHandleNop: Unimplemented\n");
 }
@@ -850,7 +858,7 @@
 }

 static void
-htcpHandleTst(htcpDataHeader * hdr, char *buf, int sz, struct sockaddr_in *from) +htcpHandleTst(htcpDataHeader * hdr, char *buf, int sz, const sqaddr_t *from)
 {
     debug(31, 3) ("htcpHandleTst: sz = %d\n", (int) sz);
     if (hdr->RR == RR_REQUEST)
@@ -860,26 +868,32 @@
 }

 static void
-htcpHandleTstResponse(htcpDataHeader * hdr, char *buf, int sz, struct sockaddr_in *from)
+htcpHandleTstResponse(htcpDataHeader * hdr, char *buf, int sz,
+  const sqaddr_t *from)
 {
     htcpReplyData htcpReply;
     cache_key *key = NULL;
-    struct sockaddr_in *peer;
+    sqaddr_t *peer;
     htcpDetail *d = NULL;
     char *t;
+    char sbuf[MAX_IPSTRLEN];
+
+    /* XXX I'm being lazy -adrian */
+    (void) sqinet_ntoa(from, sbuf, MAX_IPSTRLEN, SQADDR_NONE);

     if (queried_id[hdr->msg_id % N_QUERIED_KEYS] != hdr->msg_id) {
- debug(31, 2) ("htcpHandleTstResponse: No matching query id '%d' (expected %d) from '%s'\n", hdr->msg_id, queried_id[hdr->msg_id % N_QUERIED_KEYS], inet_ntoa(from->sin_addr)); + debug(31, 2) ("htcpHandleTstResponse: No matching query id '%d' (expected %d) from '%s'\n", hdr->msg_id, queried_id[hdr->msg_id % N_QUERIED_KEYS], sbuf);
        return;
     }
     key = queried_keys[hdr->msg_id % N_QUERIED_KEYS];
     if (!key) {
- debug(31, 1) ("htcpHandleTstResponse: No query key for response id '%d' from '%s'\n", hdr->msg_id, inet_ntoa(from->sin_addr)); + debug(31, 1) ("htcpHandleTstResponse: No query key for response id '%d' from '%s'\n", hdr->msg_id, sbuf);
        return;
     }
     peer = &queried_addr[hdr->msg_id % N_QUERIED_KEYS];
- if (peer->sin_addr.s_addr != from->sin_addr.s_addr || peer->sin_port != from->sin_port) { - debug(31, 1) ("htcpHandleTstResponse: Unexpected response source %s\n", inet_ntoa(from->sin_addr));
+    if ((! sqinet_compare_addr(from, peer)) ||
+      (! sqinet_compare_port(from, peer))) {
+ debug(31, 1) ("htcpHandleTstResponse: Unexpected response source %s\n", sbuf);
        return;
     }
     if (hdr->F1 == 1) {
@@ -915,7 +929,8 @@
 }

 static void
-htcpHandleTstRequest(htcpDataHeader * dhdr, char *buf, int sz, struct sockaddr_in *from)
+htcpHandleTstRequest(htcpDataHeader * dhdr, char *buf, int sz,
+  const sqaddr_t *from)
 {
     /* buf should be a SPECIFIER */
     htcpSpecifier *s;
@@ -954,19 +969,19 @@
 }

 static void
-htcpHandleMon(htcpDataHeader * hdr, char *buf, int sz, struct sockaddr_in *from) +htcpHandleMon(htcpDataHeader * hdr, char *buf, int sz, const sqaddr_t *from)
 {
     debug(31, 3) ("htcpHandleMon: Unimplemented\n");
 }

 static void
-htcpHandleSet(htcpDataHeader * hdr, char *buf, int sz, struct sockaddr_in *from) +htcpHandleSet(htcpDataHeader * hdr, char *buf, int sz, const sqaddr_t *from)
 {
     debug(31, 3) ("htcpHandleSet: Unimplemented\n");
 }

 static void
-htcpHandleClr(htcpDataHeader * hdr, char *buf, int sz, struct sockaddr_in *from) +htcpHandleClr(htcpDataHeader * hdr, char *buf, int sz, const sqaddr_t *from)
 {
     htcpSpecifier *s;
     /* buf[0/1] is reserved and reason */
@@ -1031,17 +1046,21 @@
        if (!p->options.htcp_forward_clr) {
            continue;
        }
-       htcpSend(buf, sz, &p->in_addr);
+       htcpSend(buf, sz, &p->addr);
     }
 }

 static void
-htcpHandle(char *buf, int sz, struct sockaddr_in *from)
+htcpHandle(char *buf, int sz, const sqaddr_t *from)
 {
     htcpHeader htcpHdr;
     htcpDataHeader hdr;
     char *hbuf;
     int hsz;
+    char sbuf[MAX_IPSTRLEN];
+
+    /* XXX being lazy -adrian */
+    (void) sqinet_ntoa(from, sbuf, MAX_IPSTRLEN, SQADDR_NONE);

     if (sz < sizeof(htcpHeader)) {
        debug(31, 1) ("htcpHandle: msg size less than htcpHeader size\n");
@@ -1059,14 +1078,13 @@
     debug(31, 3) ("htcpHandle: htcpHdr.minor = %d\n", (int) htcpHdr.minor);
     if (sz != htcpHdr.length) {
        debug(31, 1) ("htcpHandle: sz/%d != htcpHdr.length/%d from %s:%d\n",
-           sz, htcpHdr.length,
-           inet_ntoa(from->sin_addr), (int) ntohs(from->sin_port));
+           sz, htcpHdr.length, sbuf, sqinet_get_port(from));
        return;
     }
     if (htcpHdr.major != 0) {
        debug(31, 1) ("htcpHandle: Unknown major version %d from %s:%d\n",
            htcpHdr.major,
-           inet_ntoa(from->sin_addr), (int) ntohs(from->sin_port));
+            sbuf, sqinet_get_port(from));
        return;
     }
     hbuf = buf + sizeof(htcpHeader);
@@ -1095,7 +1113,7 @@
     debug(31, 3) ("htcpHandle: length = %d\n", (int) hdr.length);
     if (hdr.opcode >= HTCP_END) {
        debug(31, 1) ("htcpHandle: client %s, opcode %d out of range\n",
-           inet_ntoa(from->sin_addr),
+           sbuf,
            (int) hdr.opcode);
        return;
     }
@@ -1145,19 +1163,27 @@
 {
     static char buf[8192];
     int len;
-    static struct sockaddr_in from;
-    socklen_t flen = sizeof(struct sockaddr_in);
+    struct sockaddr_storage from;
+    sqaddr_t sfrom;
+    socklen_t flen = sizeof(from);
     memset(&from, '\0', flen);
 #if NOTYET
     statCounter.syscalls.sock.recvfroms++;
 #endif
     /* Receive up to 8191 bytes, leaving room for a null */
+    sqinet_init(&sfrom);
len = recvfrom(fd, buf, sizeof(buf) - 1, 0, (struct sockaddr *) &from, &flen);
-    debug(31, 3) ("htcpRecv: FD %d, %d bytes from %s:%d\n",
-       fd, len, inet_ntoa(from.sin_addr), ntohs(from.sin_port));
+    sqinet_set_sockaddr(&sfrom, &from);
+    if (do_debug(31, 3)) {
+        char sbuf[MAX_IPSTRLEN];
+        (void) sqinet_ntoa(&sfrom, sbuf, MAX_IPSTRLEN, SQADDR_NONE);
+        debug(31, 3) ("htcpRecv: FD %d, %d bytes from %s:%d\n",
+          fd, len, sbuf, sqinet_get_port(&sfrom));
+    }
     if (len)
        statCounter.htcp.pkts_recv++;
-    htcpHandle(buf, len, &from);
+    htcpHandle(buf, len, &sfrom);
+    sqinet_done(&sfrom);
     commSetSelect(fd, COMM_SELECT_READ, htcpRecv, NULL, 0);
 }

@@ -1255,11 +1281,11 @@
        debug(31, 1) ("htcpQuery: htcpBuildPacket() failed\n");
        return;
     }
-    htcpSend(pkt, (int) pktlen, &p->in_addr);
+    htcpSend(pkt, (int) pktlen, &p->addr);
     queried_id[stuff.msg_id % N_QUERIED_KEYS] = stuff.msg_id;
     save_key = queried_keys[stuff.msg_id % N_QUERIED_KEYS];
     storeKeyCopy(save_key, e->hash.key);
-    queried_addr[stuff.msg_id % N_QUERIED_KEYS] = p->in_addr;
+    sqinet_copy(&queried_addr[stuff.msg_id % N_QUERIED_KEYS], &p->addr);
debug(31, 3) ("htcpQuery: key (%p) %s\n", save_key, storeKeyText(save_key));
 }

@@ -1326,7 +1352,7 @@
        debug(31, 1) ("htcpQuery: htcpBuildPacket() failed\n");
        return;
     }
-    htcpSend(pkt, (int) pktlen, &p->in_addr);
+    htcpSend(pkt, (int) pktlen, &p->addr);
 }

 /*
=======================================
--- /playpen/LUSCA_HEAD_ipv6/src/icp_v2.c       Mon Sep  6 21:39:50 2010
+++ /playpen/LUSCA_HEAD_ipv6/src/icp_v2.c       Sun Jul 10 02:19:03 2011
@@ -37,8 +37,8 @@

 #include "client_db.h"

-static void icpLogIcp(struct in_addr, log_type, int, const char *, int);
-static void icpHandleIcpV2(int, struct sockaddr_in, char *, int);
+static void icpLogIcp(const sqaddr_t *, log_type, int, const char *, int);
+static void icpHandleIcpV2(int, const sqaddr_t *, char *, int);
 static void icpCount(void *, int, size_t, int);

 /*
@@ -48,20 +48,21 @@
 static icpUdpData *IcpQueueTail = NULL;

 static void
-icpLogIcp(struct in_addr caddr, log_type logcode, int len, const char *url, int delay) +icpLogIcp(const sqaddr_t *caddr, log_type logcode, int len, const char *url,
+  int delay)
 {
     AccessLogEntry al;
     if (LOG_TAG_NONE == logcode)
        return;
     if (LOG_ICP_QUERY == logcode)
        return;
-    clientdbUpdate(caddr, logcode, PROTO_ICP, len);
+    clientdbUpdate6(caddr, logcode, PROTO_ICP, len);
     if (!Config.onoff.log_udp)
        return;
     accessLogEntryInit(&al);
     al.icp.opcode = ICP_QUERY;
     al.url = url;
-    accessLogEntrySetClientAddr4(&al, caddr);
+    accessLogEntrySetClientAddr(&al, caddr);
     al.cache.size = len;
     al.cache.code = logcode;
     al.cache.msec = delay;
@@ -78,8 +79,9 @@
     while ((q = IcpQueueHead) != NULL) {
        delay = tvSubUsec(q->queue_time, current_time);
        /* increment delay to prevent looping */
-       x = icpUdpSend(fd, &q->address, q->msg, q->logcode, ++delay);
+       x = icpUdpSend(fd, &q->addr, q->msg, q->logcode, ++delay);
        IcpQueueHead = q->next;
+        sqinet_done(&q->addr);
        safe_free(q);
        if (x < 0)
            break;
@@ -119,7 +121,7 @@

 int
 icpUdpSend(int fd,
-    const struct sockaddr_in *to,
+    const sqaddr_t *to,
     icp_common_t * msg,
     log_type logcode,
     int delay)
@@ -128,22 +130,28 @@
     int x;
     int len;
     len = (int) ntohs(msg->length);
-    debug(12, 5) ("icpUdpSend: FD %d sending %s, %d bytes to %s:%d\n",
-       fd,
-       icp_opcode_str[msg->opcode],
-       len,
-       inet_ntoa(to->sin_addr),
-       ntohs(to->sin_port));
-    x = comm_udp_sendto(fd, to, sizeof(*to), msg, len);
+    if (do_debug(12, 5)) {
+        char sbuf[MAX_IPSTRLEN];
+        (void) sqinet_ntoa(to, sbuf, MAX_IPSTRLEN, SQADDR_NONE);
+
+        debug(12, 5) ("icpUdpSend: FD %d sending %s, %d bytes to %s:%d\n",
+          fd,
+          icp_opcode_str[msg->opcode],
+          len,
+          sbuf,
+          sqinet_get_port(to));
+    }
+    x = comm_udp_sendto6(fd, to, msg, len);
     if (x >= 0) {
        /* successfully written */
-       icpLogIcp(to->sin_addr, logcode, len, (char *) (msg + 1), delay);
+       icpLogIcp(to, logcode, len, (char *) (msg + 1), delay);
        icpCount(msg, SENT, (size_t) len, delay);
        safe_free(msg);
     } else if (0 == delay) {
        /* send failed, but queue it */
        queue = xcalloc(1, sizeof(icpUdpData));
-       queue->address = *to;
+        sqinet_init(&queue->addr);
+        sqinet_copy(&queue->addr, to);
        queue->msg = msg;
        queue->len = (int) ntohs(msg->length);
        queue->queue_time = current_time;
@@ -182,7 +190,7 @@
 }

 static void
-icpHandleIcpV2(int fd, struct sockaddr_in from, char *buf, int len)
+icpHandleIcpV2(int fd, const sqaddr_t *from, char *buf, int len)
 {
     icp_common_t header;
     StoreEntry *entry = NULL;
@@ -197,6 +205,8 @@
     int rtt = 0;
     int hops = 0;
     method_t *method_get;
+    char sbuf[MAX_IPSTRLEN];
+
     xmemcpy(&header, buf, sizeof(icp_common_t));
     method_get = urlMethodGetKnownByCode(METHOD_GET);
     /*
@@ -220,35 +230,36 @@
        if (strpbrk(url, w_space)) {
            url = rfc1738_escape(url);
            reply = icpCreateMessage(ICP_ERR, 0, url, header.reqnum, 0);
-           icpUdpSend(fd, &from, reply, LOG_UDP_INVALID, 0);
+           icpUdpSend(fd, from, reply, LOG_UDP_INVALID, 0);
            break;
        }
        if ((icp_request = urlParse(method_get, url)) == NULL) {
            reply = icpCreateMessage(ICP_ERR, 0, url, header.reqnum, 0);
-           icpUdpSend(fd, &from, reply, LOG_UDP_INVALID, 0);
+           icpUdpSend(fd, from, reply, LOG_UDP_INVALID, 0);
            break;
        }
        memset(&checklist, '\0', sizeof(checklist));
        aclCheckSetup(&checklist);
-       sqinet_set_family(&checklist.src_address, AF_INET);
-       sqinet_set_v4_inaddr(&checklist.src_address, &from.sin_addr);
-#warning needs to be made v6 "my_address" aware!
-        sqinet_set_family(&checklist.my_address, AF_INET);
+       sqinet_copy(&checklist.src_address, from);
+        sqinet_set_family(&checklist.my_address, sqinet_get_family(from));
         sqinet_set_noaddr(&checklist.my_address);
        checklist.request = icp_request;
        allow = aclCheckFast(Config.accessList.icp, &checklist);
        if (!allow) {
-           debug(12, 2) ("icpHandleIcpV2: Access Denied for %s by %s.\n",
-               inet_ntoa(from.sin_addr), AclMatchedName);
-           if (clientdbCutoffDenied(from.sin_addr)) {
+            if (do_debug(12, 2)) {
+                (void) sqinet_ntoa(from, sbuf, MAX_IPSTRLEN, SQADDR_NONE);
+ debug(12, 2) ("icpHandleIcpV2: Access Denied for %s by %s.\n",
+                  sbuf, AclMatchedName);
+            }
+           if (clientdbCutoffDenied(from)) {
                /*
                 * count this DENIED query in the clientdb, even though
                 * we're not sending an ICP reply...
                 */
-               clientdbUpdate(from.sin_addr, LOG_UDP_DENIED, PROTO_ICP, 0);
+               clientdbUpdate6(from, LOG_UDP_DENIED, PROTO_ICP, 0);
            } else {
                reply = icpCreateMessage(ICP_DENIED, 0, url, header.reqnum, 0);
-               icpUdpSend(fd, &from, reply, LOG_UDP_DENIED, 0);
+               icpUdpSend(fd, from, reply, LOG_UDP_DENIED, 0);
            }
            break;
        }
@@ -264,7 +275,7 @@
debug(12, 5) ("icpHandleIcpV2: OPCODE %s\n", icp_opcode_str[header.opcode]);
        if (icpCheckUdpHit(entry, icp_request)) {
            reply = icpCreateMessage(ICP_HIT, flags, url, header.reqnum, 
src_rtt);
-           icpUdpSend(fd, &from, reply, LOG_UDP_HIT, 0);
+           icpUdpSend(fd, from, reply, LOG_UDP_HIT, 0);
            break;
        }
        if (Config.onoff.test_reachability && rtt == 0) {
@@ -274,16 +285,16 @@
        /* if store is rebuilding, return a UDP_HIT, but not a MISS */
        if (store_dirs_rebuilding && opt_reload_hit_only) {
reply = icpCreateMessage(ICP_MISS_NOFETCH, flags, url, header.reqnum, src_rtt);
-           icpUdpSend(fd, &from, reply, LOG_UDP_MISS_NOFETCH, 0);
+           icpUdpSend(fd, from, reply, LOG_UDP_MISS_NOFETCH, 0);
        } else if (hit_only_mode_until > squid_curtime) {
reply = icpCreateMessage(ICP_MISS_NOFETCH, flags, url, header.reqnum, src_rtt);
-           icpUdpSend(fd, &from, reply, LOG_UDP_MISS_NOFETCH, 0);
+           icpUdpSend(fd, from, reply, LOG_UDP_MISS_NOFETCH, 0);
        } else if (Config.onoff.test_reachability && rtt == 0) {
reply = icpCreateMessage(ICP_MISS_NOFETCH, flags, url, header.reqnum, src_rtt);
-           icpUdpSend(fd, &from, reply, LOG_UDP_MISS_NOFETCH, 0);
+           icpUdpSend(fd, from, reply, LOG_UDP_MISS_NOFETCH, 0);
        } else {
reply = icpCreateMessage(ICP_MISS, flags, url, header.reqnum, src_rtt);
-           icpUdpSend(fd, &from, reply, LOG_UDP_MISS, 0);
+           icpUdpSend(fd, from, reply, LOG_UDP_MISS, 0);
        }
        break;

@@ -296,19 +307,23 @@
     case ICP_DENIED:
     case ICP_MISS_NOFETCH:
        if (neighbors_do_private_keys && header.reqnum == 0) {
+            (void) sqinet_ntoa(from, sbuf, MAX_IPSTRLEN, SQADDR_NONE);
            debug(12, 0) ("icpHandleIcpV2: Neighbor %s returned reqnum = 0\n",
-               inet_ntoa(from.sin_addr));
+               sbuf);
            debug(12, 0) ("icpHandleIcpV2: Disabling use of private keys\n");
            neighbors_do_private_keys = 0;
        }
        url = buf + sizeof(icp_common_t);
-       debug(12, 3) ("icpHandleIcpV2: %s from %s for '%s'\n",
-           icp_opcode_str[header.opcode],
-           inet_ntoa(from.sin_addr),
-           url);
+        if (do_debug(12, 3)) {
+            (void) sqinet_ntoa(from, sbuf, MAX_IPSTRLEN, SQADDR_NONE);
+            debug(12, 3) ("icpHandleIcpV2: %s from %s for '%s'\n",
+              icp_opcode_str[header.opcode],
+              sbuf,
+              url);
+        }
        key = icpGetCacheKey(url, (int) header.reqnum);
        /* call neighborsUdpAck even if ping_status != PING_WAITING */
-       neighborsUdpAck(key, &header, &from);
+       neighborsUdpAck(key, &header, from);
        break;

     case ICP_INVALID:
@@ -316,8 +331,9 @@
        break;

     default:
+        (void) sqinet_ntoa(from, sbuf, MAX_IPSTRLEN, SQADDR_NONE);
        debug(12, 0) ("icpHandleIcpV2: UNKNOWN OPCODE: %d from %s\n",
-           header.opcode, inet_ntoa(from.sin_addr));
+           header.opcode, sbuf);
        break;
     }
     if (icp_request)
@@ -348,12 +364,14 @@
 icpHandleUdp(int sock, void *data)
 {
     int *N = &incoming_sockets_accepted;
-    struct sockaddr_in from;
+    struct sockaddr_storage from;
     socklen_t from_len;
     LOCAL_ARRAY(char, buf, SQUID_UDP_SO_RCVBUF);
     int len;
     int icp_version;
     int max = INCOMING_ICP_MAX;
+    sqaddr_t sfrom;
+
     commSetSelect(sock, COMM_SELECT_READ, icpHandleUdp, NULL, 0);
     while (max--) {
        from_len = sizeof(from);
@@ -381,30 +399,41 @@
                    sock, xstrerror());
            break;
        }
+        sqinet_init(&sfrom);
+        sqinet_set_sockaddr(&sfrom, &from);
        (*N)++;
        icpCount(buf, RECV, (size_t) len, 0);
        buf[len] = '\0';
-       debug(12, 4) ("icpHandleUdp: FD %d: received %d bytes from %s.\n",
-           sock,
-           len,
-           inet_ntoa(from.sin_addr));
+        if (do_debug(12, 4)) {
+            char sbuf[MAX_IPSTRLEN];
+            (void) sqinet_ntoa(&sfrom, sbuf, MAX_IPSTRLEN, SQADDR_NONE);
+ debug(12, 4) ("icpHandleUdp: FD %d: received %d bytes from %s.\n",
+                    sock,
+                    len,
+                    sbuf);
+        }
 #ifdef ICP_PACKET_DUMP
        icpPktDump(buf);
 #endif
        if (len < sizeof(icp_common_t)) {
            debug(12, 4) ("icpHandleUdp: Ignoring too-small UDP packet\n");
+            sqinet_done(&sfrom);
            break;
        }
        icp_version = (int) buf[1];     /* cheat! */
        if (icp_version == ICP_VERSION_2)
-           icpHandleIcpV2(sock, from, buf, len);
+           icpHandleIcpV2(sock, &sfrom, buf, len);
        else if (icp_version == ICP_VERSION_3)
-           icpHandleIcpV3(sock, from, buf, len);
-       else
-           debug(12, 1) ("WARNING: Unused ICP version %d received from 
%s:%d\n",
-               icp_version,
-               inet_ntoa(from.sin_addr),
-               ntohs(from.sin_port));
+           icpHandleIcpV3(sock, &sfrom, buf, len);
+       else if (do_debug(12, 1)) {
+            char sbuf[MAX_IPSTRLEN];
+            (void) sqinet_ntoa(&sfrom, sbuf, MAX_IPSTRLEN, SQADDR_NONE);
+ debug(12, 1) ("WARNING: Unused ICP version %d received from %s:%d\n",
+              icp_version,
+              sbuf,
+              sqinet_get_port(&sfrom));
+        }
+        sqinet_done(&sfrom);
     }
 }

=======================================
--- /playpen/LUSCA_HEAD_ipv6/src/icp_v3.c       Mon Sep  6 21:39:50 2010
+++ /playpen/LUSCA_HEAD_ipv6/src/icp_v3.c       Sun Jul 10 02:19:03 2011
@@ -39,7 +39,7 @@

 /* Currently Harvest cached-2.x uses ICP_VERSION_3 */
 void
-icpHandleIcpV3(int fd, struct sockaddr_in from, char *buf, int len)
+icpHandleIcpV3(int fd, const sqaddr_t *from, char *buf, int len)
 {
     icp_common_t header;
     icp_common_t *reply;
@@ -50,6 +50,8 @@
     int allow = 0;
     aclCheck_t checklist;
     method_t *method_get;
+    char sbuf[MAX_IPSTRLEN];
+
     xmemcpy(&header, buf, sizeof(icp_common_t));
     method_get = urlMethodGetKnownByCode(METHOD_GET);
     /*
@@ -73,35 +75,36 @@
        if (strpbrk(url, w_space)) {
            url = rfc1738_escape(url);
            reply = icpCreateMessage(ICP_ERR, 0, url, header.reqnum, 0);
-           icpUdpSend(fd, &from, reply, LOG_UDP_INVALID, 0);
+           icpUdpSend(fd, from, reply, LOG_UDP_INVALID, 0);
            break;
        }
        if ((icp_request = urlParse(method_get, url)) == NULL) {
            reply = icpCreateMessage(ICP_ERR, 0, url, header.reqnum, 0);
-           icpUdpSend(fd, &from, reply, LOG_UDP_INVALID, 0);
+           icpUdpSend(fd, from, reply, LOG_UDP_INVALID, 0);
            break;
        }
        memset(&checklist, '\0', sizeof(checklist));
        aclCheckSetup(&checklist);
-       sqinet_set_family(&checklist.src_address, AF_INET);
-       sqinet_set_v4_inaddr(&checklist.src_address, &from.sin_addr);
-#warning needs to be made ipv6-aware for "my_address"!
-       sqinet_set_family(&checklist.my_address, AF_INET);
+       sqinet_copy(&checklist.src_address, from);
+       sqinet_set_family(&checklist.my_address, sqinet_get_family(from));
        sqinet_set_noaddr(&checklist.my_address);
        checklist.request = icp_request;
        allow = aclCheckFast(Config.accessList.icp, &checklist);
        if (!allow) {
-           debug(12, 2) ("icpHandleIcpV3: Access Denied for %s by %s.\n",
-               inet_ntoa(from.sin_addr), AclMatchedName);
-           if (clientdbCutoffDenied(from.sin_addr)) {
+            if (do_debug(12, 2)) {
+                (void) sqinet_ntoa(from, sbuf, MAX_IPSTRLEN, SQADDR_NONE);
+ debug(12, 2) ("icpHandleIcpV3: Access Denied for %s by %s.\n",
+                  sbuf, AclMatchedName);
+           }
+           if (clientdbCutoffDenied(from)) {
                /*
                 * count this DENIED query in the clientdb, even though
                 * we're not sending an ICP reply...
                 */
-               clientdbUpdate(from.sin_addr, LOG_UDP_DENIED, PROTO_ICP, 0);
+               clientdbUpdate6(from, LOG_UDP_DENIED, PROTO_ICP, 0);
            } else {
                reply = icpCreateMessage(ICP_DENIED, 0, url, header.reqnum, 0);
-               icpUdpSend(fd, &from, reply, LOG_UDP_DENIED, 0);
+               icpUdpSend(fd, from, reply, LOG_UDP_DENIED, 0);
            }
            break;
        }
@@ -111,19 +114,19 @@
            icp_opcode_str[header.opcode]);
        if (icpCheckUdpHit(entry, icp_request)) {
            reply = icpCreateMessage(ICP_HIT, 0, url, header.reqnum, 0);
-           icpUdpSend(fd, &from, reply, LOG_UDP_HIT, 0);
+           icpUdpSend(fd, from, reply, LOG_UDP_HIT, 0);
            break;
        }
        /* if store is rebuilding, return a UDP_HIT, but not a MISS */
        if (opt_reload_hit_only && store_dirs_rebuilding) {
            reply = icpCreateMessage(ICP_MISS_NOFETCH, 0, url, header.reqnum, 
0);
-           icpUdpSend(fd, &from, reply, LOG_UDP_MISS_NOFETCH, 0);
+           icpUdpSend(fd, from, reply, LOG_UDP_MISS_NOFETCH, 0);
        } else if (hit_only_mode_until > squid_curtime) {
            reply = icpCreateMessage(ICP_MISS_NOFETCH, 0, url, header.reqnum, 
0);
-           icpUdpSend(fd, &from, reply, LOG_UDP_MISS_NOFETCH, 0);
+           icpUdpSend(fd, from, reply, LOG_UDP_MISS_NOFETCH, 0);
        } else {
            reply = icpCreateMessage(ICP_MISS, 0, url, header.reqnum, 0);
-           icpUdpSend(fd, &from, reply, LOG_UDP_MISS, 0);
+           icpUdpSend(fd, from, reply, LOG_UDP_MISS, 0);
        }
        break;

@@ -136,19 +139,23 @@
     case ICP_DENIED:
     case ICP_MISS_NOFETCH:
        if (neighbors_do_private_keys && header.reqnum == 0) {
-           debug(12, 0) ("icpHandleIcpV3: Neighbor %s returned reqnum = 0\n",
-               inet_ntoa(from.sin_addr));
+            (void) sqinet_ntoa(from, sbuf, MAX_IPSTRLEN, SQADDR_NONE);
+ debug(12, 0) ("icpHandleIcpV3: Neighbor %s returned reqnum = 0\n",
+              sbuf);
            debug(12, 0) ("icpHandleIcpV3: Disabling use of private keys\n");
            neighbors_do_private_keys = 0;
        }
        url = buf + sizeof(icp_common_t);
-       debug(12, 3) ("icpHandleIcpV3: %s from %s for '%s'\n",
-           icp_opcode_str[header.opcode],
-           inet_ntoa(from.sin_addr),
-           url);
+        if (do_debug(12, 3)) {
+            (void) sqinet_ntoa(from, sbuf, MAX_IPSTRLEN, SQADDR_NONE);
+            debug(12, 3) ("icpHandleIcpV3: %s from %s for '%s'\n",
+              icp_opcode_str[header.opcode],
+              sbuf,
+              url);
+        }
        key = icpGetCacheKey(url, (int) header.reqnum);
        /* call neighborsUdpAck even if ping_status != PING_WAITING */
-       neighborsUdpAck(key, &header, &from);
+       neighborsUdpAck(key, &header, from);
        break;

     case ICP_INVALID:
@@ -156,8 +163,9 @@
        break;

     default:
+        (void) sqinet_ntoa(from, sbuf, MAX_IPSTRLEN, SQADDR_NONE);
        debug(12, 0) ("icpHandleIcpV3: UNKNOWN OPCODE: %d from %s\n",
-           header.opcode, inet_ntoa(from.sin_addr));
+           header.opcode, sbuf);
        break;
     }
     if (icp_request)
=======================================
--- /playpen/LUSCA_HEAD_ipv6/src/neighbors.c    Tue Jan 11 21:34:35 2011
+++ /playpen/LUSCA_HEAD_ipv6/src/neighbors.c    Sun Jul 10 02:19:03 2011
@@ -56,7 +56,7 @@
 static void peerCountMcastPeersStart(void *data);
 static void peerCountMcastPeersSchedule(peer * p, time_t when);
 static IRCB peerCountHandleIcpReply;
-static void neighborIgnoreNonPeer(const struct sockaddr_in *, icp_opcode);
+static void neighborIgnoreNonPeer(const sqaddr_t *, icp_opcode);
 static OBJH neighborDumpPeers;
 static OBJH neighborDumpNonPeers;
 static void dump_peers(StoreEntry * sentry, peer * peers);
@@ -81,16 +81,20 @@


 peer *
-whichPeer(const struct sockaddr_in * from)
+whichPeer(const sqaddr_t * from)
 {
     int j;
-    u_short port = ntohs(from->sin_port);
-    struct in_addr ip = from->sin_addr;
+    u_short port = sqinet_get_port(from);
     peer *p = NULL;
-    debug(15, 3) ("whichPeer: from %s port %d\n", inet_ntoa(ip), port);
+    if (do_debug(15, 3)) {
+        char sbuf[MAX_IPSTRLEN];
+        (void) sqinet_ntoa(from, sbuf, MAX_IPSTRLEN, SQADDR_NONE);
+        debug(15, 3) ("whichPeer: from %s port %d\n", sbuf, port);
+    }
     for (p = Config.peers; p; p = p->next) {
        for (j = 0; j < p->n_addresses; j++) {
-           if (ip.s_addr == p->addresses[j].s_addr && port == p->icp.port) {
+           if (sqinet_compare_port(from, &p->addresses[j]) &&
+              sqinet_compare_addr(from, &p->addresses[j])) {
                return p;
            }
        }
@@ -482,7 +486,7 @@
            echo_hdr.reqnum = reqnum;
            query = icpCreateMessage(ICP_DECHO, 0, url, reqnum, 0);
            icpUdpSend(theOutIcpConnection,
-               &p->in_addr,
+               &p->addr,
                query,
                LOG_ICP_QUERY,
                0);
@@ -493,7 +497,7 @@
                    flags |= ICP_FLAG_SRC_RTT;
            query = icpCreateMessage(ICP_QUERY, flags, url, reqnum, 0);
            icpUdpSend(theOutIcpConnection,
-               &p->in_addr,
+               &p->addr,
                query,
                LOG_ICP_QUERY,
                0);
@@ -757,23 +761,25 @@
 static peer *non_peers = NULL;

 static void
-neighborIgnoreNonPeer(const struct sockaddr_in *from, icp_opcode opcode)
+neighborIgnoreNonPeer(const sqaddr_t *from, icp_opcode opcode)
 {
     peer *np;
     for (np = non_peers; np; np = np->next) {
-       if (np->in_addr.sin_addr.s_addr != from->sin_addr.s_addr)
+       if (! sqinet_compare_addr(from, &np->addr))
            continue;
-       if (np->in_addr.sin_port != from->sin_port)
+       if (! sqinet_compare_port(from, &np->addr))
            continue;
        break;
     }
     if (np == NULL) {
+        char sbuf[MAX_IPSTRLEN];
+        (void) sqinet_ntoa(from, sbuf, MAX_IPSTRLEN, SQADDR_NONE);
        np = xcalloc(1, sizeof(peer));
-       np->in_addr.sin_addr = from->sin_addr;
-       np->in_addr.sin_port = from->sin_port;
-       np->icp.port = ntohl(from->sin_port);
+        sqinet_init(&np->addr);
+        sqinet_copy(&np->addr, from);
+       np->icp.port = sqinet_get_port(from);
        np->type = PEER_NONE;
-       np->host = xstrdup(inet_ntoa(from->sin_addr));
+       np->host = xstrdup(sbuf);
        np->next = non_peers;
        non_peers = np;
     }
@@ -808,7 +814,8 @@
  * If a hit process is already started, then sobeit
  */
 void
-neighborsUdpAck(const cache_key * key, icp_common_t * header, const struct sockaddr_in *from)
+neighborsUdpAck(const cache_key * key, icp_common_t * header,
+  const sqaddr_t *from)
 {
     peer *p = NULL;
     StoreEntry *entry;
@@ -898,7 +905,11 @@
mem->ping_reply_callback(NULL, ntype, PROTO_ICP, header, mem->ircb_data);
 #endif
        } else {
- debug(15, 1) ("Unsolicited SECHO from %s\n", inet_ntoa(from->sin_addr));
+            if (do_debug(15, 1)) {
+                char sbuf[MAX_IPSTRLEN];
+                (void) sqinet_ntoa(from, sbuf, MAX_IPSTRLEN, SQADDR_NONE);
+                debug(15, 1) ("Unsolicited SECHO from %s\n", sbuf);
+            }
        }
     } else if (opcode == ICP_DENIED) {
        if (p == NULL) {
@@ -984,6 +995,7 @@
        safe_free(l);
     }
     aclDestroyAccessList(&p->access);
+    sqinet_done(&p->addr);
     safe_free(p->host);
     safe_free(p->name);
     safe_free(p->domain);
@@ -1034,7 +1046,6 @@
 peerDNSConfigure(const ipcache_addrs * ia, void *data)
 {
     peer *p = data;
-    struct sockaddr_in *ap;
     int j;
     if (p->n_addresses == 0) {
        debug(15, 1) ("Configuring %s %s %s/%d/%d\n", p->name, 
neighborTypeStr(p),
@@ -1052,17 +1063,18 @@
        return;
     }
     for (j = 0; j < (int) ia->count && j < PEER_MAX_ADDRESSES; j++) {
-       p->addresses[j] = ipcacheGetAddrV4(ia, j);
-       debug(15, 2) ("--> IP address #%d: %s\n", j, 
inet_ntoa(p->addresses[j]));
-       p->n_addresses++;
+        ipcacheGetAddr(ia, j, &p->addresses[j]);
+        if (do_debug(15, 2)) {
+            char sbuf[MAX_IPSTRLEN];
+            (void) sqinet_ntoa(&p->addresses[j], sbuf, MAX_IPSTRLEN,
+              SQADDR_NONE);
+            debug(15, 2) ("--> IP address #%d: %s\n", j, sbuf);
+        }
+        p->n_addresses++;
     }
     if (!p->tcp_up)
        peerProbeConnect((peer *) p);
-    ap = &p->in_addr;
-    memset(ap, '\0', sizeof(struct sockaddr_in));
-    ap->sin_family = AF_INET;
-    ap->sin_addr = p->addresses[0];
-    ap->sin_port = htons(p->icp.port);
+    sqinet_copy(&p->addr, &p->addresses[0]);
     if (p->type == PEER_MULTICAST)
        peerCountMcastPeersSchedule(p, 10);
     if (p->type != PEER_MULTICAST)
@@ -1203,10 +1215,13 @@
     int reqnum;
     method_t *method_get;
     LOCAL_ARRAY(char, url, MAX_URL);
+    char sbuf[MAX_IPSTRLEN];
+
     assert(p->type == PEER_MULTICAST);
     method_get = urlMethodGetKnownByCode(METHOD_GET);
     p->mcast.flags.count_event_pending = 0;
-    snprintf(url, MAX_URL, "http://%s/";, inet_ntoa(p->in_addr.sin_addr));
+    (void) sqinet_ntoa(&p->addr, sbuf, MAX_IPSTRLEN, SQADDR_NONE);
+    snprintf(url, MAX_URL, "http://%s/";, sbuf);
     fake = storeCreateEntry(url, null_request_flags, method_get);
     CBDATA_INIT_TYPE(ps_state);
     psstate = cbdataAlloc(ps_state);
@@ -1226,7 +1241,7 @@
     reqnum = icpSetCacheKey(fake->hash.key);
     query = icpCreateMessage(ICP_QUERY, 0, url, reqnum, 0);
     icpUdpSend(theOutIcpConnection,
-       &p->in_addr,
+       &p->addr,
        query,
        LOG_ICP_QUERY,
        0);
@@ -1383,6 +1398,8 @@
     struct _domain_ping *d = NULL;
     icp_opcode op;
     int i;
+    char sbuf[MAX_IPSTRLEN];
+
     if (peers == NULL)
        storeAppendPrintf(sentry, "There are no neighbors installed.\n");
     for (e = peers; e; e = e->next) {
@@ -1397,8 +1414,8 @@
        storeAppendPrintf(sentry, "Flags      :");
        dump_peer_options(sentry, e);
        for (i = 0; i < e->n_addresses; i++) {
-           storeAppendPrintf(sentry, "Address[%d] : %s\n", i,
-               inet_ntoa(e->addresses[i]));
+ (void) sqinet_ntoa(&e->addresses[i], sbuf, MAX_IPSTRLEN, SQADDR_NONE);
+           storeAppendPrintf(sentry, "Address[%d] : %s\n", i, sbuf);
        }
        storeAppendPrintf(sentry, "Status     : %s\n",
            neighborUp(e) ? "Up" : "Down");
@@ -1466,7 +1483,8 @@

 #if USE_HTCP
 void
-neighborsHtcpReply(const cache_key * key, htcpReplyData * htcp, const struct sockaddr_in *from)
+neighborsHtcpReply(const cache_key * key, htcpReplyData * htcp,
+  const sqaddr_t *from)
 {
     StoreEntry *e = storeGet(key);
     MemObject *mem = NULL;
@@ -1539,7 +1557,12 @@
        if (p->options.htcp_no_purge_clr && reason == HTCP_CLR_PURGE) {
            continue;
        }
- debug(15, 3) ("neighborsHtcpClear: sending CLR to %s:%d\n", inet_ntoa(p->in_addr.sin_addr), ntohs(p->in_addr.sin_port));
+        if (do_debug(15, 3)) {
+            char sbuf[MAX_IPSTRLEN];
+            (void) sqinet_ntoa(&p->addr, sbuf, MAX_IPSTRLEN, SQADDR_NONE);
+            debug(15, 3) ("neighborsHtcpClear: sending CLR to %s:%d\n",
+              sbuf, sqinet_get_port(&p->addr));
+        }
        htcpClear(e, uri, req, method, p, reason);
     }
 }
=======================================
--- /playpen/LUSCA_HEAD_ipv6/src/peer_select.c  Mon Feb  8 01:08:16 2010
+++ /playpen/LUSCA_HEAD_ipv6/src/peer_select.c  Sun Jul 10 02:19:03 2011
@@ -423,10 +423,10 @@
        code = SOURCE_FASTEST;
     } else
 #endif
-    if (! IsAnyAddr(&ps->closest_parent_miss.sin_addr)) {
+    if (! sqinet_is_anyaddr(&ps->closest_parent_miss)) {
        p = whichPeer(&ps->closest_parent_miss);
        code = CLOSEST_PARENT_MISS;
-    } else if (! IsAnyAddr(&ps->first_parent_miss.sin_addr)) {
+    } else if (! sqinet_is_anyaddr(&ps->first_parent_miss)) {
        p = whichPeer(&ps->first_parent_miss);
        code = FIRST_PARENT_MISS;
     }
@@ -551,7 +551,7 @@
            if (rtt > 0 && rtt < 0xFFFF)
                netdbUpdatePeer(ps->request, p, rtt, hops);
            if (rtt && (ps->ping.p_rtt == 0 || rtt < ps->ping.p_rtt)) {
-               ps->closest_parent_miss = p->in_addr;
+               sqinet_copy(&ps->closest_parent_miss, &p->addr);
                ps->ping.p_rtt = rtt;
            }
        }
@@ -560,12 +560,12 @@
     if (p->options.closest_only)
        return;
     /* set FIRST_MISS if there is no CLOSEST parent */
-    if (! IsAnyAddr(&ps->closest_parent_miss.sin_addr))
+    if (! sqinet_is_anyaddr(&ps->closest_parent_miss))
        return;
     rtt = tvSubMsec(ps->ping.start, current_time) / p->weight;
-    if (IsAnyAddr(&ps->first_parent_miss.sin_addr) ||
+    if (sqinet_is_anyaddr(&ps->first_parent_miss) ||
        rtt < ps->ping.w_rtt) {
-       ps->first_parent_miss = p->in_addr;
+       sqinet_copy(&ps->first_parent_miss, &p->addr);
        ps->ping.w_rtt = rtt;
     }
 }
@@ -639,7 +639,7 @@
            hops = (int) htcp->cto.hops * 1000;
            netdbUpdatePeer(ps->request, p, rtt, hops);
            if (rtt && (ps->ping.p_rtt == 0 || rtt < ps->ping.p_rtt)) {
-               ps->closest_parent_miss = p->in_addr;
+               sqinet_copy(&ps->closest_parent_miss, &p->addr);
                ps->ping.p_rtt = rtt;
            }
        }
@@ -648,12 +648,12 @@
     if (p->options.closest_only)
        return;
     /* set FIRST_MISS if there is no CLOSEST parent */
-    if (! IsAnyAddr(&ps->closest_parent_miss.sin_addr))
+    if (! sqinet_is_anyaddr(&ps->closest_parent_miss))
        return;
     rtt = tvSubMsec(ps->ping.start, current_time) / p->weight;
-    if (IsAnyAddr(&ps->first_parent_miss.sin_addr) ||
+    if (sqinet_is_anyaddr(&ps->first_parent_miss) ||
        rtt < ps->ping.w_rtt) {
-       ps->first_parent_miss = p->in_addr;
+       sqinet_copy(&ps->first_parent_miss, &p->addr);
        ps->ping.w_rtt = rtt;
     }
 }
=======================================
--- /playpen/LUSCA_HEAD_ipv6/src/protos.h       Sat Jul  9 18:52:04 2011
+++ /playpen/LUSCA_HEAD_ipv6/src/protos.h       Sun Jul 10 02:19:03 2011
@@ -38,7 +38,7 @@
 extern void accessLogEntryDone(AccessLogEntry *al);
 extern void accessLogEntryClearHack(AccessLogEntry *al);
extern void accessLogEntrySetReplyStatus(AccessLogEntry *al, HttpReply *reply); -extern void accessLogEntrySetClientAddr(AccessLogEntry *al, sqaddr_t *addr); +extern void accessLogEntrySetClientAddr(AccessLogEntry *al, const sqaddr_t *addr); extern void accessLogEntrySetClientAddr4(AccessLogEntry *al, struct in_addr addr);
 extern void accessLogEntrySetOutAddr(AccessLogEntry *al, sqaddr_t *addr);
extern void accessLogEntrySetOutAddr4(AccessLogEntry *al, struct in_addr addr);
@@ -274,7 +274,7 @@
     const char *url,
     int reqnum,
     int pad);
-extern int icpUdpSend(int, const struct sockaddr_in *, icp_common_t *, log_type, int); +extern int icpUdpSend(int, const sqaddr_t *to, icp_common_t *, log_type, int);
 extern PF icpHandleUdp;
 extern PF icpUdpSendQueue;
 extern PF httpAccept;
@@ -314,7 +314,7 @@
 extern void wccp2ConnectionClose(void);
 #endif /* USE_WCCPv2 */

-extern void icpHandleIcpV3(int, struct sockaddr_in, char *, int);
+extern void icpHandleIcpV3(int, const sqaddr_t *, char *, int);
 extern int icpCheckUdpHit(StoreEntry *, request_t * request);
 extern void icpConnectionsOpen(void);
 extern void icpConnectionShutdown(void);
@@ -359,7 +359,8 @@
     int *exprep,
     int *timeout);
 extern void neighborAddAcl(const char *, const char *);
-extern void neighborsUdpAck(const cache_key *, icp_common_t *, const struct sockaddr_in *);
+extern void neighborsUdpAck(const cache_key *, icp_common_t *,
+  const sqaddr_t *);
extern void neighborAdd(const char *, const char *, int, int, int, int, int);
 extern void neighbors_init(void);
 #if USE_HTCP
@@ -384,9 +385,10 @@
 extern void peerConnectSucceded(peer *);
 extern void dump_peer_options(StoreEntry *, peer *);
 extern int peerHTTPOkay(const peer *, request_t *);
-extern peer *whichPeer(const struct sockaddr_in *from);
+extern peer *whichPeer(const sqaddr_t *from);
 #if USE_HTCP
-extern void neighborsHtcpReply(const cache_key *, htcpReplyData *, const struct sockaddr_in *);
+extern void neighborsHtcpReply(const cache_key *, htcpReplyData *,
+  const sqaddr_t *);
 #endif
 extern void peerAddFwdServer(FwdServer ** FS, peer * p, hier_code code);
 extern int peerAllowedToUse(const peer *, request_t *);
=======================================
--- /playpen/LUSCA_HEAD_ipv6/src/snmp_agent.c   Sat Apr 26 06:32:35 2008
+++ /playpen/LUSCA_HEAD_ipv6/src/snmp_agent.c   Sun Jul 10 02:19:03 2011
@@ -148,6 +148,7 @@
     return Answer;
 }

+#if 0
 variable_list *
 snmp_meshPtblFn(variable_list * Var, snint * ErrP)
 {
@@ -270,6 +271,7 @@
     }
     return Answer;
 }
+#endif

 variable_list *
 snmp_prfSysFn(variable_list * Var, snint * ErrP)
=======================================
--- /playpen/LUSCA_HEAD_ipv6/src/structs.h      Sat Jul  9 19:10:58 2011
+++ /playpen/LUSCA_HEAD_ipv6/src/structs.h      Sun Jul 10 02:19:03 2011
@@ -898,7 +898,7 @@
 };

 struct _icpUdpData {
-    struct sockaddr_in address;
+    sqaddr_t addr;
     void *msg;
     size_t len;
     icpUdpData *next;
@@ -1169,7 +1169,7 @@
     char *name;
     char *host;
     peer_t type;
-    struct sockaddr_in in_addr;
+    sqaddr_t addr;
     struct {
        int pings_sent;
        int pings_acked;
@@ -1251,7 +1251,7 @@
     char *digest_url;
 #endif
     int tcp_up;                        /* 0 if a connect() fails */
-    struct in_addr addresses[10];
+    sqaddr_t addresses[10];
     int n_addresses;
     int rr_count;
     peer *next;
@@ -1350,8 +1350,9 @@
      * the peer * based on the address when we are finally ready to
      * reference the peer structure.
      */
-    struct sockaddr_in first_parent_miss;
-    struct sockaddr_in closest_parent_miss;
+    /* XXX what if a peer has >1 IP address? */
+    sqaddr_t first_parent_miss;
+    sqaddr_t closest_parent_miss;
     /*
      * ->hit and ->secho can be peer* because they should only be
      * accessed during the thread when they are set

--
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.

Reply via email to