1.\" $NetBSD: ethers.3,v 1.5 1997/11/14 02:04:44 mrg Exp $ 2.\" 3.\" Written by roland@frob.com. Public domain. 4.\" 5.Dd November 2, 1997 6.Dt ETHERS 3 7.Os NetBSD 8.Sh NAME 9.Nm ether_ntoa , 10.Nm ether_aton , 11.Nm ether_ntohost , 12.Nm ether_hostton , 13.Nm ether_line , 14.Nd get ethers entry 15.Sh SYNOPSIS 16.Fd #include <net/if_ether.h> 17.Ft char * 18.Fn ether_ntoa "struct ether_addr *e" 19.Ft struct ether_addr * 20.Fn ether_aton "const char *s" 21.Ft int 22.Fn ether_ntohost "char *hostname" "struct ether_addr *e" 23.Ft int 24.Fn ether_hostton "const char *hostname" "struct ether_addr *e" 25.Ft int 26.Fn ether_line "const char *line" "struct ether_addr *e" "char *hostname" 27.Sh DESCRIPTION 28Ethernet addresses are represented by the 29following structure: 30.Bd -literal -offset indent 31struct ether_addr { 32 u_char ether_addr_octet[6]; 33}; 34.Ed 35.Pp 36The 37.Fn ether_ntoa 38function converts this structure into an ASCII string of the form 39``xx:xx:xx:xx:xx:xx'', consisting of 6 hexadecimal numbers separated 40by colons. It returns a pointer to a static buffer that is reused for 41each call. 42The 43.Fn ether_aton 44converts an ASCII string of the same form and to a structure 45containing the 6 octets of the address. It returns a pointer to a 46static structure that is reused for each call. 47.Pp 48The 49.Fn ether_ntohost 50and 51.Fn ether_hostton 52functions interrogate the data base mapping host names to Ethernet 53addresses, 54.Pa /etc/ethers . 55The 56.Fn ether_ntohost 57function looks up the given Ethernet address and writes the associated 58host name into the character buffer passed. 59The 60.Fn ether_hostton 61function looks up the given host name and writes the associated 62Ethernet address into the structure passed. Both functions return 63zero if they find the requested host name or address, and -1 if not. 64Each call reads 65.Pa /etc/ethers 66from the beginning; if a + appears alone on a line in the file, then 67.Fn ether_hostton 68will consult the 69.Pa ethers.byname 70YP map, and 71.Fn ether_ntohost 72will consult the 73.Pa ethers.byaddr 74YP map. 75.Pp 76The 77.Fn ether_line 78function parses a line from the 79.Pa /etc/ethers 80file and fills in the passed ``struct ether_addr'' and character 81buffer with the Ethernet address and host name on the line. It 82returns zero if the line was successfully parsed and -1 if not. 83.Pp 84The 85.Fa hostname 86buffer for 87.Fn ether_line 88and 89.Fn ether_ntohost 90should be at least 91.Dv MAXHOSTNAMELEN 92+ 1 93characters long, to prevent a buffer overflow during parsing. 94.Sh FILES 95.Bl -tag -width /etc/ethers -compact 96.It Pa /etc/ethers 97.El 98.Sh SEE ALSO 99.Xr ethers 5 100.Sh HISTORY 101The 102.Fn ether_ntoa , 103.Fn ether_aton , 104.Fn ether_ntohost , 105.Fn ether_hostton , 106and 107.Fn ether_line 108functions were adopted from SunOS and appeared in 109NetBSD 0.9b. 110.Sh BUGS 111The data space used by these functions is static; if future use 112requires the data, it should be copied before any subsequent calls to 113these functions overwrite it. 114