mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-15 10:17:20 +00:00
Add support for an /etc/eui64 file modeled on /etc/ethers. The API is
modeled on ethers(3) except that all functions are thread-safe. Reviewed by: simokawa
This commit is contained in:
parent
3858fd7a0c
commit
7387768ef4
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=129759
@ -4,7 +4,7 @@
|
||||
# machine-independent net sources
|
||||
.PATH: ${.CURDIR}/${MACHINE_ARCH}/net ${.CURDIR}/net
|
||||
|
||||
SRCS+= addr2ascii.c ascii2addr.c base64.c ether_addr.c getaddrinfo.c \
|
||||
SRCS+= addr2ascii.c ascii2addr.c base64.c ether_addr.c eui64.c getaddrinfo.c \
|
||||
gethostbydns.c gethostbyht.c gethostbynis.c gethostnamadr.c \
|
||||
getifaddrs.c getifmaddrs.c getnameinfo.c \
|
||||
getnetbydns.c getnetbyht.c getnetbynis.c getnetnamadr.c \
|
||||
@ -39,7 +39,8 @@ nslexer.c: nslexer.l nsparser.h
|
||||
.include "${.CURDIR}/${MACHINE_ARCH}/net/Makefile.inc"
|
||||
.endif
|
||||
|
||||
MAN+= addr2ascii.3 byteorder.3 ethers.3 getaddrinfo.3 gethostbyname.3 \
|
||||
MAN+= addr2ascii.3 byteorder.3 ethers.3 eui64.3 \
|
||||
getaddrinfo.3 gethostbyname.3 \
|
||||
getifaddrs.3 getifmaddrs.3 getipnodebyname.3 \
|
||||
getnameinfo.3 getnetent.3 getprotoent.3 getservent.3 hesiod.3 \
|
||||
if_indextoname.3 \
|
||||
@ -53,6 +54,8 @@ MLINKS+=byteorder.3 htonl.3 byteorder.3 htons.3 byteorder.3 ntohl.3 \
|
||||
byteorder.3 ntohs.3
|
||||
MLINKS+=ethers.3 ether_aton.3 ethers.3 ether_hostton.3 ethers.3 ether_line.3 \
|
||||
ethers.3 ether_ntoa.3 ethers.3 ether_ntohost.3
|
||||
MLINKS+=eui64.3 eui64_aton.3 eui64.3 eui64_hostton.3 \
|
||||
eui64.3 eui64_ntoa.3 eui64.3 eui64_ntohost.3
|
||||
MLINKS+=getaddrinfo.3 freeaddrinfo.3 getaddrinfo.3 gai_strerror.3
|
||||
MLINKS+=gethostbyname.3 endhostent.3 gethostbyname.3 gethostbyaddr.3 \
|
||||
gethostbyname.3 gethostbyname2.3 gethostbyname.3 gethostent.3 \
|
||||
|
202
lib/libc/net/eui64.3
Normal file
202
lib/libc/net/eui64.3
Normal file
@ -0,0 +1,202 @@
|
||||
.\" Copyright (c) 1995
|
||||
.\" Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\" 3. All advertising materials mentioning features or use of this software
|
||||
.\" must display the following acknowledgement:
|
||||
.\" This product includes software developed by Bill Paul.
|
||||
.\" 4. Neither the name of the author nor the names of any co-contributors
|
||||
.\" may be used to endorse or promote products derived from this software
|
||||
.\" without specific prior written permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd March 4 2004
|
||||
.Dt EUI64 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm eui64 ,
|
||||
.\" .Nm eui64_line ,
|
||||
.Nm eui64_aton ,
|
||||
.Nm eui64_ntoa ,
|
||||
.Nm eui64_ntohost ,
|
||||
.Nm eui64_hostton
|
||||
.Nd IEEE EUI-64 conversion and lookup routines
|
||||
.Sh LIBRARY
|
||||
.Lb libc
|
||||
.Sh SYNOPSIS
|
||||
.In sys/types.h
|
||||
.In sys/eui64.h
|
||||
.\" .Ft int
|
||||
.\" .Fn eui64_line "const char *l" "struct eui64 *e" "char *hostname" "size_t len"
|
||||
.Ft int
|
||||
.Fn eui64_aton "const char *a" "struct eui64 *e"
|
||||
.Ft int
|
||||
.Fn eui64_ntoa "const struct eui64 *id" "char *a" "size_t len"
|
||||
.Ft int
|
||||
.Fn eui64_ntohost "char *hostname" "size_t len" "const struct eui64 *id"
|
||||
.Ft int
|
||||
.Fn eui64_hostton "const char *hostname" "struct eui64 *id"
|
||||
.Sh DESCRIPTION
|
||||
These functions operate on IEEE EUI-64s using an
|
||||
.Vt eui64
|
||||
structure, which is defined in the header file
|
||||
.In sys/eui64.h :
|
||||
.Bd -literal -offset indent
|
||||
/*
|
||||
* The number of bytes in an EUI-64.
|
||||
*/
|
||||
#define EUI64_LEN 8
|
||||
|
||||
/*
|
||||
* Structure of an IEEE EUI-64.
|
||||
*/
|
||||
struct eui64 {
|
||||
u_char octet[EUI64_LEN];
|
||||
};
|
||||
.Ed
|
||||
.\" .Pp
|
||||
.\" The function
|
||||
.\" .Fn eui64_line
|
||||
.\" scans
|
||||
.\" .Fa l ,
|
||||
.\" an
|
||||
.\" .Tn ASCII
|
||||
.\" string in
|
||||
.\" .Xr eui64 5
|
||||
.\" format and sets
|
||||
.\" .Fa e
|
||||
.\" to the EUI-64 specified in the string and
|
||||
.\" .Fa h
|
||||
.\" to the hostname.
|
||||
.\" This function is used to parse lines from
|
||||
.\" .Pa /etc/eui64
|
||||
.\" into their component parts.
|
||||
.Pp
|
||||
The
|
||||
.Fn eui64_aton
|
||||
function converts an
|
||||
.Tn ASCII
|
||||
representation of an EUI-64 into an
|
||||
.Vt eui64
|
||||
structure.
|
||||
Likewise,
|
||||
.Fn eui64_ntoa
|
||||
converts an EUI-64 specified as an
|
||||
.Vt eui64
|
||||
structure into an
|
||||
.Tn ASCII
|
||||
string.
|
||||
.Pp
|
||||
The
|
||||
.Fn eui64_ntohost
|
||||
and
|
||||
.Fn eui64_hostton
|
||||
functions map EUI-64s to their corresponding hostnames
|
||||
as specified in the
|
||||
.Pa /etc/eui64
|
||||
database.
|
||||
The
|
||||
.Fn eui64_ntohost
|
||||
function
|
||||
converts from EUI-64 to hostname, and
|
||||
.Fn eui64_hostton
|
||||
converts from hostname to EUI-64.
|
||||
.Sh RETURN VALUES
|
||||
.\" The
|
||||
.\" .Fn eui64_line
|
||||
.\" function
|
||||
.\" returns zero on success and non-zero if it was unable to parse
|
||||
.\" any part of the supplied line
|
||||
.\" .Fa l .
|
||||
.\" It returns the extracted EUI-64 in the supplied
|
||||
.\" .Vt eui64
|
||||
.\" structure
|
||||
.\" .Fa e
|
||||
.\" and the hostname in the supplied string
|
||||
.\" .Fa h .
|
||||
.\" .Pp
|
||||
On success,
|
||||
.Fn eui64_ntoa
|
||||
returns a pointer to a string containing an
|
||||
.Tn ASCII
|
||||
representation of an EUI-64.
|
||||
If it is unable to convert
|
||||
the supplied
|
||||
.Vt eui64
|
||||
structure, it returns a
|
||||
.Dv NULL
|
||||
pointer.
|
||||
Likewise,
|
||||
.Fn eui64_aton
|
||||
returns a pointer to an
|
||||
.Vt eui64
|
||||
structure on success and a
|
||||
.Dv NULL
|
||||
pointer on failure.
|
||||
.Pp
|
||||
The
|
||||
.Fn eui64_ntohost
|
||||
and
|
||||
.Fn eui64_hostton
|
||||
functions both return zero on success or non-zero if they were
|
||||
unable to find a match in the
|
||||
.Pa /etc/eui64
|
||||
database.
|
||||
.Sh NOTES
|
||||
The user must insure that the hostname strings passed to the
|
||||
.\" .Fn eui64_line ,
|
||||
.Fn eui64_ntohost
|
||||
and
|
||||
.Fn eui64_hostton
|
||||
functions are large enough to contain the returned hostnames.
|
||||
.Sh NIS INTERACTION
|
||||
If the
|
||||
.Pa /etc/eui64
|
||||
contains a line with a single + in it, the
|
||||
.Fn eui64_ntohost
|
||||
and
|
||||
.Fn eui64_hostton
|
||||
functions will attempt to consult the NIS
|
||||
.Pa eui64.byname
|
||||
and
|
||||
.Pa eui64.byid
|
||||
maps in addition to the data in the
|
||||
.Pa /etc/eui64
|
||||
file.
|
||||
.Sh SEE ALSO
|
||||
.Xr firewire 4 ,
|
||||
.Xr eui64 5 ,
|
||||
.Xr yp 8
|
||||
.Sh BUGS
|
||||
The
|
||||
.Fn eui64_aton
|
||||
and
|
||||
.Fn eui64_ntoa
|
||||
functions returns values that are stored in static memory areas
|
||||
which may be overwritten the next time they are called.
|
||||
.Sh HISTORY
|
||||
These functions first appears in
|
||||
.Fx 5.3 .
|
||||
They are derived from the
|
||||
.Xr ethers 3
|
||||
family of functions.
|
285
lib/libc/net/eui64.c
Normal file
285
lib/libc/net/eui64.c
Normal file
@ -0,0 +1,285 @@
|
||||
/*
|
||||
* Copyright (c) 1995
|
||||
* Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Bill Paul.
|
||||
* 4. Neither the name of the author nor the names of any co-contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* EUI-64 conversion and lookup routines
|
||||
*
|
||||
*
|
||||
* Converted from ether_addr.c rev
|
||||
* FreeBSD: src/lib/libc/net/eui64.c,v 1.15 2002/04/08 07:51:10 ru Exp
|
||||
* by Brooks Davis
|
||||
*
|
||||
* Written by Bill Paul <wpaul@ctr.columbia.edu>
|
||||
* Center for Telecommunications Research
|
||||
* Columbia University, New York City
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <stdio.h>
|
||||
#include <paths.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/eui64.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/param.h>
|
||||
#ifdef YP
|
||||
#include <rpc/rpc.h>
|
||||
#include <rpcsvc/yp_prot.h>
|
||||
#include <rpcsvc/ypclnt.h>
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_EUI64
|
||||
#define _PATH_EUI64 "/etc/eui64"
|
||||
#endif
|
||||
|
||||
static int eui64_line(const char *l, struct eui64 *e, char *hostname,
|
||||
size_t len);
|
||||
|
||||
/*
|
||||
* Parse a string of text containing an EUI-64 and hostname
|
||||
* and separate it into its component parts.
|
||||
*/
|
||||
static int
|
||||
eui64_line(const char *l, struct eui64 *e, char *hostname, size_t len)
|
||||
{
|
||||
char *line, *linehead, *cur;
|
||||
|
||||
linehead = strdup(l);
|
||||
if (linehead == NULL)
|
||||
return (-1);
|
||||
line = linehead;
|
||||
|
||||
/* Find and parse the EUI64 */
|
||||
while ((cur = strsep(&line, " \t\r\n")) != NULL) {
|
||||
if (*cur != '\0') {
|
||||
if (eui64_aton(cur, e) == 0)
|
||||
break;
|
||||
else
|
||||
goto bad;
|
||||
}
|
||||
}
|
||||
|
||||
/* Find the hostname */
|
||||
while ((cur = strsep(&line, " \t\r\n")) != NULL) {
|
||||
if (*cur != '\0') {
|
||||
if (strlcpy(hostname, cur, len) <= len)
|
||||
break;
|
||||
else
|
||||
goto bad;
|
||||
}
|
||||
}
|
||||
|
||||
/* Make sure what remains is either whitespace or a comment */
|
||||
while ((cur = strsep(&line, " \t\r\n")) != NULL) {
|
||||
if (*cur == '#')
|
||||
break;
|
||||
if (*cur != '\0')
|
||||
goto bad;
|
||||
}
|
||||
|
||||
return (0);
|
||||
|
||||
bad:
|
||||
free(linehead);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert an ASCII representation of an EUI-64 to binary form.
|
||||
*/
|
||||
int
|
||||
eui64_aton(const char *a, struct eui64 *e)
|
||||
{
|
||||
int i;
|
||||
unsigned int o0, o1, o2, o3, o4, o5, o6, o7;
|
||||
|
||||
/* canonical form */
|
||||
i = sscanf(a, "%x-%x-%x-%x-%x-%x-%x-%x",
|
||||
&o0, &o1, &o2, &o3, &o4, &o5, &o6, &o7);
|
||||
if (i == EUI64_LEN)
|
||||
goto good;
|
||||
/* ethernet form */
|
||||
i = sscanf(a, "%x:%x:%x:%x:%x:%x:%x:%x",
|
||||
&o0, &o1, &o2, &o3, &o4, &o5, &o6, &o7);
|
||||
if (i == EUI64_LEN)
|
||||
goto good;
|
||||
/* classic fwcontrol/dconschat form */
|
||||
i = sscanf(a, "0x%2x%2x%2x%2x%2x%2x%2x%2x",
|
||||
&o0, &o1, &o2, &o3, &o4, &o5, &o6, &o7);
|
||||
if (i == EUI64_LEN)
|
||||
goto good;
|
||||
/* MAC format (-) */
|
||||
i = sscanf(a, "%x-%x-%x-%x-%x-%x",
|
||||
&o0, &o1, &o2, &o5, &o6, &o7);
|
||||
if (i == 6) {
|
||||
o3 = 0xff;
|
||||
o4 = 0xfe;
|
||||
goto good;
|
||||
}
|
||||
/* MAC format (:) */
|
||||
i = sscanf(a, "%x:%x:%x:%x:%x:%x",
|
||||
&o0, &o1, &o2, &o5, &o6, &o7);
|
||||
if (i == 6) {
|
||||
o3 = 0xff;
|
||||
o4 = 0xfe;
|
||||
goto good;
|
||||
}
|
||||
|
||||
return (-1);
|
||||
|
||||
good:
|
||||
e->octet[0]=o0;
|
||||
e->octet[1]=o1;
|
||||
e->octet[2]=o2;
|
||||
e->octet[3]=o3;
|
||||
e->octet[4]=o4;
|
||||
e->octet[5]=o5;
|
||||
e->octet[6]=o6;
|
||||
e->octet[7]=o7;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert a binary representation of an EUI-64 to an ASCII string.
|
||||
*/
|
||||
int
|
||||
eui64_ntoa(const struct eui64 *id, char *a, size_t len)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = snprintf(a, len, "%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x",
|
||||
id->octet[0], id->octet[1], id->octet[2], id->octet[3],
|
||||
id->octet[4], id->octet[5], id->octet[6], id->octet[7]);
|
||||
if (i < 23 || i >= len)
|
||||
return (-1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Map an EUI-64 to a hostname. Use either /etc/eui64 or NIS/YP.
|
||||
*/
|
||||
int
|
||||
eui64_ntohost(char *hostname, size_t len, const struct eui64 *id)
|
||||
{
|
||||
FILE *fp;
|
||||
char buf[BUFSIZ + 2];
|
||||
struct eui64 local_eui64;
|
||||
char local_host[MAXHOSTNAMELEN];
|
||||
#ifdef YP
|
||||
char *result;
|
||||
int resultlen;
|
||||
char eui64_a[24];
|
||||
char *yp_domain;
|
||||
#endif
|
||||
if ((fp = fopen(_PATH_EUI64, "r")) == NULL)
|
||||
return (1);
|
||||
|
||||
while (fgets(buf,BUFSIZ,fp)) {
|
||||
if (buf[0] == '#')
|
||||
continue;
|
||||
#ifdef YP
|
||||
if (buf[0] == '+') {
|
||||
if (yp_get_default_domain(&yp_domain))
|
||||
continue;
|
||||
eui64_ntoa(id, eui64_a, sizeof(eui64_a));
|
||||
if (yp_match(yp_domain, "eui64.byid", eui64_a,
|
||||
strlen(eui64_a), &result, &resultlen)) {
|
||||
continue;
|
||||
}
|
||||
strncpy(buf, result, resultlen);
|
||||
buf[resultlen] = '\0';
|
||||
free(result);
|
||||
}
|
||||
#endif
|
||||
if (eui64_line(buf, &local_eui64, local_host,
|
||||
sizeof(local_host)) == 0) {
|
||||
if (bcmp(&local_eui64.octet[0],
|
||||
&id->octet[0], EUI64_LEN) == 0) {
|
||||
/* We have a match */
|
||||
strcpy(hostname, local_host);
|
||||
fclose(fp);
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Map a hostname to an EUI-64 using /etc/eui64 or NIS/YP.
|
||||
*/
|
||||
int
|
||||
eui64_hostton(const char *hostname, struct eui64 *id)
|
||||
{
|
||||
FILE *fp;
|
||||
char buf[BUFSIZ + 2];
|
||||
struct eui64 local_eui64;
|
||||
char local_host[MAXHOSTNAMELEN];
|
||||
#ifdef YP
|
||||
char *result;
|
||||
int resultlen;
|
||||
char *yp_domain;
|
||||
#endif
|
||||
if ((fp = fopen(_PATH_EUI64, "r")) == NULL)
|
||||
return (1);
|
||||
|
||||
while (fgets(buf,BUFSIZ,fp)) {
|
||||
if (buf[0] == '#')
|
||||
continue;
|
||||
#ifdef YP
|
||||
if (buf[0] == '+') {
|
||||
if (yp_get_default_domain(&yp_domain))
|
||||
continue;
|
||||
if (yp_match(yp_domain, "eui64.byname", hostname,
|
||||
strlen(hostname), &result, &resultlen)) {
|
||||
continue;
|
||||
}
|
||||
strncpy(buf, result, resultlen);
|
||||
buf[resultlen] = '\0';
|
||||
free(result);
|
||||
}
|
||||
#endif
|
||||
if (eui64_line(buf, &local_eui64, local_host,
|
||||
sizeof(local_host)) == 0) {
|
||||
if (strcmp(hostname, local_host) == 0) {
|
||||
/* We have a match */
|
||||
bcopy(&local_eui64, id, sizeof(struct eui64));
|
||||
fclose(fp);
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
return (1);
|
||||
}
|
@ -15,6 +15,7 @@ MAN= acct.5 \
|
||||
drivers.conf.5 \
|
||||
elf.5 \
|
||||
ethers.5 \
|
||||
eui64.5 \
|
||||
fbtab.5 \
|
||||
fdescfs.5 \
|
||||
forward.5 \
|
||||
|
108
share/man/man5/eui64.5
Normal file
108
share/man/man5/eui64.5
Normal file
@ -0,0 +1,108 @@
|
||||
.\" Copyright (c) 1995
|
||||
.\" Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\" 3. All advertising materials mentioning features or use of this software
|
||||
.\" must display the following acknowledgement:
|
||||
.\" This product includes software developed by Bill Paul.
|
||||
.\" 4. Neither the name of the author nor the names of any co-contributors
|
||||
.\" may be used to endorse or promote products derived from this software
|
||||
.\" without specific prior written permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd May 11, 2004
|
||||
.Dt EUI64 5
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm eui64
|
||||
.Nd IEEE EUI-64 address database
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
database contains information regarding known IEEE EUI-64s of hosts.
|
||||
The data is stored in a file called
|
||||
.Pa /etc/eui64
|
||||
in the following format:
|
||||
.Bd -unfilled -offset indent
|
||||
.Pa EUI-64 host-name
|
||||
.Ed
|
||||
.Pp
|
||||
Items are separated by any number of blanks and/or
|
||||
tab characters.
|
||||
A
|
||||
.Dq #
|
||||
at the start of a line indicates the
|
||||
beginning of a comment that extends to the end of the line.
|
||||
Valid lines may also contain comments.
|
||||
A
|
||||
.Dq +
|
||||
at the start of a line will cause the
|
||||
.Xr eui64 3
|
||||
library functions to use data stored in the
|
||||
.Xr NIS 4
|
||||
.Pa eui64.byname
|
||||
and
|
||||
.Pa eui64.byid
|
||||
maps in addition to the data in the
|
||||
.Pa /etc/eui64
|
||||
file.
|
||||
.Pp
|
||||
An EUI-64 is expressed in
|
||||
.Tn ASCII
|
||||
form as "x-x-x-x-x-x-x-x" where
|
||||
.Ar x
|
||||
is a hexadecimal value between 0x00 and 0xFF.
|
||||
The address values
|
||||
should be in network order.
|
||||
Hostnames specified in the
|
||||
.Pa /etc/eui64
|
||||
database should correspond to entries in the
|
||||
.Xr hosts 5
|
||||
file.
|
||||
./" .Pp
|
||||
./" The
|
||||
./" .Fn eui64_line
|
||||
./" function in the standard C library can be used to break individual
|
||||
./" lines in the
|
||||
./" .Pa /etc/eui64
|
||||
./" database into their individual components: a binary EUI-64 is
|
||||
./" stored as an
|
||||
./" .Pa eui64_addr
|
||||
./" structure, and a hostname stored as a character string.
|
||||
.Sh FILES
|
||||
.Bl -tag -width /etc/eui64 -compact
|
||||
.It Pa /etc/eui64
|
||||
The
|
||||
.Nm
|
||||
file resides in
|
||||
.Pa /etc .
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr eui64 3 ,
|
||||
.Xr yp 8
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm
|
||||
format is based on the
|
||||
.Xr ethers 5
|
||||
format.
|
57
sys/sys/eui64.h
Normal file
57
sys/sys/eui64.h
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2004 The Aerospace Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions, and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions, and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of The Aerospace Corporation may not be used to endorse or
|
||||
* promote products derived from this software.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AEROSPACE CORPORATION "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AEROSPACE CORPORATION BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
#ifndef _SYS_EUI64_H
|
||||
#define _SYS_EUI64_H
|
||||
|
||||
/*
|
||||
* Size of the ASCII representation of an EUI-64.
|
||||
*/
|
||||
#define EUI64_SIZ 24
|
||||
|
||||
/*
|
||||
* The number of bytes in an EUI-64.
|
||||
*/
|
||||
#define EUI64_LEN 8
|
||||
|
||||
/*
|
||||
* Structure of an IEEE EUI-64.
|
||||
*/
|
||||
struct eui64 {
|
||||
u_char octet[EUI64_LEN];
|
||||
};
|
||||
|
||||
#ifndef _KERNEL
|
||||
int eui64_aton(const char *, struct eui64 *);
|
||||
int eui64_ntoa(const struct eui64 *, char *, size_t);
|
||||
int eui64_ntohost(char *, size_t, const struct eui64 *);
|
||||
int eui64_hostton(const char *, struct eui64 *);
|
||||
#endif /* !_KERNEL */
|
||||
|
||||
#endif /* !_SYS_EUI64_H */
|
12
tools/regression/lib/libc/net/Makefile
Normal file
12
tools/regression/lib/libc/net/Makefile
Normal file
@ -0,0 +1,12 @@
|
||||
# $FreeBSD$
|
||||
|
||||
TESTS= test-eui64_aton test-eui64_line test-eui64_ntoa
|
||||
CFLAGS= -g -Wall
|
||||
|
||||
.PHONY: tests
|
||||
tests: ${TESTS}
|
||||
for p in ${TESTS}; do ${.OBJDIR}/$$p; done
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-rm -f ${TESTS}
|
110
tools/regression/lib/libc/net/test-eui64.h
Normal file
110
tools/regression/lib/libc/net/test-eui64.h
Normal file
@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright 2004 The Aerospace Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions, and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions, and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of The Aerospace Corporation may not be used to endorse or
|
||||
* promote products derived from this software.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AEROSPACE CORPORATION "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AEROSPACE CORPORATION BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
#ifndef _TEST_EUI64_H
|
||||
#define _TEST_EUI64_H
|
||||
|
||||
struct eui64 test_eui64_id = {{0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77}};
|
||||
struct eui64 test_eui64_eui48 = {{0x00,0x11,0x22,0xFF,0xFE,0x33,0x44,0x55}};
|
||||
struct eui64 test_eui64_mac48 = {{0x00,0x11,0x22,0xFF,0xFF,0x33,0x44,0x55}};
|
||||
|
||||
#define test_eui64_id_ascii "00-11-22-33-44-55-66-77"
|
||||
#define test_eui64_id_colon_ascii "00:11:22:33:44:55:66:77"
|
||||
#define test_eui64_hex_ascii "0x0011223344556677"
|
||||
#define test_eui64_eui48_ascii "00-11-22-ff-fe-33-44-55"
|
||||
#define test_eui64_mac48_ascii "00-11-22-ff-fe-33-44-55"
|
||||
#define test_eui64_mac_ascii "00-11-22-33-44-55"
|
||||
#define test_eui64_mac_colon_ascii "00:11:22:33:44:55"
|
||||
#define test_eui64_id_host "id"
|
||||
#define test_eui64_eui48_host "eui-48"
|
||||
#define test_eui64_mac48_host "mac-48"
|
||||
|
||||
#define test_eui64_line_id "00-11-22-33-44-55-66-77 id"
|
||||
#define test_eui64_line_id_colon "00:11:22:33:44:55:66:77 id"
|
||||
#define test_eui64_line_eui48 "00-11-22-FF-fe-33-44-55 eui-48"
|
||||
#define test_eui64_line_mac48 "00-11-22-FF-ff-33-44-55 mac-48"
|
||||
#define test_eui64_line_eui48_6byte "00-11-22-33-44-55 eui-48"
|
||||
#define test_eui64_line_eui48_6byte_c "00:11:22:33:44:55 eui-48"
|
||||
|
||||
#endif /* !_TEST_EUI64_H */
|
||||
/*
|
||||
* Copyright 2004 The Aerospace Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions, and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions, and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of The Aerospace Corporation may not be used to endorse or
|
||||
* promote products derived from this software.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AEROSPACE CORPORATION "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AEROSPACE CORPORATION BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
#ifndef _TEST_EUI64_H
|
||||
#define _TEST_EUI64_H
|
||||
|
||||
struct eui64 test_eui64_id = {{0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77}};
|
||||
struct eui64 test_eui64_eui48 = {{0x00,0x11,0x22,0xFF,0xFE,0x33,0x44,0x55}};
|
||||
struct eui64 test_eui64_mac48 = {{0x00,0x11,0x22,0xFF,0xFF,0x33,0x44,0x55}};
|
||||
|
||||
#define test_eui64_id_ascii "00-11-22-33-44-55-66-77"
|
||||
#define test_eui64_id_colon_ascii "00:11:22:33:44:55:66:77"
|
||||
#define test_eui64_hex_ascii "0x0011223344556677"
|
||||
#define test_eui64_eui48_ascii "00-11-22-ff-fe-33-44-55"
|
||||
#define test_eui64_mac48_ascii "00-11-22-ff-fe-33-44-55"
|
||||
#define test_eui64_mac_ascii "00-11-22-33-44-55"
|
||||
#define test_eui64_mac_colon_ascii "00:11:22:33:44:55"
|
||||
#define test_eui64_id_host "id"
|
||||
#define test_eui64_eui48_host "eui-48"
|
||||
#define test_eui64_mac48_host "mac-48"
|
||||
|
||||
#define test_eui64_line_id "00-11-22-33-44-55-66-77 id"
|
||||
#define test_eui64_line_id_colon "00:11:22:33:44:55:66:77 id"
|
||||
#define test_eui64_line_eui48 "00-11-22-FF-fe-33-44-55 eui-48"
|
||||
#define test_eui64_line_mac48 "00-11-22-FF-ff-33-44-55 mac-48"
|
||||
#define test_eui64_line_eui48_6byte "00-11-22-33-44-55 eui-48"
|
||||
#define test_eui64_line_eui48_6byte_c "00:11:22:33:44:55 eui-48"
|
||||
|
||||
#endif /* !_TEST_EUI64_H */
|
136
tools/regression/lib/libc/net/test-eui64_aton.c
Normal file
136
tools/regression/lib/libc/net/test-eui64_aton.c
Normal file
@ -0,0 +1,136 @@
|
||||
/*
|
||||
* Copyright 2004 The Aerospace Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions, and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions, and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of The Aerospace Corporation may not be used to endorse or
|
||||
* promote products derived from this software.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AEROSPACE CORPORATION "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AEROSPACE CORPORATION BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/eui64.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "test-eui64.h"
|
||||
|
||||
static int
|
||||
test_str( const char *str, const struct eui64 *eui)
|
||||
{
|
||||
struct eui64 e;
|
||||
char buf[EUI64_SIZ];
|
||||
|
||||
if (eui64_aton(str, &e) != 0 &&
|
||||
memcmp(&e, &eui, sizeof(struct eui64)) != 0) {
|
||||
printf("FAIL: eui64_aton(%s)\n", str);
|
||||
eui64_ntoa(&e, buf, sizeof(buf));
|
||||
printf("got: %s\n", buf);
|
||||
return (0);
|
||||
} else {
|
||||
printf("PASS: eui64_aton(%s)\n", str);
|
||||
return (1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
|
||||
test_str(test_eui64_id_ascii, &test_eui64_id);
|
||||
test_str(test_eui64_id_colon_ascii, &test_eui64_id);
|
||||
test_str(test_eui64_mac_ascii, &test_eui64_eui48);
|
||||
test_str(test_eui64_mac_colon_ascii, &test_eui64_eui48);
|
||||
test_str(test_eui64_hex_ascii, &test_eui64_id);
|
||||
|
||||
return (0);
|
||||
}
|
||||
/*
|
||||
* Copyright 2004 The Aerospace Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions, and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions, and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of The Aerospace Corporation may not be used to endorse or
|
||||
* promote products derived from this software.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AEROSPACE CORPORATION "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AEROSPACE CORPORATION BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/eui64.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "test-eui64.h"
|
||||
|
||||
static int
|
||||
test_str( const char *str, const struct eui64 *eui)
|
||||
{
|
||||
struct eui64 e;
|
||||
char buf[EUI64_SIZ];
|
||||
|
||||
if (eui64_aton(str, &e) != 0 &&
|
||||
memcmp(&e, &eui, sizeof(struct eui64)) != 0) {
|
||||
printf("FAIL: eui64_aton(%s)\n", str);
|
||||
eui64_ntoa(&e, buf, sizeof(buf));
|
||||
printf("got: %s\n", buf);
|
||||
return (0);
|
||||
} else {
|
||||
printf("PASS: eui64_aton(%s)\n", str);
|
||||
return (1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
|
||||
test_str(test_eui64_id_ascii, &test_eui64_id);
|
||||
test_str(test_eui64_id_colon_ascii, &test_eui64_id);
|
||||
test_str(test_eui64_mac_ascii, &test_eui64_eui48);
|
||||
test_str(test_eui64_mac_colon_ascii, &test_eui64_eui48);
|
||||
test_str(test_eui64_hex_ascii, &test_eui64_id);
|
||||
|
||||
return (0);
|
||||
}
|
152
tools/regression/lib/libc/net/test-eui64_line.c
Normal file
152
tools/regression/lib/libc/net/test-eui64_line.c
Normal file
@ -0,0 +1,152 @@
|
||||
/*
|
||||
* Copyright 2004 The Aerospace Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions, and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions, and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of The Aerospace Corporation may not be used to endorse or
|
||||
* promote products derived from this software.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AEROSPACE CORPORATION "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AEROSPACE CORPORATION BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/eui64.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "test-eui64.h"
|
||||
|
||||
static int
|
||||
test_line(const char *line, const struct eui64 *eui, const char *host)
|
||||
{
|
||||
struct eui64 e;
|
||||
char buf[256];
|
||||
|
||||
if (eui64_line(line, &e, buf, sizeof(buf)) != 0 ||
|
||||
memcmp(&e, eui, sizeof(struct eui64)) != 0 ||
|
||||
strcmp(buf, host) != 0) {
|
||||
printf("FAIL: eui64_line(\"%s\")\n", line);
|
||||
printf("host = %s\n", buf);
|
||||
eui64_ntoa(&e, buf, sizeof(buf));
|
||||
printf("e = %s\n", buf);
|
||||
return (0);
|
||||
} else {
|
||||
printf("PASS: eui64_line(\"%s\")\n", line);
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
|
||||
test_line(test_eui64_line_id, &test_eui64_id,
|
||||
test_eui64_id_host);
|
||||
test_line(test_eui64_line_id_colon, &test_eui64_id,
|
||||
test_eui64_id_host);
|
||||
test_line(test_eui64_line_eui48, &test_eui64_eui48,
|
||||
test_eui64_eui48_host);
|
||||
test_line(test_eui64_line_mac48, &test_eui64_mac48,
|
||||
test_eui64_mac48_host);
|
||||
test_line(test_eui64_line_eui48_6byte, &test_eui64_eui48,
|
||||
test_eui64_eui48_host);
|
||||
test_line(test_eui64_line_eui48_6byte_c, &test_eui64_eui48,
|
||||
test_eui64_eui48_host);
|
||||
|
||||
return (0);
|
||||
}
|
||||
/*
|
||||
* Copyright 2004 The Aerospace Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions, and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions, and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of The Aerospace Corporation may not be used to endorse or
|
||||
* promote products derived from this software.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AEROSPACE CORPORATION "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AEROSPACE CORPORATION BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/eui64.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "test-eui64.h"
|
||||
|
||||
static int
|
||||
test_line(const char *line, const struct eui64 *eui, const char *host)
|
||||
{
|
||||
struct eui64 e;
|
||||
char buf[256];
|
||||
|
||||
if (eui64_line(line, &e, buf, sizeof(buf)) != 0 ||
|
||||
memcmp(&e, eui, sizeof(struct eui64)) != 0 ||
|
||||
strcmp(buf, host) != 0) {
|
||||
printf("FAIL: eui64_line(\"%s\")\n", line);
|
||||
printf("host = %s\n", buf);
|
||||
eui64_ntoa(&e, buf, sizeof(buf));
|
||||
printf("e = %s\n", buf);
|
||||
return (0);
|
||||
} else {
|
||||
printf("PASS: eui64_line(\"%s\")\n", line);
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
|
||||
test_line(test_eui64_line_id, &test_eui64_id,
|
||||
test_eui64_id_host);
|
||||
test_line(test_eui64_line_id_colon, &test_eui64_id,
|
||||
test_eui64_id_host);
|
||||
test_line(test_eui64_line_eui48, &test_eui64_eui48,
|
||||
test_eui64_eui48_host);
|
||||
test_line(test_eui64_line_mac48, &test_eui64_mac48,
|
||||
test_eui64_mac48_host);
|
||||
test_line(test_eui64_line_eui48_6byte, &test_eui64_eui48,
|
||||
test_eui64_eui48_host);
|
||||
test_line(test_eui64_line_eui48_6byte_c, &test_eui64_eui48,
|
||||
test_eui64_eui48_host);
|
||||
|
||||
return (0);
|
||||
}
|
104
tools/regression/lib/libc/net/test-eui64_ntoa.c
Normal file
104
tools/regression/lib/libc/net/test-eui64_ntoa.c
Normal file
@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright 2004 The Aerospace Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions, and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions, and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of The Aerospace Corporation may not be used to endorse or
|
||||
* promote products derived from this software.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AEROSPACE CORPORATION "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AEROSPACE CORPORATION BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/eui64.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "test-eui64.h"
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
char a[EUI64_SIZ];
|
||||
|
||||
if (eui64_ntoa(&test_eui64_id, a, sizeof(a)) == 0 &&
|
||||
strcmp(a, test_eui64_id_ascii) == 0) {
|
||||
printf("PASS: eui64_ntoa\n");
|
||||
return (0);
|
||||
}
|
||||
printf("a = '%s'\n", a);
|
||||
|
||||
printf("FAIL: eui64_ntoa\n");
|
||||
return (0);
|
||||
}
|
||||
/*
|
||||
* Copyright 2004 The Aerospace Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions, and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions, and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of The Aerospace Corporation may not be used to endorse or
|
||||
* promote products derived from this software.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AEROSPACE CORPORATION "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AEROSPACE CORPORATION BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/eui64.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "test-eui64.h"
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
char a[EUI64_SIZ];
|
||||
|
||||
if (eui64_ntoa(&test_eui64_id, a, sizeof(a)) == 0 &&
|
||||
strcmp(a, test_eui64_id_ascii) == 0) {
|
||||
printf("PASS: eui64_ntoa\n");
|
||||
return (0);
|
||||
}
|
||||
printf("a = '%s'\n", a);
|
||||
|
||||
printf("FAIL: eui64_ntoa\n");
|
||||
return (0);
|
||||
}
|
Loading…
Reference in New Issue
Block a user