static void routing_full_parse_Scluster(void);/*cluster bypass*/
-/* this lines are olny for replace use like index in the model table */
-#define SURF_MODEL_FULL 0
-#define SURF_MODEL_FLOYD 1
-#define SURF_MODEL_DIJKSTRA 2
-#define SURF_MODEL_DIJKSTRACACHE 3
-#define SURF_MODEL_RULEBASED 4
-#define SURF_MODEL_NONE 5
+/* this lines are only for replace use like index in the model table */
+typedef enum {
+ SURF_MODEL_FULL=0,
+ SURF_MODEL_FLOYD,
+ SURF_MODEL_DIJKSTRA,
+ SURF_MODEL_DIJKSTRACACHE,
+ SURF_MODEL_NONE,
+#ifdef HAVE_PCRE_LIB
+ SURF_MODEL_RULEBASED
+#endif
+} e_routing_types;
+
/* must be finish with null and carefull if change de order */
struct s_model_type routing_models[] =
model_dijkstra_create ,model_dijkstra_both_load, model_dijkstra_both_unload, model_dijkstra_both_end },
{"DijkstraCache", "Dijkstra routing data (fast initialization, fast lookup, small memory requirements, shortest path routing only)",
model_dijkstracache_create, model_dijkstra_both_load, model_dijkstra_both_unload, model_dijkstra_both_end },
- {"RuleBased", "Rule-Based routing data (...)",
- model_rulebased_create, model_rulebased_load, model_rulebased_unload, model_rulebased_end },
{"none", "No routing (usable with Constant network only)",
model_none_create, model_none_load, model_none_unload, model_none_end },
+#ifdef HAVE_PCRE_LIB
+ {"RuleBased", "Rule-Based routing data (...)", model_rulebased_create, model_rulebased_load, model_rulebased_unload, model_rulebased_end },
+#endif
{NULL,NULL,NULL,NULL,NULL,NULL}};
/* ************************************************************************** */
/* *************** GENERIC BUSINESS METHODS (declarations) ****************** */
static xbt_dynar_t generic_get_onelink_routes (routing_component_t rc);
-static int generic_is_router (const char *name);
+static int generic_is_router (routing_component_t rc, const char *name);
static route_extended_t generic_get_bypassroute(routing_component_t rc, const char* src, const char* dst);
/* ************************************************************************** */
xbt_dict_cursor_t cursor=NULL;
routing_component_t rc_child;
xbt_dict_foreach(rc->routing_sons, cursor, key, rc_child) {
- xbt_dynar_t onelink_child = recursive_get_onelink_routes (rc_child);//->get_onelink_routes (rc_child);
+ xbt_dynar_t onelink_child = recursive_get_onelink_routes (rc_child);
if (onelink_child){
xbt_dynar_foreach(onelink_child, cpt, link) {
xbt_dynar_push(ret,&link);
static int is_router(const char *name)
{
- xbt_die("global \"is_router\" function not implemented yet");
+ routing_component_t rc=NULL;
+ rc = xbt_dict_get(global_routing->where_network_elements,name);
+ return rc->is_router(rc, name);
}
/**
return ret;
}
-static int full_is_router(const char *name)
+static int full_is_router(routing_component_t rc, const char *name)
{
- xbt_die("\"full_is_router\" function not implemented yet");
+ routing_component_full_t routing = (routing_component_full_t)rc;
+
+ if(SURF_NETWORK_ELEMENT_ROUTER == ( (network_element_t) xbt_dict_get(routing->to_index , name) )->type )
+ return 1;
+ else
+ return 0;
}
static route_extended_t full_get_route(routing_component_t rc, const char* src,const char* dst) {
return ret;
}
-static int floyd_is_router(const char *name)
+static int floyd_is_router(routing_component_t rc, const char *name)
{
- xbt_die("\"floyd_is_router\" function not implemented yet");
+ routing_component_floyd_t routing = (routing_component_floyd_t)rc;
+
+ if(SURF_NETWORK_ELEMENT_ROUTER == ( (network_element_t) xbt_dict_get(routing->to_index , name) )->type )
+ return 1;
+ else
+ return 0;
}
static route_extended_t floyd_get_route(routing_component_t rc, const char* src,const char* dst) {
xbt_die("\"dijkstra_get_onelink_routes\" function not implemented yet");
}
-static int dijkstra_is_router(const char *name)
+static int dijkstra_is_router(routing_component_t rc, const char *name)
{
- xbt_die("\"dijkstra_is_router\" function not implemented yet");
+ routing_component_dijkstra_t routing = (routing_component_dijkstra_t)rc;
+
+ if(SURF_NETWORK_ELEMENT_ROUTER == ( (network_element_t) xbt_dict_get(routing->to_index , name) )->type )
+ return 1;
+ else
+ return 0;
}
static route_extended_t dijkstra_get_route(routing_component_t rc, const char* src,const char* dst) {
}
+#ifdef HAVE_PCRE_LIB
/* ************************************************** */
/* ************** RULE-BASED ROUTING **************** */
xbt_die("\"rulebased_get_onelink_routes\" function not implemented yet");
}
-static int rulebased_is_router(const char *name)
+static int rulebased_is_router(routing_component_t rc, const char *name)
{
- xbt_die("\"rulebased_is_router\" function not implemented yet");
+ //routing_component_rulebased_t routing = (routing_component_rulebased_t)rc;
+
+//PIERRE FIXME
+
+ xbt_die("\"rulebased_is_router\" function not implemented yet");
}
/* Business methods */
static void model_rulebased_end(void) {
}
+#endif /* HAVE_PCRE_LIB */
+
/* ************************************************************************** */
/* ******************************* NO ROUTING ******************************* */
static xbt_dynar_t none_get_onelink_routes(routing_component_t rc){
return NULL;
}
-static int none_is_router(const char *name){
+static int none_is_router(routing_component_t rc, const char *name){
return -1;
}
static route_extended_t none_get_route(routing_component_t rc, const char* src,const char* dst){
xbt_die("\"generic_get_onelink_routes\" not implemented yet");
}
-static int generic_is_router (const char *name)
+static int generic_is_router (routing_component_t rc, const char *name)
{
xbt_die("\"generic_is_router\" not implemented yet");
}
{
case 1:
surf_parse_get_int(&start, xbt_dynar_get_as(radical_ends, 0, char *));
- host_id = bprintf("%s%d%s", cluster_prefix, start, cluster_suffix);
+ host_id = bprintf("%s_%d%s", cluster_prefix, start, cluster_suffix);
#ifndef HAVE_PCRE_LIB
xbt_dynar_push_as(tab_elements_num, int, start);
#endif
DEBUG2("Create hosts and links from %d to %d",start,end);
for (i = start; i <= end; i++)
{
- host_id = bprintf("%s%d%s", cluster_prefix, i, cluster_suffix);
+ host_id = bprintf("%s_%d%s", cluster_prefix, i, cluster_suffix);
#ifndef HAVE_PCRE_LIB
xbt_dynar_push_as(tab_elements_num, int, i);
#endif
}
DEBUG0(" ");
- router_id = bprintf("%srouter%s",cluster_prefix,cluster_suffix);
- link_router = bprintf("%s_link_router",cluster_id);
+ router_id = bprintf("%s_%s_router%s",cluster_prefix,cluster_id,cluster_suffix);
+ link_router = bprintf("%s_link_%s_router",cluster_id,cluster_id);
link_backbone = bprintf("%s_backbone",cluster_id);
- DEBUG1("<router id=\"%s\"\">",router_id);
+ DEBUG1("<router id=\"%s\"/>",router_id);
SURFXML_BUFFER_SET(router_id, router_id);;
SURFXML_START_TAG(router);
SURFXML_END_TAG(router);
new_suffix = bprintf("%s\\.%s",new_suffix,groups);
}
}
- route_src_dst = bprintf("%s(.*)%s",cluster_prefix,new_suffix);
+ route_src_dst = bprintf("%s_(.*)%s",cluster_prefix,new_suffix);
DEBUG0(" ");
DEBUG0("</route>");
SURFXML_END_TAG(route);
#else
- for(i=0 ; i<=tab_elements_num->elmsize ; i++)
+ for(i=0 ; i<=xbt_dynar_length(tab_elements_num) ; i++)
{
- for(j=0 ; j<=tab_elements_num->elmsize ; j++)
+ for(j=0 ; j<=xbt_dynar_length(tab_elements_num) ; j++)
{
- route_src = bprintf("%s%d%s",cluster_prefix,xbt_dynar_get_as(tab_elements_num,i,int),cluster_suffix);
- route_dst = bprintf("%s%d%s",cluster_prefix,xbt_dynar_get_as(tab_elements_num,j,int),cluster_suffix);
+ if(i == xbt_dynar_length(tab_elements_num))
+ {
+ route_src = router_id;
+ }
+ else
+ {
+ route_src = bprintf("%s_%d%s",cluster_prefix,xbt_dynar_get_as(tab_elements_num,i,int),cluster_suffix);
+ }
+
+ if(j == xbt_dynar_length(tab_elements_num))
+ {
+ route_dst = router_id;
+ }
+ else
+ {
+ route_dst = bprintf("%s_%d%s",cluster_prefix,xbt_dynar_get_as(tab_elements_num,j,int),cluster_suffix);
+ }
DEBUG2("<route\tsrc=\"%s\"\tdst=\"%s\">",route_src,route_dst);
SURFXML_BUFFER_SET(route_src, route_src);
SURFXML_BUFFER_SET(route_dst, route_dst);
SURFXML_START_TAG(route);
- route_src = bprintf("%s_link_%d",cluster_id,xbt_dynar_get_as(tab_elements_num,i,int));
- route_dst = bprintf("%s_link_%d",cluster_id,xbt_dynar_get_as(tab_elements_num,j,int));
-
- DEBUG2("<link:ctn\tid=\"%s_link_%d\"/>",cluster_id,xbt_dynar_get_as(tab_elements_num,i,int));
- SURFXML_BUFFER_SET(link_ctn_id, bprintf("%s_link_%d",cluster_id,xbt_dynar_get_as(tab_elements_num,i,int)));
+ if(i == xbt_dynar_length(tab_elements_num))
+ {
+ route_src = link_router;
+ }
+ else
+ {
+ route_src = bprintf("%s_link_%d",cluster_id,xbt_dynar_get_as(tab_elements_num,i,int));
+ }
+
+ if(j == xbt_dynar_length(tab_elements_num))
+ {
+ route_dst = link_router;
+ }
+ else
+ {
+ route_dst = bprintf("%s_link_%d",cluster_id,xbt_dynar_get_as(tab_elements_num,j,int));
+ }
+
+ DEBUG1("<link:ctn\tid=\"%s\"/>",route_src);
+ SURFXML_BUFFER_SET(link_ctn_id, route_src);
SURFXML_START_TAG(link_ctn);
SURFXML_END_TAG(link_ctn);
SURFXML_START_TAG(link_ctn);
SURFXML_END_TAG(link_ctn);
- DEBUG2("<link:ctn\tid=\"%s_link_%d\"/>",cluster_id,xbt_dynar_get_as(tab_elements_num,j,int));
- SURFXML_BUFFER_SET(link_ctn_id, bprintf("%s_link_%d",cluster_id,xbt_dynar_get_as(tab_elements_num,j,int)));
+ DEBUG1("<link:ctn\tid=\"%s\"/>",route_dst);
+ SURFXML_BUFFER_SET(link_ctn_id, route_dst);
SURFXML_START_TAG(link_ctn);
SURFXML_END_TAG(link_ctn);