]>
Commit | Line | Data |
---|---|---|
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 | 14 | ether_aton, ether_ntoa, ether_ntohost, ether_hostton, ether_line, |
fea681da | 15 | ether_ntoa_r, ether_aton_r \- Ethernet address manipulation routines |
afa8db94 AC |
16 | .SH LIBRARY |
17 | Standard 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 |
40 | converts the 48-bit Ethernet host address |
41 | .I asc | |
fea681da MK |
42 | from the standard hex-digits-and-colons notation into binary data in |
43 | network byte order and returns a pointer to it in a statically | |
44 | allocated buffer, which subsequent calls will | |
60a90ecd MK |
45 | overwrite. |
46 | .BR ether_aton () | |
47 | returns NULL if the address is invalid. | |
fea681da | 48 | .PP |
60a90ecd MK |
49 | The |
50 | .BR ether_ntoa () | |
51 | function converts the Ethernet host address | |
c6fa0841 MK |
52 | .I addr |
53 | given in network byte order to a string in standard | |
7b01461a | 54 | hex-digits-and-colons notation, omitting leading zeros. |
fea681da MK |
55 | The string is returned in a statically allocated buffer, |
56 | which subsequent calls will overwrite. | |
57 | .PP | |
60a90ecd MK |
58 | The |
59 | .BR ether_ntohost () | |
60 | function maps an Ethernet address to the | |
c13182ef | 61 | corresponding hostname in |
836f07c1 | 62 | .I /etc/ethers |
c7094399 | 63 | and returns nonzero if it cannot be found. |
fea681da | 64 | .PP |
60a90ecd MK |
65 | The |
66 | .BR ether_hostton () | |
67 | function maps a hostname to the | |
fea681da | 68 | corresponding Ethernet address in |
836f07c1 | 69 | .I /etc/ethers |
c7094399 | 70 | and returns nonzero if it cannot be found. |
fea681da | 71 | .PP |
60a90ecd MK |
72 | The |
73 | .BR ether_line () | |
74 | function parses a line in | |
836f07c1 | 75 | .I /etc/ethers |
fea681da | 76 | format (ethernet address followed by whitespace followed by |
b957f81f | 77 | hostname; \[aq]#\[aq] introduces a comment) and returns an address |
c7094399 | 78 | and hostname pair, or nonzero if it cannot be parsed. |
fea681da MK |
79 | The buffer pointed to by |
80 | .I hostname | |
75b94dc3 | 81 | must be sufficiently long, for example, have the same length as |
fea681da MK |
82 | .IR line . |
83 | .PP | |
60a90ecd MK |
84 | The functions |
85 | .BR ether_ntoa_r () | |
86 | and | |
87 | .BR ether_aton_r () | |
da27f178 | 88 | are reentrant |
79761fe5 | 89 | thread-safe versions of |
60a90ecd MK |
90 | .BR ether_ntoa () |
91 | and | |
92 | .BR ether_aton () | |
fea681da MK |
93 | respectively, and do not use static buffers. |
94 | .PP | |
c6fa0841 MK |
95 | The structure |
96 | .I ether_addr | |
97 | is defined in | |
eb12ffbf MK |
98 | .I <net/ethernet.h> |
99 | as: | |
51f5698d | 100 | .PP |
a08ea57c | 101 | .in +4n |
b8302363 | 102 | .EX |
fea681da | 103 | struct ether_addr { |
aeb4b1fc | 104 | uint8_t ether_addr_octet[6]; |
fea681da | 105 | } |
b8302363 | 106 | .EE |
a08ea57c | 107 | .in |
6a92c34c | 108 | .SH ATTRIBUTES |
053cd430 MK |
109 | For an explanation of the terms used in this section, see |
110 | .BR attributes (7). | |
053cd430 MK |
111 | .TS |
112 | allbox; | |
c466875e | 113 | lbx lb lb |
053cd430 MK |
114 | l l l. |
115 | Interface Attribute Value | |
116 | T{ | |
9e54434e BR |
117 | .na |
118 | .nh | |
053cd430 | 119 | .BR ether_aton (), |
6a92c34c | 120 | .BR ether_ntoa () |
053cd430 MK |
121 | T} Thread safety MT-Unsafe |
122 | T{ | |
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 |
130 | T} Thread safety MT-Safe |
131 | .TE | |
c466875e | 132 | .sp 1 |
3113c7f3 | 133 | .SH STANDARDS |
4131356c AC |
134 | None. |
135 | .SH HISTORY | |
44a2c328 | 136 | 4.3BSD, SunOS. |
2b2581ee | 137 | .SH BUGS |
053cd430 | 138 | In 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 | 142 | is broken. |
47297adb | 143 | .SH SEE ALSO |
fea681da | 144 | .BR ethers (5) |