#include <MACAddress.h>
Inheritance diagram for MACAddress:

Public Methods | |
| MACAddress () | |
| MACAddress (const char *hexstr) | |
| MACAddress (const MACAddress &other) | |
| MACAddress & | operator= (const MACAddress &other) |
| virtual unsigned int | getAddressArraySize () const |
| virtual unsigned char | getAddress (unsigned int k) const |
| virtual void | setAddress (unsigned int k, unsigned char addrbyte) |
| void | setAddress (const char *hexstr) |
| unsigned char * | getAddressBytes () |
| void | setAddressBytes (unsigned char *addrbytes) |
| void | setBroadcast () |
| bool | isBroadcast () const |
| bool | isMulticast () const |
| bool | isEmpty () const |
| const char * | toHexString (char *buf) const |
| bool | equals (const MACAddress &other) const |
| int | compareTo (const MACAddress &other) const |
Private Attributes | |
| unsigned char | address [6] |
Definition at line 32 of file MACAddress.h.
|
|
Default constructor initializes address bytes to zero. Definition at line 66 of file MACAddress.cc. References address.
|
|
|
Constructor which accepts hex string or the string "auto". Definition at line 71 of file MACAddress.cc. References setAddress().
00071 : MACAddress_Base() 00072 { 00073 setAddress(hexstr); 00074 } |
|
|
Copy constructor. Definition at line 49 of file MACAddress.h. References operator=().
00049 : MACAddress_Base() {operator=(other);} |
|
|
Returns -1, 0 or 1 as result of comparison of 2 addresses. Definition at line 143 of file MACAddress.cc. References address, and MAC_ADDRESS_BYTES. Referenced by MACRelayUnitBase::MAC_compare::operator()().
00144 {
00145 return memcmp(address, other.address, MAC_ADDRESS_BYTES);
00146 }
|
|
|
Returns true if 2 addresses are equal. Definition at line 138 of file MACAddress.cc. References address, and MAC_ADDRESS_BYTES. Referenced by EtherMAC::processFrameFromUpperLayer(), and EtherMAC::processReceivedDataFrame().
00139 {
00140 return memcmp(address, other.address, MAC_ADDRESS_BYTES)==0;
00141 }
|
|
|
Returns the kth byte of the address. Implements MACAddress_Base. Definition at line 88 of file MACAddress.cc. References address.
00089 {
00090 if (k>=6) throw new cException("Array of size 6 indexed with %d", k);
00091 return address[k];
00092 }
|
|
|
Returns 6. Implements MACAddress_Base. Definition at line 83 of file MACAddress.cc.
00084 {
00085 return 6;
00086 }
|
|
|
Returns pointer to internal binary representation of address (array of 6 unsigned chars). Definition at line 74 of file MACAddress.h. References address.
00074 {return address;}
|
|
|
Returns true this is the broadcast address (hex ff:ff:ff:ff:ff:ff). Definition at line 118 of file MACAddress.cc. References address. Referenced by MACRelayUnitBase::handleAndDispatchFrame(), and EtherMAC::processReceivedDataFrame().
|
|
|
Returns true if all address bytes are zero. Definition at line 124 of file MACAddress.cc. References address. Referenced by EtherAppCli::initialize(), and EtherMAC::processFrameFromUpperLayer().
|
|
|
Returns true this is a multicast logical address (starts with bit 1). Definition at line 90 of file MACAddress.h. References address.
00090 {return address[0]&0x80;};
|
|
|
Assignment. Definition at line 76 of file MACAddress.cc. References address, MAC_ADDRESS_BYTES, and MACAddress_Base::operator=(). Referenced by MACAddress().
00077 {
00078 MACAddress_Base::operator=(other);
00079 memcpy(address, other.address, MAC_ADDRESS_BYTES);
00080 return *this;
00081 }
|
|
|
Converts address value from hex string. The string "auto" is also accepted, it'll generate a unique address starting with "A0 00". Definition at line 100 of file MACAddress.cc. References address, and MAC_ADDRESS_BYTES.
00101 {
00102 if (!hexstr)
00103 throw new cException("MACAddress::setAddress(const char *): got null pointer");
00104 if (hextobin(hexstr, address, MAC_ADDRESS_BYTES)!=MAC_ADDRESS_BYTES)
00105 throw new cException("MACAddress::setAddress(const char *): hex string \"%s\" too short, should be 12 hex digits", hexstr);
00106 }
|
|
||||||||||||
|
Sets the kth byte of the address. Implements MACAddress_Base. Definition at line 94 of file MACAddress.cc. References address. Referenced by EtherMAC::initialize(), and MACAddress().
00095 {
00096 if (k>=6) throw new cException("Array of size 6 indexed with %d", k);
00097 address[k] = addrbyte;
00098 }
|
|
|
Sets address bytes. The argument should point to an array of 6 unsigned chars. Definition at line 108 of file MACAddress.cc. References address, and MAC_ADDRESS_BYTES. Referenced by EtherMAC::initialize().
00109 {
00110 memcpy(address, addrbytes, MAC_ADDRESS_BYTES);
00111 }
|
|
|
Sets the address to the broadcast address (hex ff:ff:ff:ff:ff:ff). Definition at line 113 of file MACAddress.cc. References address.
|
|
|
Converts address to hext string and places result into passed buffer. Definition at line 129 of file MACAddress.cc. References address, and MAC_ADDRESS_BYTES. Referenced by EtherMAC::initialize(), and EtherMAC::processFrameFromUpperLayer().
00130 {
00131 char *s = buf;
00132 for (int i=0; i<MAC_ADDRESS_BYTES; i++, s+=3)
00133 sprintf(s,"%2.2X:",address[i]);
00134 *(s-1)='\0';
00135 return buf;
00136 }
|
|
|
Definition at line 35 of file MACAddress.h. Referenced by compareTo(), equals(), getAddress(), getAddressBytes(), isBroadcast(), isEmpty(), isMulticast(), MACAddress(), operator=(), setAddress(), setAddressBytes(), setBroadcast(), and toHexString(). |
1.2.17