次の方法で共有


GetIpForwardTable (Compact 2013)

3/26/2014

This function retrieves the IP routing table.

Syntax

DWORD GetIpForwardTable(
  PMIB_IPFORWARDTABLE pIpForwardTable, 
  PULONG pdwSize, 
  BOOL bOrder 
);

Parameters

  • pIpForwardTable
    [out] Pointer to a buffer that contains the IP routing table as a MIB_IPFORWARDTABLE structure.
  • pdwSize
    [in, out] The size of the buffer indicated by the pIpForwardTable parameter. If the buffer is not large enough to hold the returned routing table, the function sets this parameter to the required buffer size.
  • bOrder
    [in] TRUE if the retrieved table should be sorted, and FALSE otherwise. The following list shows the order in which the table is sorted if this parameter is TRUE:

    • Destination address.
    • Protocol that generated the route.
    • Multipath routing policy.
    • Next-hop address.

Return Value

Return code

Description

NO_ERROR (zero)

The function succeeds.

ERROR_INSUFFICIENT_BUFFER

The buffer pointed to by the pIpForwardTable parameter is not large enough. The required size is returned in the DWORD variable pointed to by the pdwSize parameter.

ERROR_INVALID_PARAMETER

The pdwSize parameter is NULL, or GetIpForwardTable is unable to write to the memory pointed to by the pdwSize parameter.

ERROR_NO_DATA

No data is available. This error is returned if there are no routes present on the local device.

ERROR_NOT_SUPPORTED

This function is not supported on the operating system that is used on the local system. This error is returned if there is no IP stack installed on the local device.

Other

Use FormatMessage to obtain the message string for the returned error.

Remarks

The dwForwardProto member of the MIB_IPFORWARDROW structure specifies the protocol or routing mechanism that generated the route.

The dwForwardDest, dwForwardMask, and dwForwardNextHop members of the MIB_IPFORWARDROW structure represent an IPv4 address in network byte order.

An IPv4 address of 0.0.0.0 in the dwForwardDest member of the MIB_IPFORWARDROW structure is considered a default route. The MIB_IPFORWARDTABLE may contain multiple MIB_IPFORWARDROW entries with the dwForwardDest member set to 0.0.0.0 when there are multiple network adapters installed.

When dwForwardAge is set to INFINITE, the route will not be removed based on a time-out value. Any other value for dwForwardAge specifies the number of seconds since the route was added or modified in the network routing table.

Requirements

Header

iphlpapi.h

Library

Iphlpapi.lib

See Also

Reference

IP Helper Functions
CreateIpForwardEntry
DeleteIpForwardEntry
GetIpInterfaceEntry
MIB_IPFORWARDTABLE
MIB_IPINTERFACE_ROW
SetIpForwardEntry

Other Resources

IP Helper