OSDN Git Service

b6f5a70b581514d91e0bcff4cd81e52fc349fedf
[linuxjm/LDP_man-pages.git] / original / man3 / if_nametoindex.3
1 .\" Copyright (c) 2012 YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
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
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
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.
23 .\" %%%LICENSE_END
24 .\"
25 .TH IF_NAMETOINDEX 3 2014-04-01 "GNU" "Linux Programmer's Manual"
26 .SH NAME
27 if_nametoindex, if_indextoname \- mappings between network interface
28 names and indexes
29 .SH SYNOPSIS
30 .nf
31 .B #include <net/if.h>
32 .sp
33 .BI "unsigned int if_nametoindex(const char *" "ifname" );
34 .sp
35 .BI "char *if_indextoname(unsigned int ifindex, char *" ifname );
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 .
51 The buffer must allow for the storage of at least
52 .B IF_NAMESIZE
53 bytes.
54 .SH RETURN VALUE
55 On success,
56 .BR if_nametoindex ()
57 returns the index number of the network interface;
58 on error, 0 is returned and
59 .I errno
60 is set appropriately.
61
62 On success,
63 .BR if_indextoname ()
64 returns
65 .IR ifname ;
66 on error, NULL is returned and
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
82 .BR socket (2)
83 or
84 .BR ioctl (2).
85 .SH ATTRIBUTES
86 .SS Multithreading (see pthreads(7))
87 The
88 .BR if_nametoindex ()
89 and
90 .BR if_indextoname ()
91 functions are thread-safe.
92 .SH CONFORMING TO
93 RFC\ 3493, POSIX.1-2001.
94
95 This function first appeared in BSDi.
96 .SH SEE ALSO
97 .BR getifaddrs (3),
98 .BR if_nameindex (3),
99 .BR ifconfig (8)
100 .SH COLOPHON
101 This page is part of release 3.64 of the Linux
102 .I man-pages
103 project.
104 A description of the project,
105 and information about reporting bugs,
106 can be found at
107 \%http://www.kernel.org/doc/man\-pages/.