]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/eui/Eui64.h
283b714e0dc1b9b9a92faa98b0421c76183689c0
2 * Copyright (C) 1996-2017 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 #ifndef _SQUID_EUI_EUI64_H
10 #define _SQUID_EUI_EUI64_H
21 #include <sys/eui64.h>
27 /* EUI-64 is 8 bytes. */
28 #if defined(EUI64_LEN)
29 #define SZ_EUI64_BUF EUI64_LEN
31 #define SZ_EUI64_BUF 8
39 Eui64(const Eui64
&t
) { memcpy(this, &t
, sizeof(Eui64
)); }
40 Eui64
& operator= (const Eui64
&t
) {memcpy(this, &t
, sizeof(Eui64
)); return *this;}
41 bool operator== (const Eui64
&t
) const { return (memcmp(eui
,t
.eui
,SZ_EUI64_BUF
) == 0); }
42 bool operator< (const Eui64
&t
) const { return (memcmp(eui
,t
.eui
,SZ_EUI64_BUF
) < 0); }
45 const unsigned char *get(void);
47 bool set(const char *src
, const int len
) {
48 if (len
> SZ_EUI64_BUF
) return false;
49 if (len
< SZ_EUI64_BUF
) clear();
50 memcpy(eui
, src
, len
);
54 void clear() { memset(eui
, 0, SZ_EUI64_BUF
); }
57 * Decode an ascii representation of an EUI-64 address.
59 * \param asc ASCII representation of an EUI-64 address
60 * \param eth Binary representation of the EUI_64 address
61 * \retval false Conversion to binary failed. Invalid address
62 * \retval true Conversion completed successfully
64 bool decode(const char *asc
);
67 * Encode an ascii representation (asc) of an EUI-64 address.
69 * \param buf Buffer to receive ASCII representation of an EUI-64 address
70 * \param len Length of the buffer space available. Must be >= SZ_EUI64_BUF bytes or the encode will fail.
71 * \param eui Binary representation of the EUI-64 address
72 * \retval false Conversion to ASCII failed.
73 * \retval true Conversion completed successfully.
75 bool encode(char *buf
, const int len
) const;
77 // lookup an EUI-64 address via IPv6 SLAAC or NDP
78 bool lookup(const Ip::Address
&c
);
80 // lookup an EUI-64 address via IPv6 NDP
81 bool lookupNdp(const Ip::Address
&c
);
83 // lookup an EUI-64 address via decoding the IPv6 address SLAAC data
84 bool lookupSlaac(const Ip::Address
&c
);
87 unsigned char eui
[SZ_EUI64_BUF
];
92 #endif /* USE_SQUID_EUI */
93 #endif /* _SQUID_EUI_EUI64_H */