From: wessels <> Date: Sat, 2 May 1998 12:42:43 +0000 (+0000) Subject: binary netdb peer-peer transfers X-Git-Tag: SQUID_3_0_PRE1~3393 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de2a0782959b1feea6b1e26eaa0d68adcbc6bf55;p=thirdparty%2Fsquid.git binary netdb peer-peer transfers --- diff --git a/src/enums.h b/src/enums.h index 49e6a16889..22646b6e0f 100644 --- a/src/enums.h +++ b/src/enums.h @@ -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 +}; diff --git a/src/net_db.cc b/src/net_db.cc index c37f805f46..e61648a40c 100644 --- a/src/net_db.cc +++ b/src/net_db.cc @@ -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 +}