2#ifndef CLICK_ETHERADDRESS_HH
3#define CLICK_ETHERADDRESS_HH
5#include <click/glue.hh>
11 typedef uninitialized_type uninitialized_t;
15 _data[0] = _data[1] = _data[2] = 0;
23 memcpy(_data,
data, 6);
39 typedef
bool (
EtherAddress::*unspecified_bool_type)() const;
41 inline operator unspecified_bool_type()
const {
65 return _data[0] + _data[1] + _data[2] == 0x2FFFD;
70#if HAVE_INDIFFERENT_ALIGNMENT
78 inline unsigned char *
data() {
79 return reinterpret_cast<unsigned char *
>(_data);
83 inline const unsigned char *
data()
const {
84 return reinterpret_cast<const unsigned char *
>(_data);
88# pragma GCC diagnostic push
89# pragma GCC diagnostic ignored "-Waddress-of-packed-member"
93 inline const uint16_t *
sdata()
const {
97# pragma GCC diagnostic pop
102 return (_data[2] | ((
size_t) _data[1] << 16))
103 ^ ((size_t) _data[0] << 9);
138 inline String s() const CLICK_DEPRECATED;
143 inline operator
String() const CLICK_DEPRECATED;
152 _data[0] = _data[1] = _data[2] = m;
155} CLICK_SIZE_PACKED_ATTRIBUTE;
213 typedef void enable_direct_parse;
216 return parse(str, value, args, flags_);
218 inline bool parse(
const String& str,
unsigned char* value,
const ArgContext& args = blank_args) {
219 return parse(str, *
reinterpret_cast<EtherAddress *
>(value), args);
222 return direct_parse(str, value, args, flags_);
224 inline bool direct_parse(
const String& str,
unsigned char* value,
Args& args) {
225 return direct_parse(str, *
reinterpret_cast<EtherAddress *
>(value), args);
Argument context class.
Definition args.hh:31
Argument parser class.
Definition args.hh:249
Parser class for Ethernet addresses.
Definition etheraddress.hh:212
An Ethernet address.
Definition etheraddress.hh:9
bool operator!=(const EtherAddress &a, const EtherAddress &b)
Compares two EtherAddress objects for inequality.
Definition etheraddress.hh:186
bool operator==(const EtherAddress &a, const EtherAddress &b)
Compares two EtherAddress objects for equality.
Definition etheraddress.hh:176
static bool is_broadcast(const unsigned char *data)
Return true if data points to a broadcast address.
Definition etheraddress.hh:69
size_t hashcode() const
Hash function.
Definition etheraddress.hh:101
EtherAddress(const unsigned char *data)
Construct an EtherAddress from data.
Definition etheraddress.hh:22
String unparse() const
Unparse this address into a dash-separated hex String.
Definition etheraddress.hh:116
bool is_local() const
Return true iff this address is a "local" address.
Definition etheraddress.hh:57
static EtherAddress make_broadcast()
Return the broadcast EtherAddress, FF-FF-FF-FF-FF-FF.
Definition etheraddress.hh:32
const uint16_t * sdata() const
Return a pointer to the address data, as an array of uint16_ts.
Definition etheraddress.hh:93
bool is_broadcast() const
Return true iff this address is the broadcast address.
Definition etheraddress.hh:64
EtherAddress()
Construct an EtherAddress equal to 00-00-00-00-00-00.
Definition etheraddress.hh:14
unsigned char * data()
Return a pointer to the address data.
Definition etheraddress.hh:78
bool is_group() const
Return true iff this address is a group address.
Definition etheraddress.hh:49
String unparse_dash() const
Unparse this address into a dash-separated hex String.
Definition etheraddress.cc:43
String unparse_colon() const
Unparse this address into a colon-separated hex String.
Definition etheraddress.cc:61
String s() const
Unparse this address into a dash-separated hex String.
Definition etheraddress.hh:168
EtherAddress(const uninitialized_type &unused)
Construct an uninitialized EtherAddress.
Definition etheraddress.hh:27
const unsigned char * data() const
Definition etheraddress.hh:83
Efficiently build up Strings from pieces.
Definition straccum.hh:28
friend StringAccum & operator<<(StringAccum &sa, const String &str)
Append the contents of str to sa.
Definition straccum.hh:601
A string of characters.
Definition string.hh:22
Vector template.
Definition vector.hh:111
Type wrapper for the constant true.
Template determining whether T may be copied by memcpy.
Definition type_traits.hh:66