+static routing_component_t generic_as_exist(routing_component_t find_from, routing_component_t to_find) {
+ xbt_dict_cursor_t cursor = NULL;
+ char *key;
+ routing_component_t elem;
+ xbt_dict_foreach(find_from->routing_sons, cursor, key, elem) {
+ if( to_find == elem) return to_find;
+ if( generic_as_exist(elem,to_find) ) return to_find;
+ }
+ return NULL;
+}
+
+static routing_component_t generic_autonomous_system_exist(routing_component_t rc, char* element) {
+ routing_component_t element_as, result, elem;
+ xbt_dict_cursor_t cursor = NULL;
+ char *key;
+ element_as = xbt_dict_get_or_null(global_routing->where_network_elements,element);
+ result = (routing_component_t)(-1);
+ if(element_as!=rc)
+ result = generic_as_exist(rc,element_as);
+
+ if(result)
+ {
+ xbt_dict_foreach(element_as->routing_sons, cursor, key, elem) {
+ if( !strcmp(elem->name,element) ) return element_as;
+ }
+ }
+ return NULL;
+}
+
+static routing_component_t generic_processing_units_exist(routing_component_t rc, char* element) {
+ routing_component_t element_as;
+ element_as = xbt_dict_get_or_null(global_routing->where_network_elements,element);
+ if(element_as==rc) return element_as;
+ return generic_as_exist(rc,element_as);
+}
+
+static void generic_src_dst_check(routing_component_t rc, const char* src, const char* dst) {
+
+ routing_component_t src_as = xbt_dict_get_or_null(global_routing->where_network_elements,src);
+ routing_component_t dst_as = xbt_dict_get_or_null(global_routing->where_network_elements,dst);
+
+ xbt_assert3(src_as != NULL && dst_as != NULL,
+ "Ask for route \"from\"(%s) or \"to\"(%s) no found at AS \"%s\"",src,dst,rc->name);
+ xbt_assert4(src_as == dst_as,
+ "The src(%s in %s) and dst(%s in %s) are in differents AS",src,src_as->name,dst,dst_as->name);
+ xbt_assert2(rc == dst_as,
+ "The routing component of src and dst is not the same as the network elements belong (%s==%s)",rc->name,dst_as->name);
+}
+