The IP Helper APIs available for ARP on Windows are listed below:GetIpNetTable: Retrieves address resolution table information. SetIpNetEntry: Adds entry to the ARP table. DeleteIpNetEntry: Deletes entry from the ARP table. CreateIpNetEntry: Creates an entry in the ARP table. FlushIpNetTable: Deletes all ARP entries for the specified interface from the ARP table SendARP: Sends an ARP request to obtain the physical address that corresponds to the specified destination IP address The structures available in IP Helper APIs for ARP follow:MIB_IPNETTABLE: Contains a table of ARPentries. PMIB_IPNETTABLE: Pointer to MIB_IPNETTABLE structure. MIB_IPNETROW: Contains information for an ARPtable entry. PMIB_IPNETROW: Pointer to MIB_IPNETROW structure. In this program, GetIpNetTable of the API functions is used as follows:ULONG nSize=400;PMIB_IPNETTABLE pMib = (PMIB_IPNETTABLE)malloc(sizeof( MIB_IPNETTABLE)+ sizeof(MIB_IPNETROW)*nSize);DWORD dwRet = GetIpNetTable(pMib,&nSize,TRUE);. . .for (int i =0;i<nSize;i++) { char ipaddr[20], macaddr[20]; sprintf(ipaddr,"%d.%d.%d.%d", ( pMib->table[i].dwAddr&0x0000ff), ((pMib->table[i].dwAddr&0xff00)>>8), ((pMib->table[i].dwAddr&0xff0000)>>16), (pMib->table[i].dwAddr>>24) ); sprintf(macaddr, "%02x-%02x-%02x-%02x-%02x-%02x", pMib->table[i].bPhysAddr[0],pMib->table[i].bPhysAddr[1], pMib->table[i].bPhysAddr[2],pMib->table[i].bPhysAddr[3], pMib->table[i].bPhysAddr[4],pMib->table[i].bPhysAddr[5] ); printf("%-20s %-25s",ipaddr,macaddr); if (pMib->table[i].dwType == 3) printf("Dynamic\n"); else if (pMib->table[i].dwType == 4) printf("Static\n"); } Iphlpapi.lib needed
SetIpNetEntry: Adds entry to the ARP table.
DeleteIpNetEntry: Deletes entry from the ARP table.
CreateIpNetEntry: Creates an entry in the ARP table.
FlushIpNetTable: Deletes all ARP entries for the specified interface from the ARP table
SendARP: Sends an ARP request to obtain the physical address that corresponds to the specified destination IP address The structures available in IP Helper APIs for ARP follow:MIB_IPNETTABLE: Contains a table of ARPentries.
PMIB_IPNETTABLE: Pointer to MIB_IPNETTABLE structure.
MIB_IPNETROW: Contains information for an ARPtable entry.
PMIB_IPNETROW: Pointer to MIB_IPNETROW structure. In this program, GetIpNetTable of the API functions is used as follows:ULONG nSize=400;PMIB_IPNETTABLE pMib = (PMIB_IPNETTABLE)malloc(sizeof(
MIB_IPNETTABLE)+
sizeof(MIB_IPNETROW)*nSize);DWORD dwRet = GetIpNetTable(pMib,&nSize,TRUE);.
.
.for (int i =0;i<nSize;i++)
{
char ipaddr[20], macaddr[20]; sprintf(ipaddr,"%d.%d.%d.%d",
( pMib->table[i].dwAddr&0x0000ff),
((pMib->table[i].dwAddr&0xff00)>>8),
((pMib->table[i].dwAddr&0xff0000)>>16),
(pMib->table[i].dwAddr>>24)
); sprintf(macaddr, "%02x-%02x-%02x-%02x-%02x-%02x",
pMib->table[i].bPhysAddr[0],pMib->table[i].bPhysAddr[1],
pMib->table[i].bPhysAddr[2],pMib->table[i].bPhysAddr[3],
pMib->table[i].bPhysAddr[4],pMib->table[i].bPhysAddr[5]
); printf("%-20s %-25s",ipaddr,macaddr); if (pMib->table[i].dwType == 3) printf("Dynamic\n");
else if (pMib->table[i].dwType == 4) printf("Static\n");
}
Iphlpapi.lib needed
看看RFC吧!