/* 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++;}}
\r
/* ===================== traffic analyser - uses iptables ================ */ \r
\r
-void get_traffic_statistics(const char *whichiptables)\r
+void get_traffic_statistics(const char *whichiptables, int ipv6)\r
{\r
char *str,*cmd;\r
int downloadflag=0;\r
{\r
accept = eq(ptr,mark);\r
}\r
- /*if(filter_type==1) accept=eq(ptr,"MARK"); else accept=eq(ptr,"CLASSIFY");*/\r
break;\r
- case 8: if(downloadflag)\r
- { \r
- if(strstr(proxy_ip,ptr))\r
+ case 7: if(ipv6 && !downloadflag)\r
+ {\r
+ ipaddr = ptr;\r
+ }\r
+ break;\r
+ case 8: if(ipv6 && downloadflag)\r
+ {\r
+ ipaddr = ptr;\r
+ }\r
+ else if(!ipv6)\r
+ {\r
+ if(downloadflag)\r
+ { \r
+ if(strstr(proxy_ip,ptr))\r
+ {\r
+ proxyflag = 1;\r
+ }\r
+ }\r
+ else\r
{\r
- proxyflag = 1;\r
+ ipaddr = ptr;\r
}\r
}\r
- else\r
+ break;\r
+ case 9: if(!ipv6 && downloadflag)\r
{\r
ipaddr = ptr;\r
}\r
break;\r
- case 9: if(downloadflag)ipaddr = ptr;break;\r
}\r
\r
if(accept && traffic>0 && ipaddr)\r
{\r
+ /* IPv6 subnet - /64 */\r
+ char *isipv6 = strstr(ipaddr,"/64");\r
+ if(ipv6 && isipv6)\r
+ {\r
+ *isipv6=0;\r
+ printf("(IPv6) "); \r
+ }\r
+ \r
if(proxyflag)\r
{\r
printf("(proxy) ");\r
}\r
else if(!downloadflag)\r
{\r
- printf("(upload) ");\r
+ printf("(up) ");\r
}\r
+ else\r
+ {\r
+ printf("(down) ");\r
+ }\r
+ \r
printf("IP %s: %Lu MB (%ld pkts)\n", ipaddr, traffic, pkts);\r
\r
- if_exists(ip,ips,eq(ip->addr,ipaddr)); \r
+ if_exists(ip, ips, eqi(ip->addr,ipaddr)); \r
else \r
{\r
TheIP(ipaddr);\r
void help(void);\r
/* implemented in help.c */
\r
-void get_traffic_statistics(const char *whichiptables);\r
+void get_traffic_statistics(const char *whichiptables, int ipv6);\r
/* implemented in parseiptables.c */\r
\r
void parse_ip_log(int argc, char **argv);\r
/*-----------------------------------------------------------------*/\r
puts("Parsing iptables verbose output ...");\r
/*-----------------------------------------------------------------*/\r
- get_traffic_statistics(iptables);\r
+ get_traffic_statistics(iptables, FALSE);\r
if(ip6prefix)\r
{\r
/*-----------------------------------------------------------------*/\r
puts("Parsing ip6tables verbose output ...");\r
/*-----------------------------------------------------------------*/ \r
- get_traffic_statistics(ip6tables);\r
+ get_traffic_statistics(ip6tables, TRUE);\r
}\r
}\r
\r