#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 {
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
*/
db_dump(m_db, 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)
{
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
*/
* 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
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
*/
template <typename MSG>
friend class delete_cmd;
+
+ static std::shared_ptr<interface_cmds::events_cmd> m_events_cmd;
};
};
/*
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
#include "vom/rpc_cmd.hpp"
#include <vapi/interface.api.vapi.hpp>
+#include <vapi/ip.api.vapi.hpp>
namespace VOM {
namespace ip_unnumbered_cmds {
#include "vom/prefix.hpp"
#include "vom/singular_db.hpp"
-#include <vapi/ip.api.vapi.hpp>
-
namespace VOM {
/**
* A route-domain is a VRF.
#include <future>
+#include <vapi/vapi.hpp>
+
#include "vom/cmd.hpp"
#include "vom/logger.hpp"