11 #define NETIF_BASEDIR "/sys/class/net/"
15 void status_netif(char *ifname)
28 ifpathlen = sizeof(NETIF_BASEDIR) - 1 + strlen(ifname);
29 if (ifpathlen + 1 + sizeof("/statistics/rx_bytes") >= sizeof(ifpath))
31 statusError("status_netif",
32 "ifpath buffer too small",
36 strcpy(ifpath, NETIF_BASEDIR);
37 strcat(ifpath, ifname);
40 // Is the interface up?
41 if (access(ifpath, F_OK))
43 //printf(" ^fg(grey)[%s] ", ifname);
48 strcpy(&ifpath[ifpathlen], "/carrier");
49 stlen = fileRead(stline, sizeof(stline), ifpath);
54 fputs("^fg(yellow)", stdout);
58 //fputs("^fg(red)", stdout);
63 strcpy(&ifpath[ifpathlen], "/statistics/rx_bytes");
64 stlen = fileRead(stline, sizeof(stline), ifpath);
68 strcpy(&ifpath[ifpathlen], "/statistics/tx_bytes");
69 stlen = fileRead(stline, sizeof(stline), ifpath);
71 ifsum += atof(stline);
74 for(ifsumpower = 0; ifsum >= 1024.0; ifsumpower++)
77 printf(" %s: %.*f %c ", ifname,
78 ifsumpower ? ifsumpower - 1 : ifsumpower,
80 powerToChar(ifsumpower));