+void routing_cluster_add_backbone(void* bb) {
+ xbt_assert(current_routing->model_desc == &routing_models[SURF_MODEL_CLUSTER],
+ "You have to be in model Cluster to use tag backbone!");
+ xbt_assert(!((as_cluster_t)current_routing)->backbone,"The backbone link is already defined!");
+ ((as_cluster_t)current_routing)->backbone = bb;
+ XBT_DEBUG("Add a backbone to AS '%s'",current_routing->name);
+}
+
+static void routing_parse_cabinet(sg_platf_cabinet_cbarg_t cabinet)
+{
+ int start, end, i;
+ char *groups , *host_id , *link_id = NULL;
+ unsigned int iter;
+ xbt_dynar_t radical_elements;
+ xbt_dynar_t radical_ends;
+
+ //Make all hosts
+ radical_elements = xbt_str_split(cabinet->radical, ",");
+ xbt_dynar_foreach(radical_elements, iter, groups) {
+
+ radical_ends = xbt_str_split(groups, "-");
+ start = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 0, char *));
+
+ switch (xbt_dynar_length(radical_ends)) {
+ case 1:
+ end = start;
+ break;
+ case 2:
+ end = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 1, char *));
+ break;
+ default:
+ surf_parse_error("Malformed radical");
+ break;
+ }
+ s_sg_platf_host_cbarg_t host;
+ memset(&host, 0, sizeof(host));
+ host.initial_state = SURF_RESOURCE_ON;
+ host.power_peak = cabinet->power;
+ host.power_scale = 1.0;
+ host.core_amount = 1;
+
+ s_sg_platf_link_cbarg_t link;
+ memset(&link, 0, sizeof(link));
+ link.state = SURF_RESOURCE_ON;
+ link.policy = SURF_LINK_FULLDUPLEX;
+ link.latency = cabinet->lat;
+ link.bandwidth = cabinet->bw;
+
+ s_sg_platf_host_link_cbarg_t host_link;
+ memset(&host_link, 0, sizeof(host_link));
+
+ for (i = start; i <= end; i++) {
+ host_id = bprintf("%s%d%s",cabinet->prefix,i,cabinet->suffix);
+ link_id = bprintf("link_%s%d%s",cabinet->prefix,i,cabinet->suffix);
+ host.id = host_id;
+ link.id = link_id;
+ sg_platf_new_host(&host);
+ sg_platf_new_link(&link);
+
+ char* link_up = bprintf("%s_UP",link_id);
+ char* link_down = bprintf("%s_DOWN",link_id);
+ host_link.id = host_id;
+ host_link.link_up = link_up;
+ host_link.link_down= link_down;
+ sg_platf_new_host_link(&host_link);
+
+ free(host_id);
+ free(link_id);
+ free(link_up);
+ free(link_down);
+ }
+
+ xbt_dynar_free(&radical_ends);
+ }
+ xbt_dynar_free(&radical_elements);
+}
+