xref: /freebsd/lib/libc/net/eui64.3 (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1.\" Copyright 2004 The Aerospace Corporation.  All rights reserved.
2.\"
3.\" Redistribution and use in source and binary forms, with or without
4.\" modification, are permitted provided that the following conditions
5.\" are met:
6.\"
7.\" 1.  Redistributions of source code must retain the above copyright
8.\"     notice, this list of conditions, and the following disclaimer.
9.\" 2.  Redistributions in binary form must reproduce the above copyright
10.\"     notice, this list of conditions, and the following disclaimer in the
11.\"     documentation and/or other materials provided with the distribution.
12.\" 3.  The name of The Aerospace Corporation may not be used to endorse or
13.\"     promote products derived from this software.
14.\"
15.\" THIS SOFTWARE IS PROVIDED BY THE AEROSPACE CORPORATION "AS IS" AND
16.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AEROSPACE CORPORATION BE LIABLE
19.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25.\" SUCH DAMAGE.
26.\"
27.\" Copyright (c) 1995
28.\"	Bill Paul <wpaul@ctr.columbia.edu>.  All rights reserved.
29.\"
30.\" Redistribution and use in source and binary forms, with or without
31.\" modification, are permitted provided that the following conditions
32.\" are met:
33.\" 1. Redistributions of source code must retain the above copyright
34.\"    notice, this list of conditions and the following disclaimer.
35.\" 2. Redistributions in binary form must reproduce the above copyright
36.\"    notice, this list of conditions and the following disclaimer in the
37.\"    documentation and/or other materials provided with the distribution.
38.\" 3. All advertising materials mentioning features or use of this software
39.\"    must display the following acknowledgement:
40.\"	This product includes software developed by Bill Paul.
41.\" 4. Neither the name of the author nor the names of any co-contributors
42.\"    may be used to endorse or promote products derived from this software
43.\"    without specific prior written permission.
44.\"
45.\" THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
46.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
47.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
48.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
49.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
51.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
53.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
54.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
55.\" SUCH DAMAGE.
56.\"
57.Dd March 4, 2004
58.Dt EUI64 3
59.Os
60.Sh NAME
61.Nm eui64 ,
62.\" .Nm eui64_line ,
63.Nm eui64_aton ,
64.Nm eui64_ntoa ,
65.Nm eui64_ntohost ,
66.Nm eui64_hostton
67.Nd IEEE EUI-64 conversion and lookup routines
68.Sh LIBRARY
69.Lb libc
70.Sh SYNOPSIS
71.In sys/types.h
72.In sys/eui64.h
73.\" .Ft int
74.\" .Fn eui64_line "const char *l" "struct eui64 *e" "char *hostname" "size_t len"
75.Ft int
76.Fn eui64_aton "const char *a" "struct eui64 *e"
77.Ft int
78.Fn eui64_ntoa "const struct eui64 *id" "char *a" "size_t len"
79.Ft int
80.Fn eui64_ntohost "char *hostname" "size_t len" "const struct eui64 *id"
81.Ft int
82.Fn eui64_hostton "const char *hostname" "struct eui64 *id"
83.Sh DESCRIPTION
84These functions operate on IEEE EUI-64s using an
85.Vt eui64
86structure, which is defined in the header file
87.In sys/eui64.h :
88.Bd -literal -offset indent
89/*
90 * The number of bytes in an EUI-64.
91 */
92#define EUI64_LEN		8
93
94/*
95 * Structure of an IEEE EUI-64.
96 */
97struct  eui64 {
98        u_char octet[EUI64_LEN];
99};
100.Ed
101.\" .Pp
102.\" The function
103.\" .Fn eui64_line
104.\" scans
105.\" .Fa l ,
106.\" an
107.\" .Tn ASCII
108.\" string in
109.\" .Xr eui64 5
110.\" format and sets
111.\" .Fa e
112.\" to the EUI-64 specified in the string and
113.\" .Fa h
114.\" to the hostname.
115.\" This function is used to parse lines from
116.\" .Pa /etc/eui64
117.\" into their component parts.
118.Pp
119The
120.Fn eui64_aton
121function converts an
122.Tn ASCII
123representation of an EUI-64 into an
124.Vt eui64
125structure.
126Likewise,
127.Fn eui64_ntoa
128converts an EUI-64 specified as an
129.Vt eui64
130structure into an
131.Tn ASCII
132string.
133.Pp
134The
135.Fn eui64_ntohost
136and
137.Fn eui64_hostton
138functions map EUI-64s to their corresponding hostnames
139as specified in the
140.Pa /etc/eui64
141database.
142The
143.Fn eui64_ntohost
144function
145converts from EUI-64 to hostname, and
146.Fn eui64_hostton
147converts from hostname to EUI-64.
148.Sh RETURN VALUES
149.\" The
150.\" .Fn eui64_line
151.\" function
152.\" returns zero on success and non-zero if it was unable to parse
153.\" any part of the supplied line
154.\" .Fa l .
155.\" It returns the extracted EUI-64 in the supplied
156.\" .Vt eui64
157.\" structure
158.\" .Fa e
159.\" and the hostname in the supplied string
160.\" .Fa h .
161.\" .Pp
162On success,
163.Fn eui64_ntoa
164returns a pointer to a string containing an
165.Tn ASCII
166representation of an EUI-64.
167If it is unable to convert
168the supplied
169.Vt eui64
170structure, it returns a
171.Dv NULL
172pointer.
173Likewise,
174.Fn eui64_aton
175returns a pointer to an
176.Vt eui64
177structure on success and a
178.Dv NULL
179pointer on failure.
180.Pp
181The
182.Fn eui64_ntohost
183and
184.Fn eui64_hostton
185functions both return zero on success or non-zero if they were
186unable to find a match in the
187.Pa /etc/eui64
188database.
189.Sh NOTES
190The user must ensure that the hostname strings passed to the
191.\" .Fn eui64_line ,
192.Fn eui64_ntohost
193and
194.Fn eui64_hostton
195functions are large enough to contain the returned hostnames.
196.Sh NIS INTERACTION
197If the
198.Pa /etc/eui64
199contains a line with a single
200.Ql +
201in it, the
202.Fn eui64_ntohost
203and
204.Fn eui64_hostton
205functions will attempt to consult the NIS
206.Pa eui64.byname
207and
208.Pa eui64.byid
209maps in addition to the data in the
210.Pa /etc/eui64
211file.
212.Sh SEE ALSO
213.Xr firewire 4 ,
214.Xr eui64 5 ,
215.Xr yp 8
216.Sh HISTORY
217These functions first appears in
218.Fx 5.3 .
219They are derived from the
220.Xr ethers 3
221family of functions.
222