/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */\r
-/* Prometheus QoS - you can "steal fire" from your ISP */\r
-/* "fair-per-IP" quality of service (QoS) utility */\r
+/* Prometheus QoS - you can "steal fire" from your ISP *//* "fair-per-IP" quality of service (QoS) utility */\r
/* requires Linux 2.4.x or 2.6.x with HTB support */\r
/* Copyright(C) 2005-2013 Michael Polak, Arachne Aerospace */\r
/* iptables-restore support Copyright(C) 2007-2008 ludva */\r
/* Credit: CZFree.Net,Martin Devera,Netdave,Aquarius,Gandalf */\r
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */\r
\r
-/* Modified by: xChaos, 20130116\r
+/* Modified by: xChaos, 20130124\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-h";\r
+const char *version = "0.8.3-i";\r
\r
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */\r
/* Versions: 0.8.3 is development release, 0.8.4 will be "stable" */\r
/* === Configuraration file values defaults - stored in global variables ==== */\r
\r
int filter_type = 1; /*1 mark, 2 classify*/\r
+char *final_chain = "DROP"; /* REJECT would be better, but it is impossible in mangle */\r
char *mark = "MARK";\r
char *mark_iptables = "MARK --set-mark ";\r
int dry_run = FALSE; /* preview - use puts() instead of system() */\r
char *iptablespreamble = "*mangle\n:PREROUTING ACCEPT [0:0]\n:POSTROUTING ACCEPT [0:0]\n:INPUT ACCEPT [0:0]\n:OUTPUT ACCEPT [0:0]\n:FORWARD ACCEPT [0:0]";\r
FILE *iptables_file = NULL;\r
+FILE *ip6tables_file = NULL;\r
int enable_credit = TRUE; /* enable credit file */\r
int use_credit = FALSE; /* use credit file (if enabled)*/\r
char *title = "Hall of Fame - Greatest Suckers"; /* hall of fame title */\r
int proxy_port = 3128; /* proxy port number */\r
long long int line = 1024; /* WAN/ISP download in kbps */\r
long long int up = 1024; /* WAN/ISP upload in kbps */\r
-int free_min = 32; /* minimum guaranted bandwidth for all undefined hosts */\r
-int free_max = 64; /* maximum allowed bandwidth for all undefined hosts */\r
+int free_min = 256; /* minimum guaranted bandwidth for all undefined hosts */\r
+int free_max = 512; /* maximum allowed bandwidth for all undefined hosts */\r
int qos_free_delay = 0; /* seconds to sleep before applying new QoS rules */\r
int digital_divide = 2; /* controls digital divide weirdness ratio, 1...3 */ \r
int max_nesting = 3; /* maximum nesting of HTB clases, built-in maximum seems to be 4 */\r
struct Index *parent;\r
int bitmask;\r
int children;\r
+ int ipv6;\r
list(Index);\r
} *idxs=NULL, *idx, *metaindex;\r
\r
char *subnet_id(char *ip, int bitmask);\r
/* function implemented in ipv4subnets.c */\r
\r
+char *index6_id(char *ip, int bitmask);\r
+/* function implemented in ipv6subnets.c */\r
+\r
+char *subnet6_id(char *ip, int bitmask);\r
+/* function implemented in ipv6subnets.c */\r
+\r
/* ================= Let's parse configuration file here ================ */\r
\r
void reject_config_and_exit(char *filename)\r
}\r
}\r
\r
-void save_line(char *line)\r
+void iptables_save_line(char *line, int ipv6)\r
{\r
- fprintf(iptables_file,"%s\n",line);\r
+ if(ipv6)\r
+ {\r
+ fprintf(ip6tables_file,"%s\n",line);\r
+ }\r
+ else\r
+ {\r
+ fprintf(iptables_file,"%s\n",line);\r
+ }\r
}\r
\r
-void run_restore(void)\r
+void run_iptables_restore(void)\r
{\r
char *restor;\r
string(restor,STRLEN);\r
/*-----------------------------------------------------------------*/\r
printf("Running %s <%s ...\n", iptablesrestore, iptablesfile);\r
/*-----------------------------------------------------------------*/\r
- \r
- save_line("COMMIT");\r
+\r
+ iptables_save_line("COMMIT", FALSE);\r
fclose(iptables_file);\r
if(dry_run) \r
{\r
\r
sprintf(restor,"%s <%s",iptablesrestore, iptablesfile);\r
safe_run(restor);\r
- \r
+\r
+ if(ip6prefix)\r
+ {\r
+ /*-----------------------------------------------------------------*/\r
+ printf("Running %s <%s ...\n", ip6tablesrestore, ip6tablesfile);\r
+ /*-----------------------------------------------------------------*/\r
+ iptables_save_line("COMMIT", TRUE);\r
+ fclose(ip6tables_file);\r
+ if(dry_run) \r
+ {\r
+ parse(ip6tablesfile)\r
+ {\r
+ printf("%s\n",_);\r
+ }\r
+ done; /* ugly macro end */\r
+ }\r
+ sprintf(restor,"%s <%s",ip6tablesrestore, ip6tablesfile);\r
+ safe_run(restor);\r
+ }\r
free(restor);\r
}\r
\r
\r
printf("\n\\r
Prometheus QoS - \"fair-per-IP\" Quality of Service setup utility.\n\\r
-Version %s - Copyright (C)2005-2012 Michael Polak, Arachne Labs\n\\r
+Version %s - Copyright (C)2005-2013 Michael Polak, Arachne Labs\n\\r
iptables-restore & burst tunning & classify modification by Ludva\n\\r
Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);\r
\r
puts("Parsing iptables verbose output ...");\r
/*-----------------------------------------------------------------*/\r
get_traffic_statistics(iptables);\r
+ if(ip6prefix)\r
+ {\r
+ /*-----------------------------------------------------------------*/\r
+ puts("Parsing ip6tables verbose output ...");\r
+ /*-----------------------------------------------------------------*/ \r
+ get_traffic_statistics(ip6tables);\r
+ }\r
}\r
\r
/*-----------------------------------------------------------------*/\r
perror(iptablesfile);\r
exit(-1);\r
}\r
+ iptables_save_line(iptablespreamble, FALSE);\r
+\r
+ if(ip6prefix)\r
+ {\r
+ ip6tables_file = fopen(ip6tablesfile, "w");\r
+ if(ip6tables_file == NULL)\r
+ {\r
+ perror(ip6tablesfile);\r
+ exit(-1);\r
+ }\r
+ iptables_save_line(iptablespreamble, TRUE);\r
+ }\r
+\r
+ run_iptables_restore();\r
\r
log_file = fopen(cmdlog, "w");\r
if(log_file == NULL) \r
exit(-1);\r
}\r
\r
- save_line(iptablespreamble);\r
- run_restore();\r
\r
sprintf(str,"%s qdisc del dev %s root 2>/dev/null",tc,lan);\r
safe_run(str);\r
safe_run(str);\r
\r
iptables_file=fopen(iptablesfile,"w");\r
- save_line(iptablespreamble);\r
+ iptables_save_line(iptablespreamble, FALSE);\r
+ if(ip6prefix)\r
+ {\r
+ ip6tables_file=fopen(ip6tablesfile,"w");\r
+ iptables_save_line(iptablespreamble, TRUE);\r
+ }\r
\r
- if(qos_free_zone && *qos_free_zone!='0')\r
+ if(qos_free_zone && *qos_free_zone!='0') /* this is currently supported only for IPv4 */\r
{\r
char *chain;\r
\r
sprintf(str,"-A FORWARD -d %s -o %s -j ACCEPT", qos_free_zone, wan);\r
- save_line(str);\r
+ iptables_save_line(str, FALSE); /* this is currently supported only for IPv4 */\r
\r
if(qos_proxy)\r
{\r
- save_line(":post_noproxy - [0:0]");\r
+ iptables_save_line(":post_noproxy - [0:0]", FALSE);\r
sprintf(str,"-A POSTROUTING ! -p tcp -o %s -j post_noproxy", lan);\r
- save_line(str); \r
+ iptables_save_line(str , FALSE);\r
sprintf(str,"-A POSTROUTING ! -s %s -o %s -j post_noproxy", proxy_ip, lan);\r
- save_line(str); \r
+ iptables_save_line(str, FALSE);\r
sprintf(str,"-A POSTROUTING -s %s -p tcp ! --sport %d -o %s -j post_noproxy", proxy_ip, proxy_port, lan);\r
- save_line(str); \r
+ iptables_save_line(str, FALSE);\r
\r
chain="post_noproxy"; \r
}\r
}\r
\r
sprintf(str,"-A %s -s %s -o %s -j ACCEPT", chain, qos_free_zone, lan);\r
- save_line(str);\r
+ iptables_save_line(str, FALSE);\r
}\r
\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
+ int idxcount=0, bitmask=32-idxtable_bitmask1;\r
char *subnet, *buf;\r
/*-----------------------------------------------------------------*/\r
printf("Detected %d addresses - indexing iptables rules to improve performance...\n",ip_count);\r
/*-----------------------------------------------------------------*/\r
\r
- save_line(":post_common - [0:0]");\r
- save_line(":forw_common - [0:0]");\r
+ iptables_save_line(":post_common - [0:0]", FALSE);\r
+ iptables_save_line(":forw_common - [0:0]", FALSE);\r
+ if(ip6prefix)\r
+ {\r
+ iptables_save_line(":post_common - [0:0]", TRUE);\r
+ iptables_save_line(":forw_common - [0:0]", TRUE);\r
+ }\r
\r
- for_each(ip,ips) if(ip->addr && *(ip->addr) && !eq(ip->addr,"0.0.0.0/0") && !strchr(ip->addr,':')) /* only IPv4 */\r
+ for_each(ip,ips) if(ip->addr && *(ip->addr) && !eq(ip->addr,"0.0.0.0/0")) \r
{\r
- buf=index_id(ip->addr,bitmask);\r
+ if(ip->v6)\r
+ {\r
+ buf=index6_id(ip->addr,bitmask+32);\r
+ }\r
+ else\r
+ {\r
+ buf=index_id(ip->addr, bitmask);\r
+ }\r
+ \r
if_exists(idx,idxs,eq(idx->id,buf))\r
{\r
idx->children++;\r
else\r
{\r
create(idx,Index);\r
- idx->addr=ip->addr;\r
- idx->id=buf;\r
- idx->bitmask=bitmask;\r
- idx->parent=NULL;\r
- idx->children=0;\r
+ idx->addr = ip->addr;\r
+ idx->id = buf;\r
+ idx->bitmask = bitmask+32*ip->v6;\r
+ idx->parent = NULL;\r
+ idx->children = 0;\r
+ idx->ipv6 = ip->v6;\r
idxcount++;\r
push(idx,idxs);\r
}\r
\r
for_each(idx,idxs) if(idx->parent == NULL)\r
{\r
- buf = index_id(idx->addr,bitmask);\r
+ if(idx->ipv6)\r
+ {\r
+ buf = index6_id(idx->addr, bitmask+32);\r
+ }\r
+ else\r
+ {\r
+ buf = index_id(idx->addr, bitmask);\r
+ }\r
if_exists(metaindex,idxs,eq(metaindex->id,buf))\r
{\r
metaindex->children++;\r
else\r
{\r
create(metaindex,Index);\r
- metaindex->addr=idx->addr;\r
- metaindex->id=buf;\r
- metaindex->bitmask=bitmask;\r
- metaindex->parent=NULL;\r
- metaindex->children=0;\r
+ metaindex->addr = idx->addr;\r
+ metaindex->id = buf;\r
+ metaindex->bitmask = bitmask+32*idx->ipv6;\r
+ metaindex->parent = NULL;\r
+ metaindex->children = 0;\r
+ metaindex->ipv6 = idx->ipv6;\r
idxcount++;\r
push(metaindex,idxs);\r
}\r
i=0;\r
for_each(idx,idxs)\r
{\r
- subnet=subnet_id(idx->addr,idx->bitmask);\r
- printf("%d: %s/%d\n",\r
- ++i, subnet, idx->bitmask);\r
+ if(idx->ipv6)\r
+ {\r
+ subnet=subnet6_id(idx->addr, idx->bitmask);\r
+ }\r
+ else\r
+ {\r
+ subnet=subnet_id(idx->addr, idx->bitmask);\r
+ }\r
+ printf("%d: %s/%d\n", ++i, subnet, idx->bitmask);\r
\r
sprintf(str,":post_%s - [0:0]", idx->id);\r
- save_line(str);\r
+ iptables_save_line(str, idx->ipv6);\r
\r
sprintf(str,":forw_%s - [0:0]", idx->id);\r
- save_line(str);\r
+ iptables_save_line(str, idx->ipv6);\r
\r
if(idx->parent)\r
{\r
string(buf,strlen(idx->parent->id)+6);\r
- sprintf(buf,"post_%s",idx->parent->id);\r
+ sprintf(buf,"post_%s", idx->parent->id);\r
}\r
else\r
{\r
}\r
\r
sprintf(str,"-A %s -d %s/%d -o %s -j post_%s", buf, subnet, idx->bitmask, lan, idx->id);\r
- save_line(str);\r
+ iptables_save_line(str, idx->ipv6);\r
\r
sprintf(str,"-A %s -d %s/%d -o %s -j post_common", buf, subnet, idx->bitmask, lan);\r
- save_line(str);\r
+ iptables_save_line(str, idx->ipv6);\r
\r
if(idx->parent)\r
{\r
}\r
\r
sprintf(str,"-A %s -s %s/%d -o %s -j forw_%s", buf, subnet, idx->bitmask, wan, idx->id);\r
- save_line(str);\r
+ iptables_save_line(str, idx->ipv6);\r
\r
sprintf(str,"-A %s -s %s/%d -o %s -j forw_common", buf, subnet, idx->bitmask, wan);\r
- save_line(str);\r
+ iptables_save_line(str, idx->ipv6);\r
}\r
printf("Total indexed iptables chains created: %d\n", i);\r
\r
sprintf(str,"-A FORWARD -o %s -j forw_common", wan);\r
- save_line(str);\r
+ iptables_save_line(str, FALSE);\r
\r
sprintf(str,"-A POSTROUTING -o %s -j post_common", lan);\r
- save_line(str);\r
+ iptables_save_line(str, FALSE);\r
+\r
+ if(ip6prefix)\r
+ {\r
+ sprintf(str,"-A FORWARD -o %s -j forw_common", wan);\r
+ iptables_save_line(str, TRUE);\r
+ \r
+ sprintf(str,"-A POSTROUTING -o %s -j post_common", lan);\r
+ iptables_save_line(str, TRUE);\r
+ }\r
}\r
- \r
}\r
\r
if(just_flush)\r
printf("Writing json traffic overview %s ... ", json_traffic);\r
/*-----------------------------------------------------------------*/\r
write_json_traffic(json_traffic);\r
- }\r
\r
- /*-----------------------------------------------------------------*/\r
- printf("Writing statistics into HTML page %s ...\n", html);\r
- /*-----------------------------------------------------------------*/\r
- write_htmlandlogs(html, d,total, just_preview);\r
+ /*-----------------------------------------------------------------*/\r
+ printf("Writing statistics into HTML page %s ...\n", html);\r
+ /*-----------------------------------------------------------------*/\r
+ write_htmlandlogs(html, d, total, just_preview);\r
+ }\r
\r
if(just_preview)\r
{\r
puts("Generating iptables and tc classes ... ");\r
/*-----------------------------------------------------------------*/\r
\r
- for_each(ip, ips) if(ip->mark > 0 && !strchr(ip->addr,':')) /* works only for IPv4 so far */\r
+ for_each(ip, ips) if(ip->mark > 0) /* works only for IPv4 so far */\r
{\r
if(idxs)\r
{\r
char *buf;\r
duplicate(ip->addr,buf);\r
- buf=index_id(ip->addr,32-idxtable_bitmask1); \r
+ if(ip->v6)\r
+ {\r
+ buf=index6_id(ip->addr,64-idxtable_bitmask1);\r
+ }\r
+ else\r
+ {\r
+ buf=index_id(ip->addr,32-idxtable_bitmask1);\r
+ }\r
\r
string(chain_forward,6+strlen(buf));\r
strcpy(chain_forward,"forw_");\r
\r
/* -------------------------------------------------------- mark download */\r
\r
- sprintf(str, "-A %s -d %s/32 -o %s -j %s%d",\r
- chain_postrouting, ip->addr, lan, mark_iptables, ip->mark);\r
- /*sprintf(str,"-A %s -d %s/32 -o %s -j MARK --set-mark %d",chain_postrouting,ip->addr,lan,ip->mark);*/\r
+ sprintf(str, "-A %s -d %s/%d -o %s -j %s%d",\r
+ chain_postrouting, ip->addr, 32*(1+ip->v6), lan, mark_iptables, ip->mark);\r
/* -m limit --limit 1/s */ \r
- save_line(str);\r
+ iptables_save_line(str, ip->v6);\r
\r
if(qos_proxy)\r
{\r
- sprintf(str, "-A %s -s %s -p tcp --sport %d -d %s/32 -o %s -j %s%d",\r
- chain_postrouting, proxy_ip, proxy_port, ip->addr, lan, mark_iptables, ip->mark);\r
- /*sprintf(str,"-A %s -s %s -p tcp --sport %d -d %s/32 -o %s -j MARK --set-mark %d",chain_postrouting,proxy_ip,proxy_port,ip->addr,lan,ip->mark);*/\r
- save_line(str);\r
+ sprintf(str, "-A %s -s %s -p tcp --sport %d -d %s/%d -o %s -j %s%d",\r
+ chain_postrouting, proxy_ip, proxy_port, ip->addr, 32*(1+ip->v6), lan, mark_iptables, ip->mark);\r
+ iptables_save_line(str, ip->v6);\r
}\r
\r
- sprintf(str, "-A %s -d %s/32 -o %s -j ACCEPT",\r
- chain_postrouting, ip->addr, lan);\r
- save_line(str);\r
+ sprintf(str, "-A %s -d %s/%d -o %s -j ACCEPT",\r
+ chain_postrouting, ip->addr, 32*(1+ip->v6), lan);\r
+ iptables_save_line(str, ip->v6);\r
\r
/* -------------------------------------------------------- mark upload */\r
- sprintf(str, "-A %s -s %s/32 -o %s -j %s%d", \r
- chain_forward, ip->addr, wan, mark_iptables, ip->mark);\r
- /* sprintf(str,"-A %s -s %s/32 -o %s -j MARK --set-mark %d",chain_forward,ip->addr,wan,ip->mark);*/\r
- save_line(str);\r
+ sprintf(str, "-A %s -s %s/%d -o %s -j %s%d", \r
+ chain_forward, ip->addr, 32*(1+ip->v6), wan, mark_iptables, ip->mark);\r
+ iptables_save_line(str, ip->v6);\r
\r
- sprintf(str, "-A %s -s %s/32 -o %s -j ACCEPT",\r
- chain_forward, ip->addr, wan);\r
- save_line(str);\r
+ sprintf(str, "-A %s -s %s/%d -o %s -j ACCEPT",\r
+ chain_forward, ip->addr, 32*(1+ip->v6), wan);\r
+ iptables_save_line(str, ip->v6);\r
\r
if(ip->min)\r
{\r
\r
if(strcmpi(ip->keyword->leaf_discipline, "none"))\r
{\r
- sprintf(str, "%s qdisc add dev %s parent 1:%d handle %d %s", \r
- tc, lan, ip->mark, ip->mark, ip->keyword->leaf_discipline); /*qos_leaf*/\r
- safe_run(str);\r
+ sprintf(str, "%s qdisc add dev %s parent 1:%d handle %d %s", \r
+ tc, lan, ip->mark, ip->mark, ip->keyword->leaf_discipline); /*qos_leaf*/\r
+ safe_run(str);\r
}\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",\r
- tc, lan, ip->mark, ip->mark);\r
- safe_run(str);\r
+ sprintf(str, "%s filter add dev %s parent 1:0 protocol ip handle %d fw flowid 1:%d",\r
+ tc, lan, ip->mark, ip->mark);\r
+ safe_run(str);\r
}\r
\r
/* -------------------------------------------------------- upload class */\r
\r
if(strcmpi(ip->keyword->leaf_discipline, "none"))\r
{\r
- sprintf(str, "%s qdisc add dev %s parent 1:%d handle %d %s",\r
- tc, wan, ip->mark, ip->mark, ip->keyword->leaf_discipline); /*qos_leaf*/\r
- safe_run(str);\r
+ sprintf(str, "%s qdisc add dev %s parent 1:%d handle %d %s",\r
+ tc, wan, ip->mark, ip->mark, ip->keyword->leaf_discipline); /*qos_leaf*/\r
+ safe_run(str);\r
} \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",\r
- tc, wan, ip->mark, ip->mark);\r
- safe_run(str);\r
+ sprintf(str, "%s filter add dev %s parent 1:0 protocol ip handle %d fw flowid 1:%d",\r
+ tc, wan, ip->mark, ip->mark);\r
+ safe_run(str);\r
}\r
\r
if(f > 0)\r
{\r
- fprintf(f, "%s %d\n", ip->addr, ip->mark);\r
+ fprintf(f, "%s %d\n", ip->addr, ip->mark);\r
}\r
}\r
else\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
- /* -------------------------------- classify or reject free download */\r
+\r
+ if(free_min)\r
{\r
- char *final_chain = "DROP"; /* REJECT would be better, but it is impossible in mangle */\r
- if(free_min)\r
- {\r
- final_chain = "ACCEPT";\r
- }\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",\r
- 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",\r
- 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
+ final_chain = "ACCEPT";\r
+ }\r
+\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",\r
+ chain_postrouting,proxy_ip,proxy_port,lan,mark_iptables, 3);\r
+ iptables_save_line(str, FALSE); /* only for IPv4 */\r
+ }\r
+ sprintf(str, "-A %s -s %s -p tcp --sport %d -o %s -j %s",\r
+ chain_postrouting,proxy_ip,proxy_port,lan,final_chain);\r
+ iptables_save_line(str, FALSE); /* only for IPv4 */\r
+ }\r
+\r
+ if(free_min)\r
+ {\r
+ sprintf(str, "-A %s -o %s -j %s%d",\r
+ chain_postrouting, lan, mark_iptables, 3);\r
+ iptables_save_line(str, FALSE); /* only for IPv4 */\r
+ }\r
+\r
+ sprintf(str,"-A %s -o %s -j %s", chain_postrouting, lan, final_chain);\r
+ iptables_save_line(str, FALSE);\r
+ if(ip6prefix)\r
+ {\r
+ sprintf(str,"-A %s -o %s -j %s", chain_postrouting, lan, final_chain);\r
+ iptables_save_line(str, TRUE);\r
+ }\r
+\r
+ if(free_min)\r
+ {\r
+ sprintf(str,"-A %s -o %s -j %s%d", chain_forward, wan, mark_iptables, 3);\r
+ iptables_save_line(str, FALSE); /* only for IPv4 */\r
+ }\r
+\r
+ sprintf(str,"-A %s -o %s -j %s", chain_forward, wan, final_chain);\r
+ iptables_save_line(str, FALSE);\r
+ if(ip6prefix)\r
+ {\r
+ sprintf(str,"-A %s -o %s -j %s", chain_postrouting, lan, final_chain);\r
+ iptables_save_line(str, TRUE);\r
}\r
\r
if(free_min) /* allocate free bandwith if it is not zero... */ \r
safe_run(str);\r
}\r
printf("Total IP count: %d\n", i);\r
- run_restore(); \r
+ run_iptables_restore();\r
if(log_file)\r
{\r
fclose(log_file);\r