diff options
author | Neale Ranns <nranns@cisco.com> | 2018-12-17 07:29:32 -0800 |
---|---|---|
committer | Neale Ranns <nranns@cisco.com> | 2018-12-17 16:30:50 +0000 |
commit | 66b48a9c6155a2c088f0f45fc568c846edb4b1af (patch) | |
tree | 5c1c2d2da40f8920f52d87e4505162882eac01da | |
parent | f49ba0e81e0cb9b9f8075cb4ce051b5bacde8ad3 (diff) |
VOM: IGMP only supports IPv4
Change-Id: Ie0a8898fa2d8ab71522686fb83fb1de959ee3098
Signed-off-by: Neale Ranns <nranns@cisco.com>
-rw-r--r-- | extras/vom/vom/api_types.cpp | 5 | ||||
-rw-r--r-- | extras/vom/vom/api_types.hpp | 2 | ||||
-rw-r--r-- | extras/vom/vom/igmp_binding.cpp | 18 | ||||
-rw-r--r-- | extras/vom/vom/igmp_binding.hpp | 20 | ||||
-rw-r--r-- | extras/vom/vom/igmp_listen.cpp | 11 | ||||
-rw-r--r-- | extras/vom/vom/igmp_listen.hpp | 8 | ||||
-rw-r--r-- | extras/vom/vom/igmp_listen_cmds.cpp | 28 |
7 files changed, 73 insertions, 19 deletions
diff --git a/extras/vom/vom/api_types.cpp b/extras/vom/vom/api_types.cpp index 9615410a036..418f3e43564 100644 --- a/extras/vom/vom/api_types.cpp +++ b/extras/vom/vom/api_types.cpp @@ -28,6 +28,11 @@ to_api(const ip_address_t& a, vapi_type_address& v) memcpy(v.un.ip6, a.to_v6().to_bytes().data(), 16); } } +void +to_api(const boost::asio::ip::address& a, vapi_type_ip4_address& v) +{ + memcpy(v, a.to_v4().to_bytes().data(), 4); +} ip_address_t from_api(const vapi_type_address& v) diff --git a/extras/vom/vom/api_types.hpp b/extras/vom/vom/api_types.hpp index 96e2c47f558..c28ae1e997d 100644 --- a/extras/vom/vom/api_types.hpp +++ b/extras/vom/vom/api_types.hpp @@ -24,8 +24,10 @@ namespace VOM { typedef boost::asio::ip::address ip_address_t; void to_api(const ip_address_t& a, vapi_type_address& v); +void to_api(const boost::asio::ip::address& a, vapi_type_ip4_address& v); ip_address_t from_api(const vapi_type_address& v); +ip_address_t from_api(const vapi_type_ip4_address& v); vapi_type_mac_address to_api(const mac_address_t& a); diff --git a/extras/vom/vom/igmp_binding.cpp b/extras/vom/vom/igmp_binding.cpp index bcdc6cbed10..73e0bd8f02a 100644 --- a/extras/vom/vom/igmp_binding.cpp +++ b/extras/vom/vom/igmp_binding.cpp @@ -22,7 +22,7 @@ namespace VOM { /** * A DB of all igmp bindings configs */ -singular_db<interface::key_t, igmp_binding> igmp_binding::m_db; +singular_db<igmp_binding::key_t, igmp_binding> igmp_binding::m_db; igmp_binding::event_handler igmp_binding::m_evh; @@ -41,7 +41,7 @@ igmp_binding::igmp_binding(const igmp_binding& o) igmp_binding::~igmp_binding() { sweep(); - m_db.release(m_itf->key(), this); + m_db.release(key(), this); } bool @@ -50,6 +50,12 @@ igmp_binding::operator==(const igmp_binding& l) const return (*m_itf == *l.m_itf); } +const igmp_binding::key_t +igmp_binding::key() const +{ + return (m_itf->key()); +} + void igmp_binding::sweep() { @@ -96,7 +102,13 @@ igmp_binding::update(const igmp_binding& desired) std::shared_ptr<igmp_binding> igmp_binding::find_or_add(const igmp_binding& temp) { - return (m_db.find_or_add(temp.m_itf->key(), temp)); + return (m_db.find_or_add(temp.key(), temp)); +} + +std::shared_ptr<igmp_binding> +igmp_binding::find(const key_t& k) +{ + return (m_db.find(k)); } std::shared_ptr<igmp_binding> diff --git a/extras/vom/vom/igmp_binding.hpp b/extras/vom/vom/igmp_binding.hpp index e2726cd0e20..56af8d1117e 100644 --- a/extras/vom/vom/igmp_binding.hpp +++ b/extras/vom/vom/igmp_binding.hpp @@ -31,6 +31,12 @@ class igmp_binding : public object_base { public: /** + * A binding is tied to a given interface, hence its key is + * that of the interface + */ + typedef interface::key_t key_t; + + /** * Construct a new object matching the desried state */ igmp_binding(const interface& itf); @@ -51,6 +57,11 @@ public: bool operator==(const igmp_binding& l) const; /** + * Get the object's key + */ + const key_t key() const; + + /** * Return the 'singular' of the IGMP binding that matches this object */ std::shared_ptr<igmp_binding> singular() const; @@ -70,6 +81,11 @@ public: */ static void dump(std::ostream& os); + /** + * Find a listen from its key + */ + static std::shared_ptr<igmp_binding> find(const key_t& k); + private: /** * Class definition for listeners to OM events @@ -124,7 +140,7 @@ private: /** * It's the singular_db class that calls replay() */ - friend class singular_db<interface::key_t, igmp_binding>; + friend class singular_db<key_t, igmp_binding>; /** * Sweep/reap the object if still stale @@ -152,7 +168,7 @@ private: /** * A map of all IGMP bindings keyed against the interface. */ - static singular_db<interface::key_t, igmp_binding> m_db; + static singular_db<key_t, igmp_binding> m_db; }; }; diff --git a/extras/vom/vom/igmp_listen.cpp b/extras/vom/vom/igmp_listen.cpp index 68c51867fa6..8d321add65d 100644 --- a/extras/vom/vom/igmp_listen.cpp +++ b/extras/vom/vom/igmp_listen.cpp @@ -26,7 +26,7 @@ igmp_listen::event_handler igmp_listen::m_evh; * Construct a new object matching the desried state */ igmp_listen::igmp_listen(const igmp_binding& igmp_bind, - const boost::asio::ip::address& gaddr, + const boost::asio::ip::address_v4& gaddr, const igmp_listen::src_addrs_t& saddrs) : m_igmp_bind(igmp_bind.singular()) , m_gaddr(gaddr) @@ -35,6 +35,15 @@ igmp_listen::igmp_listen(const igmp_binding& igmp_bind, { } +igmp_listen::igmp_listen(const igmp_binding& igmp_bind, + const boost::asio::ip::address_v4& gaddr) + : m_igmp_bind(igmp_bind.singular()) + , m_gaddr(gaddr) + , m_saddrs() + , m_listen(true, rc_t::NOOP) +{ +} + igmp_listen::igmp_listen(const igmp_listen& o) : m_igmp_bind(o.m_igmp_bind) , m_gaddr(o.m_gaddr) diff --git a/extras/vom/vom/igmp_listen.hpp b/extras/vom/vom/igmp_listen.hpp index cd1da0bdd27..4f07e759b09 100644 --- a/extras/vom/vom/igmp_listen.hpp +++ b/extras/vom/vom/igmp_listen.hpp @@ -31,7 +31,7 @@ namespace VOM { class igmp_listen : public object_base { public: - typedef std::set<boost::asio::ip::address> src_addrs_t; + typedef std::set<boost::asio::ip::address_v4> src_addrs_t; /** * The key type for igmp_listens @@ -42,8 +42,10 @@ public: * Construct a new object matching the desried state */ igmp_listen(const igmp_binding& igmp_bind, - const boost::asio::ip::address& gaddr, + const boost::asio::ip::address_v4& gaddr, const src_addrs_t& saddrs); + igmp_listen(const igmp_binding& igmp_bind, + const boost::asio::ip::address_v4& gaddr); /** * Copy Constructor @@ -162,7 +164,7 @@ private: /** * The group address for igmp configuration */ - const boost::asio::ip::address m_gaddr; + const boost::asio::ip::address_v4 m_gaddr; /** * The set of src addresses to listen for diff --git a/extras/vom/vom/igmp_listen_cmds.cpp b/extras/vom/vom/igmp_listen_cmds.cpp index cdf0850ebc5..683b2b9a0b6 100644 --- a/extras/vom/vom/igmp_listen_cmds.cpp +++ b/extras/vom/vom/igmp_listen_cmds.cpp @@ -14,6 +14,7 @@ */ #include "vom/igmp_listen_cmds.hpp" +#include "vom/api_types.hpp" DEFINE_VAPI_MSG_IDS_IGMP_API_JSON; @@ -44,17 +45,24 @@ listen_cmd::issue(connection& con) auto& payload = req.get_request().get_payload(); payload.group.sw_if_index = m_itf.value(); - payload.group.filter = EXCLUDE; - to_bytes(m_gaddr.to_v4(), (u8*)&payload.group.gaddr); - auto addr = m_saddrs.cbegin(); - u8 i = 0; - while (addr != m_saddrs.cend()) { - to_bytes(addr->to_v4(), (u8*)&payload.group.saddrs[i]); - addr++; - i++; + to_api(m_gaddr.to_v4(), payload.group.gaddr); + + if (0 == size) { + // no sources => (*,G) join + payload.group.filter = EXCLUDE; + payload.group.n_srcs = 0; + } else { + // source => (S,G) join + payload.group.filter = INCLUDE; + u8 i = 0; + + for (auto addr : m_saddrs) { + to_api(addr, payload.group.saddrs[i]); + i++; + } + payload.group.n_srcs = i; } - payload.group.n_srcs = i; VAPI_CALL(req.execute()); return (wait()); @@ -99,7 +107,7 @@ unlisten_cmd::issue(connection& con) payload.group.sw_if_index = m_itf.value(); payload.group.n_srcs = 0; payload.group.filter = INCLUDE; - to_bytes(m_gaddr.to_v4(), (u8*)&payload.group.gaddr); + to_api(m_gaddr.to_v4(), payload.group.gaddr); VAPI_CALL(req.execute()); |