if_nametoindex function

The if_nametoindex 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 [in]

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

Return value

If the function succeeds, if_nametoindex returns the local interface index. 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 with 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 function to convert the ANSI interface name to a NET_LUID union, followed by a call to the ConvertInterfaceLuidToIndex 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.

Requirements

Version

Available in Windows Vista and later versions of the Windows operating systems.

Header

Netioapi.h (include Netioapi.h)

IRQL

PASSIVE_LEVEL

See also

ConvertInterfaceLuidToIndex
ConvertInterfaceNameToLuidA
NET_LUID

 

 

Send comments about this topic to Microsoft

Show:
© 2014 Microsoft. All rights reserved.