1 .\" Copyright (c) 2012 YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .TH IF_NAMETOINDEX 3 2021-03-22 "Linux man-pages (unreleased)" "Linux Programmer's Manual"
7 if_nametoindex, if_indextoname \- mappings between network interface
11 .RI ( libc ", " \-lc )
14 .B #include <net/if.h>
16 .BI "unsigned int if_nametoindex(const char *" "ifname" );
17 .BI "char *if_indextoname(unsigned int ifindex, char *" ifname );
22 function returns the index of the network interface
23 corresponding to the name
28 function returns the name of the network interface
29 corresponding to the interface index
31 The name is placed in the buffer pointed to by
33 The buffer must allow for the storage of at least
39 returns the index number of the network interface;
40 on error, 0 is returned and
42 is set to indicate the error.
48 on error, NULL is returned and
50 is set to indicate the error.
58 No interface found with given name.
66 No interface found for the index.
71 may also fail for any of the errors specified for
76 For an explanation of the terms used in this section, see
84 Interface Attribute Value
86 .BR if_nametoindex (),
88 T} Thread safety MT-Safe
94 POSIX.1-2001, POSIX.1-2008, RFC\ 3493.
96 This function first appeared in BSDi.