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)) {
29 statusError("status_netif",
30 "ifpath buffer too small",
34 strcpy(ifpath, NETIF_BASEDIR);
35 strcat(ifpath, ifname);
38 /* Is the interface up? */
39 if (access(ifpath, F_OK)) {
40 //printf(" ^fg(grey)[%s] ", ifname);
45 strcpy(&ifpath[ifpathlen], "/carrier");
46 stlen = fileRead(stline, sizeof(stline), ifpath);
48 if (stline[0] == '1') {
49 fputs("^fg(yellow)", stdout);
51 //fputs("^fg(red)", stdout);
58 strcpy(&ifpath[ifpathlen], "/statistics/rx_bytes");
59 stlen = fileRead(stline, sizeof(stline), ifpath);
64 strcpy(&ifpath[ifpathlen], "/statistics/tx_bytes");
65 stlen = fileRead(stline, sizeof(stline), ifpath);
67 ifsum += atof(stline);
71 for(ifsumpower = 0; ifsum >= 1024.0; ifsumpower++) {
75 printf(" %s: %.*f %c ", ifname,
76 ifsumpower ? ifsumpower - 1 : ifsumpower,
78 powerToChar(ifsumpower));