]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/acl/Asn.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / acl / Asn.cc
index 5ef8091232eec75a98c684fac8484c55000b06a0..1adb07f360fadc6c9b2a6a672696391df1f69cd6 100644 (file)
@@ -1,36 +1,13 @@
-
 /*
- * DEBUG: section 53    AS Number handling
- * AUTHOR: Duane Wessels, Kostas Anagnostakis
- *
- * SQUID Web Proxy Cache          http://www.squid-cache.org/
- * ----------------------------------------------------------
- *
- *  Squid is the result of efforts by numerous individuals from
- *  the Internet community; see the CONTRIBUTORS file for full
- *  details.   Many organizations have provided support for Squid's
- *  development; see the SPONSORS file for full details.  Squid is
- *  Copyrighted (C) 2001 by the Regents of the University of
- *  California; see the COPYRIGHT file for full details.  Squid
- *  incorporates software developed and/or copyrighted by other
- *  sources; see the CREDITS file for full details.
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ * 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.
  */
 
+/* DEBUG: section 53    AS Number handling */
+
 #include "squid.h"
 #include "acl/Acl.h"
 #include "acl/Asn.h"
 #include "Store.h"
 #include "StoreClient.h"
 #include "StoreClient.h"
-#include "wordlist.h"
 
 #define WHOIS_PORT 43
-#define        AS_REQBUF_SZ    4096
+#define AS_REQBUF_SZ    4096
 
 /* BEGIN of definitions for radix tree entries */
 
@@ -75,7 +51,7 @@ struct squid_radix_node_head *AS_tree_head;
 
 /* explicit instantiation required for some systems */
 
-/// \cond AUTODOCS-IGNORE
+/// \cond AUTODOCS_IGNORE
 template cbdata_type CbDataList<int>::CBDATA_CbDataList;
 /// \endcond
 
@@ -86,11 +62,13 @@ template cbdata_type CbDataList<int>::CBDATA_CbDataList;
  */
 struct as_info {
     CbDataList<int> *as_number;
-    time_t expires;            /* NOTUSED */
+    time_t expires;     /* NOTUSED */
 };
 
 class ASState
 {
+    CBDATA_CLASS(ASState);
+
 public:
     ASState();
     ~ASState();
@@ -103,20 +81,18 @@ public:
     int reqofs;
     char reqbuf[AS_REQBUF_SZ];
     bool dataRead;
-private:
-    CBDATA_CLASS2(ASState);
 };
 
 CBDATA_CLASS_INIT(ASState);
 
 ASState::ASState() :
-        entry(NULL),
-        sc(NULL),
-        request(NULL),
-        as_number(0),
-        offset(0),
-        reqofs(0),
-        dataRead(false)
+    entry(NULL),
+    sc(NULL),
+    request(NULL),
+    as_number(0),
+    offset(0),
+    reqofs(0),
+    dataRead(false)
 {
     memset(reqbuf, 0, AS_REQBUF_SZ);
 }
@@ -125,7 +101,7 @@ ASState::~ASState()
 {
     debugs(53, 3, entry->url());
     storeUnregister(sc, entry, this);
-    entry->unlock();
+    entry->unlock("~ASState");
 }
 
 /** entry into the radix tree */
@@ -146,8 +122,8 @@ static STCB asHandleReply;
 extern "C" {
 #endif
 
-    static int destroyRadixNode(struct squid_radix_node *rn, void *w);
-    static int printRadixNode(struct squid_radix_node *rn, void *sentry);
+static int destroyRadixNode(struct squid_radix_node *rn, void *w);
+static int printRadixNode(struct squid_radix_node *rn, void *sentry);
 
 #if defined(__cplusplus)
 }
@@ -221,7 +197,7 @@ asnRegisterWithCacheManager(void)
 
 /* initialize the radix tree structure */
 
-SQUIDCEXTERN int squid_max_keylen;     /* yuck.. this is in lib/radix.c */
+SQUIDCEXTERN int squid_max_keylen;  /* yuck.. this is in lib/radix.c */
 
 void
 asnInit(void)
@@ -273,7 +249,7 @@ asnCacheStart(int as)
         asState->sc = storeClientListAdd(e, asState);
         FwdState::fwdStart(Comm::ConnectionPointer(), e, asState->request.getRaw());
     } else {
-        e->lock();
+        e->lock("Asn");
         asState->sc = storeClientListAdd(e, asState);
     }
 
@@ -463,7 +439,7 @@ asnAddNet(char *as_string, int as_number)
         e->e_info = asinfo;
     }
 
-    if (rn == 0) {             /* assert might expand to nothing */
+    if (rn == 0) {      /* assert might expand to nothing */
         xfree(asinfo);
         delete q;
         xfree(e);
@@ -551,20 +527,21 @@ ACLASN::match(Ip::Address toMatch)
     return asnMatchIp(data, toMatch);
 }
 
-wordlist *
-ACLASN::dump()
+SBufList
+ACLASN::dump() const
 {
-    wordlist *W = NULL;
-    char buf[32];
+    SBufList sl;
+
     CbDataList<int> *ldata = data;
 
     while (ldata != NULL) {
-        snprintf(buf, sizeof(buf), "%d", ldata->element);
-        wordlistAdd(&W, buf);
+        SBuf s;
+        s.Printf("%d", ldata->element);
+        sl.push_back(s);
         ldata = ldata->next;
     }
 
-    return W;
+    return sl;
 }
 
 bool
@@ -656,3 +633,4 @@ ACLDestinationASNStrategy::Instance()
 }
 
 ACLDestinationASNStrategy ACLDestinationASNStrategy::Instance_;
+