]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/ether_aton.3
man*/: ffix (un-bracket tables)
[thirdparty/man-pages.git] / man3 / ether_aton.3
CommitLineData
a1eaacb1 1'\" t
fea681da
MK
2.\" Copyright 2002 Ian Redfern (redferni@logica.com)
3.\"
5fbde956 4.\" SPDX-License-Identifier: Linux-man-pages-copyleft
fea681da
MK
5.\"
6.\" References consulted:
7.\" Linux libc source code
8.\" FreeBSD 4.4 man pages
9.\"
f9293d98 10.\" Minor additions, aeb, 2013-06-21
fea681da 11.\"
4c1c5274 12.TH ether_aton 3 (date) "Linux man-pages (unreleased)"
fea681da 13.SH NAME
c13182ef 14ether_aton, ether_ntoa, ether_ntohost, ether_hostton, ether_line,
fea681da 15ether_ntoa_r, ether_aton_r \- Ethernet address manipulation routines
afa8db94
AC
16.SH LIBRARY
17Standard C library
18.RI ( libc ", " \-lc )
fea681da
MK
19.SH SYNOPSIS
20.nf
21.B #include <netinet/ether.h>
68e4db0a 22.PP
b9f02710 23.BI "char *ether_ntoa(const struct ether_addr *" addr );
b9f02710 24.BI "struct ether_addr *ether_aton(const char *" asc );
68e4db0a 25.PP
b9f02710 26.BI "int ether_ntohost(char *" hostname ", const struct ether_addr *" addr );
b9f02710 27.BI "int ether_hostton(const char *" hostname ", struct ether_addr *" addr );
68e4db0a 28.PP
b9f02710
MK
29.BI "int ether_line(const char *" line ", struct ether_addr *" addr ,
30.BI " char *" hostname );
68e4db0a 31.PP
fea681da 32/* GNU extensions */
b9f02710 33.BI "char *ether_ntoa_r(const struct ether_addr *" addr ", char *" buf );
68e4db0a 34.PP
c13182ef 35.BI "struct ether_addr *ether_aton_r(const char *" asc ,
b9f02710 36.BI " struct ether_addr *" addr );
fea681da
MK
37.fi
38.SH DESCRIPTION
60a90ecd 39.BR ether_aton ()
c6fa0841
MK
40converts the 48-bit Ethernet host address
41.I asc
fea681da
MK
42from the standard hex-digits-and-colons notation into binary data in
43network byte order and returns a pointer to it in a statically
44allocated buffer, which subsequent calls will
60a90ecd
MK
45overwrite.
46.BR ether_aton ()
47returns NULL if the address is invalid.
fea681da 48.PP
60a90ecd
MK
49The
50.BR ether_ntoa ()
51function converts the Ethernet host address
c6fa0841
MK
52.I addr
53given in network byte order to a string in standard
7b01461a 54hex-digits-and-colons notation, omitting leading zeros.
fea681da
MK
55The string is returned in a statically allocated buffer,
56which subsequent calls will overwrite.
57.PP
60a90ecd
MK
58The
59.BR ether_ntohost ()
60function maps an Ethernet address to the
c13182ef 61corresponding hostname in
836f07c1 62.I /etc/ethers
c7094399 63and returns nonzero if it cannot be found.
fea681da 64.PP
60a90ecd
MK
65The
66.BR ether_hostton ()
67function maps a hostname to the
fea681da 68corresponding Ethernet address in
836f07c1 69.I /etc/ethers
c7094399 70and returns nonzero if it cannot be found.
fea681da 71.PP
60a90ecd
MK
72The
73.BR ether_line ()
74function parses a line in
836f07c1 75.I /etc/ethers
fea681da 76format (ethernet address followed by whitespace followed by
b957f81f 77hostname; \[aq]#\[aq] introduces a comment) and returns an address
c7094399 78and hostname pair, or nonzero if it cannot be parsed.
fea681da
MK
79The buffer pointed to by
80.I hostname
75b94dc3 81must be sufficiently long, for example, have the same length as
fea681da
MK
82.IR line .
83.PP
60a90ecd
MK
84The functions
85.BR ether_ntoa_r ()
86and
87.BR ether_aton_r ()
da27f178 88are reentrant
79761fe5 89thread-safe versions of
60a90ecd
MK
90.BR ether_ntoa ()
91and
92.BR ether_aton ()
fea681da
MK
93respectively, and do not use static buffers.
94.PP
c6fa0841
MK
95The structure
96.I ether_addr
97is defined in
eb12ffbf
MK
98.I <net/ethernet.h>
99as:
51f5698d 100.PP
a08ea57c 101.in +4n
b8302363 102.EX
fea681da 103struct ether_addr {
aeb4b1fc 104 uint8_t ether_addr_octet[6];
fea681da 105}
b8302363 106.EE
a08ea57c 107.in
6a92c34c 108.SH ATTRIBUTES
053cd430
MK
109For an explanation of the terms used in this section, see
110.BR attributes (7).
053cd430
MK
111.TS
112allbox;
c466875e 113lbx lb lb
053cd430
MK
114l l l.
115Interface Attribute Value
116T{
9e54434e
BR
117.na
118.nh
053cd430 119.BR ether_aton (),
6a92c34c 120.BR ether_ntoa ()
053cd430
MK
121T} Thread safety MT-Unsafe
122T{
9e54434e
BR
123.na
124.nh
6a92c34c
PH
125.BR ether_ntohost (),
126.BR ether_hostton (),
127.BR ether_line (),
053cd430 128.BR ether_ntoa_r (),
6a92c34c 129.BR ether_aton_r ()
053cd430
MK
130T} Thread safety MT-Safe
131.TE
c466875e 132.sp 1
3113c7f3 133.SH STANDARDS
4131356c
AC
134None.
135.SH HISTORY
44a2c328 1364.3BSD, SunOS.
2b2581ee 137.SH BUGS
053cd430 138In glibc 2.2.5 and earlier, the implementation of
d9a10d9d 139.BR ether_line ()
053cd430
MK
140.\" The fix was presumably commit c0a0f9a32c8baa6ab93d00eb42d92c02e9e146d7
141.\" which was in glibc 2.3
d9a10d9d 142is broken.
47297adb 143.SH SEE ALSO
fea681da 144.BR ethers (5)