]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fixed Acl::Ip
authorFrancesco Chemolli <kinkie@squid-cache.org>
Tue, 30 Dec 2014 22:13:01 +0000 (23:13 +0100)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Tue, 30 Dec 2014 22:13:01 +0000 (23:13 +0100)
src/acl/Ip.cc
src/acl/Ip.h

index aded60f1e42127dcc70b5a9a7e6eb3d4f8173f80..8b7a77bebea00c240000f0957082cde07e661def 100644 (file)
@@ -30,18 +30,6 @@ ACLIP::operator delete (void *address)
     fatal ("ACLIP::operator delete: unused");
 }
 
-/**
- * Writes an IP ACL data into a buffer, then copies the buffer into the wordlist given
- *
- \param ip  ACL data structure to display
- \param state   wordlist structure which is being generated
- */
-void
-ACLIP::DumpIpListWalkee(acl_ip_data * const & ip, void *state)
-{
-    static_cast<SBufList *>(state)->push_back(ip->toSBuf());
-}
-
 /**
  * print/format an acl_ip_data structure for debugging output.
  *
@@ -494,7 +482,7 @@ ACLIP::parse()
             /* pop each result off the list and add it to the data tree individually */
             acl_ip_data *next_node = q->next;
             q->next = NULL;
-            data = data->insert(q, acl_ip_data::NetworkCompare);
+            data->insert(q, acl_ip_data::NetworkCompare);
             q = next_node;
         }
     }
@@ -503,15 +491,22 @@ ACLIP::parse()
 ACLIP::~ACLIP()
 {
     if (data)
-        data->destroy(IPSplay::DefaultFree);
+        data->destroy();
 }
 
+struct IpAclDumpVisitor {
+    SBufList contents;
+    void operator() (acl_ip_data * const & ip) {
+        contents.push_back(ip->toSBuf());
+    }
+};
+
 SBufList
 ACLIP::dump() const
 {
-    SBufList sl;
-    data->walk(DumpIpListWalkee, &sl);
-    return sl;
+    IpAclDumpVisitor visitor;
+    data->visit(visitor);
+    return visitor.contents;
 }
 
 bool
@@ -534,9 +529,9 @@ ACLIP::match(Ip::Address &clientip)
     ClientAddress.addr2.setEmpty();
     ClientAddress.mask.setEmpty();
 
-    data = data->splay(&ClientAddress, aclIpAddrNetworkCompare);
-    debugs(28, 3, "aclIpMatchIp: '" << clientip << "' " << (splayLastResult ? "NOT found" : "found"));
-    return !splayLastResult;
+    const acl_ip_data * const * result =  data->find(&ClientAddress, aclIpAddrNetworkCompare);
+    debugs(28, 3, "aclIpMatchIp: '" << clientip << "' " << (result ? "found" : "NOT found"));
+    return (result != NULL);
 }
 
 acl_ip_data::acl_ip_data() :addr1(), addr2(), mask(), next (NULL) {}
index 3995c20d7371720182e7c2082008f7ae0782acfc..9f065f9dd79c93e086fb8ab664c21d5d189ad04f 100644 (file)
@@ -52,7 +52,7 @@ public:
 
     ~ACLIP();
 
-    typedef SplayNode<acl_ip_data *> IPSplay;
+    typedef Splay<acl_ip_data *> IPSplay;
 
     virtual char const *typeString() const = 0;
     virtual void parse();
@@ -66,8 +66,6 @@ protected:
     int match(Ip::Address &);
     IPSplay *data;
 
-private:
-    static void DumpIpListWalkee(acl_ip_data * const & ip, void *state);
 };
 
 #endif /* SQUID_ACLIP_H */