Partager via


if_nametoindex (NETIOAPI) (Compact 2013)

3/26/2014

This function converts the ANSI interface name for a network interface to the local index for the interface.

Syntax

NET_IFINDEX NETIOAPI_API_
  if_nametoindex(
    __in PCSTR  InterfaceName
    );

Parameters

  • InterfaceName
    A pointer to a NULL-terminated ANSI string that contains the interface name.

Return Value

if_nametoindex function returns the local interface index if the function succeeds. If the function fails, if_nametoindex returns zero.

Remarks

The if_nametoindex function maps an interface name into its corresponding index. This function is designed as part of basic socket extensions for IPv6 as described by the IETF in RFC 2553.

The if_nametoindex function is implemented for portability of drivers that have Unix environments, but the ConvertInterfaceXxx functions are the preferred method to convert network interface identifiers. You can replace the if_nametoindex function by a call to the ConvertInterfaceNameToLuidA (NETIOAPI) function to convert the ANSI interface name to a NET_LUID structure, followed by a call to the ConvertInterfaceLuidToIndex (NETIOAPI) function to convert NET_LUID to the local interface index.

If the if_nametoindex function fails and returns zero, you cannot determine an error code.

See Also

Reference

IP Helper Kernel-Mode Functions
ConvertInterfaceLuidToIndex (NETIOAPI)
ConvertInterfaceNameToLuidA (NETIOAPI)
NET_LUID