Partager via


CreateIpForwardEntry (Compact 2013)

3/26/2014

This function creates a route in the local computer's IP routing table.

Syntax

DWORD CreateIpForwardEntry( 
  PMIB_IPFORWARDROW pRoute
);

Parameters

  • pRoute
    [in] Pointer to a MIB_IPFORWARDROW structure that contains the information for the new route. The caller must specify values for all members of this structure. The caller must specify PROTO_IP_NETMGMT for the dwForwardProto member of MIB_IPFORWARDROW.

Return Value

Return code

Description

NO_ERROR (zero)

The function is successful

ERROR_ACCESS_DENIED

Access is denied.

ERROR_INVALID_PARAMETER

An input parameter is invalid, no action was taken. This error is returned if the pRoute parameter is NULL, the dwForwardProto member of MIB_IPFORWARDROW was not set to MIB_IPPROTO_NETMGMT, the dwForwardMask member of the PMIB_IPFORWARDROW structure is not a valid IPv4 subnet mask, or one of the other members of the MIB_IPFORWARDROW structure is invalid.

ERROR_NOT_SUPPORTED

The IPv4 transport is not configured on the local device.

Other

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

Remarks

The dwForwardProto member of MIB_IPFORWARDROW structure pointed to by the route parameter must be set to MIB_IPPROTO_NETMGMT otherwise CreateIpForwardEntry will fail. Routing protocol identifiers are used to identify route information for the specified routing protocol. For example, MIB_IPPROTO_NETMGMT is used to identify route information for IP routing set through network management such as the Dynamic Host Configuration Protocol (DCHP), the Simple Network Management Protocol (SNMP), or by calls to the CreateIpForwardEntry, DeleteIpForwardEntry, or SetIpForwardEntry functions.

Several members of the MIB_IPFORWARDROW structure pointed to by the route parameter are currently not used by CreateIpForwardEntry. These members include dwForwardPolicy, dwForwardType, dwForwardAge, dwForwardNextHopAS, dwForwardMetric2, dwForwardMetric3, dwForwardMetric4, and dwForwardMetric5.

A new route created by CreateIpForwardEntry will automatically have a default value for dwForwardAge of INFINITE.

To modify an existing route in the IPv4 routing table, use the SetIpForwardEntry function. To retrieve the IPv4 routing table, call the GetIpForwardTable function.

Requirements

Header

iphlpapi.h

Library

Iphlpapi.lib

See Also

Reference

IP Helper Functions
GetIpForwardTable
GetIpInterfaceEntry
DeleteIpForwardEntry
MIB_IPFORWARDROW
SetIpForwardEntry

Other Resources

IP Helper