]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/eui/Eui64.cc
Source Format Enforcement (#763)
[thirdparty/squid.git] / src / eui / Eui64.cc
index 5b01644282f03bc48dd043129836da863cae3f39..653f48c4cb75ba285bef9eb9f4af1dfa1e619782 100644 (file)
@@ -1,11 +1,14 @@
 /*
- * DEBUG: section 89    EUI-64 Handling
- * AUTHOR: Amos Jeffries
+ * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
  *
- * Copyright (c) 2009, Amos Jeffries <squid3@treenet.co.nz>
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
  */
 
-#include "config.h"
+/* DEBUG: section 89    EUI-64 Handling */
+
+#include "squid.h"
 
 #if USE_SQUID_EUI
 
 bool
 Eui::Eui64::decode(const char *asc)
 {
-    if (eui64_aton(asc, (struct eui64 *)eui) != 0) return false;
+    if (eui64_aton(asc, (struct eui64 *)eui) != 0) {
+        debugs(28, 4, "id=" << (void*)this << " decode fail on " << asc);
+        return false;
+    }
 
+    debugs(28, 4, "id=" << (void*)this << " ATON decoded " << asc);
     return true;
 }
 
 bool
-Eui::Eui64::encode(char *buf, const int len)
+Eui::Eui64::encode(char *buf, const int len) const
 {
     if (len < SZ_EUI64_BUF) return false;
 
     snprintf(buf, len, "%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x",
              eui[0], eui[1], eui[2], eui[3],
              eui[4], eui[5], eui[6], eui[7]);
+    debugs(28, 4, "id=" << (void*)this << " encoded " << buf);
     return true;
 }
 
 // return binary representation of the EUI
 bool
-Eui::Eui64::lookup(Ip::Address &c)
+Eui::Eui64::lookup(const Ip::Address &c)
 {
     /* try to short-circuit slow OS lookups by using SLAAC data */
-    if (lookupSlaac(c)) return true;
+    if (lookupSlaac(c))
+        return true;
 
     // find EUI-64 some other way. NDP table lookup?
     return lookupNdp(c);
 }
 
 bool
-Eui::Eui64::lookupSlaac(Ip::Address &c)
+Eui::Eui64::lookupSlaac(const Ip::Address &c)
 {
-#if USE_IPV6
     /* RFC 4291 Link-Local unicast addresses which contain SLAAC - usually trustable. */
-    if (c.IsSiteLocal6() && c.IsSlaac() ) {
+    if (c.isSiteLocal6() && c.isSiteLocalAuto()) {
 
         // strip the final 64 bits of the address...
         struct in6_addr tmp;
-        c.GetInAddr(tmp);
+        c.getInAddr(tmp);
         memcpy(eui, &(tmp.s6_addr[8]), SZ_EUI64_BUF);
-
+        debugs(28, 4, "id=" << (void*)this << " SLAAC decoded " << c);
         return true;
     }
-#endif
+
+    debugs(28, 4, "id=" << (void*)this << " SLAAC fail on " << c << " SL-6="
+           << (c.isSiteLocal6()?'T':'F') << " AAC-6=" << (c.isSiteLocalAuto()?'T':'F'));
     return false;
 }
 
 // return binary representation of the EUI
 bool
-Eui::Eui64::lookupNdp(Ip::Address &c)
+Eui::Eui64::lookupNdp(const Ip::Address &/*c*/)
 {
 #if 0 /* no actual lookup coded yet */
-#if USE_IPV6
 
     /* no OS yet supported for NDP protocol lookup */
-    debugs(28, 0, "ERROR: ARP / MAC / EUI-* operations not supported on this operating system.");
+    debugs(28, DBG_CRITICAL, "ERROR: ARP / MAC / EUI-* operations not supported on this operating system.");
 
     /*
      * Address was not found on any interface
      */
-    debugs(28, 3, HERE << c << " NOT found");
-#else
-    debugs(28, 0, "ERROR: IPv6 EUI-64 operations not supported on this operating system.");
-#endif
+    debugs(28, 3, "id=" << (void*)this << ' ' << c << " NOT found");
 #endif /* 0 */
 
     clear();
@@ -87,3 +93,4 @@ Eui::Eui64::lookupNdp(Ip::Address &c)
 }
 
 #endif /* USE_SQUID_EUI */
+