style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-7505528228218001"
data-ad-slot="1225241371">

2.2.1 - Getting hardware MAC address from interface

You can get interface's MAC address directly from PcapIf class by calling on PcapIf.getHardwareAddress(). This method will return a byte[] containing the hardware address. The length of the array tells the exact length of the address. If null is returned, that means that the physical interface, does not support hardware addresses, such as loopback interface, a PPP interface, etc..

Notice that PcapIf.getHardwareAddress() method is a convenience method. The actual implementation of this method is in the PcapUtils.getHardwareAdderess() call. Libpcap library does not provide any function calls to acquire a hardware address of an interface. This has been added as an extension to libpcap in a PcapUtils class.