X-Git-Url: http://git.harvie.cz/?p=svn%2FPrometheus-QoS%2F.git;a=blobdiff_plain;f=parsehosts.c;h=8c9eca159c6d1b3304f8e45342c1c04d2eeaced9;hp=1e0c65ceceaf5a6517f94074367b88d1e93d6b36;hb=dba7666bdacf8846560e5414b6c9535434e98f8b;hpb=67120c6224470998a5f772a8e1e3ebda3203aade diff --git a/parsehosts.c b/parsehosts.c index 1e0c65c..8c9eca1 100644 --- a/parsehosts.c +++ b/parsehosts.c @@ -11,7 +11,9 @@ extern struct IP *ips, *ip, *sharedip, *networks; extern struct Group *groups, *group; extern struct Keyword *keyword, *defaultkeyword, *keywords; extern struct Macro *macro, *macros; +extern struct Textfile *previous_classmap, *textline; extern int class_count; +extern int mix_new_hosts; extern int ip_count; extern int found_lmsid; extern int free_min; @@ -25,27 +27,30 @@ void update_network(char *look_for, struct IP* ip); void TheIP(char *ipaddr, int is_network) { 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->pps_limit = \ - ip->pktsdown = 0; - ip->keyword = keywords; - ip->v6 = (strchr(ip->addr,':')!=NULL); - ip->mask = ((ip->v6)?64:32); + ip->name = ""; + ip->addr = ipaddr; + ip->sharing = NULL; + ip->prio = highest_priority+1; + ip->lmsid = -1; + ip->fixedprio = \ + ip->aggregated = \ + ip->mark = \ + ip->min = \ + ip->max = \ + ip->desired = \ + ip->credit = \ + ip->upload = \ + ip->proxy = \ + ip->direct = \ + ip->traffic = \ + ip->traffic_down = \ + ip->traffic_up = \ + ip->pktsup = \ + ip->pps_limit = \ + ip->pktsdown = 0; + ip->keyword = keywords; + ip->v6 = (strchr(ip->addr,':')!=NULL); + ip->mask = ((ip->v6)?64:32); if(is_network) { push(ip, networks); @@ -339,7 +344,23 @@ void parse_hosts(char *hosts) } } - ip->mark = FIRSTIPCLASS+1+class_count++; + if(mix_new_hosts) + for_each(textline, previous_classmap) + { + ptr = strchr(textline->str, ' '); + if(ptr) + { + if(!strncmp(ip->addr, textline->str, ptr-textline->str)) + { + ip->mark = atoi(ptr+1); + printf("Match class: %s %d\n", ip->addr, ip->mark); + } + } + } + + if(!mix_new_hosts || !ip->mark) + ip->mark = FIRSTIPCLASS+1+class_count++; + update_network(ip->addr, ip); if_exists(group,groups,(group->min == ip->min))