]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/ether_aton.3
intro.1, _exit.2, access.2, alarm.2, alloc_hugepages.2, arch_prctl.2, bind.2, chdir...
[thirdparty/man-pages.git] / man3 / ether_aton.3
CommitLineData
fea681da
MK
1.\" Copyright 2002 Ian Redfern (redferni@logica.com)
2.\"
4b72fb64 3.\" %%%LICENSE_START(verbatim)
fea681da
MK
4.\" Permission is granted to make and distribute verbatim copies of this
5.\" manual provided the copyright notice and this permission notice are
6.\" preserved on all copies.
7.\"
8.\" Permission is granted to copy and distribute modified versions of this
9.\" manual under the conditions for verbatim copying, provided that the
10.\" entire resulting derived work is distributed under the terms of a
11.\" permission notice identical to this one.
c13182ef 12.\"
fea681da
MK
13.\" Since the Linux kernel and libraries are constantly changing, this
14.\" manual page may be incorrect or out-of-date. The author(s) assume no
15.\" responsibility for errors or omissions, or for damages resulting from
16.\" the use of the information contained herein. The author(s) may not
17.\" have taken the same level of care in the production of this manual,
18.\" which is licensed free of charge, as they might when working
19.\" professionally.
c13182ef 20.\"
fea681da
MK
21.\" Formatted or processed versions of this manual, if unaccompanied by
22.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 23.\" %%%LICENSE_END
fea681da
MK
24.\"
25.\" References consulted:
26.\" Linux libc source code
27.\" FreeBSD 4.4 man pages
28.\"
29.\" Minor additions, aeb, 2002-07-20
30.\"
69962544 31.TH ETHER_ATON 3 2002-07-20 "GNU" "Linux Programmer's Manual"
fea681da 32.SH NAME
c13182ef 33ether_aton, ether_ntoa, ether_ntohost, ether_hostton, ether_line,
fea681da
MK
34ether_ntoa_r, ether_aton_r \- Ethernet address manipulation routines
35.SH SYNOPSIS
36.nf
37.B #include <netinet/ether.h>
38.sp
b9f02710 39.BI "char *ether_ntoa(const struct ether_addr *" addr );
fea681da 40.sp
b9f02710 41.BI "struct ether_addr *ether_aton(const char *" asc );
fea681da 42.sp
b9f02710 43.BI "int ether_ntohost(char *" hostname ", const struct ether_addr *" addr );
fea681da 44.sp
b9f02710 45.BI "int ether_hostton(const char *" hostname ", struct ether_addr *" addr );
fea681da 46.sp
b9f02710
MK
47.BI "int ether_line(const char *" line ", struct ether_addr *" addr ,
48.BI " char *" hostname );
fea681da
MK
49.sp
50/* GNU extensions */
51.br
b9f02710 52.BI "char *ether_ntoa_r(const struct ether_addr *" addr ", char *" buf );
fea681da 53.sp
c13182ef 54.BI "struct ether_addr *ether_aton_r(const char *" asc ,
b9f02710 55.BI " struct ether_addr *" addr );
fea681da
MK
56.fi
57.SH DESCRIPTION
60a90ecd
MK
58.BR ether_aton ()
59converts the 48-bit Ethernet host address \fIasc\fP
fea681da
MK
60from the standard hex-digits-and-colons notation into binary data in
61network byte order and returns a pointer to it in a statically
62allocated buffer, which subsequent calls will
60a90ecd
MK
63overwrite.
64.BR ether_aton ()
65returns NULL if the address is invalid.
fea681da 66.PP
60a90ecd
MK
67The
68.BR ether_ntoa ()
69function converts the Ethernet host address
fea681da 70\fIaddr\fP given in network byte order to a string in standard
7b01461a 71hex-digits-and-colons notation, omitting leading zeros.
fea681da
MK
72The string is returned in a statically allocated buffer,
73which subsequent calls will overwrite.
74.PP
60a90ecd
MK
75The
76.BR ether_ntohost ()
77function maps an Ethernet address to the
c13182ef 78corresponding hostname in
836f07c1 79.I /etc/ethers
c7094399 80and returns nonzero if it cannot be found.
fea681da 81.PP
60a90ecd
MK
82The
83.BR ether_hostton ()
84function maps a hostname to the
fea681da 85corresponding Ethernet address in
836f07c1 86.I /etc/ethers
c7094399 87and returns nonzero if it cannot be found.
fea681da 88.PP
60a90ecd
MK
89The
90.BR ether_line ()
91function parses a line in
836f07c1 92.I /etc/ethers
fea681da 93format (ethernet address followed by whitespace followed by
f81fb444 94hostname; \(aq#\(aq introduces a comment) and returns an address
c7094399 95and hostname pair, or nonzero if it cannot be parsed.
fea681da
MK
96The buffer pointed to by
97.I hostname
75b94dc3 98must be sufficiently long, for example, have the same length as
fea681da
MK
99.IR line .
100.PP
60a90ecd
MK
101The functions
102.BR ether_ntoa_r ()
103and
104.BR ether_aton_r ()
da27f178 105are reentrant
79761fe5 106thread-safe versions of
60a90ecd
MK
107.BR ether_ntoa ()
108and
109.BR ether_aton ()
fea681da
MK
110respectively, and do not use static buffers.
111.PP
e859a67a 112The structure \fIether_addr\fP is defined in
eb12ffbf
MK
113.I <net/ethernet.h>
114as:
fea681da 115.sp
a08ea57c 116.in +4n
fea681da 117.nf
fea681da 118struct ether_addr {
aeb4b1fc 119 uint8_t ether_addr_octet[6];
fea681da 120}
fea681da 121.fi
a08ea57c 122.in
47297adb 123.SH CONFORMING TO
44a2c328 1244.3BSD, SunOS.
2b2581ee 125.SH BUGS
d9a10d9d
MK
126The glibc 2.2.5 implementation of
127.BR ether_line ()
128is broken.
47297adb 129.SH SEE ALSO
fea681da 130.BR ethers (5)