Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
merge changes. Strange, it seems to ate pierre commit
[simgrid.git] / src / surf / surf_routing_cluster.c
1 /* Copyright (c) 2009, 2010, 2011. The SimGrid Team.
2  * All rights reserved.                                                     */
3
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"
7
8 /* Global vars */
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;
14
15 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_cluster, surf, "Routing part of surf");
16
17 /* Routing model structure */
18
19 typedef struct {
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;
24
25 /* Parse routing model functions */
26
27 static route_extended_t cluster_get_route(routing_component_t rc,
28                                             const char *src,
29                                             const char *dst);
30
31 /* Business methods */
32 static route_extended_t cluster_get_route(routing_component_t rc,
33                                             const char *src,
34                                             const char *dst)
35 {
36           xbt_assert(rc && src
37                       && dst,
38                       "Invalid params for \"get_route\" function at AS \"%s\"",
39                       rc->name);
40
41
42           xbt_dynar_t links_list = xbt_dynar_new(global_routing->size_of_link, NULL);
43
44           char *link_src,*link_bb,*link_dst,*link_src_up,*link_dst_down;
45           surf_parsing_link_up_down_t info;
46
47           info = xbt_dict_get_or_null(cluster_host_link,src);
48           if(info) xbt_dynar_push_as(links_list,void*,info->link_up); //link_up
49
50           info = xbt_dict_get_or_null(cluster_host_link,rc->name);
51           if(info)  xbt_dynar_push_as(links_list,void*,info->link_up); //link_bb
52
53           info = xbt_dict_get_or_null(cluster_host_link,dst);
54           if(info) xbt_dynar_push_as(links_list,void*,info->link_down); //link_down
55
56           route_extended_t new_e_route = NULL;
57           new_e_route = xbt_new0(s_route_extended_t, 1);
58           new_e_route->generic_route.link_list = links_list;
59
60           return new_e_route;
61 }
62
63 /* Creation routing model functions */
64 void *model_cluster_create(void)
65 {
66   routing_component_cluster_t new_component = model_rulebased_create();
67   new_component->generic_routing.get_route = cluster_get_route;
68
69   return new_component;
70 }