]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/if_nametoindex.3
All pages: Replace the 4th argument to .TH by "Linux man-pages (unreleased)"
[thirdparty/man-pages.git] / man3 / if_nametoindex.3
1 .\" Copyright (c) 2012 YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
2 .\"
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
4 .\"
5 .TH IF_NAMETOINDEX 3 2021-03-22 "Linux man-pages (unreleased)" "Linux Programmer's Manual"
6 .SH NAME
7 if_nametoindex, if_indextoname \- mappings between network interface
8 names and indexes
9 .SH LIBRARY
10 Standard C library
11 .RI ( libc ", " \-lc )
12 .SH SYNOPSIS
13 .nf
14 .B #include <net/if.h>
15 .PP
16 .BI "unsigned int if_nametoindex(const char *" "ifname" );
17 .BI "char *if_indextoname(unsigned int ifindex, char *" ifname );
18 .fi
19 .SH DESCRIPTION
20 The
21 .BR if_nametoindex ()
22 function returns the index of the network interface
23 corresponding to the name
24 .IR ifname .
25 .PP
26 The
27 .BR if_indextoname ()
28 function returns the name of the network interface
29 corresponding to the interface index
30 .IR ifindex .
31 The name is placed in the buffer pointed to by
32 .IR ifname .
33 The buffer must allow for the storage of at least
34 .B IF_NAMESIZE
35 bytes.
36 .SH RETURN VALUE
37 On success,
38 .BR if_nametoindex ()
39 returns the index number of the network interface;
40 on error, 0 is returned and
41 .I errno
42 is set to indicate the error.
43 .PP
44 On success,
45 .BR if_indextoname ()
46 returns
47 .IR ifname ;
48 on error, NULL is returned and
49 .I errno
50 is set to indicate the error.
51 .SH ERRORS
52 .BR if_nametoindex ()
53 may fail and set
54 .I errno
55 if:
56 .TP
57 .B ENODEV
58 No interface found with given name.
59 .PP
60 .BR if_indextoname ()
61 may fail and set
62 .I errno
63 if:
64 .TP
65 .B ENXIO
66 No interface found for the index.
67 .PP
68 .BR if_nametoindex ()
69 and
70 .BR if_indextoname ()
71 may also fail for any of the errors specified for
72 .BR socket (2)
73 or
74 .BR ioctl (2).
75 .SH ATTRIBUTES
76 For an explanation of the terms used in this section, see
77 .BR attributes (7).
78 .ad l
79 .nh
80 .TS
81 allbox;
82 lbx lb lb
83 l l l.
84 Interface Attribute Value
85 T{
86 .BR if_nametoindex (),
87 .BR if_indextoname ()
88 T} Thread safety MT-Safe
89 .TE
90 .hy
91 .ad
92 .sp 1
93 .SH STANDARDS
94 POSIX.1-2001, POSIX.1-2008, RFC\ 3493.
95 .PP
96 This function first appeared in BSDi.
97 .SH SEE ALSO
98 .BR getifaddrs (3),
99 .BR if_nameindex (3),
100 .BR ifconfig (8)