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_
12 #include "surf_interface.hpp"
15 XBT_PUBLIC(void) routing_model_create( void *loopback);
25 class XBT_PRIVATE RoutingModelDescription;
26 class XBT_PRIVATE Onelink;
29 /** @ingroup SURF_routing_interface
30 * @brief A network card
31 * @details This represents a position in the network. One can route information between two netcards
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;
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(
84 NetCard *src, NetCard *dst,
85 sg_platf_route_cbarg_t into, double *latency)=0;
86 virtual xbt_dynar_t getOneLinkRoutes()=0;
87 virtual void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)=0;
88 virtual sg_platf_route_cbarg_t getBypassRoute(
89 NetCard *src, NetCard *dst,
92 /* The parser calls the following functions to inform the routing models
93 * that a new element is added to the AS currently built.
95 * Of course, only the routing model of this AS is informed, not every ones */
96 virtual int parsePU(NetCard *elm)=0; /* A host or a router, whatever */
97 virtual int parseAS(NetCard *elm)=0;
98 virtual void parseRoute(sg_platf_route_cbarg_t route)=0;
99 virtual void parseASroute(sg_platf_route_cbarg_t route)=0;
100 virtual void parseBypassroute(sg_platf_route_cbarg_t e_route)=0;
103 struct XBT_PRIVATE NetCardImpl : public NetCard {
105 NetCardImpl(char *name, int id, e_surf_network_element_type_t rcType, As *rcComponent)
106 : p_rcComponent(rcComponent), p_rcType(rcType), m_id(id), p_name(name) {}
107 ~NetCardImpl() { 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 As *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 /** @ingroup SURF_routing_interface
123 * @brief Link of lenght 1, alongside with its source and destination. This is mainly usefull in the ns3 bindings
127 Onelink(void *link, NetCard *src, NetCard *dst)
128 : p_src(src), p_dst(dst), p_link(link) {};
134 /** @ingroup SURF_routing_interface
135 * @brief The class representing a whole routing platform
137 XBT_PUBLIC_CLASS RoutingPlatf {
142 xbt_dynar_t p_lastRoute;
143 xbt_dynar_t getOneLinkRoutes(void);
144 xbt_dynar_t recursiveGetOneLinkRoutes(As *rc);
145 void getRouteAndLatency(NetCard *src, NetCard *dst, xbt_dynar_t * links, double *latency);
152 XBT_PUBLIC_DATA(simgrid::surf::signal<void(NetCard*)>) routingEdgeCreatedCallbacks;
153 XBT_PUBLIC_DATA(simgrid::surf::signal<void(As*)>) asCreatedCallbacks;
158 #endif /* NETWORK_ROUTING_HPP_ */