]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
SourceLayout: shuffle DNS primitives to dns/libdns.la
authorAmos Jeffries <squid3@treenet.co.nz>
Thu, 29 Jan 2015 16:09:11 +0000 (08:09 -0800)
committerAmos Jeffries <squid3@treenet.co.nz>
Thu, 29 Jan 2015 16:09:11 +0000 (08:09 -0800)
* create dns/libdns.la with namespace Dns::

* move the RFC specific base functions performing DNS actions
  into libdns.

* move the SquidDns.h definitions to dns/forward.h
  - rename dns*() functions to Dns:: namespace

* move DnsLookupDetails to Dns:: namespace
  - move class files to libdns.

There are no logic changes in this patch.

36 files changed:
configure.ac
lib/Makefile.am
src/ClientRequestContext.h
src/HttpRequest.cc
src/HttpRequest.h
src/Makefile.am
src/acl/DestinationDomain.cc
src/acl/DestinationDomain.h
src/acl/DestinationIp.cc
src/acl/SourceDomain.cc
src/acl/SourceDomain.h
src/adaptation/icap/Xaction.cc
src/client_side_request.cc
src/dns/LookupDetails.cc [moved from src/DnsLookupDetails.cc with 69% similarity]
src/dns/LookupDetails.h [moved from src/DnsLookupDetails.h with 54% similarity]
src/dns/Makefile.am [new file with mode: 0644]
src/dns/forward.h [moved from src/SquidDns.h with 61% similarity]
src/dns/rfc1035.cc [moved from lib/rfc1035.c with 99% similarity]
src/dns/rfc1035.h [moved from include/rfc1035.h with 98% similarity]
src/dns/rfc2671.cc [moved from lib/rfc2671.c with 94% similarity]
src/dns/rfc2671.h [moved from include/rfc2671.h with 100% similarity]
src/dns/rfc3596.cc [moved from lib/rfc3596.c with 99% similarity]
src/dns/rfc3596.h [moved from include/rfc3596.h with 98% similarity]
src/dns_internal.cc
src/fqdncache.cc
src/icmp/net_db.cc
src/ipcache.cc
src/ipcache.h
src/main.cc
src/multicast.cc
src/neighbors.cc
src/peer_select.cc
src/send-announce.cc
src/tests/testRFC1035.cc [moved from lib/tests/testRFC1035.cc with 97% similarity]
src/tests/testRFC1035.h [moved from lib/tests/testRFC1035.h with 100% similarity]
src/typedefs.h

