Whisper Library
 All Classes Functions Variables Typedefs Enumerations Friends
whisper_library::EthernetHeader Class Reference

Represents an ethernet header. More...

Public Member Functions

 EthernetHeader ()
 Constructor that initializes the header with 0.
 
 EthernetHeader (unsigned char *header)
 Constructor that initializees the header with the given char array. More...
 
 ~EthernetHeader ()
 Destructor.
 
string sourceMAC ()
 Returns the source mac address in the format ff:ff:ff:ff:ff:ff (hexadecimal, bytes seperated by :)
 
string destinationMAC ()
 Returns the destination mac address in the format ff:ff:ff:ff:ff:ff (hexadecimal, bytes seperated by :)
 
unsigned long ethernetType ()
 Returns the ethernet type (2048<-> ipv4)
 
void setSourceMAC (string mac)
 Sets the source mac address in the format ff:ff:ff:ff:ff:ff (hexadecimal, bytes seperated by :)
 
void setSourceMAC (unsigned char *char_array)
 Sets the source mac address. More...
 
void setDestinationMAC (string mac)
 Sets the destination mac address in the format ff:ff:ff:ff:ff:ff (hexadecimal, bytes seperated by :)
 
void setDestinationMAC (unsigned char *char_array)
 Sets the destination mac address. More...
 
void setEthernetType (unsigned long type)
 Sets the ethernet type (2048<-> ipv4)
 
vector< bool > toVector ()
 Returns the content of the header as binary in little endian.
 
string toString ()
 Creates a string which lists all fields and values in humanly readable form. More...
 

Static Public Member Functions

static string toMacString (unsigned char *buffer)
 Converts a binary mac address to a string in the format ff:ff:ff:ff:ff:ff (hexadecimal, bytes seperated by :) More...
 

Private Member Functions

unsigned char hexToInt (string hex)
 Converts hexadecimal to decimal. More...
 

Static Private Member Functions

static string intToHex (unsigned int i)
 Converts an integer to hexadecimal. More...
 

Private Attributes

unsigned char * m_head
 holds the 14 byte header
 

Detailed Description

Represents an ethernet header.

This class provides getters and setters for all ethernet header fields (IEEE 802.3 without extensions) The content is exported as binary by using 'toVector'.

Constructor & Destructor Documentation

whisper_library::EthernetHeader::EthernetHeader ( unsigned char *  header)

Constructor that initializees the header with the given char array.

Parameters
headerpointer to char array of 14 byte (char <-> 1 byte)

Member Function Documentation

unsigned char whisper_library::EthernetHeader::hexToInt ( string  hex)
private

Converts hexadecimal to decimal.

Parameters
hexhexadecimal string, maximum 1 byte
Returns
decimal representation of given hex
string whisper_library::EthernetHeader::intToHex ( unsigned int  i)
staticprivate

Converts an integer to hexadecimal.

Parameters
iInteger you want to convert
Returns
String representing the integer as hex
void whisper_library::EthernetHeader::setDestinationMAC ( unsigned char *  char_array)

Sets the destination mac address.

Parameters
char_arraypointer to a char array of 6 bytes
void whisper_library::EthernetHeader::setSourceMAC ( unsigned char *  char_array)

Sets the source mac address.

Parameters
char_arraypointer to a char array of 6 bytes
string whisper_library::EthernetHeader::toMacString ( unsigned char *  buffer)
static

Converts a binary mac address to a string in the format ff:ff:ff:ff:ff:ff (hexadecimal, bytes seperated by :)

Parameters
bufferpointer to a char array of 6 byte
Returns
mac address as string
string whisper_library::EthernetHeader::toString ( )

Creates a string which lists all fields and values in humanly readable form.

Returns
String with all field values