-static void add_route(void)
-{
- xbt_ex_t e;
- int nb_link = 0;
- unsigned int cpt = 0;
- int link_list_capacity = 0;
- link_CM02_t *link_list = NULL;
- xbt_dict_cursor_t cursor = NULL;
- char *key,*data, *end;
- const char *sep = "#";
- xbt_dynar_t links, keys;
-
- if (routing_table == NULL) create_routing_table();
-
- 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(link_CM02_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);
- }
- }
- route_new(src_id, dst_id, link_list, nb_link);
- }
-}
-
-static void count_hosts(void)
-{
- host_number++;
-}
-
-
-static void add_traces(void) {
- xbt_dict_cursor_t cursor=NULL;
- char *trace_name,*elm;
-
- static int called = 0;
- if (called) return;
- called = 1;
-
- /* connect all traces relative to network */
- xbt_dict_foreach(trace_connect_list_link_avail, cursor, trace_name, elm) {
- tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
- link_CM02_t link = xbt_dict_get_or_null(link_set, elm);
-
- xbt_assert1(link, "Link %s undefined", elm);
- xbt_assert1(trace, "Trace %s undefined", trace_name);
-
- link->state_event = tmgr_history_add_trace(history, trace, 0.0, 0, link);
- }
-
- xbt_dict_foreach(trace_connect_list_bandwidth, cursor, trace_name, elm) {
- tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
- link_CM02_t link = xbt_dict_get_or_null(link_set, elm);
-
- xbt_assert1(link, "Link %s undefined", elm);
- xbt_assert1(trace, "Trace %s undefined", trace_name);
-
- link->bw_event = tmgr_history_add_trace(history, trace, 0.0, 0, link);
- }
-
- xbt_dict_foreach(trace_connect_list_latency, cursor, trace_name, elm) {
- tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
- link_CM02_t link = xbt_dict_get_or_null(link_set, elm);
-
- xbt_assert1(link, "Link %s undefined", elm);
- xbt_assert1(trace, "Trace %s undefined", trace_name);
-
- link->lat_event = tmgr_history_add_trace(history, trace, 0.0, 0, link);
- }
-}
-
-static void define_callbacks(const char *file)
-{
- /* Figuring out the network links */
- surfxml_add_callback(STag_surfxml_host_cb_list, &count_hosts);
- surfxml_add_callback(STag_surfxml_link_cb_list, &parse_link_init);
- surfxml_add_callback(STag_surfxml_route_cb_list, &parse_route_set_endpoints);
- surfxml_add_callback(ETag_surfxml_route_cb_list, &parse_route_set_route);
- surfxml_add_callback(ETag_surfxml_platform_cb_list, &add_traces);
- surfxml_add_callback(ETag_surfxml_platform_cb_list, &add_route);
- surfxml_add_callback(ETag_surfxml_platform_cb_list, &add_loopback);
-}