1 .\" Copyright (c) 2012 YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of
9 .\" this manual under the conditions for verbatim copying, provided that
10 .\" the entire resulting derived work is distributed under the terms of
11 .\" a permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume
15 .\" no responsibility for errors or omissions, or for damages resulting
16 .\" from the use of the information contained herein. The author(s) may
17 .\" not have taken the same level of care in the production of this
18 .\" manual, which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
25 .TH IF_NAMETOINDEX 3 2021-03-22 "GNU" "Linux Programmer's Manual"
27 if_nametoindex, if_indextoname \- mappings between network interface
31 .B #include <net/if.h>
33 .BI "unsigned int if_nametoindex(const char *" "ifname" );
34 .BI "char *if_indextoname(unsigned int ifindex, char *" ifname );
39 function returns the index of the network interface
40 corresponding to the name
45 function returns the name of the network interface
46 corresponding to the interface index
48 The name is placed in the buffer pointed to by
50 The buffer must allow for the storage of at least
56 returns the index number of the network interface;
57 on error, 0 is returned and
59 is set to indicate the error.
65 on error, NULL is returned and
67 is set to indicate the error.
75 No interface found with given name.
83 No interface found for the index.
88 may also fail for any of the errors specified for
93 For an explanation of the terms used in this section, see
101 Interface Attribute Value
103 .BR if_nametoindex (),
104 .BR if_indextoname ()
105 T} Thread safety MT-Safe
111 POSIX.1-2001, POSIX.1-2008, RFC\ 3493.
113 This function first appeared in BSDi.
116 .BR if_nameindex (3),