summaryrefslogtreecommitdiffstats
path: root/newlib/libc/sys/linux/net/ethers.3
blob: 7b7866fd90e1753ce179caf1c2f4f8f2cd40e0f8 (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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
ETHERS(3)                          BSD Library Functions Manual                         ETHERS(3)

NAME
     ethers, ether_line, ether_aton, ether_ntoa, ether_ntohost, ether_hostton -- Ethernet address
     conversion and lookup routines

LIBRARY
     Standard C Library (libc, -lc)

SYNOPSIS
     #include <sys/types.h>
     #include <sys/socket.h>
     #include <net/ethernet.h>

     int
     ether_line(const char *l, struct ether_addr *e, char *hostname);

     struct ether_addr *
     ether_aton(const char *a);

     char *
     ether_ntoa(const struct ether_addr *n);

     int
     ether_ntohost(char *hostname, const struct ether_addr *e);

     int
     ether_hostton(const char *hostname, struct ether_addr *e);

DESCRIPTION
     These functions operate on ethernet addresses using an ether_addr structure, which is de-
     fined in the header file <netinet/if_ether.h>:

           /*
            * The number of bytes in an ethernet (MAC) address.
            */
           #define ETHER_ADDR_LEN          6

           /*
            * Structure of a 48-bit Ethernet address.
            */
           struct  ether_addr {
                   u_char octet[ETHER_ADDR_LEN];
           };

     The function ether_line() scans l, an ASCII string in ethers(5) format and sets e to the
     ethernet address specified in the string and h to the hostname.  This function is used to
     parse lines from /etc/ethers into their component parts.

     The ether_aton() function converts an ASCII representation of an ethernet address into an
     ether_addr structure.  Likewise, ether_ntoa() converts an ethernet address specified as an
     ether_addr structure into an ASCII string.

     The ether_ntohost() and ether_hostton() functions map ethernet addresses to their corre-
     sponding hostnames as specified in the /etc/ethers database.  ether_ntohost() converts from
     ethernet address to hostname, and ether_hostton() converts from hostname to ethernet ad-
     dress.

RETURN VALUES
     ether_line() returns zero on success and non-zero if it was unable to parse any part of the
     supplied line l.  It returns the extracted ethernet address in the supplied ether_addr
     structure e and the hostname in the supplied string h.

     On success, ether_ntoa() returns a pointer to a string containing an ASCII representation of
     an ethernet address.  If it is unable to convert the supplied ether_addr structure, it re-
     turns a NULL pointer.  Likewise, ether_aton() returns a pointer to an ether_addr structure
     on success and a NULL pointer on failure.

     The ether_ntohost() and ether_hostton() functions both return zero on success or non-zero if
     they were unable to find a match in the /etc/ethers database.

NOTES
     The user must insure that the hostname strings passed to the ether_line(), ether_ntohost()
     and ether_hostton() functions are large enough to contain the returned hostnames.

NIS INTERACTION
     If the /etc/ethers contains a line with a single + in it, the ether_ntohost() and
     ether_hostton() functions will attempt to consult the NIS ethers.byname and ethers.byaddr
     maps in addition to the data in the /etc/ethers file.

SEE ALSO
     ethers(5), yp(8)

BUGS
     The ether_aton() and ether_ntoa() functions returns values that are stored in static memory
     areas which may be overwritten the next time they are called.

HISTORY
     This particular implementation of the ethers library functions were written for and first
     appeared in FreeBSD 2.1.

BSD                                       April 12, 1995                                      BSD