]>
Commit | Line | Data |
---|---|---|
a98c2da5 | 1 | /* |
bde978a6 | 2 | * Copyright (C) 1996-2015 The Squid Software Foundation and contributors |
a98c2da5 | 3 | * |
bbc27441 AJ |
4 | * Squid software is distributed under GPLv2+ license and includes |
5 | * contributions from numerous individuals and organizations. | |
6 | * Please see the COPYING and CONTRIBUTORS files for details. | |
a98c2da5 AJ |
7 | */ |
8 | ||
bbc27441 AJ |
9 | /* DEBUG: section 28 Access Control */ |
10 | ||
582c2af2 | 11 | #include "squid.h" |
a98c2da5 AJ |
12 | |
13 | #if USE_SQUID_EUI | |
14 | ||
15 | #include "acl/Eui64.h" | |
16 | #include "acl/FilledChecklist.h" | |
06390e4b | 17 | #include "cache_cf.h" |
582c2af2 | 18 | #include "Debug.h" |
a98c2da5 | 19 | #include "eui/Eui64.h" |
9b859d6f | 20 | #include "globals.h" |
96d89ea0 | 21 | #include "ip/Address.h" |
a98c2da5 | 22 | |
a98c2da5 AJ |
23 | ACL * |
24 | ACLEui64::clone() const | |
25 | { | |
26 | return new ACLEui64(*this); | |
27 | } | |
28 | ||
fdd757c5 | 29 | ACLEui64::ACLEui64 (char const *theClass) : class_ (theClass) |
a98c2da5 AJ |
30 | {} |
31 | ||
fdd757c5 | 32 | ACLEui64::ACLEui64 (ACLEui64 const & old) : eui64Data(old.eui64Data), class_ (old.class_) |
a98c2da5 | 33 | { |
a98c2da5 AJ |
34 | } |
35 | ||
a98c2da5 AJ |
36 | char const * |
37 | ACLEui64::typeString() const | |
38 | { | |
39 | return class_; | |
40 | } | |
41 | ||
42 | bool | |
43 | ACLEui64::empty () const | |
44 | { | |
fdd757c5 | 45 | return eui64Data.empty(); |
a98c2da5 AJ |
46 | } |
47 | ||
48 | Eui::Eui64 * | |
49 | aclParseEuiData(const char *t) | |
50 | { | |
51 | char buf[256]; | |
52 | Eui::Eui64 *q = new Eui::Eui64; | |
53 | debugs(28, 5, "aclParseEuiData: " << t); | |
54 | ||
55 | if (sscanf(t, "%[0-9a-fA-F:]", buf) != 1) { | |
fa84c01d | 56 | debugs(28, DBG_CRITICAL, "aclParseEuiData: Bad EUI-64 address: '" << t << "'"); |
2dd66a22 | 57 | delete q; |
a98c2da5 AJ |
58 | return NULL; |
59 | } | |
60 | ||
61 | if (!q->decode(buf)) { | |
fa84c01d FC |
62 | debugs(28, DBG_CRITICAL, "" << cfg_filename << " line " << config_lineno << ": " << config_input_line); |
63 | debugs(28, DBG_CRITICAL, "aclParseEuiData: Ignoring invalid EUI-64 acl entry: can't parse '" << buf << "'"); | |
2dd66a22 | 64 | delete q; |
a98c2da5 AJ |
65 | return NULL; |
66 | } | |
67 | ||
68 | return q; | |
69 | } | |
70 | ||
a98c2da5 AJ |
71 | /*******************/ |
72 | /* aclParseEuiList */ | |
73 | /*******************/ | |
74 | void | |
75 | ACLEui64::parse() | |
a98c2da5 | 76 | { |
68acf08e FC |
77 | while (const char * t = strtokFile()) { |
78 | if (Eui::Eui64 * q = aclParseEuiData(t)) { | |
79 | eui64Data.insert(*q); | |
2dd66a22 | 80 | delete q; |
68acf08e | 81 | } |
a98c2da5 AJ |
82 | } |
83 | } | |
84 | ||
85 | int | |
86 | ACLEui64::match(ACLChecklist *cl) | |
87 | { | |
88 | ACLFilledChecklist *checklist = Filled(cl); | |
89 | ||
90 | /* IPv4 does not do EUI-64 (yet) */ | |
4dd643d5 | 91 | if (!checklist->src_addr.isIPv6()) { |
a98c2da5 AJ |
92 | debugs(14, 3, "ACLEui64::match: IPv6 Required for EUI-64 Lookups. Skipping " << checklist->src_addr ); |
93 | return 0; | |
94 | } | |
95 | ||
736a7789 | 96 | Eui::Eui64 lookingFor; |
fdd757c5 FC |
97 | if (lookingFor.lookup(checklist->src_addr)) { |
98 | bool found = (eui64Data.find(lookingFor) != eui64Data.end()); | |
99 | debugs(28, 3, checklist->src_addr << "' " << (found ? "found" : "NOT found")); | |
100 | return found; | |
a98c2da5 AJ |
101 | } |
102 | ||
fdd757c5 | 103 | debugs(28, 3, checklist->src_addr << " NOT found"); |
a98c2da5 AJ |
104 | return 0; |
105 | } | |
106 | ||
9b859d6f | 107 | SBufList |
a98c2da5 AJ |
108 | ACLEui64::dump() const |
109 | { | |
fdd757c5 FC |
110 | SBufList sl; |
111 | for (auto i = eui64Data.cbegin(); i != eui64Data.end(); ++i) { | |
68acf08e | 112 | static char buf[48]; |
fdd757c5 FC |
113 | i->encode(buf,48); |
114 | sl.push_back(SBuf(buf)); | |
115 | } | |
116 | return sl; | |
a98c2da5 AJ |
117 | } |
118 | ||
119 | #endif /* USE_SQUID_EUI */ | |
f53969cc | 120 |