#include "network_gtnets_private.h"
#include "gtnets/gtnets_interface.h"
-XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_network_gtnets);
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_network_gtnets, surf,
+ "Logging specific to the SURF network module");
/* surf_network_resource_t surf_network_resource = NULL; */
/*static xbt_dict_t network_link_set = NULL;*/
#endif
int i;
int *gtnets_links;
-
+
/* KF: Build the list of gtnets link IDs */
gtnets_links = (int *)calloc(nb_link, sizeof(int));
for (i=0; i<nb_link; i++) {
- gtnets_links[i]=(int)(xbt_dict_get(network_link_set, links[i]));
+ gtnets_links[i]=
+ ((network_link_GTNETS_t)(xbt_dict_get(network_link_set, links[i])))->id;
}
/* KF: Create the GTNets route */
}
}
+/* Instantiate a new route: MODIFY BY KF */
+static void route_onehop_new(int src_id, int dst_id, char **links, int nb_link)
+{
+ int linkid;
+
+ if (nb_link != 1){
+ xbt_assert0(0, "In onehop_new, nb_link should be 1");
+ }
+
+ /* KF: Build the list of gtnets link IDs */
+ linkid =
+ ((network_link_GTNETS_t)(xbt_dict_get(network_link_set, links[0])))->id;
+
+ /* KF: Create the GTNets route */
+ if (gtnets_add_onehop_route(src_id, dst_id, linkid)) {
+ xbt_assert0(0,"Cannot create GTNetS route");
+ }
+}
+
/* Parse the XML for a network link */
static void parse_network_link(void)
{
link_name = NULL;
}
+/* KF*/
+static void parse_route_set_routers(void)
+{
+ int id = network_card_new(A_surfxml_router_name);
+
+ /* KF: Create the GTNets router */
+ if (gtnets_add_router(id)) {
+ xbt_assert0(0,"Cannot add GTNetS router");
+ }
+}
+
/* Parses a route element from the XML: UNMODIFIED BY HC */
static void parse_route_elem(void)
{
link_name[(nb_link) - 1] = xbt_strdup(A_surfxml_route_element_name);
}
-/* Create the route: UNMODIFIED BY HC */
+/* Create the route (more than one hops): MODIFIED BY KF */
static void parse_route_set_route(void)
{
- route_new(src_id, dst_id, link_name, nb_link);
+ if (nb_link > 1)
+ route_new(src_id, dst_id, link_name, nb_link);
+}
+
+/* Create the one-hope route: BY KF */
+static void parse_route_set_onehop_route(void)
+{
+ if (nb_link == 1)
+ route_onehop_new(src_id, dst_id, link_name, nb_link);
}
/* Main XML parsing */
surf_parse_close();
/* Figuring out the network cards used */
+ /* KF
surf_parse_reset_parser();
STag_surfxml_route_fun=parse_route_set_endpoints;
surf_parse_open(file);
xbt_assert1((!surf_parse()),"Parse error in %s",file);
surf_parse_close();
+ */
+
+ /* KF: Figuring out the router (considered as part of
+ network cards) used.*/
+ surf_parse_reset_parser();
+ STag_surfxml_router_fun=parse_route_set_routers;
+ surf_parse_open(file);
+ xbt_assert1((!surf_parse()),"Parse error in %s",file);
+ surf_parse_close();
+
+ /* Building the one-hop routes */
+ surf_parse_reset_parser();
+ STag_surfxml_route_fun=parse_route_set_endpoints;
+ ETag_surfxml_route_element_fun=parse_route_elem;
+ ETag_surfxml_route_fun=parse_route_set_onehop_route;
+ surf_parse_open(file);
+ xbt_assert1((!surf_parse()),"Parse error in %s",file);
+ surf_parse_close();
/* Building the routes */
surf_parse_reset_parser();
}
}
-
-
void surf_network_resource_init_GTNETS(const char *filename)
{
if (surf_network_resource)
surf_network_resource_init_internal();
parse_file(filename);
xbt_dynar_push(resource_list, &surf_network_resource);
+
+ update_resource_description(surf_network_resource_description,
+ surf_network_resource_description_size,
+ "GTNets",
+ (surf_resource_t) surf_network_resource);
}