次の方法で共有


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

Parameters

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

Return Value

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

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 applications that have 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.

See Also

Reference

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