1 #include "surf_interface.hpp"
4 #ifndef NETWORK_ROUTING_HPP_
5 #define NETWORK_ROUTING_HPP_
7 void routing_model_create( void *loopback);
9 /* ************************************************************************** */
10 /* ************************* GRAPH EXPORTING FUNCTIONS ********************** */
11 xbt_node_t new_xbt_graph_node (xbt_graph_t graph, const char *name, xbt_dict_t nodes);
12 xbt_edge_t new_xbt_graph_edge (xbt_graph_t graph, xbt_node_t s, xbt_node_t d, xbt_dict_t edges);
18 /* Note: As and RoutingEdge are declard as struct instead of class, to keep
19 compatibility with C files where they are mentioned. */
23 class RoutingModelDescription;
24 typedef RoutingModelDescription *RoutingModelDescriptionPtr;
27 typedef RoutingEdge *RoutingEdgePtr;
30 typedef Onelink *OnelinkPtr;
33 typedef RoutingPlatf *RoutingPlatfPtr;
35 /** @ingroup SURF_routing_interface
36 * @brief The Autonomous System (AS) routing interface
41 xbt_dynar_t p_indexNetworkElm;
42 xbt_dict_t p_bypassRoutes; /* store bypass routes */
43 routing_model_description_t p_modelDesc;
44 e_surf_routing_hierarchy_t p_hierarchy;
46 AsPtr p_routingFather;
47 xbt_dict_t p_routingSons;
48 RoutingEdgePtr p_netElem;
49 xbt_dynar_t p_linkUpDownList;
52 * @brief The As constructor
57 * @brief The As destructor
64 * @brief Get the route and latency between two RoutingEdgs
65 * @details [long description]
67 * @param src [description]
68 * @param dst [description]
69 * @param into [description]
70 * @param latency [description]
72 virtual void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t into, double *latency)=0;
73 virtual xbt_dynar_t getOneLinkRoutes()=0;
74 virtual void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)=0;
75 virtual sg_platf_route_cbarg_t getBypassRoute(RoutingEdgePtr src, RoutingEdgePtr dst, double *lat)=0;
77 /* The parser calls the following functions to inform the routing models
78 * that a new element is added to the AS currently built.
80 * Of course, only the routing model of this AS is informed, not every ones */
81 virtual int parsePU(RoutingEdgePtr elm)=0; /* A host or a router, whatever */
82 virtual int parseAS( RoutingEdgePtr elm)=0;
83 virtual void parseRoute(sg_platf_route_cbarg_t route)=0;
84 virtual void parseASroute(sg_platf_route_cbarg_t route)=0;
85 virtual void parseBypassroute(sg_platf_route_cbarg_t e_route)=0;
88 /** @ingroup SURF_routing_interface
89 * @brief A routing edge
90 * @details [long description]
94 virtual ~RoutingEdge(){};
95 virtual int getId()=0;
96 virtual int *getIdPtr()=0;
97 virtual void setId(int id)=0;
98 virtual char *getName()=0;
99 virtual AsPtr getRcComponent()=0;
100 virtual e_surf_network_element_type_t getRcType()=0;
103 struct RoutingEdgeImpl : public RoutingEdge {
105 RoutingEdgeImpl(char *name, int id, e_surf_network_element_type_t rcType, AsPtr rcComponent)
106 : p_rcComponent(rcComponent), p_rcType(rcType), m_id(id), p_name(name) {}
107 ~RoutingEdgeImpl() { xbt_free(p_name);};
109 int getId() {return m_id;}
110 int *getIdPtr() {return &m_id;}
111 void setId(int id) {m_id = id;}
112 char *getName() {return p_name;}
113 AsPtr getRcComponent() {return p_rcComponent;}
114 e_surf_network_element_type_t getRcType() {return p_rcType;}
117 e_surf_network_element_type_t p_rcType;
122 struct RoutingEdgeWrapper : public RoutingEdge {
124 RoutingEdgeWrapper(RoutingEdge *re) : p_re(re){}
125 ~RoutingEdgeWrapper(){}
126 int getId() {return p_re->getId();}
127 int *getIdPtr() {return p_re->getIdPtr();}
128 void setId(int id) {p_re->setId(id);}
129 char *getName() {return p_re->getName();}
130 AsPtr getRcComponent() {return p_re->getRcComponent();}
131 e_surf_network_element_type_t getRcType() {return p_re->getRcType();}
136 /** @ingroup SURF_routing_interface
137 * @brief Link of lenght 1, alongside with its source and destination. This is mainly usefull in the bindings to gtnets and ns3
141 Onelink(void *link, RoutingEdgePtr src, RoutingEdgePtr dst)
142 : p_src(src), p_dst(dst), p_link(link) {};
143 RoutingEdgePtr p_src;
144 RoutingEdgePtr p_dst;
148 /** @ingroup SURF_routing_interface
149 * @brief The class representing a whole routing platform
156 xbt_dynar_t p_lastRoute;
157 xbt_dynar_t getOneLinkRoutes(void);
158 xbt_dynar_t recursiveGetOneLinkRoutes(AsPtr rc);
159 void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, xbt_dynar_t * links, double *latency);
162 #endif /* NETWORK_ROUTING_HPP_ */