]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/eui/Eui64.cc
2 * DEBUG: section 89 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/Address.h"
19 Eui::Eui64::decode(const char *asc
)
21 if (eui64_aton(asc
, (struct eui64
*)eui
) != 0) {
22 debugs(28, 4, "id=" << (void*)this << " decode fail on " << asc
);
26 debugs(28, 4, "id=" << (void*)this << " ATON decoded " << asc
);
31 Eui::Eui64::encode(char *buf
, const int len
)
33 if (len
< SZ_EUI64_BUF
) return false;
35 snprintf(buf
, len
, "%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x",
36 eui
[0], eui
[1], eui
[2], eui
[3],
37 eui
[4], eui
[5], eui
[6], eui
[7]);
38 debugs(28, 4, "id=" << (void*)this << " encoded " << buf
);
42 // return binary representation of the EUI
44 Eui::Eui64::lookup(const Ip::Address
&c
)
46 /* try to short-circuit slow OS lookups by using SLAAC data */
50 // find EUI-64 some other way. NDP table lookup?
55 Eui::Eui64::lookupSlaac(const Ip::Address
&c
)
57 /* RFC 4291 Link-Local unicast addresses which contain SLAAC - usually trustable. */
58 if (c
.isSiteLocal6() && c
.isSiteLocalAuto()) {
60 // strip the final 64 bits of the address...
63 memcpy(eui
, &(tmp
.s6_addr
[8]), SZ_EUI64_BUF
);
64 debugs(28, 4, "id=" << (void*)this << " SLAAC decoded " << c
);
68 debugs(28, 4, "id=" << (void*)this << " SLAAC fail on " << c
<< " SL-6="
69 << (c
.isSiteLocal6()?'T':'F') << " AAC-6=" << (c
.isSiteLocalAuto()?'T':'F'));
73 // return binary representation of the EUI
75 Eui::Eui64::lookupNdp(const Ip::Address
&c
)
77 #if 0 /* no actual lookup coded yet */
79 /* no OS yet supported for NDP protocol lookup */
80 debugs(28, DBG_CRITICAL
, "ERROR: ARP / MAC / EUI-* operations not supported on this operating system.");
83 * Address was not found on any interface
85 debugs(28, 3, "id=" << (void*)this << ' ' << c
<< " NOT found");
92 #endif /* USE_SQUID_EUI */