xref: /plan9/sys/src/libip/parseether.c (revision 3e12c5d1bb89fc02707907988834ef147769ddaf)
1 #include <u.h>
2 #include <libc.h>
3 
4 int
parseether(uchar * to,char * from)5 parseether(uchar *to, char *from)
6 {
7 	char nip[4];
8 	char *p;
9 	int i;
10 
11 	p = from;
12 	for(i = 0; i < 6; i++){
13 		if(*p == 0)
14 			return -1;
15 		nip[0] = *p++;
16 		if(*p == 0)
17 			return -1;
18 		nip[1] = *p++;
19 		nip[2] = 0;
20 		to[i] = strtoul(nip, 0, 16);
21 		if(*p == ':')
22 			p++;
23 	}
24 	return 0;
25 }
26