Expand Minimize

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 WINAPI if_nametoindex(
  _In_  PCSTR InterfaceName
);

Parameters

InterfaceName [in]

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

Minimum supported client

Windows Vista [desktop apps only]

Minimum supported server

Windows Server 2008 [desktop apps only]

Header

Netioapi.h (include Iphlpapi.h)

Library

Iphlpapi.lib

DLL

Iphlpapi.dll

See also

ConvertInterfaceAliasToLuid
ConvertInterfaceGuidToLuid
ConvertInterfaceIndexToLuid
ConvertInterfaceLuidToAlias
ConvertInterfaceLuidToGuid
ConvertInterfaceLuidToIndex
ConvertInterfaceLuidToNameA
ConvertInterfaceLuidToNameW
ConvertInterfaceNameToLuidA
ConvertInterfaceNameToLuidW
if_indextoname
NET_LUID

 

 

Community Additions

ADD
Show:
© 2014 Microsoft