]>
Commit | Line | Data |
---|---|---|
2a5e7b35 YH |
1 | .\" Copyright (c) 2012 YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> |
2 | .\" | |
93015253 | 3 | .\" %%%LICENSE_START(VERBATIM) |
2a5e7b35 YH |
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. | |
7 | .\" | |
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. | |
12 | .\" | |
13 | .\" Since the Linux kernel and libraries are constantly changing, this | |
62290181 SP |
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 | |
2a5e7b35 YH |
19 | .\" professionally. |
20 | .\" | |
21 | .\" Formatted or processed versions of this manual, if unaccompanied by | |
22 | .\" the source, must acknowledge the copyright and authors of this work. | |
4b72fb64 | 23 | .\" %%%LICENSE_END |
2a5e7b35 | 24 | .\" |
4b8c67d9 | 25 | .TH IF_NAMETOINDEX 3 2017-09-15 "GNU" "Linux Programmer's Manual" |
2a5e7b35 | 26 | .SH NAME |
e8a16dbb MK |
27 | if_nametoindex, if_indextoname \- mappings between network interface |
28 | names and indexes | |
2a5e7b35 YH |
29 | .SH SYNOPSIS |
30 | .nf | |
31 | .B #include <net/if.h> | |
68e4db0a | 32 | .PP |
2a5e7b35 | 33 | .BI "unsigned int if_nametoindex(const char *" "ifname" ); |
68e4db0a | 34 | .PP |
e8a16dbb | 35 | .BI "char *if_indextoname(unsigned int ifindex, char *" ifname ); |
2a5e7b35 YH |
36 | .fi |
37 | .SH DESCRIPTION | |
38 | The | |
39 | .BR if_nametoindex () | |
40 | function returns the index of the network interface | |
41 | corresponding to the name | |
42 | .IR ifname . | |
847e0d88 | 43 | .PP |
2a5e7b35 YH |
44 | The |
45 | .BR if_indextoname () | |
46 | function returns the name of the network interface | |
47 | corresponding to the interface index | |
48 | .IR ifindex . | |
49 | The name is placed in the buffer pointed to by | |
50 | .IR ifname . | |
e8a16dbb | 51 | The buffer must allow for the storage of at least |
2a5e7b35 YH |
52 | .B IF_NAMESIZE |
53 | bytes. | |
2a5e7b35 YH |
54 | .SH RETURN VALUE |
55 | On success, | |
56 | .BR if_nametoindex () | |
57 | returns the index number of the network interface; | |
e8a16dbb | 58 | on error, 0 is returned and |
2a5e7b35 YH |
59 | .I errno |
60 | is set appropriately. | |
847e0d88 | 61 | .PP |
2a5e7b35 YH |
62 | On success, |
63 | .BR if_indextoname () | |
64 | returns | |
65 | .IR ifname ; | |
e8a16dbb | 66 | on error, NULL is returned and |
2a5e7b35 YH |
67 | .I errno |
68 | is set appropriately. | |
69 | .SH ERRORS | |
1187f16f DCS |
70 | .BR if_nametoindex () |
71 | may fail and set | |
72 | .I errno | |
73 | if: | |
74 | .TP | |
75 | .B ENODEV | |
76 | No interface found with given name. | |
77 | .PP | |
2a5e7b35 YH |
78 | .BR if_indextoname () |
79 | may fail and set | |
80 | .I errno | |
81 | if: | |
82 | .TP | |
83 | .B ENXIO | |
84 | No interface found for the index. | |
85 | .PP | |
86 | .BR if_nametoindex () | |
87 | and | |
88 | .BR if_indextoname () | |
89 | may also fail for any of the errors specified for | |
e8a16dbb MK |
90 | .BR socket (2) |
91 | or | |
2a5e7b35 | 92 | .BR ioctl (2). |
60bd4d85 | 93 | .SH ATTRIBUTES |
7546adb9 MK |
94 | For an explanation of the terms used in this section, see |
95 | .BR attributes (7). | |
96 | .TS | |
97 | allbox; | |
98 | lbw34 lb lb | |
99 | l l l. | |
100 | Interface Attribute Value | |
101 | T{ | |
102 | .BR if_nametoindex (), | |
60bd4d85 | 103 | .BR if_indextoname () |
7546adb9 MK |
104 | T} Thread safety MT-Safe |
105 | .TE | |
2a5e7b35 | 106 | .SH CONFORMING TO |
a22c8e53 | 107 | POSIX.1-2001, POSIX.1-2008, RFC\ 3493. |
847e0d88 | 108 | .PP |
2a5e7b35 YH |
109 | This function first appeared in BSDi. |
110 | .SH SEE ALSO | |
111 | .BR getifaddrs (3), | |
112 | .BR if_nameindex (3), | |
113 | .BR ifconfig (8) |