X-Git-Url: https://git.harvie.cz/?p=svn%2FPrometheus-QoS%2F.git;a=blobdiff_plain;f=parsehosts.c;h=146e897b8fde295714b575f7a30166ff98038649;hp=1e0c65ceceaf5a6517f94074367b88d1e93d6b36;hb=47b5fd64878b8e1206cbdc7fc2ec65308b0d9e89;hpb=67120c6224470998a5f772a8e1e3ebda3203aade diff --git a/parsehosts.c b/parsehosts.c index 1e0c65c..146e897 100644 --- a/parsehosts.c +++ b/parsehosts.c @@ -25,27 +25,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); @@ -54,9 +57,17 @@ void TheIP(char *ipaddr, int is_network) { push(ip, ips); } +#ifdef MONITORINGTRHU_CTU + ip->technology_str = NULL; + ip->ruian_id_str = NULL; +#endif + ip_count++; } +#ifdef MONITORINGTRHU_CTU +struct Technology *technologies = NULL, *technology = NULL; +#endif struct IP *lastIP6range, *lastIP6uplink; /* == This function strips extra characters after IPv4 address and stores it = */ @@ -248,7 +259,7 @@ void parse_hosts(char *hosts) else { substring = strstr(str, "#255."); - if(substring and not strstr(str, "#255.255.255.255")) /* do not ping /32 uplinks */ + if(substring and not strstr(str, "#255.255.255.255")) /* ignore /32 subnets */ { /* netmask detected - save network*/ unsigned bit; @@ -277,9 +288,45 @@ void parse_hosts(char *hosts) } else { + /* Main branch - most IP addresses go here */ /*Do we have to create new QoS class for this IP ? */ if_exists(keyword,keywords,(substring=strstr(str,keyword->key))) { +#ifdef MONITORINGTRHU_CTU +//special hack only to generate certain required CSV statistics for www.ctu.cz (regulation body) + char *found_at = strchr(str, '@'); + char *ruian_id_str = NULL; + technology = NULL; + if(found_at) + { + int len; + char *found_ruian_end = strchr(found_at, ' '); + char *found_tech_str = found_at; + while(found_tech_str-- > str && *found_tech_str != ' ' && *found_tech_str != '#'); + if(found_tech_str > str) + { + len = found_at - found_tech_str - 1; + for_each(technology, technologies) + if(!strncmp(technology->filename, found_tech_str + 1, len)) + break; + if(!technology) + { + create(technology,Technology); + string(technology->filename, len + 1); + strncpy(technology->filename, found_tech_str + 1, len); + technology->filename[len] = 0; + push(technology, technologies); + } + if(found_ruian_end) + { + len = found_ruian_end - found_at - 1; + string(ruian_id_str, len + 1); + strncpy(ruian_id_str, found_at + 1, len); + ruian_id_str[len] = 0; + } + } + } +#endif parse_and_append_ip(str, ips); if(lastIP6range) { @@ -342,6 +389,15 @@ void parse_hosts(char *hosts) ip->mark = FIRSTIPCLASS+1+class_count++; update_network(ip->addr, ip); +#ifdef MONITORINGTRHU_CTU + if(technology) + { + ip->technology_str = technology->filename; + ip->ruian_id_str = ruian_id_str; + /* debug printf("[%s,%d,%s,%d]\n", ip->technology_str,ip->lmsid, ip->ruian_id_str, ip->max); */ + } +#endif + if_exists(group,groups,(group->min == ip->min)) { group->count++; @@ -364,7 +420,7 @@ void parse_hosts(char *hosts) group->desired = ip->min; insert(group, groups, desc_order_by,min); } - }//endif keyword- + }//endif keyword- }//endif netmask }//endif sharing- } @@ -377,4 +433,4 @@ void parse_hosts(char *hosts) // TheIP("0.0.0.0", TRUE); // ip->name = "TOTAL"; // ip->mask = 0; -} +} \ No newline at end of file