|
libdoip
0.1.0
DoIP (Diagnostics over Internet Protocol) ISO 13400 C++17 Library
|
Retrieves the MAC address of a network interface.This function is cross-platform and works on Linux, macOS, and Windows. It retrieves the hardware (MAC) address of the specified network interface.
| ifname | The name of the network interface (e.g., "eth0" on Linux, "en0" on macOS, "Ethernet" on Windows) If nullptr, the function will attempt to find the first available Ethernet interface. |
| mac | Reference to a MacAddress where the result will be stored |
MacAddress mac; if (getMacAddress("eth0", mac)) { // MAC address successfully retrieved printf("%02X:%02X:%02X:%02X:%02X:%02X\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); }