X-Git-Url: https://git.harvie.cz/?a=blobdiff_plain;f=parsehosts.c;h=d37a71657236390195709271a7af41ea61dcdee2;hb=d7357b63c9942c72481993bdb9632861c1d83a55;hp=2740c1c8c08d29936dcef4301abaa0572f85788b;hpb=1c9cae56507516acf3eda8fcfe60a74bfe923ee4;p=svn%2FPrometheus-QoS%2F.git diff --git a/parsehosts.c b/parsehosts.c index 2740c1c..d37a716 100644 --- a/parsehosts.c +++ b/parsehosts.c @@ -14,14 +14,54 @@ extern int class_count; extern int ip_count; extern int found_lmsid; extern int free_min; +extern const int highest_priority; +extern char *ip6prefix; -/* function implemented in prometheus.c */ -void TheIP(void); +/* This must be object oriented! This looks almost like constructor ;-) */ +void TheIP(char *ipaddr) +{ + create(ip,IP); + ip->name = ""; + ip->addr = ipaddr; + ip->sharing = NULL; + ip->prio = highest_priority+1; + ip->lmsid = -1; + ip->fixedprio = \ + ip->mark = \ + ip->min = \ + ip->max = \ + ip->desired = \ + ip->credit = \ + ip->upload = \ + ip->proxy = \ + ip->direct = \ + ip->traffic = \ + ip->pktsup = \ + ip->pktsdown = 0; + ip->keyword = keywords; + ip->v6 = (strchr(ip->addr,':')!=NULL); + push(ip,ips); +} /* == This function strips extra characters after IPv4 address and stores it = */ void parse_ip(char *str) { - char *ptr, *ipaddr = NULL, *ipname = NULL, *lmsid = NULL; + char *ptr, *ipaddr, *ip6range = NULL, *ipname = NULL, *lmsid = NULL; + + if(ip6prefix) /* Try this only if IPv6 subsystem is active...*/ + { + ptr = strstr(str, "::"); + if(ptr && ptr-str > 4) + { + ptr -= 4; + duplicate(ptr,ip6range); + ptr = strstr(ip6range, "::"); + if(ptr) + { + *(ptr+2) = 0; + } + } + } ptr = strchr(str, '{'); if(ptr) @@ -54,12 +94,28 @@ void parse_ip(char *str) } *ptr=0; + if(ip6range) + { + concatenate(ip6prefix,ip6range,ptr); + ip6range=ptr; + if_exists(ip, ips, eq(ip->addr,ip6range)); + else + { + TheIP(ip6range); + } + ip->name = ip6range; + ip->sharing = ipname; + if(lmsid) + { + ip->lmsid = atoi(lmsid); + } + } + if_exists(ip, ips, eq(ip->addr,ipaddr)); else { - TheIP(); + TheIP(ipaddr); } - ip->addr = ipaddr; ip->name = ipname; if(lmsid) {