if_nametoindex Subroutine

Purpose

Maps an interface name to its corresponding index.

Library

Standard C Library (libc.a)

Syntax

#include <net/if.h>
unsigned int if_nametoindex(const char *ifname);

Description

If the ifname parameter is the name of an interface, the if_nametoindex subroutine returns the interface index corresponding to the ifname name. If the ifname parameter is not the name of an interface, the if_nametoindex subroutine returns a 0 and the errno global variable is set to the appropriate value.

Parameters

Item Description
ifname Possible name of an interface.