Edit

Share via


if_nametoindex function (netioapi.h)

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

Syntax

IPHLPAPI_DLL_LINKAGE NET_IFINDEX NETIOAPI_API_ if_nametoindex(
  [in] PCSTR InterfaceName
);

Parameters

[in] InterfaceName

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

Return value

On success, if_nametoindex returns the local interface index. On failure, zero is returned.

Remarks

The if_nametoindex function is available on Windows Vista and later.

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. For more information, see http://www.ietf.org/rfc/rfc2553.txt.

The if_nametoindex function is implemented for portability of applications with Unix environments, but the ConvertInterface functions are preferred. The if_nametoindex function can be replaced by a call to the ConvertInterfaceNameToLuidA function to convert the ANSI interface name to a NET_LUID followed by a call to the ConvertInterfaceLuidToIndex to convert the NET_LUID to the local interface index.

If the if_nametoindex function fails and returns zero, it is not possible to determine an error code.

Requirements

Requirement Value
Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Target Platform Windows
Header netioapi.h (include Iphlpapi.h)
Library Iphlpapi.lib
DLL Iphlpapi.dll

See also

ConvertInterfaceAliasToLuid

ConvertInterfaceGuidToLuid

ConvertInterfaceIndexToLuid

ConvertInterfaceLuidToAlias

ConvertInterfaceLuidToGuid

ConvertInterfaceLuidToIndex

ConvertInterfaceLuidToNameA

ConvertInterfaceLuidToNameW

ConvertInterfaceNameToLuidA

ConvertInterfaceNameToLuidW

NET_LUID

if_indextoname