]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/eui/Eui48.h
dfa06baa344ced184fce917bb3dc05d53876ee7b
2 * Copyright (C) 1996-2015 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_EUI48_H
10 #define _SQUID_EUI_EUI48_H
14 /* EUI-48 is 6 bytes. */
15 #define SZ_EUI48_BUF 6
32 Eui48(const Eui48
&t
) { memcpy(this, &t
, sizeof(Eui48
)); }
35 const unsigned char *get(void);
37 bool set(const char *src
, const int len
) {
38 if (len
> SZ_EUI48_BUF
) return false;
39 if (len
< SZ_EUI48_BUF
) clear();
40 memcpy(eui
, src
, len
);
44 void clear() { memset(eui
, 0, SZ_EUI48_BUF
); }
47 * Decode an ascii representation of an EUI-48 ethernet address.
49 * \param asc ASCII representation of an ethernet (MAC) address
50 * \param eth Binary representation of the ethernet address
51 * \retval false Conversion to binary failed. Invalid address
52 * \retval true Conversion completed successfully
54 bool decode(const char *asc
);
57 * Encode an ascii representation (asc) of an EUI-48 ethernet address.
59 * \param buf Buffer to receive ASCII representation of an ethernet (MAC) address
60 * \param len Length of the buffer space available. Must be >= SZ_EUI48_BUF bytes or the encode will fail.
61 * \param eui Binary representation of the ethernet address
62 * \retval false Conversion to ASCII failed.
63 * \retval true Conversion completed successfully.
65 bool encode(char *buf
, const int len
) const;
67 // lookup an EUI-48 / MAC address via ARP
68 bool lookup(const Ip::Address
&c
);
71 unsigned char eui
[SZ_EUI48_BUF
];
76 #endif /* USE_SQUID_EUI */
77 #endif /* _SQUID_EUI_EUI48_H */