- char *name;
- if (src_id != -1 && dst_id != -1) {
- name = bprintf("%x#%x", src_id, dst_id);
- manage_route(route_table, name, route_action, 0);
- free(name);
- }
-}
-
-static void add_route()
-{
- xbt_ex_t e;
- unsigned int cpt = 0;
- int link_list_capacity = 0;
- int nb_link = 0;
- xbt_dict_cursor_t cursor = NULL;
- char *key, *data, *end;
- const char *sep = "#";
- xbt_dynar_t links, keys;
- static network_link_GTNETS_t *link_list = NULL;
-
-
- XBT_IN;
- xbt_dict_foreach(route_table, cursor, key, data) {
- char *link = NULL;
- nb_link = 0;
- links = (xbt_dynar_t) data;
- keys = xbt_str_split_str(key, sep);
-
- link_list_capacity = xbt_dynar_length(links);
- link_list = xbt_new(network_link_GTNETS_t, link_list_capacity);
-
- src_id = strtol(xbt_dynar_get_as(keys, 0, char *), &end, 16);
- dst_id = strtol(xbt_dynar_get_as(keys, 1, char *), &end, 16);
- xbt_dynar_free(&keys);
-
- xbt_dynar_foreach(links, cpt, link) {
- TRY {
- link_list[nb_link++] = xbt_dict_get(link_set, link);
- }
- CATCH(e) {
- RETHROW1("Link %s not found (dict raised this exception: %s)", link);
- }
- }
- if (nb_link == 1)
- route_onehop_new(src_id, dst_id, link_list, nb_link);
- }
-
- xbt_dict_foreach(route_table, cursor, key, data) {
- char *link = NULL;
- nb_link = 0;
- links = (xbt_dynar_t) data;
- keys = xbt_str_split_str(key, sep);
-
- link_list_capacity = xbt_dynar_length(links);
- link_list = xbt_new(network_link_GTNETS_t, link_list_capacity);
-
- src_id = strtol(xbt_dynar_get_as(keys, 0, char *), &end, 16);
- dst_id = strtol(xbt_dynar_get_as(keys, 1, char *), &end, 16);
- xbt_dynar_free(&keys);
-
- xbt_dynar_foreach(links, cpt, link) {
- TRY {
- link_list[nb_link++] = xbt_dict_get(link_set, link);
- }
- CATCH(e) {
- RETHROW1("Link %s not found (dict raised this exception: %s)", link);
- }
- }
- if (nb_link >= 1)
- route_new(src_id, dst_id, link_list, nb_link);
- }
-
- xbt_dict_free(&route_table);
- gtnets_print_topology();
- XBT_OUT;
+ int src_id,dst_id;
+
+ XBT_DEBUG("Starting topology generation");
+// À refaire plus tard. Il faut prendre la liste des hôtes/routeurs (dans routing)
+// À partir de cette liste, on les numérote.
+// Ensuite, on peut utiliser les id pour refaire les appels GTNets qui suivent.
+
+ //get the onelinks from the parsed platform
+ xbt_dynar_t onelink_routes = global_routing->get_onelink_routes();
+ if (!onelink_routes)
+ return;
+
+ //save them in trace file
+ onelink_t onelink;
+ unsigned int iter;
+ xbt_dynar_foreach(onelink_routes, iter, onelink) {
+ char *src = onelink->src;
+ char *dst = onelink->dst;
+ void *link = onelink->link_ptr;
+ src_id = *((int *) xbt_dict_get_or_null(global_routing->root->to_index,src));
+ dst_id = *((int *) xbt_dict_get_or_null(global_routing->root->to_index,dst));
+
+ if(src_id != dst_id){
+ XBT_DEBUG("Link (#%p), src (#%s), dst (#%s), src_id = %d, dst_id = %d", link,src,dst, src_id, dst_id);
+ XBT_DEBUG("Calling one link route");
+ if(global_routing->get_network_element_type(src) == SURF_NETWORK_ELEMENT_ROUTER){
+ gtnets_add_router(src_id);
+ }
+ if(global_routing->get_network_element_type(dst) == SURF_NETWORK_ELEMENT_ROUTER){
+ gtnets_add_router(dst_id);
+ }
+ route_onehop_new(src_id, dst_id, (network_link_GTNETS_t)(link));
+ }
+ }
+
+ if (XBT_LOG_ISENABLED(surf_network_gtnets, xbt_log_priority_debug)) {
+ gtnets_print_topology();
+ }