From d7357b63c9942c72481993bdb9632861c1d83a55 Mon Sep 17 00:00:00 2001 From: xchaos Date: Thu, 24 Jan 2013 09:41:39 +0000 Subject: [PATCH] boha jeho... git-svn-id: https://dev.arachne.cz/repos/prometheus/trunk@212 251d49ef-1d17-4917-a970-b30cf55b089b --- cll1-0.6.2.h | 1 + parseiptables.c | 48 ++++++++++++++++++++++++++++++++++++++---------- prometheus.c | 6 +++--- 3 files changed, 42 insertions(+), 13 deletions(-) diff --git a/cll1-0.6.2.h b/cll1-0.6.2.h index 6b2214b..d3456ce 100644 --- a/cll1-0.6.2.h +++ b/cll1-0.6.2.h @@ -74,6 +74,7 @@ /* String macros & sequences, updated 2004-04-19 by xCh. */ #define eq(A,B) ((A) && (B) && !strcmp(A,B)) +#define eqi(A,B) ((A) && (B) && !strcmpi(A,B)) #define strcmpi(A,B) strcasecmp(A,B) #define strlwr(A) {char *_S=A; while(_&&*_S){*_S=tolower(*_S);_S++;}} #define strupr(A) {char *_S=A; while(_&&*_S){*_S=toupper(*_S);_S++;}} diff --git a/parseiptables.c b/parseiptables.c index e736324..cc2daac 100644 --- a/parseiptables.c +++ b/parseiptables.c @@ -15,7 +15,7 @@ extern int include_upload; /* ===================== traffic analyser - uses iptables ================ */ -void get_traffic_statistics(const char *whichiptables) +void get_traffic_statistics(const char *whichiptables, int ipv6) { char *str,*cmd; int downloadflag=0; @@ -86,36 +86,64 @@ void get_traffic_statistics(const char *whichiptables) { accept = eq(ptr,mark); } - /*if(filter_type==1) accept=eq(ptr,"MARK"); else accept=eq(ptr,"CLASSIFY");*/ break; - case 8: if(downloadflag) - { - if(strstr(proxy_ip,ptr)) + case 7: if(ipv6 && !downloadflag) + { + ipaddr = ptr; + } + break; + case 8: if(ipv6 && downloadflag) + { + ipaddr = ptr; + } + else if(!ipv6) + { + if(downloadflag) + { + if(strstr(proxy_ip,ptr)) + { + proxyflag = 1; + } + } + else { - proxyflag = 1; + ipaddr = ptr; } } - else + break; + case 9: if(!ipv6 && downloadflag) { ipaddr = ptr; } break; - case 9: if(downloadflag)ipaddr = ptr;break; } if(accept && traffic>0 && ipaddr) { + /* IPv6 subnet - /64 */ + char *isipv6 = strstr(ipaddr,"/64"); + if(ipv6 && isipv6) + { + *isipv6=0; + printf("(IPv6) "); + } + if(proxyflag) { printf("(proxy) "); } else if(!downloadflag) { - printf("(upload) "); + printf("(up) "); } + else + { + printf("(down) "); + } + printf("IP %s: %Lu MB (%ld pkts)\n", ipaddr, traffic, pkts); - if_exists(ip,ips,eq(ip->addr,ipaddr)); + if_exists(ip, ips, eqi(ip->addr,ipaddr)); else { TheIP(ipaddr); diff --git a/prometheus.c b/prometheus.c index 62ebbc8..48384a6 100644 --- a/prometheus.c +++ b/prometheus.c @@ -137,7 +137,7 @@ struct Keyword *keyword, *defaultkeyword=NULL, *keywords=NULL; void help(void); /* implemented in help.c */ -void get_traffic_statistics(const char *whichiptables); +void get_traffic_statistics(const char *whichiptables, int ipv6); /* implemented in parseiptables.c */ void parse_ip_log(int argc, char **argv); @@ -537,13 +537,13 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); /*-----------------------------------------------------------------*/ puts("Parsing iptables verbose output ..."); /*-----------------------------------------------------------------*/ - get_traffic_statistics(iptables); + get_traffic_statistics(iptables, FALSE); if(ip6prefix) { /*-----------------------------------------------------------------*/ puts("Parsing ip6tables verbose output ..."); /*-----------------------------------------------------------------*/ - get_traffic_statistics(ip6tables); + get_traffic_statistics(ip6tables, TRUE); } } -- 2.30.2