wait.2: Add ESRCH for when pid == INT_MIN
[man-pages.git] / man3 / ether_aton.3
bloba2b5aca2a1ca4b34e84e820b3884993e2b991f3c
1 .\" Copyright 2002 Ian Redfern (redferni@logica.com)
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
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.
12 .\"
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.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\" References consulted:
26 .\"     Linux libc source code
27 .\"     FreeBSD 4.4 man pages
28 .\"
29 .\" Minor additions, aeb, 2013-06-21
30 .\"
31 .TH ETHER_ATON 3  2021-03-22 "GNU" "Linux Programmer's Manual"
32 .SH NAME
33 ether_aton, ether_ntoa, ether_ntohost, ether_hostton, ether_line,
34 ether_ntoa_r, ether_aton_r \- Ethernet address manipulation routines
35 .SH SYNOPSIS
36 .nf
37 .B #include <netinet/ether.h>
38 .PP
39 .BI "char *ether_ntoa(const struct ether_addr *" addr );
40 .BI "struct ether_addr *ether_aton(const char *" asc );
41 .PP
42 .BI "int ether_ntohost(char *" hostname ", const struct ether_addr *" addr );
43 .BI "int ether_hostton(const char *" hostname ", struct ether_addr *" addr );
44 .PP
45 .BI "int ether_line(const char *" line ", struct ether_addr *" addr ,
46 .BI "               char *" hostname );
47 .PP
48 /* GNU extensions */
49 .BI "char *ether_ntoa_r(const struct ether_addr *" addr ", char *" buf );
50 .PP
51 .BI "struct ether_addr *ether_aton_r(const char *" asc ,
52 .BI "                                struct ether_addr *" addr );
53 .fi
54 .SH DESCRIPTION
55 .BR ether_aton ()
56 converts the 48-bit Ethernet host address
57 .I asc
58 from the standard hex-digits-and-colons notation into binary data in
59 network byte order and returns a pointer to it in a statically
60 allocated buffer, which subsequent calls will
61 overwrite.
62 .BR ether_aton ()
63 returns NULL if the address is invalid.
64 .PP
65 The
66 .BR ether_ntoa ()
67 function converts the Ethernet host address
68 .I addr
69 given in network byte order to a string in standard
70 hex-digits-and-colons notation, omitting leading zeros.
71 The string is returned in a statically allocated buffer,
72 which subsequent calls will overwrite.
73 .PP
74 The
75 .BR ether_ntohost ()
76 function maps an Ethernet address to the
77 corresponding hostname in
78 .I /etc/ethers
79 and returns nonzero if it cannot be found.
80 .PP
81 The
82 .BR ether_hostton ()
83 function maps a hostname to the
84 corresponding Ethernet address in
85 .I /etc/ethers
86 and returns nonzero if it cannot be found.
87 .PP
88 The
89 .BR ether_line ()
90 function parses a line in
91 .I /etc/ethers
92 format (ethernet address followed by whitespace followed by
93 hostname; \(aq#\(aq introduces a comment) and returns an address
94 and hostname pair, or nonzero if it cannot be parsed.
95 The buffer pointed to by
96 .I hostname
97 must be sufficiently long, for example, have the same length as
98 .IR line .
99 .PP
100 The functions
101 .BR ether_ntoa_r ()
103 .BR ether_aton_r ()
104 are reentrant
105 thread-safe versions of
106 .BR ether_ntoa ()
108 .BR ether_aton ()
109 respectively, and do not use static buffers.
111 The structure
112 .I ether_addr
113 is defined in
114 .I <net/ethernet.h>
117 .in +4n
119 struct ether_addr {
120     uint8_t ether_addr_octet[6];
124 .SH ATTRIBUTES
125 For an explanation of the terms used in this section, see
126 .BR attributes (7).
127 .ad l
130 allbox;
131 lbx lb lb
132 l l l.
133 Interface       Attribute       Value
135 .BR ether_aton (),
136 .BR ether_ntoa ()
137 T}      Thread safety   MT-Unsafe
139 .BR ether_ntohost (),
140 .BR ether_hostton (),
141 .BR ether_line (),
142 .BR ether_ntoa_r (),
143 .BR ether_aton_r ()
144 T}      Thread safety   MT-Safe
148 .sp 1
149 .SH CONFORMING TO
150 4.3BSD, SunOS.
151 .SH BUGS
152 In glibc 2.2.5 and earlier, the implementation of
153 .BR ether_line ()
154 .\" The fix was presumably commit c0a0f9a32c8baa6ab93d00eb42d92c02e9e146d7
155 .\" which was in glibc 2.3
156 is broken.
157 .SH SEE ALSO
158 .BR ethers (5)