1 /* Copyright (c) 2013-2014. 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 #include "surf_interface.hpp"
10 #ifndef NETWORK_ROUTING_HPP_
11 #define NETWORK_ROUTING_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 The Autonomous System (AS) routing interface
35 xbt_dynar_t p_indexNetworkElm;
36 xbt_dict_t p_bypassRoutes; /* store bypass routes */
37 routing_model_description_t p_modelDesc;
38 e_surf_routing_hierarchy_t p_hierarchy;
41 xbt_dict_t p_routingSons;
42 RoutingEdge *p_netElem;
43 xbt_dynar_t p_linkUpDownList;
46 * @brief The As constructor
51 * @brief The As destructor
58 * @brief Get the route and latency between two RoutingEdges
59 * @details [long description]
61 * @param src [description]
62 * @param dst [description]
63 * @param into [description]
64 * @param latency [description]
66 virtual void getRouteAndLatency(RoutingEdge *src, RoutingEdge *dst, sg_platf_route_cbarg_t into, double *latency)=0;
67 virtual xbt_dynar_t getOneLinkRoutes()=0;
68 virtual void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)=0;
69 virtual sg_platf_route_cbarg_t getBypassRoute(RoutingEdge *src, RoutingEdge *dst, double *lat)=0;
71 /* The parser calls the following functions to inform the routing models
72 * that a new element is added to the AS currently built.
74 * Of course, only the routing model of this AS is informed, not every ones */
75 virtual int parsePU(RoutingEdge *elm)=0; /* A host or a router, whatever */
76 virtual int parseAS( RoutingEdge *elm)=0;
77 virtual void parseRoute(sg_platf_route_cbarg_t route)=0;
78 virtual void parseASroute(sg_platf_route_cbarg_t route)=0;
79 virtual void parseBypassroute(sg_platf_route_cbarg_t e_route)=0;
82 /** @ingroup SURF_routing_interface
83 * @brief A routing edge
84 * @details [long description]
88 virtual ~RoutingEdge(){};
89 virtual int getId()=0;
90 virtual int *getIdPtr()=0;
91 virtual void setId(int id)=0;
92 virtual char *getName()=0;
93 virtual As *getRcComponent()=0;
94 virtual e_surf_network_element_type_t getRcType()=0;
97 struct RoutingEdgeImpl : public RoutingEdge {
99 RoutingEdgeImpl(char *name, int id, e_surf_network_element_type_t rcType, As *rcComponent)
100 : p_rcComponent(rcComponent), p_rcType(rcType), m_id(id), p_name(name) {}
101 ~RoutingEdgeImpl() { xbt_free(p_name);};
103 int getId() {return m_id;}
104 int *getIdPtr() {return &m_id;}
105 void setId(int id) {m_id = id;}
106 char *getName() {return p_name;}
107 As *getRcComponent() {return p_rcComponent;}
108 e_surf_network_element_type_t getRcType() {return p_rcType;}
111 e_surf_network_element_type_t p_rcType;
116 struct RoutingEdgeWrapper : public RoutingEdge {
118 RoutingEdgeWrapper(RoutingEdge *re) : p_re(re){}
119 ~RoutingEdgeWrapper(){}
120 int getId() {return p_re->getId();}
121 int *getIdPtr() {return p_re->getIdPtr();}
122 void setId(int id) {p_re->setId(id);}
123 char *getName() {return p_re->getName();}
124 As *getRcComponent() {return p_re->getRcComponent();}
125 e_surf_network_element_type_t getRcType() {return p_re->getRcType();}
130 /** @ingroup SURF_routing_interface
131 * @brief Link of lenght 1, alongside with its source and destination. This is mainly usefull in the bindings to gtnets and ns3
135 Onelink(void *link, RoutingEdge *src, RoutingEdge *dst)
136 : p_src(src), p_dst(dst), p_link(link) {};
142 /** @ingroup SURF_routing_interface
143 * @brief The class representing a whole routing platform
145 XBT_PUBLIC_CLASS RoutingPlatf {
150 xbt_dynar_t p_lastRoute;
151 xbt_dynar_t getOneLinkRoutes(void);
152 xbt_dynar_t recursiveGetOneLinkRoutes(As *rc);
153 void getRouteAndLatency(RoutingEdge *src, RoutingEdge *dst, xbt_dynar_t * links, double *latency);
156 #endif /* NETWORK_ROUTING_HPP_ */