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