]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/acl/Arp.cc
2 * Copyright (C) 1996-2015 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"
19 #include "eui/Eui48.h"
21 #include "ip/Address.h"
28 return new ACLARP(*this);
31 ACLARP::ACLARP (char const *theClass
) : class_ (theClass
)
34 ACLARP::ACLARP (ACLARP
const & old
) : class_ (old
.class_
), aclArpData(old
.aclArpData
)
39 ACLARP::typeString() const
45 ACLARP::empty () const
47 return aclArpData
.empty();
50 /* ==== BEGIN ARP ACL SUPPORT ============================================= */
53 * From: dale@server.ctam.bitmcnit.bryansk.su (Dale)
54 * To: wessels@nlanr.net
55 * Subject: Another Squid patch... :)
56 * Date: Thu, 04 Dec 1997 19:55:01 +0300
57 * ============================================================================
59 * Working on setting up a proper firewall for a network containing some
60 * Win'95 computers at our Univ, I've discovered that some smart students
61 * avoid the restrictions easily just changing their IP addresses in Win'95
62 * Contol Panel... It has been getting boring, so I took Squid-1.1.18
63 * sources and added a new acl type for hard-wired access control:
65 * acl <name> arp <Ethernet address> ...
69 * acl students arp 00:00:21:55:ed:22 00:00:21:ff:55:38
71 * NOTE: Linux code by David Luyer <luyer@ucs.uwa.edu.au>.
72 * Original (BSD-specific) code no longer works.
73 * Solaris code by R. Gancarz <radekg@solaris.elektrownia-lagisza.com.pl>
77 aclParseArpData(const char *t
)
80 Eui::Eui48
*q
= new Eui::Eui48
;
81 debugs(28, 5, "aclParseArpData: " << t
);
83 if (sscanf(t
, "%[0-9a-fA-F:]", buf
) != 1) {
84 debugs(28, DBG_CRITICAL
, "aclParseArpData: Bad ethernet address: '" << t
<< "'");
89 if (!q
->decode(buf
)) {
90 debugs(28, DBG_CRITICAL
, "" << cfg_filename
<< " line " << config_lineno
<< ": " << config_input_line
);
91 debugs(28, DBG_CRITICAL
, "aclParseArpData: Ignoring invalid ARP acl entry: can't parse '" << buf
<< "'");
100 /* aclParseArpList */
101 /*******************/
105 while (const char *t
= strtokFile()) {
106 if (Eui::Eui48
*q
= aclParseArpData(t
)) {
107 aclArpData
.insert(*q
);
114 ACLARP::match(ACLChecklist
*cl
)
116 ACLFilledChecklist
*checklist
= Filled(cl
);
118 /* IPv6 does not do ARP */
119 if (!checklist
->src_addr
.isIPv4()) {
120 debugs(14, 3, "ACLARP::match: IPv4 Required for ARP Lookups. Skipping " << checklist
->src_addr
);
124 Eui::Eui48 lookingFor
;
125 lookingFor
.lookup(checklist
->src_addr
);
126 return (aclArpData
.find(lookingFor
) != aclArpData
.end());
133 for (auto i
= aclArpData
.cbegin(); i
!= aclArpData
.cend(); ++i
) {
136 sl
.push_back(SBuf(buf
));
141 /* ==== END ARP ACL SUPPORT =============================================== */
143 #endif /* USE_SQUID_EUI */