]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/eui/Eui64.cc
2 * DEBUG: section ?? EUI-64 Handling
3 * AUTHOR: Amos Jeffries
5 * Copyright (c) 2009, Amos Jeffries <squid3@treenet.co.nz>
12 #include "compat/eui64_aton.h"
14 #include "eui/Eui64.h"
16 #include "ip/IpAddress.h"
19 Eui::Eui64::decode(const char *asc
)
21 if (eui64_aton(asc
, (struct eui64
*)eui
) != 0) return false;
27 Eui::Eui64::encode(char *buf
, const int len
)
29 if (len
< SZ_EUI64_BUF
) return false;
31 snprintf(buf
, len
, "%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x",
32 eui
[0], eui
[1], eui
[2], eui
[3],
33 eui
[4], eui
[5], eui
[6], eui
[7]);
37 // return binary representation of the EUI
39 Eui::Eui64::lookup(IpAddress
&c
)
41 /* try to short-circuit slow OS lookups by using SLAAC data */
42 if (lookupSlaac(c
)) return true;
44 // find EUI-64 some other way. NDP table lookup?
49 Eui::Eui64::lookupSlaac(IpAddress
&c
)
52 /* RFC 4291 Link-Local unicast addresses which contain SLAAC - usually trustable. */
53 if (c
.IsSiteLocal6() && c
.IsSlaac() ) {
55 // strip the final 64 bits of the address...
58 memcpy(eui
, &(tmp
.s6_addr
[8]), SZ_EUI64_BUF
);
66 // return binary representation of the EUI
68 Eui::Eui64::lookupNdp(IpAddress
&c
)
72 #if 0 /* no OS yet supported for NDP protocol lookup */
75 debugs(28, 0, "ERROR: ARP / MAC / EUI-* operations not supported on this operating system.");
79 * Address was not found on any interface
81 debugs(28, 3, HERE
<< c
<< " NOT found");
83 debugs(28, 0, "ERROR: IPv6 EUI-64 operations not supported on this operating system.");
90 #endif /* USE_SQUID_EUI */