/*
- * DEBUG: section 89 EUI-48 Lookup
- * AUTHOR: Duane Wessels
+ * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
*
- * SQUID Web Proxy Cache http://www.squid-cache.org/
- * ----------------------------------------------------------
- *
- * Squid is the result of efforts by numerous individuals from
- * the Internet community; see the CONTRIBUTORS file for full
- * details. Many organizations have provided support for Squid's
- * development; see the SPONSORS file for full details. Squid is
- * Copyrighted (C) 2001 by the Regents of the University of
- * California; see the COPYRIGHT file for full details. Squid
- * incorporates software developed and/or copyrighted by other
- * sources; see the CREDITS file for full details.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
- *
- *
- * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
*/
+/* DEBUG: section 89 EUI-48 Lookup */
+
#include "squid.h"
#if USE_SQUID_EUI
#include <cerrno>
/* START Legacy includes pattern */
-/* TODO: clean this up so we dont have per-OS requirements.
+/* TODO: clean this up so we do not have per-OS requirements.
The files are checked for existence individually
and can be wrapped
*/
* Working on setting up a proper firewall for a network containing some
* Win'95 computers at our Univ, I've discovered that some smart students
* avoid the restrictions easily just changing their IP addresses in Win'95
- * Contol Panel... It has been getting boring, so I took Squid-1.1.18
+ * Control Panel... It has been getting boring, so I took Squid-1.1.18
* sources and added a new acl type for hard-wired access control:
*
* acl <name> arp <Ethernet address> ...
if (sscanf(asc, "%x:%x:%x:%x:%x:%x", &a1, &a2, &a3, &a4, &a5, &a6) != 6) {
debugs(28, DBG_CRITICAL, "Decode EUI-48: Invalid ethernet address '" << asc << "'");
clear();
- return false; /* This is not valid address */
+ return false; /* This is not valid address */
}
eui[0] = (u_char) a1;
}
bool
-Eui::Eui48::encode(char *buf, const int len)
+Eui::Eui48::encode(char *buf, const int len) const
{
if (len < SZ_EUI48_BUF)
return false;
/* IPv6 builds do not provide the first http_port as an IPv4 socket for ARP */
int tmpSocket = socket(AF_INET,SOCK_STREAM,0);
if (tmpSocket < 0) {
- debugs(28, DBG_IMPORTANT, "Attempt to open socket for EUI retrieval failed: " << xstrerror());
+ int xerrno = errno;
+ debugs(28, DBG_IMPORTANT, "Attempt to open socket for EUI retrieval failed: " << xstrerr(xerrno));
clear();
return false;
}
close(tmpSocket);
if (arpReq.arp_ha.sa_family != ARPHRD_ETHER) {
+ debugs(28, 4, "id=" << (void*)this << " ... not an Ethernet interface: " << arpReq.arp_ha.sa_data);
clear();
return false;
}
ifc.ifc_buf = (char *)ifbuffer;
if (ioctl(tmpSocket, SIOCGIFCONF, &ifc) < 0) {
- debugs(28, DBG_IMPORTANT, "Attempt to retrieve interface list failed: " << xstrerror());
+ int xerrno = errno;
+ debugs(28, DBG_IMPORTANT, "Attempt to retrieve interface list failed: " << xstrerr(xerrno));
clear();
close(tmpSocket);
return false;
/* Query ARP table */
if (-1 == ioctl(tmpSocket, SIOCGARP, &arpReq)) {
- /*
- * Query failed. Do not log failed lookups or "device
- * not supported"
- */
-
- if (ENXIO == errno)
- (void) 0;
- else if (ENODEV == errno)
- (void) 0;
- else
- debugs(28, DBG_IMPORTANT, "ARP query " << ipAddr << " failed: " << ifr->ifr_name << ": " << xstrerror());
+ int xerrno = errno;
+ // Query failed. Do not log failed lookups or "device not supported"
+ if (ENXIO != xerrno && ENODEV != xerrno)
+ debugs(28, DBG_IMPORTANT, "ARP query " << ipAddr << " failed: " << ifr->ifr_name << ": " << xstrerr(xerrno));
continue;
}
/* IPv6 builds do not provide the first http_port as an IPv4 socket for ARP */
int tmpSocket = socket(AF_INET,SOCK_STREAM,0);
if (tmpSocket < 0) {
- debugs(28, DBG_IMPORTANT, "Attempt to open socket for EUI retrieval failed: " << xstrerror());
+ int xerrno = errno;
+ debugs(28, DBG_IMPORTANT, "Attempt to open socket for EUI retrieval failed: " << xstrerr(xerrno));
clear();
return false;
}
mib[4] = NET_RT_FLAGS;
+#if defined(RTF_LLDATA)
+ mib[5] = RTF_LLDATA;
+#else
mib[5] = RTF_LLINFO;
+#endif
if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0) {
debugs(28, DBG_CRITICAL, "Can't estimate ARP table size!");
/* ==== END EUI LOOKUP SUPPORT =============================================== */
#endif /* USE_SQUID_EUI */
+