2 * DEBUG: section 28 Access Control
3 * AUTHOR: Amos Jeffries
5 * SQUID Web Proxy Cache http://www.squid-cache.org/
6 * ----------------------------------------------------------
8 * Squid is the result of efforts by numerous individuals from
9 * the Internet community; see the CONTRIBUTORS file for full
10 * details. Many organizations have provided support for Squid's
11 * development; see the SPONSORS file for full details. Squid is
12 * Copyrighted (C) 2001 by the Regents of the University of
13 * California; see the COPYRIGHT file for full details. Squid
14 * incorporates software developed and/or copyrighted by other
15 * sources; see the CREDITS file for full details.
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
32 * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
35 #include "squid-old.h"
39 #include "acl/Eui64.h"
40 #include "acl/FilledChecklist.h"
41 #include "eui/Eui64.h"
42 #include "ip/Address.h"
45 static void aclParseEuiList(SplayNode
<Eui::Eui64
*> **curlist
);
46 static int aclMatchEui(SplayNode
<Eui::Eui64
*> **dataptr
, Ip::Address
&c
);
47 static SplayNode
<Eui::Eui64
*>::SPLAYCMP aclEui64Compare
;
48 static SplayNode
<Eui::Eui64
*>::SPLAYWALKEE aclDumpEuiListWalkee
;
52 ACLEui64::clone() const
54 return new ACLEui64(*this);
57 ACLEui64::ACLEui64 (char const *theClass
) : data (NULL
), class_ (theClass
)
60 ACLEui64::ACLEui64 (ACLEui64
const & old
) : data (NULL
), class_ (old
.class_
)
62 /* we don't have copy constructors for the data yet */
69 data
->destroy(SplayNode
<Eui::Eui64
*>::DefaultFree
);
73 ACLEui64::typeString() const
79 ACLEui64::empty () const
85 aclParseEuiData(const char *t
)
88 Eui::Eui64
*q
= new Eui::Eui64
;
89 debugs(28, 5, "aclParseEuiData: " << t
);
91 if (sscanf(t
, "%[0-9a-fA-F:]", buf
) != 1) {
92 debugs(28, 0, "aclParseEuiData: Bad EUI-64 address: '" << t
<< "'");
97 if (!q
->decode(buf
)) {
98 debugs(28, 0, "" << cfg_filename
<< " line " << config_lineno
<< ": " << config_input_line
);
99 debugs(28, 0, "aclParseEuiData: Ignoring invalid EUI-64 acl entry: can't parse '" << buf
<< "'");
108 /*******************/
109 /* aclParseEuiList */
110 /*******************/
114 aclParseEuiList(&data
);
118 aclParseEuiList(SplayNode
<Eui::Eui64
*> **curlist
)
121 SplayNode
<Eui::Eui64
*> **Top
= curlist
;
122 Eui::Eui64
*q
= NULL
;
124 while ((t
= strtokFile())) {
125 if ((q
= aclParseEuiData(t
)) == NULL
)
128 *Top
= (*Top
)->insert(q
, aclEui64Compare
);
133 ACLEui64::match(ACLChecklist
*cl
)
135 ACLFilledChecklist
*checklist
= Filled(cl
);
137 /* IPv4 does not do EUI-64 (yet) */
138 if (!checklist
->src_addr
.IsIPv6()) {
139 debugs(14, 3, "ACLEui64::match: IPv6 Required for EUI-64 Lookups. Skipping " << checklist
->src_addr
);
143 return aclMatchEui(&data
, checklist
->src_addr
);
150 aclMatchEui(SplayNode
<Eui::Eui64
*> **dataptr
, Ip::Address
&c
)
153 SplayNode
<Eui::Eui64
*> **Top
= dataptr
;
155 if (result
.lookup(c
)) {
156 /* Do ACL match lookup */
157 *Top
= (*Top
)->splay(&result
, aclEui64Compare
);
158 debugs(28, 3, "aclMatchEui: '" << c
<< "' " << (splayLastResult
? "NOT found" : "found"));
159 return (0 == splayLastResult
);
163 * Address was not found on any interface
165 debugs(28, 3, "aclMatchEui: " << c
<< " NOT found");
170 aclEui64Compare(Eui::Eui64
* const &a
, Eui::Eui64
* const &b
)
172 return memcmp(a
, b
, sizeof(Eui::Eui64
));
176 aclDumpEuiListWalkee(Eui::Eui64
* const &node
, void *state
)
179 node
->encode(buf
, 48);
180 wordlistAdd((wordlist
**)state
, buf
);
184 ACLEui64::dump() const
187 data
->walk(aclDumpEuiListWalkee
, &w
);
191 #endif /* USE_SQUID_EUI */