aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2018-12-05 04:34:27 -0800
committerNeale Ranns <nranns@cisco.com>2018-12-05 14:30:02 +0000
commit7e9affb696fcfd8f22cdce0caf46b1e2f25c5799 (patch)
tree8afdb2f45499c4f6f98ceb9e4ab1a4077d5057e4
parent661f91fe0a6bd87040408d45d116b63c0811f4f9 (diff)
VOM: interface event struct
Change-Id: If133829ba4db2da1c9c20bfbbdfc6df6276efa10 Signed-off-by: Neale Ranns <nranns@cisco.com>
-rw-r--r--extras/vom/vom/arp_proxy_binding_cmds.hpp2
-rw-r--r--extras/vom/vom/interface.cpp19
-rw-r--r--extras/vom/vom/interface.hpp26
-rw-r--r--extras/vom/vom/interface_cmds.cpp25
-rw-r--r--extras/vom/vom/ip_unnumbered_cmds.hpp1
-rw-r--r--extras/vom/vom/route_domain.hpp2
-rw-r--r--extras/vom/vom/rpc_cmd.hpp2
7 files changed, 72 insertions, 5 deletions
diff --git a/extras/vom/vom/arp_proxy_binding_cmds.hpp b/extras/vom/vom/arp_proxy_binding_cmds.hpp
index cafc1420f87..9389896c009 100644
--- a/extras/vom/vom/arp_proxy_binding_cmds.hpp
+++ b/extras/vom/vom/arp_proxy_binding_cmds.hpp
@@ -19,7 +19,7 @@
#include "vom/arp_proxy_binding.hpp"
#include "vom/dump_cmd.hpp"
-#include <vapi/vpe.api.vapi.hpp>
+#include <vapi/ip.api.vapi.hpp>
namespace VOM {
namespace arp_proxy_binding_cmds {
diff --git a/extras/vom/vom/interface.cpp b/extras/vom/vom/interface.cpp
index 371682333c7..c1894c2fbdf 100644
--- a/extras/vom/vom/interface.cpp
+++ b/extras/vom/vom/interface.cpp
@@ -39,6 +39,11 @@ std::map<handle_t, std::weak_ptr<interface>> interface::m_hdl_db;
interface::event_handler interface::m_evh;
/**
+ * the event enable command.
+ */
+std::shared_ptr<interface_cmds::events_cmd> interface::m_events_cmd;
+
+/**
* Construct a new object matching the desried state
*/
interface::interface(const std::string& name,
@@ -486,6 +491,20 @@ interface::dump(std::ostream& os)
}
void
+interface::enable_events(interface::event_listener& el)
+{
+ m_events_cmd = std::make_shared<interface_cmds::events_cmd>(el);
+ HW::enqueue(m_events_cmd);
+ HW::write();
+}
+
+void
+interface::disable_events()
+{
+ m_events_cmd.reset();
+}
+
+void
interface::event_handler::handle_populate(const client_db::key_t& key)
{
/*
diff --git a/extras/vom/vom/interface.hpp b/extras/vom/vom/interface.hpp
index 1096bcb332c..42dfa67e03d 100644
--- a/extras/vom/vom/interface.hpp
+++ b/extras/vom/vom/interface.hpp
@@ -389,6 +389,18 @@ public:
const std::string m_name;
};
+ struct event
+ {
+ event(const interface& itf, const interface::oper_state_t& state)
+ : itf(itf)
+ , state(state)
+ {
+ }
+
+ const interface& itf;
+ interface::oper_state_t state;
+ };
+
/**
* A class that listens to interface Events
*/
@@ -404,7 +416,7 @@ public:
* Virtual function called on the listener when the command has data
* ready to process
*/
- virtual void handle_interface_event(interface_cmds::events_cmd* cmd) = 0;
+ virtual void handle_interface_event(std::vector<event> es) = 0;
/**
* Return the HW::item representing the status
@@ -469,6 +481,16 @@ public:
void enable_stats(stat_listener& el,
const stats_type_t& st = stats_type_t::NORMAL);
+ /**
+ * Enable the reception of events of all interfaces
+ */
+ static void enable_events(interface::event_listener& el);
+
+ /**
+ * disable the reception of events of all interfaces
+ */
+ static void disable_events();
+
protected:
/**
* Set the handle of an interface object. Only called by the interface
@@ -658,6 +680,8 @@ private:
*/
template <typename MSG>
friend class delete_cmd;
+
+ static std::shared_ptr<interface_cmds::events_cmd> m_events_cmd;
};
};
/*
diff --git a/extras/vom/vom/interface_cmds.cpp b/extras/vom/vom/interface_cmds.cpp
index 9e2772584c0..c4fd6613a0e 100644
--- a/extras/vom/vom/interface_cmds.cpp
+++ b/extras/vom/vom/interface_cmds.cpp
@@ -441,7 +441,30 @@ events_cmd::retire(connection& con)
void
events_cmd::notify()
{
- m_listener.handle_interface_event(this);
+ std::lock_guard<interface_cmds::events_cmd> lg(*this);
+ std::vector<interface::event> events;
+
+ for (auto& msg : *this) {
+ auto& payload = msg.get_payload();
+
+ handle_t handle(payload.sw_if_index);
+ std::shared_ptr<interface> sp = interface::find(handle);
+
+ if (sp) {
+ interface::oper_state_t oper_state =
+ interface::oper_state_t::from_int(payload.link_up_down);
+
+ VOM_LOG(log_level_t::DEBUG) << "Interface Event: " << sp->to_string()
+ << " state: " << oper_state.to_string();
+
+ sp->set(oper_state);
+ events.push_back({ *sp, oper_state });
+ }
+ }
+
+ flush();
+
+ m_listener.handle_interface_event(events);
}
std::string
diff --git a/extras/vom/vom/ip_unnumbered_cmds.hpp b/extras/vom/vom/ip_unnumbered_cmds.hpp
index fdd00520404..436b0c72130 100644
--- a/extras/vom/vom/ip_unnumbered_cmds.hpp
+++ b/extras/vom/vom/ip_unnumbered_cmds.hpp
@@ -21,6 +21,7 @@
#include "vom/rpc_cmd.hpp"
#include <vapi/interface.api.vapi.hpp>
+#include <vapi/ip.api.vapi.hpp>
namespace VOM {
namespace ip_unnumbered_cmds {
diff --git a/extras/vom/vom/route_domain.hpp b/extras/vom/vom/route_domain.hpp
index 19a3c18dddc..96e46ce575b 100644
--- a/extras/vom/vom/route_domain.hpp
+++ b/extras/vom/vom/route_domain.hpp
@@ -22,8 +22,6 @@
#include "vom/prefix.hpp"
#include "vom/singular_db.hpp"
-#include <vapi/ip.api.vapi.hpp>
-
namespace VOM {
/**
* A route-domain is a VRF.
diff --git a/extras/vom/vom/rpc_cmd.hpp b/extras/vom/vom/rpc_cmd.hpp
index 1996f4b3fbe..ccb41abbd2d 100644
--- a/extras/vom/vom/rpc_cmd.hpp
+++ b/extras/vom/vom/rpc_cmd.hpp
@@ -18,6 +18,8 @@
#include <future>
+#include <vapi/vapi.hpp>
+
#include "vom/cmd.hpp"
#include "vom/logger.hpp"