X-Git-Url: https://git.harvie.cz/?a=blobdiff_plain;f=prometheus.c;h=70b0953b5da168e415953e3ca0a418fabdbb37bf;hb=3f76726a95b374e0f3b405b6e07f1ed3f565df01;hp=b5f610be06f59aedc3f3370d8abe5ba0a1e78f2e;hpb=14e28c6f75dba715fac299d909fdad50bfcf192d;p=svn%2FPrometheus-QoS%2F.git diff --git a/prometheus.c b/prometheus.c index b5f610b..70b0953 100644 --- a/prometheus.c +++ b/prometheus.c @@ -1,5 +1,6 @@ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -/* Prometheus QoS - you can "steal fire" from your ISP *//* "fair-per-IP" quality of service (QoS) utility */ +/* 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-2013 Michael Polak, Arachne Aerospace */ /* iptables-restore support Copyright(C) 2007-2008 ludva */ @@ -471,6 +472,7 @@ program int nodelay = FALSE; int just_preview = FALSE; /* preview - generate just stats */ int start_shaping = FALSE; /* apply FUP - requires classmap file */ + int stop_shaping = FALSE; /* apply FUP - requires classmap file */ int just_logs = FALSE; /* just parse logs */ int run = FALSE; int total = 0; @@ -493,6 +495,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); argument("-f") { run=TRUE; just_flush=TRUE; } argument("-9") { run=TRUE; just_flush=9; } argument("-p") { run=TRUE; just_preview=TRUE; } + argument("-q") { run=TRUE; just_preview=TRUE; stop_shaping=TRUE; } argument("-s") { run=TRUE; just_preview=TRUE; start_shaping=TRUE; } argument("-r") { run=TRUE; } argument("-n") { run=TRUE; nodelay=TRUE; } @@ -563,12 +566,12 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); /*-----------------------------------------------------------------*/ for_each(ip,ips) if(ip->sharing) { - for_each(sharedip,ips) if(eq(sharedip->name,ip->sharing)) + for_each(sharedip,ips) if(eq(sharedip->name, ip->sharing)) { - sharedip->traffic+=ip->traffic; - ip->traffic=0; - ip->mark=sharedip->mark; - ip->lmsid=sharedip->lmsid; + sharedip->traffic += ip->traffic; + ip->traffic = 0; + ip->mark = sharedip->mark; + ip->lmsid = sharedip->lmsid; break; } if(not sharedip) @@ -630,8 +633,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); { perror(cmdlog); exit(-1); - } - + } sprintf(str,"%s qdisc del dev %s root 2>/dev/null",tc,lan); safe_run(str); @@ -977,7 +979,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); if(just_preview) { - if(start_shaping) + if(start_shaping || stop_shaping) { printf("Reading %s and applying Fair Use Policy rules ... \n", classmap); parse(classmap) @@ -990,9 +992,17 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); if_exists(ip,ips,eq(ip->addr,_)) { ip->mark=atoi(ptr); - if(ip->max < ip->desired) /* apply FUP limit immediately.... */ + if(ip->max < ip->desired || stop_shaping) /* apply or disable FUP limit immediately.... */ { - printf("Applying limit for %-22s %-16s %04d ", ip->name, ip->addr, ip->mark); + if(stop_shaping) + { + ip->max = ip->desired; + printf("Removing limit for %-22s %-16s %04d ", ip->name, ip->addr, ip->mark); + } + else + { + printf("Applying limit for %-22s %-16s %04d ", ip->name, ip->addr, ip->mark); + } printf("(down: %dk-%dk ", ip->min, ip->max); sprintf(str, "%s class change 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); @@ -1013,6 +1023,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); perror(classmap); puts("Warning - classmap file not fund, just generating preview ..."); start_shaping=FALSE; + stop_shaping=FALSE; } done; /* ugly macro end */ } @@ -1040,6 +1051,11 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); { swchar='s'; } + else if(stop_shaping) + { + swchar='q'; + } + printf("Statistics preview generated (-%c switch) - now exiting ...\n", swchar); exit(0); }