1 #include <u.h> 2 #include <libc.h> 3 #include "ip.h" 4 5 int 6 myetheraddr(uchar *to, char *dev) 7 { 8 char buf[256]; 9 int n, fd; 10 char *ptr; 11 12 sprint(buf, "%s/1/stats", dev); 13 fd = open(buf, OREAD); 14 if(fd < 0) 15 return -1; 16 n = read(fd, buf, sizeof(buf)-1); 17 close(fd); 18 if(n <= 0) 19 return -1; 20 buf[n] = 0; 21 22 ptr = strstr(buf, "addr: "); 23 if(!ptr) 24 return -1; 25 ptr += 6; 26 27 parseether(to, ptr); 28 return 0; 29 } 30