Export (0) Print
Expand All
Expand Minimize

CreateIpForwardEntry2 (NETIOAPI) (Compact 2013)

3/26/2014

This function creates a new IP route entry on a local device.


NETIOAPI_API
  CreateIpForwardEntry2(
    IN const MIB_IPFORWARD_ROW2*  Row
    );

Row

A pointer to a MIB_IPFORWARD_ROW2 structure entry for an IP route entry.

CreateIpForwardEntry2 returns STATUS_SUCCESS if the function succeeds.

If the function fails, CreateIpForwardEntry2 returns one of the following error codes.

Error Code

Meaning

STATUS_INVALID_PARAMETER

An invalid parameter was passed to the function. This error is returned if one of the following situations occurs:

  • A NULL pointer is passed in the Row parameter.
  • The DestinationPrefix member of the MIB_IPFORWARD_ROW2 structure that the Row parameter points to was not specified.
  • The NextHop member of the MIB_IPFORWARD_ROW2 structure was not specified.
  • Both InterfaceLuid and InterfaceIndex members of the MIB_IPFORWARD_ROW2 structure were unspecified.
  • The PreferredLifetime member of the MIB_IPFORWARD_ROW2 structure is greater than the ValidLifetime member.
  • The SitePrefixLength member of the MIB_IPFORWARD_ROW2 structure is greater than the prefix length that is specified by the DestinationPrefix member.

This error is returned if a NULL pointer is passed in the Row parameter, the DestinationPrefix member of the MIB_IPFORWARD_ROW2 structure that is pointed to by the Row parameter was not specified, the NextHop member of the MIB_IPFORWARD_ROW2 structure was not specified, or both InterfaceLuid and InterfaceIndex members of the MIB_IPFORWARD_ROW2 structure were unspecified. This error is also returned if the PreferredLifetime member that is specified in the MIB_IPFORWARD_ROW2 structure is greater than the ValidLifetime member, or if the SitePrefixLength in the MIB_IPFORWARD_ROW2 structure is greater than the prefix length that is specified in the DestinationPrefix member.

STATUS_NOT_FOUND

The specified interface could not be found. This error is returned if the function cannot find the network interface that is specified by the InterfaceLuid or InterfaceIndex member of the MIB_IPNET_ROW2 structure that the Row parameter points to.

STATUS_NOT_SUPPORTED

The request is not supported. This error is returned if the interface that is specified does not support routes. This error is returned if no IPv4 stack is located on the local device and AF_INET was specified in the address family in the DestinationPrefix member of the MIB_IPFORWARD_ROW2 structure that the Row parameter points to, or if no IPv6 stack is located on the local device and AF_INET6 was specified for the address family in the DestinationPrefix member.

ERROR_OBJECT_ALREADY_EXISTS

The object already exists. This error is returned if the DestinationPrefix member of the MIB_IPFORWARD_ROW2 structure that the Row parameter points to is a duplicate of an existing IP route entry on the interface that is specified by the InterfaceLuid or InterfaceIndex member of the MIB_IPFORWARD_ROW2 structure.

Other

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

The CreateIpForwardEntry2 function is used to add a new neighbor IP address entry on a local device. Use the InitializeIpForwardEntry function to initialize the members of a MIB_IPFORWARD_ROW2 structure entry with default values. A driver can then change the members in the MIB_IPFORWARD_ROW2 entry that it wants to modify and then call CreateIpForwardEntry2.

Your driver must initialize the following members of the MIB_IPFORWARD_ROW2 structure that the Row parameter points to:

  • Set DestinationPrefix to a valid IPv4 or IPv6 address prefix.
  • Set NextHop to a valid IPv4 or IPv6 address and family.
  • Set InterfaceLuid or InterfaceIndex to the LUID or index value of the interface.

The InterfaceLuid and InterfaceIndex members are used in the order that is listed earlier. So if the InterfaceLuid is specified, this member is used to determine the interface to add the IP route entry on. If no value was set for the InterfaceLuid member (the value of this member was set to zero), the InterfaceIndex member is next used to determine the interface.

The route metric offset that is specified in the Metric member of the MIB_IPFORWARD_ROW2 structure that the Row parameter points to represents only part of the complete route metric. The complete metric is a combination of this route metric offset added to the interface metric that is specified in the Metric member of the MIB_IPINTERFACE_ROW structure of the associated interface. A driver can retrieve the interface metric by calling the GetIpInterfaceEntry (NETIOAPI) function.

The Age and Origin members of the MIB_IPFORWARD_ROW2 structure that the Row parameter points to are ignored when the CreateIpForwardEntry2 function is called. These members are set by the network stack and cannot be set by using the CreateIpForwardEntry2 function.

The CreateIpForwardEntry2 function fails if the DestinationPrefix and NextHop members of the MIB_IPFORWARD_ROW2 structure that the Row parameter points to are a duplicate of an existing IP route entry on the interface that is specified in the InterfaceLuid or InterfaceIndex members.

Show:
© 2014 Microsoft