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);
64 strcpy(&ifpath[ifpathlen], "/statistics/rx_bytes");
65 stlen = fileRead(stline, sizeof(stline), ifpath);
69 strcpy(&ifpath[ifpathlen], "/statistics/tx_bytes");
70 stlen = fileRead(stline, sizeof(stline), ifpath);
72 ifsum += atof(stline);
75 for(ifsumpower = 0; ifsum >= 1024.0; ifsumpower++)
78 printf(" %s: %.*f %c ", ifname,
79 ifsumpower ? ifsumpower - 1 : ifsumpower,
81 powerToChar(ifsumpower));