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.380
1 files changed, 50 insertions, 30 deletions
diff --git a/src/lib/libc/net/ethers.3 b/src/lib/libc/net/ethers.3
index 81e6c65935..435a52696a 100644
--- a/src/lib/libc/net/ethers.3
+++ b/src/lib/libc/net/ethers.3
@@ -1,65 +1,85 @@
1.\" $OpenBSD: ethers.3,v 1.19 2007/05/31 19:19:30 jmc Exp $
1.\" 2.\"
2.\" Written by roland@frob.com. Public domain. 3.\" Written by roland@frob.com. Public domain.
3.\" 4.\"
4.Dd December 16, 1993 5.Dd $Mdocdate: May 31 2007 $
5.Dt ETHERS 3 6.Dt ETHERS 3
6.Os NetBSD 7.Os
7.Sh NAME 8.Sh NAME
9.Nm ether_aton ,
8.Nm ether_ntoa , 10.Nm ether_ntoa ,
9.Nm ether_addr ,
10.Nm ether_ntohost , 11.Nm ether_ntohost ,
11.Nm ether_hostton , 12.Nm ether_hostton ,
12.Nm ether_line , 13.Nm ether_line
13.Nd get ethers entry 14.Nd get ethers entry
14.Sh SYNOPSIS 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>
15.Fd #include <netinet/if_ether.h> 20.Fd #include <netinet/if_ether.h>
16.Ft char * 21.Ft char *
17.Fn ether_ntoa "struct ether_addr *e" 22.Fn ether_ntoa "struct ether_addr *e"
18.Ft struct ether_addr * 23.Ft struct ether_addr *
19.Fn ether_aton "char *s" 24.Fn ether_aton "const char *s"
25.Ft int
20.Fn ether_ntohost "char *hostname" "struct ether_addr *e" 26.Fn ether_ntohost "char *hostname" "struct ether_addr *e"
21.Fn ether_hostton "char *hostname" "struct ether_addr *e" 27.Ft int
22.Fn ether_line "char *l" "struct ether_addr *e" "char *hostname" 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"
23.Sh DESCRIPTION 31.Sh DESCRIPTION
24Ethernet addresses are represented by the 32Ethernet addresses are represented by the
25following structure: 33following structure:
26.Bd -literal -offset indent 34.Bd -literal -offset indent
27struct ether_addr { 35struct ether_addr {
28 u_char ether_addr_octet[6]; 36 u_int8_t ether_addr_octet[6];
29}; 37};
30.Ed 38.Ed
31.Pp 39.Pp
32The 40The
33.Fn ether_ntoa 41.Fn ether_ntoa
34function converts this structure into an ASCII string of the form 42function converts this structure into an
35``xx:xx:xx:xx:xx:xx'', consisting of 6 hexadecimal numbers separated 43.Tn ASCII
36by colons. It returns a pointer to a static buffer that is reused for 44string of the form
37each call. 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.
38The 49The
39.Fn ether_aton 50.Fn ether_aton
40converts an ASCII string of the same form and to a structure 51converts an
41containing the 6 octets of the address. It returns a pointer to a 52.Tn ASCII
42static structure that is reused for each call. 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.
43.Pp 56.Pp
44The 57The
45.Fn ether_ntohost 58.Fn ether_ntohost
46and 59and
47.Fn ether_hostton 60.Fn ether_hostton
48functions interrogate the data base mapping host names to Ethernet 61functions interrogate the database mapping host names to Ethernet
49addresses, 62addresses,
50.Pa /etc/ethers . 63.Pa /etc/ethers .
51The 64The
52.Fn ether_ntohost 65.Fn ether_ntohost
53function looks up the given Ethernet address and writes the associated 66function looks up the given Ethernet address and writes the associated
54host name into the character buffer passed. 67host name into the character buffer passed.
68This buffer should be
69.Dv MAXHOSTNAMELEN
70characters in size.
55The 71The
56.Fn ether_hostton 72.Fn ether_hostton
57function looks up the given host name and writes the associated 73function looks up the given host name and writes the associated
58Ethernet address into the structure passed. Both functions return 74Ethernet address into the structure passed.
59zero if they find the requested host name or address, and -1 if not. 75Both functions return
76zero if they find the requested host name or address, and \-1 if not.
77.Pp
60Each call reads 78Each call reads
61.Pa /etc/ethers 79.Pa /etc/ethers
62from the beginning; if a + appears alone on a line in the file, then 80from the beginning; if a
81.Ql +
82appears alone on a line in the file, then
63.Fn ether_hostton 83.Fn ether_hostton
64will consult the 84will consult the
65.Pa ethers.byname 85.Pa ethers.byname
@@ -73,9 +93,13 @@ The
73.Fn ether_line 93.Fn ether_line
74function parses a line from the 94function parses a line from the
75.Pa /etc/ethers 95.Pa /etc/ethers
76file and fills in the passed ``struct ether_addr'' and character 96file and fills in the passed
77buffer with the Ethernet address and host name on the line. It 97.Li struct ether_addr
78returns zero if the line was successfully parsed and -1 if not. 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.
79.Sh FILES 103.Sh FILES
80.Bl -tag -width /etc/ethers -compact 104.Bl -tag -width /etc/ethers -compact
81.It Pa /etc/ethers 105.It Pa /etc/ethers
@@ -91,12 +115,8 @@ The
91and 115and
92.Fn ether_line 116.Fn ether_line
93functions were adopted from SunOS and appeared in 117functions were adopted from SunOS and appeared in
94NetBSD 0.9b. 118.Nx 0.9 b.
95.Sh BUGS 119.Sh BUGS
96The data space used by these functions is static; if future use 120The data space used by these functions is static; if future use
97requires the data, it should be copied before any subsequent calls to 121requires the data, it should be copied before any subsequent calls to
98these functions overwrite it. There is no way to restrict how many 122these functions overwrite it.
99character will be written into the host name buffer passed. A very
100long line in
101.Pa /etc/ethers
102could overflow your buffer.