summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2004-02-11 23:30:30 +0000
committerDimitri Sokolyuk <demon@dim13.org>2004-02-11 23:30:30 +0000
commita363dfe24ac5a65e4fee1ed8f6595f1e7460ce5c (patch)
tree17602b7994e1cab6ee23542260a40a4d68dc0d22
parenta5f206585eabe1ff5a76f0b57baecfec1c4ee362 (diff)
- add xname
-rw-r--r--ifstat.c4
-rw-r--r--main.c8
-rw-r--r--main.h4
-rw-r--r--output.c15
4 files changed, 16 insertions, 15 deletions
diff --git a/ifstat.c b/ifstat.c
index 3ecc60d..ecd09e0 100644
--- a/ifstat.c
+++ b/ifstat.c
@@ -22,7 +22,6 @@
#include <kvm.h>
#include <nlist.h>
#include <limits.h>
-// #include <err.h>
#include "main.h"
kvm_t *kvmd = NULL;
@@ -57,7 +56,6 @@ int if_init(char *ifname) {
if (addr == NULL)
error("interface not found");
-
}
int if_stat(void) {
@@ -66,7 +64,7 @@ int if_stat(void) {
if (kvm_read(kvmd, (unsigned long)addr, &ifnet, sizeof(ifnet)) != sizeof(ifnet))
error(kvm_geterr(kvmd));
- ifdata.xname = ifnet.if_xname;
+ strlcpy(ifdata.xname ,ifnet.if_xname, sizeof(ifdata.xname));
ifdata.baudrate = ifnet.if_baudrate;
ifdata.ipackets = ifnet.if_ipackets;
ifdata.ierrors = ifnet.if_ierrors;
diff --git a/main.c b/main.c
index 9750e10..36ad8cd 100644
--- a/main.c
+++ b/main.c
@@ -19,13 +19,7 @@
#include <curses.h>
#include "main.h"
-// extern char *__progname;
-
int main(int argc, char **argv) {
-/*
- struct stat last;
- struct stat diff;
-*/
extern struct ifdata ifdata;
struct ifdata last;
struct ifdata diff;
@@ -47,6 +41,8 @@ int main(int argc, char **argv) {
if_stat();
diff.ibytes = ifdata.ibytes - last.ibytes;
diff.obytes = ifdata.obytes - last.obytes;
+ diff.ipackets = ifdata.ipackets - last.ipackets;
+ diff.opackets = ifdata.opackets - last.opackets;
out(&diff);
last = ifdata;
usleep(1000000); /* 1s */
diff --git a/main.h b/main.h
index 896dbfe..ef06f90 100644
--- a/main.h
+++ b/main.h
@@ -17,12 +17,12 @@
#define kB 1024
#define MB (kB*1024)
-// #define IFNAMSIZ 16
+#define NAMSIZ 16
extern char *__progname;
struct ifdata {
- char *xname;
+ char xname[NAMSIZ];
u_long baudrate;
u_long ipackets;
u_long ierrors;
diff --git a/output.c b/output.c
index 8b4faee..f0ff6ae 100644
--- a/output.c
+++ b/output.c
@@ -20,15 +20,22 @@
int out(struct ifdata *diff) {
extern struct ifdata ifdata;
+ WINDOW *scr;
move(0,0);
// clear();
- printw("I: %ld\n", diff->ibytes);
- printw("O: %ld\n", diff->obytes);
+ printw("IF: %s\n", ifdata.xname);
+ printw("BR: %d Mbps\n\n", ifdata.baudrate / 1000000);
- printw("I: %ld\n", ifdata.ibytes);
- printw("O: %ld\n", ifdata.obytes);
+ printw("RX: %lu kBps\n", diff->ibytes / 1024);
+ printw("TX: %lu kBps\n\n", diff->obytes / 1024);
+
+ printw("RX: %lu pps\n", diff->ipackets);
+ printw("TX: %lu pps\n\n", diff->opackets);
+
+ printw("RX: %lu MB\n", ifdata.ibytes / (1024 * 1024));
+ printw("TX: %lu MB\n", ifdata.obytes / (1024 * 1024));
refresh();
}