]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright 2002 Ian Redfern (redferni@logica.com) |
2 | .\" | |
93015253 | 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 | .\" | |
f9293d98 | 29 | .\" Minor additions, aeb, 2013-06-21 |
fea681da | 30 | .\" |
4b8c67d9 | 31 | .TH ETHER_ATON 3 2017-09-15 "GNU" "Linux Programmer's Manual" |
fea681da | 32 | .SH NAME |
c13182ef | 33 | ether_aton, ether_ntoa, ether_ntohost, ether_hostton, ether_line, |
fea681da MK |
34 | ether_ntoa_r, ether_aton_r \- Ethernet address manipulation routines |
35 | .SH SYNOPSIS | |
36 | .nf | |
37 | .B #include <netinet/ether.h> | |
68e4db0a | 38 | .PP |
b9f02710 | 39 | .BI "char *ether_ntoa(const struct ether_addr *" addr ); |
68e4db0a | 40 | .PP |
b9f02710 | 41 | .BI "struct ether_addr *ether_aton(const char *" asc ); |
68e4db0a | 42 | .PP |
b9f02710 | 43 | .BI "int ether_ntohost(char *" hostname ", const struct ether_addr *" addr ); |
68e4db0a | 44 | .PP |
b9f02710 | 45 | .BI "int ether_hostton(const char *" hostname ", struct ether_addr *" addr ); |
68e4db0a | 46 | .PP |
b9f02710 MK |
47 | .BI "int ether_line(const char *" line ", struct ether_addr *" addr , |
48 | .BI " char *" hostname ); | |
68e4db0a | 49 | .PP |
fea681da MK |
50 | /* GNU extensions */ |
51 | .br | |
b9f02710 | 52 | .BI "char *ether_ntoa_r(const struct ether_addr *" addr ", char *" buf ); |
68e4db0a | 53 | .PP |
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 | 58 | .BR ether_aton () |
c6fa0841 MK |
59 | converts the 48-bit Ethernet host address |
60 | .I asc | |
fea681da MK |
61 | from the standard hex-digits-and-colons notation into binary data in |
62 | network byte order and returns a pointer to it in a statically | |
63 | allocated buffer, which subsequent calls will | |
60a90ecd MK |
64 | overwrite. |
65 | .BR ether_aton () | |
66 | returns NULL if the address is invalid. | |
fea681da | 67 | .PP |
60a90ecd MK |
68 | The |
69 | .BR ether_ntoa () | |
70 | function converts the Ethernet host address | |
c6fa0841 MK |
71 | .I addr |
72 | given in network byte order to a string in standard | |
7b01461a | 73 | hex-digits-and-colons notation, omitting leading zeros. |
fea681da MK |
74 | The string is returned in a statically allocated buffer, |
75 | which subsequent calls will overwrite. | |
76 | .PP | |
60a90ecd MK |
77 | The |
78 | .BR ether_ntohost () | |
79 | function maps an Ethernet address to the | |
c13182ef | 80 | corresponding hostname in |
836f07c1 | 81 | .I /etc/ethers |
c7094399 | 82 | and returns nonzero if it cannot be found. |
fea681da | 83 | .PP |
60a90ecd MK |
84 | The |
85 | .BR ether_hostton () | |
86 | function maps a hostname to the | |
fea681da | 87 | corresponding Ethernet address in |
836f07c1 | 88 | .I /etc/ethers |
c7094399 | 89 | and returns nonzero if it cannot be found. |
fea681da | 90 | .PP |
60a90ecd MK |
91 | The |
92 | .BR ether_line () | |
93 | function parses a line in | |
836f07c1 | 94 | .I /etc/ethers |
fea681da | 95 | format (ethernet address followed by whitespace followed by |
f81fb444 | 96 | hostname; \(aq#\(aq introduces a comment) and returns an address |
c7094399 | 97 | and hostname pair, or nonzero if it cannot be parsed. |
fea681da MK |
98 | The buffer pointed to by |
99 | .I hostname | |
75b94dc3 | 100 | must be sufficiently long, for example, have the same length as |
fea681da MK |
101 | .IR line . |
102 | .PP | |
60a90ecd MK |
103 | The functions |
104 | .BR ether_ntoa_r () | |
105 | and | |
106 | .BR ether_aton_r () | |
da27f178 | 107 | are reentrant |
79761fe5 | 108 | thread-safe versions of |
60a90ecd MK |
109 | .BR ether_ntoa () |
110 | and | |
111 | .BR ether_aton () | |
fea681da MK |
112 | respectively, and do not use static buffers. |
113 | .PP | |
c6fa0841 MK |
114 | The structure |
115 | .I ether_addr | |
116 | is defined in | |
eb12ffbf MK |
117 | .I <net/ethernet.h> |
118 | as: | |
51f5698d | 119 | .PP |
a08ea57c | 120 | .in +4n |
b8302363 | 121 | .EX |
fea681da | 122 | struct ether_addr { |
aeb4b1fc | 123 | uint8_t ether_addr_octet[6]; |
fea681da | 124 | } |
b8302363 | 125 | .EE |
a08ea57c | 126 | .in |
6a92c34c | 127 | .SH ATTRIBUTES |
053cd430 MK |
128 | For an explanation of the terms used in this section, see |
129 | .BR attributes (7). | |
130 | .ad l | |
131 | .TS | |
132 | allbox; | |
133 | lbw33 lb lb | |
134 | l l l. | |
135 | Interface Attribute Value | |
136 | T{ | |
137 | .BR ether_aton (), | |
6a92c34c | 138 | .BR ether_ntoa () |
053cd430 MK |
139 | T} Thread safety MT-Unsafe |
140 | T{ | |
6a92c34c PH |
141 | .BR ether_ntohost (), |
142 | .BR ether_hostton (), | |
143 | .BR ether_line (), | |
053cd430 | 144 | .BR ether_ntoa_r (), |
6a92c34c | 145 | .BR ether_aton_r () |
053cd430 MK |
146 | T} Thread safety MT-Safe |
147 | .TE | |
148 | .ad | |
47297adb | 149 | .SH CONFORMING TO |
44a2c328 | 150 | 4.3BSD, SunOS. |
2b2581ee | 151 | .SH BUGS |
053cd430 | 152 | In glibc 2.2.5 and earlier, the implementation of |
d9a10d9d | 153 | .BR ether_line () |
053cd430 MK |
154 | .\" The fix was presumably commit c0a0f9a32c8baa6ab93d00eb42d92c02e9e146d7 |
155 | .\" which was in glibc 2.3 | |
d9a10d9d | 156 | is broken. |
47297adb | 157 | .SH SEE ALSO |
fea681da | 158 | .BR ethers (5) |