X-Git-Url: https://git.harvie.cz/?p=svn%2FPrometheus-QoS%2F.git;a=blobdiff_plain;f=parsehosts.c;h=7e12a41b34d1280821ef1c916e417675fade4b4a;hp=b21af786e7d7c87a4dc0d5afb52107f08fe200a0;hb=a25842fafee4469c8acbacd673fc4c905bcab3f9;hpb=cdfd88eb2cfba828e5bfc3f77eba37b3cba286ce diff --git a/parsehosts.c b/parsehosts.c index b21af78..7e12a41 100644 --- a/parsehosts.c +++ b/parsehosts.c @@ -17,7 +17,7 @@ extern int free_min; extern const int highest_priority; extern char *ip6prefix; -struct IP* find_network_for_ip(char *ipaddr_orig); +void update_network(char *look_for, struct IP* ip); /* implemented in networks.c */ /* This must be object oriented! This looks almost like constructor ;-) */ @@ -40,6 +40,7 @@ void TheIP(char *ipaddr, int is_network) ip->direct = \ ip->traffic = \ ip->pktsup = \ + ip->pps_limit = \ ip->pktsdown = 0; ip->keyword = keywords; ip->v6 = (strchr(ip->addr,':')!=NULL); @@ -235,6 +236,7 @@ void parse_hosts(char *hosts) *ptr=0; ip->max = ip->desired = atoi(ptr+1); } + ip->min = atoi(substring); if(ip->min <= 0) { @@ -242,6 +244,7 @@ void parse_hosts(char *hosts) str, free_min); ip->min = free_min; } + if(ip->max <= ip->min) { ip->fixedprio = TRUE; @@ -250,24 +253,23 @@ void parse_hosts(char *hosts) else { ip->max -= ip->keyword->reserve_max; - if(ip->maxmin) + if(ip->max < ip->min) { - ip->max=ip->min; + ip->max = ip->min; } } - ip->mark = FIRSTIPCLASS+1+class_count++; - network = find_network_for_ip(ip->addr); - if(network) + /* MTU is 1450 bytes = 11600 bits ~= 12 kbit, max is in kb/s + average pkt 1/2 MTU = 6 kbit*/ + ip->pps_limit = ip->max/6; + if(ip->pps_limit > 10000) /* this limit seems to be hardcoded in iptables */ { - network->min += ip->min; - network->desired += ip->max; - if(ip->max > network->max) - { - network->max = ip->max; - } + ip->pps_limit = 0; /* do not apply packet limits */ } + ip->mark = FIRSTIPCLASS+1+class_count++; + update_network(ip->addr, ip); + if_exists(group,groups,(group->min == ip->min)) { group->count++; @@ -300,4 +302,7 @@ void parse_hosts(char *hosts) exit(-1); } done; /* ugly macro end */ +// TheIP("0.0.0.0", TRUE); +// ip->name = "TOTAL"; +// ip->mask = 0; } \ No newline at end of file