This way, users need only type "make" to build instead of needing to "cd wmppp" first. --- wmppp.app/INSTALL | 11 +- wmppp.app/Makefile | 36 + wmppp.app/example-scripts/chap-secrets | 2 + wmppp.app/example-scripts/connect-errors | 0 wmppp.app/example-scripts/ip-down | 4 + wmppp.app/example-scripts/ip-up | 14 + wmppp.app/example-scripts/options | 10 + wmppp.app/example-scripts/pap-secrets | 2 + wmppp.app/example-scripts/wmppp-chat | 9 + wmppp.app/example-scripts/wmppp-ifdown | 5 + wmppp.app/example-scripts/wmppp-start | 3 + wmppp.app/example-scripts/wmppp-stop | 18 + wmppp.app/getmodemspeed.c | 17 + wmppp.app/system.wmppprc | 4 + wmppp.app/user.wmppprc | 4 + wmppp.app/wmppp-master.xpm | 133 ++++ wmppp.app/wmppp.1 | 103 +++ wmppp.app/wmppp.c | 1013 ++++++++++++++++++++++++ wmppp.app/wmppp/Makefile | 36 - wmppp.app/wmppp/example-scripts/chap-secrets | 2 - wmppp.app/wmppp/example-scripts/connect-errors | 0 wmppp.app/wmppp/example-scripts/ip-down | 4 - wmppp.app/wmppp/example-scripts/ip-up | 14 - wmppp.app/wmppp/example-scripts/options | 10 - wmppp.app/wmppp/example-scripts/pap-secrets | 2 - wmppp.app/wmppp/example-scripts/wmppp-chat | 9 - wmppp.app/wmppp/example-scripts/wmppp-ifdown | 5 - wmppp.app/wmppp/example-scripts/wmppp-start | 3 - wmppp.app/wmppp/example-scripts/wmppp-stop | 18 - wmppp.app/wmppp/getmodemspeed.c | 17 - wmppp.app/wmppp/system.wmppprc | 4 - wmppp.app/wmppp/user.wmppprc | 4 - wmppp.app/wmppp/wmppp-master.xpm | 133 ---- wmppp.app/wmppp/wmppp.1 | 103 --- wmppp.app/wmppp/wmppp.c | 1013 ------------------------ 35 files changed, 1382 insertions(+), 1383 deletions(-) create mode 100644 wmppp.app/Makefile create mode 100644 wmppp.app/example-scripts/chap-secrets create mode 100644 wmppp.app/example-scripts/connect-errors create mode 100755 wmppp.app/example-scripts/ip-down create mode 100755 wmppp.app/example-scripts/ip-up create mode 100644 wmppp.app/example-scripts/options create mode 100644 wmppp.app/example-scripts/pap-secrets create mode 100644 wmppp.app/example-scripts/wmppp-chat create mode 100755 wmppp.app/example-scripts/wmppp-ifdown create mode 100755 wmppp.app/example-scripts/wmppp-start create mode 100755 wmppp.app/example-scripts/wmppp-stop create mode 100644 wmppp.app/getmodemspeed.c create mode 100644 wmppp.app/system.wmppprc create mode 100644 wmppp.app/user.wmppprc create mode 100644 wmppp.app/wmppp-master.xpm create mode 100644 wmppp.app/wmppp.1 create mode 100644 wmppp.app/wmppp.c delete mode 100644 wmppp.app/wmppp/Makefile delete mode 100644 wmppp.app/wmppp/example-scripts/chap-secrets delete mode 100644 wmppp.app/wmppp/example-scripts/connect-errors delete mode 100755 wmppp.app/wmppp/example-scripts/ip-down delete mode 100755 wmppp.app/wmppp/example-scripts/ip-up delete mode 100644 wmppp.app/wmppp/example-scripts/options delete mode 100644 wmppp.app/wmppp/example-scripts/pap-secrets delete mode 100644 wmppp.app/wmppp/example-scripts/wmppp-chat delete mode 100755 wmppp.app/wmppp/example-scripts/wmppp-ifdown delete mode 100755 wmppp.app/wmppp/example-scripts/wmppp-start delete mode 100755 wmppp.app/wmppp/example-scripts/wmppp-stop delete mode 100644 wmppp.app/wmppp/getmodemspeed.c delete mode 100644 wmppp.app/wmppp/system.wmppprc delete mode 100644 wmppp.app/wmppp/user.wmppprc delete mode 100644 wmppp.app/wmppp/wmppp-master.xpm delete mode 100644 wmppp.app/wmppp/wmppp.1 delete mode 100644 wmppp.app/wmppp/wmppp.c
diff --git a/wmppp.app/INSTALL b/wmppp.app/INSTALL index 504660b..44be0c4 100644 --- a/wmppp.app/INSTALL +++ b/wmppp.app/INSTALL @@ -21,15 +21,14 @@ Requirements Installation -------------------------------------------------------------- 1) % tar -zxvf wmppp-1.x.x-tar.gz -2) % cd wmppp.app/ -3) % make all -4) % su root -5) # make install -6) # vi ~/.wmppprc +2) % make all +3) % su root +4) # make install +5) # vi ~/.wmppprc set up the paths to your ppp start, stop & restart scripts -7) % wmppp & (try 'wmppp -h &' for help) +6) % wmppp & (try 'wmppp -h &' for help) Extra Install Info For Site Administrators! diff --git a/wmppp.app/Makefile b/wmppp.app/Makefile new file mode 100644 index 0000000..c1fcce4 --- /dev/null +++ b/wmppp.app/Makefile @@ -0,0 +1,36 @@ +LIBDIR = -L/usr/X11R6/lib +LIBS = -lXpm -lXext -lX11 +CFLAGS += -O2 +OBJS = wmppp.o \ + wmgeneral/wmgeneral.o \ + wmgeneral/misc.o \ + wmgeneral/list.o + +.c.o: + cc -g -c $(CPPFLAGS) $(CFLAGS) -Wall $< -o $*.o + +wmppp: $(OBJS) + cc -o wmppp $(LDFLAGS) $^ -lXext $(LIBDIR) $(LIBS) + +all:: wmppp getmodemspeed + +clean:: + for i in $(OBJS) ; do \ + rm -f $$i; \ + done + rm -f wmppp getmodemspeed + +install:: + + cp -f wmppp /usr/local/bin/ + chmod 755 /usr/local/bin/wmppp + chown root:root /usr/local/bin/wmppp + cp getmodemspeed /etc/ppp/ + chmod 755 /etc/ppp/getmodemspeed + chown root.root /etc/ppp/getmodemspeed + cp -f user.wmppprc /etc/wmppprc + chmod 644 /etc/wmppprc + chown root.root /etc/wmppprc + cp -f user.wmppprc $(HOME)/.wmppprc + cp -f wmppp.1 /usr/local/share/man/man1 + echo "WMPPP installation finished." diff --git a/wmppp.app/example-scripts/chap-secrets b/wmppp.app/example-scripts/chap-secrets new file mode 100644 index 0000000..7d1c3cd --- /dev/null +++ b/wmppp.app/example-scripts/chap-secrets @@ -0,0 +1,2 @@ +# Secrets for authentication using CHAP +# client server secret IP addresses diff --git a/wmppp.app/example-scripts/connect-errors b/wmppp.app/example-scripts/connect-errors new file mode 100644 index 0000000..e69de29 diff --git a/wmppp.app/example-scripts/ip-down b/wmppp.app/example-scripts/ip-down new file mode 100755 index 0000000..7915cea --- /dev/null +++ b/wmppp.app/example-scripts/ip-down @@ -0,0 +1,4 @@ +#!/bin/sh +# ip-down +/sbin/route delete default + diff --git a/wmppp.app/example-scripts/ip-up b/wmppp.app/example-scripts/ip-up new file mode 100755 index 0000000..65d8fac --- /dev/null +++ b/wmppp.app/example-scripts/ip-up @@ -0,0 +1,14 @@ +#!/bin/bash + +# This file should not be modified -- make local changes to +# /etc/ppp/ip-up.local instead + +LOGDEVICE=$6 +REALDEVICE=$1 + +echo "$REALDEVICE" > /var/run/ppp-$LOGDEVICE.dev +[ -x /etc/ppp/ip-up.local ] && exec /etc/ppp/ip-up.local $* + +/etc/sysconfig/network-scripts/ifup-post ifcfg-${LOGDEVICE} + +exit 0 diff --git a/wmppp.app/example-scripts/options b/wmppp.app/example-scripts/options new file mode 100644 index 0000000..a392e77 --- /dev/null +++ b/wmppp.app/example-scripts/options @@ -0,0 +1,10 @@ +/dev/modem +38400 +modem +crtscts +lock +debug +defaultroute +netmask 255.255.255.0 +ipcp-accept-remote +disconnect "chat -- \d+++\d\c OK ath0 OK" diff --git a/wmppp.app/example-scripts/pap-secrets b/wmppp.app/example-scripts/pap-secrets new file mode 100644 index 0000000..f8b7dce --- /dev/null +++ b/wmppp.app/example-scripts/pap-secrets @@ -0,0 +1,2 @@ +# Secrets for authentication using PAP +# client server secret IP addresses diff --git a/wmppp.app/example-scripts/wmppp-chat b/wmppp.app/example-scripts/wmppp-chat new file mode 100644 index 0000000..1f2b25a --- /dev/null +++ b/wmppp.app/example-scripts/wmppp-chat @@ -0,0 +1,9 @@ +ABORT BUSY +ABORT 'NO CARRIER' +ABORT 'RING - NO ANSWER' +REPORT CARRIER +REPORT CONNECT +'' ATZ +OK ATDT +ogin: +word: diff --git a/wmppp.app/example-scripts/wmppp-ifdown b/wmppp.app/example-scripts/wmppp-ifdown new file mode 100755 index 0000000..6bcc95e --- /dev/null +++ b/wmppp.app/example-scripts/wmppp-ifdown @@ -0,0 +1,5 @@ +#!/bin/sh +# Try to restart pppd in case the modem has dropped. +# +/bin/sleep 60 +pppd diff --git a/wmppp.app/example-scripts/wmppp-start b/wmppp.app/example-scripts/wmppp-start new file mode 100755 index 0000000..7a7b7a3 --- /dev/null +++ b/wmppp.app/example-scripts/wmppp-start @@ -0,0 +1,3 @@ +#!/bin/sh + +/usr/sbin/pppd connect '/usr/sbin/chat -v -f /etc/ppp/wmppp-chat' diff --git a/wmppp.app/example-scripts/wmppp-stop b/wmppp.app/example-scripts/wmppp-stop new file mode 100755 index 0000000..145f293 --- /dev/null +++ b/wmppp.app/example-scripts/wmppp-stop @@ -0,0 +1,18 @@ +#!/bin/bash +DEVICE=ppp0 + +if [ -r /var/run/$DEVICE.pid ]; then + kill -INT `cat /var/run/$DEVICE.pid` + + if [ ! "$?" = "0" ]; then + rm -f /var/run/$DEVICE.pid + echo >/dev/console "ERROR: Removed stale pid file" + exit 1 + fi + + echo >/dev/console "PPP link to $DEVICE terminated." + exit 0 +fi + +echo >/dev/console "ERROR: PPP link not active on $DEVICE" +exit 1 diff --git a/wmppp.app/getmodemspeed.c b/wmppp.app/getmodemspeed.c new file mode 100644 index 0000000..80e2ab1 --- /dev/null +++ b/wmppp.app/getmodemspeed.c @@ -0,0 +1,17 @@ +#include <stdio.h> + +int main(void) { + + FILE *fd; + char temp[256]; + + fd = popen("tac /etc/ppp/connect-errors | grep '['CONNECT'|'CARRIER']' | head -1", "r"); + + while (fgets(temp, 256, fd)) { + printf("%s", temp); + } + + pclose(fd); + + return 0; +} diff --git a/wmppp.app/system.wmppprc b/wmppp.app/system.wmppprc new file mode 100644 index 0000000..befc95c --- /dev/null +++ b/wmppp.app/system.wmppprc @@ -0,0 +1,4 @@ +forcespeed: /etc/ppp/getmodemspeed +forcestart: /etc/ppp/your-global-ppp-start-script-here +forcestop: /etc/ppp/your-global-ppp-stop-script-here +forceifdown: /etc/ppp/your-global-ppp-restart-script-here diff --git a/wmppp.app/user.wmppprc b/wmppp.app/user.wmppprc new file mode 100644 index 0000000..ff2f528 --- /dev/null +++ b/wmppp.app/user.wmppprc @@ -0,0 +1,4 @@ +speed: /etc/ppp/getmodemspeed +start: /foo/bar/your-personal-wmppp-start-script-here +stop: /foo/bar/your-personal-wmppp-stop-script-here +ifdown: /foo/bar/your-personal-wmppp-restart-script-here diff --git a/wmppp.app/wmppp-master.xpm b/wmppp.app/wmppp-master.xpm new file mode 100644 index 0000000..f4fa754 --- /dev/null +++ b/wmppp.app/wmppp-master.xpm @@ -0,0 +1,133 @@ +/* XPM */ +static char * wmppp_master_xpm[] = { +"64 114 16 1", +" c #00000000FFFF", +". c #000000000000", +"X c #208120812081", +"o c #C71BC30BC71B", +"O c #000049244103", +"+ c #28A23CF338E3", +"@ c #F7DEF3CEFFFF", +"# c #861782078E38", +"$ c #AEBAAAAAAEBA", +"% c #2081B2CAAEBA", +"& c #18618A288617", +"* c #B6DA04101861", +"= c #0000EBAD0000", +"- c #E79DC30B0820", +"; c #71C6E38D71C6", +": c #4924C30B4924", +" ", +" ", +" ", +" ", +" ................................. ..................... ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo .XXXXXXXXXXXXXXXXXXXo ", +" .XXOOOXXXOOOXXXXXXXOOOXXXOOOXXXXo .XXXXXXXXXXXXXXXXXXXo ", +" .XOXXXOXOXXXOXXOXXOXXXOXOXXXOXXXo .XX++XXXX++XXXX++XXXo ", +" .XOXXXOXOXXXOXXOXXOXXXOXOXXXOXXXo .X++++XX++++XX++++XXo ", +" .XXOOOXXXOOOXXXXXXXOOOXXXOOOXXXXo .X++++XX++++XX++++XXo ", +" .XOXXXOXOXXXOXXXXXOXXXOXOXXXOXXXo .XX++XXXX++XXXX++XXXo ", +" .XOXXXOXOXXXOXXOXXOXXXOXOXXXOXXXo .XXXXXXXXXXXXXXXXXXXo ", +" .XXOOOXXXOOOXXXOXXXOOOXXXOOOXXXXo .XXXXXXXXXXXXXXXXXXXo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo .XXXXXXXXXXXXXXXXXXXo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo .XXXXXXXXXXXXXXXXXXXo ", +" ooooooooooooooooooooooooooooooooo ooooooooooooooooooooo ", +" ", +" ", +" ........................................................ ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" oooooooooooooooooooooooooooooooooooooooooooooooooooooooo ", +" ", +" ", +" ............................ .......................... ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXo .@@@@@@@@@@@#@@@@@@@@@@@#o ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXo .@$$$$$$$$$$.@$$$$$$$$$$.o ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXo .@$$$$$$..$$.@$..$$$..$$.o ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXo .@$$$$$...$$.@$...$...$$.o ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXo .@$..$...$$$.@$$.....$$$.o ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXo .@$.....$$$$.@$$$...$$$$.o ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXo .@$....$$$$$.@$$.....$$$.o ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXo .@$...$$$$$$.@$...$...$$.o ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXo .@$..$$$$$$$.@$..$$$..$$.o ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXo .@$$$$$$$$$$.@$$$$$$$$$$.o ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXo .#...........#...........o ", +" oooooooooooooooooooooooooooo oooooooooooooooooooooooooo ", +" ", +" ", +" ", +" ", +"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", +"XX%%%XXXOOO&X&%%%&X&%%%&X&OOO&X&%%%&X&%%%&X&%%%&X&%%%&X&%%%&XXXX", +"X%XXX%XOXXX%XOXXX%XOXXX%X%XXX%X%XXXOX%XXXOXOXXX%X%XXX%X%XXX%XX%X", +"X%XXX%XOXXX%XOXXX%XOXXX%X%XXX%X%XXXOX%XXXOXOXXX%X%XXX%X%XXX%XX&X", +"X&OOO&XXOOO&X&%%%&XX%%%&X&%%%&X&%%%&X&%%%&XXOOO&X&%%%&X&%%%&XXXX", +"X%XXX%XOXXX%X%XXXOXOXXX%XOXXX%XOXXX%X%XXX%XOXXX%X%XXX%XOXXX%XXXX", +"X%XXX%XOXXX%X%XXXOXOXXX%XOXXX%XOXXX%X%XXX%XOXXX%X%XXX%XOXXX%XX%X", +"XX%%%XXXOOO&X&%%%&X&%%%&XXOOO&X&%%%&X&%%%&XXOOO&X&%%%&X&%%%&XX&X", +"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", +" ", +"...........#...........#@@@@@@@@@@@#@@@@@@@@@@@# ", +".$$$$$$$$$$@.$$$$$$$$$$@@$$$$$$$$$$.@$$$$$$$$$$. X++X X**X ", +".$$$$$$..$$@.$..$$$..$$@@$$$$$$..$$.@$..$$$..$$. ++++ *@** ", +".$$$$$...$$@.$...$...$$@@$$$$$...$$.@$...$...$$. ++++ **** ", +".$..$...$$$@.$$.....$$$@@$..$...$$$.@$$.....$$$. X++X X**X ", +".$.....$$$$@.$$$...$$$$@@$.....$$$$.@$$$...$$$$. ", +".$....$$$$$@.$$.....$$$@@$....$$$$$.@$$.....$$$. X==X X--X ", +".$...$$$$$$@.$...$...$$@@$...$$$$$$.@$...$...$$. =@== -@-- ", +".$..$$$$$$$@.$..$$$..$$@@$..$$$$$$$.@$..$$$..$$. ==== ---- ", +".$$$$$$$$$$@.$$$$$$$$$$@@$$$$$$$$$$.@$$$$$$$$$$. X==X X--X ", +"#@@@@@@@@@@@#@@@@@@@@@@@#...........#........... ", +" ;X%&; ", +"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", +"+++:X:;;:X:;;:X:++:X:;;:X:;;:X:;;:X:;;:X:;;:X:;;:X++++X++++X++++", +"+XX;X+XX;X+XX;X;XX;X;XX+X;XX+X+XX;X;XX;X;XX;X;XX;X+XX+X+XX+X+XX+", +"+XX;X+XX;X+XX;X;XX;X;XX+X;XX+X+XX;X;XX;X;XX;X;XX;X;XX;X;XX;X+XX+", +"+++:X:;;:X:;;:X:;;:X:;;:X:;;:X+++:X:;;:X:;;:X:++:X;+;+X;;;;X++++", +"+XX;X;XX+X+XX;X+XX;X+XX;X;XX;X+XX;X;XX;X+XX;X;XX;X;;X+X;XX;X+XX+", +"+XX;X;XX+X+XX;X+XX;X+XX;X;XX;X+XX;X;XX;X+XX;X;XX;X;X;+X;XX;X+XX+", +"+++;X:;;:X:;;:X+++:X:;;:X:;;:X+++:X:;;:X:;;:X:;;:X;++;X;++;X++++", +"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", +"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", +":;;:X:;;:X:;;:X:;;:X:;;:XXXX++++X++++X++++XXXXXX++++XXXXXXXXXXXX", +";XX+X;XX;X;XX;X;XX;X;XX;XXXX+XX+X+XX+X+XX+XXXXXX+XX+XXXXXXXXXXXX", +";XX+X;XX;X;XX;X;XX;X;XX;XXXX+XX+X+XX+X+XX+X+XX+X+XX+XXXXXXXXXXXX", +":;;+X:;;XX:;;XX:++:X:;;XXXXX++++X++++X++++X+X+XX++++XXXXXXXXXXXX", +";XX+X;XX;X;XX;X;XX;X;XX;XXXX+XX+X+XX+X+XX+X++XXX+XX+XXXXXXXXXXXX", +";XX+X;XX;X;XX;X;XX;X;XX;XXXX+XX+X+XX+X+XX+X+X+XX+XX+XXXXXXXXXXXX", +":;;:X:++:X:++:X:;;:X:++:XXXX++++X++++X++++X+XX+X++++XXXXXXXXXXXX", +"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", +"XXOOOXXXOOOXXXXXXXOOOXXXOOOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", +"XOXXXOXOXXXOXXOXXOXXXOXOXXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", +"XOXXXOXOXXXOXXOXXOXXXOXOXXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", +"XXOOOXXXOOOXXXXXXXOOOXXXOOOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", +"XOXXXOXOXXXOXXXXXOXXXOXOXXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", +"XOXXXOXOXXXOXXOXXOXXXOXOXXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", +"XXOOOXXXOOOXXXOXXXOOOXXXOOOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", +"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", +"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", +"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"}; diff --git a/wmppp.app/wmppp.1 b/wmppp.app/wmppp.1 new file mode 100644 index 0000000..081a1e6 --- /dev/null +++ b/wmppp.app/wmppp.1 @@ -0,0 +1,103 @@ +.\" -*-Nroff-*- +.\" +.TH wmppp.app 1 "September 1998" "Debian Project" "Debian GNU/Linux" +.SH NAME +wmppp \- Graphically monitor the average PPP load +.P +.SH SYNOPSIS +.B wmppp +.RB [\| \-display +.IR <display\ name> \|] +.RB [\| \-t \|] +.RB [\| \-u +.IR <update\ rate> \|] +.RB [\| \-i +.IR <device> \|] +.RB [\| \-h \|] +.RB [\| \-v \|] +.SH DESCRIPTION +\fBwmppp.app\fP displays a dynamic representation of the load on the +PPP line on a 64x64 miniwindow. It also starts and stops the +connection and displays the time enlapsed since the it came up. The +traffic on the interface is also monitored. +.SH OPTIONS +.TP +.B \-display <display\ name> +name of display to use +.TP +.B \-t +sets the on-line timer to display MM:SS instead of the default HH:MM. +.TP +.B \-u <update rate> +sets the frequency, in seconds, for updates to the display. Valid +range is 1-10, default value is 5. +.TP +.B \-i <device> +choose the net device (ppp1, ippp0, etc.) to monitor. (Note that this +feature is EXPERIMENTAL and should be used with caution. Bug reports +are welcomed.) +.TP +.B \-h +displays a command line summary +.TP +.B \-v +displays the version number. +.SH CONFIGURATION +The configuration file (see below) may contain any of the following +key-value pairs. The format is \fIkey: value\fP. +.TP +.I start +The program that starts the connection +.TP +.I stop +The program that stops the connection +.TP +.I speed +This program reports the speed of the connection. This program should +output \fI<speed>\fP, that is, a \fInumber\fP is expected and not the +whole \"CONNECT\" line the modem outputs. +.TP +.I ifdown +This program is run if the line goes down, and the \fIstop\fP program +hasn't been run. (Redial program) +.TP +.I stampfile +The modification time of this file is used to calculate the amount of +time the connection has been up. Something like \fItouch <stampfile>\fP +should be run for this to work. +.SH FILES +.TP +/var/run/wmppp.\fIppp0\fP +this is the stamp file use to determine the ammount of time enlapsed +since the connection came up. This file should be managed by the ip-up +and ip-down scripts. On Debian systems, \fI/etc/ppp/ip-up.d/00wmppp\fP +creates the file, and \fI/etc/ppp/ip-down.d/00wmppp\fP removes it. +.TP +/etc/wmppprc +System wide defaults +.TP +$HOME/.wmppprc +User defined settings +.TP +/etc/wmppprc.fixed +System wide fixed options, this overrides the user settings +.SH AUTHORS +\fBwmppp.app\fP was written by \fIMartijn Pieterse +<piete...@xs4all.nl>\fP and \fIAntoine Nulle <w...@xs4all.nl>\fP, and +it's based on work by \fIBeat Christen <bchri...@iiic.ethz.ch>\fP +(asclock) and \fIMichael Callahan <calla...@maths.ox.ac.uk>\fP, \fIAl +Longyear longy...@netcom.com\fP and \fIPaul Mackerras +<paul.macker...@cs.anu.edu.au>\fP (pppstats). +.P +Email regarding wmppp should be sent to +\fiwmaker-...@lists.windowmaker.org\fP. +.P +This manpage was written by \fIMarcelo Magallon +<mmaga...@debian.org\fP for the \fIDebian Project\fP +.SH "SEE ALSO" +.BR pppd (8), +.BR pppstats (8), +.BR plog (1), +.BR pon (1), +.BR poff (1) + diff --git a/wmppp.app/wmppp.c b/wmppp.app/wmppp.c new file mode 100644 index 0000000..cd86f25 --- /dev/null +++ b/wmppp.app/wmppp.c @@ -0,0 +1,1013 @@ +/* + Best viewed with vim5, using ts=4 + + This code was mainly put together by looking at the + following programs: + + asclock + A neat piece of equip, used to display the date + and time on the screen. + Comes with every WindowMaker installation. + + Source used: + How do I create a not so solid window? + How do I open a window? + How do I use pixmaps? + + pppstats + A program that prints the amount of data that + is transferred over a ppp-line. + + Source used: + How do I read the ppp device? + ------------------------------------------------------------ + + Authors: Martijn Pieterse (piete...@xs4all.nl) + Antoine Nulle (w...@xs4all.nl) + + This program might be Y2K resistant. We shall see. :) + + This program is distributed under the GPL license. + (as were asclock and pppstats) + + Known Features: (or in non M$ talk, BUGS) + * none known so far in this release + + ---- + Thanks + ---- + + CCC (Constructive Code Criticism): + + Marcelo E. Magallon + Thanks a LOT! It takes a while to get me convinced... :) + + + Minor bugs and ideas: + + Marc De Scheemaecker / David Mihm / Chris Soghoian / + Alessandro Usseglio Viretta + + and ofcourse numerous ppl who send us bug reports. + (numerous? hmm.. todo: rephrase this :) ) + Make that numberous m8ey :) + + ---- + Changes: + --- + 05/09/1998 (Martijn Pieterse, piete...@xs4all.nl) + * Added: + Speed-O-Meter (after 60 seconds) + Fixed Error reporting when pressing X + Removed the ugly kb lines + Stopped clearing on-line time when pressing X + Added createXBMfromXPM + 08/05/1998 (Martijn Pieterse, piete...@xs4all.nl) + * Removed some code from get_statistics + * Check if "ifdown" is empty before execCommanding it! + 07/05/1998 (Martijn Pieterse, piete...@xs4all.nl) + * Made the program use the xpm like warp wanted it to be :) + 04/05/1998 (Martijn Pieterse, piete...@xs4all.nl) + * Added pppX support. (EXPERIMENTAL!) + Removed HARD_CODED_DEV. (that stayed in long! :) ) + * Changed 33600 speed indication to 33k6 + Bugs if larger than 115k2 (depends on how much 1's present) + Moved the speed ind. code to DrawSpeedInd + * Added 1k lines in the stats + * Moved all the "ppp0" references into HARD_CODED_DEV. + for easy change + 03/05/1998 (Martijn Pieterse, piete...@xs4all.nl) + * Removed the number after -t. + 02/05/1998 (Martijn Pieterse, piete...@xs4all.nl) + * Removed the heyho code :) + * Changed read_rc_file to parse_rcfile. suggested bt Marcelo E. Magallon + * Added some extra checks for the -t option. + If no number was given, it would core dump + 30/04/1998 (Martijn Pieterse, piete...@xs4all.nl) + * Added execCommand code. (taken from windowmaker soure, as advised by Marcelo E. Magallon) + * Cleaned the source up a bit + * Decided to split op wmppp and wmifs + This is gonna be wmppp + * Used the DrawStats routine from wmifs in wmppp + * I decided to add a list in this source file + with name of ppl who helped me build this code better. + * I finally removed the /proc/net/route dependancy + All of the connections are taken from /proc/net/dev. + /proc/net/route is still used for checking if it is on-line. + 27/04/1998 (Martijn Pieterse, piete...@xs4all.nl) + * WMIFS: stats scrolled, while red led burning + * WMPPP: changed positions of line speed + 25/04/1998 (Martijn Pieterse, piete...@xs4all.nl) + * Changed the checknetdevs routine, a lot! + 23/04/1998 (Martijn Pieterse, piete...@xs4all.nl) + * Added line speed detection. via seperate exec. (this has to be suid root!) + Speed has to be no more than 99999 + * Added speed and forcespeed in ~/.wmppprc and /etc/wmppprc + * wmifs: added on-line detection scheme, update the bitmap coordinates + * wmppp: the x-button now allways disconnects. + 22/04/1998 (Martijn Pieterse, piete...@xs4all.nl) + * Added /etc/wmppprc support, including "forced" mode. + * Added /etc/wmifsrc support, including "forced" mode. + 21/04/1998 (Martijn Pieterse, piete...@xs4all.nl) + * Moved the stats one pixel down. + * Added status led in wmifs. + * Changed RX/TX leds of wmifs to resemble wmppp + * Added the "dot" between eth.0 ppp.0 etc. + * Changed to wmifs stats to match wmppp stats (only pppX changed) + * Made sure that when specified -t 1, it stayed that way, even + when longer than 100 minutes online + * With -t 1, jump from 59:59 to 01:00 instead of 99:59 to 01:40 + 16/04/1998 (Martijn Pieterse, piete...@xs4all.nl) + * Added "all" devices in wmifs + * Added "lo" support only if aked via -i + * Added on-line time detection (using /var/run/ppp0.pid) + * Added time-out for the orange led. (one minute) + 15/04/1998 (Martijn Pieterse, piete...@xs4all.nl) + * Another wmppp-master.xpm. + Line speed detection being the main problem here.. :( + * Moved START_COMMAND / STOP_COMMAND to ~/.wmppprc + Return 0, everything went ok. + Return 10, the command did not work. + Please note, these functions are ran in the background. + * Removed the ability to configure + * When "v" is clicked, an orange led will appear. + if the connect script fails (return value == 10) + it will become dark again. Else the on-line detection will + pick it up, and "green" it. + 14/04/1998 (Martijn Pieterse, piete...@xs4all.nl) + * Added "-timer" + * Added "-display" support + * Changed pixmap to a no-name pixmap. + + Changed LED positions + + Changed Timer position + + Changed Stats Size + 05/04/1998 (Martijn Pieterse, piete...@xs4all.nl) + * Added ~/.wmifsrc support. + * Put some code in DrawStats + * Check devices when pressing "device change" + 03/04/1998 (Martijn Pieterse, piete...@xs4all.nl) + * Added code for wmifs + 28/03/1998 (Martijn Pieterse, piete...@xs4all.nl) + * forgot what i did.. :) + 27/03/1998 (Martijn Pieterse, piete...@xs4all.nl) + * Added on-line detection + Scan through /proc/net/route and check everye line + for "ppp". + * A bit of code clean-up. +*/ + +#include <stdlib.h> +#include <stdio.h> +#include <time.h> +#include <string.h> +#include <fcntl.h> +#include <unistd.h> +#include <ctype.h> + +#include <sys/wait.h> +#include <sys/stat.h> +#include <sys/param.h> +#include <sys/types.h> +#include <sys/ioctl.h> +#include <sys/socket.h> + +#include <net/ppp_defs.h> +#include <net/if_ppp.h> + +#include <X11/Xlib.h> +#include <X11/xpm.h> +#include <X11/extensions/shape.h> + +#include "wmgeneral/wmgeneral.h" +#include "wmgeneral/misc.h" + +#include "wmppp-master.xpm" + + /***********/ + /* Defines */ +/***********/ + +#define START_ACTION (NULL) +#define STOP_ACTION (NULL) +#define SPEED_ACTION (NULL) +#define IFDOWN_ACTION (NULL) + +#define STAMP_FILE_PRE "/var/run/wmppp." + +/* Defines voor alle coordinate */ + +#define LED_PPP_RX (1) +#define LED_PPP_TX (2) +#define LED_PPP_POWER (3) + +#define BUT_V (1) +#define BUT_X (2) + +#define TIMER_X (9) +#define TIMER_Y (14) + +#define TIMER_SRC_Y (65) +#define TIMER_DES_Y (6) +#define TIMER_SZE_X (6) + +#define WMPPP_VERSION "1.3.0" + +#define ORANGE_LED_TIMEOUT (60) + + /**********************/ + /* External Variables */ +/**********************/ + +extern char **environ; + + /********************/ + /* Global Variables */ +/********************/ + +char *ProgName; +char *active_interface = "ppp0"; +int TimerDivisor=60; +int updaterate = 5; + +int wmppp_mask_width = 64; +int wmppp_mask_height = 64; +char wmppp_mask_bits[64*64]; + + + /*****************/ + /* PPP variables */ +/*****************/ + +#define PPP_UNIT 0 +int ppp_h = -1; + +#define PPP_STATS_HIS 54 + +int pixels_per_byte; + +int ppp_history[PPP_STATS_HIS+1][2]; + + /***********************/ + /* Function Prototypes */ +/***********************/ + +void usage(void); +void printversion(void); +void DrawTime(int, int); +void DrawStats(int *, int, int, int, int); +void DrawSpeedInd(char *); +void DrawLoadInd(int); + +void SetOnLED(int); +void SetErrLED(int); +void SetWaitLED(int); +void SetOffLED(int); + +void ButtonUp(int); +void ButtonDown(int); + +void wmppp_routine(int, char **); + +int get_statistics(char *, long *, long *, long *, long *); +void get_ppp_stats(struct ppp_stats *cur); +int stillonline(char *); + + + /********/ + /* Main */ +/********/ + +int main(int argc, char *argv[]) { + + int i; + + + /* Parse Command Line */ + + ProgName = argv[0]; + if (strlen(ProgName) >= 5) + ProgName += (strlen(ProgName) - 5); + + for (i=1; i<argc; i++) { + char *arg = argv[i]; + + if (*arg=='-') { + switch (arg[1]) { + case 'd' : + if (strcmp(arg+1, "display")) { + usage(); + exit(1); + } + break; + case 'g' : + if (strcmp(arg+1, "geometry")) { + usage(); + exit(1); + } + break; + case 'i' : + if (!argv[i+1]) { + usage(); + exit(1); + } + /* following removed to allow experiments with + * new devices, i.e. ippp + */ +#if 0 + if (strncmp(argv[i+1], "ppp", 3)) { + usage(); + exit(1); + } +#endif + active_interface = argv[i+1]; + i++; + break; + case 't' : + TimerDivisor = 1; + break; + case 'u' : + i++; + if (!argv[i]) { + usage(); + exit(1); + } + updaterate = atoi(argv[i]); + if (updaterate < 1 || updaterate > 10) { + usage(); + exit(1); + } + break; + case 'v' : + printversion(); + exit(0); + break; + default: + usage(); + exit(0); + break; + } + } + } + + wmppp_routine(argc, argv); + + return 0; +} + + /*****************/ + /* wmppp_routine */ +/*****************/ + +char *start_action = NULL; +char *stop_action = NULL; +char *speed_action = NULL; +char *ifdown_action = NULL; +char *stamp_file = NULL; + +void wmppp_routine(int argc, char **argv) { + + rckeys wmppp_keys[] = { + { "start", &start_action }, + { "stop", &stop_action }, + { "speed", &speed_action }, + { "ifdown", &ifdown_action }, + { "stampfile", &stamp_file }, + { NULL, NULL } + }; + + int i,j; + + int but_stat; + + long starttime; + long currenttime; + long lasttime; + long waittime; + long ppptime; + int hour,minute; + + long ppp_send,ppp_sl=-1; + long ppp_recv,ppp_rl=-1; + long ppp_sbytes,ppp_rbytes; + long ppp_osbytes,ppp_orbytes; + + struct stat st; + + pid_t stop_child = 0; + pid_t start_child = 0; + int status; + + XEvent Event; + + char *p; + char temp[128]; + + int speed_ind=60; + + /* Initialize some stuff */ + + get_statistics(active_interface, &ppp_rl, &ppp_sl, &ppp_orbytes, &ppp_osbytes); + + /* Scan through ~/.wmifsrc for the mouse button actions. */ + if (START_ACTION) start_action = strdup(START_ACTION); + if (STOP_ACTION) stop_action = strdup(STOP_ACTION); + if (SPEED_ACTION) speed_action = strdup(SPEED_ACTION); + if (IFDOWN_ACTION) ifdown_action = strdup(IFDOWN_ACTION); + if (STAMP_FILE_PRE) { + sprintf (temp, "%s%s", STAMP_FILE_PRE, active_interface); + stamp_file = strdup (temp); + } + + + strcpy(temp, "/etc/wmppprc"); + parse_rcfile(temp, wmppp_keys); + + p = getenv("HOME"); + strcpy(temp, p); + strcat(temp, "/.wmppprc"); + parse_rcfile(temp, wmppp_keys); + + strcpy(temp, "/etc/wmppprc.fixed"); + parse_rcfile(temp, wmppp_keys); + + /* Open the display */ + + createXBMfromXPM(wmppp_mask_bits, wmppp_master_xpm, wmppp_mask_width, wmppp_mask_height); + + openXwindow(argc, argv, wmppp_master_xpm, wmppp_mask_bits, wmppp_mask_width, wmppp_mask_height); + + /* V Button */ + AddMouseRegion(0, 35, 48, 46, 58); + /* x Button */ + AddMouseRegion(1, 47, 48, 58, 58); + + starttime = 0; + currenttime = time(0); + ppptime = 0; + but_stat = -1; + waittime = 0; + copyXPMArea(28, 95, 25, 11, 5, 48); + +/* wmppp main loop */ + while (1) { + lasttime = currenttime; + currenttime = time(0); + /* Check if any child has left the playground */ + i = waitpid(0, &status, WNOHANG); + if (i == stop_child && stop_child != 0) { + + starttime = 0; + SetOffLED(LED_PPP_POWER); + SetOffLED(LED_PPP_RX); + SetOffLED(LED_PPP_TX); + copyXPMArea(28, 95, 25, 11, 5, 48); + + RedrawWindow(); + + stop_child = 0; + } + if (i == start_child && start_child != 0) { + if (WIFEXITED(status)) { + if (WEXITSTATUS(status) == 10) { + + starttime = 0; + copyXPMArea(28, 95, 25, 11, 5, 48); + SetOffLED(LED_PPP_POWER); + DrawTime(0, 1); + RedrawWindow(); + } + start_child = 0; + } + } + + /* On-line detectie! 1x per second */ + + if (currenttime != lasttime) { + i = 0; + + if (stillonline(active_interface)) { + i = 1; + if (!starttime) { + starttime = currenttime; + + if (stat(stamp_file, &st) == 0) + starttime = st.st_mtime; + + SetOnLED(LED_PPP_POWER); + waittime = 0; + + copyXPMArea(28, 95, 25, 11, 5, 48); + + if (speed_action) + DrawSpeedInd(speed_action); + + speed_ind = currenttime + 60; + + RedrawWindow(); + } + } + if (!i && starttime) { + starttime = 0; + SetErrLED(LED_PPP_POWER); + + copyXPMArea(0, 95, 26, 11, 5, 48); + + if (ifdown_action) + execCommand(ifdown_action); + + RedrawWindow(); + } + } + + if (waittime && waittime <= currenttime) { + SetOffLED(LED_PPP_POWER); + RedrawWindow(); + waittime = 0; + } + + /* If we are on-line. Print the time we are */ + if (starttime) { + i = currenttime - starttime; + + i /= TimerDivisor; + + if (TimerDivisor == 1) + if (i > 59 * 60 + 59) i /= 60; + + minute = i % 60; + hour = (i / 60) % 100; + i = hour * 100 + minute; + + DrawTime(i, currenttime % 2); + /* We are online, so we can check for send/recv packets */ + + get_statistics(active_interface, &ppp_recv, &ppp_send, &ppp_rbytes, &ppp_sbytes); + + if (ppp_send != ppp_sl) SetOnLED(LED_PPP_TX); + else SetOffLED(LED_PPP_TX); + + if (ppp_recv != ppp_rl) SetOnLED(LED_PPP_RX); + else SetOffLED(LED_PPP_RX); + + ppp_sl = ppp_send; + ppp_rl = ppp_recv; + + /* Every five seconds we check to load on the line */ + + if ((currenttime - ppptime >= 0) || (ppptime == 0)) { + + ppptime = currenttime + updaterate; + + ppp_history[PPP_STATS_HIS][0] = ppp_rbytes - ppp_orbytes; + ppp_history[PPP_STATS_HIS][1] = ppp_sbytes - ppp_osbytes; + + ppp_orbytes = ppp_rbytes; + ppp_osbytes = ppp_sbytes; + + DrawStats(&ppp_history[0][0], 54, 25, 5, 43); + + for (j=1; j<55; j++) { + ppp_history[j-1][0] = ppp_history[j][0]; + ppp_history[j-1][1] = ppp_history[j][1]; + } + if (currenttime > speed_ind) { + DrawLoadInd((ppp_history[54][0] + ppp_history[54][1]) / updaterate); + } + } + + RedrawWindow(); + } + + + while (XPending(display)) { + XNextEvent(display, &Event); + switch (Event.type) { + case Expose: + RedrawWindow(); + break; + case DestroyNotify: + XCloseDisplay(display); + while (start_child | stop_child) { + i = waitpid(0, &status, WNOHANG); + if (i == stop_child) stop_child = 0; + if (i == start_child) start_child = 0; + usleep(50000l); + } + exit(0); + break; + case ButtonPress: + i = CheckMouseRegion(Event.xbutton.x, Event.xbutton.y); + switch (i) { + case 0: + ButtonDown(BUT_V); + break; + case 1: + ButtonDown(BUT_X); + break; + } + but_stat = i; + + RedrawWindow(); + break; + case ButtonRelease: + i = CheckMouseRegion(Event.xbutton.x, Event.xbutton.y); + // Button but_stat omhoogdoen! + switch (but_stat) { + case 0: + ButtonUp(BUT_V); + break; + case 1: + ButtonUp(BUT_X); + break; + } + + if (i == but_stat && but_stat >= 0) { + switch (i) { + case 0: + if (!starttime) { + copyXPMArea(28, 95, 25, 11, 5, 48); + DrawTime(0, 1); + start_child = execCommand(start_action); + SetWaitLED(LED_PPP_POWER); + waittime = ORANGE_LED_TIMEOUT + currenttime; + } + + break; + case 1: + if (stop_child == 0) { + stop_child = execCommand(stop_action); + } + break; + } + } + RedrawWindow(); + + but_stat = -1; + break; + default: + break; + } + } + usleep(50000L); + } +} + +/*******************************************************************************\ +|* get_statistics *| +\*******************************************************************************/ + +int get_statistics(char *devname, long *ip, long *op, long *is, long *os) { + + struct ppp_stats ppp_cur; + static int ppp_opened = 0; + + + if (!ppp_opened) { + /* Open the ppp device. */ + memset(&ppp_cur, 0, sizeof(ppp_cur)); + if ((ppp_h = socket(AF_INET, SOCK_DGRAM, 0)) < 0) + return -1; + ppp_opened = 1; + } + + get_ppp_stats(&ppp_cur); + + *op = ppp_cur.p.ppp_opackets; + *ip = ppp_cur.p.ppp_ipackets; + + *is = ppp_cur.p.ppp_ibytes; + *os = ppp_cur.p.ppp_obytes; + + return 0; +} + +/*******************************************************************************\ +|* stillonline *| +\*******************************************************************************/ + +int stillonline(char *ifs) { + + FILE *fp; + char temp[128]; + int i; + + i = 0; + fp = fopen("/proc/net/route", "r"); + if (fp) { + while (fgets(temp, 128, fp)) { + if (strstr(temp, ifs)) { + i = 1; /* Line is alive */ + } + } + fclose(fp); + } + return i; +} + +/*******************************************************************************\ +|* DrawTime *| +\*******************************************************************************/ + +void DrawTime(int i, int j) { + + int k = 1000; + + copyXPMArea(TIMER_SZE_X*((i / k)%10)+1, TIMER_SRC_Y, 5, 7, 6+6*0, TIMER_DES_Y); + k = k /10; + copyXPMArea(TIMER_SZE_X*((i / k)%10)+1, TIMER_SRC_Y, 5, 7, 6+6*1, TIMER_DES_Y); + k = k /10; + + if (j) + copyXPMArea(62, TIMER_SRC_Y, 1, 7, 6+6*2+1, TIMER_DES_Y); + else + copyXPMArea(63, TIMER_SRC_Y, 1, 7, 6+6*2+1, TIMER_DES_Y); + + copyXPMArea(TIMER_SZE_X*((i / k)%10)+1, TIMER_SRC_Y, 5, 7, 6+6*2 + 4, TIMER_DES_Y); + k = k /10; + copyXPMArea(TIMER_SZE_X*((i / k)%10)+1, TIMER_SRC_Y, 5, 7, 6+6*3 + 4, TIMER_DES_Y); +} + +/*******************************************************************************\ +|* DrawStats *| +\*******************************************************************************/ + +void DrawStats(int *his, int num, int size, int x_left, int y_bottom) { + + int pixels_per_byte; + int j,k; + int *p; + + pixels_per_byte = 1*size; + p = his; + for (j=0; j<num; j++) { + if (p[0] + p[1] > pixels_per_byte) + pixels_per_byte = p[0] + p[1]; + p += 2; + } + + pixels_per_byte /= size; + p = his; + + for (k=0; k<num; k++) { + + + for (j=0; j<size; j++) { + + if (j < p[0] / pixels_per_byte) + copyXPMArea(57+2, 85, 1, 1, k+x_left, y_bottom-j); + else if (j < (p[0] + p[1]) / pixels_per_byte) + copyXPMArea(57+1, 85, 1, 1, k+x_left, y_bottom-j); + else + copyXPMArea(57+0, 85, 1, 1, k+x_left, y_bottom-j); + } + p += 2; + } +} + +/*******************************************************************************\ +|* DrawSpeedInd *| +\*******************************************************************************/ + +void PrintLittle(int i, int *k) { + + switch (i) { + case -2: + *k -= 5; + /* Print the "k" letter */ + copyXPMArea(11*5-5, 86, 4, 9, *k, 48); + break; + case -1: + *k -= 5; + copyXPMArea(13*5-5, 86, 4, 9, *k, 48); + break; + case 0: + *k -= 5; + copyXPMArea(45, 86, 5, 9, *k, 48); + break; + default: + *k -= 5; + copyXPMArea(i*5-5, 86, 5, 9, *k, 48); + break; + } +} + +void DrawSpeedInd(char *speed_action) { + + int linespeed, i, k; + FILE *fp; + char *p; + char temp[128]; + + fp = popen(speed_action, "r"); + + if (fp) { + linespeed = 0; + + while (fgets(temp, 128, fp)) + ; + + pclose(fp); + + if ((p=strstr(temp, "CONNECT"))) { + linespeed = atoi(p + 8); + } + + k = 30; + + i = (linespeed % 1000) / 100; + linespeed /= 1000; + PrintLittle(i, &k); + + k -= 5; + copyXPMArea(50, 86, 5, 9, k, 48); + + do { + PrintLittle(linespeed % 10, &k); + linespeed /= 10; + } while (linespeed); + } +} + +/*******************************************************************************\ +|* DrawLoadInd *| +\*******************************************************************************/ + +void DrawLoadInd(int speed) { + + int i, k; + + k = 30; + for (i=0; i<5; i++) PrintLittle(-1, &k); + + k = 30; + + /* If speed is greater than 99999, display it in K */ + if (speed > 99999 ) + { + speed /= 1024 ; + PrintLittle(-2, &k) ; + } + + do { + PrintLittle(speed % 10, &k); + speed /= 10; + } while (speed); +} + +/*******************************************************************************\ +|* usage *| +\*******************************************************************************/ + +void usage(void) { + + fprintf(stderr, "\nwmppp - programming: tijno, design & ideas: warp\n\n"); + fprintf(stderr, "usage:\n"); + fprintf(stderr, "-display <display name>\n"); + fprintf(stderr, "-geometry +XPOS+YPOS initial window position\n"); + fprintf(stderr, "-h this help screen\n"); + fprintf(stderr, "-i <device> (ppp0, ppp1, etc) EXPERIMENTAL! Please send bugreports!\n"); + fprintf(stderr, "-t set the on-line timer to MM:SS instead of HH:MM\n"); + fprintf(stderr, "-u <update rate> (1..10), default 5 seconds\n"); + fprintf(stderr, "-v print the version number\n"); + fprintf(stderr, "\n"); +} + +/*******************************************************************************\ +|* printversion *| +\*******************************************************************************/ + +void printversion(void) { + + fprintf(stderr, "%s\n", WMPPP_VERSION); +} + +/*******************************************************************************\ +|* get_ppp_stats *| +\*******************************************************************************/ + +void get_ppp_stats(struct ppp_stats *cur) { + + struct ifpppstatsreq req; + + memset(&req, 0, sizeof(req)); + + req.stats_ptr = (caddr_t) &req.stats; + + strcpy(req.ifr__name, active_interface); + + if (ioctl(ppp_h, SIOCGPPPSTATS, &req) >= 0) + *cur = req.stats; +} + +#define LED_ON_X (50) +#define LED_ON_Y (80) +#define LED_OFF_Y (75) +#define LED_OFF_X (50) + +#define LED_ERR_X (56) +#define LED_ERR_Y (75) +#define LED_WTE_X (56) +#define LED_WTE_Y (80) +#define LED_SZE_X (4) +#define LED_SZE_Y (4) + +#define LED_PWR_X (53) +#define LED_PWR_Y (7) +#define LED_SND_X (47) +#define LED_SND_Y (7) +#define LED_RCV_X (41) +#define LED_RCV_Y (7) + +#define LED_SW_X (38) +#define LED_SW_Y (14) + +/*******************************************************************************\ +|* SetOnLED *| +\*******************************************************************************/ +void SetOnLED(int led) { + + switch (led) { + case LED_PPP_POWER: + copyXPMArea(LED_ON_X, LED_ON_Y, LED_SZE_X, LED_SZE_Y, LED_PWR_X, LED_PWR_Y); + break; + case LED_PPP_RX: + copyXPMArea(LED_ON_X, LED_ON_Y, LED_SZE_X, LED_SZE_Y, LED_RCV_X, LED_RCV_Y); + break; + case LED_PPP_TX: + copyXPMArea(LED_ON_X, LED_ON_Y, LED_SZE_X, LED_SZE_Y, LED_SND_X, LED_SND_Y); + break; + } +} + +/*******************************************************************************\ +|* SetOffLED *| +\*******************************************************************************/ +void SetOffLED(int led) { + + switch (led) { + case LED_PPP_POWER: + copyXPMArea(LED_OFF_X, LED_OFF_Y, LED_SZE_X, LED_SZE_Y, LED_PWR_X, LED_PWR_Y); + break; + case LED_PPP_RX: + copyXPMArea(LED_OFF_X, LED_OFF_Y, LED_SZE_X, LED_SZE_Y, LED_RCV_X, LED_RCV_Y); + break; + case LED_PPP_TX: + copyXPMArea(LED_OFF_X, LED_OFF_Y, LED_SZE_X, LED_SZE_Y, LED_SND_X, LED_SND_Y); + break; + + } +} + +/*******************************************************************************\ +|* SetErrLED *| +\*******************************************************************************/ +void SetErrLED(int led) { + + switch (led) { + case LED_PPP_POWER: + copyXPMArea(LED_ERR_X, LED_ERR_Y, LED_SZE_X, LED_SZE_Y, LED_PWR_X, LED_PWR_Y); + break; + } +} + +/*******************************************************************************\ +|* SetWaitLED *| +\*******************************************************************************/ +void SetWaitLED(int led) { + + switch (led) { + case LED_PPP_POWER: + copyXPMArea(LED_WTE_X, LED_WTE_Y, LED_SZE_X, LED_SZE_Y, LED_PWR_X, LED_PWR_Y); + break; + } +} + +/*******************************************************************************\ +|* ButtonUp *| +\*******************************************************************************/ +void ButtonUp(int button) { + + switch (button) { + case BUT_V : + copyXPMArea(24, 74, 12, 11, 35, 48); + break; + case BUT_X : + copyXPMArea(36, 74, 12, 11, 47, 48); + break; + } +} + +/*******************************************************************************\ +|* ButtonDown *| +\*******************************************************************************/ +void ButtonDown(int button) { + + switch (button) { + case BUT_V : + copyXPMArea(0, 74, 12, 11, 35, 48); + break; + case BUT_X : + copyXPMArea(12, 74, 12, 11, 47, 48); + break; + } +} diff --git a/wmppp.app/wmppp/Makefile b/wmppp.app/wmppp/Makefile deleted file mode 100644 index bd64608..0000000 --- a/wmppp.app/wmppp/Makefile +++ /dev/null @@ -1,36 +0,0 @@ -LIBDIR = -L/usr/X11R6/lib -LIBS = -lXpm -lXext -lX11 -CFLAGS += -O2 -OBJS = wmppp.o \ - ../wmgeneral/wmgeneral.o \ - ../wmgeneral/misc.o \ - ../wmgeneral/list.o - -.c.o: - cc -g -c $(CPPFLAGS) $(CFLAGS) -Wall $< -o $*.o - -wmppp: $(OBJS) - cc -o wmppp $(LDFLAGS) $^ -lXext $(LIBDIR) $(LIBS) - -all:: wmppp getmodemspeed - -clean:: - for i in $(OBJS) ; do \ - rm -f $$i; \ - done - rm -f wmppp getmodemspeed - -install:: - - cp -f wmppp /usr/local/bin/ - chmod 755 /usr/local/bin/wmppp - chown root:root /usr/local/bin/wmppp - cp getmodemspeed /etc/ppp/ - chmod 755 /etc/ppp/getmodemspeed - chown root.root /etc/ppp/getmodemspeed - cp -f user.wmppprc /etc/wmppprc - chmod 644 /etc/wmppprc - chown root.root /etc/wmppprc - cp -f user.wmppprc $(HOME)/.wmppprc - cp -f wmppp.1 /usr/local/share/man/man1 - echo "WMPPP installation finished." diff --git a/wmppp.app/wmppp/example-scripts/chap-secrets b/wmppp.app/wmppp/example-scripts/chap-secrets deleted file mode 100644 index 7d1c3cd..0000000 --- a/wmppp.app/wmppp/example-scripts/chap-secrets +++ /dev/null @@ -1,2 +0,0 @@ -# Secrets for authentication using CHAP -# client server secret IP addresses diff --git a/wmppp.app/wmppp/example-scripts/connect-errors b/wmppp.app/wmppp/example-scripts/connect-errors deleted file mode 100644 index e69de29..0000000 diff --git a/wmppp.app/wmppp/example-scripts/ip-down b/wmppp.app/wmppp/example-scripts/ip-down deleted file mode 100755 index 7915cea..0000000 --- a/wmppp.app/wmppp/example-scripts/ip-down +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -# ip-down -/sbin/route delete default - diff --git a/wmppp.app/wmppp/example-scripts/ip-up b/wmppp.app/wmppp/example-scripts/ip-up deleted file mode 100755 index 65d8fac..0000000 --- a/wmppp.app/wmppp/example-scripts/ip-up +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -# This file should not be modified -- make local changes to -# /etc/ppp/ip-up.local instead - -LOGDEVICE=$6 -REALDEVICE=$1 - -echo "$REALDEVICE" > /var/run/ppp-$LOGDEVICE.dev -[ -x /etc/ppp/ip-up.local ] && exec /etc/ppp/ip-up.local $* - -/etc/sysconfig/network-scripts/ifup-post ifcfg-${LOGDEVICE} - -exit 0 diff --git a/wmppp.app/wmppp/example-scripts/options b/wmppp.app/wmppp/example-scripts/options deleted file mode 100644 index a392e77..0000000 --- a/wmppp.app/wmppp/example-scripts/options +++ /dev/null @@ -1,10 +0,0 @@ -/dev/modem -38400 -modem -crtscts -lock -debug -defaultroute -netmask 255.255.255.0 -ipcp-accept-remote -disconnect "chat -- \d+++\d\c OK ath0 OK" diff --git a/wmppp.app/wmppp/example-scripts/pap-secrets b/wmppp.app/wmppp/example-scripts/pap-secrets deleted file mode 100644 index f8b7dce..0000000 --- a/wmppp.app/wmppp/example-scripts/pap-secrets +++ /dev/null @@ -1,2 +0,0 @@ -# Secrets for authentication using PAP -# client server secret IP addresses diff --git a/wmppp.app/wmppp/example-scripts/wmppp-chat b/wmppp.app/wmppp/example-scripts/wmppp-chat deleted file mode 100644 index 1f2b25a..0000000 --- a/wmppp.app/wmppp/example-scripts/wmppp-chat +++ /dev/null @@ -1,9 +0,0 @@ -ABORT BUSY -ABORT 'NO CARRIER' -ABORT 'RING - NO ANSWER' -REPORT CARRIER -REPORT CONNECT -'' ATZ -OK ATDT -ogin: -word: diff --git a/wmppp.app/wmppp/example-scripts/wmppp-ifdown b/wmppp.app/wmppp/example-scripts/wmppp-ifdown deleted file mode 100755 index 6bcc95e..0000000 --- a/wmppp.app/wmppp/example-scripts/wmppp-ifdown +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -# Try to restart pppd in case the modem has dropped. -# -/bin/sleep 60 -pppd diff --git a/wmppp.app/wmppp/example-scripts/wmppp-start b/wmppp.app/wmppp/example-scripts/wmppp-start deleted file mode 100755 index 7a7b7a3..0000000 --- a/wmppp.app/wmppp/example-scripts/wmppp-start +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -/usr/sbin/pppd connect '/usr/sbin/chat -v -f /etc/ppp/wmppp-chat' diff --git a/wmppp.app/wmppp/example-scripts/wmppp-stop b/wmppp.app/wmppp/example-scripts/wmppp-stop deleted file mode 100755 index 145f293..0000000 --- a/wmppp.app/wmppp/example-scripts/wmppp-stop +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -DEVICE=ppp0 - -if [ -r /var/run/$DEVICE.pid ]; then - kill -INT `cat /var/run/$DEVICE.pid` - - if [ ! "$?" = "0" ]; then - rm -f /var/run/$DEVICE.pid - echo >/dev/console "ERROR: Removed stale pid file" - exit 1 - fi - - echo >/dev/console "PPP link to $DEVICE terminated." - exit 0 -fi - -echo >/dev/console "ERROR: PPP link not active on $DEVICE" -exit 1 diff --git a/wmppp.app/wmppp/getmodemspeed.c b/wmppp.app/wmppp/getmodemspeed.c deleted file mode 100644 index 80e2ab1..0000000 --- a/wmppp.app/wmppp/getmodemspeed.c +++ /dev/null @@ -1,17 +0,0 @@ -#include <stdio.h> - -int main(void) { - - FILE *fd; - char temp[256]; - - fd = popen("tac /etc/ppp/connect-errors | grep '['CONNECT'|'CARRIER']' | head -1", "r"); - - while (fgets(temp, 256, fd)) { - printf("%s", temp); - } - - pclose(fd); - - return 0; -} diff --git a/wmppp.app/wmppp/system.wmppprc b/wmppp.app/wmppp/system.wmppprc deleted file mode 100644 index befc95c..0000000 --- a/wmppp.app/wmppp/system.wmppprc +++ /dev/null @@ -1,4 +0,0 @@ -forcespeed: /etc/ppp/getmodemspeed -forcestart: /etc/ppp/your-global-ppp-start-script-here -forcestop: /etc/ppp/your-global-ppp-stop-script-here -forceifdown: /etc/ppp/your-global-ppp-restart-script-here diff --git a/wmppp.app/wmppp/user.wmppprc b/wmppp.app/wmppp/user.wmppprc deleted file mode 100644 index ff2f528..0000000 --- a/wmppp.app/wmppp/user.wmppprc +++ /dev/null @@ -1,4 +0,0 @@ -speed: /etc/ppp/getmodemspeed -start: /foo/bar/your-personal-wmppp-start-script-here -stop: /foo/bar/your-personal-wmppp-stop-script-here -ifdown: /foo/bar/your-personal-wmppp-restart-script-here diff --git a/wmppp.app/wmppp/wmppp-master.xpm b/wmppp.app/wmppp/wmppp-master.xpm deleted file mode 100644 index f4fa754..0000000 --- a/wmppp.app/wmppp/wmppp-master.xpm +++ /dev/null @@ -1,133 +0,0 @@ -/* XPM */ -static char * wmppp_master_xpm[] = { -"64 114 16 1", -" c #00000000FFFF", -". c #000000000000", -"X c #208120812081", -"o c #C71BC30BC71B", -"O c #000049244103", -"+ c #28A23CF338E3", -"@ c #F7DEF3CEFFFF", -"# c #861782078E38", -"$ c #AEBAAAAAAEBA", -"% c #2081B2CAAEBA", -"& c #18618A288617", -"* c #B6DA04101861", -"= c #0000EBAD0000", -"- c #E79DC30B0820", -"; c #71C6E38D71C6", -": c #4924C30B4924", -" ", -" ", -" ", -" ", -" ................................. ..................... ", -" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo .XXXXXXXXXXXXXXXXXXXo ", -" .XXOOOXXXOOOXXXXXXXOOOXXXOOOXXXXo .XXXXXXXXXXXXXXXXXXXo ", -" .XOXXXOXOXXXOXXOXXOXXXOXOXXXOXXXo .XX++XXXX++XXXX++XXXo ", -" .XOXXXOXOXXXOXXOXXOXXXOXOXXXOXXXo .X++++XX++++XX++++XXo ", -" .XXOOOXXXOOOXXXXXXXOOOXXXOOOXXXXo .X++++XX++++XX++++XXo ", -" .XOXXXOXOXXXOXXXXXOXXXOXOXXXOXXXo .XX++XXXX++XXXX++XXXo ", -" .XOXXXOXOXXXOXXOXXOXXXOXOXXXOXXXo .XXXXXXXXXXXXXXXXXXXo ", -" .XXOOOXXXOOOXXXOXXXOOOXXXOOOXXXXo .XXXXXXXXXXXXXXXXXXXo ", -" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo .XXXXXXXXXXXXXXXXXXXo ", -" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo .XXXXXXXXXXXXXXXXXXXo ", -" ooooooooooooooooooooooooooooooooo ooooooooooooooooooooo ", -" ", -" ", -" ........................................................ ", -" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", -" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", -" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", -" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", -" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", -" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", -" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", -" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", -" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", -" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", -" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", -" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", -" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", -" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", -" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", -" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", -" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", -" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", -" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", -" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", -" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", -" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", -" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", -" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", -" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", -" oooooooooooooooooooooooooooooooooooooooooooooooooooooooo ", -" ", -" ", -" ............................ .......................... ", -" .XXXXXXXXXXXXXXXXXXXXXXXXXXo .@@@@@@@@@@@#@@@@@@@@@@@#o ", -" .XXXXXXXXXXXXXXXXXXXXXXXXXXo .@$$$$$$$$$$.@$$$$$$$$$$.o ", -" .XXXXXXXXXXXXXXXXXXXXXXXXXXo .@$$$$$$..$$.@$..$$$..$$.o ", -" .XXXXXXXXXXXXXXXXXXXXXXXXXXo .@$$$$$...$$.@$...$...$$.o ", -" .XXXXXXXXXXXXXXXXXXXXXXXXXXo .@$..$...$$$.@$$.....$$$.o ", -" .XXXXXXXXXXXXXXXXXXXXXXXXXXo .@$.....$$$$.@$$$...$$$$.o ", -" .XXXXXXXXXXXXXXXXXXXXXXXXXXo .@$....$$$$$.@$$.....$$$.o ", -" .XXXXXXXXXXXXXXXXXXXXXXXXXXo .@$...$$$$$$.@$...$...$$.o ", -" .XXXXXXXXXXXXXXXXXXXXXXXXXXo .@$..$$$$$$$.@$..$$$..$$.o ", -" .XXXXXXXXXXXXXXXXXXXXXXXXXXo .@$$$$$$$$$$.@$$$$$$$$$$.o ", -" .XXXXXXXXXXXXXXXXXXXXXXXXXXo .#...........#...........o ", -" oooooooooooooooooooooooooooo oooooooooooooooooooooooooo ", -" ", -" ", -" ", -" ", -"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", -"XX%%%XXXOOO&X&%%%&X&%%%&X&OOO&X&%%%&X&%%%&X&%%%&X&%%%&X&%%%&XXXX", -"X%XXX%XOXXX%XOXXX%XOXXX%X%XXX%X%XXXOX%XXXOXOXXX%X%XXX%X%XXX%XX%X", -"X%XXX%XOXXX%XOXXX%XOXXX%X%XXX%X%XXXOX%XXXOXOXXX%X%XXX%X%XXX%XX&X", -"X&OOO&XXOOO&X&%%%&XX%%%&X&%%%&X&%%%&X&%%%&XXOOO&X&%%%&X&%%%&XXXX", -"X%XXX%XOXXX%X%XXXOXOXXX%XOXXX%XOXXX%X%XXX%XOXXX%X%XXX%XOXXX%XXXX", -"X%XXX%XOXXX%X%XXXOXOXXX%XOXXX%XOXXX%X%XXX%XOXXX%X%XXX%XOXXX%XX%X", -"XX%%%XXXOOO&X&%%%&X&%%%&XXOOO&X&%%%&X&%%%&XXOOO&X&%%%&X&%%%&XX&X", -"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", -" ", -"...........#...........#@@@@@@@@@@@#@@@@@@@@@@@# ", -".$$$$$$$$$$@.$$$$$$$$$$@@$$$$$$$$$$.@$$$$$$$$$$. X++X X**X ", -".$$$$$$..$$@.$..$$$..$$@@$$$$$$..$$.@$..$$$..$$. ++++ *@** ", -".$$$$$...$$@.$...$...$$@@$$$$$...$$.@$...$...$$. ++++ **** ", -".$..$...$$$@.$$.....$$$@@$..$...$$$.@$$.....$$$. X++X X**X ", -".$.....$$$$@.$$$...$$$$@@$.....$$$$.@$$$...$$$$. ", -".$....$$$$$@.$$.....$$$@@$....$$$$$.@$$.....$$$. X==X X--X ", -".$...$$$$$$@.$...$...$$@@$...$$$$$$.@$...$...$$. =@== -@-- ", -".$..$$$$$$$@.$..$$$..$$@@$..$$$$$$$.@$..$$$..$$. ==== ---- ", -".$$$$$$$$$$@.$$$$$$$$$$@@$$$$$$$$$$.@$$$$$$$$$$. X==X X--X ", -"#@@@@@@@@@@@#@@@@@@@@@@@#...........#........... ", -" ;X%&; ", -"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", -"+++:X:;;:X:;;:X:++:X:;;:X:;;:X:;;:X:;;:X:;;:X:;;:X++++X++++X++++", -"+XX;X+XX;X+XX;X;XX;X;XX+X;XX+X+XX;X;XX;X;XX;X;XX;X+XX+X+XX+X+XX+", -"+XX;X+XX;X+XX;X;XX;X;XX+X;XX+X+XX;X;XX;X;XX;X;XX;X;XX;X;XX;X+XX+", -"+++:X:;;:X:;;:X:;;:X:;;:X:;;:X+++:X:;;:X:;;:X:++:X;+;+X;;;;X++++", -"+XX;X;XX+X+XX;X+XX;X+XX;X;XX;X+XX;X;XX;X+XX;X;XX;X;;X+X;XX;X+XX+", -"+XX;X;XX+X+XX;X+XX;X+XX;X;XX;X+XX;X;XX;X+XX;X;XX;X;X;+X;XX;X+XX+", -"+++;X:;;:X:;;:X+++:X:;;:X:;;:X+++:X:;;:X:;;:X:;;:X;++;X;++;X++++", -"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", -":;;:X:;;:X:;;:X:;;:X:;;:XXXX++++X++++X++++XXXXXX++++XXXXXXXXXXXX", -";XX+X;XX;X;XX;X;XX;X;XX;XXXX+XX+X+XX+X+XX+XXXXXX+XX+XXXXXXXXXXXX", -";XX+X;XX;X;XX;X;XX;X;XX;XXXX+XX+X+XX+X+XX+X+XX+X+XX+XXXXXXXXXXXX", -":;;+X:;;XX:;;XX:++:X:;;XXXXX++++X++++X++++X+X+XX++++XXXXXXXXXXXX", -";XX+X;XX;X;XX;X;XX;X;XX;XXXX+XX+X+XX+X+XX+X++XXX+XX+XXXXXXXXXXXX", -";XX+X;XX;X;XX;X;XX;X;XX;XXXX+XX+X+XX+X+XX+X+X+XX+XX+XXXXXXXXXXXX", -":;;:X:++:X:++:X:;;:X:++:XXXX++++X++++X++++X+XX+X++++XXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", -"XXOOOXXXOOOXXXXXXXOOOXXXOOOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", -"XOXXXOXOXXXOXXOXXOXXXOXOXXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", -"XOXXXOXOXXXOXXOXXOXXXOXOXXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", -"XXOOOXXXOOOXXXXXXXOOOXXXOOOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", -"XOXXXOXOXXXOXXXXXOXXXOXOXXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", -"XOXXXOXOXXXOXXOXXOXXXOXOXXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", -"XXOOOXXXOOOXXXOXXXOOOXXXOOOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"}; diff --git a/wmppp.app/wmppp/wmppp.1 b/wmppp.app/wmppp/wmppp.1 deleted file mode 100644 index 081a1e6..0000000 --- a/wmppp.app/wmppp/wmppp.1 +++ /dev/null @@ -1,103 +0,0 @@ -.\" -*-Nroff-*- -.\" -.TH wmppp.app 1 "September 1998" "Debian Project" "Debian GNU/Linux" -.SH NAME -wmppp \- Graphically monitor the average PPP load -.P -.SH SYNOPSIS -.B wmppp -.RB [\| \-display -.IR <display\ name> \|] -.RB [\| \-t \|] -.RB [\| \-u -.IR <update\ rate> \|] -.RB [\| \-i -.IR <device> \|] -.RB [\| \-h \|] -.RB [\| \-v \|] -.SH DESCRIPTION -\fBwmppp.app\fP displays a dynamic representation of the load on the -PPP line on a 64x64 miniwindow. It also starts and stops the -connection and displays the time enlapsed since the it came up. The -traffic on the interface is also monitored. -.SH OPTIONS -.TP -.B \-display <display\ name> -name of display to use -.TP -.B \-t -sets the on-line timer to display MM:SS instead of the default HH:MM. -.TP -.B \-u <update rate> -sets the frequency, in seconds, for updates to the display. Valid -range is 1-10, default value is 5. -.TP -.B \-i <device> -choose the net device (ppp1, ippp0, etc.) to monitor. (Note that this -feature is EXPERIMENTAL and should be used with caution. Bug reports -are welcomed.) -.TP -.B \-h -displays a command line summary -.TP -.B \-v -displays the version number. -.SH CONFIGURATION -The configuration file (see below) may contain any of the following -key-value pairs. The format is \fIkey: value\fP. -.TP -.I start -The program that starts the connection -.TP -.I stop -The program that stops the connection -.TP -.I speed -This program reports the speed of the connection. This program should -output \fI<speed>\fP, that is, a \fInumber\fP is expected and not the -whole \"CONNECT\" line the modem outputs. -.TP -.I ifdown -This program is run if the line goes down, and the \fIstop\fP program -hasn't been run. (Redial program) -.TP -.I stampfile -The modification time of this file is used to calculate the amount of -time the connection has been up. Something like \fItouch <stampfile>\fP -should be run for this to work. -.SH FILES -.TP -/var/run/wmppp.\fIppp0\fP -this is the stamp file use to determine the ammount of time enlapsed -since the connection came up. This file should be managed by the ip-up -and ip-down scripts. On Debian systems, \fI/etc/ppp/ip-up.d/00wmppp\fP -creates the file, and \fI/etc/ppp/ip-down.d/00wmppp\fP removes it. -.TP -/etc/wmppprc -System wide defaults -.TP -$HOME/.wmppprc -User defined settings -.TP -/etc/wmppprc.fixed -System wide fixed options, this overrides the user settings -.SH AUTHORS -\fBwmppp.app\fP was written by \fIMartijn Pieterse -<piete...@xs4all.nl>\fP and \fIAntoine Nulle <w...@xs4all.nl>\fP, and -it's based on work by \fIBeat Christen <bchri...@iiic.ethz.ch>\fP -(asclock) and \fIMichael Callahan <calla...@maths.ox.ac.uk>\fP, \fIAl -Longyear longy...@netcom.com\fP and \fIPaul Mackerras -<paul.macker...@cs.anu.edu.au>\fP (pppstats). -.P -Email regarding wmppp should be sent to -\fiwmaker-...@lists.windowmaker.org\fP. -.P -This manpage was written by \fIMarcelo Magallon -<mmaga...@debian.org\fP for the \fIDebian Project\fP -.SH "SEE ALSO" -.BR pppd (8), -.BR pppstats (8), -.BR plog (1), -.BR pon (1), -.BR poff (1) - diff --git a/wmppp.app/wmppp/wmppp.c b/wmppp.app/wmppp/wmppp.c deleted file mode 100644 index 97d386f..0000000 --- a/wmppp.app/wmppp/wmppp.c +++ /dev/null @@ -1,1013 +0,0 @@ -/* - Best viewed with vim5, using ts=4 - - This code was mainly put together by looking at the - following programs: - - asclock - A neat piece of equip, used to display the date - and time on the screen. - Comes with every WindowMaker installation. - - Source used: - How do I create a not so solid window? - How do I open a window? - How do I use pixmaps? - - pppstats - A program that prints the amount of data that - is transferred over a ppp-line. - - Source used: - How do I read the ppp device? - ------------------------------------------------------------ - - Authors: Martijn Pieterse (piete...@xs4all.nl) - Antoine Nulle (w...@xs4all.nl) - - This program might be Y2K resistant. We shall see. :) - - This program is distributed under the GPL license. - (as were asclock and pppstats) - - Known Features: (or in non M$ talk, BUGS) - * none known so far in this release - - ---- - Thanks - ---- - - CCC (Constructive Code Criticism): - - Marcelo E. Magallon - Thanks a LOT! It takes a while to get me convinced... :) - - - Minor bugs and ideas: - - Marc De Scheemaecker / David Mihm / Chris Soghoian / - Alessandro Usseglio Viretta - - and ofcourse numerous ppl who send us bug reports. - (numerous? hmm.. todo: rephrase this :) ) - Make that numberous m8ey :) - - ---- - Changes: - --- - 05/09/1998 (Martijn Pieterse, piete...@xs4all.nl) - * Added: - Speed-O-Meter (after 60 seconds) - Fixed Error reporting when pressing X - Removed the ugly kb lines - Stopped clearing on-line time when pressing X - Added createXBMfromXPM - 08/05/1998 (Martijn Pieterse, piete...@xs4all.nl) - * Removed some code from get_statistics - * Check if "ifdown" is empty before execCommanding it! - 07/05/1998 (Martijn Pieterse, piete...@xs4all.nl) - * Made the program use the xpm like warp wanted it to be :) - 04/05/1998 (Martijn Pieterse, piete...@xs4all.nl) - * Added pppX support. (EXPERIMENTAL!) - Removed HARD_CODED_DEV. (that stayed in long! :) ) - * Changed 33600 speed indication to 33k6 - Bugs if larger than 115k2 (depends on how much 1's present) - Moved the speed ind. code to DrawSpeedInd - * Added 1k lines in the stats - * Moved all the "ppp0" references into HARD_CODED_DEV. - for easy change - 03/05/1998 (Martijn Pieterse, piete...@xs4all.nl) - * Removed the number after -t. - 02/05/1998 (Martijn Pieterse, piete...@xs4all.nl) - * Removed the heyho code :) - * Changed read_rc_file to parse_rcfile. suggested bt Marcelo E. Magallon - * Added some extra checks for the -t option. - If no number was given, it would core dump - 30/04/1998 (Martijn Pieterse, piete...@xs4all.nl) - * Added execCommand code. (taken from windowmaker soure, as advised by Marcelo E. Magallon) - * Cleaned the source up a bit - * Decided to split op wmppp and wmifs - This is gonna be wmppp - * Used the DrawStats routine from wmifs in wmppp - * I decided to add a list in this source file - with name of ppl who helped me build this code better. - * I finally removed the /proc/net/route dependancy - All of the connections are taken from /proc/net/dev. - /proc/net/route is still used for checking if it is on-line. - 27/04/1998 (Martijn Pieterse, piete...@xs4all.nl) - * WMIFS: stats scrolled, while red led burning - * WMPPP: changed positions of line speed - 25/04/1998 (Martijn Pieterse, piete...@xs4all.nl) - * Changed the checknetdevs routine, a lot! - 23/04/1998 (Martijn Pieterse, piete...@xs4all.nl) - * Added line speed detection. via seperate exec. (this has to be suid root!) - Speed has to be no more than 99999 - * Added speed and forcespeed in ~/.wmppprc and /etc/wmppprc - * wmifs: added on-line detection scheme, update the bitmap coordinates - * wmppp: the x-button now allways disconnects. - 22/04/1998 (Martijn Pieterse, piete...@xs4all.nl) - * Added /etc/wmppprc support, including "forced" mode. - * Added /etc/wmifsrc support, including "forced" mode. - 21/04/1998 (Martijn Pieterse, piete...@xs4all.nl) - * Moved the stats one pixel down. - * Added status led in wmifs. - * Changed RX/TX leds of wmifs to resemble wmppp - * Added the "dot" between eth.0 ppp.0 etc. - * Changed to wmifs stats to match wmppp stats (only pppX changed) - * Made sure that when specified -t 1, it stayed that way, even - when longer than 100 minutes online - * With -t 1, jump from 59:59 to 01:00 instead of 99:59 to 01:40 - 16/04/1998 (Martijn Pieterse, piete...@xs4all.nl) - * Added "all" devices in wmifs - * Added "lo" support only if aked via -i - * Added on-line time detection (using /var/run/ppp0.pid) - * Added time-out for the orange led. (one minute) - 15/04/1998 (Martijn Pieterse, piete...@xs4all.nl) - * Another wmppp-master.xpm. - Line speed detection being the main problem here.. :( - * Moved START_COMMAND / STOP_COMMAND to ~/.wmppprc - Return 0, everything went ok. - Return 10, the command did not work. - Please note, these functions are ran in the background. - * Removed the ability to configure - * When "v" is clicked, an orange led will appear. - if the connect script fails (return value == 10) - it will become dark again. Else the on-line detection will - pick it up, and "green" it. - 14/04/1998 (Martijn Pieterse, piete...@xs4all.nl) - * Added "-timer" - * Added "-display" support - * Changed pixmap to a no-name pixmap. - + Changed LED positions - + Changed Timer position - + Changed Stats Size - 05/04/1998 (Martijn Pieterse, piete...@xs4all.nl) - * Added ~/.wmifsrc support. - * Put some code in DrawStats - * Check devices when pressing "device change" - 03/04/1998 (Martijn Pieterse, piete...@xs4all.nl) - * Added code for wmifs - 28/03/1998 (Martijn Pieterse, piete...@xs4all.nl) - * forgot what i did.. :) - 27/03/1998 (Martijn Pieterse, piete...@xs4all.nl) - * Added on-line detection - Scan through /proc/net/route and check everye line - for "ppp". - * A bit of code clean-up. -*/ - -#include <stdlib.h> -#include <stdio.h> -#include <time.h> -#include <string.h> -#include <fcntl.h> -#include <unistd.h> -#include <ctype.h> - -#include <sys/wait.h> -#include <sys/stat.h> -#include <sys/param.h> -#include <sys/types.h> -#include <sys/ioctl.h> -#include <sys/socket.h> - -#include <net/ppp_defs.h> -#include <net/if_ppp.h> - -#include <X11/Xlib.h> -#include <X11/xpm.h> -#include <X11/extensions/shape.h> - -#include "../wmgeneral/wmgeneral.h" -#include "../wmgeneral/misc.h" - -#include "wmppp-master.xpm" - - /***********/ - /* Defines */ -/***********/ - -#define START_ACTION (NULL) -#define STOP_ACTION (NULL) -#define SPEED_ACTION (NULL) -#define IFDOWN_ACTION (NULL) - -#define STAMP_FILE_PRE "/var/run/wmppp." - -/* Defines voor alle coordinate */ - -#define LED_PPP_RX (1) -#define LED_PPP_TX (2) -#define LED_PPP_POWER (3) - -#define BUT_V (1) -#define BUT_X (2) - -#define TIMER_X (9) -#define TIMER_Y (14) - -#define TIMER_SRC_Y (65) -#define TIMER_DES_Y (6) -#define TIMER_SZE_X (6) - -#define WMPPP_VERSION "1.3.0" - -#define ORANGE_LED_TIMEOUT (60) - - /**********************/ - /* External Variables */ -/**********************/ - -extern char **environ; - - /********************/ - /* Global Variables */ -/********************/ - -char *ProgName; -char *active_interface = "ppp0"; -int TimerDivisor=60; -int updaterate = 5; - -int wmppp_mask_width = 64; -int wmppp_mask_height = 64; -char wmppp_mask_bits[64*64]; - - - /*****************/ - /* PPP variables */ -/*****************/ - -#define PPP_UNIT 0 -int ppp_h = -1; - -#define PPP_STATS_HIS 54 - -int pixels_per_byte; - -int ppp_history[PPP_STATS_HIS+1][2]; - - /***********************/ - /* Function Prototypes */ -/***********************/ - -void usage(void); -void printversion(void); -void DrawTime(int, int); -void DrawStats(int *, int, int, int, int); -void DrawSpeedInd(char *); -void DrawLoadInd(int); - -void SetOnLED(int); -void SetErrLED(int); -void SetWaitLED(int); -void SetOffLED(int); - -void ButtonUp(int); -void ButtonDown(int); - -void wmppp_routine(int, char **); - -int get_statistics(char *, long *, long *, long *, long *); -void get_ppp_stats(struct ppp_stats *cur); -int stillonline(char *); - - - /********/ - /* Main */ -/********/ - -int main(int argc, char *argv[]) { - - int i; - - - /* Parse Command Line */ - - ProgName = argv[0]; - if (strlen(ProgName) >= 5) - ProgName += (strlen(ProgName) - 5); - - for (i=1; i<argc; i++) { - char *arg = argv[i]; - - if (*arg=='-') { - switch (arg[1]) { - case 'd' : - if (strcmp(arg+1, "display")) { - usage(); - exit(1); - } - break; - case 'g' : - if (strcmp(arg+1, "geometry")) { - usage(); - exit(1); - } - break; - case 'i' : - if (!argv[i+1]) { - usage(); - exit(1); - } - /* following removed to allow experiments with - * new devices, i.e. ippp - */ -#if 0 - if (strncmp(argv[i+1], "ppp", 3)) { - usage(); - exit(1); - } -#endif - active_interface = argv[i+1]; - i++; - break; - case 't' : - TimerDivisor = 1; - break; - case 'u' : - i++; - if (!argv[i]) { - usage(); - exit(1); - } - updaterate = atoi(argv[i]); - if (updaterate < 1 || updaterate > 10) { - usage(); - exit(1); - } - break; - case 'v' : - printversion(); - exit(0); - break; - default: - usage(); - exit(0); - break; - } - } - } - - wmppp_routine(argc, argv); - - return 0; -} - - /*****************/ - /* wmppp_routine */ -/*****************/ - -char *start_action = NULL; -char *stop_action = NULL; -char *speed_action = NULL; -char *ifdown_action = NULL; -char *stamp_file = NULL; - -void wmppp_routine(int argc, char **argv) { - - rckeys wmppp_keys[] = { - { "start", &start_action }, - { "stop", &stop_action }, - { "speed", &speed_action }, - { "ifdown", &ifdown_action }, - { "stampfile", &stamp_file }, - { NULL, NULL } - }; - - int i,j; - - int but_stat; - - long starttime; - long currenttime; - long lasttime; - long waittime; - long ppptime; - int hour,minute; - - long ppp_send,ppp_sl=-1; - long ppp_recv,ppp_rl=-1; - long ppp_sbytes,ppp_rbytes; - long ppp_osbytes,ppp_orbytes; - - struct stat st; - - pid_t stop_child = 0; - pid_t start_child = 0; - int status; - - XEvent Event; - - char *p; - char temp[128]; - - int speed_ind=60; - - /* Initialize some stuff */ - - get_statistics(active_interface, &ppp_rl, &ppp_sl, &ppp_orbytes, &ppp_osbytes); - - /* Scan through ~/.wmifsrc for the mouse button actions. */ - if (START_ACTION) start_action = strdup(START_ACTION); - if (STOP_ACTION) stop_action = strdup(STOP_ACTION); - if (SPEED_ACTION) speed_action = strdup(SPEED_ACTION); - if (IFDOWN_ACTION) ifdown_action = strdup(IFDOWN_ACTION); - if (STAMP_FILE_PRE) { - sprintf (temp, "%s%s", STAMP_FILE_PRE, active_interface); - stamp_file = strdup (temp); - } - - - strcpy(temp, "/etc/wmppprc"); - parse_rcfile(temp, wmppp_keys); - - p = getenv("HOME"); - strcpy(temp, p); - strcat(temp, "/.wmppprc"); - parse_rcfile(temp, wmppp_keys); - - strcpy(temp, "/etc/wmppprc.fixed"); - parse_rcfile(temp, wmppp_keys); - - /* Open the display */ - - createXBMfromXPM(wmppp_mask_bits, wmppp_master_xpm, wmppp_mask_width, wmppp_mask_height); - - openXwindow(argc, argv, wmppp_master_xpm, wmppp_mask_bits, wmppp_mask_width, wmppp_mask_height); - - /* V Button */ - AddMouseRegion(0, 35, 48, 46, 58); - /* x Button */ - AddMouseRegion(1, 47, 48, 58, 58); - - starttime = 0; - currenttime = time(0); - ppptime = 0; - but_stat = -1; - waittime = 0; - copyXPMArea(28, 95, 25, 11, 5, 48); - -/* wmppp main loop */ - while (1) { - lasttime = currenttime; - currenttime = time(0); - /* Check if any child has left the playground */ - i = waitpid(0, &status, WNOHANG); - if (i == stop_child && stop_child != 0) { - - starttime = 0; - SetOffLED(LED_PPP_POWER); - SetOffLED(LED_PPP_RX); - SetOffLED(LED_PPP_TX); - copyXPMArea(28, 95, 25, 11, 5, 48); - - RedrawWindow(); - - stop_child = 0; - } - if (i == start_child && start_child != 0) { - if (WIFEXITED(status)) { - if (WEXITSTATUS(status) == 10) { - - starttime = 0; - copyXPMArea(28, 95, 25, 11, 5, 48); - SetOffLED(LED_PPP_POWER); - DrawTime(0, 1); - RedrawWindow(); - } - start_child = 0; - } - } - - /* On-line detectie! 1x per second */ - - if (currenttime != lasttime) { - i = 0; - - if (stillonline(active_interface)) { - i = 1; - if (!starttime) { - starttime = currenttime; - - if (stat(stamp_file, &st) == 0) - starttime = st.st_mtime; - - SetOnLED(LED_PPP_POWER); - waittime = 0; - - copyXPMArea(28, 95, 25, 11, 5, 48); - - if (speed_action) - DrawSpeedInd(speed_action); - - speed_ind = currenttime + 60; - - RedrawWindow(); - } - } - if (!i && starttime) { - starttime = 0; - SetErrLED(LED_PPP_POWER); - - copyXPMArea(0, 95, 26, 11, 5, 48); - - if (ifdown_action) - execCommand(ifdown_action); - - RedrawWindow(); - } - } - - if (waittime && waittime <= currenttime) { - SetOffLED(LED_PPP_POWER); - RedrawWindow(); - waittime = 0; - } - - /* If we are on-line. Print the time we are */ - if (starttime) { - i = currenttime - starttime; - - i /= TimerDivisor; - - if (TimerDivisor == 1) - if (i > 59 * 60 + 59) i /= 60; - - minute = i % 60; - hour = (i / 60) % 100; - i = hour * 100 + minute; - - DrawTime(i, currenttime % 2); - /* We are online, so we can check for send/recv packets */ - - get_statistics(active_interface, &ppp_recv, &ppp_send, &ppp_rbytes, &ppp_sbytes); - - if (ppp_send != ppp_sl) SetOnLED(LED_PPP_TX); - else SetOffLED(LED_PPP_TX); - - if (ppp_recv != ppp_rl) SetOnLED(LED_PPP_RX); - else SetOffLED(LED_PPP_RX); - - ppp_sl = ppp_send; - ppp_rl = ppp_recv; - - /* Every five seconds we check to load on the line */ - - if ((currenttime - ppptime >= 0) || (ppptime == 0)) { - - ppptime = currenttime + updaterate; - - ppp_history[PPP_STATS_HIS][0] = ppp_rbytes - ppp_orbytes; - ppp_history[PPP_STATS_HIS][1] = ppp_sbytes - ppp_osbytes; - - ppp_orbytes = ppp_rbytes; - ppp_osbytes = ppp_sbytes; - - DrawStats(&ppp_history[0][0], 54, 25, 5, 43); - - for (j=1; j<55; j++) { - ppp_history[j-1][0] = ppp_history[j][0]; - ppp_history[j-1][1] = ppp_history[j][1]; - } - if (currenttime > speed_ind) { - DrawLoadInd((ppp_history[54][0] + ppp_history[54][1]) / updaterate); - } - } - - RedrawWindow(); - } - - - while (XPending(display)) { - XNextEvent(display, &Event); - switch (Event.type) { - case Expose: - RedrawWindow(); - break; - case DestroyNotify: - XCloseDisplay(display); - while (start_child | stop_child) { - i = waitpid(0, &status, WNOHANG); - if (i == stop_child) stop_child = 0; - if (i == start_child) start_child = 0; - usleep(50000l); - } - exit(0); - break; - case ButtonPress: - i = CheckMouseRegion(Event.xbutton.x, Event.xbutton.y); - switch (i) { - case 0: - ButtonDown(BUT_V); - break; - case 1: - ButtonDown(BUT_X); - break; - } - but_stat = i; - - RedrawWindow(); - break; - case ButtonRelease: - i = CheckMouseRegion(Event.xbutton.x, Event.xbutton.y); - // Button but_stat omhoogdoen! - switch (but_stat) { - case 0: - ButtonUp(BUT_V); - break; - case 1: - ButtonUp(BUT_X); - break; - } - - if (i == but_stat && but_stat >= 0) { - switch (i) { - case 0: - if (!starttime) { - copyXPMArea(28, 95, 25, 11, 5, 48); - DrawTime(0, 1); - start_child = execCommand(start_action); - SetWaitLED(LED_PPP_POWER); - waittime = ORANGE_LED_TIMEOUT + currenttime; - } - - break; - case 1: - if (stop_child == 0) { - stop_child = execCommand(stop_action); - } - break; - } - } - RedrawWindow(); - - but_stat = -1; - break; - default: - break; - } - } - usleep(50000L); - } -} - -/*******************************************************************************\ -|* get_statistics *| -\*******************************************************************************/ - -int get_statistics(char *devname, long *ip, long *op, long *is, long *os) { - - struct ppp_stats ppp_cur; - static int ppp_opened = 0; - - - if (!ppp_opened) { - /* Open the ppp device. */ - memset(&ppp_cur, 0, sizeof(ppp_cur)); - if ((ppp_h = socket(AF_INET, SOCK_DGRAM, 0)) < 0) - return -1; - ppp_opened = 1; - } - - get_ppp_stats(&ppp_cur); - - *op = ppp_cur.p.ppp_opackets; - *ip = ppp_cur.p.ppp_ipackets; - - *is = ppp_cur.p.ppp_ibytes; - *os = ppp_cur.p.ppp_obytes; - - return 0; -} - -/*******************************************************************************\ -|* stillonline *| -\*******************************************************************************/ - -int stillonline(char *ifs) { - - FILE *fp; - char temp[128]; - int i; - - i = 0; - fp = fopen("/proc/net/route", "r"); - if (fp) { - while (fgets(temp, 128, fp)) { - if (strstr(temp, ifs)) { - i = 1; /* Line is alive */ - } - } - fclose(fp); - } - return i; -} - -/*******************************************************************************\ -|* DrawTime *| -\*******************************************************************************/ - -void DrawTime(int i, int j) { - - int k = 1000; - - copyXPMArea(TIMER_SZE_X*((i / k)%10)+1, TIMER_SRC_Y, 5, 7, 6+6*0, TIMER_DES_Y); - k = k /10; - copyXPMArea(TIMER_SZE_X*((i / k)%10)+1, TIMER_SRC_Y, 5, 7, 6+6*1, TIMER_DES_Y); - k = k /10; - - if (j) - copyXPMArea(62, TIMER_SRC_Y, 1, 7, 6+6*2+1, TIMER_DES_Y); - else - copyXPMArea(63, TIMER_SRC_Y, 1, 7, 6+6*2+1, TIMER_DES_Y); - - copyXPMArea(TIMER_SZE_X*((i / k)%10)+1, TIMER_SRC_Y, 5, 7, 6+6*2 + 4, TIMER_DES_Y); - k = k /10; - copyXPMArea(TIMER_SZE_X*((i / k)%10)+1, TIMER_SRC_Y, 5, 7, 6+6*3 + 4, TIMER_DES_Y); -} - -/*******************************************************************************\ -|* DrawStats *| -\*******************************************************************************/ - -void DrawStats(int *his, int num, int size, int x_left, int y_bottom) { - - int pixels_per_byte; - int j,k; - int *p; - - pixels_per_byte = 1*size; - p = his; - for (j=0; j<num; j++) { - if (p[0] + p[1] > pixels_per_byte) - pixels_per_byte = p[0] + p[1]; - p += 2; - } - - pixels_per_byte /= size; - p = his; - - for (k=0; k<num; k++) { - - - for (j=0; j<size; j++) { - - if (j < p[0] / pixels_per_byte) - copyXPMArea(57+2, 85, 1, 1, k+x_left, y_bottom-j); - else if (j < (p[0] + p[1]) / pixels_per_byte) - copyXPMArea(57+1, 85, 1, 1, k+x_left, y_bottom-j); - else - copyXPMArea(57+0, 85, 1, 1, k+x_left, y_bottom-j); - } - p += 2; - } -} - -/*******************************************************************************\ -|* DrawSpeedInd *| -\*******************************************************************************/ - -void PrintLittle(int i, int *k) { - - switch (i) { - case -2: - *k -= 5; - /* Print the "k" letter */ - copyXPMArea(11*5-5, 86, 4, 9, *k, 48); - break; - case -1: - *k -= 5; - copyXPMArea(13*5-5, 86, 4, 9, *k, 48); - break; - case 0: - *k -= 5; - copyXPMArea(45, 86, 5, 9, *k, 48); - break; - default: - *k -= 5; - copyXPMArea(i*5-5, 86, 5, 9, *k, 48); - break; - } -} - -void DrawSpeedInd(char *speed_action) { - - int linespeed, i, k; - FILE *fp; - char *p; - char temp[128]; - - fp = popen(speed_action, "r"); - - if (fp) { - linespeed = 0; - - while (fgets(temp, 128, fp)) - ; - - pclose(fp); - - if ((p=strstr(temp, "CONNECT"))) { - linespeed = atoi(p + 8); - } - - k = 30; - - i = (linespeed % 1000) / 100; - linespeed /= 1000; - PrintLittle(i, &k); - - k -= 5; - copyXPMArea(50, 86, 5, 9, k, 48); - - do { - PrintLittle(linespeed % 10, &k); - linespeed /= 10; - } while (linespeed); - } -} - -/*******************************************************************************\ -|* DrawLoadInd *| -\*******************************************************************************/ - -void DrawLoadInd(int speed) { - - int i, k; - - k = 30; - for (i=0; i<5; i++) PrintLittle(-1, &k); - - k = 30; - - /* If speed is greater than 99999, display it in K */ - if (speed > 99999 ) - { - speed /= 1024 ; - PrintLittle(-2, &k) ; - } - - do { - PrintLittle(speed % 10, &k); - speed /= 10; - } while (speed); -} - -/*******************************************************************************\ -|* usage *| -\*******************************************************************************/ - -void usage(void) { - - fprintf(stderr, "\nwmppp - programming: tijno, design & ideas: warp\n\n"); - fprintf(stderr, "usage:\n"); - fprintf(stderr, "-display <display name>\n"); - fprintf(stderr, "-geometry +XPOS+YPOS initial window position\n"); - fprintf(stderr, "-h this help screen\n"); - fprintf(stderr, "-i <device> (ppp0, ppp1, etc) EXPERIMENTAL! Please send bugreports!\n"); - fprintf(stderr, "-t set the on-line timer to MM:SS instead of HH:MM\n"); - fprintf(stderr, "-u <update rate> (1..10), default 5 seconds\n"); - fprintf(stderr, "-v print the version number\n"); - fprintf(stderr, "\n"); -} - -/*******************************************************************************\ -|* printversion *| -\*******************************************************************************/ - -void printversion(void) { - - fprintf(stderr, "%s\n", WMPPP_VERSION); -} - -/*******************************************************************************\ -|* get_ppp_stats *| -\*******************************************************************************/ - -void get_ppp_stats(struct ppp_stats *cur) { - - struct ifpppstatsreq req; - - memset(&req, 0, sizeof(req)); - - req.stats_ptr = (caddr_t) &req.stats; - - strcpy(req.ifr__name, active_interface); - - if (ioctl(ppp_h, SIOCGPPPSTATS, &req) >= 0) - *cur = req.stats; -} - -#define LED_ON_X (50) -#define LED_ON_Y (80) -#define LED_OFF_Y (75) -#define LED_OFF_X (50) - -#define LED_ERR_X (56) -#define LED_ERR_Y (75) -#define LED_WTE_X (56) -#define LED_WTE_Y (80) -#define LED_SZE_X (4) -#define LED_SZE_Y (4) - -#define LED_PWR_X (53) -#define LED_PWR_Y (7) -#define LED_SND_X (47) -#define LED_SND_Y (7) -#define LED_RCV_X (41) -#define LED_RCV_Y (7) - -#define LED_SW_X (38) -#define LED_SW_Y (14) - -/*******************************************************************************\ -|* SetOnLED *| -\*******************************************************************************/ -void SetOnLED(int led) { - - switch (led) { - case LED_PPP_POWER: - copyXPMArea(LED_ON_X, LED_ON_Y, LED_SZE_X, LED_SZE_Y, LED_PWR_X, LED_PWR_Y); - break; - case LED_PPP_RX: - copyXPMArea(LED_ON_X, LED_ON_Y, LED_SZE_X, LED_SZE_Y, LED_RCV_X, LED_RCV_Y); - break; - case LED_PPP_TX: - copyXPMArea(LED_ON_X, LED_ON_Y, LED_SZE_X, LED_SZE_Y, LED_SND_X, LED_SND_Y); - break; - } -} - -/*******************************************************************************\ -|* SetOffLED *| -\*******************************************************************************/ -void SetOffLED(int led) { - - switch (led) { - case LED_PPP_POWER: - copyXPMArea(LED_OFF_X, LED_OFF_Y, LED_SZE_X, LED_SZE_Y, LED_PWR_X, LED_PWR_Y); - break; - case LED_PPP_RX: - copyXPMArea(LED_OFF_X, LED_OFF_Y, LED_SZE_X, LED_SZE_Y, LED_RCV_X, LED_RCV_Y); - break; - case LED_PPP_TX: - copyXPMArea(LED_OFF_X, LED_OFF_Y, LED_SZE_X, LED_SZE_Y, LED_SND_X, LED_SND_Y); - break; - - } -} - -/*******************************************************************************\ -|* SetErrLED *| -\*******************************************************************************/ -void SetErrLED(int led) { - - switch (led) { - case LED_PPP_POWER: - copyXPMArea(LED_ERR_X, LED_ERR_Y, LED_SZE_X, LED_SZE_Y, LED_PWR_X, LED_PWR_Y); - break; - } -} - -/*******************************************************************************\ -|* SetWaitLED *| -\*******************************************************************************/ -void SetWaitLED(int led) { - - switch (led) { - case LED_PPP_POWER: - copyXPMArea(LED_WTE_X, LED_WTE_Y, LED_SZE_X, LED_SZE_Y, LED_PWR_X, LED_PWR_Y); - break; - } -} - -/*******************************************************************************\ -|* ButtonUp *| -\*******************************************************************************/ -void ButtonUp(int button) { - - switch (button) { - case BUT_V : - copyXPMArea(24, 74, 12, 11, 35, 48); - break; - case BUT_X : - copyXPMArea(36, 74, 12, 11, 47, 48); - break; - } -} - -/*******************************************************************************\ -|* ButtonDown *| -\*******************************************************************************/ -void ButtonDown(int button) { - - switch (button) { - case BUT_V : - copyXPMArea(0, 74, 12, 11, 35, 48); - break; - case BUT_X : - copyXPMArea(12, 74, 12, 11, 47, 48); - break; - } -} -- 2.1.4 -- To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.