10 #define NETIF_BASEDIR "/sys/class/net/"
14 void status_netif(char *ifname)
27 ifpathlen = sizeof(NETIF_BASEDIR) - 1 + strlen(ifname);
28 if (ifpathlen + 1 + sizeof("/statistics/rx_bytes") >= sizeof(ifpath))
30 statusError("status_netif",
31 "ifpath buffer too small",
35 strcpy(ifpath, NETIF_BASEDIR);
36 strcat(ifpath, ifname);
39 // Is the interface up?
40 if (access(ifpath, F_OK))
42 //printf(" ^fg(grey)[%s] ", ifname);
47 strcpy(&ifpath[ifpathlen], "/carrier");
48 stlen = fileRead(stline, sizeof(stline), ifpath);
53 fputs("^fg(yellow)", stdout);
57 //fputs("^fg(red)", stdout);
62 strcpy(&ifpath[ifpathlen], "/statistics/rx_bytes");
63 stlen = fileRead(stline, sizeof(stline), ifpath);
67 strcpy(&ifpath[ifpathlen], "/statistics/tx_bytes");
68 stlen = fileRead(stline, sizeof(stline), ifpath);
70 ifsum += atof(stline);
73 for(ifsumpower = 0; ifsum >= 1024.0; ifsumpower++)
76 printf(" %s: %.*f %c ", ifname,
77 ifsumpower ? ifsumpower - 1 : ifsumpower,
79 powerToChar(ifsumpower));