Click
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Related Symbols | List of all members
EtherAddress Class Reference

An Ethernet address. More...

Public Types

typedef uninitialized_type uninitialized_t
 
typedef bool(EtherAddress::* unspecified_bool_type) () const
 
typedef const EtherAddress & parameter_type
 

Public Member Functions

 EtherAddress ()
 Construct an EtherAddress equal to 00-00-00-00-00-00.
 
 EtherAddress (const unsigned char *data)
 Construct an EtherAddress from data.
 
 EtherAddress (const uninitialized_type &unused)
 Construct an uninitialized EtherAddress.
 
 operator unspecified_bool_type () const
 Return true iff the address is not 00-00-00-00-00-00.
 
bool is_group () const
 Return true iff this address is a group address.
 
bool is_local () const
 Return true iff this address is a "local" address.
 
bool is_broadcast () const
 Return true iff this address is the broadcast address.
 
unsigned char * data ()
 Return a pointer to the address data.
 
const unsigned char * data () const
 
const uint16_t * sdata () const
 Return a pointer to the address data, as an array of uint16_ts.
 
size_t hashcode () const
 Hash function.
 
String unparse () const
 Unparse this address into a dash-separated hex String.
 
String unparse_colon () const
 Unparse this address into a colon-separated hex String.
 
String unparse_dash () const
 Unparse this address into a dash-separated hex String.
 
String s () const
 Unparse this address into a dash-separated hex String.
 
 operator String () const
 Unparse this address into a dash-separated hex String.
 

Static Public Member Functions

static EtherAddress make_broadcast ()
 Return the broadcast EtherAddress, FF-FF-FF-FF-FF-FF.
 
static EtherAddress broadcast ()
 
static bool is_broadcast (const unsigned char *data)
 Return true if data points to a broadcast address.
 

Related Symbols

(Note that these are not member symbols.)

bool operator== (const EtherAddress &a, const EtherAddress &b)
 Compares two EtherAddress objects for equality.
 
bool operator!= (const EtherAddress &a, const EtherAddress &b)
 Compares two EtherAddress objects for inequality.
 

Detailed Description

An Ethernet address.

The EtherAddress type represents an Ethernet address. It supports equality operations and provides methods for unparsing addresses into ASCII form.

Constructor & Destructor Documentation

◆ EtherAddress() [1/3]

EtherAddress::EtherAddress ( )
inline

Construct an EtherAddress equal to 00-00-00-00-00-00.

◆ EtherAddress() [2/3]

EtherAddress::EtherAddress ( const unsigned char *  data)
inlineexplicit

Construct an EtherAddress from data.

Parameters
datathe address data, in network byte order

The bytes data[0]...data[5] are used to construct the address.

◆ EtherAddress() [3/3]

EtherAddress::EtherAddress ( const uninitialized_type &  unused)
inline

Construct an uninitialized EtherAddress.

Member Function Documentation

◆ make_broadcast()

static EtherAddress EtherAddress::make_broadcast ( )
inlinestatic

Return the broadcast EtherAddress, FF-FF-FF-FF-FF-FF.

◆ operator unspecified_bool_type()

EtherAddress::operator unspecified_bool_type ( ) const
inline

Return true iff the address is not 00-00-00-00-00-00.

◆ is_group()

bool EtherAddress::is_group ( ) const
inline

Return true iff this address is a group address.

Group addresses have the low-order bit of the first byte set to 1, as in 01-00-00-00-00-00 or 03-00-00-02-04-09.

◆ is_local()

bool EtherAddress::is_local ( ) const
inline

Return true iff this address is a "local" address.

Local addresses have the next-to-lowest-order bit of the first byte set to 1.

◆ is_broadcast() [1/2]

bool EtherAddress::is_broadcast ( ) const
inline

Return true iff this address is the broadcast address.

The Ethernet broadcast address is FF-FF-FF-FF-FF-FF.

◆ is_broadcast() [2/2]

static bool EtherAddress::is_broadcast ( const unsigned char *  data)
inlinestatic

Return true if data points to a broadcast address.

◆ data() [1/2]

unsigned char * EtherAddress::data ( )
inline

Return a pointer to the address data.

◆ data() [2/2]

const unsigned char * EtherAddress::data ( ) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ sdata()

const uint16_t * EtherAddress::sdata ( ) const
inline

Return a pointer to the address data, as an array of uint16_ts.

◆ hashcode()

size_t EtherAddress::hashcode ( ) const
inline

Hash function.

◆ unparse()

String EtherAddress::unparse ( ) const
inline

Unparse this address into a dash-separated hex String.

Examples include "00-00-00-00-00-00" and "00-05-4E-50-3C-1A".

Note
The IEEE standard for printing Ethernet addresses uses dashes as separators, not colons. Use unparse_colon() to unparse into the nonstandard colon-separated form.

◆ unparse_colon()

String EtherAddress::unparse_colon ( ) const

Unparse this address into a colon-separated hex String.

Examples include "00:00:00:00:00:00" and "00:05:4E:50:3C:1A".

Note
Use unparse() to create the IEEE standard dash-separated form.

◆ unparse_dash()

String EtherAddress::unparse_dash ( ) const

Unparse this address into a dash-separated hex String.

Examples include "00-00-00-00-00-00" and "00-05-4E-50-3C-1A".

Note
This is the IEEE standard for printing Ethernet addresses.
See also
unparse_colon

◆ s()

String EtherAddress::s ( ) const
inline

Unparse this address into a dash-separated hex String.

Deprecated:
The unparse() function should be preferred to s().
See also
unparse

◆ operator String()

EtherAddress::operator String ( ) const
inline

Unparse this address into a dash-separated hex String.

Deprecated:
The unparse() function should be preferred to this cast.
See also
unparse

Friends And Related Symbol Documentation

◆ operator==()

bool operator== ( const EtherAddress &  a,
const EtherAddress &  b 
)
related

Compares two EtherAddress objects for equality.

◆ operator!=()

bool operator!= ( const EtherAddress &  a,
const EtherAddress &  b 
)
related

Compares two EtherAddress objects for inequality.


The documentation for this class was generated from the following files: