// // $Id: ipfw-core.c,v 1.9 2001/11/22 13:29:04 mavetju Exp $ // // // The core functions of ipfw-graph // #include #include #include #include #include "ipfw-graph.h" DATA_TYPE data_bytes; // data for the bytes received DATA_TYPE *data=NULL; // data for the ipfw rules int data_size; // number of elements of data int xsize; // xsize of the output int ysize_bytes,ysize_drawing; // ysize of the bytes/piles output long maxyvalues[MAXSTORED]; // maxyvalues per column in the output long maxyvalue=-1; // biggest of the maxyvalues // tables with pointers to the drawing functions struct funtable drawtable[]={ { linear_drawing, linear_bytes, default_stats, bg_drawing, bg_bytes, "Linear drawing", "All", 0, NULL, NULL }, { denyonly_drawing, denyonly_bytes, default_stats, bg_drawing, bg_bytes, "Deny-only drawing", "Deny", 0, NULL, NULL }, { allowonly_drawing, allowonly_bytes, default_stats, bg_drawing, bg_bytes, "Allow-only drawing", "Allow", 0, NULL, NULL }, { NULL, NULL, NULL } }; // // periodic called function to redraw the screen // gint update(void) { debug("updating data (current page is %d)",current_page); getdata(); (*drawtable[current_page].bgdrawing_fun)(); (*drawtable[current_page].drawing_fun)(); (*drawtable[current_page].bgbytes_fun)(); (*drawtable[current_page].bytes_fun)(); (*drawtable[current_page].stats_fun)(); gtk_widget_queue_draw(drawtable[current_page].area); gtk_widget_queue_draw(bytes_area); return 1; } // // Read the config from ipfw // void get_config(void) { FILE * fin; char s[1000]; char * p; int x; char * ipfwal=BINDIR"/ipfw-al defs"; if ((fin=popen(ipfwal,"r"))==NULL) { perror("ipfw-al defs"); exit(0); } while (!feof(fin)) { if (fgets(s,sizeof(s),fin)==NULL) break; if (s[0]==0) continue; if (s[0]=='#') break; s[strlen(s)-1]=0; data=(DATA_TYPE *)realloc(data,(data_size+1)*sizeof(DATA_TYPE)); data[data_size].new=0; data[data_size].old=0; data[data_size].gc=NULL; for (x=0;x