X-Git-Url: http://git.harvie.cz/?p=svn%2FPrometheus-QoS%2F.git;a=blobdiff_plain;f=parsehosts.c;h=528f376ce38fa5333bb6305d3d15c5db47021451;hp=db3bf2eb52f2003c647518487023cceb98d9d118;hb=f64d54310ae39276c552b80183ae2320789bb4be;hpb=a1204fc9fd3dab261b08e0d1491ec4099a762c5a diff --git a/parsehosts.c b/parsehosts.c index db3bf2e..528f376 100644 --- a/parsehosts.c +++ b/parsehosts.c @@ -15,13 +15,14 @@ extern int ip_count; extern int found_lmsid; extern int free_min; extern const int highest_priority; +extern char *ip6prefix; /* This must be object oriented! This looks almost like constructor ;-) */ -void TheIP(void) +void TheIP(char *ipaddr) { create(ip,IP); ip->name = ""; - ip->addr = ""; + ip->addr = ipaddr; ip->sharing = NULL; ip->prio = highest_priority+1; ip->lmsid = -1; @@ -44,7 +45,22 @@ void TheIP(void) /* == 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) @@ -77,12 +93,28 @@ void parse_ip(char *str) } *ptr=0; + if(ip6range) + { + concatenate(ip6prefix,ip6range,ptr); + concatenate(ptr,"/64",ip6range); + if_exists(ip, ips, eq(ip->addr,ip6range)); + else + { + TheIP(ip6range); + } + ip->name = ptr; + 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) {