]>
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 | .\" |
fe0fefbf | 25 | .TH IF_NAMETOINDEX 3 2015-03-02 "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> | |
32 | .sp | |
33 | .BI "unsigned int if_nametoindex(const char *" "ifname" ); | |
e8a16dbb MK |
34 | .sp |
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 . | |
43 | ||
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. | |
61 | ||
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 | |
70 | .BR if_indextoname () | |
71 | may fail and set | |
72 | .I errno | |
73 | if: | |
74 | .TP | |
75 | .B ENXIO | |
76 | No interface found for the index. | |
77 | .PP | |
78 | .BR if_nametoindex () | |
79 | and | |
80 | .BR if_indextoname () | |
81 | may also fail for any of the errors specified for | |
e8a16dbb MK |
82 | .BR socket (2) |
83 | or | |
2a5e7b35 | 84 | .BR ioctl (2). |
60bd4d85 | 85 | .SH ATTRIBUTES |
7546adb9 MK |
86 | For an explanation of the terms used in this section, see |
87 | .BR attributes (7). | |
88 | .TS | |
89 | allbox; | |
90 | lbw34 lb lb | |
91 | l l l. | |
92 | Interface Attribute Value | |
93 | T{ | |
94 | .BR if_nametoindex (), | |
60bd4d85 | 95 | .BR if_indextoname () |
7546adb9 MK |
96 | T} Thread safety MT-Safe |
97 | .TE | |
2a5e7b35 | 98 | .SH CONFORMING TO |
a22c8e53 | 99 | POSIX.1-2001, POSIX.1-2008, RFC\ 3493. |
2a5e7b35 YH |
100 | |
101 | This function first appeared in BSDi. | |
102 | .SH SEE ALSO | |
103 | .BR getifaddrs (3), | |
104 | .BR if_nameindex (3), | |
105 | .BR ifconfig (8) |