]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/if_nametoindex.3
malloc.3: Add reference to glibc MallocInternals wiki
[thirdparty/man-pages.git] / man3 / if_nametoindex.3
CommitLineData
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
27if_nametoindex, if_indextoname \- mappings between network interface
28names 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
38The
39.BR if_nametoindex ()
40function returns the index of the network interface
41corresponding to the name
42.IR ifname .
847e0d88 43.PP
2a5e7b35
YH
44The
45.BR if_indextoname ()
46function returns the name of the network interface
47corresponding to the interface index
48.IR ifindex .
49The name is placed in the buffer pointed to by
50.IR ifname .
e8a16dbb 51The buffer must allow for the storage of at least
2a5e7b35
YH
52.B IF_NAMESIZE
53bytes.
2a5e7b35
YH
54.SH RETURN VALUE
55On success,
56.BR if_nametoindex ()
57returns the index number of the network interface;
e8a16dbb 58on error, 0 is returned and
2a5e7b35
YH
59.I errno
60is set appropriately.
847e0d88 61.PP
2a5e7b35
YH
62On success,
63.BR if_indextoname ()
64returns
65.IR ifname ;
e8a16dbb 66on error, NULL is returned and
2a5e7b35
YH
67.I errno
68is set appropriately.
69.SH ERRORS
1187f16f
DCS
70.BR if_nametoindex ()
71may fail and set
72.I errno
73if:
74.TP
75.B ENODEV
76No interface found with given name.
77.PP
2a5e7b35
YH
78.BR if_indextoname ()
79may fail and set
80.I errno
81if:
82.TP
83.B ENXIO
84No interface found for the index.
85.PP
86.BR if_nametoindex ()
87and
88.BR if_indextoname ()
89may also fail for any of the errors specified for
e8a16dbb
MK
90.BR socket (2)
91or
2a5e7b35 92.BR ioctl (2).
60bd4d85 93.SH ATTRIBUTES
7546adb9
MK
94For an explanation of the terms used in this section, see
95.BR attributes (7).
96.TS
97allbox;
98lbw34 lb lb
99l l l.
100Interface Attribute Value
101T{
102.BR if_nametoindex (),
60bd4d85 103.BR if_indextoname ()
7546adb9
MK
104T} Thread safety MT-Safe
105.TE
2a5e7b35 106.SH CONFORMING TO
a22c8e53 107POSIX.1-2001, POSIX.1-2008, RFC\ 3493.
847e0d88 108.PP
2a5e7b35
YH
109This function first appeared in BSDi.
110.SH SEE ALSO
111.BR getifaddrs (3),
112.BR if_nameindex (3),
113.BR ifconfig (8)