-#define BUFFER_SIZE 4096 /* result buffer size */
-#define OVECCOUNT 30 /* should be a multiple of 3 */
-
-static route_extended_t cluster_get_route(routing_component_t rc,
- const char *src,
- const char *dst);
-static xbt_dynar_t cluster_get_onelink_routes(routing_component_t rc)
-{
- xbt_dynar_t ret = xbt_dynar_new (sizeof(onelink_t), xbt_free);
-
- //We have already bypass cluster routes with network NS3
- if(!strcmp(surf_network_model->name,"network NS3"))
- return ret;
-
- routing_component_cluster_t routing = (routing_component_cluster_t)rc;
-
- xbt_dict_cursor_t c1 = NULL;
- char *k1, *d1;
-
- //find router
- char *router = NULL;
- xbt_dict_foreach(routing->dict_processing_units, c1, k1, d1) {
- if (rc->get_network_element_type(k1) == SURF_NETWORK_ELEMENT_ROUTER){
- router = k1;
- }
- }
-
- if (!router){
- xbt_die ("cluster_get_onelink_routes works only if the AS is a cluster, sorry.");
- }
-
- xbt_dict_foreach(routing->dict_processing_units, c1, k1, d1) {
- route_extended_t route = cluster_get_route (rc, router, k1);
-
- int number_of_links = xbt_dynar_length(route->generic_route.link_list);
-
- if(number_of_links == 1) {
- //loopback
- }
- else{
- if (number_of_links != 2) {
- xbt_die ("cluster_get_onelink_routes works only if the AS is a cluster, sorry.");
- }
-
- void *link_ptr;
- xbt_dynar_get_cpy (route->generic_route.link_list, 1, &link_ptr);
- onelink_t onelink = xbt_new0 (s_onelink_t, 1);
- onelink->src = xbt_strdup (k1);
- onelink->dst = xbt_strdup (router);
- onelink->link_ptr = link_ptr;
- xbt_dynar_push (ret, &onelink);
- }
- }
- return ret;
-}
-
-/* Business methods */
-static route_extended_t cluster_get_route(routing_component_t rc,
- const char *src,
- const char *dst)
-{
- xbt_assert(rc && src
- && dst,
- "Invalid params for \"get_route\" function at AS \"%s\"",
- rc->name);
-
-
- xbt_dynar_t links_list =
- xbt_dynar_new(global_routing->size_of_link, NULL);
-
- char *cluster_is_fd = xbt_dict_get_or_null(cluster_host_link,rc->name);
- char *link_src,*link_bb,*link_dst,*link_src_up,*link_dst_down;
-
- if(!cluster_is_fd){ // NOT FULLDUPLEX
- link_src = xbt_dict_get_or_null(cluster_host_link,src);
- if( !link_src && (global_routing->get_network_element_type(src) != SURF_NETWORK_ELEMENT_ROUTER) )
- xbt_die("No link for '%s' found!",src);
- if(link_src) xbt_dynar_push_as(links_list,void*,xbt_lib_get_or_null(link_lib, link_src, SURF_LINK_LEVEL)); //link_up
-
- link_bb = bprintf("%s_backbone",rc->name);
- xbt_dynar_push_as(links_list,void*,xbt_lib_get_or_null(link_lib, link_bb, SURF_LINK_LEVEL)); //link_bb
- free(link_bb);
-
- link_dst = xbt_dict_get_or_null(cluster_host_link,dst);
- if( !link_dst && (global_routing->get_network_element_type(dst) != SURF_NETWORK_ELEMENT_ROUTER) )
- xbt_die("No link for '%s' found!",dst);
- if(link_dst) xbt_dynar_push_as(links_list,void*,xbt_lib_get_or_null(link_lib, link_dst, SURF_LINK_LEVEL)); //link_down
- }
- else // FULLDUPLEX
- {
- link_src = xbt_dict_get_or_null(cluster_host_link,src);
- if( !link_src && (global_routing->get_network_element_type(src) != SURF_NETWORK_ELEMENT_ROUTER) )
- xbt_die("No link for '%s' found!",src);
- link_src_up = bprintf("%s_UP",link_src);
- 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
- free(link_src_up);
-
- link_bb = bprintf("%s_backbone",rc->name);
- if(link_bb) xbt_dynar_push_as(links_list,void*,xbt_lib_get_or_null(link_lib, link_bb, SURF_LINK_LEVEL)); //link_bb
- free(link_bb);
-
- link_dst = xbt_dict_get_or_null(cluster_host_link,dst);
- if(!link_dst && (global_routing->get_network_element_type(dst) != SURF_NETWORK_ELEMENT_ROUTER))
- xbt_die("No link for '%s' found!",dst);
- link_dst_down = bprintf("%s_DOWN",link_dst);
- 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
- free(link_dst_down);
- }