# MAC48 Data Type

Topics

:

Overview
Conditional Directives
Constants
Functions

Overview

The gxMAC48 class is used by database applications to represent 48-bit MAC addresses independently of the operating system or hardware platform used. A MAC (Media Access Control) address is a hardware address that uniquely identifies each node of a network. Ethernet hardware addresses are 48 bits, expressed as 12 hexadecimal digits. The first 24 bits of the MAC address consist of a unique vendor code, which should match the vendor of the network interface card.

Conditional Directives

__UNIX__

- Conditional directive required for all UNIX variants.

__WIN32__

- Conditional directive required for all WIN32 platforms

Constants

    const int mac48MaxStrLen = 255; // Maximum MAC48 string length

Functions

gxMAC48::gxMAC48()
gxMAC48::GetByte1()
gxMAC48::GetByte2()
gxMAC48::GetByte3()
gxMAC48::GetByte4()
gxMAC48::GetByte5()
gxMAC48::GetByte6()
gxMAC48::GetVendorCode()
gxMAC48::SetByte1()
gxMAC48::SetByte2()
gxMAC48::SetByte3()
gxMAC48::SetByte4()
gxMAC48::SetByte5()
gxMAC48::SetByte6()
gxMAC48::SetMACAddress()
gxMAC48::SizeOf()
gxMAC48::c_str()

Standalone Helper functions

:
ParseMACVendorEntry()
FindVendor()

gxMAC48::gxMAC48(unsigned char b1 = 0, unsigned char b2 = 0, unsigned char b3 = 0,unsigned char b4 = 0, unsigned char b5 = 0, unsigned char b6 = 0)

- Default class constructor.

gxMAC48::gxMAC48(char *mac, char delimiter = ':', int tuple = 2)

- Class constructor used to construct an object and assign its MAC address based on the null terminated "mac" string.

gxMAC48::gxMAC48(const char *mac, char delimiter = ':', int tuple = 2)

- Class constructor used to construct an object and assign its MAC address based on the null terminated "mac" string.

gxMAC48::gxMAC48(const gxMAC48& ob)

- Class copy constructor.

gxMAC48& gxMAC48::operator=(const gxMAC48& ob)

- Assignment operator.

unsigned char gxMAC48::GetByte1()

- Public member function that returns MAC address byte 1.

unsigned char gxMAC48::GetByte2()

- Public member function that returns MAC address byte 2.

unsigned char gxMAC48::GetByte3()

- Public member function that returns MAC address byte 3.

unsigned char gxMAC48::GetByte4()

- Public member function that returns MAC address byte 4.

unsigned char gxMAC48::GetByte5()

- Public member function that returns MAC address byte 5.

unsigned char gxMAC48::GetByte6()

- Public member function that returns MAC address byte 6.

int gxMAC48::GetVendorCode()

- Public member function that returns the vendor code portion of the MAC address.

char *gxMAC48::GetVendorCode(char *sbuf)

- Public member function that passes back the vendor code portion of the MAC address in a null terminated string and redundantly returns the string. NOTE: The calling function must allocate a memory buffer large enough to hold a single MAC48 string.

void gxMAC48::SetByte1(unsigned char b = 0)

- Public member function used to set MAC address byte 1.

void gxMAC48::SetByte2(unsigned char b = 0)

- Public member function used to set MAC address byte 2.

void gxMAC48::SetByte3(unsigned char b = 0)

- Public member function used to set MAC address byte 3

void gxMAC48::SetByte4(unsigned char b = 0)

- Public member function used to set MAC address byte 4.

void gxMAC48::SetByte5(unsigned char b = 0)

- Public member function used to set MAC address byte 5.

void gxMAC48::SetByte6(unsigned char b = 0)

- Public member function used to set MAC address byte 6.

int gxMAC48::SetMACAddress(const char *mac, char delimiter = ':', int tuple = 2)

- Public member function used to set the MAC address using a null terminated character string. Return false if the string is not formatted correctly using the 48-bit notation: 00:60:B0:F9:B8:95, 00-60-B0-F9-B8-95, 0060.B0F9.B895, or 0060-B0F9-B895

int gxMAC48::SetMACAddress(char *mac, char delimiter = ':', int tuple = 2)

- Public member function used to set the MAC address using a null terminated character string. Return false if the string is not formatted correctly using the 48-bit notation: 00:60:B0:F9:B8:95, 00-60-B0-F9-B8-95, 0060.B0F9.B895, or 0060-B0F9-B895

void gxMAC48::SetMACAddress(unsigned char b1 = 0, unsigned char b2 = 0, unsigned char b3 = 0, unsigned char b4 = 0,unsigned char b5 = 0, unsigned char b6 = 0)

- Public member function used to set the MAC address using individual byte values.

unsigned gxMAC48::SizeOf()

- Public member function that returns the size of a gxMAC48 object.

char *gxMAC48::c_str(char *sbuf, char delimiter = ':', int tuple = 2)

- Public member function that passes back a null terminated MAC48 string in the "sbuf" variable and redundantly return the string. NOTE: The calling function must allocate a memory buffer large enough to hold a single MAC48 string.

int ParseMACVendorEntry(char *entry, char *code, char *name, char *comment)

- Standalone function used to parse a single line of a MAC vendor code text file. Returns true if no error were encountered or false if the line does not contain a valid vendor code and name. MAC vendor text database format:

    <vendor code> <vendor name> [# comments]

int FindVendor(const char *fname, const char *code, char *name, char *comment)

- Standalone function used to find vendor information in a MAC code text database file. Returns true if a match is found or false if a match could not be found or an error occurs. If successful the vendor name and any comments will be passed back in the "name" and "comment" variables.

int FindVendor(const char *fname, const gxMAC48 &mac, char *name, char *comment)

- Standalone function used to find vendor information in a MAC code text database file. Returns true if a match is found or false if a match could not be found or an error occurs. If successful the vendor name and any comments will be passed back in the "name" and "comment" variables.

End Of Document