\r
#include "cll1-0.6.h"\r
\r
-const char *version = "0.7.9-c"; \r
+const char *version = "0.7.9-d"; \r
\r
/* Version numbers: 0.7.9 is development releases ("beta"), 0.8.0 will be "stable" */\r
/* Debian(RPM) package versions/patchlevels: 0.7.9-2, 0.8.0-1, 0.8.0-2, etc. */\r
sprintf(str,"%s class add dev %s parent 1:%d classid 1:%d htb rate %dkbit ceil %dkbit burst %dk prio %d", tc, lan, ip->group, ip->mark,ip->min,ip->max, burst, ip->prio);\r
safe_run(str);\r
\r
- if (strcmpi(ip->keyword->leaf_discipline, "none")){\r
- sprintf(str,"%s qdisc add dev %s parent 1:%d handle %d %s", tc, lan, ip->mark, ip->mark, ip->keyword->leaf_discipline); /*qos_leaf*/\r
- safe_run(str);\r
- }\r
- \r
- if (filter_type == 1){\r
- sprintf(str,"%s filter add dev %s parent 1:0 protocol ip handle %d fw flowid 1:%d", tc, lan, ip->mark, ip->mark);\r
- safe_run(str);\r
+ if (strcmpi(ip->keyword->leaf_discipline, "none"))\r
+ {\r
+ sprintf(str,"%s qdisc add dev %s parent 1:%d handle %d %s", tc, lan, ip->mark, ip->mark, ip->keyword->leaf_discipline); /*qos_leaf*/\r
+ safe_run(str);\r
+ } \r
+ if (filter_type == 1)\r
+ {\r
+ sprintf(str,"%s filter add dev %s parent 1:0 protocol ip handle %d fw flowid 1:%d", tc, lan, ip->mark, ip->mark);\r
+ safe_run(str);\r
}\r
\r
/* -------------------------------------------------------- upload class */\r
(int)((ip->max/ip->keyword->asymetry_ratio)-ip->keyword->asymetry_fixed), burst, ip->prio);\r
safe_run(str);\r
\r
- if (strcmpi(ip->keyword->leaf_discipline, "none")){\r
- sprintf(str,"%s qdisc add dev %s parent 1:%d handle %d %s",tc, wan, ip->mark, ip->mark, ip->keyword->leaf_discipline); /*qos_leaf*/\r
- safe_run(str);\r
- }\r
- \r
- if (filter_type == 1){\r
- sprintf(str,"%s filter add dev %s parent 1:0 protocol ip handle %d fw flowid 1:%d",tc, wan, ip->mark, ip->mark);\r
- safe_run(str);\r
+ if (strcmpi(ip->keyword->leaf_discipline, "none"))\r
+ {\r
+ sprintf(str,"%s qdisc add dev %s parent 1:%d handle %d %s",tc, wan, ip->mark, ip->mark, ip->keyword->leaf_discipline); /*qos_leaf*/\r
+ safe_run(str);\r
+ } \r
+ if (filter_type == 1)\r
+ {\r
+ sprintf(str,"%s filter add dev %s parent 1:0 protocol ip handle %d fw flowid 1:%d",tc, wan, ip->mark, ip->mark);\r
+ safe_run(str);\r
}\r
}\r
else\r
i++;\r
}\r
\r
-\r
if(idxs)\r
{\r
- chain_forward="forw_common";\r
- chain_postrouting="post_common";\r
+ chain_forward = "forw_common";\r
+ chain_postrouting = "post_common";\r
}\r
else\r
{\r
- chain_forward="FORWARD";\r
- chain_postrouting="POSTROUTING";\r
+ chain_forward = "FORWARD";\r
+ chain_postrouting = "POSTROUTING";\r
}\r
-\r
- /* -------------------------------------------------------- mark download */\r
-\r
- if(qos_proxy)\r
+ /* -------------------------------- classify or reject free download */\r
{\r
- sprintf(str,"-A %s -s %s -p tcp --sport %d -o %s -j %s%d",chain_postrouting,proxy_ip,proxy_port,lan,mark_iptables,3);\r
- save_line(str);\r
- sprintf(str,"-A %s -s %s -p tcp --sport %d -o %s -j ACCEPT",chain_postrouting,proxy_ip,proxy_port,lan);\r
- save_line(str);\r
+ char *final_chain = "REJECT";\r
+ if(free_min) final_chain = "ACCEPT";\r
+ if(qos_proxy)\r
+ {\r
+ if(free_min)\r
+ {\r
+ sprintf(str,"-A %s -s %s -p tcp --sport %d -o %s -j %s%d",chain_postrouting,proxy_ip,proxy_port,lan,mark_iptables,3);\r
+ save_line(str);\r
+ }\r
+ sprintf(str,"-A %s -s %s -p tcp --sport %d -o %s -j %s",chain_postrouting,proxy_ip,proxy_port,lan,final_chain);\r
+ save_line(str);\r
+ }\r
+ if(free_min)\r
+ {\r
+ sprintf(str,"-A %s -o %s -j %s%d",chain_postrouting,lan,mark_iptables,3);\r
+ save_line(str);\r
+ }\r
+ sprintf(str,"-A %s -o %s -j %s",chain_postrouting,lan,final_chain);\r
+ save_line(str);\r
+ /* ------------------------------- classify or reject free upload */\r
+ if(free_min)\r
+ {\r
+ sprintf(str,"-A %s -o %s -j %s%d",chain_forward,wan,mark_iptables,3);\r
+ save_line(str);\r
+ }\r
+ sprintf(str,"-A %s -o %s -j %s",chain_forward,wan,final_chain);\r
+ save_line(str);\r
}\r
- sprintf(str,"-A %s -o %s -j %s%d",chain_postrouting,lan,mark_iptables,3);\r
- save_line(str);\r
- sprintf(str,"-A %s -o %s -j ACCEPT",chain_postrouting,lan);\r
- save_line(str);\r
-\r
- /* -------------------------------------------------------- mark upload */\r
- sprintf(str,"-A %s -o %s -j %s%d",chain_forward,wan,mark_iptables,3);\r
- save_line(str);\r
- sprintf(str,"-A %s -o %s -j ACCEPT",chain_forward,wan);\r
- save_line(str);\r
-\r
- printf("Total IP count: %d\n", i);\r
-\r
- /*-----------------------------------------------------------------*/\r
- puts("Generating free bandwith classes ...");\r
- /*-----------------------------------------------------------------*/\r
\r
- /* ---------------------------------------- tc - free bandwith shared class */\r
- sprintf(str,"%s class add dev %s parent 1:%d classid 1:3 htb rate %dkbit ceil %dkbit burst %dk prio 2",tc,lan,parent,free_min,free_max,burst);\r
- safe_run(str);\r
-\r
- sprintf(str,"%s class add dev %s parent 1:%d classid 1:3 htb rate %dkbit ceil %dkbit burst %dk prio 2",tc,wan,parent,free_min,free_max,burst);\r
- safe_run(str);\r
+ if(free_min) /* allocate free bandwith if it is not zero... */ \r
+ {\r
+ /*-----------------------------------------------------------------*/\r
+ puts("Generating free bandwith classes ...");\r
+ /*-----------------------------------------------------------------*/\r
+ sprintf(str,"%s class add dev %s parent 1:%d classid 1:3 htb rate %dkbit ceil %dkbit burst %dk prio 2",tc,lan,parent,free_min,free_max,burst);\r
+ safe_run(str);\r
+ sprintf(str,"%s class add dev %s parent 1:%d classid 1:3 htb rate %dkbit ceil %dkbit burst %dk prio 2",tc,wan,parent,free_min,free_max,burst);\r
+ safe_run(str);\r
+ /* tc SFQ */\r
+ if (strcmpi(qos_leaf, "none"))\r
+ {\r
+ sprintf(str,"%s qdisc add dev %s parent 1:3 handle 3 %s",tc,lan,qos_leaf);\r
+ safe_run(str);\r
+ \r
+ sprintf(str,"%s qdisc add dev %s parent 1:3 handle 3 %s",tc,wan,qos_leaf);\r
+ safe_run(str);\r
+ } \r
+ /* tc handle 1 fw flowid */\r
+ sprintf(str,"%s filter add dev %s parent 1:0 protocol ip handle 3 fw flowid 1:3",tc,lan);\r
+ safe_run(str);\r
\r
- /* tc SFQ */\r
- if (strcmpi(qos_leaf, "none")){\r
- sprintf(str,"%s qdisc add dev %s parent 1:3 handle 3 %s",tc,lan,qos_leaf);\r
- safe_run(str);\r
- \r
- sprintf(str,"%s qdisc add dev %s parent 1:3 handle 3 %s",tc,wan,qos_leaf);\r
- safe_run(str);\r
+ sprintf(str,"%s filter add dev %s parent 1:0 protocol ip handle 3 fw flowid 1:3",tc,wan);\r
+ safe_run(str);\r
}\r
- \r
- /* tc handle 1 fw flowid */\r
- sprintf(str,"%s filter add dev %s parent 1:0 protocol ip handle 3 fw flowid 1:3",tc,lan);\r
- safe_run(str);\r
-\r
- sprintf(str,"%s filter add dev %s parent 1:0 protocol ip handle 3 fw flowid 1:3",tc,wan);\r
- safe_run(str);\r
-\r
- run_restore();\r
- \r
+ printf("Total IP count: %d\n", i);\r
+ run_restore(); \r
if (log_file) fclose(log_file);\r
return 0;\r
-\r
/* that's all folks, thank you for reading it all the way up to this point ;-) */\r
/* bad luck C<<1 is not yet finished, I promise no sprintf() next time... */\r
}\r