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_nametoindex() may fail and set errno if:
34
35       ENODEV No interface found with given name.
36
37       if_indextoname() may fail and set errno if:
38
39       ENXIO  No interface found for the index.
40
41       if_nametoindex() and if_indextoname() may also  fail  for  any  of  the
42       errors specified for socket(2) or ioctl(2).
43

ATTRIBUTES

45       For   an   explanation   of   the  terms  used  in  this  section,  see
46       attributes(7).
47
48       ┌───────────────────────────────────┬───────────────┬─────────┐
49Interface                          Attribute     Value   
50       ├───────────────────────────────────┼───────────────┼─────────┤
51if_nametoindex(), if_indextoname() │ Thread safety │ MT-Safe │
52       └───────────────────────────────────┴───────────────┴─────────┘

CONFORMING TO

54       POSIX.1-2001, POSIX.1-2008, RFC 3493.
55
56       This function first appeared in BSDi.
57

SEE ALSO

59       getifaddrs(3), if_nameindex(3), ifconfig(8)
60

COLOPHON

62       This page is part of release 4.15 of the Linux  man-pages  project.   A
63       description  of  the project, information about reporting bugs, and the
64       latest    version    of    this    page,    can     be     found     at
65       https://www.kernel.org/doc/man-pages/.
66
67
68
69GNU                               2017-09-15                 IF_NAMETOINDEX(3)
Impressum