OSDN Git Service

LDP: Update original to LDP v3.79
[linuxjm/LDP_man-pages.git] / original / man3 / ether_aton.3
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  2014-07-08 "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 .sp
39 .BI "char *ether_ntoa(const struct ether_addr *" addr );
40 .sp
41 .BI "struct ether_addr *ether_aton(const char *" asc );
42 .sp
43 .BI "int ether_ntohost(char *" hostname ", const struct ether_addr *" addr );
44 .sp
45 .BI "int ether_hostton(const char *" hostname ", struct ether_addr *" addr );
46 .sp
47 .BI "int ether_line(const char *" line ", struct ether_addr *" addr ,
48 .BI "               char *" hostname );
49 .sp
50 /* GNU extensions */
51 .br
52 .BI "char *ether_ntoa_r(const struct ether_addr *" addr ", char *" buf );
53 .sp
54 .BI "struct ether_addr *ether_aton_r(const char *" asc ,
55 .BI "                                struct ether_addr *" addr );
56 .fi
57 .SH DESCRIPTION
58 .BR ether_aton ()
59 converts the 48-bit Ethernet host address
60 .I asc
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
64 overwrite.
65 .BR ether_aton ()
66 returns NULL if the address is invalid.
67 .PP
68 The
69 .BR ether_ntoa ()
70 function converts the Ethernet host address
71 .I addr
72 given in network byte order to a string in standard
73 hex-digits-and-colons notation, omitting leading zeros.
74 The string is returned in a statically allocated buffer,
75 which subsequent calls will overwrite.
76 .PP
77 The
78 .BR ether_ntohost ()
79 function maps an Ethernet address to the
80 corresponding hostname in
81 .I /etc/ethers
82 and returns nonzero if it cannot be found.
83 .PP
84 The
85 .BR ether_hostton ()
86 function maps a hostname to the
87 corresponding Ethernet address in
88 .I /etc/ethers
89 and returns nonzero if it cannot be found.
90 .PP
91 The
92 .BR ether_line ()
93 function parses a line in
94 .I /etc/ethers
95 format (ethernet address followed by whitespace followed by
96 hostname; \(aq#\(aq introduces a comment) and returns an address
97 and hostname pair, or nonzero if it cannot be parsed.
98 The buffer pointed to by
99 .I hostname
100 must be sufficiently long, for example, have the same length as
101 .IR line .
102 .PP
103 The functions
104 .BR ether_ntoa_r ()
105 and
106 .BR ether_aton_r ()
107 are reentrant
108 thread-safe versions of
109 .BR ether_ntoa ()
110 and
111 .BR ether_aton ()
112 respectively, and do not use static buffers.
113 .PP
114 The structure
115 .I ether_addr
116 is defined in
117 .I <net/ethernet.h>
118 as:
119 .sp
120 .in +4n
121 .nf
122 struct ether_addr {
123     uint8_t ether_addr_octet[6];
124 }
125 .fi
126 .in
127 .SH ATTRIBUTES
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 (),
138 .BR ether_ntoa ()
139 T}      Thread safety   MT-Unsafe
140 T{
141 .BR ether_ntohost (),
142 .BR ether_hostton (),
143 .BR ether_line (),
144 .BR ether_ntoa_r (),
145 .BR ether_aton_r ()
146 T}      Thread safety   MT-Safe
147 .TE
148 .ad
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)
159 .SH COLOPHON
160 This page is part of release 3.79 of the Linux
161 .I man-pages
162 project.
163 A description of the project,
164 information about reporting bugs,
165 and the latest version of this page,
166 can be found at
167 \%http://www.kernel.org/doc/man\-pages/.