1 .\" $KAME: if_indextoname.3,v 1.10 2000/11/24 08:13:51 itojun Exp $
2 .\" BSDI Id: if_indextoname.3,v 2.2 2000/04/17 22:38:05 dab Exp
4 .\" Copyright (c) 1997, 2000
5 .\" Berkeley Software Design, Inc. All rights reserved.
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\" notice, this list of conditions and the following disclaimer.
13 .\" THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED. IN NO EVENT SHALL Berkeley Software Design, Inc. BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 .\" $FreeBSD: src/lib/libc/net/if_indextoname.3,v 1.11 2005/11/23 10:49:07 ru Exp $
35 .Nd provide mappings between interface names and indexes
41 .Fn if_nametoindex "const char *ifname"
43 .Fn if_indextoname "unsigned int ifindex" "char *ifname"
44 .Ft "struct if_nameindex *"
45 .Fn if_nameindex "void"
47 .Fn if_freenameindex "struct if_nameindex *ptr"
51 function maps the interface name specified in
53 to its corresponding index.
54 If the specified interface does not exist, it returns 0.
58 function maps the interface index specified in
60 to it corresponding name, which is copied into the
63 which must be of at least
66 This pointer is also the return value of the function.
67 If there is no interface corresponding to the specified
74 function returns an array of
76 structures, one structure per interface, as
77 defined in the include file
81 structure contains at least the following entries:
83 unsigned int if_index; /* 1, 2, ... */
84 char *if_name; /* null terminated name: "le0", ... */
87 The end of the array of structures is indicated by a structure with an
95 pointer is returned upon an error.
99 function frees the dynamic memory that was
103 Upon successful completion,
105 returns the index number of the interface.
106 If the interface is not found, a value of 0 is returned and
110 A value of 0 is also returned if an error
111 occurs while retrieving the list of interfaces via
114 Upon successful completion,
118 If the interface is not found, a
120 pointer is returned and
126 pointer is also returned if an error
127 occurs while retrieving the list of interfaces via
135 occurs while retrieving the list of interfaces via
137 or if sufficient memory cannot be allocated.
151 The implementation first appeared in BSDi