source: trunk/minix/lib/ip/ethera2n.c@ 15

Last change on this file since 15 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 695 bytes
Line 
1/*
2ethera2n.c
3
4Convert an ASCII string with an ethernet address into a struct ether_addr.
5
6Created: Nov 17, 1992 by Philip Homburg
7*/
8
9#include <sys/types.h>
10#include <stdlib.h>
11#include <net/netlib.h>
12#include <net/gen/ether.h>
13#include <net/gen/if_ether.h>
14
15struct ether_addr *ether_aton(s)
16_CONST char *s;
17{
18 static struct ether_addr ea;
19
20 int i;
21 long v;
22 char *check;
23
24 if (s == NULL)
25 return NULL;
26
27 for (i=0; i<6; i++)
28 {
29 v= strtol(s, &check, 16);
30 if (v<0 || v>255)
31 return NULL;
32 if ((i<5 && check[0] != ':') || (i == 5 && check[0] != '\0'))
33 return NULL;
34 ea.ea_addr[i]= v;
35 s= check+1;
36 }
37 return &ea;
38}
39
40/*
41 * $PchId: ethera2n.c,v 1.3 1996/02/22 21:10:01 philip Exp $
42 */
Note: See TracBrowser for help on using the repository browser.