/* Credit: CZFree.Net,Martin Devera,Netdave,Aquarius,Gandalf */\r
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */\r
\r
-/* Modified by: xChaos, 20121007\r
+/* Modified by: xChaos, 20121011\r
ludva, 20080415\r
\r
Prometheus QoS is free software; you can redistribute it and/or\r
\r
const char *stats_html_signature = "<span class=\"small\">Statistics generated by Prometheus QoS version %s<br />GPL+Copyright(C)2005-2012 Michael Polak, <a target=\"_blank\" href=\"http://www.arachne.cz/\">Arachne Labs</a></span>\n";\r
\r
+/* ======= Help screen is hopefuly self-documenting part of code :-) ======= */\r
+\r
+void help(void)\r
+{\r
+ puts("Command line switches:\n\\r
+\n\\r
+-d Dry run (preview tc and iptables commands on stdout)\n\\r
+-r Run (reset all statistics and start shaping - daily usage)\n\\r
+-p just generate Preview of data transfer statistics and exit (after -r)\n\\r
+-s start Shaping FUP limits (keeps data transfer stat like -p) (after -r)\n\\r
+-n run Now (like -r delay - overrides qos-free-delay keyword, after boot)\n\\r
+-f just Flush iptables and tc classes and exit (stop shaping, no QiS)\n\\r
+-9 emergency iptables flush (like -f, but dumps data transfer statistics)\n\\r
+\n\\r
+-c filename force alternative /etc/prometheus/prometheus.conf filename\n\\r
+-h filename force alternative /etc/hosts filename (overrides hosts keyword)\n\\r
+-l Mmm YYYY generate HTML summary of Logged traffic (Mmm=Jan-Dec) (and exit)\n\\r
+-m generate HTML summary of traffic for yesterday's Month (and exit)\n\\r
+-y generate HTML summary of traffic for yesterday's Year (and exit)\n\\r
+-? --help show this help scree (and exit)\n\\r
+-v --version show Version number of this utility (and exit)\n");\r
+}\r
+\r
/* ======= All path names are defined here (for RPM patch) ======= */\r
\r
const char *tc = "/sbin/tc"; /* requires tc with HTB support */\r
char *lms_url = "/lms/?m=customerinfo&id=";\r
int use_jquery_popups = 1;\r
int row_odd_even = 0; /*<tr class="odd/even"> */\r
-\r
-\r
-void parse_ip_log(int argc, char **argv);\r
-/* implementid in parselog.c */\r
-\r
-void parse_hosts(char *hosts);\r
-/* implementid in parsehosts.c */\r
-\r
-const char *tr_odd_even(void)\r
-{\r
- row_odd_even = 1 - row_odd_even;\r
- if(row_odd_even)\r
- {\r
- return "<tr class=\"even\">\n";\r
- }\r
- else\r
- {\r
- return "<tr class=\"odd\">\n";\r
- }\r
-}\r
-\r
-/* ======= Help screen is hopefuly self-documenting part of code :-) ======= */\r
-\r
-void help(void)\r
-{\r
- puts("Command line switches:\n\\r
-\n\\r
--d Dry run (preview tc and iptables commands on stdout)\n\\r
--r Run (reset all statistics and start shaping - daily usage)\n\\r
--p just generate Preview of data transfer statistics and exit (after -r)\n\\r
--s start Shaping FUP limits (keeps data transfer stat like -p) (after -r)\n\\r
--n run Now (like -r delay - overrides qos-free-delay keyword, after boot)\n\\r
--f just Flush iptables and tc classes and exit (stop shaping, no QiS)\n\\r
--9 emergency iptables flush (like -f, but dumps data transfer statistics)\n\\r
-\n\\r
--c filename force alternative /etc/prometheus/prometheus.conf filename\n\\r
--h filename force alternative /etc/hosts filename (overrides hosts keyword)\n\\r
--l Mmm YYYY generate HTML summary of Logged traffic (Mmm=Jan-Dec) (and exit)\n\\r
--m generate HTML summary of traffic for yesterday's Month (and exit)\n\\r
--y generate HTML summary of traffic for yesterday's Year (and exit)\n\\r
--? --help show this help scree (and exit)\n\\r
--v --version show Version number of this utility (and exit)\n");\r
-}\r
-\r
+ \r
/* === Configuraration file values defaults - stored in global variables ==== */\r
\r
int filter_type = 1; /*1 mark, 2 classify*/\r
struct Group *groups = NULL, *group;\r
struct Keyword *keyword, *defaultkeyword=NULL, *keywords=NULL;\r
\r
+void parse_ip_log(int argc, char **argv);\r
+/* implementid in parselog.c */\r
+\r
+void parse_hosts(char *hosts);\r
+/* implementid in parsehosts.c */\r
+\r
+const char *tr_odd_even(void)\r
+{\r
+ row_odd_even = 1 - row_odd_even;\r
+ if(row_odd_even)\r
+ {\r
+ return "<tr class=\"even\">\n";\r
+ }\r
+ else\r
+ {\r
+ return "<tr class=\"odd\">\n";\r
+ }\r
+}\r
+\r
/* ==== This is C<<1 stuff - learn C<<1 first! https://dev.arachne.cz/svn/cll1h ==== */\r
\r
struct Index\r
} *idxs=NULL, *idx, *metaindex;\r
\r
\r
-\r
void TheIP(void);\r
/* function implemented in parsehosts.c */\r
\r
/* ====== iptables indexes are used to reduce complexity to log8(N) ===== */\r
\r
-char *very_ugly_ipv4_code(char *inip,int bitmask,int format_as_chainname)\r
+char *very_ugly_ipv4_code(char *inip, int bitmask, int format_as_chainname)\r
{\r
/* warning: this function was debugged only for bitmask values 20,24,28 !!!*/\r
int dot=0, n;\r
return outip;\r
}\r
\r
-char *hash_id(char *ip,int bitmask)\r
+char *index_id(char *ip,int bitmask)\r
{ \r
return very_ugly_ipv4_code(ip,bitmask,1);\r
}\r
\r
for_each(ip,ips) if(ip->addr && *(ip->addr) && !eq(ip->addr,"0.0.0.0/0"))\r
{\r
- buf=hash_id(ip->addr,bitmask);\r
+ buf=index_id(ip->addr,bitmask);\r
if_exists(idx,idxs,eq(idx->id,buf))\r
{\r
idx->children++;\r
\r
for_each(idx,idxs) if(idx->parent == NULL)\r
{\r
- buf=hash_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
char *buf;\r
duplicate(ip->addr,buf);\r
- buf=hash_id(ip->addr,32-idxtable_bitmask1); \r
+ buf=index_id(ip->addr,32-idxtable_bitmask1); \r
\r
string(chain_forward,6+strlen(buf));\r
strcpy(chain_forward,"forw_");\r