1 /* Modified by: xChaos, 20131029 */
3 #include "cll1-0.6.2.h"
8 extern struct IP
*ips
, *networks
;
10 void update_network(char *look_for
, struct IP
* ip
)
13 char *netaddr
, *lastnum
, *ipaddr
;
16 duplicate(look_for
, ipaddr
);
17 lastnum
= strrchr(ipaddr
, '.');
20 ipnum
= atoi(lastnum
+ 1);
24 for_each(network
, networks
)
26 duplicate(network
->addr
, netaddr
);
27 lastnum
= strrchr(netaddr
, '.');
30 netnum
= atoi(lastnum
+ 1);
32 // printf("%s/%d + %d\n",network->addr,network->mask,(1<<(32-network->mask)));
33 if( eq(netaddr
, ipaddr
)
34 and netnum
+ (1<<(32-network
->mask
)) > ipnum
38 network
->min
+= ip
->min
;
39 network
->direct
+= ip
->max
>>10; /* sum of Mbps, not kbps*/
41 if(ip
->max
> network
->max
)
43 network
->max
= ip
->max
;
46 if(network
->max
> network
->min
)
48 network
->desired
= network
->max
>>10;
52 network
->desired
= network
->min
>>10;
60 void analyse_topology(char *traceroute
)
62 char *buf
, *netaddr
, *ptr
, *lastnum
, *str
;
63 int col
, gateway
, netnum
, tracert
;
64 struct IP
*network
=NULL
, *ip
;
66 /*-----------------------------------------------------------------*/
67 puts("Analysing network topology ...");
68 /*-----------------------------------------------------------------*/
69 for_each(ip
, networks
)
71 printf("%s/%d %s\n",ip
->addr
, ip
->mask
, ip
->name
);
72 duplicate(ip
->addr
, buf
);
73 lastnum
= strrchr(buf
, '.');
76 gateway
= atoi(lastnum
+ 1) + 1; /* this is just common rule... */
79 sprintf(str
, traceroute
, buf
, gateway
);
83 if( not strstr(str
, "traceroute")
84 and not strstr(str
, "* * *"))
88 valid_columns(ptr
, buf
, ' ', col
)
96 printf("via [%s]\n", ptr
);
98 update_network(ptr
, ip
);
104 sort(network
, networks
, desc_order_by
, min
);
105 sort(network
, networks
, desc_order_by
, desired
);
107 /*-----------------------------------------------------------------*/
108 puts("Requested network parameters are:");
109 /*-----------------------------------------------------------------*/
110 for_each(ip
, networks
) if(ip
->desired
)
112 printf("%s/%d %s REQUESTED=%dM (classes=%d, sum_min=%dk, max_1=%dk, sum_max=%LuM, agreg.=1:%d)\n",
113 ip
->addr
, ip
->mask
, ip
->name
, ip
->desired
, ip
->group
, ip
->min
, ip
->max
, ip
->direct
,
114 (int)((float)((ip
->direct
)/ip
->desired
)+.5));
This page took 0.334153 seconds and 4 git commands to generate.