summaryrefslogtreecommitdiffstats
path: root/extras
diff options
context:
space:
mode:
Diffstat (limited to 'extras')
-rw-r--r--extras/vom/vom/CMakeLists.txt18
-rw-r--r--extras/vom/vom/igmp_binding.cpp150
-rw-r--r--extras/vom/vom/igmp_binding.hpp167
-rw-r--r--extras/vom/vom/igmp_binding_cmds.cpp105
-rw-r--r--extras/vom/vom/igmp_binding_cmds.hpp101
-rw-r--r--extras/vom/vom/igmp_listen.cpp179
-rw-r--r--extras/vom/vom/igmp_listen.hpp199
-rw-r--r--extras/vom/vom/igmp_listen_cmds.cpp168
-rw-r--r--extras/vom/vom/igmp_listen_cmds.hpp162
9 files changed, 1249 insertions, 0 deletions
diff --git a/extras/vom/vom/CMakeLists.txt b/extras/vom/vom/CMakeLists.txt
index 20d926add09..5a5e5a7df0e 100644
--- a/extras/vom/vom/CMakeLists.txt
+++ b/extras/vom/vom/CMakeLists.txt
@@ -16,6 +16,7 @@ unset (ACL_FILE)
unset (NAT_FILE)
unset (L2E_FILE)
unset (GBP_FILE)
+unset (IGMP_FILE)
unset (VOM_SOURCES)
unset (VOM_HEADERS)
@@ -33,6 +34,7 @@ find_file(ACL_FILE NAMES acl.api.vapi.hpp PATH_SUFFIXES vapi)
find_file(NAT_FILE NAMES nat.api.vapi.hpp PATH_SUFFIXES vapi)
find_file(L2E_FILE NAMES l2e.api.vapi.hpp PATH_SUFFIXES vapi)
find_file(GBP_FILE NAMES gbp.api.vapi.hpp PATH_SUFFIXES vapi)
+find_file(IGMP_FILE NAMES igmp.api.vapi.hpp PATH_SUFFIXES vapi)
if(ACL_FILE)
list(APPEND VOM_SOURCES
@@ -79,6 +81,15 @@ if(GBP_FILE)
)
endif()
+if (IGMP_FILE)
+ list(APPEND VOM_SOURCES
+ igmp_binding_cmds.cpp
+ igmp_binding.cpp
+ igmp_listen_cmds.cpp
+ igmp_listen.cpp
+ )
+endif()
+
list(APPEND VOM_SOURCES
types.cpp
api_types.cpp
@@ -182,6 +193,13 @@ if(GBP_FILE)
)
endif()
+if(IGMP_FILE)
+ list(APPEND VOM_HEADERS
+ igmp_binding.hpp
+ igmp_listen.hpp
+ )
+endif()
+
list(APPEND VOM_HEADERS
arp_proxy_binding.hpp
arp_proxy_config.hpp
diff --git a/extras/vom/vom/igmp_binding.cpp b/extras/vom/vom/igmp_binding.cpp
new file mode 100644
index 00000000000..bcdc6cbed10
--- /dev/null
+++ b/extras/vom/vom/igmp_binding.cpp
@@ -0,0 +1,150 @@
+/*
+ * Copyright (c) 2018 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "vom/igmp_binding.hpp"
+#include "vom/igmp_binding_cmds.hpp"
+#include "vom/singular_db_funcs.hpp"
+
+namespace VOM {
+
+/**
+ * A DB of all igmp bindings configs
+ */
+singular_db<interface::key_t, igmp_binding> igmp_binding::m_db;
+
+igmp_binding::event_handler igmp_binding::m_evh;
+
+igmp_binding::igmp_binding(const interface& itf)
+ : m_itf(itf.singular())
+ , m_binding(true)
+{
+}
+
+igmp_binding::igmp_binding(const igmp_binding& o)
+ : m_itf(o.m_itf)
+ , m_binding(o.m_binding)
+{
+}
+
+igmp_binding::~igmp_binding()
+{
+ sweep();
+ m_db.release(m_itf->key(), this);
+}
+
+bool
+igmp_binding::operator==(const igmp_binding& l) const
+{
+ return (*m_itf == *l.m_itf);
+}
+
+void
+igmp_binding::sweep()
+{
+ if (m_binding) {
+ HW::enqueue(new igmp_binding_cmds::unbind_cmd(m_binding, m_itf->handle()));
+ }
+ HW::write();
+}
+
+void
+igmp_binding::dump(std::ostream& os)
+{
+ db_dump(m_db, os);
+}
+
+void
+igmp_binding::replay()
+{
+ if (m_binding) {
+ HW::enqueue(new igmp_binding_cmds::bind_cmd(m_binding, m_itf->handle()));
+ }
+}
+
+std::string
+igmp_binding::to_string() const
+{
+ std::ostringstream s;
+ s << "igmp-binding: [" << m_itf->to_string() << " mode:host]";
+
+ return (s.str());
+}
+
+void
+igmp_binding::update(const igmp_binding& desired)
+{
+ /*
+ * the desired state is always that the interface should be created
+ */
+ if (!m_binding) {
+ HW::enqueue(new igmp_binding_cmds::bind_cmd(m_binding, m_itf->handle()));
+ }
+}
+
+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));
+}
+
+std::shared_ptr<igmp_binding>
+igmp_binding::singular() const
+{
+ return find_or_add(*this);
+}
+
+std::shared_ptr<interface>
+igmp_binding::itf() const
+{
+ return m_itf;
+}
+
+igmp_binding::event_handler::event_handler()
+{
+ OM::register_listener(this);
+ inspect::register_handler({ "igmp-binding" }, "IGMP bindings", this);
+}
+
+void
+igmp_binding::event_handler::handle_replay()
+{
+ m_db.replay();
+}
+
+void
+igmp_binding::event_handler::handle_populate(const client_db::key_t& key)
+{
+ /* done with igmp_dump in igmp_listen */
+}
+
+dependency_t
+igmp_binding::event_handler::order() const
+{
+ return (dependency_t::BINDING);
+}
+
+void
+igmp_binding::event_handler::show(std::ostream& os)
+{
+ db_dump(m_db, os);
+}
+}
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
diff --git a/extras/vom/vom/igmp_binding.hpp b/extras/vom/vom/igmp_binding.hpp
new file mode 100644
index 00000000000..e2726cd0e20
--- /dev/null
+++ b/extras/vom/vom/igmp_binding.hpp
@@ -0,0 +1,167 @@
+/*
+ * Copyright (c) 2018 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __VOM_IGMP_BINDING_H__
+#define __VOM_IGMP_BINDING_H__
+
+#include "vom/hw.hpp"
+#include "vom/inspect.hpp"
+#include "vom/interface.hpp"
+#include "vom/object_base.hpp"
+#include "vom/om.hpp"
+#include "vom/singular_db.hpp"
+
+namespace VOM {
+/**
+ * A representation of IGMP binding on an interface
+ */
+class igmp_binding : public object_base
+{
+public:
+ /**
+ * Construct a new object matching the desried state
+ */
+ igmp_binding(const interface& itf);
+
+ /**
+ * Copy Constructor
+ */
+ igmp_binding(const igmp_binding& o);
+
+ /**
+ * Destructor
+ */
+ ~igmp_binding();
+
+ /**
+ * Equal operator
+ */
+ bool operator==(const igmp_binding& l) const;
+
+ /**
+ * Return the 'singular' of the IGMP binding that matches this object
+ */
+ std::shared_ptr<igmp_binding> singular() const;
+
+ /**
+ * convert to string format for debug purposes
+ */
+ std::string to_string() const;
+
+ /**
+ * Return the matching'singular' of the interface
+ */
+ std::shared_ptr<interface> itf() const;
+
+ /**
+ * Dump all IGMP bindings into the stream provided
+ */
+ static void dump(std::ostream& os);
+
+private:
+ /**
+ * Class definition for listeners to OM events
+ */
+ class event_handler : public OM::listener, public inspect::command_handler
+ {
+ public:
+ event_handler();
+ virtual ~event_handler() = default;
+
+ /**
+ * Handle a populate event
+ */
+ void handle_populate(const client_db::key_t& key);
+
+ /**
+ * Handle a replay event
+ */
+ void handle_replay();
+
+ /**
+ * Show the object in the Singular DB
+ */
+ void show(std::ostream& os);
+
+ /**
+ * Get the sortable Id of the listener
+ */
+ dependency_t order() const;
+ };
+
+ /**
+ * event_handler to register with OM
+ */
+ static event_handler m_evh;
+
+ /**
+ * Enquue commonds to the VPP command Q for the update
+ */
+ void update(const igmp_binding& obj);
+
+ /**
+ * Find or add IGMP binding to the OM
+ */
+ static std::shared_ptr<igmp_binding> find_or_add(const igmp_binding& temp);
+
+ /*
+ * It's the OM class that calls singular()
+ */
+ friend class OM;
+
+ /**
+ * It's the singular_db class that calls replay()
+ */
+ friend class singular_db<interface::key_t, igmp_binding>;
+
+ /**
+ * Sweep/reap the object if still stale
+ */
+ void sweep(void);
+
+ /**
+ * replay the object to create it in hardware
+ */
+ void replay(void);
+
+ /**
+ * A reference counting pointer to the interface on which IGMP config
+ * resides. By holding the reference here, we can guarantee that
+ * this object will outlive the interface
+ */
+ const std::shared_ptr<interface> m_itf;
+
+ /**
+ * HW configuration for the binding. The bool representing the
+ * do/don't bind.
+ */
+ HW::item<bool> m_binding;
+
+ /**
+ * A map of all IGMP bindings keyed against the interface.
+ */
+ static singular_db<interface::key_t, igmp_binding> m_db;
+};
+};
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
+
+#endif
diff --git a/extras/vom/vom/igmp_binding_cmds.cpp b/extras/vom/vom/igmp_binding_cmds.cpp
new file mode 100644
index 00000000000..133509e4e75
--- /dev/null
+++ b/extras/vom/vom/igmp_binding_cmds.cpp
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2018 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "vom/igmp_binding_cmds.hpp"
+
+namespace VOM {
+namespace igmp_binding_cmds {
+
+bind_cmd::bind_cmd(HW::item<bool>& item, const handle_t& itf)
+ : rpc_cmd(item)
+ , m_itf(itf)
+{
+}
+
+bool
+bind_cmd::operator==(const bind_cmd& other) const
+{
+ return (m_itf == other.m_itf);
+}
+
+rc_t
+bind_cmd::issue(connection& con)
+{
+ msg_t req(con.ctx(), std::ref(*this));
+
+ auto& payload = req.get_request().get_payload();
+ payload.sw_if_index = m_itf.value();
+ payload.enable = 1;
+ payload.mode = 1;
+
+ VAPI_CALL(req.execute());
+
+ return (wait());
+}
+
+std::string
+bind_cmd::to_string() const
+{
+ std::ostringstream s;
+ s << "igmp-bind: " << m_hw_item.to_string() << " itf:" << m_itf.to_string();
+
+ return (s.str());
+}
+
+unbind_cmd::unbind_cmd(HW::item<bool>& item, const handle_t& itf)
+ : rpc_cmd(item)
+ , m_itf(itf)
+{
+}
+
+bool
+unbind_cmd::operator==(const unbind_cmd& other) const
+{
+ return (m_itf == other.m_itf);
+}
+
+rc_t
+unbind_cmd::issue(connection& con)
+{
+ msg_t req(con.ctx(), std::ref(*this));
+
+ auto& payload = req.get_request().get_payload();
+ payload.sw_if_index = m_itf.value();
+ payload.enable = 0;
+ payload.mode = 1;
+
+ VAPI_CALL(req.execute());
+
+ wait();
+ m_hw_item.set(rc_t::NOOP);
+
+ return rc_t::OK;
+}
+
+std::string
+unbind_cmd::to_string() const
+{
+ std::ostringstream s;
+ s << "igmp-unbind: " << m_hw_item.to_string() << " itf:" << m_itf.to_string();
+
+ return (s.str());
+}
+
+}; // namespace igmp_binding_cmds
+}; // namespace VOM
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
diff --git a/extras/vom/vom/igmp_binding_cmds.hpp b/extras/vom/vom/igmp_binding_cmds.hpp
new file mode 100644
index 00000000000..25a1a67215a
--- /dev/null
+++ b/extras/vom/vom/igmp_binding_cmds.hpp
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2018 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __VOM_IGMP_BINDING_CMDS_H__
+#define __VOM_IGMP_BINDING_CMDS_H__
+
+#include "vom/igmp_binding.hpp"
+#include "vom/rpc_cmd.hpp"
+
+#include <vapi/igmp.api.vapi.hpp>
+
+namespace VOM {
+namespace igmp_binding_cmds {
+/**
+ * A command class that binds the IGMP config to the interface
+ */
+class bind_cmd : public rpc_cmd<HW::item<bool>, vapi::Igmp_enable_disable>
+{
+public:
+ /**
+ * Constructor
+ */
+ bind_cmd(HW::item<bool>& item, const handle_t& itf);
+
+ /**
+ * Issue the command to VPP/HW
+ */
+ rc_t issue(connection& con);
+ /**
+ * convert to string format for debug purposes
+ */
+ std::string to_string() const;
+
+ /**
+ * Comparison operator - only used for UT
+ */
+ bool operator==(const bind_cmd& i) const;
+
+private:
+ /**
+ * Reference to the HW::item of the interface to bind
+ */
+ const handle_t& m_itf;
+};
+
+/**
+ * A cmd class that Unbinds IGMP Config from an interface
+ */
+class unbind_cmd : public rpc_cmd<HW::item<bool>, vapi::Igmp_enable_disable>
+{
+public:
+ /**
+ * Constructor
+ */
+ unbind_cmd(HW::item<bool>& item, const handle_t& itf);
+
+ /**
+ * Issue the command to VPP/HW
+ */
+ rc_t issue(connection& con);
+ /**
+ * convert to string format for debug purposes
+ */
+ std::string to_string() const;
+
+ /**
+ * Comparison operator - only used for UT
+ */
+ bool operator==(const unbind_cmd& i) const;
+
+private:
+ /**
+ * Reference to the HW::item of the interface to unbind
+ */
+ const handle_t& m_itf;
+};
+
+}; // namespace cmds
+}; // namespace VOM
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
+
+#endif
diff --git a/extras/vom/vom/igmp_listen.cpp b/extras/vom/vom/igmp_listen.cpp
new file mode 100644
index 00000000000..68c51867fa6
--- /dev/null
+++ b/extras/vom/vom/igmp_listen.cpp
@@ -0,0 +1,179 @@
+/*
+ * Copyright (c) 2018 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "vom/igmp_listen.hpp"
+#include "vom/igmp_listen_cmds.hpp"
+#include "vom/singular_db_funcs.hpp"
+
+namespace VOM {
+singular_db<igmp_listen::key_t, igmp_listen> igmp_listen::m_db;
+
+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 igmp_listen::src_addrs_t& saddrs)
+ : m_igmp_bind(igmp_bind.singular())
+ , m_gaddr(gaddr)
+ , m_saddrs(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)
+ , m_saddrs(o.m_saddrs)
+ , m_listen(o.m_listen)
+{
+}
+
+igmp_listen::~igmp_listen()
+{
+ sweep();
+
+ // not in the DB anymore.
+ m_db.release(key(), this);
+}
+
+bool
+igmp_listen::operator==(const igmp_listen& l) const
+{
+ return ((m_gaddr == l.m_gaddr) && (*m_igmp_bind == *l.m_igmp_bind) &&
+ (m_saddrs == l.m_saddrs));
+}
+
+const igmp_listen::key_t
+igmp_listen::key() const
+{
+ return (make_pair(m_igmp_bind->itf()->key(), m_gaddr));
+}
+
+void
+igmp_listen::sweep()
+{
+ if (m_listen) {
+ HW::enqueue(new igmp_listen_cmds::unlisten_cmd(
+ m_listen, m_igmp_bind->itf()->handle(), m_gaddr));
+ }
+ HW::write();
+}
+
+void
+igmp_listen::replay()
+{
+ if (m_listen) {
+ HW::enqueue(new igmp_listen_cmds::listen_cmd(
+ m_listen, m_igmp_bind->itf()->handle(), m_gaddr, m_saddrs));
+ }
+}
+
+std::string
+igmp_listen::to_string() const
+{
+ auto addr = m_saddrs.cbegin();
+
+ std::ostringstream s;
+ s << "igmp-listen:[" << m_igmp_bind->to_string() << " group:" << m_gaddr
+ << " src-addrs: [";
+ while (addr != m_saddrs.cend()) {
+ s << " " << *addr;
+ ++addr;
+ }
+ s << " ] " << m_listen.to_string() << "]";
+
+ return (s.str());
+}
+
+void
+igmp_listen::update(const igmp_listen& desired)
+{
+ /*
+ * no updates for the listen. chaning the interface or the group addr is a
+ * change to the key, hence a new object
+ */
+ if (!m_listen) {
+ HW::enqueue(new igmp_listen_cmds::listen_cmd(
+ m_listen, m_igmp_bind->itf()->handle(), m_gaddr, m_saddrs));
+ }
+}
+
+std::shared_ptr<igmp_listen>
+igmp_listen::find_or_add(const igmp_listen& temp)
+{
+ return (m_db.find_or_add(temp.key(), temp));
+}
+
+std::shared_ptr<igmp_listen>
+igmp_listen::find(const key_t& k)
+{
+ return (m_db.find(k));
+}
+
+std::shared_ptr<igmp_listen>
+igmp_listen::singular() const
+{
+ return find_or_add(*this);
+}
+
+void
+igmp_listen::dump(std::ostream& os)
+{
+ db_dump(m_db, os);
+}
+
+igmp_listen::event_handler::event_handler()
+{
+ OM::register_listener(this);
+ inspect::register_handler({ "igmp-listen" }, "igmp listener", this);
+}
+
+void
+igmp_listen::event_handler::handle_replay()
+{
+ m_db.replay();
+}
+
+void
+igmp_listen::event_handler::handle_populate(const client_db::key_t& key)
+{
+ /**
+ * This is done while populating the interfaces
+ */
+}
+
+dependency_t
+igmp_listen::event_handler::order() const
+{
+ return (dependency_t::ENTRY);
+}
+
+void
+igmp_listen::event_handler::show(std::ostream& os)
+{
+ db_dump(m_db, os);
+}
+}
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
diff --git a/extras/vom/vom/igmp_listen.hpp b/extras/vom/vom/igmp_listen.hpp
new file mode 100644
index 00000000000..cd1da0bdd27
--- /dev/null
+++ b/extras/vom/vom/igmp_listen.hpp
@@ -0,0 +1,199 @@
+/*
+ * Copyright (c) 2018 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __VOM_IGMP_LISTEN_H__
+#define __VOM_IGMP_LISTEN_H__
+
+#include "vom/hw.hpp"
+#include "vom/igmp_binding.hpp"
+#include "vom/inspect.hpp"
+#include "vom/interface.hpp"
+#include "vom/object_base.hpp"
+#include "vom/om.hpp"
+#include "vom/singular_db.hpp"
+
+namespace VOM {
+/**
+ * A representation of igmp configuration on an interface
+ */
+class igmp_listen : public object_base
+{
+public:
+ typedef std::set<boost::asio::ip::address> src_addrs_t;
+
+ /**
+ * The key type for igmp_listens
+ */
+ typedef std::pair<interface::key_t, boost::asio::ip::address> key_t;
+
+ /**
+ * Construct a new object matching the desried state
+ */
+ igmp_listen(const igmp_binding& igmp_bind,
+ const boost::asio::ip::address& gaddr,
+ const src_addrs_t& saddrs);
+
+ /**
+ * Copy Constructor
+ */
+ igmp_listen(const igmp_listen& o);
+
+ /**
+ * Destructor
+ */
+ ~igmp_listen();
+
+ /**
+ * Comparison operator
+ */
+ bool operator==(const igmp_listen& l) const;
+
+ /**
+ * Get the object's key
+ */
+ const key_t key() const;
+
+ /**
+ * Return the 'singular instance' of the IGMP that matches this
+ * object
+ */
+ std::shared_ptr<igmp_listen> singular() const;
+
+ /**
+ * convert to string format for debug purposes
+ */
+ std::string to_string() const;
+
+ /**
+ * Dump all igmp_listens into the stream provided
+ */
+ static void dump(std::ostream& os);
+
+ /**
+ * Find a listen from its key
+ */
+ static std::shared_ptr<igmp_listen> find(const key_t& k);
+
+private:
+ /**
+ * Class definition for listeners to OM events
+ */
+ class event_handler : public OM::listener, public inspect::command_handler
+ {
+ public:
+ event_handler();
+ virtual ~event_handler() = default;
+
+ /**
+ * Handle a populate event
+ */
+ void handle_populate(const client_db::key_t& key);
+
+ /**
+ * Handle a replay event
+ */
+ void handle_replay();
+
+ /**
+ * Show the object in the Singular DB
+ */
+ void show(std::ostream& os);
+
+ /**
+ * Get the sortable Id of the listener
+ */
+ dependency_t order() const;
+ };
+
+ /**
+ * event_handler to register with OM
+ */
+ static event_handler m_evh;
+
+ /**
+ * Enquue commonds to the VPP command Q for the update
+ */
+ void update(const igmp_listen& obj);
+
+ /**
+ * Find or add the singular instance in the DB
+ */
+ static std::shared_ptr<igmp_listen> find_or_add(const igmp_listen& temp);
+
+ /*
+ * It's the VPPHW class that updates the objects in HW
+ */
+ friend class OM;
+
+ /**
+ * It's the singular_db class that calls replay()
+ */
+ friend class singular_db<key_t, igmp_listen>;
+
+ /**
+ * Sweep/reap the object if still stale
+ */
+ void sweep(void);
+
+ /**
+ * replay the object to create it in hardware
+ */
+ void replay(void);
+
+ /**
+ * A reference counting pointer the igmp_binding that this 'igmp listen'
+ * represents. By holding the reference here, we can guarantee that
+ * this object will outlive the igmp_binding
+ */
+ const std::shared_ptr<igmp_binding> m_igmp_bind;
+
+ /**
+ * The group address for igmp configuration
+ */
+ const boost::asio::ip::address m_gaddr;
+
+ /**
+ * The set of src addresses to listen for
+ */
+ const src_addrs_t m_saddrs;
+
+ /**
+ * HW configuration for the listen. The bool representing the
+ * do/don't bind.
+ */
+ HW::item<bool> m_listen;
+
+ /**
+ * A map of all igmp listen keyed against a combination of the interface
+ * and group addr keys.
+ */
+ static singular_db<key_t, igmp_listen> m_db;
+};
+
+/**
+ * Ostream output for the key
+ */
+std::ostream& operator<<(std::ostream& os, const igmp_listen::key_t& key);
+};
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
+
+#endif
diff --git a/extras/vom/vom/igmp_listen_cmds.cpp b/extras/vom/vom/igmp_listen_cmds.cpp
new file mode 100644
index 00000000000..cdf0850ebc5
--- /dev/null
+++ b/extras/vom/vom/igmp_listen_cmds.cpp
@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) 2018 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "vom/igmp_listen_cmds.hpp"
+
+DEFINE_VAPI_MSG_IDS_IGMP_API_JSON;
+
+namespace VOM {
+namespace igmp_listen_cmds {
+listen_cmd::listen_cmd(HW::item<bool>& item,
+ const handle_t& itf,
+ const boost::asio::ip::address& gaddr,
+ const igmp_listen::src_addrs_t& saddrs)
+ : rpc_cmd(item)
+ , m_itf(itf)
+ , m_gaddr(gaddr)
+ , m_saddrs(saddrs)
+{
+}
+
+bool
+listen_cmd::operator==(const listen_cmd& other) const
+{
+ return ((m_itf == other.m_itf) && (m_gaddr == other.m_gaddr));
+}
+
+rc_t
+listen_cmd::issue(connection& con)
+{
+ u8 size = m_saddrs.size();
+ msg_t req(con.ctx(), sizeof(vapi_type_ip4_address) * size, std::ref(*this));
+
+ 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++;
+ }
+
+ payload.group.n_srcs = i;
+ VAPI_CALL(req.execute());
+
+ return (wait());
+}
+
+std::string
+listen_cmd::to_string() const
+{
+ auto addr = m_saddrs.cbegin();
+ std::ostringstream s;
+ s << "igmp-listen: " << m_hw_item.to_string() << " itf:" << m_itf.to_string()
+ << " group:" << m_gaddr << " src-addrs:[";
+ while (addr != m_saddrs.cend()) {
+ s << " " << *addr;
+ addr++;
+ }
+ s << " ]";
+ return (s.str());
+}
+
+unlisten_cmd::unlisten_cmd(HW::item<bool>& item,
+ const handle_t& itf,
+ const boost::asio::ip::address& gaddr)
+ : rpc_cmd(item)
+ , m_itf(itf)
+ , m_gaddr(gaddr)
+{
+}
+
+bool
+unlisten_cmd::operator==(const unlisten_cmd& other) const
+{
+ return ((m_itf == other.m_itf) && (m_gaddr == other.m_gaddr));
+}
+
+rc_t
+unlisten_cmd::issue(connection& con)
+{
+ msg_t req(con.ctx(), 0, std::ref(*this));
+
+ auto& payload = req.get_request().get_payload();
+ 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);
+
+ VAPI_CALL(req.execute());
+
+ wait();
+ m_hw_item.set(rc_t::NOOP);
+
+ return rc_t::OK;
+}
+
+std::string
+unlisten_cmd::to_string() const
+{
+ std::ostringstream s;
+ s << "igmp-unlisten: " << m_hw_item.to_string()
+ << " itf:" << m_itf.to_string() << " group:" << m_gaddr;
+
+ return (s.str());
+}
+
+dump_cmd::dump_cmd(const handle_t& hdl)
+ : m_itf(hdl)
+{
+}
+
+dump_cmd::dump_cmd(const dump_cmd& d)
+ : m_itf(d.m_itf)
+{
+}
+
+bool
+dump_cmd::operator==(const dump_cmd& other) const
+{
+ return (true);
+}
+
+rc_t
+dump_cmd::issue(connection& con)
+{
+ m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
+
+ auto& payload = m_dump->get_request().get_payload();
+ payload.sw_if_index = m_itf.value();
+
+ VAPI_CALL(m_dump->execute());
+
+ wait();
+
+ return rc_t::OK;
+}
+
+std::string
+dump_cmd::to_string() const
+{
+ return ("igmp-listen-dump");
+}
+
+}; // namespace igmp_listen_cmds
+}; // namespace VOM
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
diff --git a/extras/vom/vom/igmp_listen_cmds.hpp b/extras/vom/vom/igmp_listen_cmds.hpp
new file mode 100644
index 00000000000..c062358e4dd
--- /dev/null
+++ b/extras/vom/vom/igmp_listen_cmds.hpp
@@ -0,0 +1,162 @@
+/*
+ * Copyright (c) 2018 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __VOM_IGMP_LISTEN_CMDS_H__
+#define __VOM_IGMP_LISTEN_CMDS_H__
+
+#include "vom/dump_cmd.hpp"
+#include "vom/igmp_listen.hpp"
+#include "vom/rpc_cmd.hpp"
+
+#include <vapi/igmp.api.vapi.hpp>
+
+namespace VOM {
+namespace igmp_listen_cmds {
+
+/**
+ * A functor class that binds the igmp group to the interface
+ */
+class listen_cmd : public rpc_cmd<HW::item<bool>, vapi::Igmp_listen>
+{
+public:
+ /**
+ * Constructor
+ */
+ listen_cmd(HW::item<bool>& item,
+ const handle_t& itf,
+ const boost::asio::ip::address& gaddr,
+ const igmp_listen::src_addrs_t& saddrs);
+
+ /**
+ * Issue the command to VPP/HW
+ */
+ rc_t issue(connection& con);
+ /**
+ * convert to string format for debug purposes
+ */
+ std::string to_string() const;
+
+ /**
+ * Comparison operator - only used for UT
+ */
+ bool operator==(const listen_cmd& i) const;
+
+private:
+ /**
+ * Reference to the interface to bind to
+ */
+ const handle_t& m_itf;
+
+ /**
+ * The igmp group to bind
+ */
+ const boost::asio::ip::address& m_gaddr;
+
+ /**
+ * The igmp srouce specific addresses to listen them
+ */
+ const igmp_listen::src_addrs_t& m_saddrs;
+};
+
+/**
+ * A cmd class that Unbinds igmp group from an interface
+ */
+class unlisten_cmd : public rpc_cmd<HW::item<bool>, vapi::Igmp_listen>
+{
+public:
+ /**
+ * Constructor
+ */
+ unlisten_cmd(HW::item<bool>& item,
+ const handle_t& itf,
+ const boost::asio::ip::address& gaddr);
+
+ /**
+ * Issue the command to VPP/HW
+ */
+ rc_t issue(connection& con);
+
+ /**
+ * convert to string format for debug purposes
+ */
+ std::string to_string() const;
+
+ /**
+ * Comparison operator - only used for UT
+ */
+ bool operator==(const unlisten_cmd& i) const;
+
+private:
+ /**
+ * Reference to the interface to unbind
+ */
+ const handle_t& m_itf;
+
+ /**
+ * The igmp group to unlisten
+ */
+ const boost::asio::ip::address& m_gaddr;
+};
+
+/**
+ * A cmd class that Dumps all the igmp configs
+ */
+class dump_cmd : public VOM::dump_cmd<vapi::Igmp_dump>
+{
+public:
+ /**
+ * Constructor
+ */
+ dump_cmd(const handle_t& itf);
+ dump_cmd(const dump_cmd& d);
+
+ /**
+ * Issue the command to VPP/HW
+ */
+ rc_t issue(connection& con);
+ /**
+ * convert to string format for debug purposes
+ */
+ std::string to_string() const;
+
+ /**
+ * Comparison operator - only used for UT
+ */
+ bool operator==(const dump_cmd& i) const;
+
+private:
+ /**
+ * HW reutrn code
+ */
+ HW::item<bool> item;
+
+ /**
+ * The interface to get the igmp config for
+ */
+ const handle_t& m_itf;
+};
+
+}; // namespace igmp_listen_cmds
+}; // namespace VOM
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
+
+#endif