IP Helper API

The IP Helper API provides functions for retrieving and modifying the configuration of network interfaces and protocols on a local computer.

Core Concepts

The IP Helper API is essential for network programming in Windows. It allows applications to:

  • Query IP address information for network adapters.
  • Manage ARP cache entries.
  • Retrieve routing table information.
  • Get and set TCP/IP parameters.
  • Monitor network events.

Key Functions

GetAdaptersInfo

DWORD GetAdaptersInfo( PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen );

Retrieves detailed information about installed network adapters.

Parameters

Name Type Description
pAdapterInfo PIP_ADAPTER_INFO Pointer to a buffer that receives an array of IP_ADAPTER_INFO structures.
pOutBufLen PULONG Pointer to a variable that specifies the size, in bytes, of the buffer pointed to by pAdapterInfo.

Return Value

If the function succeeds, the return value is NO_ERROR. If the buffer is not large enough to hold the adapter information, the function returns ERROR_BUFFER_OVERFLOW and the value pointed to by pOutBufLen is updated with the required buffer size.

GetIpAddrTable

DWORD GetIpAddrTable( PMIB_IPADDRTABLE pIpAddrTable, PULONG pdwSize, BOOL bOrder );

Retrieves the local IP address table.

Parameters

Name Type Description
pIpAddrTable PMIB_IPADDRTABLE Pointer to a buffer that receives the IP address table.
pdwSize PULONG Pointer to a variable that specifies the size, in bytes, of the buffer pointed to by pIpAddrTable.
bOrder BOOL A flag that indicates whether the entries in the table should be sorted.

Return Value

If the function succeeds, the return value is NO_ERROR. If the buffer pointed to by pIpAddrTable is not large enough, the function returns ERROR_INSUFFICIENT_BUFFER, and the value pointed to by pdwSize is updated with the required buffer size.

SendARP

ULONG SendARP( IPADDR DestIP, IPADDR SrcIP, PULONG pMacAddr, PULONG pAdapter );

Resolves a specified IPv4 address to its corresponding physical address (MAC address).

Parameters

Name Type Description
DestIP IPADDR The destination IPv4 address.
SrcIP IPADDR The source IPv4 address. If zero, the system chooses a source IP address.
pMacAddr PULONG Pointer to a buffer that receives the physical address.
pAdapter PULONG Pointer to a variable that receives the handle to the adapter that sent the ARP request.

Return Value

If the function succeeds, the return value is the physical address. If the function fails, the return value is zero. Extended error information is available by calling GetLastError.

Requirements

Header: Iphlpapi.h
Library: Iphlpapi.lib
DLL: Iphlpapi.dll