IP Helper Constants
This section details the constants used by the IP Helper API, which provides functions for retrieving and modifying the configuration of network interfaces, IP addresses, routing tables, and other network-related information.
General Constants
These constants are used across various IP Helper functions to specify parameters or indicate states.
| Constant | Value | Description |
|---|---|---|
IP_SUCCESS |
0 |
Indicates that the operation was successful. |
IP_BUFFER_TOO_SMALL |
234 |
The buffer provided is too small to hold the requested data. |
ERROR_INVALID_PARAMETER |
87 |
An invalid parameter was passed to the function. |
ERROR_NOT_SUPPORTED |
50 |
The requested operation is not supported on this system or interface. |
Constants for IP Addresses
These constants are used when working with IPv4 and IPv6 addresses.
| Constant | Value | Description |
|---|---|---|
AF_INET |
2 |
Address family for IPv4. |
AF_INET6 |
23 |
Address family for IPv6. |
IP_ADDRESS_TYPE_IPV4 |
1 |
Specifies an IPv4 address. |
IP_ADDRESS_TYPE_IPV6 |
2 |
Specifies an IPv6 address. |
IP_ADDR_EXACT |
0 |
Match an exact IP address. |
IP_ADDR_PREFIX |
1 |
Match an IP address prefix. |
Constants for Interface Types
These constants define the types of network interfaces.
| Constant | Value | Description |
|---|---|---|
IF_TYPE_ETHERNET_CSMACD |
6 |
Ethernet interface. |
IF_TYPE_LOOPBACK |
23 |
Loopback interface. |
IF_TYPE_PPP |
23 |
Point-to-Point Protocol interface. |
IF_TYPE_SOFTWARE_LOOPBACK |
243 |
Software loopback interface. |
Constants for Routing
These constants are used when managing the IP routing table.
| Constant | Value | Description |
|---|---|---|
RTM_DEST_IFL |
0x00000001 |
Destination interface list. |
RTM_NEXTHOP |
0x00000002 |
Next hop address. |
RTM_ROUTE_METRIC |
0x00000004 |
Route metric. |
RTM_ADD |
0x00000000 |
Add a route. |
RTM_DELETE |
0x00000001 |
Delete a route. |
RTM_CHANGE |
0x00000002 |
Change a route. |
Example Usage
Here's a conceptual example of using constants when querying for an IPv4 address:
// Assume some function call like:
// dwStatus = GetAdaptersInfo(pAdapterInfo, &ulOutBufLen);
// ... later when checking address type:
if (pAdapterInfo->AddressFamily == AF_INET) {
// This is an IPv4 address
printf("IPv4 Address: %s\n", inet_ntoa(pAdapterInfo->IpAddressList.IpAddress.S_un.S_addr));
} else if (pAdapterInfo->AddressFamily == AF_INET6) {
// This is an IPv6 address
// ... handle IPv6 ...
}