X-Git-Url: http://git.harvie.cz/?a=blobdiff_plain;f=prometheus.c;h=c7887a0e5b099f1326f2229f802a48222b879fb1;hb=abe9b855231afc2d01861539e9569e86be57f04b;hp=3abaa34ecb78b77d2ed83100e20b42b3d05f13f2;hpb=99127c70a2642b70ed3cde02f22ed2e4fc5d126f;p=svn%2FPrometheus-QoS%2F.git diff --git a/prometheus.c b/prometheus.c index 3abaa34..c7887a0 100644 --- a/prometheus.c +++ b/prometheus.c @@ -1,13 +1,13 @@ - -/* ============================================================= */ -/* === 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) === */ -/* === Credits: CZFree.Net, Martin Devera, Netdave, Aquarius === */ -/* ============================================================= */ - -/* Modified: xChaos, 20080119 +/* =============================================================== */ +/* == 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, 20080201 ludva, 20071227 Prometheus QoS is free software; you can redistribute it and/or @@ -28,12 +28,12 @@ #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.7-1"; /*0.7.9 will be last development, 0.8.0 first stable */ +const char *version="0.7.8"; /*0.7.9 will be last development, 0.8.0 first stable */ /* ======= Help screen is hopefuly self-documenting part of code :-) ======= */ @@ -74,7 +74,7 @@ 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/logs/"; /* log directory pathname */ +char *log_dir="/var/www/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 */ @@ -88,8 +88,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 */ @@ -111,10 +111,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 */ +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: @@ -563,6 +563,10 @@ void run_restore(void) { char *restor, *str; string(restor,STRLEN); + + /*-----------------------------------------------------------------*/ + printf("Running %s <%s ...\n",iptablesrestore,iptablesfile); + /*-----------------------------------------------------------------*/ save_line("COMMIT"); fclose(iptables_file); @@ -641,7 +645,7 @@ program Prometheus QoS - \"fair-per-IP\" Quality of Service setup utility.\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: ----*/ @@ -748,7 +752,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) { @@ -1075,7 +1079,7 @@ Credits: CZFree.Net, Martin Devera, Netdave, Aquarius\n\n",version); } else { - if( keyword->data_prio && !ip->fixedprio && + if( ip->keyword->data_prio && !ip->fixedprio && ip->traffic>ip->credit+ (ip->min*ip->keyword->data_prio+(ip->keyword->fixed_prio<<20)) ) { @@ -1459,6 +1463,10 @@ Credits: CZFree.Net, Martin Devera, Netdave, Aquarius\n\n",version); 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); @@ -1481,7 +1489,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);