4 ** This routine parses the array pointed to by "line" (which should be
5 ** from a file in the format of /etc/ethers) and returns in "eaddr" the
6 ** ethernet address at the start of the line and the corresponding host
7 ** name in "hostname". It assumes either tabs or spaces separate the
8 ** two. The buffer pointed to by "hostname" must be big enough to hold
9 ** the host name plus a NULL byte.
10 ** The function returns 0 on success and 1 on failure.
11 ** Arguments are assumed sensible. Null pointers will probably cause
13 ** Author: Gregory J. Sharp, July 1990
14 ** Adapted to MINIX: Philip Homburg, May 1992
17 #include <sys/types.h>
20 #include <net/gen/ether.h>
21 #include <net/gen/if_ether.h>
24 ether_line(line
, eaddr
, hostname
)
26 struct ether_addr
* eaddr
;
30 register unsigned long val
;
32 /* skip leading white space */
33 while (*line
!= '\n' && (*line
== ' ' || *line
== '\t'))
36 /* read the ethernet address */
37 for (i
= 0; i
< 5; i
++)
39 val
= (unsigned long) strtol(line
, &line
, 16);
40 if (val
> 255 || *line
++ != ':')
42 eaddr
->ea_addr
[i
] = val
& 0xff;
44 val
= (unsigned long) strtol(line
, &line
, 16);
45 if (val
> 255 || (*line
!= ' ' && *line
!= '\t'))
47 eaddr
->ea_addr
[i
] = val
& 0xff;
49 /* skip leading white space */
50 while (*line
!= '\n' && (*line
== ' ' || *line
== '\t'))
53 /* read in the hostname */
54 while (!isspace(*line
))
55 *hostname
++ = *line
++;