1 /* Copyright (c) 2009, 2010, 2011. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #include "surf_routing_private.h"
9 extern routing_global_t global_routing;
10 extern routing_component_t current_routing;
11 extern model_type_t current_routing_model;
12 extern xbt_dynar_t link_list;
13 extern xbt_dict_t cluster_host_link;
15 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_cluster, surf, "Routing part of surf");
17 /* Routing model structure */
20 s_routing_component_t generic_routing;
21 xbt_dict_t dict_processing_units;
22 xbt_dict_t dict_autonomous_systems;
23 } s_routing_component_cluster_t, *routing_component_cluster_t;
25 /* Parse routing model functions */
27 static route_extended_t cluster_get_route(routing_component_t rc,
31 /* Business methods */
32 static route_extended_t cluster_get_route(routing_component_t rc,
38 "Invalid params for \"get_route\" function at AS \"%s\"",
42 xbt_dynar_t links_list =
43 xbt_dynar_new(global_routing->size_of_link, NULL);
45 char *cluster_is_fd = xbt_dict_get_or_null(cluster_host_link,rc->name);
46 char *link_src,*link_bb,*link_dst,*link_src_up,*link_dst_down;
48 if(!cluster_is_fd){ // NOT FULLDUPLEX
49 link_src = xbt_dict_get_or_null(cluster_host_link,src);
50 if( !link_src && (global_routing->get_network_element_type(src) != SURF_NETWORK_ELEMENT_ROUTER) )
51 xbt_die("No link for '%s' found!",src);
52 if(link_src) xbt_dynar_push_as(links_list,void*,xbt_lib_get_or_null(link_lib, link_src, SURF_LINK_LEVEL)); //link_up
54 link_bb = bprintf("%s_backbone",rc->name);
55 xbt_dynar_push_as(links_list,void*,xbt_lib_get_or_null(link_lib, link_bb, SURF_LINK_LEVEL)); //link_bb
58 link_dst = xbt_dict_get_or_null(cluster_host_link,dst);
59 if( !link_dst && (global_routing->get_network_element_type(dst) != SURF_NETWORK_ELEMENT_ROUTER) )
60 xbt_die("No link for '%s' found!",dst);
61 if(link_dst) xbt_dynar_push_as(links_list,void*,xbt_lib_get_or_null(link_lib, link_dst, SURF_LINK_LEVEL)); //link_down
65 link_src = xbt_dict_get_or_null(cluster_host_link,src);
66 if( !link_src && (global_routing->get_network_element_type(src) != SURF_NETWORK_ELEMENT_ROUTER) )
67 xbt_die("No link for '%s' found!",src);
68 link_src_up = bprintf("%s_UP",link_src);
69 if(link_src) xbt_dynar_push_as(links_list,void*,xbt_lib_get_or_null(link_lib, link_src_up, SURF_LINK_LEVEL)); //link_up
72 link_bb = bprintf("%s_backbone",rc->name);
73 if(link_bb) xbt_dynar_push_as(links_list,void*,xbt_lib_get_or_null(link_lib, link_bb, SURF_LINK_LEVEL)); //link_bb
76 link_dst = xbt_dict_get_or_null(cluster_host_link,dst);
77 if(!link_dst && (global_routing->get_network_element_type(dst) != SURF_NETWORK_ELEMENT_ROUTER))
78 xbt_die("No link for '%s' found!",dst);
79 link_dst_down = bprintf("%s_DOWN",link_dst);
80 if(link_dst) xbt_dynar_push_as(links_list,void*,xbt_lib_get_or_null(link_lib, link_dst_down, SURF_LINK_LEVEL)); //link_down
84 route_extended_t new_e_route = NULL;
85 new_e_route = xbt_new0(s_route_extended_t, 1);
86 new_e_route->generic_route.link_list = links_list;
91 /* Creation routing model functions */
92 void *model_cluster_create(void)
94 routing_component_cluster_t new_component = model_rulebased_create();
95 new_component->generic_routing.get_route = cluster_get_route;