X-Git-Url: http://git.harvie.cz/?p=svn%2FPrometheus-QoS%2F.git;a=blobdiff_plain;f=prometheus.c;h=38bd53b8e3e2ffd2ed1f4917cf9157fd515a5b4e;hp=96ce79705ebeaa45515dc191dab14a6399832f03;hb=33ec95ab4c8797bc37e0ccc97411f7c67bd08f80;hpb=5def4ce39f6eec34acb8c333068da837bb28311b diff --git a/prometheus.c b/prometheus.c index 96ce797..38bd53b 100644 --- a/prometheus.c +++ b/prometheus.c @@ -1,14 +1,14 @@ - -/* ============================================================= */ -/* === Prometheus QoS - you can "steal fire" from your ISP === */ -/* === "fair-per-IP" quality of service (QoS) utility === */ -/* === requires Linux 2.4.x or 2.6.x with HTB support === */ -/* === Copyright(C) 2005-2007 Michael Polak (xChaos) === */ -/* === Credits: CZFree.Net, Martin Devera, Netdave, Aquarius === */ -/* ============================================================= */ - -/* Modified: xChaos, 20070502 - ludva, 20071227 + /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ + /* Prometheus QoS - you can "steal fire" from your ISP */ +/* "fair-per-IP" quality of service (QoS) utility */ +/* requires Linux 2.4.x or 2.6.x with HTB support */ +/* Copyright(C) 2005-2008 Michael Polak (xChaos) */ +/* iptables-restore support Copyright(C) 2007-2008 ludva */ +/* Credit: CZFree.Net,Martin Devera,Netdave,Aquarius,Gandalf */ +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ + +/* Modified: xChaos, 20080422 + ludva, 20080415 Prometheus QoS is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -20,18 +20,40 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with the Linux kernel source code; if not, write to - Michael Polak, Svojsikova 7, 169 00 Praha 6 Czech Republic */ + You should have received a copy of the GNU General Public License + along with Prometheus Qos; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + GNU General Public License is located in file COPYING */ #define STRLEN 256 #define FIRSTGROUPID 1024 -#define MAX_GUARANTED_KBPS 2048 +#define FIRSTIPCLASS 2048 #undef DEBUG -#include "cll1.h" +#include "cll1-0.6.h" + +const char *version="0.7.9.2"; /*0.7.9 will be last development, 0.8.0 first stable */ + +/* ======= All path names are defined hear (for RPM patch) ======= */ + +char *tc = "/sbin/tc"; /* requires tc with HTB support */ +char *iptables = "/sbin/iptables"; /* requires iptables utility */ +char *iptablessave = "/sbin/iptables-save"; /* not yet required */ +char *iptablesrestore = "/sbin/iptables-restore"; /* requires iptables-restore */ +char *ls = "/bin/ls"; /* this is not user configurable :-) */ + +char *config = "/etc/prometheus/prometheus.conf"; /* main configuration file */ +char *hosts = "/etc/prometheus/hosts"; /* per-IP bandwidth definition file */ -const char *version="0.7.7"; /*0.7.9 will be last development, 0.8.0 first stable */ +char *iptablesfile = "/var/spool/prometheus.iptables"; /* temporary file for iptables-restore*/ +char *credit = "/var/lib/misc/prometheus.credit"; /* credit log file */ +char *html = "/var/www/traffic.html"; /* hall of fame filename */ +char *preview = "/var/www/preview.html"; /* hall of fame preview */ +char *cmdlog = "/var/log/prometheuslog"; /* command log filename */ +char *log_dir = "/var/www/logs/"; /* log directory pathname, ended with slash */ +char *log_url = "logs/"; /* log directory relative URI prefix (partial URL) */ +char *html_log_dir = "/var/www/logs/html/"; /* ======= Help screen is hopefuly self-documenting part of code :-) ======= */ @@ -48,7 +70,13 @@ void help(void) -p just generate preview of data transfer statistics and exit\n\ -n no delay (overrides qos-free-delay keyword)\n\ -d dry run (preview tc and iptables commands on stdout)\n\ -"); +-l Mmm YYYY generate HTML summary of traffic logs (Mmm=Jan-Dec or Year, YYYY=year)\n\ +-m generate HTML summary of traffic logs for yesterday's month\n\ +-y generate HTML summary of traffic logs for yesterday's year\n"); +/* not yet implemented: +-s start shaping! (keep data transfer statistics - but apply shaping)\n\ +-r just reload configuration (...and keep data transfer statistics)\n\ +*/ } /* === Configuraration file values defaults - stored in global variables ==== */ @@ -57,23 +85,10 @@ int filter_type=1; /*1 mark, 2 classify*/ char *mark="MARK"; char *mark_iptables="MARK --set-mark "; int dry_run=0; /* preview - use puts() instead of system() */ -char *config="/etc/prometheus/prometheus.conf"; /* main configuration file */ -char *hosts="/etc/prometheus/hosts"; /* line bandwidth definition file */ -char *tc="/sbin/tc"; /* requires tc with HTB support */ -char *iptables="/usr/sbin/iptables"; /* requires iptables utility */ -char *iptablessave="/usr/sbin/iptables-save"; /* new */ -char *iptablesrestore="/usr/sbin/iptables-restore"; /* new */ -char *iptablesfile="/var/spool/prometheus.iptables"; /* new; file for iptables-restore*/ 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]"; FILE *iptables_file=NULL; -char *html="/var/www/traffic.html"; /* hall of fame filename */ -char *preview="/var/www/preview.html"; /* hall of fame preview */ -char *cmdlog="/var/log/prometheus"; /* command log filename */ -char *credit="/var/run/prometheus.credit"; /* credit log file */ int enable_credit=1; /* enable credit file */ int use_credit=0; /* use credit file (if enabled)*/ -char *log_dir="/var/www/html/logs/"; /* log directory pathname */ -char *log_url="logs/"; /* log directory URL prefix */ char *title="Hall of Fame - Greatest Suckers"; /* hall of fame title */ int hall_of_fame=1; /* enable hall of fame */ char *lan="eth0"; /* LAN interface */ @@ -86,8 +101,8 @@ int qos_proxy=1; /* include proxy port to QoS */ int include_upload=1; /* upload+download=total traffic */ char *proxy_ip="192.168.1.1/32"; /* our IP with proxy port */ int proxy_port=3128; /* proxy port number */ -long long int line=1024; /* WAN/ISP download in kbps */ -long long int up=1024; /* WAN/ISP upload in kbps */ +long long int line=1024; /* WAN/ISP download in kbps */ +long long int up=1024; /* WAN/ISP upload in kbps */ int free_min=32; /* minimum guaranted bandwidth for all undefined hosts */ int free_max=64; /* maximum allowed bandwidth for all undefined hosts */ int qos_free_delay=0; /* seconds to sleep before applying new QoS rules */ @@ -109,16 +124,10 @@ FILE *log_file=NULL; char *kwd="via-prometheus"; /* /etc/hosts comment, eg. #qos-64-128 */ -const int idxtable_treshold1=24; /* this is no longer configurable */ -const int idxtable_treshold2=12; /* this is no longer configurable */ -const int idxtable_bitmask1=3; /* this is no longer configurable */ -const int idxtable_bitmask2=3; /* this is no longer configurable */ - - -/* not yet implemented: --s start shaping! (keep data transfer statistics - but apply shaping)\n\ --r just reload configuration (...and keep data transfer statistics)\n\ -*/ +const int idxtable_treshold1=24; /* this is no longer configurable */ +const int idxtable_treshold2=12; /* this is no longer configurable */ +const int idxtable_bitmask1=3; /* this is no longer configurable */ +const int idxtable_bitmask2=3; /* this is no longer configurable */ /* ==== This is C<<1 stuff - learn C<<1 first! http://cll1.arachne.cz ==== */ @@ -171,7 +180,7 @@ struct Keyword int asymetry_ratio; /* ratio for ADSL-like upload */ int asymetry_fixed; /* fixed treshold for ADSL-like upload */ int data_limit; /* hard shaping: apply magic_treshold if max*data_limit MB exceeded */ - int prio_limit; /* soft shaping (qos): reduce HTB prio if max*prio_limit MB exceeded */ + int data_prio; /* soft shaping (qos): reduce HTB prio if max*data_prio MB exceeded */ long fixed_limit; /* fixed data limit for setting lower HTB ceil */ long fixed_prio; /* fixed data lmit for setting lower HTB prio */ int reserve_min; /* bonus for nominal HTB rate bandwidth (in kbps) */ @@ -203,7 +212,7 @@ void TheIP(void) push(ip,ips); } -/* ====== Iptables indexes are used to reduce complexity to log8(N) ===== */ +/* ====== iptables indexes are used to reduce complexity to log8(N) ===== */ char *very_ugly_ipv4_code(char *inip,int bitmask,int format_as_chainname) { @@ -300,7 +309,7 @@ void get_config(char *config_filename) keyword->asymetry_ratio=1; /* ratio for ADSL-like upload */ keyword->asymetry_fixed=0; /* fixed treshold for ADSL-like upload */ keyword->data_limit=8; /* hard shaping: apply magic_treshold if max*data_limit MB exceeded */ - keyword->prio_limit=4; /* soft shaping (qos): reduce HTB prio if max*prio_limit MB exceeded */ + keyword->data_prio=4; /* soft shaping (qos): reduce HTB prio if max*data_prio MB exceeded */ keyword->fixed_limit=0; /* fixed data limit for setting lower HTB ceil */ keyword->fixed_prio=0; /* fixed data limit for setting lower HTB prio */ keyword->reserve_min=8; /* bonus for nominal HTB rate bandwidth (in kbps) */ @@ -332,7 +341,7 @@ void get_config(char *config_filename) ioption("asymetry-ratio",keyword->asymetry_ratio); ioption("asymetry-treshold",keyword->asymetry_fixed); ioption("magic-relative-limit",keyword->data_limit); - ioption("magic-relative-prio",keyword->prio_limit); + ioption("magic-relative-prio",keyword->data_prio); loption("magic-fixed-limit",keyword->fixed_limit); loption("magic-fixed-prio",keyword->fixed_prio); ioption("htb-default-prio",keyword->default_prio); @@ -347,10 +356,8 @@ void get_config(char *config_filename) _=tmptr; if(keyword->data_limit || keyword->fixed_limit || - keyword->prio_limit || keyword->fixed_prio) - use_credit=1; - - + keyword->data_prio || keyword->fixed_prio) + use_credit=1; } } @@ -374,6 +381,7 @@ void get_config(char *config_filename) option("credit-filename",credit); ioption("credit-enable",enable_credit); option("log-traffic-directory",log_dir); + option("log-traffic-html-directory",html_log_dir); option("log-traffic-url-path",log_url); option("qos-free-zone",qos_free_zone); ioption("qos-free-delay",qos_free_delay); @@ -390,8 +398,7 @@ void get_config(char *config_filename) ioption("htb-r2q",htb_r2q); ioption("magic-include-upload",include_upload); ioption("magic-priorities",magic_priorities); - ioption("magic-treshold",magic_treshold); - + ioption("magic-treshold",magic_treshold); option("filter-type", cnf); /* not yet implemented: @@ -561,20 +568,24 @@ void run_restore(void) { char *restor, *str; string(restor,STRLEN); + + /*-----------------------------------------------------------------*/ + printf("Running %s <%s ...\n",iptablesrestore,iptablesfile); + /*-----------------------------------------------------------------*/ save_line("COMMIT"); fclose(iptables_file); - if(dry_run) { + if(dry_run) + { parse(iptablesfile) { str=_; printf("%s\n", str); }done; - }else{ - //sprintf(restor,"cat %s",iptablesfile); else - sprintf(restor,"%s <%s",iptablesrestore, iptablesfile); - system(restor); - }; + } + + sprintf(restor,"%s <%s",iptablesrestore, iptablesfile); + safe_run(restor); free(restor); } @@ -617,6 +628,119 @@ char *parse_datafile_line(char *str) return NULL; } +struct IpLog +{ + char *name; + long traffic; + list(IpLog); +} *iplog,*iplogs; + +void parse_ip_log(int argc, char **argv) +{ + char *month,*year,*str,*name,*ptr,*ptr2; + long traffic,traffic_month,total=0; + int col,col2,y_ok,m_ok,accept_month,i=1,any_month=0; + char mstr[4],ystr[5]; + FILE *f; + + string(str,STRLEN); + + if(argv[1][1]=='l') /* -l */ + { + if(argc<4) + { + puts("Missing parameter(s)!\nUsage: prometheus -l Mmm YYYY (Mmm=Jan-Dec or Year, YYYY=year)"); + exit(-1); + } + else + { + month=argv[2]; + if(eq(month,"Year")) any_month=1; + year=argv[3]; + } + } + else + { + time_t t = time(NULL) - 3600*24 ; /* yesterday's timestamp*/ + struct tm *timep = localtime(&t); + + if(argv[1][1]=='m') /* -m yestarday - month */ + { + strftime(mstr, 4, "%b", timep); + month=mstr; + strftime(ystr, 5, "%Y", timep); + year=ystr; + } + else /* -y yesterday - year */ + { + month="Year"; + any_month=1; + strftime(ystr, 5, "%Y", timep); + year=ystr; + } + } + printf("Analysing traffic for %s %s ...\n",month,year); + + sprintf(str,"%s %s/*.log",ls,log_dir); + shell(str); + input(str,STRLEN) + { + ptr=strrchr(str,'\n'); + if(ptr) *ptr='\0'; + printf("Parsing %s ...",str); + accept_month=0; + traffic_month=0; + parse(str) + { + y_ok=m_ok=0; + valid_columns(ptr,_,'\t',col) switch(col) + { + case 2: name=ptr;break; + case 3: traffic=atol(ptr);break; + case 7: valid_columns(ptr2,ptr,' ',col2) switch(col2) + { + case 2: if(any_month || eq(ptr2,month)) m_ok=1; break; + case 5: if(eq(ptr2,year)) y_ok=1; break; + } + } + if(y_ok && m_ok) + { + traffic_month+=traffic; + accept_month=1; + } + } + done; + if(accept_month) + { + create(iplog,IpLog); + iplog->name=name; + iplog->traffic=traffic_month; + insert(iplog,iplogs,desc_order_by,traffic); + printf(" %ld MB\n",iplog->traffic); + } + else + puts(" no records."); + } + sprintf(str,"%s/%s-%s.html",html_log_dir,year,month); + printf("Writing %s ...",str); + f=fopen(str,"w"); + if(f) + { + fprintf(f,"\n ",month,year); + every(iplog,iplogs) + if(iplog->traffic) + { + fprintf(f,"\n",i++,iplog->name,iplog->traffic,iplog->traffic>>10); + total+=iplog->traffic>>10; + } + fprintf(f,"\n",total); + fputs("
Data transfers - %s %s
%d%s%ld MB%ld GB
Total:%ld GB
\n",f); + fclose(f); + puts(" done."); + } +} + + /*-----------------------------------------------------------------*/ /* Are you looking for int main (int argc, char **argv) ? :-)) */ /*-----------------------------------------------------------------*/ @@ -631,15 +755,17 @@ program int parent=1; int just_flush=0; int nodelay=0; - int just_preview=0; /* preview - generate just stats */ + int just_preview=0; /* preview - generate just stats */ + int just_logs=0; /* just parse logs */ + char *chain_forward, *chain_postrouting; char *althosts=NULL; printf("\n\ Prometheus QoS - \"fair-per-IP\" Quality of Service setup utility.\n\ -Version %s - Copyright (C)2005-2007 Michael Polak (xChaos)\n\ +Version %s - Copyright (C)2005-2008 Michael Polak (xChaos)\n\ iptables-restore & burst tunning & classify modification 0.7d by Ludva\n\ -Credits: CZFree.Net, Martin Devera, Netdave, Aquarius\n\n",version); +Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); /*----- Boring... we have to check command line options first: ----*/ @@ -652,6 +778,9 @@ Credits: CZFree.Net, Martin Devera, Netdave, Aquarius\n\n",version); argument("-9") { just_flush=9; } argument("-p") { just_preview=1; } argument("-n") { nodelay=1; } + argument("-l") { just_logs=1; } + argument("-m") { just_logs=1; } + argument("-y") { just_logs=1; } argument("-?") { help(); exit(0); } argument("--help") { help(); exit(0); } argument("-v") { exit(0); } @@ -667,6 +796,12 @@ Credits: CZFree.Net, Martin Devera, Netdave, Aquarius\n\n",version); printf("Parsing configuration file %s ...\n", config); /*-----------------------------------------------------------------*/ get_config(config); + + if(just_logs) + { + parse_ip_log(argc,argv); + exit(0); + } if(althosts) hosts=althosts; @@ -725,8 +860,8 @@ Credits: CZFree.Net, Martin Devera, Netdave, Aquarius\n\n",version); ip->min=atoi(substring); if(ip->min<=0) { - puts("Illegal value of minimum bandwidth: 0 kbps."); - reject_config_and_exit(hosts); + printf(" %s: Illegal value of minimum bandwidth 0 kbps, using %d kbps\n",str,free_min); + ip->min=free_min; } if(ip->max<=ip->min) { @@ -746,7 +881,7 @@ Credits: CZFree.Net, Martin Devera, Netdave, Aquarius\n\n",version); if(ip->maxmin) ip->max=ip->min; } - ip->mark=MAX_GUARANTED_KBPS+1+class_count++; + ip->mark=FIRSTIPCLASS+1+class_count++; find(group,groups,group->min==ip->min) { @@ -1062,10 +1197,9 @@ Credits: CZFree.Net, Martin Devera, Netdave, Aquarius\n\n",version); search(ip, ips, ip->min==group->min && ip->max>ip->min) { - if(ip->keyword->data_limit>0 && + if( ip->keyword->data_limit && !ip->fixedprio && ip->traffic>ip->credit+ - (ip->min*ip->keyword->data_limit+(ip->keyword->fixed_limit<<20)) - && !ip->fixedprio) + (ip->min*ip->keyword->data_limit+(ip->keyword->fixed_limit<<20)) ) { if(group_ratemax) ip->max=group_rate; group_rate+=magic_treshold; @@ -1074,9 +1208,9 @@ Credits: CZFree.Net, Martin Devera, Netdave, Aquarius\n\n",version); } else { - if(ip->traffic>ip->credit+ - (ip->min*ip->keyword->prio_limit+(ip->keyword->fixed_prio<<20)) && - !ip->fixedprio) + if( ip->keyword->data_prio && !ip->fixedprio && + ip->traffic>ip->credit+ + (ip->min*ip->keyword->data_prio+(ip->keyword->fixed_prio<<20)) ) { ip->prio=priority_sequence--; if(ip->prio<2) ip->prio=2; @@ -1085,6 +1219,7 @@ Credits: CZFree.Net, Martin Devera, Netdave, Aquarius\n\n",version); if(credit_file) { unsigned long long lcredit=0; + if((ip->min*ip->keyword->data_limit+(ip->keyword->fixed_limit<<20))>ip->traffic) lcredit=(ip->min*ip->keyword->data_limit+(ip->keyword->fixed_limit<<20))-ip->traffic; fprintf(credit_file,"%s %Lu\n",ip->addr,lcredit); @@ -1236,11 +1371,12 @@ Credits: CZFree.Net, Martin Devera, Netdave, Aquarius\n\n",version); if(!just_preview) { - sprintf(str,"%s%s.log",log_dir,ip->name); + sprintf(str,"%s/%s.log",log_dir,ip->name); iplog=fopen(str,"a"); if(iplog) { - fprintf(iplog,"%ld\t%s\t%Lu\t%Lu\t%Lu\t%Lu\t%s",time(NULL),ip->name,ip->traffic, ip->direct, ip->proxy, ip->upload,d); + fprintf(iplog,"%ld\t%s\t%Lu\t%Lu\t%Lu\t%Lu\t%d\t%d\t%d\t%s", + time(NULL),ip->name,ip->traffic,ip->direct,ip->proxy,ip->upload,ip->min,ip->max,ip->desired,d); /* d = date*/ fclose(iplog); } } @@ -1256,22 +1392,63 @@ Credits: CZFree.Net, Martin Devera, Netdave, Aquarius\n\n",version); if(active_classes>10) { - fputs("

\n",f); - fputs("\n",f); - find (sum,sums,sum->l>=total/4) - fprintf(f,"\n",sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total); - find (sum,sums,sum->i==10) - fprintf(f,"\n",(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total); - find (sum,sums,sum->l>=total/2) - fprintf(f,"\n",sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total); - find (sum,sums,sum->i>=(active_classes+3)/4) - fprintf(f,"\n",sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total); - find (sum,sums,sum->i>=(active_classes+1)/2) - fprintf(f,"\n",sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total); - fprintf(f,"\n",active_classes,total); + fputs("

Enterprise Research and Planning (ERP)
Active ClassesData transfers
Top %d%d %%%Lu M%Ld %%
Top 10%d %%%Lu M%Ld %%
Top %d%d %%%Lu M%Ld %%
Top %d%d %%%Lu M%Ld %%
Top %d%d %%%Lu M%Ld %%
All %d100 %%%Lu M100 %%
\n",f); + fputs("\n",f); + fputs("\n",f); + + find(sum,sums,sum->l>=total/4) + { + fprintf(f,"\n"); + fprintf(f,"\n",sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total); + } + + find(sum,sums,sum->i==10) + { + fprintf(f,"\n"); + fprintf(f,"\n",(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total); + } + + find(sum,sums,sum->l>=total/2) + { + fprintf(f,"\n"); + fprintf(f,"\n",sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total); + } + + find(sum,sums,sum->l>=4*total/5) + { + fprintf(f,"\n"); + fprintf(f,"\n",sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total); + } + + find (sum,sums,sum->i>=(active_classes+1)/5) + { + fprintf(f,"\n"); + fprintf(f,"\n",sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total); + } + + find(sum,sums,sum->i>=(active_classes+1)/4) + { + fprintf(f,"\n"); + fprintf(f,"\n",sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total); + } + + find(sum,sums,sum->i>=(active_classes+1)/2) + { + fprintf(f,"\n"); + fprintf(f,"\n",sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total); + } + + find(sum,sums,sum->i>=4*(active_classes+1)/5) + { + fprintf(f,"\n"); + fprintf(f,"\n",sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total); + } + + fprintf(f,"\n"); + fprintf(f,"\n",active_classes,total); fputs("
Enterprise Research and Planning (ERP)
Analytic categoryActive ClassesData transfers
Top 25%% of traffic%d%d %%%Lu M%Ld %%
Top 10 downloaders10%d %%%Lu M%Ld %%
Top 50%% of traffic%d%d %%%Lu M%Ld %%
Top 80%% of traffic%d%d %%%Lu M%Ld %%
Top 20%% downloaders%d%d %%%Lu M%Ld %%
Top 25%% downloaders%d%d %%%Lu M%Ld %%
Top 50%% downloaders%d%d %%%Lu M%Ld %%
Top 80%% downloaders%d%d %%%Lu M%Ld %%
All users, all traffic%d100 %%%Lu M100 %%
\n",f); } - fprintf(f,"Statistics generated by Prometheus QoS version %s
GPL+Copyright(C)2005 Michael Polak, Arachne Labs
\n",version); + fprintf(f,"Statistics generated by Prometheus QoS version %s
GPL+Copyright(C)2005-2008 Michael Polak, Arachne Labs
\n",version); fclose(f); } @@ -1398,24 +1575,28 @@ Credits: CZFree.Net, Martin Devera, Netdave, Aquarius\n\n",version); if(qos_proxy) { - sprintf(str,"-A %s -s %s -p tcp --sport %d -o %s -j MARK --set-mark 3",chain_postrouting,proxy_ip,proxy_port,lan); + 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); save_line(str); sprintf(str,"-A %s -s %s -p tcp --sport %d -o %s -j ACCEPT",chain_postrouting,proxy_ip,proxy_port,lan); save_line(str); } - sprintf(str,"-A %s -o %s -j MARK --set-mark 3",chain_postrouting,lan); + sprintf(str,"-A %s -o %s -j %s%d",chain_postrouting,lan,mark_iptables,3); save_line(str); sprintf(str,"-A %s -o %s -j ACCEPT",chain_postrouting,lan); save_line(str); /* -------------------------------------------------------- mark upload */ - sprintf(str,"-A %s -o %s -j MARK --set-mark 3",chain_forward,wan); + sprintf(str,"-A %s -o %s -j %s%d",chain_forward,wan,mark_iptables,3); save_line(str); sprintf(str,"-A %s -o %s -j ACCEPT",chain_forward,wan); save_line(str); printf("Total IP count: %d\n", i); + /*-----------------------------------------------------------------*/ + puts("Generating free bandwith classes ..."); + /*-----------------------------------------------------------------*/ + /* ---------------------------------------- tc - free bandwith shared class */ 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); safe_run(str); @@ -1438,7 +1619,7 @@ Credits: CZFree.Net, Martin Devera, Netdave, Aquarius\n\n",version); sprintf(str,"%s filter add dev %s parent 1:0 protocol ip handle 3 fw flowid 1:3",tc,wan); safe_run(str); - + run_restore(); if (log_file) fclose(log_file);