- Tutorials
- API Examples
- User Guide
- Ch 1 - The Basics
- Ch 2 - libpcap
- 2.1 - The Main libpcap API Overview
- 2.2 - Getting a List of Interfaces
- 2.3 - Opening a Network Interface for Capture
- 2.4 - Opening offline capture
- 2.5 - Setting a packet filter
- 2.6 - Reading one packet at a time
- 2.7 - Reading multiple packets with dispatch loops
- 2.8 - Dumping captured packet to an offline file
- 2.9 - Transmitting packets
- 2.10 - Close Pcap and PcapDumper handles
- Ch 3 - Packet Decoding
- Ch 4 - Internals
- Ch 5 - Protocols
- Ch 6 - Native API
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.
»
Printer-friendly- Login or register to post comments
Send via Email
PDF Convert