if_nametoindex - NtDoc

Native API online documentation, based on the System Informer (formerly Process Hacker) phnt headers
// netioapi.h

NET_IFINDEX NETIOAPI_API_ if_nametoindex(
  _In_ PCSTR InterfaceName
);
View the official Windows hardware development documentation

NtDoc

No description available.

Windows hardware development documentation (if-nametoindex)

if_nametoindex function

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

Parameters

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 ConvertInterface*Xxx* 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

Target platform Universal
Version Available in Windows Vista and later versions of the Windows operating systems.
Header Netioapi.h (include Netioapi.h)
Library Netio.lib
IRQL PASSIVE_LEVEL

See also

ConvertInterfaceLuidToIndex

ConvertInterfaceNameToLuidA

NET_LUID