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