index 629021e5efeb1f0ad864d1f44d124d430d51609a..9d5565cee6fe0d1d12ca784d78ccda7a0384e619 100644 (file)
@@ -3859,6 +3859,7 @@ AC_CONFIG_FILES([
        src/base/Makefile
        src/clients/Makefile
        src/comm/Makefile
+       src/dns/Makefile
        src/esi/Makefile
        src/eui/Makefile
        src/format/Makefile
index d73181d2318efa58877ebc694fe8dadb7b8ddf02..804c1a5213c533fccbdf68971883119322ef918f 100644 (file)
@@ -71,31 +71,16 @@ libmiscutil_la_SOURCES = \
        heap.c \
        iso3307.c \
        radix.c \
-       rfc1035.c \
        rfc1123.c \
-       rfc2671.c \
-       rfc3596.c \
        $(SNPRINTFSOURCE) \
        Splay.cc \
        stub_memaccount.c \
        util.c \
        xusleep.c
 
-TESTS += tests/testRFC1035 tests/testRFC1738
+TESTS += tests/testRFC1738
 
-check_PROGRAMS += tests/testRFC1035 tests/testRFC1738
-
-tests_testRFC1035_SOURCES= \
-       tests/testRFC1035.h \
-       tests/testRFC1035.cc
-
-tests_testRFC1035_LDADD= \
-       $(SQUID_CPPUNIT_LA) $(SQUID_CPPUNIT_LIBS) \
-       $(top_builddir)/lib/libmiscencoding.la \
-       $(top_builddir)/lib/libmiscutil.la \
-       $(COMPAT_LIB)
-
-tests_testRFC1035_LDFLAGS = $(LIBADD_DL)
+check_PROGRAMS += tests/testRFC1738
 
 tests_testRFC1738_SOURCES= \
        tests/testRFC1738.h \
index 2a017d6cf04e1ee0dcb3393a09d532a52f079b1c..8862893ed6bb8b328cd83e8c779ca1029484c8de 100644 (file)
@@ -11,6 +11,7 @@
 
 #include "base/RefCount.h"
 #include "cbdata.h"
+#include "dns/forward.h"
 #include "helper/forward.h"
 #include "ipcache.h"
 
@@ -20,7 +21,6 @@
 
 class ACLChecklist;
 class ClientHttpRequest;
-class DnsLookupDetails;
 class ErrorState;
 
 class ClientRequestContext : public RefCountable
@@ -33,7 +33,7 @@ public:
 
     bool httpStateIsValid();
     void hostHeaderVerify();
-    void hostHeaderIpVerify(const ipcache_addrs* ia, const DnsLookupDetails &dns);
+    void hostHeaderIpVerify(const ipcache_addrs* ia, const Dns::LookupDetails &dns);
     void hostHeaderVerifyFailed(const char *A, const char *B);
     void clientAccessCheck();
     void clientAccessCheck2();
index 459cae8558d79446ffb9fdf97e4b244c5631d771..17abf97b9365716208fe615f09dd5db48c76d8ac 100644 (file)
@@ -13,7 +13,7 @@
 #include "acl/AclSizeLimit.h"
 #include "acl/FilledChecklist.h"
 #include "client_side.h"
-#include "DnsLookupDetails.h"
+#include "dns/LookupDetails.h"
 #include "err_detail_type.h"
 #include "globals.h"
 #include "gopher.h"
@@ -616,7 +616,7 @@ HttpRequest::conditional() const
 }
 
 void
-HttpRequest::recordLookup(const DnsLookupDetails &dns)
+HttpRequest::recordLookup(const Dns::LookupDetails &dns)
 {
     if (dns.wait >= 0) { // known delay
         if (dnsWait >= 0) // have recorded DNS wait before
index 73f30653632ff017941a2818a4bb9cc03e14be8a..de9339afbe6eac43a2c520811c89502f44d29bf4 100644 (file)
@@ -11,6 +11,7 @@
 
 #include "base/CbcPointer.h"
 #include "Debug.h"
+#include "dns/forward.h"
 #include "err_type.h"
 #include "HierarchyLogEntry.h"
 #include "http/RequestMethod.h"
@@ -39,7 +40,6 @@ class ConnStateData;
 void httpRequestPack(void *obj, Packer *p);
 
 class HttpHdrRange;
-class DnsLookupDetails;
 
 class HttpRequest: public HttpMsg
 {
@@ -100,7 +100,7 @@ public:
     Adaptation::Icap::History::Pointer icapHistory() const;
 #endif
 
-    void recordLookup(const DnsLookupDetails &detail);
+    void recordLookup(const Dns::LookupDetails &detail);
 
     /// sets error detail if no earlier detail was available
     void detailError(err_type aType, int aDetail);
index 6619f467780c85597e4795e8141d59102feb5272..9e89a9a6cf59a1a3c619e17a462ec85b358ded65 100644 (file)
@@ -10,10 +10,7 @@ include $(top_srcdir)/src/Common.am
 AUTOMAKE_OPTIONS = subdir-objects
 
 DNSSOURCE = \
-       dns_internal.cc \
-       SquidDns.h \
-       DnsLookupDetails.h \
-       DnsLookupDetails.cc
+       dns_internal.cc
 
 SBUF_SOURCE= \
        base/CharacterSet.h \
@@ -47,8 +44,8 @@ LOADABLE_MODULES_SOURCES = \
        LoadableModules.h \
        LoadableModules.cc
 
-SUBDIRS        = mem base anyp helper ftp parser comm eui acl format clients servers fs repl
-DIST_SUBDIRS = mem base anyp helper ftp parser comm eui acl format clients servers fs repl
+SUBDIRS        = mem base anyp helper dns ftp parser comm eui acl format clients servers fs repl
+DIST_SUBDIRS = mem base anyp helper dns ftp parser comm eui acl format clients servers fs repl
 
 if ENABLE_AUTH
 SUBDIRS += auth
@@ -614,6 +611,7 @@ squid_LDADD = \
        helper/libhelper.la \
        http/libsquid-http.la \
        parser/libsquid-parser.la \
+       dns/libdns.la \
        base/libbase.la \
        libsquid.la \
        ip/libip.la \
@@ -1059,6 +1057,7 @@ check_PROGRAMS+=\
        tests/testBoilerplate \
        tests/testCacheManager \
        tests/testDiskIO \
+       tests/testDns \
        tests/testEvent \
        tests/testEventLoop \
        tests/test_http_range \
@@ -1586,6 +1585,7 @@ tests_testCacheManager_LDADD = \
        acl/libacls.la \
        acl/libstate.la \
        acl/libapi.la \
+       dns/libdns.la \
        base/libbase.la \
        ip/libip.la \
        fs/libfs.la \
@@ -1768,7 +1768,6 @@ tests_testDiskIO_LDADD = \
        parser/libsquid-parser.la \
        SquidConfig.o \
        CommCalls.o \
-       DnsLookupDetails.o \
        ident/libident.la \
        acl/libacls.la \
        acl/libstate.la \
@@ -1784,6 +1783,7 @@ tests_testDiskIO_LDADD = \
        mgr/libmgr.la \
        $(SSL_LIBS) \
        ipc/libipc.la \
+       dns/libdns.la \
        base/libbase.la \
        mem/libmem.la \
        $(top_builddir)/lib/libmisccontainers.la \
@@ -1802,7 +1802,23 @@ tests_testDiskIO_DEPENDENCIES = \
        $(SWAP_TEST_DS) \
        $(SQUID_CPPUNIT_LA)
 
-## Tests of the Even module.
+tests_testDns_SOURCES= \
+       tests/testRFC1035.cc \
+       tests/testRFC1035.h
+nodist_tests_testDns_SOURCES= \
+       tests/stub_debug.cc \
+       tests/stub_SBuf.cc \
+       tests/stub_tools.cc
+tests_testDns_LDADD= \
+       dns/libdns.la \
+       base/libbase.la \
+       $(top_builddir)/lib/libmiscutil.la \
+       $(COMPAT_LIB) \
+       $(XTRA_LIBS) \
+       $(SQUID_CPPUNIT_LA) \
+       $(SQUID_CPPUNIT_LIBS)
+tests_testDns_LDFLAGS= $(LIBADD_DL)
+
 tests_testEvent_SOURCES = \
        AccessLogEntry.cc \
        BodyPipe.cc \
@@ -2012,6 +2028,7 @@ tests_testEvent_LDADD = \
        acl/libacls.la \
        acl/libstate.la \
        acl/libapi.la \
+       dns/libdns.la \
        base/libbase.la \
        ip/libip.la \
        fs/libfs.la \
@@ -2254,6 +2271,7 @@ tests_testEventLoop_LDADD = \
        acl/libacls.la \
        acl/libstate.la \
        acl/libapi.la \
+       dns/libdns.la \
        base/libbase.la \
        ip/libip.la \
        fs/libfs.la \
@@ -2506,6 +2524,7 @@ tests_test_http_range_LDADD = \
        $(ESI_LIBS) \
        $(SSL_LIBS) \
        ipc/libipc.la \
+       dns/libdns.la \
        base/libbase.la \
        mgr/libmgr.la \
        $(SNMP_LIBS) \
@@ -2782,6 +2801,7 @@ tests_testHttpRequest_LDADD = \
        $(SSL_LIBS) \
        ipc/libipc.la \
        parser/libsquid-parser.la \
+       dns/libdns.la \
        base/libbase.la \
        mgr/libmgr.la \
        anyp/libanyp.la \
@@ -2960,6 +2980,7 @@ tests_testStore_LDADD= \
        acl/libacls.la \
        acl/libstate.la \
        acl/libapi.la \
+       dns/libdns.la \
        base/libbase.la \
        ip/libip.la \
        fs/libfs.la \
@@ -2975,7 +2996,6 @@ tests_testStore_LDADD= \
        $(SQUID_CPPUNIT_LIBS) \
        $(SSLLIB) \
        CommCalls.o \
-       DnsLookupDetails.o \
        $(COMPAT_LIB) \
        $(XTRA_LIBS)
 tests_testStore_LDFLAGS = $(LIBADD_DL)
@@ -3182,7 +3202,6 @@ tests_testUfs_LDADD = \
        http/libsquid-http.la \
        parser/libsquid-parser.la \
        CommCalls.o \
-       DnsLookupDetails.o \
        ident/libident.la \
        acl/libacls.la \
        acl/libstate.la \
@@ -3200,6 +3219,7 @@ tests_testUfs_LDADD = \
        ipc/libipc.la \
        comm/libcomm.la \
        anyp/libanyp.la \
+       dns/libdns.la \
        base/libbase.la \
        ip/libip.la \
        mem/libmem.la \
@@ -3606,6 +3626,7 @@ tests_testURL_LDADD = \
        eui/libeui.la \
        acl/libstate.la \
        acl/libapi.la \
+       dns/libdns.la \
        base/libbase.la \
        ip/libip.la \
        fs/libfs.la \
index de9f8eddab241e5f3cdb0c159b1f497a5c7eba0e..5104cefc4f1a5df7688ac169fc9e466517c28129 100644 (file)
@@ -33,7 +33,7 @@ DestinationDomainLookup::checkForAsync(ACLChecklist *cl) const
 }
 
 void
-DestinationDomainLookup::LookupDone(const char *, const DnsLookupDetails &details, void *data)
+DestinationDomainLookup::LookupDone(const char *, const Dns::LookupDetails &details, void *data)
 {
     ACLFilledChecklist *checklist = Filled((ACLChecklist*)data);
     checklist->markDestinationDomainChecked();
index bfe0768387ceaa892d53a1ce1e5becaf0cb09a6d..d8e967bf831492d5757effb8ab63e49211c658a9 100644 (file)
@@ -48,7 +48,7 @@ public:
 
 private:
     static DestinationDomainLookup instance_;
-    static void LookupDone(const char *, const DnsLookupDetails &, void *);
+    static void LookupDone(const char *, const Dns::LookupDetails &, void *);
 };
 
 /// \ingroup ACLAPI
index 97ae96d25cf2dd5b209dab0799c2af703b3054d9..f7b7ef50022282bb1fcd9441da5d893c6d75f8ab 100644 (file)
@@ -91,7 +91,7 @@ DestinationIPLookup::checkForAsync(ACLChecklist *cl)const
 }
 
 void
-DestinationIPLookup::LookupDone(const ipcache_addrs *, const DnsLookupDetails &details, void *data)
+DestinationIPLookup::LookupDone(const ipcache_addrs *, const Dns::LookupDetails &details, void *data)
 {
     ACLFilledChecklist *checklist = Filled((ACLChecklist*)data);
     checklist->request->flags.destinationIpLookedUp = true;
index ec815d2d10f268cc6182efc5fe52932f4cb7a685..c53d11ebe73e6457114be2a2887aed234fb57563 100644 (file)
@@ -31,7 +31,7 @@ SourceDomainLookup::checkForAsync(ACLChecklist *checklist) const
 }
 
 void
-SourceDomainLookup::LookupDone(const char *, const DnsLookupDetails &details, void *data)
+SourceDomainLookup::LookupDone(const char *, const Dns::LookupDetails &details, void *data)
 {
     ACLFilledChecklist *checklist = Filled((ACLChecklist*)data);
     checklist->markSourceDomainChecked();
index 48550f969979f77fbdb27e09e4fa157c4f6f75de..3c459ae8c2ceec1716dc3d259e6d6eb1a61c0730 100644 (file)
@@ -40,7 +40,7 @@ public:
 
 private:
     static SourceDomainLookup instance_;
-    static void LookupDone(const char *, const DnsLookupDetails &, void *);
+    static void LookupDone(const char *, const Dns::LookupDetails &, void *);
 };
 
 class ACLSourceDomain
index 8dee87fad138d63970bd036cbd61dfc6e91d4e74..ada97ce6871126d0478b9cc57894aebdc2b9fd0b 100644 (file)
@@ -103,7 +103,7 @@ void Adaptation::Icap::Xaction::start()
 }
 
 static void
-icapLookupDnsResults(const ipcache_addrs *ia, const DnsLookupDetails &, void *data)
+icapLookupDnsResults(const ipcache_addrs *ia, const Dns::LookupDetails &, void *data)
 {
     Adaptation::Icap::Xaction *xa = static_cast<Adaptation::Icap::Xaction *>(data);
     xa->dnsLookupDone(ia);
index 7e488fcdad28a36fff0c36a178f4ba2aee866728..a702ea2621158c47e212127fec126f1022cb5ea9 100644 (file)
@@ -500,14 +500,14 @@ clientFollowXForwardedForCheck(allow_t answer, void *data)
 #endif /* FOLLOW_X_FORWARDED_FOR */
 
 static void
-hostHeaderIpVerifyWrapper(const ipcache_addrs* ia, const DnsLookupDetails &dns, void *data)
+hostHeaderIpVerifyWrapper(const ipcache_addrs* ia, const Dns::LookupDetails &dns, void *data)
 {
     ClientRequestContext *c = static_cast<ClientRequestContext*>(data);
     c->hostHeaderIpVerify(ia, dns);
 }
 
 void
-ClientRequestContext::hostHeaderIpVerify(const ipcache_addrs* ia, const DnsLookupDetails &dns)
+ClientRequestContext::hostHeaderIpVerify(const ipcache_addrs* ia, const Dns::LookupDetails &dns)
 {
     Comm::ConnectionPointer clientConn = http->getConn()->clientConnection;
 
similarity index 69%
rename from src/DnsLookupDetails.cc
rename to src/dns/LookupDetails.cc
index c0df2c341a39ba691f8d1ad82ce127f45ffb27c8..6829f11778c1132f9ff7f94062b4b0ab6237a5e2 100644 (file)
@@ -9,19 +9,10 @@
 /* DEBUG: section 78    DNS lookups */
 
 #include "squid.h"
-#include "DnsLookupDetails.h"
-
-DnsLookupDetails::DnsLookupDetails(): wait(-1)
-{
-}
-
-DnsLookupDetails::DnsLookupDetails(const String &e, int w):
-    error(e), wait(w)
-{
-}
+#include "dns/LookupDetails.h"
 
 std::ostream &
-DnsLookupDetails::print(std::ostream &os) const
+Dns::LookupDetails::print(std::ostream &os) const
 {
     if (wait > 0)
         os << "lookup_wait=" << wait;
similarity index 54%
rename from src/DnsLookupDetails.h
rename to src/dns/LookupDetails.h
index d6feb51a9f849b8254b0d6f0b8aca915d96be8d3..1f3b50910921082ca66a0e00e3b21d05255752f6 100644 (file)
@@ -8,30 +8,35 @@
 
 /* DEBUG: section 78    DNS lookups */
 
-#ifndef SQUID_DNS_LOOKUP_DETAILS_H
-#define SQUID_DNS_LOOKUP_DETAILS_H
+#ifndef SQUID_DNS_LOOKUPDETAILS_H
+#define SQUID_DNS_LOOKUPDETAILS_H
 
 #include "SquidString.h"
 
+namespace Dns
+{
+
 /// encapsulates DNS lookup results
-class DnsLookupDetails
+class LookupDetails
 {
 public:
-    DnsLookupDetails(); ///< no error, no lookup delay (i.e., no lookup)
-    DnsLookupDetails(const String &error, int wait);
+    LookupDetails() : wait(-1) {} ///< no error, no lookup delay (i.e., no lookup)
+    LookupDetails(const String &anError, int aWait) : error(anError), wait(aWait) {}
 
     std::ostream &print(std::ostream &os) const;
 
 public:
-    String error; ///< error message for unsuccessdul lookups; empty otherwise
+    String error; ///< error message for unsuccessful lookups; empty otherwise
     int wait; ///< msecs spent waiting for the lookup (if any) or -1 (if none)
 };
 
-inline
-std::ostream &operator << (std::ostream &os, const DnsLookupDetails &dns)
+} // namespace Dns
+
+inline std::ostream &
+operator <<(std::ostream &os, const Dns::LookupDetails &dns)
 {
     return dns.print(os);
 }
 
-#endif
+#endif /* SQUID_DNS_LOOKUPDETAILS_H */
 
diff --git a/src/dns/Makefile.am b/src/dns/Makefile.am
new file mode 100644 (file)
index 0000000..1f9921a
--- /dev/null
@@ -0,0 +1,24 @@
+## Copyright (C) 1996-2015 The Squid Software Foundation and contributors
+##
+## Squid software is distributed under GPLv2+ license and includes
+## contributions from numerous individuals and organizations.
+## Please see the COPYING and CONTRIBUTORS files for details.
+##
+
+include $(top_srcdir)/src/Common.am
+include $(top_srcdir)/src/TestHeaders.am
+
+AUTOMAKE_OPTIONS = subdir-objects
+
+noinst_LTLIBRARIES = libdns.la
+
+libdns_la_SOURCES = \
+       forward.h \
+       LookupDetails.cc \
+       LookupDetails.h \
+       rfc1035.cc \
+       rfc1035.h \
+       rfc2671.cc \
+       rfc2671.h \
+       rfc3596.cc \
+       rfc3596.h
similarity index 61%
rename from src/SquidDns.h
rename to src/dns/forward.h
index 9fb4a2a92f4c87c663282063d181b2b6bacdb46d..2a6eb81292bf98fc544f84cab39e341ace1d4679 100644 (file)
@@ -6,21 +6,31 @@
  * Please see the COPYING and CONTRIBUTORS files for details.
  */
 
-#ifndef SQUID_DNS_H
-#define SQUID_DNS_H
+#ifndef _SQUID_SRC_DNS_FORWARD_H
+#define _SQUID_SRC_DNS_FORWARD_H
 
 namespace Ip
 {
 class Address;
 }
 
+class rfc1035_rr;
+
+typedef void IDNSCB(void *, const rfc1035_rr *, int, const char *);
+
 // generic DNS API
-void dnsInit(void);
-void dnsShutdown(void);
+namespace Dns
+{
+
+class LookupDetails;
+
+void Init(void);
+void Shutdown(void);
+
+} // namespace Dns
 
 // internal DNS client API
 void idnsALookup(const char *, IDNSCB *, void *);
 void idnsPTRLookup(const Ip::Address &, IDNSCB *, void *);
 
-#endif /* SQUID_DNS_H */
-
+#endif /* _SQUID_SRC_DNS_FORWARD_H */
similarity index 99%
rename from lib/rfc1035.c
rename to src/dns/rfc1035.cc
index d3b44b7a1e08738680c29867370de79fa997f9b6..ba20e66420cd85a5e331a3b81386bbc7c231fae2 100644 (file)
@@ -15,6 +15,8 @@
  */
 
 #include "squid.h"
+#include "dns/rfc1035.h"
+#include "dns/rfc2671.h"
 #include "util.h"
 
 #if HAVE_STRING_H
@@ -39,9 +41,6 @@
 #include <strings.h>
 #endif
 
-#include "rfc1035.h"
-#include "rfc2671.h"
-
 #define RFC1035_MAXLABELSZ 63
 #define rfc1035_unpack_error 15
 
similarity index 98%
rename from include/rfc1035.h
rename to src/dns/rfc1035.h
index cd6783cf2a9288d9cdd6b18a127bf9898c00c822..a3843c0318405b96f0e2773c82745e578ce4fed0 100644 (file)
@@ -33,8 +33,9 @@
 
 #define RFC1035_DEFAULT_PACKET_SZ 512
 
-typedef struct _rfc1035_rr rfc1035_rr;
-struct _rfc1035_rr {
+class rfc1035_rr
+{
+public:
     char name[RFC1035_MAXHOSTNAMESZ];
     unsigned short type;
     unsigned short _class;
similarity index 94%
rename from lib/rfc2671.c
rename to src/dns/rfc2671.cc
index 67b24e1ae931b436f56e0d8bad2d233b14ae417a..0201d943068bf0794e5c3295a8c1eed617bc76e7 100644 (file)
@@ -7,8 +7,8 @@
  */
 
 #include "squid.h"
-#include "rfc1035.h"
-#include "rfc2671.h"
+#include "dns/rfc1035.h"
+#include "dns/rfc2671.h"
 
 int
 rfc2671RROptPack(char *buf, size_t sz, ssize_t edns_sz)
similarity index 100%
rename from include/rfc2671.h
rename to src/dns/rfc2671.h
similarity index 99%
rename from lib/rfc3596.c
rename to src/dns/rfc3596.cc
index d04afb0362a84e5901b5641033f1226353a23512..e54aaaccf5ecc5e7095411d1e8a77a1f9f0ddbca 100644 (file)
@@ -7,6 +7,8 @@
  */
 
 #include "squid.h"
+#include "dns/rfc2671.h"
+#include "dns/rfc3596.h"
 #include "util.h"
 
 #if HAVE_UNISTD_H
@@ -25,9 +27,6 @@
 #include <strings.h>
 #endif
 
-#include "rfc2671.h"
-#include "rfc3596.h"
-
 #ifndef SQUID_RFC1035_H
 #error RFC3596 Library depends on RFC1035
 #endif
similarity index 98%
rename from include/rfc3596.h
rename to src/dns/rfc3596.h
index 90bc48abd9522f52d9aba36d8661f5d5059d8ed9..5bc07f03cf5666cf1eab1c7d34624b519b76e3f1 100644 (file)
@@ -10,7 +10,7 @@
 #define SQUID_RFC3596_H
 
 /* RFC 3596 extends RFC 1035 */
-#include "rfc1035.h"
+#include "dns/rfc1035.h"
 
 SQUIDCEXTERN ssize_t rfc3596BuildAQuery(const char *hostname,
                                         char *buf,
index fe590d953cc0efd1bc3c79d9f9c8d7599b558785..3e8280969a18c460973730661738afac03626484 100644 (file)
@@ -6,7 +6,7 @@
  * Please see the COPYING and CONTRIBUTORS files for details.
  */
 
-/* DEBUG: section 78    DNS lookups; interacts with lib/rfc1035.c */
+/* DEBUG: section 78    DNS lookups; interacts with dns/rfc1035.cc */
 
 #include "squid.h"
 #include "base/InstanceId.h"
 #include "comm/Read.h"
 #include "comm/Write.h"
 #include "dlink.h"
+#include "dns/forward.h"
+#include "dns/rfc3596.h"
 #include "event.h"
 #include "fd.h"
 #include "fde.h"
 #include "ip/tools.h"
 #include "MemBuf.h"
 #include "mgr/Registration.h"
-#include "rfc3596.h"
 #include "SquidConfig.h"
 #include "SquidTime.h"
 #include "Store.h"
@@ -852,7 +853,7 @@ idnsVCClosed(const CommCloseCbParams &params)
     delete vc->queue;
     delete vc->msg;
     vc->conn = NULL;
-    if (vc->ns < nns) // XXX: dnsShutdown may have freed nameservers[]
+    if (vc->ns < nns) // XXX: Dns::Shutdown may have freed nameservers[]
         nameservers[vc->ns].vc = NULL;
     cbdataFree(vc);
 }
@@ -1497,16 +1498,8 @@ idnsRcodeCount(int rcode, int attempt)
             ++ RcodeMatrix[rcode][attempt];
 }
 
-/* ====================================================================== */
-
-static void
-idnsRegisterWithCacheManager(void)
-{
-    Mgr::RegisterAction("idns", "Internal DNS Statistics", idnsStats, 0, 1);
-}
-
 void
-dnsInit(void)
+Dns::Init(void)
 {
     static int init = 0;
 
@@ -1600,11 +1593,11 @@ dnsInit(void)
     }
 #endif
 
-    idnsRegisterWithCacheManager();
+    Mgr::RegisterAction("idns", "Internal DNS Statistics", idnsStats, 0, 1);
 }
 
 void
-dnsShutdown(void)
+Dns::Shutdown(void)
 {
     if (DnsSocketA < 0 && DnsSocketB < 0)
         return;
index 3daff6082829c2a104d36a6d0c1896114f4a1aef..e9cb18e6f91d12fb340501a358c306fb60595715 100644 (file)
 
 #include "squid.h"
 #include "cbdata.h"
-#include "DnsLookupDetails.h"
+#include "dns/forward.h"
+#include "dns/LookupDetails.h"
+#include "dns/rfc1035.h"
 #include "event.h"
 #include "helper.h"
 #include "mgr/Registration.h"
 #include "SquidConfig.h"
-#include "SquidDns.h"
 #include "SquidTime.h"
 #include "StatCounters.h"
 #include "Store.h"
@@ -310,7 +311,7 @@ fqdncacheCallback(fqdncache_entry * f, int wait)
     f->handler = NULL;
 
     if (cbdataReferenceValidDone(f->handlerData, &cbdata)) {
-        const DnsLookupDetails details(f->error_message, wait);
+        const Dns::LookupDetails details(f->error_message, wait);
         callback(f->name_count ? f->names[0] : NULL, details, cbdata);
     }
 
@@ -427,7 +428,7 @@ fqdncache_nbgethostbyaddr(const Ip::Address &addr, FQDNH * handler, void *handle
 
     if (name[0] == '\0') {
         debugs(35, 4, "fqdncache_nbgethostbyaddr: Invalid name!");
-        const DnsLookupDetails details("Invalid hostname", -1); // error, no lookup
+        const Dns::LookupDetails details("Invalid hostname", -1); // error, no lookup
         if (handler)
             handler(NULL, details, handlerData);
         return;
index b2ab320076510afc8928487684f2bd71ebc11378..c39349505e66ba6d5328a7c3b53ec4886ad5dfb7 100644 (file)
@@ -264,7 +264,7 @@ netdbAdd(Ip::Address &addr)
 }
 
 static void
-netdbSendPing(const ipcache_addrs *ia, const DnsLookupDetails &, void *data)
+netdbSendPing(const ipcache_addrs *ia, const Dns::LookupDetails &, void *data)
 {
     Ip::Address addr;
     char *hostname = NULL;
index b778320ad23ec5d6bfacf1c73a8eec9413623af4..c167e844160f4c9b21c5873c81e6b60a242a2a7d 100644 (file)
 #include "CacheManager.h"
 #include "cbdata.h"
 #include "dlink.h"
-#include "DnsLookupDetails.h"
+#include "dns/LookupDetails.h"
+#include "dns/rfc3596.h"
 #include "event.h"
 #include "ip/Address.h"
 #include "ip/tools.h"
 #include "ipcache.h"
 #include "mgr/Registration.h"
-#include "rfc3596.h"
 #include "SquidConfig.h"
-#include "SquidDns.h"
 #include "SquidTime.h"
 #include "StatCounters.h"
 #include "Store.h"
@@ -321,7 +320,7 @@ ipcacheCallback(ipcache_entry *i, int wait)
     i->handler = NULL;
 
     if (cbdataReferenceValidDone(i->handlerData, &cbdata)) {
-        const DnsLookupDetails details(i->error_message, wait);
+        const Dns::LookupDetails details(i->error_message, wait);
         callback((i->addrs.count ? &i->addrs : NULL), details, cbdata);
     }
 
@@ -504,7 +503,7 @@ ipcache_nbgethostbyname(const char *name, IPH * handler, void *handlerData)
     if (name == NULL || name[0] == '\0') {
         debugs(14, 4, "ipcache_nbgethostbyname: Invalid name!");
         ++IpcacheStats.invalid;
-        const DnsLookupDetails details("Invalid hostname", -1); // error, no lookup
+        const Dns::LookupDetails details("Invalid hostname", -1); // error, no lookup
         if (handler)
             handler(NULL, details, handlerData);
         return;
@@ -513,7 +512,7 @@ ipcache_nbgethostbyname(const char *name, IPH * handler, void *handlerData)
     if ((addrs = ipcacheCheckNumeric(name))) {
         debugs(14, 4, "ipcache_nbgethostbyname: BYPASS for '" << name << "' (already numeric)");
         ++IpcacheStats.numeric_hits;
-        const DnsLookupDetails details(NULL, -1); // no error, no lookup
+        const Dns::LookupDetails details; // no error, no lookup
         if (handler)
             handler(addrs, details, handlerData);
         return;
index 449a56705eed8f277cc5cf7eba1bc75c44280418..cfdc096d2ea1d62fb2a87ac2c23e7cbb658b970f 100644 (file)
@@ -9,13 +9,13 @@
 #ifndef _SQUID_IPCACHE_H
 #define _SQUID_IPCACHE_H
 
+#include "dns/forward.h"
+
 namespace Ip
 {
 class Address;
 }
 
-class DnsLookupDetails;
-
 typedef struct _ipcache_addrs {
     Ip::Address *in_addrs;
     unsigned char *bad_mask;
@@ -24,7 +24,7 @@ typedef struct _ipcache_addrs {
     unsigned char badcount;
 } ipcache_addrs;
 
-typedef void IPH(const ipcache_addrs *, const DnsLookupDetails &details, void *);
+typedef void IPH(const ipcache_addrs *, const Dns::LookupDetails &details, void *);
 
 void ipcache_purgelru(void *);
 void ipcache_nbgethostbyname(const char *name, IPH * handler, void *handlerData);
index 2fd0bc5b9a4fffa1e90cbc0089e14b53340c861f..45e20a44f6d55adf80cd06267b36b2ed3485b197 100644 (file)
@@ -25,6 +25,7 @@
 #include "CpuAffinity.h"
 #include "disk.h"
 #include "DiskIO/DiskIOModule.h"
+#include "dns/forward.h"
 #include "errorpage.h"
 #include "event.h"
 #include "EventLoop.h"
@@ -59,7 +60,6 @@
 #include "refresh.h"
 #include "send-announce.h"
 #include "SquidConfig.h"
-#include "SquidDns.h"
 #include "SquidTime.h"
 #include "stat.h"
 #include "StatCounters.h"
@@ -803,7 +803,7 @@ mainReconfigureStart(void)
 #if USE_HTCP
     htcpClosePorts();
 #endif
-    dnsShutdown();
+    Dns::Shutdown();
 #if USE_SSL_CRTD
     Ssl::Helper::GetInstance()->Shutdown();
 #endif
@@ -890,7 +890,7 @@ mainReconfigureFinish(void *)
     icapLogOpen();
 #endif
     storeLogOpen();
-    dnsInit();
+    Dns::Init();
 #if USE_SSL_CRTD
     Ssl::Helper::GetInstance()->Init();
 #endif
@@ -1094,7 +1094,7 @@ mainInitialize(void)
 
     parseEtcHosts();
 
-    dnsInit();
+    Dns::Init();
 
 #if USE_SSL_CRTD
     Ssl::Helper::GetInstance()->Init();
@@ -1915,7 +1915,7 @@ SquidShutdown()
 #endif
 
     debugs(1, DBG_IMPORTANT, "Shutting down...");
-    dnsShutdown();
+    Dns::Shutdown();
 #if USE_SSL_CRTD
     Ssl::Helper::GetInstance()->Shutdown();
 #endif
index 08ab9bb31dd8f6017a1d5583977a616ce9766e78..0c1ae5c4c3cf549170061c3f1151991dc7b06ab9 100644 (file)
@@ -31,7 +31,7 @@ mcastSetTtl(int fd, int mcast_ttl)
 }
 
 void
-mcastJoinGroups(const ipcache_addrs *ia, const DnsLookupDetails &, void *)
+mcastJoinGroups(const ipcache_addrs *ia, const Dns::LookupDetails &, void *)
 {
 #ifdef IP_MULTICAST_TTL
     struct ip_mreq mr;
index 68778a6114416562b07358aa532e206c851c17b6..fde225c9eeea7a3ce6977fedd41dda591eafd415 100644 (file)
@@ -1203,7 +1203,7 @@ peerNoteDigestGone(CachePeer * p)
 }
 
 static void
-peerDNSConfigure(const ipcache_addrs *ia, const DnsLookupDetails &, void *data)
+peerDNSConfigure(const ipcache_addrs *ia, const Dns::LookupDetails &, void *data)
 {
     // TODO: connections to no-longer valid IP addresses should be
     // closed when we can detect such IP addresses.
index 5b00a3f5c5383319039bf852453a606bbbdbcad0..05e1506769c356d70865273fb56131de51fe230e 100644 (file)
@@ -13,7 +13,7 @@
 #include "CachePeer.h"
 #include "carp.h"
 #include "client_side.h"
-#include "DnsLookupDetails.h"
+#include "dns/LookupDetails.h"
 #include "errorpage.h"
 #include "event.h"
 #include "FwdState.h"
@@ -61,7 +61,7 @@ static void peerGetSomeParent(ps_state *);
 static void peerGetAllParents(ps_state *);
 static void peerAddFwdServer(FwdServer **, CachePeer *, hier_code);
 static void peerSelectPinned(ps_state * ps);
-static void peerSelectDnsResults(const ipcache_addrs *ia, const DnsLookupDetails &details, void *data);
+static void peerSelectDnsResults(const ipcache_addrs *ia, const Dns::LookupDetails &details, void *data);
 
 CBDATA_CLASS_INIT(ps_state);
 
@@ -306,7 +306,7 @@ peerSelectDnsPaths(ps_state *psstate)
 }
 
 static void
-peerSelectDnsResults(const ipcache_addrs *ia, const DnsLookupDetails &details, void *data)
+peerSelectDnsResults(const ipcache_addrs *ia, const Dns::LookupDetails &details, void *data)
 {
     ps_state *psstate = (ps_state *)data;
 
index b414d6aeb6faf2d97bd39ebd52b96d4c26ec61c7..0b2b7d51e76c4f1b3f2d2c519ea7f018c24c7e47 100644 (file)
@@ -39,7 +39,7 @@ start_announce(void *)
 }
 
 static void
-send_announce(const ipcache_addrs *ia, const DnsLookupDetails &, void *)
+send_announce(const ipcache_addrs *ia, const Dns::LookupDetails &, void *)
 {
     LOCAL_ARRAY(char, tbuf, 256);
     LOCAL_ARRAY(char, sndbuf, BUFSIZ);
similarity index 97%
rename from lib/tests/testRFC1035.cc
rename to src/tests/testRFC1035.cc
index e238ec097f5f90c7cac5b3bbf28c91be0c5097ff..cc74966d2351ed592cb13a083600519fe1943f9a 100644 (file)
@@ -7,15 +7,12 @@
  */
 
 #include "squid.h"
+#include "dns/rfc1035.h"
 #include "testRFC1035.h"
 #include "unitTestMain.h"
 
 #include <cassert>
 
-/* Being a C library code it is best bodily included and tested with C++ type-safe techniques. */
-#include "lib/rfc1035.c"
-#include "lib/rfc2671.c"
-
 CPPUNIT_TEST_SUITE_REGISTRATION( testRFC1035 );
 
 // TODO Test each function in the Library independently
index 1826e2ea91217c5fe9c60279cc6f3df8ebdb9ec5..7d38ff3ae9be9afd52d43ffc60d3318c58c8b405 100644 (file)
@@ -7,7 +7,6 @@
  */
 
 #include "enums.h"
-#include "rfc1035.h"
 
 #ifndef SQUID_TYPEDEFS_H
 #define SQUID_TYPEDEFS_H
@@ -44,8 +43,11 @@ typedef void DCCB(int, int errflag, void *data);    /* disk close CB */
 typedef void DUCB(int errflag, void *data); /* disk unlink CB */
 typedef void DTCB(int errflag, void *data); /* disk trunc CB */
 
-class DnsLookupDetails;
-typedef void FQDNH(const char *, const DnsLookupDetails &details, void *);
+namespace Dns
+{
+class LookupDetails;
+}
+typedef void FQDNH(const char *, const Dns::LookupDetails &details, void *);
 
 #include "anyp/ProtocolType.h"
 class CachePeer;
@@ -68,7 +70,6 @@ typedef void STVLDCB(void *, int, int);
 typedef int HLPSAVAIL(void *);
 typedef void HLPSONEQ(void *);
 typedef void HLPCMDOPTS(int *argc, char **argv);
-typedef void IDNSCB(void *, const rfc1035_rr *, int, const char *);
 
 /* MD5 cache keys */
 typedef unsigned char cache_key;