1 .\" $NetBSD: if_indextoname.3,v 1.12 2010/03/22 19:30:54 joerg Exp $
2 .\" $KAME: if_indextoname.3,v 1.10 2000/11/24 08:13:51 itojun Exp $
3 .\" BSDI Id: if_indextoname.3,v 2.2 2000/04/17 22:38:05 dab Exp
5 .\" Copyright (c) 1997, 2000
6 .\" Berkeley Software Design, Inc. All rights reserved.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\" notice, this list of conditions and the following disclaimer.
14 .\" THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``AS IS'' AND
15 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 .\" ARE DISCLAIMED. IN NO EVENT SHALL Berkeley Software Design, Inc. BE LIABLE
18 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 .Nd provide mappings between interface names and indexes
38 .Fn if_nametoindex "const char *ifname"
40 .Fn if_indextoname "unsigned int ifindex" "char *ifname"
41 .Ft struct if_nameindex *
42 .Fn if_nameindex "void"
44 .Fn if_freenameindex "struct if_nameindex *ptr"
48 function maps the interface name specified in
50 to its corresponding index.
51 If the specified interface does not exist, it returns 0.
55 function maps the interface index specified in
57 to it corresponding name, which is copied into the
60 which must be of at least IFNAMSIZ bytes.
61 This pointer is also the return value of the function.
62 If there is no interface corresponding to the specified
63 index, NULL is returned.
67 function returns an array of
69 structures, one structure per interface, as
70 defined in the include file
74 structure contains at least the following entries:
76 unsigned int if_index; /* 1, 2, ... */
77 char *if_name; /* null terminated name: "le0", ... */
80 The end of the array of structures is indicated by a structure with an
85 A NULL pointer is returned upon an error.
89 function frees the dynamic memory that was
93 Upon successful completion,
95 returns the index number of the interface.
96 If the interface is not found, a value of 0 is returned and
100 A value of 0 is also returned if an error
101 occurs while retrieving the list of interfaces via
104 Upon successful completion,
108 If the interface is not found, a NULL pointer is returned and
112 A NULL pointer is also returned if an error
113 occurs while retrieving the list of interfaces via
118 returns a NULL pointer if an error
119 occurs while retrieving the list of interfaces via
121 or if sufficient memory cannot be allocated.
137 The implementation first appeared in