-}
-
-//The following is common to all and has been relocated to surfxml_parse
-/* Parses a route element from the XML: UNMODIFIED BY HC */
-/*static void parse_route_elem(void)
-{
- nb_link++;
- link_name = xbt_realloc(link_name, (nb_link) * sizeof(char *));
- link_name[(nb_link) - 1] = xbt_strdup(A_surfxml_route_element_name);
-}
-*/
-
-/* Create the route (more than one hops): MODIFIED BY KF */
-static void parse_route_set_route(void)
-{
-/* if (nb_link > 1)
- route_new(src_id, dst_id, link_name, nb_link);
-*/
- char *name = bprintf("%x#%x",src_id, dst_id);
- xbt_dict_set(route_table, name, route_link_list, NULL);
- free(name);
-}
-
-//This is not used anymore. one hop routes are created in add_route
-/* Create the one-hope route: BY KF */
-static void parse_route_set_onehop_route(void)
-{
- if (nb_link == 1)
- route_onehop_new(src_id, dst_id, link_name, nb_link);
-}
-
-static void add_route()
-{
- xbt_ex_t e;
- unsigned int cpt = 0;
- int i = 0;
- xbt_dict_cursor_t cursor = NULL;
- char *key,*data, *end;
- const char *sep = "#";
- xbt_dynar_t links, keys;
-
- xbt_dict_foreach(route_table, cursor, key, data) {
- nb_link = 0;
- links = (xbt_dynar_t)data;
- keys = xbt_str_split_str(key, sep);
-
- nb_link = xbt_dynar_length(links);
- link_name = xbt_realloc(link_name, (nb_link) * sizeof(char *));
-
- src_id = strtol(xbt_dynar_get_as(keys, 0, char*), &end, 16);
- dst_id = strtol(xbt_dynar_get_as(keys, 1, char*), &end, 16);
-
- i = 0;
- char* link = NULL;
- xbt_dynar_foreach (links, cpt, link) {
- TRY {
- link_name[i++] = 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_name, nb_link);
- if (nb_link == 1)
- route_onehop_new(src_id, dst_id, link_name, nb_link);
+ else link_new(link->id, link->bandwidth, link->latency, current_property_set);
+ current_property_set = NULL;
+}
+
+/* Create the gtnets topology based on routing strategy */
+static void create_gtnets_topology(void)
+{
+ XBT_DEBUG("Starting topology generation");
+// FIXME: We should take the list of hosts/routers (in the routing module), number the elements of this list,
+// and then you can use the id to reimplement properly the following GTNets calls
+
+ //get the onelinks from the parsed platform
+ xbt_dynar_t onelink_routes = routing_platf->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) {
+ void *link = onelink->link_ptr;
+
+ if(onelink->src->id != onelink->dst->id){
+ XBT_DEBUG("Link (#%p), src (#%s), dst (#%s), src_id = %d, dst_id = %d",
+ link,
+ onelink->src->name,
+ onelink->dst->name,
+ onelink->src->id,
+ onelink->dst->id);
+ XBT_DEBUG("Calling one link route");
+ if(onelink->src->rc_type == SURF_NETWORK_ELEMENT_ROUTER){
+ gtnets_add_router(onelink->src->id);
+ }
+ if(onelink->dst->rc_type == SURF_NETWORK_ELEMENT_ROUTER){
+ gtnets_add_router(onelink->dst->id);
+ }
+ route_onehop_new(onelink->src->id, onelink->dst->id, (network_link_GTNETS_t)(link));
+ }