ETHERS(3) BSD Library Functions Manual ETHERS(3)
NAME
ethers, etherline, etheraton, etherntoa, etherntohost, etherhostton
-- Ethernet address conversion and lookup routines
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
##include <>
##include <>
##include <>
int
etherline(const char *l, struct etheraddr *e, char *hostname);
struct etheraddr *
etheraton(const char *a);
char *
etherntoa(const struct etheraddr *n);
int
etherntohost(char *hostname, const struct etheraddr *e);
int
etherhostton(const char *hostname, struct etheraddr *e);
DESCRIPTION
These functions operate on ethernet addresses using an etheraddr struc-
ture, which is defined in the header file :
/*
* The number of bytes in an ethernet (MAC) address.
*/
#define ETHERADRLEN 6
/*
* Structure of a 48-bit Ethernet address.
*/
struct etheraddr {
uchar octet[ETHERADRLEN];
};
The function etherline() scans l, an ASCI string in ethers(5) format
and sets e to the ethernet address specified in the string and h to the
hostname. This function is used to parse lines from /etc/ethers into
their component parts.
The etheraton() function converts an ASCI representation of an ethernet
address into an etheraddr structure. Likewise, etherntoa() converts an
ethernet address specified as an etheraddr structure into an ASCI
string.
The etherntohost() and etherhostton() functions map ethernet addresses
to their corresponding hostnames as specified in the /etc/ethers data-
base. etherntohost() converts from ethernet address to hostname, and
etherhostton() converts from hostname to ethernet address.
RETURN VALUES
etherline() returns zero on success and non-zero if it was unable to
parse any part of the supplied line l. It returns the extracted ethernet
address in the supplied etheraddr structure e and the hostname in the
supplied string h.
On success, etherntoa() returns a pointer to a string containing an
ASCI representation of an ethernet address. If it is unable to convert
the supplied etheraddr structure, it returns a NUL pointer. Likewise,
etheraton() returns a pointer to an etheraddr structure on success and
a NUL pointer on failure.
The etherntohost() and etherhostton() functions both return zero on
success or non-zero if they were unable to find a match in the
/etc/ethers database.
NOTES
The user must insure that the hostname strings passed to the
etherline(), etherntohost() and etherhostton() functions are large
enough to contain the returned hostnames.
NIS INTERACTION
If the /etc/ethers contains a line with a single ] in it, the
etherntohost() and etherhostton() functions will attempt to consult the
NIS ethers.byname and ethers.byaddr maps in addition to the data in the
/etc/ethers file.
SEE ALSO
yp(4), ethers(5)
BUGS
The etheraton() and etherntoa() functions returns values that are
stored in static memory areas which may be overwritten the next time they
are called.
HISTORY
This particular implementation of the ethers library functions were writ-
ten for and first appeared in FreeBSD 2.1.
BSD April 12, 1995 BSD
|