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