pochmara@cse.ogi.edu (John Pochmara) (03/20/91)
Submitted-by: John Pochmara <pochmara@cse.ogi.edu> Posting-number: Volume 12, Issue 44 Archive-name: xtr/part01 Xtr is an X front end to Suns' etherd network monitor. I have been using this version of xtr for about 3 month now and it seems pretty stable. Xtr still needs work (most notably in the 'host' window) but I thought some people might find it useful now. #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 1 (of 3)." # Contents: Imakefile Makefile README bar.c bar.h button.c button.h # compat.c display.h ether.h ether_clnt.c ether_xdr.c inbox.c # inbox.h label.c label.h misc.h rpc_stuff.h strip.h # Wrapped by pochmara@ogicse on Thu Mar 14 10:00:06 1991 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'Imakefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Imakefile'\" else echo shar: Extracting \"'Imakefile'\" \(416 characters\) sed "s/^X//" >'Imakefile' <<'END_OF_FILE' X DEPLIBS = $(DEPXLIB) XLOCAL_LIBRARIES = $(XLIB) X SRCS = bar.c button.c compat.c display.c \ X ether_clnt.c ether_xdr.c host.c inbox.c \ X label.c mask.c rpc_stuff.c stat.c \ X strip.c window.c xtr.c X OBJS = bar.o button.o compat.o display.o \ X ether_clnt.o ether_xdr.o host.o inbox.o \ X label.o mask.o rpc_stuff.o stat.o \ X strip.o window.o xtr.o X XComplexProgramTarget(xtr) END_OF_FILE if test 416 -ne `wc -c <'Imakefile'`; then echo shar: \"'Imakefile'\" unpacked with wrong size! fi # end of 'Imakefile' fi if test -f 'Makefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Makefile'\" else echo shar: Extracting \"'Makefile'\" \(1217 characters\) sed "s/^X//" >'Makefile' <<'END_OF_FILE' X# X# Makefile for xtr X# X# X# X# XSRC = xtr.c ether_clnt.c ether_xdr.c rpc_stuff.c display.c bar.c button.c\ X stat.c host.c strip.c mask.c inbox.c compat.c label.c XOBJ = xtr.o ether_clnt.o ether_xdr.o rpc_stuff.o display.o bar.o button.o\ X stat.o host.o strip.o mask.o inbox.o compat.o label.o XHDR = ether.h display.h misc.h rpc_stuff.h bar.h button.h strip.h inbox.h\ X label.h X X# X# Which C compiler to use X# XCC = gcc X X# X# OCC should be set to the C compiler that comes with the OS X# XOCC = cc X X# X# Must copy ether.x to curretn directory. X# ether.x is in /usr/include/rpcsvc X# X# This only need to be done if you have to X# remake ether.h, ether_xdr.c, and ether_clnt.c. X# XETHER_X = ether.x XLIBS = -lX11 XCFLAGS = -g X X.c.o: X $(CC) $(CFLAGS) -c $*.c X Xxtr: $(OBJ) X $(CC) $(CFLAGS) -o xtr $(OBJ) $(LIBS) X Xsxtr: $(OBJ) X $(CC) $(CFLAGS) -o xtr -Bstatic $(OBJ) $(LIBS) X X$(OBJ): $(HDR) X Xether.h: X rpcgen -h -o ether.h $(ETHER_X) X Xether_xdr.c: X rpcgen -c -o ether_xdr.c $(ETHER_X) X Xether_clnt.c: X rpcgen -l -o ether_clnt.c $(ETHER_X) X Xcompat.o: compat.c X $(OCC) $(CFLAGS) -c compat.c X Xtags: $(HDR) $(SRC) X rm -f tags X ctags $(HDR) $(SRC) X Xclean: X rm -f $(OBJ) X Xkit: X ls README Makefile Imakefile $(HDR) $(SRC) | makekit -s30k END_OF_FILE if test 1217 -ne `wc -c <'Makefile'`; then echo shar: \"'Makefile'\" unpacked with wrong size! fi # end of 'Makefile' fi if test -f 'README' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'README'\" else echo shar: Extracting \"'README'\" \(1415 characters\) sed "s/^X//" >'README' <<'END_OF_FILE' X X X X Xtr is an X front end to Suns' etherd network monitor. X I have been using this version of xtr for about 3 month X now and it seems pretty stable. Xtr still needs work X (most notably in the 'host' window) but I thought some X people might find it useful now. X X Compiling xtr is pretty straight forward. Xtr only use X X lib so it should be pretty painless to get running. X A few things need to be set in the Makefile, do that X then run make and xtr should be made. X X To run xtr do: X X % xtr <host> X X Where <host> is the hostname where etherd is running. X Using xtr is pretty easy the only thing that needs X explanation is the filters. So here it goes.... X X Four different filters can be set. They X are: X X packet length X IP protocol X Source address X Destination address X X The packet length filter excepts a single value X or a range of values. X X Example: X X 64 ( single ) X 200-1000 ( range ) X X The IP protocol filter excepts protocol numbers X or protocol names. X X Example: X X 6 ( number ) X tcp ( name ) X X The Source and Destination address filters except X Internet Address in dot notation or host names. X X Example: X X 137.39.1.2 X uunet.uu.net X X Plea for help. If anyone knows HOW to use the etherd filters X at the RPC level PLEASE ( I am begging here ) let me know. X How I am using them now is complete guess work. X X X X --John Pochmara X pochmara@ogicse.cse.ogi.edu X X END_OF_FILE if test 1415 -ne `wc -c <'README'`; then echo shar: \"'README'\" unpacked with wrong size! fi # end of 'README' fi if test -f 'bar.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'bar.c'\" else echo shar: Extracting \"'bar.c'\" \(4195 characters\) sed "s/^X//" >'bar.c' <<'END_OF_FILE' X/* X * X * bar.c X * X * X */ X#include <stdio.h> X#include <X11/Xlib.h> X#include "misc.h" X#include "display.h" X X X#define MAX_LEN (20) X#define MAX_BARS (1000) X Xstruct bargraph { X int b_id; X int b_val; X char b_lable[MAX_LEN]; X int b_llen; X int b_min; X int b_max; X float b_delta; X int b_width; X int b_height; X int b_x,b_y; X int b_bstart; X int b_mapped; X int b_small; X int b_clear; X Window b_win; X}; X Xstatic void DrawBarBar(); Xstatic void ClearBarBar(); Xvoid RedrawBar(); X Xstatic GC BarGC = 0; Xstatic struct bargraph BarArray[MAX_BARS]; Xstatic int LastBar = 0; X Xint CreateBarGraph( lable, min, max, width, height, small, bstart, x, y ) Xchar *lable; Xint min, max; Xint width, height; Xint small; Xint bstart; Xint x, y; X{ X int id; X X if( BarGC == 0 ) { X BarGC = XCreateGC( Dp, MainWin, 0, NULL ); X XSetState(Dp, BarGC, ForGndPix, BackGndPix, GXcopy, AllPlanes); X } X X id = LastBar++; X X strncpy( BarArray[id].b_lable, lable, MAX_LEN ); X BarArray[id].b_llen = strlen( lable ); X BarArray[id].b_min = min; X BarArray[id].b_max = max; X BarArray[id].b_width = width - 2; X BarArray[id].b_height = height - 2; X BarArray[id].b_x = x; X BarArray[id].b_y = y; X BarArray[id].b_val = 0; X BarArray[id].b_bstart = bstart; X BarArray[id].b_mapped = FALSE; X BarArray[id].b_small = small; X BarArray[id].b_clear = 1; X X BarArray[id].b_delta = (float)( width - bstart - 2 ) / X (float)( max - min ); X X BarArray[id].b_win = XCreateSimpleWindow( Dp, MainWin, x, y, width - 2, X height - 2, 1, ForGndPix, BackGndPix ); X X XSelectInput( Dp, BarArray[id].b_win, ExposureMask|StructureNotifyMask| X ButtonPressMask ); X X X return( id ); X X} X Xvoid ShowBar( id ) Xint id; X{ X XEvent ev; X X XMapWindow( Dp, BarArray[id].b_win ); X X FlushDpy(); X X while( 1 ) { X XNextEvent( Dp, &ev ); X if( ev.type == Expose ) { X break; X } X } X X BarArray[id].b_mapped = TRUE; X X} X Xvoid RedrawAllBars() X{ X int i; X X for( i = 0; i < LastBar; i++ ) { X if( BarArray[i].b_mapped == TRUE ) { X RedrawBar( i ); X } X } X X} X Xvoid HideBar( id ) Xint id; X{ X XUnmapWindow( Dp, BarArray[id].b_win ); X BarArray[id].b_mapped = FALSE; X} X Xvoid UpdateBarVal( id, val ) Xint id; Xint val; X{ X if( BarArray[id].b_val != val ) { X ClearBarBar( id ); X BarArray[id].b_val = val; X DrawBarBar( id ); X } X} X Xvoid RedrawBar( id ) Xint id; X{ X struct bargraph *bar; X char buf[512]; X int x, l; X X bar = &BarArray[id]; X X XClearWindow( Dp, bar->b_win ); X X if( bar->b_small == TRUE ) { X XDrawImageString( Dp, bar->b_win, Text5x8GC, 0, 10, X bar->b_lable, bar->b_llen ); X } else { X XDrawImageString( Dp, bar->b_win, Text6x10GC, 0, 10, X bar->b_lable, bar->b_llen ); X } X X sprintf( buf, "%d", bar->b_max ); X l = strlen( buf ); X x = bar->b_width - ( l * 5 ); X XDrawImageString( Dp, bar->b_win, Text5x8GC, x, 7, buf, l ); X X sprintf( buf, "%d", bar->b_min ); X l = strlen( buf ); X XDrawImageString( Dp, bar->b_win, Text5x8GC, bar->b_bstart, 7, buf, l ); X X DrawBarBar( id ); X X} X Xstatic void DrawBarBar( id ) Xint id; X{ X char buf[512]; X int val; X int bh, bw; X int x, l; X X val = BarArray[id].b_val; X if( val > BarArray[id].b_max ) { X val = BarArray[id].b_max; X } X X bw = (int)(((float)val) * BarArray[id].b_delta); X bh = BarArray[id].b_height - 8; X X XFillRectangle( Dp, BarArray[id].b_win, BarGC, BarArray[id].b_bstart, X 8, bw, bh ); X X sprintf( buf, "%d", BarArray[id].b_val ); X l = strlen( buf ); X x = BarArray[id].b_bstart + ( BarArray[id].b_width - X BarArray[id].b_bstart ) / 2; X x -= 5; X X XSetForeground( Dp, BarGC, BackGndPix ); X XSetBackground( Dp, BarGC, ForGndPix ); X XFillRectangle( Dp, BarArray[id].b_win, BarGC, x, 0, X BarArray[id].b_clear, 8 ); X XSetForeground( Dp, BarGC, ForGndPix ); X XSetBackground( Dp, BarGC, BackGndPix ); X X XDrawImageString( Dp, BarArray[id].b_win, Text5x8GC, x, 7, buf, l ); X X BarArray[id].b_clear = l * 5; X X} X Xstatic void ClearBarBar( id ) Xint id; X{ X int bh, bw; X X bw = (int)(((float)BarArray[id].b_val) * BarArray[id].b_delta); X bh = BarArray[id].b_height - 8; X X XSetForeground( Dp, BarGC, BackGndPix ); X XSetBackground( Dp, BarGC, ForGndPix ); X X XFillRectangle( Dp, BarArray[id].b_win, BarGC, BarArray[id].b_bstart, X 8, bw, bh ); X X XSetForeground( Dp, BarGC, ForGndPix ); X XSetBackground( Dp, BarGC, BackGndPix ); X X} END_OF_FILE if test 4195 -ne `wc -c <'bar.c'`; then echo shar: \"'bar.c'\" unpacked with wrong size! fi # end of 'bar.c' fi if test -f 'bar.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'bar.h'\" else echo shar: Extracting \"'bar.h'\" \(225 characters\) sed "s/^X//" >'bar.h' <<'END_OF_FILE' X#ifndef _BAR_H X#define _BAR_H X/* X * bar.h X * X * X */ X Xextern int CreateBarGraph(); Xextern void ShowBar(); Xextern void RedrawAllBars(); Xextern void HideBar(); Xextern void UpdateBarVal(); Xextern void RedrawBar(); X X#endif _BAR_H END_OF_FILE if test 225 -ne `wc -c <'bar.h'`; then echo shar: \"'bar.h'\" unpacked with wrong size! fi # end of 'bar.h' fi if test -f 'button.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'button.c'\" else echo shar: Extracting \"'button.c'\" \(2831 characters\) sed "s/^X//" >'button.c' <<'END_OF_FILE' X/* X * X * button.c X * X * X */ X#include <stdio.h> X#include <X11/Xlib.h> X#include "misc.h" X#include "display.h" X X#define MAX_LABLE (50) X#define MAX_BUTTONS (100) X Xstruct button { X char bn_lable[MAX_LABLE]; X int (*bn_func)(); X int bn_width; X int bn_height; X int bn_x; X int bn_y; X Window bn_win; X int bn_mapped; X}; X Xvoid FlashButton(); Xvoid RedrawButton(); X X Xstatic struct button ButtonArray[MAX_BUTTONS]; Xstatic int LastButton = 0; X Xstatic GC ButGC = 0; X Xint CreateButton( lable, width, height, x, y, func ) Xchar *lable; Xint width; Xint height; Xint x, y; Xint (*func)(); X{ X int id; X X if( ButGC == 0 ) { X ButGC = XCreateGC( Dp, MainWin, 0, NULL ); X XSetState(Dp, ButGC, ForGndPix, BackGndPix, GXcopy, AllPlanes); X } X X id = LastButton++; X X ButtonArray[id].bn_width = width; X ButtonArray[id].bn_height = height; X ButtonArray[id].bn_x = x; X ButtonArray[id].bn_y = y; X ButtonArray[id].bn_func = func; X ButtonArray[id].bn_mapped = FALSE; X X strncpy( ButtonArray[id].bn_lable, lable, MAX_LABLE ); X X ButtonArray[id].bn_win = XCreateSimpleWindow( Dp, MainWin, x, y, width, X height, 1, ForGndPix, BackGndPix ); X X XSelectInput( Dp, ButtonArray[id].bn_win, X ExposureMask|StructureNotifyMask|ButtonPressMask ); X X return( id ); X X} X Xvoid ShowButton( id ) Xint id; X{ X XEvent ev; X X X XMapWindow( Dp, ButtonArray[id].bn_win ); X X while( 1 ) { X XNextEvent( Dp, &ev ); X if( ev.type == Expose ) { X break; X } X } X X ButtonArray[id].bn_mapped = TRUE; X} X Xvoid HideButton( id ) Xint id; X{ X XUnmapWindow( Dp, ButtonArray[id].bn_win ); X ButtonArray[id].bn_mapped = FALSE; X} X Xvoid RedrawAllButtons() X{ X int i; X X for( i = 0; i < LastButton; i++ ) { X if( ButtonArray[i].bn_mapped == TRUE ) { X RedrawButton( i ); X } X } X} X Xvoid RedrawButton( id ) Xint id; X{ X struct button *but; X int x, y; X int l; X X but =&ButtonArray[id]; X X l = strlen( but->bn_lable ); X X x = ( but->bn_width - ( l * 6 ) ) / 2; X X if( but->bn_height < 10 ) { X y = but->bn_height + ( 10 - but->bn_height ) / 2 - 1; X } else { X y = but->bn_height / 2 + 5; X } X X XClearWindow( Dp, but->bn_win ); X XDrawImageString(Dp, but->bn_win, Text6x10GC, x, y, but->bn_lable,l); X X} X Xvoid ChangeButtonLable( id, lable ) Xint id; Xchar *lable; X{ X strncpy( ButtonArray[id].bn_lable, lable, MAX_LABLE ); X RedrawButton( id ); X} X X Xint DoButtonPress( win ) XWindow win; X{ X int i; X X for( i = 0; i < LastButton; i++ ) { X X if( ButtonArray[i].bn_win == win ) { X FlashButton( i ); X (ButtonArray[i].bn_func)(); X return( TRUE ); X } X } X X return( FALSE ); X X} X X Xvoid FlashButton( id ) Xint id; X{ X struct button *but; X int i; X X but = &ButtonArray[id]; X X XSetFunction( Dp, ButGC, GXinvert ); X X XFillRectangle( Dp, but->bn_win, ButGC, 0, 0, but->bn_width, X but->bn_height ); X SyncDpy(); X X XFillRectangle( Dp, but->bn_win, ButGC, 0, 0, but->bn_width, X but->bn_height ); X X XSetFunction( Dp, ButGC, GXcopy ); X} X X END_OF_FILE if test 2831 -ne `wc -c <'button.c'`; then echo shar: \"'button.c'\" unpacked with wrong size! fi # end of 'button.c' fi if test -f 'button.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'button.h'\" else echo shar: Extracting \"'button.h'\" \(304 characters\) sed "s/^X//" >'button.h' <<'END_OF_FILE' X#ifndef _BUTTON_H X#define _BUTTON_H X/* X * button.h X * X */ X Xextern int CreateButton(); Xextern void ShowButton(); Xextern void HideButton(); Xextern void RedrawAllButtons(); Xextern void RedrawButton(); Xextern void ChangeButtonLable(); Xextern int DoButtonPress(); Xextern void FlashButton(); X X#endif _BUTTON_H END_OF_FILE if test 304 -ne `wc -c <'button.h'`; then echo shar: \"'button.h'\" unpacked with wrong size! fi # end of 'button.h' fi if test -f 'compat.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'compat.c'\" else echo shar: Extracting \"'compat.c'\" \(210 characters\) sed "s/^X//" >'compat.c' <<'END_OF_FILE' X/* X * compat.c X * X * X */ X X#include <sys/types.h> X#include <sys/socket.h> X#include <netinet/in.h> X#include <arpa/inet.h> X X Xchar *NetAddrToString( addr ) Xstruct in_addr *addr; X{ X return( inet_ntoa( *addr ) ); X} X END_OF_FILE if test 210 -ne `wc -c <'compat.c'`; then echo shar: \"'compat.c'\" unpacked with wrong size! fi # end of 'compat.c' fi if test -f 'display.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'display.h'\" else echo shar: Extracting \"'display.h'\" \(555 characters\) sed "s/^X//" >'display.h' <<'END_OF_FILE' X#ifndef _DISPLAY_H X#define _DISPLAY_H X/* X * display.h X * X * X */ X#include <X11/Xlib.h> X X Xextern Display *Dp; Xextern Window MainWin; Xextern Visual *MVis; Xextern GC Text6x10GC; Xextern GC Text5x8GC; Xextern Font Fnt6x10; Xextern Font Fnt5x8; Xextern int screen; X Xextern int ForGndPix; Xextern int BackGndPix; X Xextern void InitWin(); Xextern void FlushDpy(); Xextern void ResizeWindow(); Xextern void SetHost(); Xextern void SetInterval(); Xextern void IncInterval(); Xextern void DecInterval(); Xextern void DoEvents(); Xextern int GetDefaultValInt(); X X#endif _DISPLAY_H END_OF_FILE if test 555 -ne `wc -c <'display.h'`; then echo shar: \"'display.h'\" unpacked with wrong size! fi # end of 'display.h' fi if test -f 'ether.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'ether.h'\" else echo shar: Extracting \"'ether.h'\" \(1777 characters\) sed "s/^X//" >'ether.h' <<'END_OF_FILE' X/* X * Please do not edit this file. X * It was generated using rpcgen. X */ X X#include <rpc/types.h> X X#define NBUCKETS 16 X#define NPROTOS 6 X#define HASHSIZE 256 X Xstruct ethertimeval { X u_int tv_seconds; X u_int tv_useconds; X}; Xtypedef struct ethertimeval ethertimeval; Xbool_t xdr_ethertimeval(); X Xstruct etherstat { X ethertimeval e_time; X u_int e_bytes; X u_int e_packets; X u_int e_bcast; X u_int e_size[NBUCKETS]; X u_int e_proto[NPROTOS]; X}; Xtypedef struct etherstat etherstat; Xbool_t xdr_etherstat(); X Xstruct etherhmem_node { X int h_addr; X u_int h_cnt; X struct etherhmem_node *h_nxt; X}; Xtypedef struct etherhmem_node etherhmem_node; Xbool_t xdr_etherhmem_node(); X Xtypedef etherhmem_node *etherhmem; Xbool_t xdr_etherhmem(); X Xstruct etheraddrs { X ethertimeval e_time; X u_int e_bytes; X u_int e_packets; X u_int e_bcast; X etherhmem e_addrs[HASHSIZE]; X}; Xtypedef struct etheraddrs etheraddrs; Xbool_t xdr_etheraddrs(); X Xstruct addrmask { X int a_addr; X int a_mask; X}; Xtypedef struct addrmask addrmask; Xbool_t xdr_addrmask(); X X#define ETHERPROG ((u_long)100010) X#define ETHERVERS ((u_long)1) X#define ETHERPROC_GETDATA ((u_long)1) Xextern etherstat *etherproc_getdata_1(); X#define ETHERPROC_ON ((u_long)2) Xextern void *etherproc_on_1(); X#define ETHERPROC_OFF ((u_long)3) Xextern void *etherproc_off_1(); X#define ETHERPROC_GETSRCDATA ((u_long)4) Xextern etheraddrs *etherproc_getsrcdata_1(); X#define ETHERPROC_GETDSTDATA ((u_long)5) Xextern etheraddrs *etherproc_getdstdata_1(); X#define ETHERPROC_SELECTSRC ((u_long)6) Xextern void *etherproc_selectsrc_1(); X#define ETHERPROC_SELECTDST ((u_long)7) Xextern void *etherproc_selectdst_1(); X#define ETHERPROC_SELECTPROTO ((u_long)8) Xextern void *etherproc_selectproto_1(); X#define ETHERPROC_SELECTLNTH ((u_long)9) Xextern void *etherproc_selectlnth_1(); END_OF_FILE if test 1777 -ne `wc -c <'ether.h'`; then echo shar: \"'ether.h'\" unpacked with wrong size! fi # end of 'ether.h' fi if test -f 'ether_clnt.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'ether_clnt.c'\" else echo shar: Extracting \"'ether_clnt.c'\" \(2713 characters\) sed "s/^X//" >'ether_clnt.c' <<'END_OF_FILE' X/* X * Please do not edit this file. X * It was generated using rpcgen. X */ X X#include <rpc/rpc.h> X#include "ether.h" X X/* Default timeout can be changed using clnt_control() */ Xstatic struct timeval TIMEOUT = { 25, 0 }; X Xetherstat * Xetherproc_getdata_1(argp, clnt) X void *argp; X CLIENT *clnt; X{ X static etherstat res; X X bzero((char *)&res, sizeof(res)); X if (clnt_call(clnt, ETHERPROC_GETDATA, xdr_void, argp, xdr_etherstat, &res, TIMEOUT) != RPC_SUCCESS) { X return (NULL); X } X return (&res); X} X Xvoid * Xetherproc_on_1(argp, clnt) X void *argp; X CLIENT *clnt; X{ X static char res; X X bzero((char *)&res, sizeof(res)); X if (clnt_call(clnt, ETHERPROC_ON, xdr_void, argp, xdr_void, &res, TIMEOUT) != RPC_SUCCESS) { X return (NULL); X } X return ((void *)&res); X} X Xvoid * Xetherproc_off_1(argp, clnt) X void *argp; X CLIENT *clnt; X{ X static char res; X X bzero((char *)&res, sizeof(res)); X if (clnt_call(clnt, ETHERPROC_OFF, xdr_void, argp, xdr_void, &res, TIMEOUT) != RPC_SUCCESS) { X return (NULL); X } X return ((void *)&res); X} X Xetheraddrs * Xetherproc_getsrcdata_1(argp, clnt) X void *argp; X CLIENT *clnt; X{ X static etheraddrs res; X X bzero((char *)&res, sizeof(res)); X if (clnt_call(clnt, ETHERPROC_GETSRCDATA, xdr_void, argp, xdr_etheraddrs, &res, TIMEOUT) != RPC_SUCCESS) { X return (NULL); X } X return (&res); X} X Xetheraddrs * Xetherproc_getdstdata_1(argp, clnt) X void *argp; X CLIENT *clnt; X{ X static etheraddrs res; X X bzero((char *)&res, sizeof(res)); X if (clnt_call(clnt, ETHERPROC_GETDSTDATA, xdr_void, argp, xdr_etheraddrs, &res, TIMEOUT) != RPC_SUCCESS) { X return (NULL); X } X return (&res); X} X Xvoid * Xetherproc_selectsrc_1(argp, clnt) X addrmask *argp; X CLIENT *clnt; X{ X static char res; X X bzero((char *)&res, sizeof(res)); X if (clnt_call(clnt, ETHERPROC_SELECTSRC, xdr_addrmask, argp, xdr_void, &res, TIMEOUT) != RPC_SUCCESS) { X return (NULL); X } X return ((void *)&res); X} X Xvoid * Xetherproc_selectdst_1(argp, clnt) X addrmask *argp; X CLIENT *clnt; X{ X static char res; X X bzero((char *)&res, sizeof(res)); X if (clnt_call(clnt, ETHERPROC_SELECTDST, xdr_addrmask, argp, xdr_void, &res, TIMEOUT) != RPC_SUCCESS) { X return (NULL); X } X return ((void *)&res); X} X Xvoid * Xetherproc_selectproto_1(argp, clnt) X addrmask *argp; X CLIENT *clnt; X{ X static char res; X X bzero((char *)&res, sizeof(res)); X if (clnt_call(clnt, ETHERPROC_SELECTPROTO, xdr_addrmask, argp, xdr_void, &res, TIMEOUT) != RPC_SUCCESS) { X return (NULL); X } X return ((void *)&res); X} X Xvoid * Xetherproc_selectlnth_1(argp, clnt) X addrmask *argp; X CLIENT *clnt; X{ X static char res; X X bzero((char *)&res, sizeof(res)); X if (clnt_call(clnt, ETHERPROC_SELECTLNTH, xdr_addrmask, argp, xdr_void, &res, TIMEOUT) != RPC_SUCCESS) { X return (NULL); X } X return ((void *)&res); X} END_OF_FILE if test 2713 -ne `wc -c <'ether_clnt.c'`; then echo shar: \"'ether_clnt.c'\" unpacked with wrong size! fi # end of 'ether_clnt.c' fi if test -f 'ether_xdr.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'ether_xdr.c'\" else echo shar: Extracting \"'ether_xdr.c'\" \(2061 characters\) sed "s/^X//" >'ether_xdr.c' <<'END_OF_FILE' X/* X * Please do not edit this file. X * It was generated using rpcgen. X */ X X#include <rpc/rpc.h> X#include "ether.h" X Xbool_t Xxdr_ethertimeval(xdrs, objp) X XDR *xdrs; X ethertimeval *objp; X{ X if (!xdr_u_int(xdrs, &objp->tv_seconds)) { X return (FALSE); X } X if (!xdr_u_int(xdrs, &objp->tv_useconds)) { X return (FALSE); X } X return (TRUE); X} X Xbool_t Xxdr_etherstat(xdrs, objp) X XDR *xdrs; X etherstat *objp; X{ X if (!xdr_ethertimeval(xdrs, &objp->e_time)) { X return (FALSE); X } X if (!xdr_u_int(xdrs, &objp->e_bytes)) { X return (FALSE); X } X if (!xdr_u_int(xdrs, &objp->e_packets)) { X return (FALSE); X } X if (!xdr_u_int(xdrs, &objp->e_bcast)) { X return (FALSE); X } X if (!xdr_vector(xdrs, (char *)objp->e_size, NBUCKETS, sizeof(u_int), xdr_u_int)) { X return (FALSE); X } X if (!xdr_vector(xdrs, (char *)objp->e_proto, NPROTOS, sizeof(u_int), xdr_u_int)) { X return (FALSE); X } X return (TRUE); X} X Xbool_t Xxdr_etherhmem_node(xdrs, objp) X XDR *xdrs; X etherhmem_node *objp; X{ X if (!xdr_int(xdrs, &objp->h_addr)) { X return (FALSE); X } X if (!xdr_u_int(xdrs, &objp->h_cnt)) { X return (FALSE); X } X if (!xdr_pointer(xdrs, (char **)&objp->h_nxt, sizeof(etherhmem_node), xdr_etherhmem_node)) { X return (FALSE); X } X return (TRUE); X} X Xbool_t Xxdr_etherhmem(xdrs, objp) X XDR *xdrs; X etherhmem *objp; X{ X if (!xdr_pointer(xdrs, (char **)objp, sizeof(etherhmem_node), xdr_etherhmem_node)) { X return (FALSE); X } X return (TRUE); X} X Xbool_t Xxdr_etheraddrs(xdrs, objp) X XDR *xdrs; X etheraddrs *objp; X{ X if (!xdr_ethertimeval(xdrs, &objp->e_time)) { X return (FALSE); X } X if (!xdr_u_int(xdrs, &objp->e_bytes)) { X return (FALSE); X } X if (!xdr_u_int(xdrs, &objp->e_packets)) { X return (FALSE); X } X if (!xdr_u_int(xdrs, &objp->e_bcast)) { X return (FALSE); X } X if (!xdr_vector(xdrs, (char *)objp->e_addrs, HASHSIZE, sizeof(etherhmem), xdr_etherhmem)) { X return (FALSE); X } X return (TRUE); X} X Xbool_t Xxdr_addrmask(xdrs, objp) X XDR *xdrs; X addrmask *objp; X{ X if (!xdr_int(xdrs, &objp->a_addr)) { X return (FALSE); X } X if (!xdr_int(xdrs, &objp->a_mask)) { X return (FALSE); X } X return (TRUE); X} END_OF_FILE if test 2061 -ne `wc -c <'ether_xdr.c'`; then echo shar: \"'ether_xdr.c'\" unpacked with wrong size! fi # end of 'ether_xdr.c' fi if test -f 'inbox.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'inbox.c'\" else echo shar: Extracting \"'inbox.c'\" \(3917 characters\) sed "s/^X//" >'inbox.c' <<'END_OF_FILE' X/* X * inbox.c X * X * X */ X#include <stdio.h> X#include <ctype.h> X#include <X11/Xlib.h> X#include "display.h" X#include "misc.h" X X#define MAX_INBOX (100) X X#define BS (0x08) X#define DEL (0x07f) X X Xstruct inbox { X int ib_width; X int ib_height; X int ib_x; X int ib_y; X int ib_index; X char *ib_buf; X int ib_blen; X Window ib_win; X int ib_mapped; X}; X Xstatic GC InBoxGC = 0; Xstatic Cursor InBoxCursor; X Xstatic struct inbox InBoxArray[MAX_INBOX]; Xstatic int LastInBox = 0; X Xstatic char KeyEvToASCII(); Xstatic void AddCharToInBox(); Xstatic void DrawCharToInBox(); Xvoid RedrawInputBox(); X Xint CreateInputBox( width, height, x, y, len ) Xint width; Xint height; Xint x, y; Xint len; X{ X XSetWindowAttributes winatt; X int id; X X if( InBoxGC == 0 ) { X InBoxGC = XCreateGC( Dp, MainWin, 0, NULL ); X XSetState(Dp,InBoxGC, ForGndPix, BackGndPix, GXcopy, AllPlanes); X InBoxCursor = XCreateFontCursor( Dp, 152 ); X } X X id = LastInBox++; X X InBoxArray[id].ib_width = width; X InBoxArray[id].ib_height = height; X InBoxArray[id].ib_x = x; X InBoxArray[id].ib_y = y; X InBoxArray[id].ib_index = 0; X InBoxArray[id].ib_buf = (char *)malloc( sizeof(char) * len + 1 ); X InBoxArray[id].ib_blen = len; X InBoxArray[id].ib_mapped = FALSE; X X InBoxArray[id].ib_win = XCreateSimpleWindow( Dp, MainWin, x, y, X width - 2, height - 2, 1, ForGndPix, BackGndPix ); X X XSelectInput( Dp, InBoxArray[id].ib_win, X ExposureMask|StructureNotifyMask|ButtonPressMask X |KeyPressMask ); X X winatt.cursor = InBoxCursor; X XChangeWindowAttributes( Dp, InBoxArray[id].ib_win, CWCursor, &winatt ); X X X return( id ); X} X Xchar *GetInputBoxData( id ) Xint id; X{ X char *t; X int i; X X if( InBoxArray[id].ib_index <= 0 ) { X return( NULL ); X } X X t = (char *)malloc( InBoxArray[id].ib_index + 1 ); X X for( i = 0; i < InBoxArray[id].ib_index; i++ ) { X *(t+i) = *(InBoxArray[id].ib_buf+i); X } X X *(t+InBoxArray[id].ib_index) = NULL; X X return( t ); X X} X Xvoid SetInputBoxData( id, data ) Xint id; Xchar *data; X{ X strncpy( InBoxArray[id].ib_buf, data, InBoxArray[id].ib_index ); X InBoxArray[id].ib_index = strlen( data ); X RedrawInputBox( id ); X} X Xvoid ShowInputBox( id ) Xint id; X{ X XEvent ev; X X X XMapWindow( Dp, InBoxArray[id].ib_win ); X X while( 1 ) { X XNextEvent( Dp, &ev ); X if( ev.type == Expose ) { X break; X } X } X X InBoxArray[id].ib_mapped = TRUE; X} X Xvoid HideInputBox( id ) Xint id; X{ X XUnmapWindow( Dp, InBoxArray[id].ib_win ); X InBoxArray[id].ib_mapped = FALSE; X} X Xvoid RedrawAllInputBoxes() X{ X int i; X X for( i = 0; i < LastInBox; i++ ) { X if( InBoxArray[i].ib_mapped == TRUE ) { X RedrawInputBox( i ); X } X } X} X Xvoid RedrawInputBox( id ) Xint id; X{ X struct inbox *box; X X box = &InBoxArray[id]; X X XClearWindow( Dp, box->ib_win ); X XDrawImageString(Dp, box->ib_win, Text6x10GC, X 0, 10, box->ib_buf, box->ib_index ); X X X} X Xvoid DoKeyInput( key_ev ) XXKeyEvent *key_ev; X{ X char c; X int i; X X for( i = 0; i < LastInBox; i++ ) { X X if( key_ev->window == InBoxArray[i].ib_win ) { X X if( KeyEvToASCII( key_ev, &c ) == TRUE ) { X AddCharToInBox( &InBoxArray[i], c ); X } X return; X } X } X} X Xstatic void AddCharToInBox( box, c ) Xstruct inbox *box; Xchar c; X{ X X if( ( c == BS ) || ( c == DEL ) ) { X X if( box->ib_index > 0 ) { X box->ib_index--; X DrawCharToInBox( box, ' ' ); X } X X } else if( isprint( c ) && !isspace( c ) ) { X X if( box->ib_index < box->ib_blen ) { X DrawCharToInBox( box, c ); X *(box->ib_buf+box->ib_index) = c; X box->ib_index++; X } X X } X X} X Xstatic void DrawCharToInBox( box, c ) Xstruct inbox *box; Xchar c; X{ X XDrawImageString(Dp, box->ib_win, Text6x10GC, X box->ib_index * 6, 10, &c, 1); X} X Xstatic char KeyEvToASCII( key_ev, c ) XXKeyEvent *key_ev; Xchar *c; X{ X char buf; X int n; X X n = XLookupString( key_ev, &buf, sizeof( buf ), NULL, NULL ); X X X if( n > 0 ) { X *c = buf; X return( TRUE ); X } else { X return( FALSE ); X } X} X X END_OF_FILE if test 3917 -ne `wc -c <'inbox.c'`; then echo shar: \"'inbox.c'\" unpacked with wrong size! fi # end of 'inbox.c' fi if test -f 'inbox.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'inbox.h'\" else echo shar: Extracting \"'inbox.h'\" \(313 characters\) sed "s/^X//" >'inbox.h' <<'END_OF_FILE' X#ifndef _INBOX_H X#define _INBOX_H X/* X * inbox.h X * X */ X Xextern int CreateInputBox(); Xextern void ShowInputBox(); Xextern void HideInputBox(); Xextern void RedrawAllInputBoxes(); Xextern void RedrawInputBox(); Xextern void DoKeyInput(); Xextern char *GetInputBoxData(); Xextern void SetInputBoxData(); X X X#endif _INBOX_H END_OF_FILE if test 313 -ne `wc -c <'inbox.h'`; then echo shar: \"'inbox.h'\" unpacked with wrong size! fi # end of 'inbox.h' fi if test -f 'label.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'label.c'\" else echo shar: Extracting \"'label.c'\" \(1499 characters\) sed "s/^X//" >'label.c' <<'END_OF_FILE' X/* X * label.c X * X * X */ X#include <string.h> X#include <stdio.h> X#include "display.h" X#include "misc.h" X X#define MAX_LABELS (100) X Xstruct label { X int l_x; X int l_y; X int l_len; X char *l_str; X int l_mapped; X}; X Xstatic struct label LabelArray[MAX_LABELS]; Xstatic int LastLabel = 0; X Xint LabelGC = 0; X Xextern char *malloc(); Xvoid RedrawLabel(); X Xstatic void ClearLabel(); X X Xint CreateLabel( x, y, string ) Xint x, y; Xchar *string; X{ X int id; X int len; X X id = LastLabel++; X X len = strlen( string ); X X LabelArray[id].l_x = x; X LabelArray[id].l_y = y; X LabelArray[id].l_len = len; X LabelArray[id].l_mapped = FALSE; X X X LabelArray[id].l_str = malloc( len + 1 ); X strcpy( LabelArray[id].l_str, string ); X X/* X if( LabelGC == 0 ) { X LabelGC = XCreateGC( Dp, MainWin, 0, NULL ); X XSetState(Dp, LabelGC,ForGndPix, BackGndPix, GXcopy,AllPlanes); X } X*/ X X return( id ); X} X Xvoid ShowLabel( id ) Xint id; X{ X LabelArray[id].l_mapped = TRUE; X RedrawLabel( id ); X} X Xvoid HideLabel( id ) Xint id; X{ X LabelArray[id].l_mapped = FALSE; X ClearLabel( id ); X} X Xvoid RedrawAllLabels() X{ X int i; X X for( i = 0; i < LastLabel; i++ ) { X if( LabelArray[i].l_mapped == TRUE ) { X RedrawLabel( i ); X } X } X} X Xvoid RedrawLabel( id ) Xint id; X{ X struct label *lb; X X lb = &LabelArray[id]; X X XDrawImageString(Dp, MainWin, Text6x10GC, lb->l_x, lb->l_y, X lb->l_str , lb->l_len ); X} X Xstatic void ClearLabel( id ) X{ X struct label *lb; X X lb = &LabelArray[id]; X X XClearArea( Dp, MainWin, lb->l_x, lb->l_y, lb->l_len * 6, 10, False ); X X} X X END_OF_FILE if test 1499 -ne `wc -c <'label.c'`; then echo shar: \"'label.c'\" unpacked with wrong size! fi # end of 'label.c' fi if test -f 'label.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'label.h'\" else echo shar: Extracting \"'label.h'\" \(207 characters\) sed "s/^X//" >'label.h' <<'END_OF_FILE' X#ifndef _LABEL_H X#define _LABEL_H X/* X * label.h X * X */ X Xextern int CreateLabel(); Xextern void ShowLabel(); Xextern void HideLabel(); Xextern void RedrawAllLabels(); Xextern void RedrawLabel(); X X#endif _LABEL_H END_OF_FILE if test 207 -ne `wc -c <'label.h'`; then echo shar: \"'label.h'\" unpacked with wrong size! fi # end of 'label.h' fi if test -f 'misc.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'misc.h'\" else echo shar: Extracting \"'misc.h'\" \(152 characters\) sed "s/^X//" >'misc.h' <<'END_OF_FILE' X#ifndef _MISC_H X#define _MISC_H X/* X * misc.h X * X */ X X#define TRUE (1) X#define FALSE (0) X X#define MWIN_W (400) X#define MWIN_H (50) X X X#endif _MISC_H X END_OF_FILE if test 152 -ne `wc -c <'misc.h'`; then echo shar: \"'misc.h'\" unpacked with wrong size! fi # end of 'misc.h' fi if test -f 'rpc_stuff.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'rpc_stuff.h'\" else echo shar: Extracting \"'rpc_stuff.h'\" \(830 characters\) sed "s/^X//" >'rpc_stuff.h' <<'END_OF_FILE' X#ifndef _RPC_STUFF_H X#define _RPC_STUFF_H X/* X * rpc_stuff.h X * X * X */ X Xextern void InitRPC(); Xextern void TurnOnEther(); Xextern void TurnOffEther(); Xextern void SetLenMask(); Xextern void SetProtoMask(); Xextern void SetSrcAddrMask(); Xextern void SetDstAddrMask(); Xextern void GetStatData(); Xextern void GetSrcData(); Xextern void GetDstData(); Xextern void TopSrcData(); Xextern void TopDstData(); Xextern int GetNextSrcData(); Xextern int GetNextDstData(); Xextern int GetBytesDelta(); Xextern int GetPacketsDelta(); Xextern int GetBCastDelta(); Xextern int GetNDProtoDelta(); Xextern int GetICMPProtoDelta(); Xextern int GetUDPProtoDelta(); Xextern int GetTCPProtoDelta(); Xextern int GetARPProtoDelta(); Xextern int GetOtherProtoDelta(); Xextern long GetTimeDelta(); Xextern int GetSizeDelta(); Xextern float GetNetLoad(); X X#endif _RPC_STUFF_H X END_OF_FILE if test 830 -ne `wc -c <'rpc_stuff.h'`; then echo shar: \"'rpc_stuff.h'\" unpacked with wrong size! fi # end of 'rpc_stuff.h' fi if test -f 'strip.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'strip.h'\" else echo shar: Extracting \"'strip.h'\" \(240 characters\) sed "s/^X//" >'strip.h' <<'END_OF_FILE' X#ifndef _STRIP_H X#define _STRIP_H X/* X * strip.h X * X * X */ X Xextern int CreateStrip(); Xextern void ShowStrip(); Xextern void HideStrip(); Xextern void RedrawAllStrips(); Xextern void RedrawStrip(); Xextern void UpdateStripVal(); X X#endif _STRIP_H END_OF_FILE if test 240 -ne `wc -c <'strip.h'`; then echo shar: \"'strip.h'\" unpacked with wrong size! fi # end of 'strip.h' fi echo shar: End of archive 1 \(of 3\). cp /dev/null ark1isdone MISSING="" for I in 1 2 3 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 3 archives. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0 -- Dan Heller ------------------------------------------------ O'Reilly && Associates Z-Code Software Senior Writer President argv@ora.com argv@zipcode.com ------------------------------------------------ General Email: argv@sun.com Comp-sources-x stuff: comp-sources.x@uunet.uu.net