Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

ethers(3) [netbsd man page]

ETHERS(3)						   BSD Library Functions Manual 						 ETHERS(3)

NAME
ether_ntoa, ether_aton, ether_ntohost, ether_hostton, ether_line, -- get ethers entry LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <sys/types.h> #include <sys/socket.h> #include <net/if.h> #include <net/if_ether.h> char * ether_ntoa(const struct ether_addr *e); struct ether_addr * ether_aton(const char *s); int ether_ntohost(char *hostname, const struct ether_addr *e); int ether_hostton(const char *hostname, struct ether_addr *e); int ether_line(const char *line, struct ether_addr *e, char *hostname); DESCRIPTION
Ethernet addresses are represented by the following structure: struct ether_addr { u_char ether_addr_octet[6]; }; The ether_ntoa() function converts this structure into an ASCII string of the form ``xx:xx:xx:xx:xx:xx'', consisting of 6 hexadecimal numbers separated by colons. It returns a pointer to a static buffer that is reused for each call. The ether_aton() converts an ASCII string of the same form and to a structure containing the 6 octets of the address. It returns a pointer to a static structure that is reused for each call. The ether_ntohost() and ether_hostton() functions interrogate the data base mapping host names to Ethernet addresses, /etc/ethers. The ether_ntohost() function looks up the given Ethernet address and writes the associated host name into the character buffer passed. The ether_hostton() function looks up the given host name and writes the associated Ethernet address into the structure passed. Both functions return zero if they find the requested host name or address, and -1 if not. Each call reads /etc/ethers from the beginning; if a + appears alone on a line in the file, then ether_hostton() will consult the ethers.byname YP map, and ether_ntohost() will consult the ethers.byaddr YP map. The ether_line() function parses a line from the /etc/ethers file and fills in the passed ``struct ether_addr'' and character buffer with the Ethernet address and host name on the line. It returns zero if the line was successfully parsed and -1 if not. The hostname buffer for ether_line() and ether_ntohost() should be at least MAXHOSTNAMELEN + 1 characters long, to prevent a buffer overflow during parsing. FILES
/etc/ethers SEE ALSO
ethers(5) HISTORY
The ether_ntoa(), ether_aton(), ether_ntohost(), ether_hostton(), and ether_line() functions were adopted from SunOS and appeared in NetBSD 1.0. BUGS
The data space used by these functions is static; if future use requires the data, it should be copied before any subsequent calls to these functions overwrite it. BSD
November 2, 1997 BSD

Check Out this Related Man Page

ETHERS(3)						   BSD Library Functions Manual 						 ETHERS(3)

NAME
ethers, ether_line, ether_aton, ether_ntoa, ether_ntohost, ether_hostton -- Ethernet address conversion and lookup routines LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <sys/types.h> #include <sys/socket.h> #include <net/ethernet.h> int ether_line(const char *l, struct ether_addr *e, char *hostname); struct ether_addr * ether_aton(const char *a); char * ether_ntoa(const struct ether_addr *n); int ether_ntohost(char *hostname, const struct ether_addr *e); int ether_hostton(const char *hostname, struct ether_addr *e); DESCRIPTION
These functions operate on ethernet addresses using an ether_addr structure, which is defined in the header file <netinet/if_ether.h>: /* * The number of bytes in an ethernet (MAC) address. */ #define ETHER_ADDR_LEN 6 /* * Structure of a 48-bit Ethernet address. */ struct ether_addr { u_char octet[ETHER_ADDR_LEN]; }; The function ether_line() scans l, an ASCII 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 ether_aton() function converts an ASCII representation of an ethernet address into an ether_addr structure. Likewise, ether_ntoa() con- verts an ethernet address specified as an ether_addr structure into an ASCII string. The ether_ntohost() and ether_hostton() functions map ethernet addresses to their corresponding hostnames as specified in the /etc/ethers database. ether_ntohost() converts from ethernet address to hostname, and ether_hostton() converts from hostname to ethernet address. RETURN VALUES
ether_line() returns zero on success and non-zero if it was unable to parse any part of the supplied line l. It returns the extracted ether- net address in the supplied ether_addr structure e and the hostname in the supplied string h. On success, ether_ntoa() returns a pointer to a string containing an ASCII representation of an ethernet address. If it is unable to convert the supplied ether_addr structure, it returns a NULL pointer. Likewise, ether_aton() returns a pointer to an ether_addr structure on success and a NULL pointer on failure. The ether_ntohost() and ether_hostton() 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 ether_line(), ether_ntohost() and ether_hostton() functions are large enough to contain the returned hostnames. NIS INTERACTION
If the /etc/ethers contains a line with a single + in it, the ether_ntohost() and ether_hostton() 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(8), ethers(5) BUGS
The ether_aton() and ether_ntoa() 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 written for and first appeared in FreeBSD 2.1. BSD
April 12, 1995 BSD
Man Page