-/**
- * \brief Get the AS father and the first elements of the chain
- *
- * \param src the source host name
- * \param dst the destination host name
- *
- * Get the common father of the to processing units, and the first different
- * father in the chain
- */
-static void elements_father(sg_netcard_t src, sg_netcard_t dst,
- AS_t * res_father, AS_t * res_src, AS_t * res_dst)
-{
- xbt_assert(src && dst, "bad parameters for \"elements_father\" method");
-#define ROUTING_HIERARCHY_MAXDEPTH 16 /* increase if it is not enough */
- simgrid::surf::As *path_src[ROUTING_HIERARCHY_MAXDEPTH];
- simgrid::surf::As *path_dst[ROUTING_HIERARCHY_MAXDEPTH];
- int index_src = 0;
- int index_dst = 0;
- simgrid::surf::As *current_src;
- simgrid::surf::As *current_dst;
- simgrid::surf::As *father;
-
- /* (1) find the path to root of src and dst*/
- simgrid::surf::As *src_as = src->containingAS();
- simgrid::surf::As *dst_as = dst->containingAS();
-
- xbt_assert(src_as, "Host %s must be in an AS", src->name());
- xbt_assert(dst_as, "Host %s must be in an AS", dst->name());
-
- /* (2) find the path to the root routing component */
- for (simgrid::surf::As *current = src_as; current != NULL; current = current->father_) {
- if (index_src >= ROUTING_HIERARCHY_MAXDEPTH)
- xbt_die("ROUTING_HIERARCHY_MAXDEPTH should be increased for element %s", src->name());
- path_src[index_src++] = current;
- }
- for (simgrid::surf::As *current = dst_as; current != NULL; current = current->father_) {
- if (index_dst >= ROUTING_HIERARCHY_MAXDEPTH)
- xbt_die("ROUTING_HIERARCHY_MAXDEPTH should be increased for path_dst");
- path_dst[index_dst++] = current;
- }
-
- /* (3) find the common father */
- do {
- current_src = path_src[--index_src];
- current_dst = path_dst[--index_dst];
- } while (index_src > 0 && index_dst > 0 && current_src == current_dst);
-
- /* (4) they are not in the same routing component, make the path */
- if (current_src == current_dst)
- father = current_src;
- else
- father = path_src[index_src + 1];
-
- /* (5) result generation */
- *res_father = father; /* first the common father of src and dst */
- *res_src = current_src; /* second the first different father of src */
- *res_dst = current_dst; /* three the first different father of dst */
-
-#undef ROUTING_HIERARCHY_MAXDEPTH
-}