X-Git-Url: https://git.harvie.cz/?a=blobdiff_plain;f=parseiptables.c;h=b44c7ad133008b5275d3e128449a0ff40d752deb;hb=7449b3ede09ef8690b073f73d7732e0e9d532090;hp=ea9ef965b44dd26ceb4309cd266b6076749d0c7a;hpb=cdfd88eb2cfba828e5bfc3f77eba37b3cba286ce;p=svn%2FPrometheus-QoS%2F.git diff --git a/parseiptables.c b/parseiptables.c index ea9ef96..b44c7ad 100644 --- a/parseiptables.c +++ b/parseiptables.c @@ -1,4 +1,4 @@ -/* Modified by: xChaos, 20131029 */ +/* Modified by: xChaos, 20131208 */ #include "cll1-0.6.2.h" #include "ipstruct.h" @@ -8,17 +8,20 @@ /* globals declared in prometheus.c */ extern struct IP *ips, *ip, *sharedip; extern char *mark; -extern char *proxy_ip; +/* extern char *proxy_ip; */ extern int free_min; extern int free_max; extern int include_upload; +int traffic_detected = 0; + /* ===================== traffic analyser - uses iptables ================ */ void get_traffic_statistics(const char *whichiptables, int ipv6) { char *str,*cmd; - int downloadflag=0; + int downloadflag = 0; + traffic_detected = 0; textfile(Pipe,str) *line,*lines=NULL; string(str,STRLEN); @@ -36,7 +39,7 @@ void get_traffic_statistics(const char *whichiptables, int ipv6) for_each(line,lines) { - int col, accept = 0, proxyflag = 0, valid = 1, setchainname = 0, commonflag = 0; + int col, accept = 0, /*proxyflag = 0, */valid = 1, setchainname = 0, commonflag = 0; unsigned long long traffic = 0; unsigned long pkts = 0; char *ipaddr = NULL,*ptr; @@ -98,14 +101,17 @@ void get_traffic_statistics(const char *whichiptables, int ipv6) } else if(!ipv6) { - if(downloadflag) +/* if(downloadflag) { if(strstr(proxy_ip,ptr)) { proxyflag = 1; } - } - else + + } + else + { */ + if(!downloadflag) { ipaddr = ptr; } @@ -131,12 +137,14 @@ void get_traffic_statistics(const char *whichiptables, int ipv6) { printf("(IPv4) "); } - +/* if(proxyflag) { printf("(proxy) "); } - else if(!downloadflag) + else +*/ + if(!downloadflag) { printf("(up) "); } @@ -145,6 +153,7 @@ void get_traffic_statistics(const char *whichiptables, int ipv6) printf("(down) "); } + traffic_detected = 1; printf("%s %Lu MB (%ld pkts)\n", ipaddr, traffic, pkts); if_exists(ip, ips, eqi(ip->addr,ipaddr)); @@ -165,30 +174,33 @@ void get_traffic_statistics(const char *whichiptables, int ipv6) if(downloadflag) { +/* if(proxyflag) { ip->proxy = traffic; } else - { - ip->traffic += traffic; - } - ip->direct = ip->traffic-ip->upload-ip->proxy; - ip->pktsdown = pkts; + {*/ + ip->traffic += traffic; + ip->traffic_down += traffic; +/* } */ + ip->direct += traffic; /*-ip->proxy;*/ + ip->pktsdown += pkts; } else { - ip->upload = traffic; - ip->pktsup = pkts; + ip->upload += traffic; + ip->traffic_up += traffic; + ip->pktsup += pkts; if(include_upload) { ip->traffic += traffic; } else { - if(traffic > ip->traffic) + if(ip->upload > ip->traffic) { - ip->traffic = traffic; + ip->traffic = ip->upload; } } }