1 /* Copyright (c) 2013-2015. The SimGrid Team.
2 * All rights reserved. */
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. */
7 #ifndef NETWORK_ROUTING_HPP_
8 #define NETWORK_ROUTING_HPP_
10 #include "surf_interface.hpp"
13 XBT_PUBLIC(void) routing_model_create( void *loopback);
15 /* ************************************************************************** */
16 /* ************************* GRAPH EXPORTING FUNCTIONS ********************** */
17 xbt_node_t new_xbt_graph_node (xbt_graph_t graph, const char *name, xbt_dict_t nodes);
18 xbt_edge_t new_xbt_graph_edge (xbt_graph_t graph, xbt_node_t s, xbt_node_t d, xbt_dict_t edges);
25 class RoutingModelDescription;
29 /** @ingroup SURF_routing_interface
30 * @brief A routing edge
31 * @details [long description]
35 virtual ~RoutingEdge(){};
36 virtual int getId()=0;
37 virtual int *getIdPtr()=0;
38 virtual void setId(int id)=0;
39 virtual char *getName()=0;
40 virtual As *getRcComponent()=0;
41 virtual e_surf_network_element_type_t getRcType()=0;
44 /** @ingroup SURF_routing_interface
45 * @brief The Autonomous System (AS) routing interface
50 xbt_dynar_t p_indexNetworkElm;
51 xbt_dict_t p_bypassRoutes; /* store bypass routes */
52 routing_model_description_t p_modelDesc;
53 e_surf_routing_hierarchy_t p_hierarchy;
56 xbt_dict_t p_routingSons;
57 RoutingEdge *p_netElem;
58 xbt_dynar_t p_linkUpDownList;
61 * @brief The As constructor
66 * @brief The As destructor
75 * @brief Get the route and latency between two RoutingEdges
76 * @details [long description]
78 * @param src [description]
79 * @param dst [description]
80 * @param into [description]
81 * @param latency [description]
83 virtual void getRouteAndLatency(RoutingEdge *src, RoutingEdge *dst, sg_platf_route_cbarg_t into, double *latency)=0;
84 virtual xbt_dynar_t getOneLinkRoutes()=0;
85 virtual void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)=0;
86 virtual sg_platf_route_cbarg_t getBypassRoute(RoutingEdge *src, RoutingEdge *dst, double *lat)=0;
88 /* The parser calls the following functions to inform the routing models
89 * that a new element is added to the AS currently built.
91 * Of course, only the routing model of this AS is informed, not every ones */
92 virtual int parsePU(RoutingEdge *elm)=0; /* A host or a router, whatever */
93 virtual int parseAS( RoutingEdge *elm)=0;
94 virtual void parseRoute(sg_platf_route_cbarg_t route)=0;
95 virtual void parseASroute(sg_platf_route_cbarg_t route)=0;
96 virtual void parseBypassroute(sg_platf_route_cbarg_t e_route)=0;
99 struct RoutingEdgeImpl : public RoutingEdge {
101 RoutingEdgeImpl(char *name, int id, e_surf_network_element_type_t rcType, As *rcComponent)
102 : p_rcComponent(rcComponent), p_rcType(rcType), m_id(id), p_name(name) {}
103 ~RoutingEdgeImpl() { xbt_free(p_name);};
105 int getId() {return m_id;}
106 int *getIdPtr() {return &m_id;}
107 void setId(int id) {m_id = id;}
108 char *getName() {return p_name;}
109 As *getRcComponent() {return p_rcComponent;}
110 e_surf_network_element_type_t getRcType() {return p_rcType;}
113 e_surf_network_element_type_t p_rcType;
118 struct RoutingEdgeWrapper : public RoutingEdge {
120 RoutingEdgeWrapper(RoutingEdge *re) : p_re(re){}
121 ~RoutingEdgeWrapper(){}
122 int getId() {return p_re->getId();}
123 int *getIdPtr() {return p_re->getIdPtr();}
124 void setId(int id) {p_re->setId(id);}
125 char *getName() {return p_re->getName();}
126 As *getRcComponent() {return p_re->getRcComponent();}
127 e_surf_network_element_type_t getRcType() {return p_re->getRcType();}
132 /** @ingroup SURF_routing_interface
133 * @brief Link of lenght 1, alongside with its source and destination. This is mainly usefull in the ns3 bindings
137 Onelink(void *link, RoutingEdge *src, RoutingEdge *dst)
138 : p_src(src), p_dst(dst), p_link(link) {};
144 /** @ingroup SURF_routing_interface
145 * @brief The class representing a whole routing platform
147 XBT_PUBLIC_CLASS RoutingPlatf {
152 xbt_dynar_t p_lastRoute;
153 xbt_dynar_t getOneLinkRoutes(void);
154 xbt_dynar_t recursiveGetOneLinkRoutes(As *rc);
155 void getRouteAndLatency(RoutingEdge *src, RoutingEdge *dst, xbt_dynar_t * links, double *latency);
158 #endif /* NETWORK_ROUTING_HPP_ */