* limitations under the License.
*/
-#include "vom/interface.hpp"
+#include "vom/interface_cmds.hpp"
#include "vom/cmd.hpp"
DEFINE_VAPI_MSG_IDS_VPE_API_JSON;
DEFINE_VAPI_MSG_IDS_STATS_API_JSON;
namespace VOM {
-interface::loopback_create_cmd::loopback_create_cmd(HW::item<handle_t>& item,
- const std::string& name)
+namespace interface_cmds {
+loopback_create_cmd::loopback_create_cmd(HW::item<handle_t>& item,
+ const std::string& name)
: create_cmd(item, name)
{
}
rc_t
-interface::loopback_create_cmd::issue(connection& con)
+loopback_create_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
m_hw_item = wait();
if (m_hw_item.rc() == rc_t::OK) {
- interface::add(m_name, m_hw_item);
+ insert_interface();
}
return rc_t::OK;
}
std::string
-interface::loopback_create_cmd::to_string() const
+loopback_create_cmd::to_string() const
{
std::ostringstream s;
s << "loopback-itf-create: " << m_hw_item.to_string() << " name:" << m_name;
return (s.str());
}
-interface::af_packet_create_cmd::af_packet_create_cmd(HW::item<handle_t>& item,
- const std::string& name)
+af_packet_create_cmd::af_packet_create_cmd(HW::item<handle_t>& item,
+ const std::string& name)
: create_cmd(item, name)
{
}
rc_t
-interface::af_packet_create_cmd::issue(connection& con)
+af_packet_create_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
m_hw_item = wait();
if (m_hw_item.rc() == rc_t::OK) {
- interface::add(m_name, m_hw_item);
+ insert_interface();
}
return rc_t::OK;
}
std::string
-interface::af_packet_create_cmd::to_string() const
+af_packet_create_cmd::to_string() const
{
std::ostringstream s;
s << "af-packet-itf-create: " << m_hw_item.to_string() << " name:" << m_name;
return (s.str());
}
-interface::tap_create_cmd::tap_create_cmd(HW::item<handle_t>& item,
- const std::string& name)
+tap_create_cmd::tap_create_cmd(HW::item<handle_t>& item,
+ const std::string& name)
: create_cmd(item, name)
{
}
rc_t
-interface::tap_create_cmd::issue(connection& con)
+tap_create_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
m_hw_item = wait();
if (m_hw_item.rc() == rc_t::OK) {
- interface::add(m_name, m_hw_item);
+ insert_interface();
}
return rc_t::OK;
}
std::string
-interface::tap_create_cmd::to_string() const
+tap_create_cmd::to_string() const
{
std::ostringstream s;
s << "tap-intf-create: " << m_hw_item.to_string() << " name:" << m_name;
return (s.str());
}
-interface::loopback_delete_cmd::loopback_delete_cmd(HW::item<handle_t>& item)
+loopback_delete_cmd::loopback_delete_cmd(HW::item<handle_t>& item)
: delete_cmd(item)
{
}
rc_t
-interface::loopback_delete_cmd::issue(connection& con)
+loopback_delete_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
wait();
m_hw_item.set(rc_t::NOOP);
- interface::remove(m_hw_item);
+ remove_interface();
return rc_t::OK;
}
std::string
-interface::loopback_delete_cmd::to_string() const
+loopback_delete_cmd::to_string() const
{
std::ostringstream s;
s << "loopback-itf-delete: " << m_hw_item.to_string();
return (s.str());
}
-interface::af_packet_delete_cmd::af_packet_delete_cmd(HW::item<handle_t>& item,
- const std::string& name)
+af_packet_delete_cmd::af_packet_delete_cmd(HW::item<handle_t>& item,
+ const std::string& name)
: delete_cmd(item, name)
{
}
rc_t
-interface::af_packet_delete_cmd::issue(connection& con)
+af_packet_delete_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
wait();
m_hw_item.set(rc_t::NOOP);
- interface::remove(m_hw_item);
+ remove_interface();
return rc_t::OK;
}
std::string
-interface::af_packet_delete_cmd::to_string() const
+af_packet_delete_cmd::to_string() const
{
std::ostringstream s;
s << "af_packet-itf-delete: " << m_hw_item.to_string();
return (s.str());
}
-interface::tap_delete_cmd::tap_delete_cmd(HW::item<handle_t>& item)
+tap_delete_cmd::tap_delete_cmd(HW::item<handle_t>& item)
: delete_cmd(item)
{
}
rc_t
-interface::tap_delete_cmd::issue(connection& con)
+tap_delete_cmd::issue(connection& con)
{
// finally... call VPP
- interface::remove(m_hw_item);
+ remove_interface();
return rc_t::OK;
}
std::string
-interface::tap_delete_cmd::to_string() const
+tap_delete_cmd::to_string() const
{
std::ostringstream s;
s << "tap-itf-delete: " << m_hw_item.to_string();
return (s.str());
}
-interface::state_change_cmd::state_change_cmd(
- HW::item<interface::admin_state_t>& state,
- const HW::item<handle_t>& hdl)
+state_change_cmd::state_change_cmd(HW::item<interface::admin_state_t>& state,
+ const HW::item<handle_t>& hdl)
: rpc_cmd(state)
, m_hdl(hdl)
{
}
bool
-interface::state_change_cmd::operator==(const state_change_cmd& other) const
+state_change_cmd::operator==(const state_change_cmd& other) const
{
return ((m_hdl == other.m_hdl) && (m_hw_item == other.m_hw_item));
}
rc_t
-interface::state_change_cmd::issue(connection& con)
+state_change_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
}
std::string
-interface::state_change_cmd::to_string() const
+state_change_cmd::to_string() const
{
std::ostringstream s;
s << "itf-state-change: " << m_hw_item.to_string()
return (s.str());
}
-interface::set_table_cmd::set_table_cmd(HW::item<route::table_id_t>& table,
- const l3_proto_t& proto,
- const HW::item<handle_t>& hdl)
+set_table_cmd::set_table_cmd(HW::item<route::table_id_t>& table,
+ const l3_proto_t& proto,
+ const HW::item<handle_t>& hdl)
: rpc_cmd(table)
, m_hdl(hdl)
, m_proto(proto)
}
bool
-interface::set_table_cmd::operator==(const set_table_cmd& other) const
+set_table_cmd::operator==(const set_table_cmd& other) const
{
return ((m_hdl == other.m_hdl) && (m_proto == other.m_proto) &&
(m_hw_item == other.m_hw_item));
}
rc_t
-interface::set_table_cmd::issue(connection& con)
+set_table_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
}
std::string
-interface::set_table_cmd::to_string() const
+set_table_cmd::to_string() const
{
std::ostringstream s;
s << "itf-set-table: " << m_hw_item.to_string()
return (s.str());
}
-interface::set_mac_cmd::set_mac_cmd(HW::item<l2_address_t>& mac,
- const HW::item<handle_t>& hdl)
+set_mac_cmd::set_mac_cmd(HW::item<l2_address_t>& mac,
+ const HW::item<handle_t>& hdl)
: rpc_cmd(mac)
, m_hdl(hdl)
{
}
bool
-interface::set_mac_cmd::operator==(const set_mac_cmd& other) const
+set_mac_cmd::operator==(const set_mac_cmd& other) const
{
return ((m_hdl == other.m_hdl) && (m_hw_item == other.m_hw_item));
}
rc_t
-interface::set_mac_cmd::issue(connection& con)
+set_mac_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
}
std::string
-interface::set_mac_cmd::to_string() const
+set_mac_cmd::to_string() const
{
std::ostringstream s;
s << "itf-set-mac: " << m_hw_item.to_string() << " hdl:" << m_hdl.to_string();
return (s.str());
}
-interface::events_cmd::events_cmd(event_listener& el)
+events_cmd::events_cmd(interface::event_listener& el)
: event_cmd(el.status())
, m_listener(el)
{
}
bool
-interface::events_cmd::operator==(const events_cmd& other) const
+events_cmd::operator==(const events_cmd& other) const
{
return (true);
}
rc_t
-interface::events_cmd::issue(connection& con)
+events_cmd::issue(connection& con)
{
/*
* First set the call back to handle the interface events
wait();
- return (rc_t::INPROGRESS);
+ return (rc_t::OK);
}
void
-interface::events_cmd::retire(connection& con)
+events_cmd::retire(connection& con)
{
/*
* disable interface events.
}
void
-interface::events_cmd::notify()
+events_cmd::notify()
{
m_listener.handle_interface_event(this);
}
std::string
-interface::events_cmd::to_string() const
+events_cmd::to_string() const
{
return ("itf-events");
}
/**
* Interface statistics
*/
-interface::stats_cmd::stats_cmd(stat_listener& el,
- const std::vector<handle_t>& interfaces)
+stats_enable_cmd::stats_enable_cmd(interface::stat_listener& el,
+ const handle_t& handle)
: event_cmd(el.status())
, m_listener(el)
- , m_swifindex(interfaces)
+ , m_swifindex(handle)
{
}
bool
-interface::stats_cmd::operator==(const stats_cmd& other) const
+stats_enable_cmd::operator==(const stats_enable_cmd& other) const
{
return (true);
}
rc_t
-interface::stats_cmd::issue(connection& con)
+stats_enable_cmd::issue(connection& con)
{
/*
- * First set the clal back to handle the interface stats
- */
+ * First set the call back to handle the interface stats
+ */
m_reg.reset(new reg_t(con.ctx(), std::ref(*(static_cast<event_cmd*>(this)))));
- // m_reg->execute();
/*
- * then send the request to enable them
- */
- msg_t req(con.ctx(), m_swifindex.size(),
- std::ref(*(static_cast<rpc_cmd*>(this))));
+ * then send the request to enable them
+ */
+ msg_t req(con.ctx(), 1, std::ref(*(static_cast<rpc_cmd*>(this))));
auto& payload = req.get_request().get_payload();
payload.enable_disable = 1;
payload.pid = getpid();
- payload.num = m_swifindex.size();
-
- auto it = m_swifindex.cbegin();
- uint32_t ii = 0;
- while (it != m_swifindex.cend()) {
- payload.sw_ifs[ii] = it->value();
- ++it;
- ++ii;
- }
+ payload.num = 1;
+
+ payload.sw_ifs[0] = m_swifindex.value();
VAPI_CALL(req.execute());
wait();
- return (rc_t::INPROGRESS);
+ return (rc_t::OK);
}
void
-interface::stats_cmd::retire(connection& con)
+stats_enable_cmd::retire(connection& con)
{
+ /*
+ * disable interface stats.
+ */
+ msg_t req(con.ctx(), 1, std::ref(*(static_cast<rpc_cmd*>(this))));
+
+ auto& payload = req.get_request().get_payload();
+ payload.enable_disable = 0;
+ payload.pid = getpid();
+ payload.num = 1;
+ payload.sw_ifs[0] = m_swifindex.value();
+
+ VAPI_CALL(req.execute());
+
+ wait();
}
void
-interface::stats_cmd::notify()
+stats_enable_cmd::notify()
{
m_listener.handle_interface_stat(this);
}
std::string
-interface::stats_cmd::to_string() const
+stats_enable_cmd::to_string() const
+{
+ std::ostringstream s;
+ s << "itf-stats-enable itf:" << m_swifindex.to_string();
+ return (s.str());
+}
+
+dump_cmd::dump_cmd()
+{
+}
+
+stats_disable_cmd::stats_disable_cmd(const handle_t& handle)
+ : rpc_cmd(m_res)
+ , m_swifindex(handle)
+{
+}
+
+bool
+stats_disable_cmd::operator==(const stats_disable_cmd& other) const
{
- return ("itf-stats");
+ return (true);
}
-interface::dump_cmd::dump_cmd()
+rc_t
+stats_disable_cmd::issue(connection& con)
{
+ /*
+ * then send the request to enable them
+ */
+ msg_t req(con.ctx(), 1, std::ref(*this));
+
+ auto& payload = req.get_request().get_payload();
+ payload.enable_disable = 0;
+ payload.pid = getpid();
+ payload.num = 1;
+
+ payload.sw_ifs[0] = m_swifindex.value();
+
+ VAPI_CALL(req.execute());
+
+ wait();
+
+ return (rc_t::OK);
+}
+
+std::string
+stats_disable_cmd::to_string() const
+{
+ std::ostringstream s;
+ s << "itf-stats-disable itf:" << m_swifindex.to_string();
+ return (s.str());
}
bool
-interface::dump_cmd::operator==(const dump_cmd& other) const
+dump_cmd::operator==(const dump_cmd& other) const
{
return (true);
}
rc_t
-interface::dump_cmd::issue(connection& con)
+dump_cmd::issue(connection& con)
{
m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
}
std::string
-interface::dump_cmd::to_string() const
+dump_cmd::to_string() const
{
return ("itf-dump");
}
-interface::set_tag::set_tag(HW::item<handle_t>& item, const std::string& name)
+set_tag::set_tag(HW::item<handle_t>& item, const std::string& name)
: rpc_cmd(item)
, m_name(name)
{
}
rc_t
-interface::set_tag::issue(connection& con)
+set_tag::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
return rc_t::OK;
}
std::string
-interface::set_tag::to_string() const
+set_tag::to_string() const
{
std::ostringstream s;
s << "itf-set-tag: " << m_hw_item.to_string() << " name:" << m_name;
}
bool
-interface::set_tag::operator==(const set_tag& o) const
+set_tag::operator==(const set_tag& o) const
{
return ((m_name == o.m_name) && (m_hw_item.data() == o.m_hw_item.data()));
}
-}
+}; // namespace interface_cmds
+}; // namespace VOM
+
/*
* fd.io coding-style-patch-verification: ON
*