<!-- Copyright (C) 2003 Red Hat, Inc. -->
|
<!-- Copyright (C) 2003 Red Hat, Inc. -->
|
<!-- This material may be distributed only subject to the terms -->
|
<!-- This material may be distributed only subject to the terms -->
|
<!-- and conditions set forth in the Open Publication License, v1.0 -->
|
<!-- and conditions set forth in the Open Publication License, v1.0 -->
|
<!-- or later (the latest version is presently available at -->
|
<!-- or later (the latest version is presently available at -->
|
<!-- http://www.opencontent.org/openpub/). -->
|
<!-- http://www.opencontent.org/openpub/). -->
|
<!-- Distribution of the work or derivative of the work in any -->
|
<!-- Distribution of the work or derivative of the work in any -->
|
<!-- standard (paper) book form is prohibited unless prior -->
|
<!-- standard (paper) book form is prohibited unless prior -->
|
<!-- permission is obtained from the copyright holder. -->
|
<!-- permission is obtained from the copyright holder. -->
|
<HTML
|
<HTML
|
><HEAD
|
><HEAD
|
><TITLE
|
><TITLE
|
>if_nametoindex</TITLE
|
>if_nametoindex</TITLE
|
><meta name="MSSmartTagsPreventParsing" content="TRUE">
|
><meta name="MSSmartTagsPreventParsing" content="TRUE">
|
<META
|
<META
|
NAME="GENERATOR"
|
NAME="GENERATOR"
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
|
"><LINK
|
"><LINK
|
REL="HOME"
|
REL="HOME"
|
TITLE="eCos Reference Manual"
|
TITLE="eCos Reference Manual"
|
HREF="ecos-ref.html"><LINK
|
HREF="ecos-ref.html"><LINK
|
REL="UP"
|
REL="UP"
|
TITLE="TCP/IP Library Reference"
|
TITLE="TCP/IP Library Reference"
|
HREF="tcpip-library-reference.html"><LINK
|
HREF="tcpip-library-reference.html"><LINK
|
REL="PREVIOUS"
|
REL="PREVIOUS"
|
TITLE="getservent"
|
TITLE="getservent"
|
HREF="net-common-tcpip-manpages-getservent.html"><LINK
|
HREF="net-common-tcpip-manpages-getservent.html"><LINK
|
REL="NEXT"
|
REL="NEXT"
|
TITLE="inet"
|
TITLE="inet"
|
HREF="net-common-tcpip-manpages-inet.html"></HEAD
|
HREF="net-common-tcpip-manpages-inet.html"></HEAD
|
><BODY
|
><BODY
|
CLASS="SECT1"
|
CLASS="SECT1"
|
BGCOLOR="#FFFFFF"
|
BGCOLOR="#FFFFFF"
|
TEXT="#000000"
|
TEXT="#000000"
|
LINK="#0000FF"
|
LINK="#0000FF"
|
VLINK="#840084"
|
VLINK="#840084"
|
ALINK="#0000FF"
|
ALINK="#0000FF"
|
><DIV
|
><DIV
|
CLASS="NAVHEADER"
|
CLASS="NAVHEADER"
|
><TABLE
|
><TABLE
|
SUMMARY="Header navigation table"
|
SUMMARY="Header navigation table"
|
WIDTH="100%"
|
WIDTH="100%"
|
BORDER="0"
|
BORDER="0"
|
CELLPADDING="0"
|
CELLPADDING="0"
|
CELLSPACING="0"
|
CELLSPACING="0"
|
><TR
|
><TR
|
><TH
|
><TH
|
COLSPAN="3"
|
COLSPAN="3"
|
ALIGN="center"
|
ALIGN="center"
|
>eCos Reference Manual</TH
|
>eCos Reference Manual</TH
|
></TR
|
></TR
|
><TR
|
><TR
|
><TD
|
><TD
|
WIDTH="10%"
|
WIDTH="10%"
|
ALIGN="left"
|
ALIGN="left"
|
VALIGN="bottom"
|
VALIGN="bottom"
|
><A
|
><A
|
HREF="net-common-tcpip-manpages-getservent.html"
|
HREF="net-common-tcpip-manpages-getservent.html"
|
ACCESSKEY="P"
|
ACCESSKEY="P"
|
>Prev</A
|
>Prev</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="80%"
|
WIDTH="80%"
|
ALIGN="center"
|
ALIGN="center"
|
VALIGN="bottom"
|
VALIGN="bottom"
|
>Chapter 38. TCP/IP Library Reference</TD
|
>Chapter 38. TCP/IP Library Reference</TD
|
><TD
|
><TD
|
WIDTH="10%"
|
WIDTH="10%"
|
ALIGN="right"
|
ALIGN="right"
|
VALIGN="bottom"
|
VALIGN="bottom"
|
><A
|
><A
|
HREF="net-common-tcpip-manpages-inet.html"
|
HREF="net-common-tcpip-manpages-inet.html"
|
ACCESSKEY="N"
|
ACCESSKEY="N"
|
>Next</A
|
>Next</A
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
><HR
|
><HR
|
ALIGN="LEFT"
|
ALIGN="LEFT"
|
WIDTH="100%"></DIV
|
WIDTH="100%"></DIV
|
><DIV
|
><DIV
|
CLASS="SECT1"
|
CLASS="SECT1"
|
><H1
|
><H1
|
CLASS="SECT1"
|
CLASS="SECT1"
|
><A
|
><A
|
NAME="NET-COMMON-TCPIP-MANPAGES-IF-NAMETOINDEX">if_nametoindex</H1
|
NAME="NET-COMMON-TCPIP-MANPAGES-IF-NAMETOINDEX">if_nametoindex</H1
|
><TABLE
|
><TABLE
|
BORDER="5"
|
BORDER="5"
|
BGCOLOR="#E0E0F0"
|
BGCOLOR="#E0E0F0"
|
WIDTH="70%"
|
WIDTH="70%"
|
><TR
|
><TR
|
><TD
|
><TD
|
><PRE
|
><PRE
|
CLASS="SCREEN"
|
CLASS="SCREEN"
|
>IF_NAMETOINDEX(3) System Library Functions Manual IF_NAMETOINDEX(3)
|
>IF_NAMETOINDEX(3) System Library Functions Manual IF_NAMETOINDEX(3)
|
|
|
NAME
|
NAME
|
if_nametoindex, if_indextoname, if_nameindex, if_freenameindex - convert
|
if_nametoindex, if_indextoname, if_nameindex, if_freenameindex - convert
|
interface index to name, and vice versa
|
interface index to name, and vice versa
|
|
|
SYNOPSIS
|
SYNOPSIS
|
#include <net/if.h>
|
#include <net/if.h>
|
|
|
unsigned int
|
unsigned int
|
if_nametoindex(const char *ifname);
|
if_nametoindex(const char *ifname);
|
|
|
char *
|
char *
|
if_indextoname(unsigned int ifindex, char *ifname);
|
if_indextoname(unsigned int ifindex, char *ifname);
|
|
|
struct if_nameindex *
|
struct if_nameindex *
|
if_nameindex(void);
|
if_nameindex(void);
|
|
|
void
|
void
|
if_freenameindex(struct if_nameindex *ptr);
|
if_freenameindex(struct if_nameindex *ptr);
|
|
|
DESCRIPTION
|
DESCRIPTION
|
These functions map interface indexes to interface names (such as
|
These functions map interface indexes to interface names (such as
|
``lo0''), and vice versa.
|
``lo0''), and vice versa.
|
|
|
The if_nametoindex() function converts an interface name specified by the
|
The if_nametoindex() function converts an interface name specified by the
|
ifname argument to an interface index (positive integer value). If the
|
ifname argument to an interface index (positive integer value). If the
|
specified interface does not exist, 0 will be returned.
|
specified interface does not exist, 0 will be returned.
|
|
|
if_indextoname() converts an interface index specified by the ifindex
|
if_indextoname() converts an interface index specified by the ifindex
|
argument to an interface name. The ifname argument must point to a
|
argument to an interface name. The ifname argument must point to a
|
buffer of at least IF_NAMESIZE bytes into which the interface name corre-
|
buffer of at least IF_NAMESIZE bytes into which the interface name corre-
|
sponding to the specified index is returned. (IF_NAMESIZE is also
|
sponding to the specified index is returned. (IF_NAMESIZE is also
|
defined in <net/if.h> and its value includes a terminating null byte at
|
defined in <net/if.h> and its value includes a terminating null byte at
|
the end of the interface name.) This pointer is also the return value of
|
the end of the interface name.) This pointer is also the return value of
|
the function. If there is no interface corresponding to the specified
|
the function. If there is no interface corresponding to the specified
|
index, NULL is returned.
|
index, NULL is returned.
|
|
|
if_nameindex() returns an array of if_nameindex structures.
|
if_nameindex() returns an array of if_nameindex structures.
|
if_nametoindex is also defined in <net/if.h>, and is as follows:
|
if_nametoindex is also defined in <net/if.h>, and is as follows:
|
|
|
struct if_nameindex {
|
struct if_nameindex {
|
unsigned int if_index; /* 1, 2, ... */
|
unsigned int if_index; /* 1, 2, ... */
|
char *if_name; /* null terminated name: "le0", ... */
|
char *if_name; /* null terminated name: "le0", ... */
|
};
|
};
|
|
|
The end of the array of structures is indicated by a structure with an
|
The end of the array of structures is indicated by a structure with an
|
if_index of 0 and an if_name of NULL. The function returns a null
|
if_index of 0 and an if_name of NULL. The function returns a null
|
pointer on error. The memory used for this array of structures along
|
pointer on error. The memory used for this array of structures along
|
with the interface names pointed to by the if_name members is obtained
|
with the interface names pointed to by the if_name members is obtained
|
dynamically. This memory is freed by the if_freenameindex() function.
|
dynamically. This memory is freed by the if_freenameindex() function.
|
|
|
if_freenameindex() takes a pointer that was returned by if_nameindex() as
|
if_freenameindex() takes a pointer that was returned by if_nameindex() as
|
argument (ptr), and it reclaims the region allocated.
|
argument (ptr), and it reclaims the region allocated.
|
|
|
DIAGNOSTICS
|
DIAGNOSTICS
|
if_nametoindex() returns 0 on error, positive integer on success.
|
if_nametoindex() returns 0 on error, positive integer on success.
|
if_indextoname() and if_nameindex() return NULL on errors.
|
if_indextoname() and if_nameindex() return NULL on errors.
|
|
|
SEE ALSO
|
SEE ALSO
|
R. Gilligan, S. Thomson, J. Bound, and W. Stevens, ``Basic Socket Inter-
|
R. Gilligan, S. Thomson, J. Bound, and W. Stevens, ``Basic Socket Inter-
|
face Extensions for IPv6,'' RFC2553, March 1999.
|
face Extensions for IPv6,'' RFC2553, March 1999.
|
|
|
STANDARDS
|
STANDARDS
|
These functions are defined in ``Basic Socket Interface Extensions for
|
These functions are defined in ``Basic Socket Interface Extensions for
|
IPv6'' (RFC2533).
|
IPv6'' (RFC2533).
|
|
|
BSD May 21, 1998 BSD
|
BSD May 21, 1998 BSD
|
</PRE
|
</PRE
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
></DIV
|
></DIV
|
><DIV
|
><DIV
|
CLASS="NAVFOOTER"
|
CLASS="NAVFOOTER"
|
><HR
|
><HR
|
ALIGN="LEFT"
|
ALIGN="LEFT"
|
WIDTH="100%"><TABLE
|
WIDTH="100%"><TABLE
|
SUMMARY="Footer navigation table"
|
SUMMARY="Footer navigation table"
|
WIDTH="100%"
|
WIDTH="100%"
|
BORDER="0"
|
BORDER="0"
|
CELLPADDING="0"
|
CELLPADDING="0"
|
CELLSPACING="0"
|
CELLSPACING="0"
|
><TR
|
><TR
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="left"
|
ALIGN="left"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="net-common-tcpip-manpages-getservent.html"
|
HREF="net-common-tcpip-manpages-getservent.html"
|
ACCESSKEY="P"
|
ACCESSKEY="P"
|
>Prev</A
|
>Prev</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="34%"
|
WIDTH="34%"
|
ALIGN="center"
|
ALIGN="center"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="ecos-ref.html"
|
HREF="ecos-ref.html"
|
ACCESSKEY="H"
|
ACCESSKEY="H"
|
>Home</A
|
>Home</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="right"
|
ALIGN="right"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="net-common-tcpip-manpages-inet.html"
|
HREF="net-common-tcpip-manpages-inet.html"
|
ACCESSKEY="N"
|
ACCESSKEY="N"
|
>Next</A
|
>Next</A
|
></TD
|
></TD
|
></TR
|
></TR
|
><TR
|
><TR
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="left"
|
ALIGN="left"
|
VALIGN="top"
|
VALIGN="top"
|
>getservent</TD
|
>getservent</TD
|
><TD
|
><TD
|
WIDTH="34%"
|
WIDTH="34%"
|
ALIGN="center"
|
ALIGN="center"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="tcpip-library-reference.html"
|
HREF="tcpip-library-reference.html"
|
ACCESSKEY="U"
|
ACCESSKEY="U"
|
>Up</A
|
>Up</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="right"
|
ALIGN="right"
|
VALIGN="top"
|
VALIGN="top"
|
>inet</TD
|
>inet</TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
></DIV
|
></DIV
|
></BODY
|
></BODY
|
></HTML
|
></HTML
|
|
|