OSDN Git Service

(split) Import translated manuals from JM CVS Repository.
[linuxjm/LDP_man-pages.git] / original / man3 / ether_aton.3
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\"
3 .\" Copyright 2002 Ian Redfern (redferni@logica.com)
4 .\"
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein.  The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\"
25 .\" References consulted:
26 .\"     Linux libc source code
27 .\"     FreeBSD 4.4 man pages
28 .\"
29 .\" Minor additions, aeb, 2002-07-20
30 .\"
31 .TH ETHER_ATON 3  2002-07-20 "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 \fIasc\fP
60 from the standard hex-digits-and-colons notation into binary data in
61 network byte order and returns a pointer to it in a statically
62 allocated buffer, which subsequent calls will
63 overwrite.
64 .BR ether_aton ()
65 returns NULL if the address is invalid.
66 .PP
67 The
68 .BR ether_ntoa ()
69 function converts the Ethernet host address
70 \fIaddr\fP given in network byte order to a string in standard
71 hex-digits-and-colons notation, omitting leading zeros.
72 The string is returned in a statically allocated buffer,
73 which subsequent calls will overwrite.
74 .PP
75 The
76 .BR ether_ntohost ()
77 function maps an Ethernet address to the
78 corresponding hostname in
79 .I /etc/ethers
80 and returns nonzero if it cannot be found.
81 .PP
82 The
83 .BR ether_hostton ()
84 function maps a hostname to the
85 corresponding Ethernet address in
86 .I /etc/ethers
87 and returns nonzero if it cannot be found.
88 .PP
89 The
90 .BR ether_line ()
91 function parses a line in
92 .I /etc/ethers
93 format (ethernet address followed by whitespace followed by
94 hostname; \(aq#\(aq introduces a comment) and returns an address
95 and hostname pair, or nonzero if it cannot be parsed.
96 The buffer pointed to by
97 .I hostname
98 must be sufficiently long, for example, have the same length as
99 .IR line .
100 .PP
101 The functions
102 .BR ether_ntoa_r ()
103 and
104 .BR ether_aton_r ()
105 are reentrant
106 thread-safe versions of
107 .BR ether_ntoa ()
108 and
109 .BR ether_aton ()
110 respectively, and do not use static buffers.
111 .PP
112 The structure \fIether_addr\fP is defined in
113 .I <net/ethernet.h>
114 as:
115 .sp
116 .in +4n
117 .nf
118 struct ether_addr {
119     uint8_t ether_addr_octet[6];
120 }
121 .fi
122 .in
123 .SH "CONFORMING TO"
124 4.3BSD, SunOS.
125 .SH BUGS
126 The glibc 2.2.5 implementation of
127 .BR ether_line ()
128 is broken.
129 .SH "SEE ALSO"
130 .BR ethers (5)