Eui64.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2022 The Squid Software Foundation and contributors
3 *
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.
7 */
8
9/* DEBUG: section 28 Access Control */
10
11#include "squid.h"
12
13#if USE_SQUID_EUI
14
15#include "acl/Eui64.h"
16#include "acl/FilledChecklist.h"
17#include "cache_cf.h"
18#include "debug/Stream.h"
19#include "eui/Eui64.h"
20#include "globals.h"
21#include "ip/Address.h"
22
23ACLEui64::ACLEui64 (char const *theClass) : class_ (theClass)
24{}
25
26char const *
28{
29 return class_;
30}
31
32bool
34{
35 return eui64Data.empty();
36}
37
38static Eui::Eui64 *
39aclParseEuiData(const char *t)
40{
41 char buf[256];
42 Eui::Eui64 *q = new Eui::Eui64;
43 debugs(28, 5, "aclParseEuiData: " << t);
44
45 if (sscanf(t, "%[0-9a-fA-F:]", buf) != 1) {
46 debugs(28, DBG_CRITICAL, "ERROR: aclParseEuiData: Bad EUI-64 address: '" << t << "'");
47 delete q;
48 return nullptr;
49 }
50
51 if (!q->decode(buf)) {
52 debugs(28, DBG_CRITICAL, "" << cfg_filename << " line " << config_lineno << ": " << config_input_line);
53 debugs(28, DBG_CRITICAL, "ERROR: aclParseEuiData: Ignoring invalid EUI-64 acl entry: cannot parse '" << buf << "'");
54 delete q;
55 return nullptr;
56 }
57
58 return q;
59}
60
61/*******************/
62/* aclParseEuiList */
63/*******************/
64void
66{
67 while (const char * t = ConfigParser::strtokFile()) {
68 if (Eui::Eui64 * q = aclParseEuiData(t)) {
69 eui64Data.insert(*q);
70 delete q;
71 }
72 }
73}
74
75int
77{
78 ACLFilledChecklist *checklist = Filled(cl);
79
80 /* IPv4 does not do EUI-64 (yet) */
81 if (!checklist->src_addr.isIPv6()) {
82 debugs(14, 3, "ACLEui64::match: IPv6 Required for EUI-64 Lookups. Skipping " << checklist->src_addr );
83 return 0;
84 }
85
86 Eui::Eui64 lookingFor;
87 if (lookingFor.lookup(checklist->src_addr)) {
88 bool found = (eui64Data.find(lookingFor) != eui64Data.end());
89 debugs(28, 3, checklist->src_addr << "' " << (found ? "found" : "NOT found"));
90 return found;
91 }
92
93 debugs(28, 3, checklist->src_addr << " NOT found");
94 return 0;
95}
96
99{
100 SBufList sl;
101 for (auto i = eui64Data.begin(); i != eui64Data.end(); ++i) {
102 static char buf[48];
103 i->encode(buf,48);
104 sl.push_back(SBuf(buf));
105 }
106 return sl;
107}
108
109#endif /* USE_SQUID_EUI */
110
ACLFilledChecklist * Filled(ACLChecklist *checklist)
convenience and safety wrapper for dynamic_cast<ACLFilledChecklist*>
static Eui::Eui64 * aclParseEuiData(const char *t)
Definition: Eui64.cc:39
char config_input_line[BUFSIZ]
Definition: cache_cf.cc:273
const char * cfg_filename
Definition: cache_cf.cc:271
int config_lineno
Definition: cache_cf.cc:272
virtual char const * typeString() const
Definition: Eui64.cc:27
virtual int match(ACLChecklist *checklist)
Matches the actual data in checklist against this ACL.
Definition: Eui64.cc:76
virtual SBufList dump() const
Definition: Eui64.cc:98
virtual bool empty() const
Definition: Eui64.cc:33
virtual void parse()
parses node representation in squid.conf; dies on failures
Definition: Eui64.cc:65
Eui64Data_t eui64Data
Definition: Eui64.h:37
ACLEui64(char const *)
Definition: Eui64.cc:23
char const * class_
Definition: Eui64.h:38
Ip::Address src_addr
static char * strtokFile()
Definition: ConfigParser.cc:64
bool decode(const char *asc)
Definition: Eui64.cc:22
bool lookup(const Ip::Address &c)
Definition: Eui64.cc:47
bool isIPv6() const
Definition: Address.cc:164
Definition: SBuf.h:94
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Stream.h:196
#define DBG_CRITICAL
Definition: Stream.h:40
std::list< SBuf > SBufList
Definition: forward.h:23

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors