typedef struct s_as {
xbt_dict_t to_index; /* char* -> network_element_t */
xbt_dict_t bypassRoutes; /* store bypass routes */
- routing_model_description_t routing;
+ routing_model_description_t model_desc;
e_surf_routing_hierarchy_t hierarchy;
char *name;
struct s_as *routing_father;
*/
void routing_AS_begin(const char *AS_id, const char *wanted_routing_type)
{
- AS_t new_routing;
+ AS_t new_as;
routing_model_description_t model = NULL;
int cpt;
}
/* make a new routing component */
- new_routing = (AS_t) (*(model->create)) ();
- new_routing->routing = model;
- new_routing->hierarchy = SURF_ROUTING_NULL;
- new_routing->name = xbt_strdup(AS_id);
- new_routing->routing_sons = xbt_dict_new();
+ new_as = (AS_t) (*(model->create)) ();
+ new_as->model_desc = model;
+ new_as->hierarchy = SURF_ROUTING_NULL;
+ new_as->name = xbt_strdup(AS_id);
if (current_routing == NULL && global_routing->root == NULL) {
/* it is the first one */
- new_routing->routing_father = NULL;
- global_routing->root = new_routing;
+ new_as->routing_father = NULL;
+ global_routing->root = new_as;
} else if (current_routing != NULL && global_routing->root != NULL) {
(current_routing->routing_sons, AS_id),
"The AS \"%s\" already exists", AS_id);
/* it is a part of the tree */
- new_routing->routing_father = current_routing;
+ new_as->routing_father = current_routing;
/* set the father behavior */
if (current_routing->hierarchy == SURF_ROUTING_NULL)
current_routing->hierarchy = SURF_ROUTING_RECURSIVE;
/* add to the sons dictionary */
xbt_dict_set(current_routing->routing_sons, AS_id,
- (void *) new_routing, NULL);
+ (void *) new_as, NULL);
/* add to the father element list */
(*(current_routing->parse_AS)) (current_routing, AS_id);
} else {
THROWF(arg_error, 0, "All defined components must be belong to a AS");
}
/* set the new current component of the tree */
- current_routing = new_routing;
+ current_routing = new_as;
}
/**
xbt_lib_set(as_router_lib, current_routing->name, ROUTING_ASR_LEVEL,
(void *) info);
- if (current_routing->routing->end)
- (*(current_routing->routing->end)) (current_routing);
+ if (current_routing->model_desc->end)
+ (*(current_routing->model_desc->end)) (current_routing);
current_routing = current_routing->routing_father;
}
}
sg_platf_new_link(&link);
- surf_parsing_link_up_down_t info =
- xbt_new0(s_surf_parsing_link_up_down_t, 1);
- info->link_up =
- xbt_lib_get_or_null(link_lib, link_backbone, SURF_LINK_LEVEL);
- info->link_down = info->link_up;
- surf_routing_cluster_add_link(struct_cluster->id, info);
+ surf_routing_cluster_add_backbone(current_routing, xbt_lib_get_or_null(link_lib, link_backbone, SURF_LINK_LEVEL));
free(link_backbone);
}
char *key;
AS_t elem;
- xbt_dict_foreach(as->routing_sons, cursor, key, elem)
- finalize_rec(elem);
+ xbt_dict_foreach(as->routing_sons, cursor, key, elem) {
+ finalize_rec(elem);
+ }
- xbt_dict_free(&as->routing_sons);
- xbt_free(as->name);
as->finalize(as);
}
* Note that a router is created, easing the interconnexion with the rest of the world.
*/
+typedef struct {
+ s_as_t generic_routing;
+ void *backbone;
+} s_as_cluster_t, *as_cluster_t;
+
+
static xbt_dict_t cluster_host_link = NULL;
/* Business methods */
info = xbt_dict_get_or_null(cluster_host_link,src);
if(info) xbt_dynar_push_as(links_list,void*,info->link_up); //link_up
- info = xbt_dict_get_or_null(cluster_host_link,as->name);
- if(info) xbt_dynar_push_as(links_list,void*,info->link_up); //link_bb
+ if ( ((as_cluster_t)as)->backbone )
+ xbt_dynar_push_as(links_list,void*, ((as_cluster_t)as)->backbone) ;
info = xbt_dict_get_or_null(cluster_host_link,dst);
if(info) xbt_dynar_push_as(links_list,void*,info->link_down); //link_down
return new_e_route;
}
+static void model_cluster_finalize(AS_t as) {
+ xbt_dict_free(&cluster_host_link);
+ model_none_finalize(as);
+}
/* Creation routing model functions */
AS_t model_cluster_create(void)
{
- AS_t result = model_none_create();
+ AS_t result = model_none_create_sized(sizeof(s_as_cluster_t));
result->get_route = cluster_get_route;
+ result->finalize = model_cluster_finalize;
return (AS_t) result;
}
xbt_dict_set(cluster_host_link,host_id,info,xbt_free);
}
+
+void surf_routing_cluster_add_backbone(AS_t as, void* bb) {
+ ((as_cluster_t)as)->backbone = bb;
+}
{
as_dijkstra_t as = (as_dijkstra_t) asg;
- if (as) {
- xbt_graph_free_graph(as->route_graph, &xbt_free,
- &graph_edge_data_free, &xbt_free);
- xbt_dict_free(&as->graph_node_map);
- if (as->cached)
- xbt_dict_free(&as->route_cache);
- /* Delete bypass dict */
- xbt_dict_free(&as->generic_routing.bypassRoutes);
- /* Delete index dict */
- xbt_dict_free(&(as->generic_routing.to_index));
- /* Delete structure */
- xbt_free(as);
- }
+ xbt_graph_free_graph(as->route_graph, &xbt_free,
+ &graph_edge_data_free, &xbt_free);
+ xbt_dict_free(&as->graph_node_map);
+ if (as->cached)
+ xbt_dict_free(&as->route_cache);
+
+ model_generic_finalize(asg);
}
/* Creation routing model functions */
AS_t model_dijkstra_both_create(int cached)
{
as_dijkstra_t new_component = (as_dijkstra_t)
- routmod_generic_create(sizeof(s_as_dijkstra_t));
+ model_generic_create_sized(sizeof(s_as_dijkstra_t));
new_component->generic_routing.parse_route = model_dijkstra_both_parse_route;
new_component->generic_routing.parse_ASroute = model_dijkstra_both_parse_route;
AS_t model_floyd_create(void)
{
- as_floyd_t new_component = (as_floyd_t)routmod_generic_create(sizeof(s_as_floyd_t));
+ as_floyd_t new_component = (as_floyd_t)model_generic_create_sized(sizeof(s_as_floyd_t));
new_component->generic_routing.parse_route = model_floyd_parse_route;
new_component->generic_routing.parse_ASroute = model_floyd_parse_route;
new_component->generic_routing.get_route = floyd_get_route;
for (j = 0; j < table_size; j++)
generic_free_extended_route(TO_ROUTE_FULL(i, j));
xbt_free(routing->routing_table);
- /* Delete bypass dict */
- xbt_dict_free(&rc->bypassRoutes);
- /* Delete index dict */
- xbt_dict_free(&rc->to_index);
- /* Delete structure */
- xbt_free(rc);
+ model_generic_finalize(rc);
}
}
AS_t model_full_create(void)
{
routing_component_full_t new_component = (routing_component_full_t)
- routmod_generic_create(sizeof(s_routing_component_full_t));
+ model_generic_create_sized(sizeof(s_routing_component_full_t));
new_component->generic_routing.parse_route = model_full_set_route;
new_component->generic_routing.parse_ASroute = model_full_set_route;
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_routing_generic, surf_route, "Generic implementation of the surf routing");
-AS_t routmod_generic_create(size_t childsize) {
- AS_t new_component = xbt_malloc0(childsize);
+AS_t model_generic_create_sized(size_t childsize) {
+ AS_t new_component = model_none_create_sized(childsize);
new_component->parse_PU = generic_parse_PU;
new_component->parse_AS = generic_parse_AS;
new_component->get_onelink_routes = NULL;
new_component->get_bypass_route =
generic_get_bypassroute;
- new_component->finalize = NULL;
+ new_component->finalize = model_generic_finalize;
+
new_component->to_index = xbt_dict_new();
new_component->bypassRoutes = xbt_dict_new();
return new_component;
}
-
+void model_generic_finalize(AS_t as) {
+ xbt_dict_free(&as->to_index);
+ xbt_dict_free(&as->bypassRoutes);
+ model_none_finalize(as);
+}
void generic_parse_PU(AS_t as, const char *name)
{
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_none, surf, "Routing part of surf");
-/* Routing model structure */
-/* Business methods */
-static xbt_dynar_t none_get_onelink_routes(AS_t rc)
-{
+static xbt_dynar_t none_get_onelink_routes(AS_t rc) {
return NULL;
}
static route_extended_t none_get_bypass_route(AS_t rc,
const char *src,
- const char *dst)
-{
+ const char *dst) {
return NULL;
}
-static void none_finalize(AS_t rc)
-{
- xbt_free(rc);
+static void none_parse_PU(AS_t rc, const char *name) {
+ /* don't care about PUs */
}
-static void none_parse_PU(AS_t rc,
- const char *name)
-{
-}
-
-static void none_parse_AS(AS_t rc,
- const char *name)
-{
+static void none_parse_AS(AS_t rc, const char *name) {
+ /* even don't care about sub-ASes */
}
/* Creation routing model functions */
-AS_t model_none_create(void)
-{
- AS_t new_component = xbt_new(s_as_t, 1);
+AS_t model_none_create() {
+ return model_none_create_sized(sizeof(s_as_t));
+}
+AS_t model_none_create_sized(size_t childsize) {
+ AS_t new_component = xbt_malloc0(childsize);
new_component->parse_PU = none_parse_PU;
new_component->parse_AS = none_parse_AS;
new_component->parse_route = NULL;
new_component->get_route = none_get_route;
new_component->get_onelink_routes = none_get_onelink_routes;
new_component->get_bypass_route = none_get_bypass_route;
- new_component->finalize = none_finalize;
+ new_component->finalize = model_none_finalize;
+
+ new_component->routing_sons = xbt_dict_new();
+
return new_component;
}
+void model_none_finalize(AS_t as) {
+ xbt_dict_free(&as->routing_sons);
+ xbt_free(as->name);
+ xbt_free(as);
+}
+
-/*
- * surf_routing_private.h
- *
- * Created on: 14 avr. 2011
- * Author: navarrop
- */
+/* Copyright (c) 2009, 2010, 2011. The SimGrid Team.
+ * All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
#ifndef _SURF_SURF_ROUTING_PRIVATE_H
#define _SURF_SURF_ROUTING_PRIVATE_H
#include "xbt/set.h"
#include "surf/surfxml_parse.h"
+/* ************************************************************************** */
+/* ******************************* NO ROUTING ******************************* */
+/* Only save the AS tree, and forward calls to child ASes */
+AS_t model_none_create(void);
+AS_t model_none_create_sized(size_t childsize);
+void model_none_finalize(AS_t as);
/* ************************************************************************** */
/* ***************** GENERIC PARSE FUNCTIONS (declarations) ***************** */
-AS_t routmod_generic_create(size_t childsize);
+AS_t model_generic_create_sized(size_t childsize);
+void model_generic_finalize(AS_t as);
-void generic_parse_PU(AS_t rc,
- const char *name);
-void generic_parse_AS(AS_t rc,
- const char *name);
-void generic_parse_bypassroute(AS_t rc,
- const char *src, const char *dst,
- route_extended_t e_route);
+void generic_parse_PU(AS_t rc, const char *name);
+void generic_parse_AS(AS_t rc, const char *name);
+void generic_parse_bypassroute(AS_t rc, const char *src, const char *dst,
+ route_extended_t e_route);
/* ************************************************************************** */
/* *************** GENERIC BUSINESS METHODS (declarations) ****************** */
/* ************** Cluster ROUTING **************** */
AS_t model_cluster_create(void); /* create structures for cluster routing model */
+/* Pass info from the cluster parser to the cluster routing */
void surf_routing_cluster_add_link(const char* host_id,surf_parsing_link_up_down_t info);
+void surf_routing_cluster_add_backbone(AS_t as, void* bb);
/* ************************************************** */
/* ************** Vivaldi ROUTING **************** */
void model_full_set_route( /* Set the route and ASroute between src and dst */
AS_t rc, const char *src, const char *dst, route_extended_t route);
-/* ************************************************************************** */
-/* ******************************* NO ROUTING ******************************* */
-AS_t model_none_create(void); /* none routing model */
#endif /* _SURF_SURF_ROUTING_PRIVATE_H */
const char *error;
int erroffset;
- if(!strcmp(rc->routing->name,"Vivaldi")){
+ if(!strcmp(rc->model_desc->name,"Vivaldi")){
if(xbt_dynar_length(route->generic_route.link_list) != 0)
xbt_die("You can't have link_ctn with Model Vivaldi.");
}
const char *error;
int erroffset;
- if(!strcmp(rc->routing->name,"Vivaldi")){
+ if(!strcmp(rc->model_desc->name,"Vivaldi")){
if(xbt_dynar_length(route->generic_route.link_list) != 0)
xbt_die("You can't have link_ctn with Model Vivaldi.");
}
AS_t model_rulebased_create(void) {
routing_component_rulebased_t new_component = (routing_component_rulebased_t)
- routmod_generic_create(sizeof(s_routing_component_rulebased_t));
+ model_generic_create_sized(sizeof(s_routing_component_rulebased_t));
new_component->generic_routing.parse_PU = model_rulebased_parse_PU;
new_component->generic_routing.parse_AS = model_rulebased_parse_AS;