]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/icmp/net_db.cc
Merge form trunk
[thirdparty/squid.git] / src / icmp / net_db.cc
index ada63ca311562e21b41c4896fe966939f04d2d0a..216847484264c6d6a28ac9a0bd56bac292bc2b32 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id: net_db.cc,v 1.202 2008/01/07 17:12:28 hno Exp $
- *
  * DEBUG: section 38    Network Measurement Database
  * AUTHOR: Duane Wessels
  *
 
 #include "squid.h"
 #include "icmp/net_db.h"
+#include "log/File.h"
 #include "cbdata.h"
 #include "event.h"
-#include "CacheManager.h"
+#include "mgr/Registration.h"
 #include "Store.h"
 #include "SwapDir.h"
 #include "HttpRequest.h"
@@ -54,7 +53,7 @@
 #include "forward.h"
 #include "SquidTime.h"
 #include "wordlist.h"
-#include "IpAddress.h"
+#include "ip/Address.h"
 
 #if USE_ICMP
 #include "icmp/IcmpSquid.h"
@@ -83,10 +82,10 @@ typedef struct {
 static hash_table *addr_table = NULL;
 static hash_table *host_table = NULL;
 
-IpAddress networkFromInaddr(const IpAddress &a);
+Ip::Address networkFromInaddr(const Ip::Address &a);
 static void netdbRelease(netdbEntry * n);
 
-static void netdbHashInsert(netdbEntry * n, IpAddress &addr);
+static void netdbHashInsert(netdbEntry * n, Ip::Address &addr);
 static void netdbHashDelete(const char *key);
 static void netdbHostInsert(netdbEntry * n, const char *hostname);
 static void netdbHostDelete(const net_db_name * x);
@@ -111,7 +110,7 @@ static void netdbExchangeDone(void *);
 static wordlist *peer_names = NULL;
 
 static void
-netdbHashInsert(netdbEntry * n, IpAddress &addr)
+netdbHashInsert(netdbEntry * n, Ip::Address &addr)
 {
     networkFromInaddr(addr).NtoA(n->network, MAX_IPSTRLEN);
     n->hash.key = n->network;
@@ -247,17 +246,18 @@ netdbPurgeLRU(void)
 }
 
 static netdbEntry *
-netdbLookupAddr(const IpAddress &addr)
+netdbLookupAddr(const Ip::Address &addr)
 {
     netdbEntry *n;
     char *key = new char[MAX_IPSTRLEN];
     networkFromInaddr(addr).NtoA(key,MAX_IPSTRLEN);
     n = (netdbEntry *) hash_lookup(addr_table, key);
+    delete[] key;
     return n;
 }
 
 static netdbEntry *
-netdbAdd(IpAddress &addr)
+netdbAdd(Ip::Address &addr)
 {
     netdbEntry *n;
 
@@ -273,9 +273,9 @@ netdbAdd(IpAddress &addr)
 }
 
 static void
-netdbSendPing(const ipcache_addrs * ia, void *data)
+netdbSendPing(const ipcache_addrs *ia, const DnsLookupDetails &, void *data)
 {
-    IpAddress addr;
+    Ip::Address addr;
     char *hostname = NULL;
     static_cast<generic_cbdata *>(data)->unwrap(&hostname);
     netdbEntry *n;
@@ -340,22 +340,19 @@ netdbSendPing(const ipcache_addrs * ia, void *data)
     xfree(hostname);
 }
 
-IpAddress
-networkFromInaddr(const IpAddress &in)
+Ip::Address
+networkFromInaddr(const Ip::Address &in)
 {
-    IpAddress out;
+    Ip::Address out;
 
     out = in;
-#if USE_IPV6
 
     /* in IPv6 the 'network' should be the routing section. */
-
     if ( in.IsIPv6() ) {
         out.ApplyMask(64, AF_INET6);
         debugs(14, 5, "networkFromInaddr : Masked IPv6 Address to " << in << "/64 routing part.");
         return out;
     }
-#endif
 
 #if USE_CLASSFUL
     struct in_addr b;
@@ -536,7 +533,7 @@ netdbReloadState(void)
     netdbEntry *n;
     netdbEntry N;
 
-    IpAddress addr;
+    Ip::Address addr;
     int count = 0;
 
     struct timeval start = current_time;
@@ -677,7 +674,7 @@ netdbFreeNameEntry(void *data)
 static void
 netdbExchangeHandleReply(void *data, StoreIOBuffer receivedData)
 {
-    IpAddress addr;
+    Ip::Address addr;
 
     netdbExchangeState *ex = (netdbExchangeState *)data;
     int rec_sz = 0;
@@ -885,8 +882,7 @@ netdbExchangeDone(void *data)
 static void
 netdbRegisterWithCacheManager(void)
 {
-    CacheManager::GetInstance()->
-    registerAction("netdb", "Network Measurement Database", netdbDump, 0, 1);
+    Mgr::RegisterAction("netdb", "Network Measurement Database", netdbDump, 0, 1);
 }
 
 #endif /* USE_ICMP */
@@ -937,7 +933,7 @@ netdbPingSite(const char *hostname)
 }
 
 void
-netdbHandlePingReply(const IpAddress &from, int hops, int rtt)
+netdbHandlePingReply(const Ip::Address &from, int hops, int rtt)
 {
 #if USE_ICMP
     netdbEntry *n;
@@ -984,7 +980,7 @@ netdbFreeMemory(void)
 
 #if 0 // AYJ: Looks to be unused code.
 int
-netdbHops(IpAddress &addr)
+netdbHops(Ip::Address &addr)
 {
 #if USE_ICMP
     netdbEntry *n = netdbLookupAddr(addr);
@@ -1151,7 +1147,7 @@ netdbUpdatePeer(HttpRequest * r, peer * e, int irtt, int ihops)
 }
 
 void
-netdbExchangeUpdatePeer(IpAddress &addr, peer * e, double rtt, double hops)
+netdbExchangeUpdatePeer(Ip::Address &addr, peer * e, double rtt, double hops)
 {
 #if USE_ICMP
     netdbEntry *n;
@@ -1193,7 +1189,7 @@ netdbExchangeUpdatePeer(IpAddress &addr, peer * e, double rtt, double hops)
 }
 
 void
-netdbDeleteAddrNetwork(IpAddress &addr)
+netdbDeleteAddrNetwork(Ip::Address &addr)
 {
 #if USE_ICMP
     netdbEntry *n = netdbLookupAddr(addr);
@@ -1214,7 +1210,7 @@ netdbBinaryExchange(StoreEntry * s)
     HttpReply *reply = new HttpReply;
 #if USE_ICMP
 
-    IpAddress addr;
+    Ip::Address addr;
 
     netdbEntry *n;
     int i;
@@ -1224,8 +1220,7 @@ netdbBinaryExchange(StoreEntry * s)
 
     struct in_addr line_addr;
     s->buffer();
-    HttpVersion version(1, 0);
-    reply->setHeaders(version, HTTP_OK, "OK", NULL, -1, squid_curtime, -2);
+    reply->setHeaders(HTTP_OK, "OK", NULL, -1, squid_curtime, -2);
     s->replaceHttpReply(reply);
     rec_sz = 0;
     rec_sz += 1 + sizeof(struct in_addr);
@@ -1288,9 +1283,7 @@ netdbBinaryExchange(StoreEntry * s)
     memFree(buf, MEM_4K_BUF);
 #else
 
-    HttpVersion version(1,0);
-    reply->setHeaders(version, HTTP_BAD_REQUEST, "Bad Request",
-                      NULL, -1, squid_curtime, -2);
+    reply->setHeaders(HTTP_BAD_REQUEST, "Bad Request", NULL, -1, squid_curtime, -2);
     s->replaceHttpReply(reply);
     storeAppendPrintf(s, "NETDB support not compiled into this Squid cache.\n");
 #endif
@@ -1325,7 +1318,7 @@ netdbExchangeStart(void *data)
 
     HTTPMSGLOCK(ex->r);
     assert(NULL != ex->r);
-    ex->r->http_ver = HttpVersion(1,0);
+    ex->r->http_ver = HttpVersion(1,1);
     ex->connstate = STATE_HEADER;
     ex->e = storeCreateEntry(uri, uri, request_flags(), METHOD_GET);
     ex->buf_sz = NETDB_REQBUF_SZ;
@@ -1343,7 +1336,8 @@ netdbExchangeStart(void *data)
 
     urlCanonical(ex->r);
 
-    FwdState::fwdStart(-1, ex->e, ex->r);
+    Comm::ConnectionPointer nul;
+    FwdState::fwdStart(nul, ex->e, ex->r);
 
 #endif
 }