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