1 <!-- Copyright (C) 2003 Red Hat, Inc. -->
2 <!-- This material may be distributed only subject to the terms -->
3 <!-- and conditions set forth in the Open Publication License, v1.0 -->
4 <!-- or later (the latest version is presently available at -->
5 <!-- http://www.opencontent.org/openpub/). -->
6 <!-- Distribution of the work or derivative of the work in any -->
7 <!-- standard (paper) book form is prohibited unless prior -->
8 <!-- permission is obtained from the copyright holder. -->
12 >if_nametoindex</TITLE
13 ><meta name="MSSmartTagsPreventParsing" content="TRUE">
16 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
19 TITLE="eCos Reference Manual"
20 HREF="ecos-ref.html"><LINK
22 TITLE="TCP/IP Library Reference"
23 HREF="tcpip-library-reference.html"><LINK
26 HREF="net-common-tcpip-manpages-getservent.html"><LINK
29 HREF="net-common-tcpip-manpages-inet.html"></HEAD
40 SUMMARY="Header navigation table"
49 >eCos Reference Manual</TH
57 HREF="net-common-tcpip-manpages-getservent.html"
65 >Chapter 38. TCP/IP Library Reference</TD
71 HREF="net-common-tcpip-manpages-inet.html"
85 NAME="NET-COMMON-TCPIP-MANPAGES-IF-NAMETOINDEX">if_nametoindex</H1
94 >IF_NAMETOINDEX(3) System Library Functions Manual IF_NAMETOINDEX(3)
97 if_nametoindex, if_indextoname, if_nameindex, if_freenameindex - convert
98 interface index to name, and vice versa
101 #include <net/if.h>
104 if_nametoindex(const char *ifname);
107 if_indextoname(unsigned int ifindex, char *ifname);
109 struct if_nameindex *
113 if_freenameindex(struct if_nameindex *ptr);
116 These functions map interface indexes to interface names (such as
117 ``lo0''), and vice versa.
119 The if_nametoindex() function converts an interface name specified by the
120 ifname argument to an interface index (positive integer value). If the
121 specified interface does not exist, 0 will be returned.
123 if_indextoname() converts an interface index specified by the ifindex
124 argument to an interface name. The ifname argument must point to a
125 buffer of at least IF_NAMESIZE bytes into which the interface name corre-
126 sponding to the specified index is returned. (IF_NAMESIZE is also
127 defined in <net/if.h> and its value includes a terminating null byte at
128 the end of the interface name.) This pointer is also the return value of
129 the function. If there is no interface corresponding to the specified
130 index, NULL is returned.
132 if_nameindex() returns an array of if_nameindex structures.
133 if_nametoindex is also defined in <net/if.h>, and is as follows:
135 struct if_nameindex {
136 unsigned int if_index; /* 1, 2, ... */
137 char *if_name; /* null terminated name: "le0", ... */
140 The end of the array of structures is indicated by a structure with an
141 if_index of 0 and an if_name of NULL. The function returns a null
142 pointer on error. The memory used for this array of structures along
143 with the interface names pointed to by the if_name members is obtained
144 dynamically. This memory is freed by the if_freenameindex() function.
146 if_freenameindex() takes a pointer that was returned by if_nameindex() as
147 argument (ptr), and it reclaims the region allocated.
150 if_nametoindex() returns 0 on error, positive integer on success.
151 if_indextoname() and if_nameindex() return NULL on errors.
154 R. Gilligan, S. Thomson, J. Bound, and W. Stevens, ``Basic Socket Inter-
155 face Extensions for IPv6,'' RFC2553, March 1999.
158 These functions are defined in ``Basic Socket Interface Extensions for
172 SUMMARY="Footer navigation table"
183 HREF="net-common-tcpip-manpages-getservent.html"
201 HREF="net-common-tcpip-manpages-inet.html"
217 HREF="tcpip-library-reference.html"