Debian Codegraph @

upstream/debian-trixie/man3/if_nametoindex.3

raw
1 '\" t
2 .\" Copyright (c) 2012 YOSHIFUJI Hideaki <[email protected]>
3 .\"
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\"
6 .TH if_nametoindex 3 2024-05-02 "Linux man-pages 6.9.1"
7 .SH NAME
8 if_nametoindex, if_indextoname \- mappings between network interface
9 names and indexes
10 .SH LIBRARY
11 Standard C library
12 .RI ( libc ", " \-lc )
13 .SH SYNOPSIS
14 .nf
15 .B #include <net/if.h>
16 .P
17 .BI "unsigned int if_nametoindex(const char *" "ifname" );
18 .BI "char *if_indextoname(unsigned int ifindex, char *" ifname );
19 .fi
20 .SH DESCRIPTION
21 The
22 .BR if_nametoindex ()
23 function returns the index of the network interface
24 corresponding to the name
25 .IR ifname .
26 .P
27 The
28 .BR if_indextoname ()
29 function returns the name of the network interface
30 corresponding to the interface index
31 .IR ifindex .
32 The name is placed in the buffer pointed to by
33 .IR ifname .
34 The buffer must allow for the storage of at least
35 .B IF_NAMESIZE
36 bytes.
37 .SH RETURN VALUE
38 On success,
39 .BR if_nametoindex ()
40 returns the index number of the network interface;
41 on error, 0 is returned and
42 .I errno
43 is set to indicate the error.
44 .P
45 On success,
46 .BR if_indextoname ()
47 returns
48 .IR ifname ;
49 on error, NULL is returned and
50 .I errno
51 is set to indicate the error.
52 .SH ERRORS
53 .BR if_nametoindex ()
54 may fail and set
55 .I errno
56 if:
57 .TP
58 .B ENODEV
59 No interface found with given name.
60 .P
61 .BR if_indextoname ()
62 may fail and set
63 .I errno
64 if:
65 .TP
66 .B ENXIO
67 No interface found for the index.
68 .P
69 .BR if_nametoindex ()
70 and
71 .BR if_indextoname ()
72 may also fail for any of the errors specified for
73 .BR socket (2)
74 or
75 .BR ioctl (2).
76 .SH ATTRIBUTES
77 For an explanation of the terms used in this section, see
78 .BR attributes (7).
79 .TS
80 allbox;
81 lbx lb lb
82 l l l.
83 Interface Attribute Value
84 T{
85 .na
86 .nh
87 .BR if_nametoindex (),
88 .BR if_indextoname ()
89 T} Thread safety MT-Safe
90 .TE
91 .SH STANDARDS
92 POSIX.1-2008, RFC\ 3493.
93 .SH HISTORY
94 POSIX.1-2001.
95 BSDi.
96 .SH SEE ALSO
97 .BR getifaddrs (3),
98 .BR if_nameindex (3),
99 .BR ifconfig (8)