{\r
fprintf(f,"<span id=\"sharing_%d\" style=\"display:none\">",i);\r
popup_button=0;\r
- for_each(sharedip, ips) if(eq(ip->name, sharedip->sharing))\r
+ for_each(sharedip, ips) if(eq(ip->name, sharedip->sharing) && !strchr(sharedip->addr,':')) /* IPv4 only */\r
{\r
fprintf(f,"<br /><a class=\"blue\" target=\"_blank\" href=\"%s%s.log\">%s</a>\n", log_url, sharedip->name, sharedip->name);\r
popup_button++;\r
}\r
+ for_each(sharedip, ips) if(eq(ip->name, sharedip->sharing) && !strchr(sharedip->addr,'.')) /* IPv6 only */\r
+ {\r
+ fprintf(f,"<br /><a class=\"blue\" target=\"_blank\" href=\"%s%s.log\">%s</a>\n", log_url, sharedip->name, sharedip->addr);\r
+ popup_button++;\r
+ }\r
fputs("</span>\n",f);\r
if(popup_button)\r
{\r
if(use_jquery_popups)\r
{\r
fprintf(f,"<span id=\"download_%d\" style=\"display:none\">",i);\r
- for_each(sharedip, ips) if(eq(ip->name, sharedip->sharing))\r
+ for_each(sharedip, ips) if(eq(ip->name, sharedip->sharing) && !strchr(sharedip->addr,':')) /* IPv4 only */\r
+ {\r
+ fprintf(f,"<br />%Lu", sharedip->direct);\r
+ }\r
+ for_each(sharedip, ips) if(eq(ip->name, sharedip->sharing) && !strchr(sharedip->addr,'.')) /* IPv6 only */\r
{\r
fprintf(f,"<br />%Lu", sharedip->direct);\r
}\r
if(use_jquery_popups)\r
{\r
fprintf(f,"<span id=\"upload_%d\" style=\"display:none\">",i);\r
- for_each(sharedip,ips) if(eq(ip->name, sharedip->sharing))\r
+ for_each(sharedip,ips) if(eq(ip->name, sharedip->sharing) && !strchr(sharedip->addr,':')) /* IPv4 only */\r
+ {\r
+ fprintf(f,"<br />%Lu", sharedip->upload);\r
+ }\r
+ for_each(sharedip,ips) if(eq(ip->name, sharedip->sharing) && !strchr(sharedip->addr,'.')) /* IPv6 only */\r
{\r
fprintf(f,"<br />%Lu", sharedip->upload);\r
}\r
extern int found_lmsid;\r
extern int free_min;\r
extern const int highest_priority;\r
+extern char *ip6prefix;\r
\r
/* This must be object oriented! This looks almost like constructor ;-) */\r
void TheIP(char *ipaddr)\r
/* == This function strips extra characters after IPv4 address and stores it = */\r
void parse_ip(char *str)\r
{\r
- char *ptr, *ipaddr = NULL, *ipname = NULL, *lmsid = NULL;\r
+ char *ptr, *ipaddr, *ip6range = NULL, *ipname = NULL, *lmsid = NULL;\r
+\r
+ if(ip6prefix) /* Try this only if IPv6 subsystem is active...*/\r
+ {\r
+ ptr = strstr(str, "::");\r
+ if(ptr && ptr-str > 4)\r
+ {\r
+ ptr -= 4; \r
+ duplicate(ptr,ip6range);\r
+ ptr = strstr(ip6range, "::");\r
+ if(ptr)\r
+ {\r
+ *(ptr+2) = 0;\r
+ }\r
+ }\r
+ }\r
\r
ptr = strchr(str, '{');\r
if(ptr)\r
}\r
*ptr=0;\r
\r
+ if(ip6range)\r
+ {\r
+ concatenate(ip6prefix,ip6range,ptr);\r
+ concatenate(ptr,"/64",ip6range);\r
+ if_exists(ip, ips, eq(ip->addr,ip6range));\r
+ else\r
+ {\r
+ TheIP(ip6range);\r
+ }\r
+ ip->name = ptr;\r
+ ip->sharing = ipname;\r
+ if(lmsid)\r
+ {\r
+ ip->lmsid = atoi(lmsid);\r
+ }\r
+ }\r
+\r
if_exists(ip, ips, eq(ip->addr,ipaddr));\r
else\r
{\r
/* Credit: CZFree.Net,Martin Devera,Netdave,Aquarius,Gandalf */\r
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */\r
\r
-/* Modified by: xChaos, 20130114\r
+/* Modified by: xChaos, 20130116\r
ludva, 20080415\r
\r
Prometheus QoS is free software; you can redistribute it and/or\r
#include "cll1-0.6.2.h"\r
#include "ipstruct.h"\r
\r
-const char *version = "0.8.3-g";\r
+const char *version = "0.8.3-h";\r
\r
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */\r
/* Versions: 0.8.3 is development release, 0.8.4 will be "stable" */\r
char *config = "/etc/prometheus/prometheus.conf"; /* main configuration file */\r
char *hosts = "/etc/prometheus/hosts"; /* per-IP bandwidth definition file */\r
char *iptablesfile = "/var/spool/prometheus.iptables"; /* temporary file for iptables-restore*/\r
+char *ip6tablesfile = "/var/spool/prometheus.ip6tables"; /* temporary file for ip6tables-restore*/\r
char *credit = "/var/lib/misc/prometheus.credit"; /* credit log file */\r
char *classmap = "/var/lib/misc/prometheus.classes"; /* credit log file */\r
char *html = "/var/www/traffic.html"; /* hall of fame - html version */\r
char *lan = "eth0"; /* LAN interface */\r
char *lan_medium = "100Mbit"; /* 10Mbit/100Mbit ethernet */\r
char *wan = "eth1"; /* WAN/ISP interface */\r
+char *ip6prefix = NULL; /* Prefix for global /48 IPv6 subnet */\r
char *wan_medium = "100Mbit"; /* 10Mbit/100Mbit ethernet */\r
char *qos_leaf = "sfq perturb 5"; /* leaf discipline */\r
char *qos_free_zone = NULL; /* QoS free zone */\r
\r
option("tc",tc);\r
option("iptables",iptables);\r
- option("iptables-save",iptablessave); /* new */\r
- option("iptables-restore",iptablesrestore); /* new */\r
+ option("iptables-save",iptablessave);\r
+ option("iptables-restore",iptablesrestore);\r
option("ip6tables",ip6tables);\r
- option("ip6tables-save",ip6tablessave); /* new */\r
- option("ip6tables-restore",ip6tablesrestore); /* new */\r
- option("iptables-in-filename",iptablesfile); /* new */\r
+ option("ip6tables-save",ip6tablessave);\r
+ option("ip6tables-restore",ip6tablesrestore);\r
+ option("iptables-in-filename",iptablesfile);\r
+ option("ip6tables-in-filename",ip6tablesfile);\r
option("hosts",hosts);\r
option("lan-interface",lan);\r
option("wan-interface",wan);\r
+ option("ip6-prefix",ip6prefix);\r
option("lan-medium",lan_medium);\r
option("wan-medium",wan_medium);\r
lloption("wan-download",line);\r
puts("Initializing iptables and tc classes ...");\r
/*-----------------------------------------------------------------*/\r
\r
- iptables_file=fopen(iptablesfile,"w");\r
+ iptables_file = fopen(iptablesfile, "w");\r
if(iptables_file == NULL)\r
{\r
- puts("Cannot open iptablesfile!");\r
+ perror(iptablesfile);\r
exit(-1);\r
}\r
\r
- log_file=fopen(cmdlog,"w");\r
+ log_file = fopen(cmdlog, "w");\r
if(log_file == NULL) \r
{\r
- puts("Cannot open logfile!");\r
+ perror(cmdlog);\r
exit(-1);\r
}\r
\r
save_line(str);\r
}\r
\r
- if(ip_count>idxtable_treshold1 && !just_flush)\r
+ if(ip_count > idxtable_treshold1 && !just_flush)\r
{\r
int idxcount=0, bitmask=32-idxtable_bitmask1; /* default net mask: 255.255.255.240 */\r
char *subnet, *buf;\r
save_line(":post_common - [0:0]");\r
save_line(":forw_common - [0:0]");\r
\r
- for_each(ip,ips) if(ip->addr && *(ip->addr) && !eq(ip->addr,"0.0.0.0/0"))\r
+ for_each(ip,ips) if(ip->addr && *(ip->addr) && !eq(ip->addr,"0.0.0.0/0") && !strchr(ip->addr,':')) /* only IPv4 */\r
{\r
buf=index_id(ip->addr,bitmask);\r
if_exists(idx,idxs,eq(idx->id,buf))\r
}\r
\r
/* brutal perfomance optimalization */\r
- while(idxcount>idxtable_treshold2 && bitmask>2*idxtable_bitmask2)\r
+ while(idxcount > idxtable_treshold2 && bitmask > 2*idxtable_bitmask2)\r
{\r
- bitmask-=idxtable_bitmask2;\r
- idxcount=0;\r
+ bitmask -= idxtable_bitmask2;\r
+ idxcount = 0;\r
\r
for_each(idx,idxs) if(idx->parent == NULL)\r
{\r
- buf=index_id(idx->addr,bitmask);\r
+ buf = index_id(idx->addr,bitmask);\r
if_exists(metaindex,idxs,eq(metaindex->id,buf))\r
{\r
metaindex->children++;\r
}\r
}\r
\r
- /* this should slightly optimize throughout ... */\r
+ /* this should slightly optimize throughput ... */\r
sort(idx,idxs,desc_order_by,children);\r
sort(idx,idxs,order_by,bitmask);\r
\r
puts("Generating iptables and tc classes ... ");\r
/*-----------------------------------------------------------------*/\r
\r
- for_each(ip, ips) if(ip->mark > 0)\r
+ for_each(ip, ips) if(ip->mark > 0 && !strchr(ip->addr,':')) /* works only for IPv4 so far */\r
{\r
if(idxs)\r
{\r