X-Git-Url: http://git.harvie.cz/?p=svn%2FPrometheus-QoS%2F.git;a=blobdiff_plain;f=parsehosts.c;h=1e8dbe6773502e9b18f580570257cba552fe20df;hp=d37a71657236390195709271a7af41ea61dcdee2;hb=c2237b8a65286bff65d5bd81e48cb88fb7d2562e;hpb=0b9c3c198771800cc6c5fbacfc0272549626bcfd diff --git a/parsehosts.c b/parsehosts.c index d37a716..1e8dbe6 100644 --- a/parsehosts.c +++ b/parsehosts.c @@ -41,20 +41,23 @@ void TheIP(char *ipaddr) ip->keyword = keywords; ip->v6 = (strchr(ip->addr,':')!=NULL); push(ip,ips); + ip_count++; } +struct IP *lastIP6; + /* == This function strips extra characters after IPv4 address and stores it = */ -void parse_ip(char *str) +parse_ip(char *str) { char *ptr, *ipaddr, *ip6range = NULL, *ipname = NULL, *lmsid = NULL; - if(ip6prefix) /* Try this only if IPv6 subsystem is active...*/ + if(ip6prefix) /* Try this only if IPv6 subsystem is active... */ { ptr = strstr(str, "::"); if(ptr && ptr-str > 4) { ptr -= 4; - duplicate(ptr,ip6range); + duplicate(ptr, ip6range); ptr = strstr(ip6range, "::"); if(ptr) { @@ -104,11 +107,16 @@ void parse_ip(char *str) TheIP(ip6range); } ip->name = ip6range; - ip->sharing = ipname; + ip->keyword = defaultkeyword; /* settings for default keyword */ if(lmsid) { ip->lmsid = atoi(lmsid); } + lastIP6 = ip; + } + else + { + lastIP6 = NULL; } if_exists(ip, ips, eq(ip->addr,ipaddr)); @@ -147,9 +155,13 @@ void parse_hosts(char *hosts) { substring += 8; /* "sharing-" */ parse_ip(str); - ip_count++; ip->sharing = substring; ip->keyword = defaultkeyword; /* settings for default keyword */ + if(lastIP6) + { + lastIP6->sharing = substring; + lastIP6 = NULL; + } while(*substring and *substring != '\n') { substring++; @@ -163,7 +175,11 @@ void parse_hosts(char *hosts) if_exists(keyword,keywords,(substring=strstr(str,keyword->key))) { parse_ip(str); - ip_count++; + if(lastIP6) + { + lastIP6->sharing = ip->name; + lastIP6 = NULL; + } ip->keyword = keyword; keyword->ip_count++; ip->prio = keyword->default_prio;