]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
binary netdb peer-peer transfers
authorwessels <>
Sat, 2 May 1998 12:42:43 +0000 (12:42 +0000)
committerwessels <>
Sat, 2 May 1998 12:42:43 +0000 (12:42 +0000)
src/enums.h
src/net_db.cc

index 49e6a16889bf5fbc886f23ec3b232f5cb63add68..22646b6e0f57193d04ada01dbf618b6e208a8e1e 100644 (file)
@@ -622,3 +622,13 @@ enum {
     SENT,
     RECV
 };
+
+/*
+ * These are field indicators for raw cache-cache netdb transfers
+ */
+enum {
+       NETDB_NONE,
+       NETDB_NETWORK,
+       NETDB_RTT,
+       NETDB_HOPS
+};
index c37f805f46581c97677a03846df33f6c8adb5777..e61648a40c5f9d3c02649b7e25cb539b53f2f8a3 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: net_db.cc,v 1.83 1998/04/07 23:50:54 rousskov Exp $
+ * $Id: net_db.cc,v 1.84 1998/05/02 06:42:43 wessels Exp $
  *
  * DEBUG: section 37    Network Measurement Database
  * AUTHOR: Duane Wessels
@@ -817,3 +817,58 @@ netdbDeleteAddrNetwork(struct in_addr addr)
     netdbRelease(n);
 #endif
 }
+
+void
+netdbBinaryExchange(StoreEntry * s)
+{
+#if USE_ICMP
+    http_reply *reply = s->mem_obj->reply;
+    netdbEntry *n;
+    netdbEntry *next;
+    int i;
+    int j;
+    int rec_sz;
+    char *buf;
+    struct in_addr addr;
+    storeBuffer(s);
+    httpReplyReset(reply);
+    httpReplySetHeaders(reply, 1.0, HTTP_OK, "OK",
+       NULL, -1, squid_curtime, -2);
+    httpReplySwapOut(reply, s);
+    rec_sz = 0;
+    rec_sz += 1 + sizeof(addr.s_addr);
+    rec_sz += 1 + sizeof(int);
+    rec_sz += 1 + sizeof(int);
+    buf = memAllocate(MEM_4K_BUF);
+    i = 0;
+    next = (netdbEntry *) hash_first(addr_table);
+    while (next != NULL) {
+       n = next;
+       next = (netdbEntry *) hash_next(addr_table);
+       if (0.0 == n->rtt)
+           continue;
+       if (!safe_inet_addr(n->network, &addr))
+           continue;
+       buf[i++] = (char) NETDB_NETWORK;
+       xmemcpy(&buf[i], &addr.s_addr, sizeof(addr.s_addr));
+       i += sizeof(addr.s_addr);
+       buf[i++] = (char) NETDB_RTT;
+       j = ntohl((int) (n->rtt * 1000));
+       xmemcpy(&buf[i], &j, sizeof(int));
+       i += sizeof(int);
+       buf[i++] = (char) NETDB_HOPS;
+       j = ntohl((int) (n->hops * 1000));
+       xmemcpy(&buf[i], &j, sizeof(int));
+       i += sizeof(int);
+       if (i + rec_sz > 4096 || next == NULL) {
+           storeAppend(s, buf, i);
+           i = 0;
+       }
+    }
+    assert(0 == i);
+    storeBufferFlush(s);
+    storeComplete(s);
+#else
+    storeAppendPrintf(s, "NETDB support not compiled into this Squid cache.\n");
+#endif
+}