X-Git-Url: https://git.harvie.cz/?a=blobdiff_plain;f=prometheus.c;h=19f06e822ea1782c56d54c0082d6e7e365c7a9c9;hb=0d5026c69dd374864809387e382fe3d569b02995;hp=282e0db069f0d2c2a60ab29db60fc985d7244802;hpb=ab85aff7bf367a49bb28e3e2be0abfbc7c7a0363;p=svn%2FPrometheus-QoS%2F.git diff --git a/prometheus.c b/prometheus.c index 282e0db..19f06e8 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: @@ -173,7 +173,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) */ @@ -302,7 +302,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) */ @@ -334,7 +334,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); @@ -349,7 +349,7 @@ void get_config(char *config_filename) _=tmptr; if(keyword->data_limit || keyword->fixed_limit || - keyword->prio_limit || keyword->fixed_prio) + keyword->data_prio || keyword->fixed_prio) use_credit=1; @@ -641,7 +641,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 +748,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) { @@ -1064,10 +1064,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; @@ -1076,9 +1075,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( 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; @@ -1087,6 +1086,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);