Revision: 14725
Author: adrian.chadd
Date: Sun Jul 11 01:35:24 2010
Log: IPv6: add a v6 enabled wrapper around clientdbUpdate().

The client_db code is still only v4 aware but this at least pushes the v6-ness
down to the internals. The API will remain the same.


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

Modified:
 /playpen/LUSCA_HEAD_ipv6/src/client_db.c
 /playpen/LUSCA_HEAD_ipv6/src/client_db.h

=======================================
--- /playpen/LUSCA_HEAD_ipv6/src/client_db.c    Sun Jul  4 07:17:21 2010
+++ /playpen/LUSCA_HEAD_ipv6/src/client_db.c    Sun Jul 11 01:35:24 2010
@@ -43,7 +43,7 @@
 #define        CLIENT_DB_SCHEDULE_IMMEDIATE_TIME       5

 struct _ClientInfo {
-    struct in_addr addr;
+    sqaddr_t saddr;
     dlink_node node;
     struct {
         int result_hist[LOG_TYPE_MAX];
@@ -87,7 +87,9 @@

     Init_Prefix(&p, AF_INET, &addr, 32);
     c = memPoolAlloc(pool_client_info);
-    c->addr = addr;
+    sqinet_init(&c->saddr);
+    sqinet_set_v4_inaddr(&c->saddr, &addr);
+ /* XXX this is a v4 address for now; will need to also handle v6 types too */
     rn = radix_lookup(client_v4_tree, &p);
     rn->data = c;
     dlinkAddTail(c, &c->node, &client_list);
@@ -115,6 +117,15 @@
     client_v6_tree = New_Radix();
cachemgrRegister("client_list", "Cache Client List", clientdbDump, 0, 1);
 }
+
+void
+clientdbUpdate6(sqaddr_t *addr, log_type ltype, protocol_t p, squid_off_t size)
+{
+       struct in_addr a;
+
+       a = sqinet_get_v4_inaddr(addr, SQADDR_ASSERT_IS_V4);
+       clientdbUpdate(a, ltype, p, size);
+}

 void
clientdbUpdate(struct in_addr addr, log_type ltype, protocol_t p, squid_off_t size)
@@ -238,9 +249,14 @@
clientdbDumpEntry(StoreEntry *sentry, ClientInfo *c, struct clientdb_iterate_stats *ci)
 {
         log_type l;
-
-       storeAppendPrintf(sentry, "Address: %s\n", xinet_ntoa(c->addr));
+       char sbuf[MAX_IPSTRLEN];
+
+       sqinet_ntoa(&c->saddr, sbuf, MAX_IPSTRLEN, SQADDR_NONE);
+
+       storeAppendPrintf(sentry, "Address: %s\n", sbuf);
+#if 0
        storeAppendPrintf(sentry, "Name: %s\n", fqdnFromAddr(c->addr));
+#endif
        storeAppendPrintf(sentry, "Currently established connections: %d\n",
            c->n_established);
        storeAppendPrintf(sentry, "    ICP Requests %d\n",
@@ -355,8 +371,21 @@
       if (age < 60)
           continue;

-      Init_Prefix(&p, AF_INET, &c->addr, 32);
-      rn = radix_search_exact(client_v4_tree, &p);
+      /* Do the (conditional) lookup */
+      if (sqinet_get_family(&c->saddr) == AF_INET) {
+       struct in_addr pp;
+       pp = sqinet_get_v4_inaddr(&c->saddr, SQADDR_ASSERT_IS_V4);
+       Init_Prefix(&p, AF_INET, &pp, 32);
+       rn = radix_search_exact(client_v4_tree, &p);
+      } else {
+       struct in6_addr pp;
+       pp = sqinet_get_v6_inaddr(&c->saddr, SQADDR_ASSERT_IS_V6);
+       Init_Prefix(&p, AF_INET6, &pp, 128);
+       rn = radix_search_exact(client_v6_tree, &p);
+      }
+ /* XXX remind me why I'm not free'ing this Prefix being created by Init_Prefix again? */
+      /* XXX ah, because it's Init_Prefix, rather than New_Prefix. Ok. */
+
       rn->data = NULL;
       radix_remove(client_v4_tree, rn);
       clientdbFreeItem(c);
=======================================
--- /playpen/LUSCA_HEAD_ipv6/src/client_db.h    Sun Jul  4 06:56:53 2010
+++ /playpen/LUSCA_HEAD_ipv6/src/client_db.h    Sun Jul 11 01:35:24 2010
@@ -4,6 +4,7 @@
 extern void clientdbInitMem(void);
 extern void clientdbInit(void);
extern void clientdbUpdate(struct in_addr, log_type, protocol_t, squid_off_t); +extern void clientdbUpdate6(sqaddr_t *addr, log_type, protocol_t, squid_off_t);
 extern int clientdbCutoffDenied(struct in_addr);
 extern void clientdbDump(StoreEntry *);
 extern void clientdbFreeMemory(void);

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