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