]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/acl/Arp.cc
2 * Copyright (C) 1996-2022 The Squid Software Foundation and contributors
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.
9 /* DEBUG: section 28 Access Control */
16 #include "acl/FilledChecklist.h"
18 #include "debug/Stream.h"
19 #include "eui/Eui48.h"
21 #include "ip/Address.h"
25 ACLARP::ACLARP (char const *theClass
) : class_ (theClass
)
29 ACLARP::typeString() const
35 ACLARP::empty () const
37 return aclArpData
.empty();
40 /* ==== BEGIN ARP ACL SUPPORT ============================================= */
43 * From: dale@server.ctam.bitmcnit.bryansk.su (Dale)
44 * To: wessels@nlanr.net
45 * Subject: Another Squid patch... :)
46 * Date: Thu, 04 Dec 1997 19:55:01 +0300
47 * ============================================================================
49 * Working on setting up a proper firewall for a network containing some
50 * Win'95 computers at our Univ, I've discovered that some smart students
51 * avoid the restrictions easily just changing their IP addresses in Win'95
52 * Control Panel... It has been getting boring, so I took Squid-1.1.18
53 * sources and added a new acl type for hard-wired access control:
55 * acl <name> arp <Ethernet address> ...
59 * acl students arp 00:00:21:55:ed:22 00:00:21:ff:55:38
61 * NOTE: Linux code by David Luyer <luyer@ucs.uwa.edu.au>.
62 * Original (BSD-specific) code no longer works.
63 * Solaris code by R. Gancarz <radekg@solaris.elektrownia-lagisza.com.pl>
67 aclParseArpData(const char *t
)
70 Eui::Eui48
*q
= new Eui::Eui48
;
71 debugs(28, 5, "aclParseArpData: " << t
);
73 if (sscanf(t
, "%[0-9a-fA-F:]", buf
) != 1) {
74 debugs(28, DBG_CRITICAL
, "ERROR: aclParseArpData: Bad ethernet address: '" << t
<< "'");
79 if (!q
->decode(buf
)) {
80 debugs(28, DBG_CRITICAL
, "" << cfg_filename
<< " line " << config_lineno
<< ": " << config_input_line
);
81 debugs(28, DBG_CRITICAL
, "ERROR: aclParseArpData: Ignoring invalid ARP acl entry: cannot parse '" << buf
<< "'");
95 while (const char *t
= ConfigParser::strtokFile()) {
96 if (Eui::Eui48
*q
= aclParseArpData(t
)) {
97 aclArpData
.insert(*q
);
104 ACLARP::match(ACLChecklist
*cl
)
106 ACLFilledChecklist
*checklist
= Filled(cl
);
108 /* IPv6 does not do ARP */
109 if (!checklist
->src_addr
.isIPv4()) {
110 debugs(14, 3, "ACLARP::match: IPv4 Required for ARP Lookups. Skipping " << checklist
->src_addr
);
114 Eui::Eui48 lookingFor
;
115 lookingFor
.lookup(checklist
->src_addr
);
116 return (aclArpData
.find(lookingFor
) != aclArpData
.end());
123 for (auto i
= aclArpData
.begin(); i
!= aclArpData
.end(); ++i
) {
126 sl
.push_back(SBuf(buf
));
131 /* ==== END ARP ACL SUPPORT =============================================== */
133 #endif /* USE_SQUID_EUI */