aboutsummaryrefslogtreecommitdiffstats
path: root/system.c
diff options
context:
space:
mode:
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2000-05-21 06:20:35 +0000
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2000-05-21 06:20:35 +0000
commit2c5d16713862968233858a2430deb67fd485078a (patch)
treefb12e6c8544f51e3a8837813c0bccc4443f755c1 /system.c
parent4b2b6ee2f0eed08a6e9117d343360e778734f26e (diff)
downloadlcd4linux-2c5d16713862968233858a2430deb67fd485078a.tar.gz
[lcd4linux @ 2000-05-21 06:20:35 by reinelt]
added ppp throughput token is '%t[iomt]' at the moment, but this will change in the near future git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@57 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
Diffstat (limited to 'system.c')
-rw-r--r--system.c50
1 files changed, 49 insertions, 1 deletions
diff --git a/system.c b/system.c
index 5db5c1b..5d9f3d3 100644
--- a/system.c
+++ b/system.c
@@ -1,4 +1,4 @@
-/* $Id: system.c,v 1.11 2000/04/15 11:56:35 reinelt Exp $
+/* $Id: system.c,v 1.12 2000/05/21 06:20:35 reinelt Exp $
*
* system status retreivement
*
@@ -20,6 +20,11 @@
*
*
* $Log: system.c,v $
+ * Revision 1.12 2000/05/21 06:20:35 reinelt
+ *
+ * added ppp throughput
+ * token is '%t[iomt]' at the moment, but this will change in the near future
+ *
* Revision 1.11 2000/04/15 11:56:35 reinelt
*
* more debug messages
@@ -110,6 +115,10 @@
* sets number of packets received and transmitted
* returns 0 if ok, -1 on error
*
+ * int PPP (int unit, int *rx, int *tx);
+ * sets number of packets received and transmitted
+ * returns 0 if ok, -1 on error
+ *
* int Sensor (int index, double *val, double *min, double *max)
* sets the current value of the index'th sensor and
* the minimum and maximum values from the config file
@@ -129,6 +138,9 @@
#include <sys/types.h>
#include <sys/utsname.h>
#include <sys/param.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <net/if_ppp.h>
#include "debug.h"
#include "cfg.h"
@@ -548,6 +560,42 @@ int Net (int *rx, int *tx)
return 0;
}
+int PPP (int unit, int *rx, int *tx)
+{
+ static int fd=-2;
+ struct ifpppstatsreq req;
+ char buffer[16];
+
+ *rx=0;
+ *tx=0;
+
+ if (fd==-1) return -1;
+
+ if (fd==-2) {
+ fd = socket(AF_INET, SOCK_DGRAM, 0);
+ if (fd==-1) {
+ perror ("socket() failed");
+ return -1;
+ }
+ debug ("socket()=%d\n", fd);
+ }
+
+ memset (&req, 0, sizeof (req));
+ req.stats_ptr = (caddr_t) &req.stats;
+ snprintf (req.ifr__name, sizeof(req.ifr__name), "ppp%d", unit);
+
+ if (ioctl(fd, SIOCGPPPSTATS, &req) < 0)
+ return 0;
+
+ snprintf (buffer, sizeof(buffer), "ppp%d_rx", unit);
+ *rx=smooth(buffer, 500, req.stats.p.ppp_ibytes);
+
+ snprintf (buffer, sizeof(buffer), "ppp%d_tx", unit);
+ *tx=smooth(buffer, 500, req.stats.p.ppp_obytes);
+
+ return 0;
+}
+
int Sensor (int index, double *val, double *min, double *max)
{
char buffer[32];