1IF_NAMETOINDEX(3)          Linux Programmer's Manual         IF_NAMETOINDEX(3)
2
3
4

NAME

6       if_nametoindex,  if_indextoname  -  mappings  between network interface
7       names and indexes
8

SYNOPSIS

10       #include <net/if.h>
11
12       unsigned int if_nametoindex(const char *ifname);
13
14       char *if_indextoname(unsigned int ifindex, char *ifname);
15

DESCRIPTION

17       The if_nametoindex() function returns the index of the  network  inter‐
18       face corresponding to the name ifname.
19
20       The if_indextoname() function returns the name of the network interface
21       corresponding to the interface index ifindex.  The name  is  placed  in
22       the buffer pointed to by ifname.  The buffer must allow for the storage
23       of at least IF_NAMESIZE bytes.
24

RETURN VALUE

26       On success, if_nametoindex() returns the index number  of  the  network
27       interface; on error, 0 is returned and errno is set appropriately.
28
29       On success, if_indextoname() returns ifname; on error, NULL is returned
30       and errno is set appropriately.
31

ERRORS

33       if_indextoname() may fail and set errno if:
34
35       ENXIO  No interface found for the index.
36
37       if_nametoindex() and if_indextoname() may also  fail  for  any  of  the
38       errors specified for socket(2) or ioctl(2).
39

CONFORMING TO

41       RFC 3493, POSIX.1-2001.
42
43       This function first appeared in BSDi.
44

SEE ALSO

46       getifaddrs(3), if_nameindex(3), ifconfig(8)
47

COLOPHON

49       This  page  is  part of release 3.53 of the Linux man-pages project.  A
50       description of the project, and information about reporting  bugs,  can
51       be found at http://www.kernel.org/doc/man-pages/.
52
53
54
55GNU                               2012-12-14                 IF_NAMETOINDEX(3)
Impressum