diff options
Diffstat (limited to 'mmss/node.hpp')
-rw-r--r-- | mmss/node.hpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/mmss/node.hpp b/mmss/node.hpp index 04b9ae7..c561cfc 100644 --- a/mmss/node.hpp +++ b/mmss/node.hpp @@ -29,9 +29,9 @@ #include "iface.hpp" #include "protocol.hpp" -#include <list> #include <memory> #include <string> +#include <unordered_set> namespace MMSS { @@ -49,18 +49,24 @@ private: unsigned rand_seed; std::shared_ptr<const protocol_t> proto; + std::unordered_set<std::shared_ptr<iface_t>> interfaces; + node_t(context_t *mmss0, const std::string &name0, unsigned rand_seed0, const std::shared_ptr<const protocol_t> &proto0) : mmss(mmss0), name(name0), gmrf_ctx(nullptr), rand_seed(rand_seed0), proto(proto0) { } -public: - std::list<std::shared_ptr<iface_t>> interfaces; +public: static std::shared_ptr<node_t> create(context_t *mmss, const std::string &name, unsigned rand_seed, const std::shared_ptr<const protocol_t> &proto) { auto node = std::shared_ptr<node_t>(new node_t(mmss, name, rand_seed, proto)); node->gmrf_ctx = proto->init(node.get()); return node; } + void add_iface(const std::shared_ptr<iface_t> &iface) { + interfaces.insert(iface); + proto->add_iface(this, gmrf_ctx, iface.get()); + } + context_t* get_context() const { return mmss; } @@ -73,10 +79,6 @@ public: return rand_r(&rand_seed); } - void add_iface(const std::shared_ptr<iface_t> &iface) { - proto->add_iface(this, gmrf_ctx, iface.get()); - } - void handle_packet(const std::shared_ptr<iface_t> &iface, const gmrf_addr_t *source, const void *data, size_t len) { proto->handle_packet(this, gmrf_ctx, iface.get(), source, data, len); } |