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