extern struct IP *ips, *networks;
-struct IP* find_network_for_ip(char *ipaddr_orig)
+void update_network(char *look_for, struct IP* ip)
{
struct IP *network;
char *netaddr, *lastnum, *ipaddr;
int ipnum, netnum;
- duplicate(ipaddr_orig, ipaddr);
+ duplicate(look_for, ipaddr);
lastnum = strrchr(ipaddr, '.');
if(lastnum)
{
and netnum + (1<<(32-network->mask)) > ipnum
and netnum <= ipnum)
{
- return network;
+ network->group += 1;
+ network->min += ip->min;
+ network->direct += ip->max<<10; /* sum of Mbps, not kbps*/
+
+ if(ip->max > network->max)
+ {
+ network->max = ip->max;
+ }
+
+ if(network->max > network->min)
+ {
+ network->desired = network->max;
+ }
+ else
+ {
+ network->desired = network->min;
+ }
+ return;
}
}
}
- return NULL;
}
void analyse_topology(char *traceroute)
int col, gateway, netnum, tracert;
struct IP *network=NULL, *ip;
- for_each(ip, networks)
- {
- printf("%s/%d %s min=%d max=%d sum=%d\n",ip->addr, ip->mask, ip->name, ip->min, ip->max, ip->desired);
- }
-
/*-----------------------------------------------------------------*/
puts("Analysing network topology ...");
/*-----------------------------------------------------------------*/
}
else if(col==2)
{
+//#ifdef DEBUG
printf("via [%s]\n", ptr);
- network = find_network_for_ip(ptr);
- if(network)
- {
- network->min += ip->min;
- network->desired += ip->max;
- if(ip->max > network->max)
- {
- network->max = ip->max;
- }
- }
+//#endif
+ update_network(ptr, ip);
}
}
}
}
}
sort(network, networks, desc_order_by, min);
- sort(network, networks, desc_order_by, max);
- for_each(ip, networks)
+ sort(network, networks, desc_order_by, desired);
+
+ /*-----------------------------------------------------------------*/
+ puts("Requested network parameters are:");
+ /*-----------------------------------------------------------------*/
+ for_each(ip, networks) if(ip->desired>>10 > 0)
{
- printf("%s/%d %s min=%d max=%d sum=%d\n",ip->addr, ip->mask, ip->name, ip->min, ip->max, ip->desired);
+ printf("%s/%d %s REQUESTED=%dM (classes=%d, sum_min=%dk, max_1=%dk, sum_max=%LuM, agreg.=1:%d)\n",
+ ip->addr, ip->mask, ip->name, ip->desired>>10, ip->group, ip->min, ip->max, ip->direct,
+ (int)((float)(ip->direct)/(ip->desired>>10)));
}
exit(-1);
}
extern const int highest_priority;\r
extern char *ip6prefix;\r
\r
-struct IP* find_network_for_ip(char *ipaddr_orig);\r
+void update_network(char *look_for, struct IP* ip);\r
/* implemented in networks.c */\r
\r
/* This must be object oriented! This looks almost like constructor ;-) */\r
}\r
ip->mark = FIRSTIPCLASS+1+class_count++;\r
\r
- network = find_network_for_ip(ip->addr);\r
- if(network)\r
- {\r
- network->min += ip->min;\r
- network->desired += ip->max;\r
- if(ip->max > network->max)\r
- {\r
- network->max = ip->max;\r
- }\r
- }\r
+ update_network(ip->addr, ip);\r
\r
if_exists(group,groups,(group->min == ip->min)) \r
{ \r