]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/eui/Eui64.cc
2 * Copyright (C) 1996-2014 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 89 EUI-64 Handling */
15 #include "compat/eui64_aton.h"
17 #include "eui/Eui64.h"
19 #include "ip/Address.h"
22 Eui::Eui64::decode(const char *asc
)
24 if (eui64_aton(asc
, (struct eui64
*)eui
) != 0) {
25 debugs(28, 4, "id=" << (void*)this << " decode fail on " << asc
);
29 debugs(28, 4, "id=" << (void*)this << " ATON decoded " << asc
);
34 Eui::Eui64::encode(char *buf
, const int len
)
36 if (len
< SZ_EUI64_BUF
) return false;
38 snprintf(buf
, len
, "%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x",
39 eui
[0], eui
[1], eui
[2], eui
[3],
40 eui
[4], eui
[5], eui
[6], eui
[7]);
41 debugs(28, 4, "id=" << (void*)this << " encoded " << buf
);
45 // return binary representation of the EUI
47 Eui::Eui64::lookup(const Ip::Address
&c
)
49 /* try to short-circuit slow OS lookups by using SLAAC data */
53 // find EUI-64 some other way. NDP table lookup?
58 Eui::Eui64::lookupSlaac(const Ip::Address
&c
)
60 /* RFC 4291 Link-Local unicast addresses which contain SLAAC - usually trustable. */
61 if (c
.isSiteLocal6() && c
.isSiteLocalAuto()) {
63 // strip the final 64 bits of the address...
66 memcpy(eui
, &(tmp
.s6_addr
[8]), SZ_EUI64_BUF
);
67 debugs(28, 4, "id=" << (void*)this << " SLAAC decoded " << c
);
71 debugs(28, 4, "id=" << (void*)this << " SLAAC fail on " << c
<< " SL-6="
72 << (c
.isSiteLocal6()?'T':'F') << " AAC-6=" << (c
.isSiteLocalAuto()?'T':'F'));
76 // return binary representation of the EUI
78 Eui::Eui64::lookupNdp(const Ip::Address
&c
)
80 #if 0 /* no actual lookup coded yet */
82 /* no OS yet supported for NDP protocol lookup */
83 debugs(28, DBG_CRITICAL
, "ERROR: ARP / MAC / EUI-* operations not supported on this operating system.");
86 * Address was not found on any interface
88 debugs(28, 3, "id=" << (void*)this << ' ' << c
<< " NOT found");
95 #endif /* USE_SQUID_EUI */