summaryrefslogtreecommitdiffstats
path: root/lib/libc/net/if_indextoname.3
diff options
context:
space:
mode:
authorume <ume@FreeBSD.org>2002-07-15 19:58:56 +0000
committerume <ume@FreeBSD.org>2002-07-15 19:58:56 +0000
commitc95ccb75f4f6064deccbec4faf05791efe52dda1 (patch)
tree6f5a9f54fb03785accc51ff6f78df3c44ec41a45 /lib/libc/net/if_indextoname.3
parentc6226499e948e58cd71ccdefc315194a7afe80b4 (diff)
downloadFreeBSD-src-c95ccb75f4f6064deccbec4faf05791efe52dda1.zip
FreeBSD-src-c95ccb75f4f6064deccbec4faf05791efe52dda1.tar.gz
Use BSDi derived if_nametoindex(), if_indextoname(), if_nameindex()
and if_freenameindex(). Obtained from: KAME MFC after: 2 weeks
Diffstat (limited to 'lib/libc/net/if_indextoname.3')
-rw-r--r--lib/libc/net/if_indextoname.3175
1 files changed, 84 insertions, 91 deletions
diff --git a/lib/libc/net/if_indextoname.3 b/lib/libc/net/if_indextoname.3
index 0cc039c..795d5693 100644
--- a/lib/libc/net/if_indextoname.3
+++ b/lib/libc/net/if_indextoname.3
@@ -1,26 +1,19 @@
-.\" Copyright (c) 1983, 1991, 1993
-.\" The Regents of the University of California. All rights reserved.
+.\" $KAME: if_indextoname.3,v 1.10 2000/11/24 08:13:51 itojun Exp $
+.\" BSDI Id: if_indextoname.3,v 2.2 2000/04/17 22:38:05 dab Exp
+.\"
+.\" Copyright (c) 1997, 2000
+.\" Berkeley Software Design, Inc. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL Berkeley Software Design, Inc. BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
@@ -29,10 +22,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" From: @(#)rcmd.3 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
-.Dd May 21, 1998
+.Dd "July 11, 1997"
.Dt IF_NAMETOINDEX 3
.Os
.Sh NAME
@@ -40,103 +32,104 @@
.Nm if_indextoname ,
.Nm if_nameindex ,
.Nm if_freenameindex
-.Nd convert interface index to name, and vice versa
-.Sh LIBRARY
-.Lb libc
+.Nd provide mappings between interface names and indexes
.Sh SYNOPSIS
-.In sys/types.h
-.In sys/socket.h
.In net/if.h
-.Ft "unsigned int"
+.Ft unsigned int
.Fn if_nametoindex "const char *ifname"
-.Ft "char *"
+.Ft char *
.Fn if_indextoname "unsigned int ifindex" "char *ifname"
-.Ft "struct if_nameindex *"
+.Ft struct if_nameindex *
.Fn if_nameindex "void"
-.Ft "void"
+.Ft void
.Fn if_freenameindex "struct if_nameindex *ptr"
.Sh DESCRIPTION
-The functions map interface index to readable interface name
-(such as
-.Dq Li lo0 ) ,
-and vice versa.
-.Pp
+The
.Fn if_nametoindex
-converts readable interface name to interface index
-.Pp positive integer value .
-If the specified interface does not exist, 0 will be returned.
+function maps the interface name specified in
+.Ar ifname
+to its corresponding index.
+If the specified interface does not exist, it returns 0.
.Pp
-.Fn if_indextoname
-converts interface index to readable interface name.
The
-.Fa ifname
-argument must point to a buffer of at least
-.Dv IF_NAMESIZE
-bytes into which the interface name corresponding to the specified index is
-returned.
-.Dv ( IF_NAMESIZE
-is also defined in
-.Aq Pa net/if.h
-and its value includes a terminating null byte at the end of the
-interface name.)
+.Fn if_indextoname
+function maps the interface index specified in
+.Ar ifindex
+to it corresponding name, which is copied into the
+buffer pointed to by
+.Ar ifname ,
+which must be of at least IFNAMSIZ bytes.
This pointer is also the return value of the function.
-If there is no interface corresponding to the specified index,
-.Dv NULL
-is returned.
+If there is no interface corresponding to the specified
+index, NULL is returned.
.Pp
+The
.Fn if_nameindex
-returns an array of
-.Fa if_nameindex
-structures.
-.Fa if_nametoindex
-is also defined in
-.Aq Pa net/if.h ,
-and is as follows:
-.Bd -literal -offset
-struct if_nameindex {
+function returns an array of
+.Nm if_nameindex
+structures, one structure per interface, as
+defined in the include file
+.Aq Pa net/if.h .
+The
+.Nm if_nameindex
+structure contains at least the following entries:
+.Bd -literal
unsigned int if_index; /* 1, 2, ... */
char *if_name; /* null terminated name: "le0", ... */
-};
.Ed
.Pp
-The end of the array of structures is indicated by a structure with
-an
-.Fa if_index
+The end of the array of structures is indicated by a structure with an
+.Nm if_index
of 0 and an
-.Fa if_name
-of
-.Dv NULL .
-The function returns a
-.Dv NULL
-pointer upon an error.
-The memory used for this array of structures along with the interface
-names pointed to by the
-.Fa if_name
-members is obtained dynamically.
-This memory is freed by the
-.Fn if_freenameindex
-function.
+.Nm if_name
+of NULL.
+A NULL pointer is returned upon an error.
.Pp
+The
.Fn if_freenameindex
-takes a pointer that was returned by
-.Fn if_nameindex
-as argument
-.Pq Fa ptr ,
-and it reclaims the region allocated.
-.Sh DIAGNOSTICS
+function frees the dynamic memory that was
+allocated by
+.Fn if_nameindex .
+.Sh RETURN VALUES
+Upon successful completion,
.Fn if_nametoindex
-returns 0 on error, positive integer on success.
+returns the index number of the interface.
+If the interface is not found, a value of 0 is returned and
+.Va errno
+is set to
+.Er ENXIO .
+A value of 0 is also returned if an error
+occurs while retrieving the list of interfaces via
+.Xr getifaddrs 3 .
+.Pp
+Upon successful completion,
.Fn if_indextoname
-and
+returns
+.Ar ifname .
+If the interface is not found, a NULL pointer is returned and
+.Va errno
+is set to
+.Er ENXIO .
+A NULL pointer is also returned if an error
+occurs while retrieving the list of interfaces via
+.Xr getifaddrs 3 .
+.Pp
+The
.Fn if_nameindex
-return
-.Dv NULL
-on errors.
+returns a NULL pointer if an error
+occurs while retrieving the list of interfaces via
+.Xr getifaddrs 3 ,
+or if sufficient memory cannot be allocated.
.Sh SEE ALSO
-R. Gilligan, S. Thomson, J. Bound, and W. Stevens,
-``Basic Socket Interface Extensions for IPv6,'' RFC2553, March 1999.
-.Sh HISTORY
-The implementation first appeared in WIDE Hydrangea IPv6 protocol stack kit.
+.Xr getifaddrs 3 ,
+.Xr networking 4
.Sh STANDARDS
-These functions are defined in ``Basic Socket Interface Extensions for IPv6''
-(RFC2533).
+The
+.Fn if_nametoindex ,
+.Fn if_indextoname ,
+.Fn if_nameindex ,
+and
+.Fn if_freenameindex
+functions conform to RFC 2553.
+.Sh HISTORY
+The implementation first appeared in BSDI BSD/OS.
OpenPOWER on IntegriCloud