man-pages/man3/ether_aton.3.html
2021-03-31 01:06:50 +01:00

218 lines
4.9 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of ETHER_ATON</TITLE>
</HEAD><BODY>
<H1>ETHER_ATON</H1>
Section: Linux Programmer's Manual (3)<BR>Updated: 2017-09-15<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
ether_aton, ether_ntoa, ether_ntohost, ether_hostton, ether_line,
ether_ntoa_r, ether_aton_r - Ethernet address manipulation routines
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<PRE>
<B>#include &lt;<A HREF="file:///usr/include/netinet/ether.h">netinet/ether.h</A>&gt;</B>
<B>char *ether_ntoa(const struct ether_addr *</B><I>addr</I><B>);</B>
<B>struct ether_addr *ether_aton(const char *</B><I>asc</I><B>);</B>
<B>int ether_ntohost(char *</B><I>hostname</I><B>, const struct ether_addr *</B><I>addr</I><B>);</B>
<B>int ether_hostton(const char *</B><I>hostname</I><B>, struct ether_addr *</B><I>addr</I><B>);</B>
<B>int ether_line(const char *</B><I>line</I><B>, struct ether_addr *</B><I>addr</I><B>,</B>
<B> char *</B><I>hostname</I><B>);</B>
/* GNU extensions */
<BR>
<B>char *ether_ntoa_r(const struct ether_addr *</B><I>addr</I><B>, char *</B><I>buf</I><B>);</B>
<B>struct ether_addr *ether_aton_r(const char *</B><I>asc</I><B>,</B>
<B> struct ether_addr *</B><I>addr</I><B>);</B>
</PRE>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
<B>ether_aton</B>()
converts the 48-bit Ethernet host address
<I>asc</I>
from the standard hex-digits-and-colons notation into binary data in
network byte order and returns a pointer to it in a statically
allocated buffer, which subsequent calls will
overwrite.
<B>ether_aton</B>()
returns NULL if the address is invalid.
<P>
The
<B>ether_ntoa</B>()
function converts the Ethernet host address
<I>addr</I>
given in network byte order to a string in standard
hex-digits-and-colons notation, omitting leading zeros.
The string is returned in a statically allocated buffer,
which subsequent calls will overwrite.
<P>
The
<B>ether_ntohost</B>()
function maps an Ethernet address to the
corresponding hostname in
<I>/etc/ethers</I>
and returns nonzero if it cannot be found.
<P>
The
<B>ether_hostton</B>()
function maps a hostname to the
corresponding Ethernet address in
<I>/etc/ethers</I>
and returns nonzero if it cannot be found.
<P>
The
<B>ether_line</B>()
function parses a line in
<I>/etc/ethers</I>
format (ethernet address followed by whitespace followed by
hostname; '#' introduces a comment) and returns an address
and hostname pair, or nonzero if it cannot be parsed.
The buffer pointed to by
<I>hostname</I>
must be sufficiently long, for example, have the same length as
<I>line</I>.
<P>
The functions
<B>ether_ntoa_r</B>()
and
<B>ether_aton_r</B>()
are reentrant
thread-safe versions of
<B>ether_ntoa</B>()
and
<B>ether_aton</B>()
respectively, and do not use static buffers.
<P>
The structure
<I>ether_addr</I>
is defined in
<I>&lt;<A HREF="file:///usr/include/net/ethernet.h">net/ethernet.h</A>&gt;</I>
as:
<P>
struct ether_addr {
<BR>&nbsp;&nbsp;&nbsp;&nbsp;uint8_t&nbsp;ether_addr_octet[6];
}
<A NAME="lbAE">&nbsp;</A>
<H2>ATTRIBUTES</H2>
For an explanation of the terms used in this section, see
<B><A HREF="/cgi-bin/man/man2html?7+attributes">attributes</A></B>(7).
<TABLE BORDER>
<TR VALIGN=top><TD><B>Interface</B></TD><TD><B>Attribute</B></TD><TD><B>Value</B><BR></TD></TR>
<TR VALIGN=top><TD>
<B>ether_aton</B>(),
<B>ether_ntoa</B>()
</TD><TD>Thread safety</TD><TD>MT-Unsafe<BR></TD></TR>
<TR VALIGN=top><TD>
<B>ether_ntohost</B>(),
<B>ether_hostton</B>(),
<B>ether_line</B>(),
<B>ether_ntoa_r</B>(),
<B>ether_aton_r</B>()
</TD><TD>Thread safety</TD><TD>MT-Safe<BR></TD></TR>
</TABLE>
<A NAME="lbAF">&nbsp;</A>
<H2>CONFORMING TO</H2>
4.3BSD, SunOS.
<A NAME="lbAG">&nbsp;</A>
<H2>BUGS</H2>
In glibc 2.2.5 and earlier, the implementation of
<B>ether_line</B>()
is broken.
<A NAME="lbAH">&nbsp;</A>
<H2>SEE ALSO</H2>
<B><A HREF="/cgi-bin/man/man2html?5+ethers">ethers</A></B>(5)
<A NAME="lbAI">&nbsp;</A>
<H2>COLOPHON</H2>
This page is part of release 5.05 of the Linux
<I>man-pages</I>
project.
A description of the project,
information about reporting bugs,
and the latest version of this page,
can be found at
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="1"><A HREF="#lbAB">NAME</A><DD>
<DT id="2"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="3"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="4"><A HREF="#lbAE">ATTRIBUTES</A><DD>
<DT id="5"><A HREF="#lbAF">CONFORMING TO</A><DD>
<DT id="6"><A HREF="#lbAG">BUGS</A><DD>
<DT id="7"><A HREF="#lbAH">SEE ALSO</A><DD>
<DT id="8"><A HREF="#lbAI">COLOPHON</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:39 GMT, March 31, 2021
</BODY>
</HTML>