1 /* Copyright (c) 2006-2016. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
8 #include "simgrid/s4u/NetZone.hpp"
9 #include "simgrid/s4u/host.hpp"
10 #include "src/kernel/routing/NetCard.hpp"
11 #include "src/surf/network_interface.hpp" // Link FIXME: move to proper header
12 #include "src/surf/surf_routing.hpp"
14 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_netzone, "S4U Networking Zones");
19 simgrid::xbt::signal<void(bool symmetrical, kernel::routing::NetCard* src, kernel::routing::NetCard* dst,
20 kernel::routing::NetCard* gw_src, kernel::routing::NetCard* gw_dst,
21 std::vector<Link*>* link_list)>
22 NetZone::onRouteCreation;
24 NetZone::NetZone(NetZone* father, const char* name) : father_(father), name_(xbt_strdup(name))
33 xbt_dict_cursor_t cursor = nullptr;
36 xbt_dict_foreach (children_, cursor, key, elem) {
37 delete (NetZone*)elem;
40 xbt_dict_free(&children_);
44 xbt_dict_t NetZone::children()
52 NetZone* NetZone::father()
57 xbt_dynar_t NetZone::hosts()
59 xbt_dynar_t res = xbt_dynar_new(sizeof(sg_host_t), nullptr);
61 for (auto card : vertices_) {
62 s4u::Host* host = simgrid::s4u::Host::by_name_or_null(card->name());
64 xbt_dynar_push(res, &host);
69 int NetZone::addComponent(kernel::routing::NetCard* elm)
71 vertices_.push_back(elm);
72 return vertices_.size() - 1; // The rank of the newly created object
75 void NetZone::addRoute(sg_platf_route_cbarg_t /*route*/)
77 xbt_die("NetZone '%s' does not accept new routes (wrong class).", name_);
80 }; // namespace simgrid::s4u