| Description | The arp_get_info function retrieves the IP address for the requested MAC (ethernet) address, or retrieves the MAC address for the requested IP address, from the ARP cache table. The argument info points to a structure in memory, which contains the input parameter for the function call, and returns result on function exit. The value of input parameter depends on which address we want to retrieve: | info.IpAdr | info.HwAdr | Description |
|---|
| IP address | don't care | The function copies the MAC address to info.HwAdr for the requested IP address from the ARP cache table. | | 0.0.0.0 | MAC address | The function copies the IP address to info.IpAdr for the requested MAC address from the ARP cache table. |
The arp_get_info function is in the RL-TCPnet library. The prototype is defined in net_config.h. note - Only the ethernet network interface needs to use the arp_get_info function. There is no ARP protocol for the PPP and SLIP network interfaces.
|
| Example |
#include <Net_Config.h>
void get_host_mac (void) {
static const U8 rem_IP[4] = {192,168,0,100};
REMOTEM rm;
mem_copy (rm.IpAdr, rem_IP, IP_ADRLEN);
if (arp_get_info (&rm) == __TRUE) {
/* Requested IP is cached, print the MAC address. */
print ("MAC address is %02x-%02x-%02x-%02x-%02x-%02x\n",
rm.HwAdr[0],rm.HwAdr[1],rm.HwAdr[2],
rm.HwAdr[3],rm.HwAdr[4],rm.HwAdr[5]);
}
else {
printf ("Requested IP address not found in ARP cache!\n");
}
}
|