}
fprintf(stderr,"Routing model %s not found. Existing models:\n",wanted);
for (cpt=0;models[cpt].name;cpt++)
- if (!strcmp(wanted,models[cpt].name))
- fprintf(stderr," %s: %s\n",models[cpt].name,models[cpt].desc);
- exit(1);
+ fprintf(stderr," %s: %s\n",models[cpt].name,models[cpt].desc);
+ xbt_die("Invalid model.");
}
/* ************************************************************************** */
#define ROUTE_FULL(i,j) ((routing_full_t)used_routing)->routing_table[(i)+(j)*(used_routing)->host_count]
#define HOST2ROUTER(id) ((id)+(2<<29))
-#define ROUTER2HOST(id) ((id)-(2>>29))
+#define ROUTER2HOST(id) ((id)-(2<<29))
#define ISROUTER(id) ((id)>=(2<<29))
/*
*val = HOST2ROUTER(used_routing->router_count++);
xbt_dict_set(used_routing->host_id,A_surfxml_router_id,val,xbt_free);
#ifdef HAVE_TRACING
- TRACE_surf_host_define_id (A_surfxml_host_id, *val);
- TRACE_surf_host_declaration (A_surfxml_host_id, 0);
+ TRACE_surf_host_define_id (A_surfxml_router_id, *val);
+ TRACE_surf_host_declaration (A_surfxml_router_id, 0);
#endif
}
static void routing_model_none_create(size_t size_of_link,void *loopback) {
routing_t routing = xbt_new0(s_routing_t,1);
- INFO0("Null routing");
routing->name = "none";
routing->host_count = 0;
routing->host_id = xbt_dict_new();
/* Set it in position */
used_routing = (routing_t) routing;
}
+
+/*****************************************************************/
+/******************* BYBASS THE PARSER ***************************/
+
+/*
+ * FIXME : better to add to the routing model instead !!
+ *
+ */
+void routing_add_route(char *source_id,char *destination_id,xbt_dynar_t links_id,int action)
+{
+ char * link_id;
+ char * name;
+ unsigned int i;
+ src_id = *(int*)xbt_dict_get(used_routing->host_id,source_id);
+ dst_id = *(int*)xbt_dict_get(used_routing->host_id,destination_id);
+ DEBUG4("Route %s %d -> %s %d",source_id,src_id,destination_id,dst_id);
+ //set Links
+ xbt_dynar_foreach(links_id,i,link_id)
+ {
+ surf_add_route_element(link_id);
+ }
+ route_action = action;
+ 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);
+ }
+
+}
+
+void routing_add_host(char* host_id)
+{
+ int *val = xbt_malloc(sizeof(int));
+ DEBUG2("Seen host %s (#%d)",host_id,used_routing->host_count);
+ *val = used_routing->host_count++;
+ xbt_dict_set(used_routing->host_id,host_id,val,xbt_free);
+}
+
+void routing_set_routes()
+{
+ routing_full_parse_end();
+}