X-Git-Url: https://git.harvie.cz/?p=svn%2FPrometheus-QoS%2F.git;a=blobdiff_plain;f=parseiptables.c;h=cc2daacc5df3db6810a4657837ec4c4b17e9977e;hp=e73632497340e0c5566d888f8f9ed8e3312f5ca1;hb=d7357b63c9942c72481993bdb9632861c1d83a55;hpb=0b9c3c198771800cc6c5fbacfc0272549626bcfd 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);