aboutsummaryrefslogtreecommitdiffstats
path: root/src/vpp-api
diff options
context:
space:
mode:
authorNeale Ranns <neale.ranns@cisco.com>2017-11-03 04:39:05 -0700
committerNeale Ranns <nranns@cisco.com>2017-11-06 17:44:21 +0000
commit9ef1c0adbf9399c55deeede3cf629dd4e8c20304 (patch)
tree0eeed8f869eee35a48797b6b837c16222a627e46 /src/vpp-api
parentaddb55b9e0533c5f720b1cc1bdeeb4bbd0e6bf2a (diff)
VOM reshuffle
split the VOM into two halves; a top/front-end and a bottom/backend. Only the backend includes the auto-generated VAPI. This serves two purposes: 1 - improves ompile times for VOM, since the VAPI is included only in the backend. 2 - does not expose VAPI to users of VOM Change-Id: I17b93aeaef10c0eba8612016d9034aca5628d9f7 Signed-off-by: Neale Ranns <neale.ranns@cisco.com> Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
Diffstat (limited to 'src/vpp-api')
-rw-r--r--src/vpp-api/vom/Makefile.am1
-rw-r--r--src/vpp-api/vom/acl_binding.cpp72
-rw-r--r--src/vpp-api/vom/acl_binding.hpp206
-rw-r--r--src/vpp-api/vom/acl_binding_cmds.cpp21
-rw-r--r--src/vpp-api/vom/acl_binding_cmds.hpp210
-rw-r--r--src/vpp-api/vom/acl_l2_rule.cpp39
-rw-r--r--src/vpp-api/vom/acl_l2_rule.hpp10
-rw-r--r--src/vpp-api/vom/acl_l3_rule.cpp84
-rw-r--r--src/vpp-api/vom/acl_l3_rule.hpp22
-rw-r--r--src/vpp-api/vom/acl_list.cpp86
-rw-r--r--src/vpp-api/vom/acl_list.hpp216
-rw-r--r--src/vpp-api/vom/acl_list_cmds.cpp57
-rw-r--r--src/vpp-api/vom/acl_list_cmds.hpp214
-rw-r--r--src/vpp-api/vom/arp_proxy_binding.cpp13
-rw-r--r--src/vpp-api/vom/arp_proxy_binding.hpp70
-rw-r--r--src/vpp-api/vom/arp_proxy_binding_cmds.cpp25
-rw-r--r--src/vpp-api/vom/arp_proxy_binding_cmds.hpp101
-rw-r--r--src/vpp-api/vom/arp_proxy_config.cpp12
-rw-r--r--src/vpp-api/vom/arp_proxy_config.hpp76
-rw-r--r--src/vpp-api/vom/arp_proxy_config_cmds.cpp34
-rw-r--r--src/vpp-api/vom/arp_proxy_config_cmds.hpp108
-rw-r--r--src/vpp-api/vom/bridge_domain.cpp12
-rw-r--r--src/vpp-api/vom/bridge_domain.hpp91
-rw-r--r--src/vpp-api/vom/bridge_domain_arp_entry.cpp10
-rw-r--r--src/vpp-api/vom/bridge_domain_arp_entry.hpp74
-rw-r--r--src/vpp-api/vom/bridge_domain_arp_entry_cmds.cpp37
-rw-r--r--src/vpp-api/vom/bridge_domain_arp_entry_cmds.hpp107
-rw-r--r--src/vpp-api/vom/bridge_domain_cmds.cpp29
-rw-r--r--src/vpp-api/vom/bridge_domain_cmds.hpp124
-rw-r--r--src/vpp-api/vom/bridge_domain_entry.cpp14
-rw-r--r--src/vpp-api/vom/bridge_domain_entry.hpp101
-rw-r--r--src/vpp-api/vom/bridge_domain_entry_cmds.cpp38
-rw-r--r--src/vpp-api/vom/bridge_domain_entry_cmds.hpp137
-rw-r--r--src/vpp-api/vom/dhcp_config.cpp13
-rw-r--r--src/vpp-api/vom/dhcp_config.hpp149
-rw-r--r--src/vpp-api/vom/dhcp_config_cmds.cpp44
-rw-r--r--src/vpp-api/vom/dhcp_config_cmds.hpp166
-rw-r--r--src/vpp-api/vom/hw.cpp33
-rw-r--r--src/vpp-api/vom/hw.hpp34
-rw-r--r--src/vpp-api/vom/hw_cmds.cpp56
-rw-r--r--src/vpp-api/vom/hw_cmds.hpp64
-rw-r--r--src/vpp-api/vom/interface.cpp57
-rw-r--r--src/vpp-api/vom/interface.hpp443
-rw-r--r--src/vpp-api/vom/interface_cmds.cpp138
-rw-r--r--src/vpp-api/vom/interface_cmds.hpp451
-rw-r--r--src/vpp-api/vom/interface_factory.cpp17
-rw-r--r--src/vpp-api/vom/interface_factory.hpp45
-rw-r--r--src/vpp-api/vom/interface_ip6_nd.hpp2
-rw-r--r--src/vpp-api/vom/interface_span.cpp17
-rw-r--r--src/vpp-api/vom/interface_span.hpp122
-rw-r--r--src/vpp-api/vom/interface_span_cmds.cpp42
-rw-r--r--src/vpp-api/vom/interface_span_cmds.hpp154
-rw-r--r--src/vpp-api/vom/ip_unnumbered.cpp12
-rw-r--r--src/vpp-api/vom/ip_unnumbered.hpp79
-rw-r--r--src/vpp-api/vom/ip_unnumbered_cmds.cpp32
-rw-r--r--src/vpp-api/vom/ip_unnumbered_cmds.hpp114
-rw-r--r--src/vpp-api/vom/l2_binding.cpp23
-rw-r--r--src/vpp-api/vom/l2_binding.hpp136
-rw-r--r--src/vpp-api/vom/l2_binding_cmds.cpp47
-rw-r--r--src/vpp-api/vom/l2_binding_cmds.hpp170
-rw-r--r--src/vpp-api/vom/l3_binding.cpp11
-rw-r--r--src/vpp-api/vom/l3_binding.hpp122
-rw-r--r--src/vpp-api/vom/l3_binding_cmds.cpp41
-rw-r--r--src/vpp-api/vom/l3_binding_cmds.hpp158
-rw-r--r--src/vpp-api/vom/lldp_binding.cpp10
-rw-r--r--src/vpp-api/vom/lldp_binding.hpp78
-rw-r--r--src/vpp-api/vom/lldp_binding_cmds.cpp28
-rw-r--r--src/vpp-api/vom/lldp_binding_cmds.hpp112
-rw-r--r--src/vpp-api/vom/lldp_global.cpp10
-rw-r--r--src/vpp-api/vom/lldp_global.hpp2
-rw-r--r--src/vpp-api/vom/lldp_global_cmds.cpp21
-rw-r--r--src/vpp-api/vom/lldp_global_cmds.hpp80
-rw-r--r--src/vpp-api/vom/nat_binding.cpp10
-rw-r--r--src/vpp-api/vom/nat_binding.hpp124
-rw-r--r--src/vpp-api/vom/nat_binding_cmds.cpp43
-rw-r--r--src/vpp-api/vom/nat_binding_cmds.hpp131
-rw-r--r--src/vpp-api/vom/nat_static.cpp13
-rw-r--r--src/vpp-api/vom/nat_static.hpp108
-rw-r--r--src/vpp-api/vom/nat_static_cmds.cpp47
-rw-r--r--src/vpp-api/vom/nat_static_cmds.hpp142
-rw-r--r--src/vpp-api/vom/neighbour.cpp16
-rw-r--r--src/vpp-api/vom/neighbour.hpp118
-rw-r--r--src/vpp-api/vom/neighbour_cmds.cpp44
-rw-r--r--src/vpp-api/vom/neighbour_cmds.hpp145
-rw-r--r--src/vpp-api/vom/route.cpp101
-rw-r--r--src/vpp-api/vom/route.hpp148
-rw-r--r--src/vpp-api/vom/route_cmds.cpp108
-rw-r--r--src/vpp-api/vom/route_cmds.hpp173
-rw-r--r--src/vpp-api/vom/route_domain.cpp19
-rw-r--r--src/vpp-api/vom/route_domain.hpp80
-rw-r--r--src/vpp-api/vom/route_domain_cmds.cpp44
-rw-r--r--src/vpp-api/vom/route_domain_cmds.hpp114
-rw-r--r--src/vpp-api/vom/singular_db.hpp2
-rw-r--r--src/vpp-api/vom/sub_interface.cpp6
-rw-r--r--src/vpp-api/vom/sub_interface.hpp71
-rw-r--r--src/vpp-api/vom/sub_interface_cmds.cpp47
-rw-r--r--src/vpp-api/vom/sub_interface_cmds.hpp108
-rw-r--r--src/vpp-api/vom/tap_interface.cpp10
-rw-r--r--src/vpp-api/vom/tap_interface.hpp71
-rw-r--r--src/vpp-api/vom/tap_interface_cmds.cpp33
-rw-r--r--src/vpp-api/vom/tap_interface_cmds.hpp102
-rw-r--r--src/vpp-api/vom/vxlan_tunnel.cpp10
-rw-r--r--src/vpp-api/vom/vxlan_tunnel.hpp101
-rw-r--r--src/vpp-api/vom/vxlan_tunnel_cmds.cpp41
-rw-r--r--src/vpp-api/vom/vxlan_tunnel_cmds.hpp135
105 files changed, 4791 insertions, 3458 deletions
diff --git a/src/vpp-api/vom/Makefile.am b/src/vpp-api/vom/Makefile.am
index 17b846fa7a4..57ddb84b07b 100644
--- a/src/vpp-api/vom/Makefile.am
+++ b/src/vpp-api/vom/Makefile.am
@@ -57,6 +57,7 @@ libvom_la_SOURCES = \
connection.cpp \
dhcp_config_cmds.cpp \
dhcp_config.cpp \
+ hw_cmds.cpp \
hw.cpp \
inspect.cpp \
interface_cmds.cpp \
diff --git a/src/vpp-api/vom/acl_binding.cpp b/src/vpp-api/vom/acl_binding.cpp
index 1ebefda6650..832e232f871 100644
--- a/src/vpp-api/vom/acl_binding.cpp
+++ b/src/vpp-api/vom/acl_binding.cpp
@@ -14,7 +14,7 @@
*/
#include "vom/acl_binding.hpp"
-#include "vom/om.hpp"
+#include "vom/acl_binding_cmds.hpp"
namespace VOM {
namespace ACL {
@@ -25,7 +25,8 @@ l2_binding::event_handler::handle_populate(const client_db::key_t& key)
/*
* dump VPP Bridge domains
*/
- std::shared_ptr<l2_binding::dump_cmd> cmd(new l2_binding::dump_cmd());
+ std::shared_ptr<binding_cmds::l2_dump_cmd> cmd(
+ new binding_cmds::l2_dump_cmd());
HW::enqueue(cmd);
HW::write();
@@ -49,7 +50,8 @@ template <>
void
l3_binding::event_handler::handle_populate(const client_db::key_t& key)
{
- std::shared_ptr<l3_binding::dump_cmd> cmd(new l3_binding::dump_cmd());
+ std::shared_ptr<binding_cmds::l3_dump_cmd> cmd(
+ new binding_cmds::l3_dump_cmd());
HW::enqueue(cmd);
HW::write();
@@ -74,6 +76,70 @@ l3_binding::event_handler::handle_populate(const client_db::key_t& key)
}
}
}
+
+template <>
+void
+l3_binding::update(const binding& obj)
+{
+ if (!m_binding) {
+ HW::enqueue(new binding_cmds::l3_bind_cmd(
+ m_binding, m_direction, m_itf->handle(), m_acl->handle()));
+ }
+ HW::write();
+}
+
+template <>
+void
+l3_binding::sweep(void)
+{
+ if (m_binding) {
+ HW::enqueue(new binding_cmds::l3_unbind_cmd(
+ m_binding, m_direction, m_itf->handle(), m_acl->handle()));
+ }
+ HW::write();
+}
+
+template <>
+void
+l3_binding::replay(void)
+{
+ if (m_binding) {
+ HW::enqueue(new binding_cmds::l3_bind_cmd(
+ m_binding, m_direction, m_itf->handle(), m_acl->handle()));
+ }
+}
+
+template <>
+void
+l2_binding::update(const binding& obj)
+{
+ if (!m_binding) {
+ HW::enqueue(new binding_cmds::l2_bind_cmd(
+ m_binding, m_direction, m_itf->handle(), m_acl->handle()));
+ }
+ HW::write();
+}
+
+template <>
+void
+l2_binding::sweep(void)
+{
+ if (m_binding) {
+ HW::enqueue(new binding_cmds::l2_unbind_cmd(
+ m_binding, m_direction, m_itf->handle(), m_acl->handle()));
+ }
+ HW::write();
+}
+
+template <>
+void
+l2_binding::replay(void)
+{
+ if (m_binding) {
+ HW::enqueue(new binding_cmds::l2_bind_cmd(
+ m_binding, m_direction, m_itf->handle(), m_acl->handle()));
+ }
+}
};
std::ostream&
diff --git a/src/vpp-api/vom/acl_binding.hpp b/src/vpp-api/vom/acl_binding.hpp
index faf9b245cae..1e87a888ec4 100644
--- a/src/vpp-api/vom/acl_binding.hpp
+++ b/src/vpp-api/vom/acl_binding.hpp
@@ -25,7 +25,6 @@
#include "vom/interface.hpp"
#include "vom/object_base.hpp"
#include "vom/om.hpp"
-#include "vom/rpc_cmd.hpp"
#include "vom/singular_db.hpp"
namespace VOM {
@@ -34,7 +33,7 @@ namespace ACL {
* A binding between an ACL and an interface.
* A representation of the application of the ACL to the interface.
*/
-template <typename LIST, typename BIND, typename DUMP>
+template <typename LIST>
class binding : public object_base
{
public:
@@ -98,159 +97,6 @@ public:
*/
static void dump(std::ostream& os) { m_db.dump(os); }
- /**
- * A command class that binds the ACL to the interface
- */
- class bind_cmd : public rpc_cmd<HW::item<bool>, rc_t, BIND>
- {
- public:
- /**
- * Constructor
- */
- bind_cmd(HW::item<bool>& item,
- const direction_t& direction,
- const handle_t& itf,
- const handle_t& acl)
- : rpc_cmd<HW::item<bool>, rc_t, BIND>(item)
- , m_direction(direction)
- , m_itf(itf)
- , m_acl(acl)
- {
- }
-
- /**
- * Issue the command to VPP/HW
- */
- rc_t issue(connection& con);
-
- /**
- * convert to string format for debug purposes
- */
- std::string to_string() const
- {
- std::ostringstream s;
- s << "acl-bind:[" << m_direction.to_string()
- << " itf:" << m_itf.to_string() << " acl:" << m_acl.to_string() << "]";
-
- return (s.str());
- }
-
- /**
- * Comparison operator - only used for UT
- */
- bool operator==(const bind_cmd& other) const
- {
- return ((m_itf == other.m_itf) && (m_acl == m_acl));
- }
-
- private:
- /**
- * The direction of the binding
- */
- const direction_t m_direction;
-
- /**
- * The interface to bind to
- */
- const handle_t m_itf;
-
- /**
- * The ACL to bind
- */
- const handle_t m_acl;
- };
-
- /**
- * A command class that binds the ACL to the interface
- */
- class unbind_cmd : public rpc_cmd<HW::item<bool>, rc_t, BIND>
- {
- public:
- /**
- * Constructor
- */
- unbind_cmd(HW::item<bool>& item,
- const direction_t& direction,
- const handle_t& itf,
- const handle_t& acl)
- : rpc_cmd<HW::item<bool>, rc_t, BIND>(item)
- , m_direction(direction)
- , m_itf(itf)
- , m_acl(acl)
- {
- }
-
- /**
- * Issue the command to VPP/HW
- */
- rc_t issue(connection& con);
-
- /**
- * convert to string format for debug purposes
- */
- std::string to_string() const
- {
- std::ostringstream s;
- s << "acl-unbind:[" << m_direction.to_string()
- << " itf:" << m_itf.to_string() << " acl:" << m_acl.to_string() << "]";
-
- return (s.str());
- }
-
- /**
- * Comparison operator - only used for UT
- */
- bool operator==(const unbind_cmd& other) const
- {
- return ((m_itf == other.m_itf) && (m_acl == m_acl));
- }
-
- private:
- /**
- * The direction of the binding
- */
- const direction_t m_direction;
-
- /**
- * The interface to bind to
- */
- const handle_t m_itf;
-
- /**
- * The ACL to bind
- */
- const handle_t m_acl;
- };
-
- /**
- * A cmd class that Dumps all the ACLs
- */
- class dump_cmd : public VOM::dump_cmd<DUMP>
- {
- public:
- /**
- * Constructor
- */
- dump_cmd() = default;
- dump_cmd(const dump_cmd& d) = default;
-
- /**
- * Issue the command to VPP/HW
- */
- rc_t issue(connection& con);
-
- /**
- * convert to string format for debug purposes
- */
- std::string to_string() const { return ("acl-bind-dump"); }
-
- private:
- /**
- * HW reutrn code
- */
- HW::item<bool> item;
- };
-
private:
/**
* Class definition for listeners to OM events
@@ -294,14 +140,7 @@ private:
/**
* Enquue commonds to the VPP command Q for the update
*/
- void update(const binding& obj)
- {
- if (!m_binding) {
- HW::enqueue(
- new bind_cmd(m_binding, m_direction, m_itf->handle(), m_acl->handle()));
- }
- HW::write();
- }
+ void update(const binding& obj);
/**
* Find or Add the instance in the DB
@@ -325,25 +164,12 @@ private:
/**
* Sweep/reap the object if still stale
*/
- void sweep(void)
- {
- if (m_binding) {
- HW::enqueue(new unbind_cmd(m_binding, m_direction, m_itf->handle(),
- m_acl->handle()));
- }
- HW::write();
- }
+ void sweep(void);
/**
* Replay the objects state to HW
*/
- void replay(void)
- {
- if (m_binding) {
- HW::enqueue(
- new bind_cmd(m_binding, m_direction, m_itf->handle(), m_acl->handle()));
- }
- }
+ void replay(void);
/**
* The direction the of the packets on which to apply the ACL
@@ -380,30 +206,22 @@ private:
/**
* Typedef the L3 binding type
*/
-typedef binding<l3_list,
- vapi::Acl_interface_add_del,
- vapi::Acl_interface_list_dump>
- l3_binding;
+typedef binding<l3_list> l3_binding;
/**
* Typedef the L2 binding type
*/
-typedef binding<l2_list,
- vapi::Macip_acl_interface_add_del,
- vapi::Macip_acl_interface_list_dump>
- l2_binding;
+typedef binding<l2_list> l2_binding;
/**
* Definition of the static Singular DB for ACL bindings
*/
-template <typename LIST, typename BIND, typename DUMP>
-singular_db<typename ACL::binding<LIST, BIND, DUMP>::key_t,
- ACL::binding<LIST, BIND, DUMP>>
- binding<LIST, BIND, DUMP>::m_db;
-
-template <typename LIST, typename BIND, typename DUMP>
-typename ACL::binding<LIST, BIND, DUMP>::event_handler
- binding<LIST, BIND, DUMP>::m_evh;
+template <typename LIST>
+singular_db<typename ACL::binding<LIST>::key_t, ACL::binding<LIST>>
+ binding<LIST>::m_db;
+
+template <typename LIST>
+typename ACL::binding<LIST>::event_handler binding<LIST>::m_evh;
};
std::ostream& operator<<(
diff --git a/src/vpp-api/vom/acl_binding_cmds.cpp b/src/vpp-api/vom/acl_binding_cmds.cpp
index 27d50434c3b..534f7868a08 100644
--- a/src/vpp-api/vom/acl_binding_cmds.cpp
+++ b/src/vpp-api/vom/acl_binding_cmds.cpp
@@ -13,15 +13,16 @@
* limitations under the License.
*/
-#include "vom/acl_binding.hpp"
+#include "vom/acl_binding_cmds.hpp"
DEFINE_VAPI_MSG_IDS_ACL_API_JSON;
namespace VOM {
namespace ACL {
+namespace binding_cmds {
template <>
rc_t
-l3_binding::bind_cmd::issue(connection& con)
+l3_bind_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -40,7 +41,7 @@ l3_binding::bind_cmd::issue(connection& con)
template <>
rc_t
-l3_binding::unbind_cmd::issue(connection& con)
+l3_unbind_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -59,7 +60,7 @@ l3_binding::unbind_cmd::issue(connection& con)
template <>
rc_t
-l3_binding::dump_cmd::issue(connection& con)
+l3_dump_cmd::issue(connection& con)
{
m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
@@ -75,7 +76,7 @@ l3_binding::dump_cmd::issue(connection& con)
template <>
rc_t
-l2_binding::bind_cmd::issue(connection& con)
+l2_bind_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -94,7 +95,7 @@ l2_binding::bind_cmd::issue(connection& con)
template <>
rc_t
-l2_binding::unbind_cmd::issue(connection& con)
+l2_unbind_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -113,7 +114,7 @@ l2_binding::unbind_cmd::issue(connection& con)
template <>
rc_t
-l2_binding::dump_cmd::issue(connection& con)
+l2_dump_cmd::issue(connection& con)
{
m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
@@ -126,8 +127,10 @@ l2_binding::dump_cmd::issue(connection& con)
return rc_t::OK;
}
-}
-}
+
+}; // namespace binding_cmds
+}; // namespace ACL
+}; // namespace VOM
/*
* fd.io coding-style-patch-verification: ON
diff --git a/src/vpp-api/vom/acl_binding_cmds.hpp b/src/vpp-api/vom/acl_binding_cmds.hpp
new file mode 100644
index 00000000000..0bc698beef5
--- /dev/null
+++ b/src/vpp-api/vom/acl_binding_cmds.hpp
@@ -0,0 +1,210 @@
+/*
+ * Copyright (c) 2017 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_ACL_BINDING_CMDS_H__
+#define __VOM_ACL_BINDING_CMDS_H__
+
+#include "vom/acl_binding.hpp"
+#include "vom/dump_cmd.hpp"
+#include "vom/rpc_cmd.hpp"
+
+#include <vapi/acl.api.vapi.hpp>
+
+namespace VOM {
+namespace ACL {
+namespace binding_cmds {
+/**
+ * A command class that binds the ACL to the interface
+ */
+template <typename BIND>
+class bind_cmd : public rpc_cmd<HW::item<bool>, rc_t, BIND>
+{
+public:
+ /**
+ * Constructor
+ */
+ bind_cmd(HW::item<bool>& item,
+ const direction_t& direction,
+ const handle_t& itf,
+ const handle_t& acl)
+ : rpc_cmd<HW::item<bool>, rc_t, BIND>(item)
+ , m_direction(direction)
+ , m_itf(itf)
+ , m_acl(acl)
+ {
+ }
+
+ /**
+ * Issue the command to VPP/HW
+ */
+ rc_t issue(connection& con);
+
+ /**
+ * convert to string format for debug purposes
+ */
+ std::string to_string() const
+ {
+ std::ostringstream s;
+ s << "acl-bind:[" << m_direction.to_string() << " itf:" << m_itf.to_string()
+ << " acl:" << m_acl.to_string() << "]";
+
+ return (s.str());
+ }
+
+ /**
+ * Comparison operator - only used for UT
+ */
+ bool operator==(const bind_cmd& other) const
+ {
+ return ((m_itf == other.m_itf) && (m_acl == m_acl));
+ }
+
+private:
+ /**
+ * The direction of the binding
+ */
+ const direction_t m_direction;
+
+ /**
+ * The interface to bind to
+ */
+ const handle_t m_itf;
+
+ /**
+ * The ACL to bind
+ */
+ const handle_t m_acl;
+};
+
+/**
+ * A command class that binds the ACL to the interface
+ */
+template <typename BIND>
+class unbind_cmd : public rpc_cmd<HW::item<bool>, rc_t, BIND>
+{
+public:
+ /**
+ * Constructor
+ */
+ unbind_cmd(HW::item<bool>& item,
+ const direction_t& direction,
+ const handle_t& itf,
+ const handle_t& acl)
+ : rpc_cmd<HW::item<bool>, rc_t, BIND>(item)
+ , m_direction(direction)
+ , m_itf(itf)
+ , m_acl(acl)
+ {
+ }
+
+ /**
+ * Issue the command to VPP/HW
+ */
+ rc_t issue(connection& con);
+
+ /**
+ * convert to string format for debug purposes
+ */
+ std::string to_string() const
+ {
+ std::ostringstream s;
+ s << "acl-unbind:[" << m_direction.to_string()
+ << " itf:" << m_itf.to_string() << " acl:" << m_acl.to_string() << "]";
+
+ return (s.str());
+ }
+
+ /**
+ * Comparison operator - only used for UT
+ */
+ bool operator==(const unbind_cmd& other) const
+ {
+ return ((m_itf == other.m_itf) && (m_acl == m_acl));
+ }
+
+private:
+ /**
+ * The direction of the binding
+ */
+ const direction_t m_direction;
+
+ /**
+ * The interface to bind to
+ */
+ const handle_t m_itf;
+
+ /**
+ * The ACL to bind
+ */
+ const handle_t m_acl;
+};
+
+/**
+ * A cmd class that Dumps all the ACLs
+ */
+template <typename DUMP>
+class dump_cmd : public VOM::dump_cmd<DUMP>
+{
+public:
+ /**
+ * Constructor
+ */
+ dump_cmd() = default;
+ dump_cmd(const dump_cmd& d) = default;
+
+ /**
+ * Issue the command to VPP/HW
+ */
+ rc_t issue(connection& con);
+
+ /**
+ * convert to string format for debug purposes
+ */
+ std::string to_string() const { return ("acl-bind-dump"); }
+
+private:
+ /**
+ * HW reutrn code
+ */
+ HW::item<bool> item;
+};
+
+/**
+ * Typedef the L3 ACL binding commands
+ */
+typedef bind_cmd<vapi::Acl_interface_add_del> l3_bind_cmd;
+typedef unbind_cmd<vapi::Acl_interface_add_del> l3_unbind_cmd;
+typedef dump_cmd<vapi::Acl_interface_list_dump> l3_dump_cmd;
+
+/**
+ * Typedef the L2 binding type
+ */
+typedef bind_cmd<vapi::Macip_acl_interface_add_del> l2_bind_cmd;
+typedef unbind_cmd<vapi::Macip_acl_interface_add_del> l2_unbind_cmd;
+typedef dump_cmd<vapi::Macip_acl_interface_list_dump> l2_dump_cmd;
+
+}; // namespace binding_cmds
+}; // namespace ACL
+}; // namespace VOM
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
+
+#endif
diff --git a/src/vpp-api/vom/acl_l2_rule.cpp b/src/vpp-api/vom/acl_l2_rule.cpp
index 1f7f9fdabc8..1fb06e29b81 100644
--- a/src/vpp-api/vom/acl_l2_rule.cpp
+++ b/src/vpp-api/vom/acl_l2_rule.cpp
@@ -39,15 +39,6 @@ l2_rule::operator<(const l2_rule& other) const
return (other.m_priority < m_priority);
}
-void
-l2_rule::to_vpp(vapi_type_macip_acl_rule& rule) const
-{
- rule.is_permit = m_action.value();
- m_src_ip.to_vpp(&rule.is_ipv6, rule.src_ip_addr, &rule.src_ip_prefix_len);
- m_mac.to_bytes(rule.src_mac, 6);
- m_mac_mask.to_bytes(rule.src_mac_mask, 6);
-}
-
bool
l2_rule::operator==(const l2_rule& rule) const
{
@@ -67,6 +58,36 @@ l2_rule::to_string() const
return (s.str());
}
+
+uint32_t
+l2_rule::priority() const
+{
+ return m_priority;
+}
+
+action_t
+l2_rule::action() const
+{
+ return m_action;
+}
+
+const route::prefix_t&
+l2_rule::src_ip() const
+{
+ return m_src_ip;
+}
+
+const mac_address_t&
+l2_rule::mac() const
+{
+ return m_mac;
+}
+
+const mac_address_t&
+l2_rule::mac_mask() const
+{
+ return m_mac_mask;
+}
}
}
/*
diff --git a/src/vpp-api/vom/acl_l2_rule.hpp b/src/vpp-api/vom/acl_l2_rule.hpp
index cc869173011..4faa628ca11 100644
--- a/src/vpp-api/vom/acl_l2_rule.hpp
+++ b/src/vpp-api/vom/acl_l2_rule.hpp
@@ -19,8 +19,6 @@
#include "vom/acl_types.hpp"
#include "vom/prefix.hpp"
-#include <vapi/acl.api.vapi.hpp>
-
namespace VOM {
namespace ACL {
/**
@@ -68,9 +66,13 @@ public:
bool operator==(const l2_rule& rule) const;
/**
- * Convert to VPP API fromat
+ * Getters
*/
- void to_vpp(vapi_type_macip_acl_rule& rule) const;
+ uint32_t priority() const;
+ action_t action() const;
+ const route::prefix_t& src_ip() const;
+ const mac_address_t& mac() const;
+ const mac_address_t& mac_mask() const;
private:
/**
diff --git a/src/vpp-api/vom/acl_l3_rule.cpp b/src/vpp-api/vom/acl_l3_rule.cpp
index e4b40920dca..2b850af3660 100644
--- a/src/vpp-api/vom/acl_l3_rule.cpp
+++ b/src/vpp-api/vom/acl_l3_rule.cpp
@@ -43,23 +43,6 @@ l3_rule::operator<(const l3_rule& other) const
return (other.m_priority < m_priority);
}
-void
-l3_rule::to_vpp(vapi_type_acl_rule& rule) const
-{
- rule.is_permit = m_action.value();
- m_src.to_vpp(&rule.is_ipv6, rule.src_ip_addr, &rule.src_ip_prefix_len);
- m_dst.to_vpp(&rule.is_ipv6, rule.dst_ip_addr, &rule.dst_ip_prefix_len);
-
- rule.proto = m_proto;
- rule.srcport_or_icmptype_first = m_srcport_or_icmptype_first;
- rule.srcport_or_icmptype_last = m_srcport_or_icmptype_last;
- rule.dstport_or_icmpcode_first = m_dstport_or_icmpcode_first;
- rule.dstport_or_icmpcode_last = m_dstport_or_icmpcode_last;
-
- rule.tcp_flags_mask = m_tcp_flags_mask;
- rule.tcp_flags_value = m_tcp_flags_value;
-}
-
bool
l3_rule::operator==(const l3_rule& rule) const
{
@@ -144,9 +127,76 @@ l3_rule::set_tcp_flags_value(uint8_t tcp_flags_value)
{
m_tcp_flags_value = tcp_flags_value;
}
+
+const route::prefix_t&
+l3_rule::src() const
+{
+ return m_src;
+}
+
+uint32_t
+l3_rule::priority() const
+{
+ return m_priority;
+}
+
+action_t
+l3_rule::action() const
+{
+ return m_action;
+}
+
+const route::prefix_t&
+l3_rule::dst() const
+{
+ return m_dst;
+}
+
+uint8_t
+l3_rule::proto() const
+{
+ return m_proto;
+}
+
+uint16_t
+l3_rule::srcport_or_icmptype_first() const
+{
+ return m_srcport_or_icmptype_first;
+}
+
+uint16_t
+l3_rule::srcport_or_icmptype_last() const
+{
+ return m_srcport_or_icmptype_last;
}
+
+uint16_t
+l3_rule::dstport_or_icmpcode_first() const
+{
+ return m_dstport_or_icmpcode_first;
}
+uint16_t
+l3_rule::dstport_or_icmpcode_last() const
+{
+ return m_dstport_or_icmpcode_last;
+}
+
+uint8_t
+l3_rule::tcp_flags_mask() const
+{
+ return m_tcp_flags_mask;
+}
+
+uint8_t
+l3_rule::tcp_flags_value() const
+{
+ return m_tcp_flags_value;
+}
+
+}; // namespace ACL
+}; // namespace VOM
+
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/src/vpp-api/vom/acl_l3_rule.hpp b/src/vpp-api/vom/acl_l3_rule.hpp
index db3ddb41639..16a8718a99e 100644
--- a/src/vpp-api/vom/acl_l3_rule.hpp
+++ b/src/vpp-api/vom/acl_l3_rule.hpp
@@ -19,8 +19,6 @@
#include "vom/acl_types.hpp"
#include "vom/prefix.hpp"
-#include <vapi/acl.api.vapi.hpp>
-
namespace VOM {
namespace ACL {
/**
@@ -67,11 +65,6 @@ public:
bool operator==(const l3_rule& rule) const;
/**
- * Convert to VPP API fromat
- */
- void to_vpp(vapi_type_acl_rule& rule) const;
-
- /**
* Set Src Ip Address
*/
void set_src_ip(route::prefix_t src);
@@ -116,6 +109,21 @@ public:
*/
void set_tcp_flags_value(uint8_t tcp_flags_value);
+ /**
+ * Getters
+ */
+ const route::prefix_t& src() const;
+ uint32_t priority() const;
+ action_t action() const;
+ const route::prefix_t& dst() const;
+ uint8_t proto() const;
+ uint16_t srcport_or_icmptype_first() const;
+ uint16_t srcport_or_icmptype_last() const;
+ uint16_t dstport_or_icmpcode_first() const;
+ uint16_t dstport_or_icmpcode_last() const;
+ uint8_t tcp_flags_mask() const;
+ uint8_t tcp_flags_value() const;
+
private:
/**
* Priority. Used to sort the rules in a list in the order
diff --git a/src/vpp-api/vom/acl_list.cpp b/src/vpp-api/vom/acl_list.cpp
index 129be8faefe..0c92c02ad22 100644
--- a/src/vpp-api/vom/acl_list.cpp
+++ b/src/vpp-api/vom/acl_list.cpp
@@ -14,6 +14,7 @@
*/
#include "vom/acl_list.hpp"
+#include "vom/acl_list_cmds.hpp"
#include "vom/logger.hpp"
namespace VOM {
@@ -28,7 +29,7 @@ l2_list::event_handler::handle_populate(const client_db::key_t& key)
/*
* dump VPP Bridge domains
*/
- std::shared_ptr<l2_list::dump_cmd> cmd(new l2_list::dump_cmd());
+ std::shared_ptr<list_cmds::l2_dump_cmd> cmd(new list_cmds::l2_dump_cmd());
HW::enqueue(cmd);
HW::write();
@@ -69,7 +70,7 @@ l3_list::event_handler::handle_populate(const client_db::key_t& key)
/*
* dump VPP Bridge domains
*/
- std::shared_ptr<l3_list::dump_cmd> cmd(new l3_list::dump_cmd());
+ std::shared_ptr<list_cmds::l3_dump_cmd> cmd(new list_cmds::l3_dump_cmd());
HW::enqueue(cmd);
HW::write();
@@ -101,8 +102,85 @@ l3_list::event_handler::handle_populate(const client_db::key_t& key)
OM::commit(key, acl);
}
}
-};
-};
+
+template <>
+void
+l3_list::update(const l3_list& obj)
+{
+ /*
+ * always update the instance with the latest rule set
+ */
+ if (!m_hdl || obj.m_rules != m_rules) {
+ HW::enqueue(new list_cmds::l3_update_cmd(m_hdl, m_key, m_rules));
+ }
+ /*
+ * We don't, can't, read the priority from VPP,
+ * so the is equals check above does not include the priorty.
+ * but we save it now.
+ */
+ m_rules = obj.m_rules;
+}
+template <>
+void
+l2_list::update(const l2_list& obj)
+{
+ /*
+ * always update the instance with the latest rule set
+ */
+ if (!m_hdl || obj.m_rules != m_rules) {
+ HW::enqueue(new list_cmds::l2_update_cmd(m_hdl, m_key, m_rules));
+ }
+ /*
+ * We don't, can't, read the priority from VPP,
+ * so the is equals check above does not include the priorty.
+ * but we save it now.
+ */
+ m_rules = obj.m_rules;
+}
+/**
+ * Sweep/reap the object if still stale
+ */
+template <>
+void
+l3_list::sweep(void)
+{
+ if (m_hdl) {
+ HW::enqueue(new list_cmds::l3_delete_cmd(m_hdl));
+ }
+ HW::write();
+}
+template <>
+void
+l2_list::sweep(void)
+{
+ if (m_hdl) {
+ HW::enqueue(new list_cmds::l2_delete_cmd(m_hdl));
+ }
+ HW::write();
+}
+
+/**
+ * Replay the objects state to HW
+ */
+template <>
+void
+l3_list::replay(void)
+{
+ if (m_hdl) {
+ HW::enqueue(new list_cmds::l3_update_cmd(m_hdl, m_key, m_rules));
+ }
+}
+template <>
+void
+l2_list::replay(void)
+{
+ if (m_hdl) {
+ HW::enqueue(new list_cmds::l2_update_cmd(m_hdl, m_key, m_rules));
+ }
+}
+
+}; // namespace ACL
+}; // namespace VOM
/*
* fd.io coding-style-patch-verification: ON
diff --git a/src/vpp-api/vom/acl_list.hpp b/src/vpp-api/vom/acl_list.hpp
index a2b512727d7..0835cea5d48 100644
--- a/src/vpp-api/vom/acl_list.hpp
+++ b/src/vpp-api/vom/acl_list.hpp
@@ -21,15 +21,11 @@
#include "vom/acl_l2_rule.hpp"
#include "vom/acl_l3_rule.hpp"
#include "vom/acl_types.hpp"
-#include "vom/dump_cmd.hpp"
#include "vom/hw.hpp"
#include "vom/inspect.hpp"
#include "vom/om.hpp"
-#include "vom/rpc_cmd.hpp"
#include "vom/singular_db.hpp"
-#include <vapi/acl.api.vapi.hpp>
-
namespace VOM {
namespace ACL {
/**
@@ -37,7 +33,7 @@ namespace ACL {
* packets.
* A list is bound to a given interface.
*/
-template <typename RULE, typename UPDATE, typename DELETE, typename DUMP>
+template <typename RULE>
class list : public object_base
{
public:
@@ -135,158 +131,6 @@ public:
*/
const handle_t& handle() const { return m_hdl.data(); }
- /**
- * A command class that Create the list
- */
- class update_cmd
- : public rpc_cmd<HW::item<handle_t>, HW::item<handle_t>, UPDATE>
- {
- public:
- /**
- * Constructor
- */
- update_cmd(HW::item<handle_t>& item, const key_t& key, const rules_t& rules)
- : rpc_cmd<HW::item<handle_t>, HW::item<handle_t>, UPDATE>(item)
- , m_key(key)
- , m_rules(rules)
- {
- }
-
- /**
- * Issue the command to VPP/HW
- */
- rc_t issue(connection& con);
-
- /**
- * convert to string format for debug purposes
- */
- std::string to_string() const
- {
- std::ostringstream s;
- s << "ACL-list-update: " << this->item().to_string();
-
- return (s.str());
- }
-
- /**
- * Comparison operator - only used for UT
- */
- bool operator==(const update_cmd& other) const
- {
- return ((m_key == other.m_key) && (m_rules == other.m_rules));
- }
-
- void complete()
- {
- std::shared_ptr<list> sp = find(m_key);
- if (sp && this->item()) {
- list::add(this->item().data(), sp);
- }
- }
-
- void succeeded()
- {
- rpc_cmd<HW::item<handle_t>, HW::item<handle_t>, UPDATE>::succeeded();
- complete();
- }
-
- /**
- * A callback function for handling ACL creates
- */
- virtual vapi_error_e operator()(UPDATE& reply)
- {
- int acl_index = reply.get_response().get_payload().acl_index;
- int retval = reply.get_response().get_payload().retval;
-
- VOM_LOG(log_level_t::DEBUG) << this->to_string() << " " << retval;
-
- HW::item<handle_t> res(acl_index, rc_t::from_vpp_retval(retval));
-
- this->fulfill(res);
-
- return (VAPI_OK);
- }
-
- private:
- /**
- * The key.
- */
- const key_t& m_key;
-
- /**
- * The rules
- */
- const rules_t& m_rules;
- };
-
- /**
- * A cmd class that Deletes an ACL
- */
- class delete_cmd : public rpc_cmd<HW::item<handle_t>, rc_t, DELETE>
- {
- public:
- /**
- * Constructor
- */
- delete_cmd(HW::item<handle_t>& item)
- : rpc_cmd<HW::item<handle_t>, rc_t, DELETE>(item)
- {
- }
-
- /**
- * Issue the command to VPP/HW
- */
- rc_t issue(connection& con) { return (rc_t::INVALID); }
-
- /**
- * convert to string format for debug purposes
- */
- std::string to_string() const
- {
- std::ostringstream s;
- s << "ACL-list-delete: " << this->item().to_string();
-
- return (s.str());
- }
-
- /**
- * Comparison operator - only used for UT
- */
- bool operator==(const delete_cmd& other) const
- {
- return (this->item().data() == other.item().data());
- }
- };
-
- /**
- * A cmd class that Dumps all the ACLs
- */
- class dump_cmd : public VOM::dump_cmd<DUMP>
- {
- public:
- /**
- * Constructor
- */
- dump_cmd() = default;
- dump_cmd(const dump_cmd& d) = default;
-
- /**
- * Issue the command to VPP/HW
- */
- rc_t issue(connection& con) { return rc_t::INVALID; }
-
- /**
- * convert to string format for debug purposes
- */
- std::string to_string() const { return ("acl-list-dump"); }
-
- private:
- /**
- * HW reutrn code
- */
- HW::item<bool> item;
- };
-
static std::shared_ptr<list> find(const handle_t& handle)
{
return (m_hdl_db[handle].lock());
@@ -345,23 +189,9 @@ private:
static event_handler m_evh;
/**
- * Enquue commonds to the VPP command Q for the update
+ * Enqueue commands to the VPP command Q for the update
*/
- void update(const list& obj)
- {
- /*
- * always update the instance with the latest rule set
- */
- if (!m_hdl || obj.m_rules != m_rules) {
- HW::enqueue(new update_cmd(m_hdl, m_key, m_rules));
- }
- /*
- * We don't, can't, read the priority from VPP,
- * so the is equals check above does not include the priorty.
- * but we save it now.
- */
- m_rules = obj.m_rules;
- }
+ void update(const list& obj);
/**
* HW assigned handle
@@ -389,23 +219,12 @@ private:
/**
* Sweep/reap the object if still stale
*/
- void sweep(void)
- {
- if (m_hdl) {
- HW::enqueue(new delete_cmd(m_hdl));
- }
- HW::write();
- }
+ void sweep(void);
/**
* Replay the objects state to HW
*/
- void replay(void)
- {
- if (m_hdl) {
- HW::enqueue(new update_cmd(m_hdl, m_key, m_rules));
- }
- }
+ void replay(void);
/**
* A map of all ACL's against the client's key
@@ -431,36 +250,27 @@ private:
/**
* Typedef the L3 ACL type
*/
-typedef list<l3_rule, vapi::Acl_add_replace, vapi::Acl_del, vapi::Acl_dump>
- l3_list;
+typedef list<l3_rule> l3_list;
/**
* Typedef the L2 ACL type
*/
-typedef list<l2_rule,
- vapi::Macip_acl_add,
- vapi::Macip_acl_del,
- vapi::Macip_acl_dump>
- l2_list;
+typedef list<l2_rule> l2_list;
/**
* Definition of the static singular_db for ACL Lists
*/
-template <typename RULE, typename UPDATE, typename DELETE, typename DUMP>
-singular_db<typename ACL::list<RULE, UPDATE, DELETE, DUMP>::key_t,
- ACL::list<RULE, UPDATE, DELETE, DUMP>>
- list<RULE, UPDATE, DELETE, DUMP>::m_db;
+template <typename RULE>
+singular_db<typename ACL::list<RULE>::key_t, ACL::list<RULE>> list<RULE>::m_db;
/**
* Definition of the static per-handle DB for ACL Lists
*/
-template <typename RULE, typename UPDATE, typename DELETE, typename DUMP>
-std::map<const handle_t, std::weak_ptr<ACL::list<RULE, UPDATE, DELETE, DUMP>>>
- list<RULE, UPDATE, DELETE, DUMP>::m_hdl_db;
+template <typename RULE>
+std::map<const handle_t, std::weak_ptr<ACL::list<RULE>>> list<RULE>::m_hdl_db;
-template <typename RULE, typename UPDATE, typename DELETE, typename DUMP>
-typename ACL::list<RULE, UPDATE, DELETE, DUMP>::event_handler
- list<RULE, UPDATE, DELETE, DUMP>::m_evh;
+template <typename RULE>
+typename ACL::list<RULE>::event_handler list<RULE>::m_evh;
};
};
diff --git a/src/vpp-api/vom/acl_list_cmds.cpp b/src/vpp-api/vom/acl_list_cmds.cpp
index 9bbe2cd76c4..80df04ef145 100644
--- a/src/vpp-api/vom/acl_list_cmds.cpp
+++ b/src/vpp-api/vom/acl_list_cmds.cpp
@@ -13,13 +13,46 @@
* limitations under the License.
*/
-#include "vom/acl_list.hpp"
+#include "vom/acl_list_cmds.hpp"
namespace VOM {
namespace ACL {
+namespace list_cmds {
+/*
+ * Jumping through hoops to not expose the VAPI types publically
+ */
+static void
+to_vpp(const l2_rule& rule, vapi_type_macip_acl_rule& payload)
+{
+ payload.is_permit = rule.action().value();
+ rule.src_ip().to_vpp(&payload.is_ipv6, payload.src_ip_addr,
+ &payload.src_ip_prefix_len);
+ rule.mac().to_bytes(payload.src_mac, 6);
+ rule.mac_mask().to_bytes(payload.src_mac_mask, 6);
+}
+
+static void
+to_vpp(const l3_rule& rule, vapi_type_acl_rule& payload)
+{
+ payload.is_permit = rule.action().value();
+ rule.src().to_vpp(&payload.is_ipv6, payload.src_ip_addr,
+ &payload.src_ip_prefix_len);
+ rule.dst().to_vpp(&payload.is_ipv6, payload.dst_ip_addr,
+ &payload.dst_ip_prefix_len);
+
+ payload.proto = rule.proto();
+ payload.srcport_or_icmptype_first = rule.srcport_or_icmptype_first();
+ payload.srcport_or_icmptype_last = rule.srcport_or_icmptype_last();
+ payload.dstport_or_icmpcode_first = rule.dstport_or_icmpcode_first();
+ payload.dstport_or_icmpcode_last = rule.dstport_or_icmpcode_last();
+
+ payload.tcp_flags_mask = rule.tcp_flags_mask();
+ payload.tcp_flags_value = rule.tcp_flags_value();
+}
+
template <>
rc_t
-l3_list::update_cmd::issue(connection& con)
+l3_update_cmd::issue(connection& con)
{
msg_t req(con.ctx(), m_rules.size(), std::ref(*this));
uint32_t ii = 0;
@@ -34,7 +67,7 @@ l3_list::update_cmd::issue(connection& con)
auto it = m_rules.cbegin();
while (it != m_rules.cend()) {
- it->to_vpp(payload.r[ii]);
+ to_vpp(*it, payload.r[ii]);
++it;
++ii;
}
@@ -49,7 +82,7 @@ l3_list::update_cmd::issue(connection& con)
template <>
rc_t
-l3_list::delete_cmd::issue(connection& con)
+l3_delete_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -66,7 +99,7 @@ l3_list::delete_cmd::issue(connection& con)
template <>
rc_t
-l3_list::dump_cmd::issue(connection& con)
+l3_dump_cmd::issue(connection& con)
{
m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
@@ -82,7 +115,7 @@ l3_list::dump_cmd::issue(connection& con)
template <>
rc_t
-l2_list::update_cmd::issue(connection& con)
+l2_update_cmd::issue(connection& con)
{
msg_t req(con.ctx(), m_rules.size(), std::ref(*this));
uint32_t ii = 0;
@@ -97,7 +130,7 @@ l2_list::update_cmd::issue(connection& con)
auto it = m_rules.cbegin();
while (it != m_rules.cend()) {
- it->to_vpp(payload.r[ii]);
+ to_vpp(*it, payload.r[ii]);
++it;
++ii;
}
@@ -111,7 +144,7 @@ l2_list::update_cmd::issue(connection& con)
template <>
rc_t
-l2_list::delete_cmd::issue(connection& con)
+l2_delete_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -128,7 +161,7 @@ l2_list::delete_cmd::issue(connection& con)
template <>
rc_t
-l2_list::dump_cmd::issue(connection& con)
+l2_dump_cmd::issue(connection& con)
{
m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
@@ -141,8 +174,10 @@ l2_list::dump_cmd::issue(connection& con)
return rc_t::OK;
}
-}
-}
+
+}; // namespace list_cmds
+}; // namespace ACL
+}; // namespace VOM
/*
* fd.io coding-style-patch-verification: ON
diff --git a/src/vpp-api/vom/acl_list_cmds.hpp b/src/vpp-api/vom/acl_list_cmds.hpp
new file mode 100644
index 00000000000..e4aa950bdce
--- /dev/null
+++ b/src/vpp-api/vom/acl_list_cmds.hpp
@@ -0,0 +1,214 @@
+/*
+ * Copyright (c) 2017 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_ACL_LIST_CMDS_H__
+#define __VOM_ACL_LIST_CMDS_H__
+
+#include "vom/acl_list.hpp"
+#include "vom/dump_cmd.hpp"
+#include "vom/rpc_cmd.hpp"
+
+#include <vapi/acl.api.vapi.hpp>
+
+namespace VOM {
+namespace ACL {
+namespace list_cmds {
+/**
+ * A command class that Create the list
+ */
+template <typename RULE, typename UPDATE>
+class update_cmd
+ : public rpc_cmd<HW::item<handle_t>, HW::item<handle_t>, UPDATE>
+{
+public:
+ typedef typename list<RULE>::rules_t cmd_rules_t;
+ typedef typename list<RULE>::key_t cmd_key_t;
+
+ /**
+ * Constructor
+ */
+ update_cmd(HW::item<handle_t>& item,
+ const cmd_key_t& key,
+ const cmd_rules_t& rules)
+ : rpc_cmd<HW::item<handle_t>, HW::item<handle_t>, UPDATE>(item)
+ , m_key(key)
+ , m_rules(rules)
+ {
+ }
+
+ /**
+ * Issue the command to VPP/HW
+ */
+ rc_t issue(connection& con);
+
+ /**
+ * convert to string format for debug purposes
+ */
+ std::string to_string() const
+ {
+ std::ostringstream s;
+ s << "ACL-list-update: " << this->item().to_string();
+
+ return (s.str());
+ }
+
+ /**
+ * Comparison operator - only used for UT
+ */
+ bool operator==(const update_cmd& other) const
+ {
+ return ((m_key == other.m_key) && (m_rules == other.m_rules));
+ }
+
+ void complete()
+ {
+ std::shared_ptr<list<RULE>> sp = list<RULE>::find(m_key);
+ if (sp && this->item()) {
+ list<RULE>::add(this->item().data(), sp);
+ }
+ }
+
+ void succeeded()
+ {
+ rpc_cmd<HW::item<handle_t>, HW::item<handle_t>, UPDATE>::succeeded();
+ complete();
+ }
+
+ /**
+ * A callback function for handling ACL creates
+ */
+ virtual vapi_error_e operator()(UPDATE& reply)
+ {
+ int acl_index = reply.get_response().get_payload().acl_index;
+ int retval = reply.get_response().get_payload().retval;
+
+ VOM_LOG(log_level_t::DEBUG) << this->to_string() << " " << retval;
+
+ HW::item<handle_t> res(acl_index, rc_t::from_vpp_retval(retval));
+
+ this->fulfill(res);
+
+ return (VAPI_OK);
+ }
+
+private:
+ /**
+ * The key.
+ */
+ const cmd_key_t& m_key;
+
+ /**
+ * The rules
+ */
+ const cmd_rules_t& m_rules;
+};
+
+/**
+ * A cmd class that Deletes an ACL
+ */
+template <typename DELETE>
+class delete_cmd : public rpc_cmd<HW::item<handle_t>, rc_t, DELETE>
+{
+public:
+ /**
+ * Constructor
+ */
+ delete_cmd(HW::item<handle_t>& item)
+ : rpc_cmd<HW::item<handle_t>, rc_t, DELETE>(item)
+ {
+ }
+
+ /**
+ * Issue the command to VPP/HW
+ */
+ rc_t issue(connection& con) { return (rc_t::INVALID); }
+
+ /**
+ * convert to string format for debug purposes
+ */
+ std::string to_string() const
+ {
+ std::ostringstream s;
+ s << "ACL-list-delete: " << this->item().to_string();
+
+ return (s.str());
+ }
+
+ /**
+ * Comparison operator - only used for UT
+ */
+ bool operator==(const delete_cmd& other) const
+ {
+ return (this->item().data() == other.item().data());
+ }
+};
+
+/**
+ * A cmd class that Dumps all the ACLs
+ */
+template <typename DUMP>
+class dump_cmd : public VOM::dump_cmd<DUMP>
+{
+public:
+ /**
+ * Constructor
+ */
+ dump_cmd() = default;
+ dump_cmd(const dump_cmd& d) = default;
+
+ /**
+ * Issue the command to VPP/HW
+ */
+ rc_t issue(connection& con) { return rc_t::INVALID; }
+
+ /**
+ * convert to string format for debug purposes
+ */
+ std::string to_string() const { return ("acl-list-dump"); }
+
+private:
+ /**
+ * HW reutrn code
+ */
+ HW::item<bool> item;
+};
+
+/**
+ * Typedef the L3 ACL commands
+ */
+typedef update_cmd<l3_rule, vapi::Acl_add_replace> l3_update_cmd;
+typedef delete_cmd<vapi::Acl_del> l3_delete_cmd;
+typedef dump_cmd<vapi::Acl_dump> l3_dump_cmd;
+
+/**
+ * Typedef the L2 ACL commands
+ */
+typedef update_cmd<l2_rule, vapi::Macip_acl_add> l2_update_cmd;
+typedef delete_cmd<vapi::Macip_acl_del> l2_delete_cmd;
+typedef dump_cmd<vapi::Macip_acl_dump> l2_dump_cmd;
+
+}; // namespace list_cmds
+}; // namespace ACL
+}; // namespace VOM
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
+
+#endif
diff --git a/src/vpp-api/vom/arp_proxy_binding.cpp b/src/vpp-api/vom/arp_proxy_binding.cpp
index 77b1bfaacde..c44cda3cebf 100644
--- a/src/vpp-api/vom/arp_proxy_binding.cpp
+++ b/src/vpp-api/vom/arp_proxy_binding.cpp
@@ -14,12 +14,12 @@
*/
#include "vom/arp_proxy_binding.hpp"
-#include "vom/cmd.hpp"
+#include "vom/arp_proxy_binding_cmds.hpp"
namespace VOM {
/**
- * A DB of all LLDP configs
+ * A DB of all ARP proxy bindings configs
*/
singular_db<interface::key_type, arp_proxy_binding> arp_proxy_binding::m_db;
@@ -52,7 +52,8 @@ void
arp_proxy_binding::sweep()
{
if (m_binding) {
- HW::enqueue(new unbind_cmd(m_binding, m_itf->handle()));
+ HW::enqueue(
+ new arp_proxy_binding_cmds::unbind_cmd(m_binding, m_itf->handle()));
}
HW::write();
}
@@ -67,7 +68,8 @@ void
arp_proxy_binding::replay()
{
if (m_binding) {
- HW::enqueue(new bind_cmd(m_binding, m_itf->handle()));
+ HW::enqueue(
+ new arp_proxy_binding_cmds::bind_cmd(m_binding, m_itf->handle()));
}
}
@@ -87,7 +89,8 @@ arp_proxy_binding::update(const arp_proxy_binding& desired)
* the desired state is always that the interface should be created
*/
if (!m_binding) {
- HW::enqueue(new bind_cmd(m_binding, m_itf->handle()));
+ HW::enqueue(
+ new arp_proxy_binding_cmds::bind_cmd(m_binding, m_itf->handle()));
}
}
diff --git a/src/vpp-api/vom/arp_proxy_binding.hpp b/src/vpp-api/vom/arp_proxy_binding.hpp
index 0d316476a8f..2ee814aa129 100644
--- a/src/vpp-api/vom/arp_proxy_binding.hpp
+++ b/src/vpp-api/vom/arp_proxy_binding.hpp
@@ -17,17 +17,13 @@
#define __VOM_ARP_PROXY_BINDING_H__
#include "vom/arp_proxy_config.hpp"
-#include "vom/dump_cmd.hpp"
#include "vom/hw.hpp"
#include "vom/inspect.hpp"
#include "vom/interface.hpp"
#include "vom/object_base.hpp"
#include "vom/om.hpp"
-#include "vom/rpc_cmd.hpp"
#include "vom/singular_db.hpp"
-#include <vapi/vpe.api.vapi.hpp>
-
namespace VOM {
/**
* A representation of LLDP client configuration on an interface
@@ -65,72 +61,6 @@ public:
*/
static void dump(std::ostream& os);
- /**
- * A command class that binds the LLDP config to the interface
- */
- class bind_cmd
- : public rpc_cmd<HW::item<bool>, rc_t, vapi::Proxy_arp_intfc_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 ArpProxy Config from an interface
- */
- class unbind_cmd
- : public rpc_cmd<HW::item<bool>, rc_t, vapi::Proxy_arp_intfc_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;
- };
-
private:
/**
* Class definition for listeners to OM events
diff --git a/src/vpp-api/vom/arp_proxy_binding_cmds.cpp b/src/vpp-api/vom/arp_proxy_binding_cmds.cpp
index d7f31883885..675feef9b8d 100644
--- a/src/vpp-api/vom/arp_proxy_binding_cmds.cpp
+++ b/src/vpp-api/vom/arp_proxy_binding_cmds.cpp
@@ -13,24 +13,25 @@
* limitations under the License.
*/
-#include "vom/arp_proxy_binding.hpp"
+#include "vom/arp_proxy_binding_cmds.hpp"
namespace VOM {
+namespace arp_proxy_binding_cmds {
-arp_proxy_binding::bind_cmd::bind_cmd(HW::item<bool>& item, const handle_t& itf)
+bind_cmd::bind_cmd(HW::item<bool>& item, const handle_t& itf)
: rpc_cmd(item)
, m_itf(itf)
{
}
bool
-arp_proxy_binding::bind_cmd::operator==(const bind_cmd& other) const
+bind_cmd::operator==(const bind_cmd& other) const
{
return (m_itf == other.m_itf);
}
rc_t
-arp_proxy_binding::bind_cmd::issue(connection& con)
+bind_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -46,7 +47,7 @@ arp_proxy_binding::bind_cmd::issue(connection& con)
}
std::string
-arp_proxy_binding::bind_cmd::to_string() const
+bind_cmd::to_string() const
{
std::ostringstream s;
s << "ARP-proxy-bind: " << m_hw_item.to_string()
@@ -55,21 +56,20 @@ arp_proxy_binding::bind_cmd::to_string() const
return (s.str());
}
-arp_proxy_binding::unbind_cmd::unbind_cmd(HW::item<bool>& item,
- const handle_t& itf)
+unbind_cmd::unbind_cmd(HW::item<bool>& item, const handle_t& itf)
: rpc_cmd(item)
, m_itf(itf)
{
}
bool
-arp_proxy_binding::unbind_cmd::operator==(const unbind_cmd& other) const
+unbind_cmd::operator==(const unbind_cmd& other) const
{
return (m_itf == other.m_itf);
}
rc_t
-arp_proxy_binding::unbind_cmd::issue(connection& con)
+unbind_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -86,7 +86,7 @@ arp_proxy_binding::unbind_cmd::issue(connection& con)
}
std::string
-arp_proxy_binding::unbind_cmd::to_string() const
+unbind_cmd::to_string() const
{
std::ostringstream s;
s << "ARP-proxy-unbind: " << m_hw_item.to_string()
@@ -94,7 +94,10 @@ arp_proxy_binding::unbind_cmd::to_string() const
return (s.str());
}
-}
+
+}; // namespace arp_proxy_binding_cmds
+}; // namespace VOM
+
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/src/vpp-api/vom/arp_proxy_binding_cmds.hpp b/src/vpp-api/vom/arp_proxy_binding_cmds.hpp
new file mode 100644
index 00000000000..c73bb13aee3
--- /dev/null
+++ b/src/vpp-api/vom/arp_proxy_binding_cmds.hpp
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2017 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_ARP_PROXY_BINDING_CMDS_H__
+#define __VOM_ARP_PROXY_BINDING_CMDS_H__
+
+#include "vom/arp_proxy_binding.hpp"
+
+#include <vapi/vpe.api.vapi.hpp>
+
+namespace VOM {
+namespace arp_proxy_binding_cmds {
+/**
+ * A command class that binds the LLDP config to the interface
+ */
+class bind_cmd
+ : public rpc_cmd<HW::item<bool>, rc_t, vapi::Proxy_arp_intfc_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 ArpProxy Config from an interface
+ */
+class unbind_cmd
+ : public rpc_cmd<HW::item<bool>, rc_t, vapi::Proxy_arp_intfc_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;
+};
+};
+};
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
+
+#endif
diff --git a/src/vpp-api/vom/arp_proxy_config.cpp b/src/vpp-api/vom/arp_proxy_config.cpp
index c07eef3c6c6..5130ba8d850 100644
--- a/src/vpp-api/vom/arp_proxy_config.cpp
+++ b/src/vpp-api/vom/arp_proxy_config.cpp
@@ -14,12 +14,9 @@
*/
#include "vom/arp_proxy_config.hpp"
-#include "vom/cmd.hpp"
+#include "vom/arp_proxy_config_cmds.hpp"
namespace VOM {
-/**
- * A DB of all LLDP configs
- */
singular_db<arp_proxy_config::key_t, arp_proxy_config> arp_proxy_config::m_db;
arp_proxy_config::event_handler arp_proxy_config::m_evh;
@@ -51,7 +48,8 @@ void
arp_proxy_config::sweep()
{
if (m_config) {
- HW::enqueue(new unconfig_cmd(m_config, m_low, m_high));
+ HW::enqueue(
+ new arp_proxy_config_cmds::unconfig_cmd(m_config, m_low, m_high));
}
HW::write();
}
@@ -66,7 +64,7 @@ void
arp_proxy_config::replay()
{
if (m_config) {
- HW::enqueue(new config_cmd(m_config, m_low, m_high));
+ HW::enqueue(new arp_proxy_config_cmds::config_cmd(m_config, m_low, m_high));
}
}
@@ -84,7 +82,7 @@ void
arp_proxy_config::update(const arp_proxy_config& desired)
{
if (!m_config) {
- HW::enqueue(new config_cmd(m_config, m_low, m_high));
+ HW::enqueue(new arp_proxy_config_cmds::config_cmd(m_config, m_low, m_high));
}
}
diff --git a/src/vpp-api/vom/arp_proxy_config.hpp b/src/vpp-api/vom/arp_proxy_config.hpp
index 78fc81a894a..3a50633de4d 100644
--- a/src/vpp-api/vom/arp_proxy_config.hpp
+++ b/src/vpp-api/vom/arp_proxy_config.hpp
@@ -16,16 +16,12 @@
#ifndef __VOM_ARP_PROXY_CONFIG_H__
#define __VOM_ARP_PROXY_CONFIG_H__
-#include "vom/dump_cmd.hpp"
#include "vom/hw.hpp"
#include "vom/inspect.hpp"
#include "vom/object_base.hpp"
#include "vom/om.hpp"
-#include "vom/rpc_cmd.hpp"
#include "vom/singular_db.hpp"
-#include <vapi/vpe.api.vapi.hpp>
-
namespace VOM {
/**
* A representation of LLDP client configuration on an interface
@@ -70,78 +66,6 @@ public:
*/
static void dump(std::ostream& os);
- /**
- * A command class that adds the ARP Proxy config
- */
- class config_cmd
- : public rpc_cmd<HW::item<bool>, rc_t, vapi::Proxy_arp_add_del>
- {
- public:
- /**
- * Constructor
- */
- config_cmd(HW::item<bool>& item,
- const boost::asio::ip::address_v4& lo,
- const boost::asio::ip::address_v4& high);
-
- /**
- * 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 config_cmd& i) const;
-
- private:
- /**
- * Address range
- */
- const boost::asio::ip::address_v4 m_low;
- const boost::asio::ip::address_v4 m_high;
- };
-
- /**
- * A cmd class that Unconfigs ArpProxy Config from an interface
- */
- class unconfig_cmd
- : public rpc_cmd<HW::item<bool>, rc_t, vapi::Proxy_arp_add_del>
- {
- public:
- /**
- * Constructor
- */
- unconfig_cmd(HW::item<bool>& item,
- const boost::asio::ip::address_v4& lo,
- const boost::asio::ip::address_v4& hig);
-
- /**
- * 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 unconfig_cmd& i) const;
-
- private:
- /**
- * Address range
- */
- const boost::asio::ip::address_v4 m_low;
- const boost::asio::ip::address_v4 m_high;
- };
-
private:
/**
* Class definition for listeners to OM events
diff --git a/src/vpp-api/vom/arp_proxy_config_cmds.cpp b/src/vpp-api/vom/arp_proxy_config_cmds.cpp
index 0a546d3c1b0..cf7fad5d90d 100644
--- a/src/vpp-api/vom/arp_proxy_config_cmds.cpp
+++ b/src/vpp-api/vom/arp_proxy_config_cmds.cpp
@@ -13,15 +13,14 @@
* limitations under the License.
*/
-#include "vom/arp_proxy_config.hpp"
-
-#include <vapi/vpe.api.vapi.hpp>
+#include "vom/arp_proxy_config_cmds.hpp"
namespace VOM {
-arp_proxy_config::config_cmd::config_cmd(
- HW::item<bool>& item,
- const boost::asio::ip::address_v4& low,
- const boost::asio::ip::address_v4& high)
+namespace arp_proxy_config_cmds {
+
+config_cmd::config_cmd(HW::item<bool>& item,
+ const boost::asio::ip::address_v4& low,
+ const boost::asio::ip::address_v4& high)
: rpc_cmd(item)
, m_low(low)
, m_high(high)
@@ -29,13 +28,13 @@ arp_proxy_config::config_cmd::config_cmd(
}
bool
-arp_proxy_config::config_cmd::operator==(const config_cmd& o) const
+config_cmd::operator==(const config_cmd& o) const
{
return ((m_low == o.m_low) && (m_high == o.m_high));
}
rc_t
-arp_proxy_config::config_cmd::issue(connection& con)
+config_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -55,7 +54,7 @@ arp_proxy_config::config_cmd::issue(connection& con)
}
std::string
-arp_proxy_config::config_cmd::to_string() const
+config_cmd::to_string() const
{
std::ostringstream s;
s << "ARP-proxy-config: " << m_hw_item.to_string()
@@ -64,10 +63,9 @@ arp_proxy_config::config_cmd::to_string() const
return (s.str());
}
-arp_proxy_config::unconfig_cmd::unconfig_cmd(
- HW::item<bool>& item,
- const boost::asio::ip::address_v4& low,
- const boost::asio::ip::address_v4& high)
+unconfig_cmd::unconfig_cmd(HW::item<bool>& item,
+ const boost::asio::ip::address_v4& low,
+ const boost::asio::ip::address_v4& high)
: rpc_cmd(item)
, m_low(low)
, m_high(high)
@@ -75,13 +73,13 @@ arp_proxy_config::unconfig_cmd::unconfig_cmd(
}
bool
-arp_proxy_config::unconfig_cmd::operator==(const unconfig_cmd& o) const
+unconfig_cmd::operator==(const unconfig_cmd& o) const
{
return ((m_low == o.m_low) && (m_high == o.m_high));
}
rc_t
-arp_proxy_config::unconfig_cmd::issue(connection& con)
+unconfig_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -102,7 +100,7 @@ arp_proxy_config::unconfig_cmd::issue(connection& con)
}
std::string
-arp_proxy_config::unconfig_cmd::to_string() const
+unconfig_cmd::to_string() const
{
std::ostringstream s;
s << "ARP-proxy-unconfig: " << m_hw_item.to_string()
@@ -111,6 +109,8 @@ arp_proxy_config::unconfig_cmd::to_string() const
return (s.str());
}
}
+}
+
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/src/vpp-api/vom/arp_proxy_config_cmds.hpp b/src/vpp-api/vom/arp_proxy_config_cmds.hpp
new file mode 100644
index 00000000000..042ed18bee1
--- /dev/null
+++ b/src/vpp-api/vom/arp_proxy_config_cmds.hpp
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2017 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_ARP_PROXY_CONFIG_CMDS_H__
+#define __VOM_ARP_PROXY_CONFIG_CMDS_H__
+
+#include "vom/arp_proxy_config.hpp"
+#include "vom/dump_cmd.hpp"
+#include "vom/rpc_cmd.hpp"
+
+#include <vapi/vpe.api.vapi.hpp>
+
+namespace VOM {
+namespace arp_proxy_config_cmds {
+/**
+ * A command class that adds the ARP Proxy config
+ */
+class config_cmd : public rpc_cmd<HW::item<bool>, rc_t, vapi::Proxy_arp_add_del>
+{
+public:
+ /**
+ * Constructor
+ */
+ config_cmd(HW::item<bool>& item,
+ const boost::asio::ip::address_v4& lo,
+ const boost::asio::ip::address_v4& high);
+
+ /**
+ * 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 config_cmd& i) const;
+
+private:
+ /**
+ * Address range
+ */
+ const boost::asio::ip::address_v4 m_low;
+ const boost::asio::ip::address_v4 m_high;
+};
+
+/**
+ * A cmd class that Unconfigs ArpProxy Config from an interface
+ */
+class unconfig_cmd
+ : public rpc_cmd<HW::item<bool>, rc_t, vapi::Proxy_arp_add_del>
+{
+public:
+ /**
+ * Constructor
+ */
+ unconfig_cmd(HW::item<bool>& item,
+ const boost::asio::ip::address_v4& lo,
+ const boost::asio::ip::address_v4& hig);
+
+ /**
+ * 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 unconfig_cmd& i) const;
+
+private:
+ /**
+ * Address range
+ */
+ const boost::asio::ip::address_v4 m_low;
+ const boost::asio::ip::address_v4 m_high;
+};
+};
+};
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
+
+#endif
diff --git a/src/vpp-api/vom/bridge_domain.cpp b/src/vpp-api/vom/bridge_domain.cpp
index 5831b2ae224..8e012b5d951 100644
--- a/src/vpp-api/vom/bridge_domain.cpp
+++ b/src/vpp-api/vom/bridge_domain.cpp
@@ -14,10 +14,9 @@
*/
#include "vom/bridge_domain.hpp"
-#include "vom/cmd.hpp"
+#include "vom/bridge_domain_cmds.hpp"
#include "vom/interface.hpp"
#include "vom/l2_binding.hpp"
-#include "vom/logger.hpp"
namespace VOM {
/**
@@ -50,7 +49,7 @@ void
bridge_domain::sweep()
{
if (rc_t::OK == m_id.rc()) {
- HW::enqueue(new delete_cmd(m_id));
+ HW::enqueue(new bridge_domain_cmds::delete_cmd(m_id));
}
HW::write();
}
@@ -59,7 +58,7 @@ void
bridge_domain::replay()
{
if (rc_t::OK == m_id.rc()) {
- HW::enqueue(new create_cmd(m_id));
+ HW::enqueue(new bridge_domain_cmds::create_cmd(m_id));
}
}
@@ -117,7 +116,7 @@ bridge_domain::update(const bridge_domain& desired)
* the desired state is always that the interface should be created
*/
if (rc_t::OK != m_id.rc()) {
- HW::enqueue(new create_cmd(m_id));
+ HW::enqueue(new bridge_domain_cmds::create_cmd(m_id));
}
}
@@ -145,7 +144,8 @@ bridge_domain::event_handler::handle_populate(const client_db::key_t& key)
/*
* dump VPP Bridge domains
*/
- std::shared_ptr<bridge_domain::dump_cmd> cmd(new bridge_domain::dump_cmd());
+ std::shared_ptr<bridge_domain_cmds::dump_cmd> cmd(
+ new bridge_domain_cmds::dump_cmd());
HW::enqueue(cmd);
HW::write();
diff --git a/src/vpp-api/vom/bridge_domain.hpp b/src/vpp-api/vom/bridge_domain.hpp
index 70371fa0f46..b42f53fce7b 100644
--- a/src/vpp-api/vom/bridge_domain.hpp
+++ b/src/vpp-api/vom/bridge_domain.hpp
@@ -16,17 +16,13 @@
#ifndef __VOM_BRIDGE_DOMAIN_H__
#define __VOM_BRIDGE_DOMAIN_H__
-#include "vom/dump_cmd.hpp"
#include "vom/enum_base.hpp"
#include "vom/hw.hpp"
#include "vom/inspect.hpp"
#include "vom/object_base.hpp"
#include "vom/om.hpp"
-#include "vom/rpc_cmd.hpp"
#include "vom/singular_db.hpp"
-#include <vapi/l2.api.vapi.hpp>
-
namespace VOM {
/**
* A base class for all object_base in the VPP object_base-Model.
@@ -78,93 +74,6 @@ public:
*/
static void dump(std::ostream& os);
- /**
- * A command class that creates an Bridge-Domain
- */
- class create_cmd
- : public rpc_cmd<HW::item<uint32_t>, rc_t, vapi::Bridge_domain_add_del>
- {
- public:
- /**
- * Constructor
- */
- create_cmd(HW::item<uint32_t>& item);
-
- /**
- * 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 create_cmd& i) const;
- };
-
- /**
- * A cmd class that Delete an Bridge-Domain
- */
- class delete_cmd
- : public rpc_cmd<HW::item<uint32_t>, rc_t, vapi::Bridge_domain_add_del>
- {
- public:
- /**
- * Constructor
- */
- delete_cmd(HW::item<uint32_t>& item);
-
- /**
- * 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 delete_cmd& i) const;
- };
-
- /**
- * A cmd class that Dumps all the IPv4 L3 configs
- */
- class dump_cmd : public VOM::dump_cmd<vapi::Bridge_domain_dump>
- {
- public:
- /**
- * Constructor
- */
- dump_cmd();
- 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;
- };
-
private:
/**
* Class definition for listeners to OM events
diff --git a/src/vpp-api/vom/bridge_domain_arp_entry.cpp b/src/vpp-api/vom/bridge_domain_arp_entry.cpp
index e2bf6d5e97c..ee34dbbce5b 100644
--- a/src/vpp-api/vom/bridge_domain_arp_entry.cpp
+++ b/src/vpp-api/vom/bridge_domain_arp_entry.cpp
@@ -14,6 +14,7 @@
*/
#include "vom/bridge_domain_arp_entry.hpp"
+#include "vom/bridge_domain_arp_entry_cmds.hpp"
namespace VOM {
@@ -70,7 +71,8 @@ void
bridge_domain_arp_entry::sweep()
{
if (m_hw) {
- HW::enqueue(new delete_cmd(m_hw, m_bd->id(), m_mac, m_ip_addr));
+ HW::enqueue(new bridge_domain_arp_entry_cmds::delete_cmd(m_hw, m_bd->id(),
+ m_mac, m_ip_addr));
}
HW::write();
}
@@ -79,7 +81,8 @@ void
bridge_domain_arp_entry::replay()
{
if (m_hw) {
- HW::enqueue(new create_cmd(m_hw, m_bd->id(), m_mac, m_ip_addr));
+ HW::enqueue(new bridge_domain_arp_entry_cmds::create_cmd(m_hw, m_bd->id(),
+ m_mac, m_ip_addr));
}
}
@@ -100,7 +103,8 @@ bridge_domain_arp_entry::update(const bridge_domain_arp_entry& r)
* create the table if it is not yet created
*/
if (rc_t::OK != m_hw.rc()) {
- HW::enqueue(new create_cmd(m_hw, m_bd->id(), m_mac, m_ip_addr));
+ HW::enqueue(new bridge_domain_arp_entry_cmds::create_cmd(m_hw, m_bd->id(),
+ m_mac, m_ip_addr));
}
}
diff --git a/src/vpp-api/vom/bridge_domain_arp_entry.hpp b/src/vpp-api/vom/bridge_domain_arp_entry.hpp
index 181afe6c8a5..caad96b88db 100644
--- a/src/vpp-api/vom/bridge_domain_arp_entry.hpp
+++ b/src/vpp-api/vom/bridge_domain_arp_entry.hpp
@@ -21,8 +21,6 @@
#include "vom/singular_db.hpp"
#include "vom/types.hpp"
-#include <vapi/l2.api.vapi.hpp>
-
namespace VOM {
/**
* A entry in the ARP termination table of a Bridge Domain
@@ -85,78 +83,6 @@ public:
*/
std::string to_string() const;
- /**
- * A command class that creates or updates the bridge domain ARP Entry
- */
- class create_cmd
- : public rpc_cmd<HW::item<bool>, rc_t, vapi::Bd_ip_mac_add_del>
- {
- public:
- /**
- * Constructor
- */
- create_cmd(HW::item<bool>& item,
- uint32_t id,
- const mac_address_t& mac,
- const boost::asio::ip::address& ip_addr);
-
- /**
- * 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 create_cmd& i) const;
-
- private:
- uint32_t m_bd;
- mac_address_t m_mac;
- boost::asio::ip::address m_ip_addr;
- };
-
- /**
- * A cmd class that deletes a bridge domain ARP entry
- */
- class delete_cmd
- : public rpc_cmd<HW::item<bool>, rc_t, vapi::Bd_ip_mac_add_del>
- {
- public:
- /**
- * Constructor
- */
- delete_cmd(HW::item<bool>& item,
- uint32_t id,
- const mac_address_t& mac,
- const boost::asio::ip::address& ip_addr);
-
- /**
- * 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 delete_cmd& i) const;
-
- private:
- uint32_t m_bd;
- mac_address_t m_mac;
- boost::asio::ip::address m_ip_addr;
- };
-
private:
/**
* Class definition for listeners to OM events
diff --git a/src/vpp-api/vom/bridge_domain_arp_entry_cmds.cpp b/src/vpp-api/vom/bridge_domain_arp_entry_cmds.cpp
index 3ea63adb09f..824dcadad02 100644
--- a/src/vpp-api/vom/bridge_domain_arp_entry_cmds.cpp
+++ b/src/vpp-api/vom/bridge_domain_arp_entry_cmds.cpp
@@ -13,15 +13,15 @@
* limitations under the License.
*/
-#include "vom/bridge_domain_arp_entry.hpp"
+#include "vom/bridge_domain_arp_entry_cmds.hpp"
namespace VOM {
+namespace bridge_domain_arp_entry_cmds {
-bridge_domain_arp_entry::create_cmd::create_cmd(
- HW::item<bool>& item,
- uint32_t bd,
- const mac_address_t& mac,
- const boost::asio::ip::address& ip_addr)
+create_cmd::create_cmd(HW::item<bool>& item,
+ uint32_t bd,
+ const mac_address_t& mac,
+ const boost::asio::ip::address& ip_addr)
: rpc_cmd(item)
, m_bd(bd)
, m_mac(mac)
@@ -30,14 +30,14 @@ bridge_domain_arp_entry::create_cmd::create_cmd(
}
bool
-bridge_domain_arp_entry::create_cmd::operator==(const create_cmd& other) const
+create_cmd::operator==(const create_cmd& other) const
{
return ((m_mac == other.m_mac) && (m_ip_addr == other.m_ip_addr) &&
(m_bd == other.m_bd));
}
rc_t
-bridge_domain_arp_entry::create_cmd::issue(connection& con)
+create_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -55,7 +55,7 @@ bridge_domain_arp_entry::create_cmd::issue(connection& con)
}
std::string
-bridge_domain_arp_entry::create_cmd::to_string() const
+create_cmd::to_string() const
{
std::ostringstream s;
s << "bridge-domain-arp-entry-create: " << m_hw_item.to_string()
@@ -65,11 +65,10 @@ bridge_domain_arp_entry::create_cmd::to_string() const
return (s.str());
}
-bridge_domain_arp_entry::delete_cmd::delete_cmd(
- HW::item<bool>& item,
- uint32_t bd,
- const mac_address_t& mac,
- const boost::asio::ip::address& ip_addr)
+delete_cmd::delete_cmd(HW::item<bool>& item,
+ uint32_t bd,
+ const mac_address_t& mac,
+ const boost::asio::ip::address& ip_addr)
: rpc_cmd(item)
, m_bd(bd)
, m_mac(mac)
@@ -78,14 +77,14 @@ bridge_domain_arp_entry::delete_cmd::delete_cmd(
}
bool
-bridge_domain_arp_entry::delete_cmd::operator==(const delete_cmd& other) const
+delete_cmd::operator==(const delete_cmd& other) const
{
return ((m_mac == other.m_mac) && (m_ip_addr == other.m_ip_addr) &&
(m_bd == other.m_bd));
}
rc_t
-bridge_domain_arp_entry::delete_cmd::issue(connection& con)
+delete_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -104,7 +103,7 @@ bridge_domain_arp_entry::delete_cmd::issue(connection& con)
}
std::string
-bridge_domain_arp_entry::delete_cmd::to_string() const
+delete_cmd::to_string() const
{
std::ostringstream s;
s << "bridge-domain-arp-entry-delete: " << m_hw_item.to_string()
@@ -113,7 +112,9 @@ bridge_domain_arp_entry::delete_cmd::to_string() const
return (s.str());
}
-}
+
+}; // namespace bridge_domain_arp_entry
+}; // namespace VOM
/*
* fd.io coding-style-patch-verification: ON
diff --git a/src/vpp-api/vom/bridge_domain_arp_entry_cmds.hpp b/src/vpp-api/vom/bridge_domain_arp_entry_cmds.hpp
new file mode 100644
index 00000000000..094de4c7fb6
--- /dev/null
+++ b/src/vpp-api/vom/bridge_domain_arp_entry_cmds.hpp
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2017 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_BRIDGE_DOMAIN_ARP_ENTRY_CMDS_H__
+#define __VOM_BRIDGE_DOMAIN_ARP_ENTRY_CMDS_H__
+
+#include "vom/bridge_domain_arp_entry.hpp"
+
+#include <vapi/l2.api.vapi.hpp>
+#include <vapi/vpe.api.vapi.hpp>
+
+namespace VOM {
+namespace bridge_domain_arp_entry_cmds {
+
+/**
+* A command class that creates or updates the bridge domain ARP Entry
+*/
+class create_cmd : public rpc_cmd<HW::item<bool>, rc_t, vapi::Bd_ip_mac_add_del>
+{
+public:
+ /**
+ * Constructor
+ */
+ create_cmd(HW::item<bool>& item,
+ uint32_t id,
+ const mac_address_t& mac,
+ const boost::asio::ip::address& ip_addr);
+
+ /**
+ * 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 create_cmd& i) const;
+
+private:
+ uint32_t m_bd;
+ mac_address_t m_mac;
+ boost::asio::ip::address m_ip_addr;
+};
+
+/**
+ * A cmd class that deletes a bridge domain ARP entry
+ */
+class delete_cmd : public rpc_cmd<HW::item<bool>, rc_t, vapi::Bd_ip_mac_add_del>
+{
+public:
+ /**
+ * Constructor
+ */
+ delete_cmd(HW::item<bool>& item,
+ uint32_t id,
+ const mac_address_t& mac,
+ const boost::asio::ip::address& ip_addr);
+
+ /**
+ * 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 delete_cmd& i) const;
+
+private:
+ uint32_t m_bd;
+ mac_address_t m_mac;
+ boost::asio::ip::address m_ip_addr;
+};
+};
+};
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
+
+#endif
diff --git a/src/vpp-api/vom/bridge_domain_cmds.cpp b/src/vpp-api/vom/bridge_domain_cmds.cpp
index 91173393cce..1b9dc1cff99 100644
--- a/src/vpp-api/vom/bridge_domain_cmds.cpp
+++ b/src/vpp-api/vom/bridge_domain_cmds.cpp
@@ -13,25 +13,25 @@
* limitations under the License.
*/
-#include "vom/bridge_domain.hpp"
-#include "vom/cmd.hpp"
+#include "vom/bridge_domain_cmds.hpp"
DEFINE_VAPI_MSG_IDS_L2_API_JSON;
namespace VOM {
-bridge_domain::create_cmd::create_cmd(HW::item<uint32_t>& item)
+namespace bridge_domain_cmds {
+create_cmd::create_cmd(HW::item<uint32_t>& item)
: rpc_cmd(item)
{
}
bool
-bridge_domain::create_cmd::operator==(const create_cmd& other) const
+create_cmd::operator==(const create_cmd& other) const
{
return (m_hw_item.data() == other.m_hw_item.data());
}
rc_t
-bridge_domain::create_cmd::issue(connection& con)
+create_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -53,7 +53,7 @@ bridge_domain::create_cmd::issue(connection& con)
}
std::string
-bridge_domain::create_cmd::to_string() const
+create_cmd::to_string() const
{
std::ostringstream s;
s << "bridge-domain-create: " << m_hw_item.to_string();
@@ -61,19 +61,19 @@ bridge_domain::create_cmd::to_string() const
return (s.str());
}
-bridge_domain::delete_cmd::delete_cmd(HW::item<uint32_t>& item)
+delete_cmd::delete_cmd(HW::item<uint32_t>& item)
: rpc_cmd(item)
{
}
bool
-bridge_domain::delete_cmd::operator==(const delete_cmd& other) const
+delete_cmd::operator==(const delete_cmd& other) const
{
return (m_hw_item == other.m_hw_item);
}
rc_t
-bridge_domain::delete_cmd::issue(connection& con)
+delete_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -90,7 +90,7 @@ bridge_domain::delete_cmd::issue(connection& con)
}
std::string
-bridge_domain::delete_cmd::to_string() const
+delete_cmd::to_string() const
{
std::ostringstream s;
s << "bridge-domain-delete: " << m_hw_item.to_string();
@@ -98,18 +98,18 @@ bridge_domain::delete_cmd::to_string() const
return (s.str());
}
-bridge_domain::dump_cmd::dump_cmd()
+dump_cmd::dump_cmd()
{
}
bool
-bridge_domain::dump_cmd::operator==(const dump_cmd& other) const
+dump_cmd::operator==(const dump_cmd& other) const
{
return (true);
}
rc_t
-bridge_domain::dump_cmd::issue(connection& con)
+dump_cmd::issue(connection& con)
{
m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
@@ -124,11 +124,12 @@ bridge_domain::dump_cmd::issue(connection& con)
}
std::string
-bridge_domain::dump_cmd::to_string() const
+dump_cmd::to_string() const
{
return ("bridge-domain-dump");
}
}
+}
/*
* fd.io coding-style-patch-verification: ON
diff --git a/src/vpp-api/vom/bridge_domain_cmds.hpp b/src/vpp-api/vom/bridge_domain_cmds.hpp
new file mode 100644
index 00000000000..c6226fd339b
--- /dev/null
+++ b/src/vpp-api/vom/bridge_domain_cmds.hpp
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2017 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_BRIDGE_DOMAIN_CMDS_H__
+#define __VOM_BRIDGE_DOMAIN_CMDS_H__
+
+#include "vom/bridge_domain.hpp"
+#include "vom/dump_cmd.hpp"
+#include "vom/rpc_cmd.hpp"
+
+#include <vapi/l2.api.vapi.hpp>
+
+namespace VOM {
+namespace bridge_domain_cmds {
+/**
+ * A command class that creates an Bridge-Domain
+ */
+class create_cmd
+ : public rpc_cmd<HW::item<uint32_t>, rc_t, vapi::Bridge_domain_add_del>
+{
+public:
+ /**
+ * Constructor
+ */
+ create_cmd(HW::item<uint32_t>& item);
+
+ /**
+ * 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 create_cmd& i) const;
+};
+
+/**
+ * A cmd class that Delete an Bridge-Domain
+ */
+class delete_cmd
+ : public rpc_cmd<HW::item<uint32_t>, rc_t, vapi::Bridge_domain_add_del>
+{
+public:
+ /**
+ * Constructor
+ */
+ delete_cmd(HW::item<uint32_t>& item);
+
+ /**
+ * 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 delete_cmd& i) const;
+};
+
+/**
+ * A cmd class that Dumps all the IPv4 L3 configs
+ */
+class dump_cmd : public VOM::dump_cmd<vapi::Bridge_domain_dump>
+{
+public:
+ /**
+ * Constructor
+ */
+ dump_cmd();
+ 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;
+};
+};
+};
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
+
+#endif
diff --git a/src/vpp-api/vom/bridge_domain_entry.cpp b/src/vpp-api/vom/bridge_domain_entry.cpp
index 7a1245b0f4d..343d82d3ffa 100644
--- a/src/vpp-api/vom/bridge_domain_entry.cpp
+++ b/src/vpp-api/vom/bridge_domain_entry.cpp
@@ -14,6 +14,7 @@
*/
#include "vom/bridge_domain_entry.hpp"
+#include "vom/bridge_domain_entry_cmds.hpp"
namespace VOM {
singular_db<bridge_domain_entry::key_t, bridge_domain_entry>
@@ -66,7 +67,8 @@ void
bridge_domain_entry::sweep()
{
if (m_hw) {
- HW::enqueue(new delete_cmd(m_hw, m_mac, m_bd->id()));
+ HW::enqueue(
+ new bridge_domain_entry_cmds::delete_cmd(m_hw, m_mac, m_bd->id()));
}
HW::write();
}
@@ -75,7 +77,8 @@ void
bridge_domain_entry::replay()
{
if (m_hw) {
- HW::enqueue(new create_cmd(m_hw, m_mac, m_bd->id(), m_tx_itf->handle()));
+ HW::enqueue(new bridge_domain_entry_cmds::create_cmd(
+ m_hw, m_mac, m_bd->id(), m_tx_itf->handle()));
}
}
std::string
@@ -95,7 +98,8 @@ bridge_domain_entry::update(const bridge_domain_entry& r)
* create the table if it is not yet created
*/
if (rc_t::OK != m_hw.rc()) {
- HW::enqueue(new create_cmd(m_hw, m_mac, m_bd->id(), m_tx_itf->handle()));
+ HW::enqueue(new bridge_domain_entry_cmds::create_cmd(
+ m_hw, m_mac, m_bd->id(), m_tx_itf->handle()));
}
}
@@ -133,8 +137,8 @@ bridge_domain_entry::event_handler::handle_replay()
void
bridge_domain_entry::event_handler::handle_populate(const client_db::key_t& key)
{
- std::shared_ptr<bridge_domain_entry::dump_cmd> cmd(
- new bridge_domain_entry::dump_cmd());
+ std::shared_ptr<bridge_domain_entry_cmds::dump_cmd> cmd(
+ new bridge_domain_entry_cmds::dump_cmd());
HW::enqueue(cmd);
HW::write();
diff --git a/src/vpp-api/vom/bridge_domain_entry.hpp b/src/vpp-api/vom/bridge_domain_entry.hpp
index 073b2d37a1d..35ea8b68f50 100644
--- a/src/vpp-api/vom/bridge_domain_entry.hpp
+++ b/src/vpp-api/vom/bridge_domain_entry.hpp
@@ -20,8 +20,6 @@
#include "vom/interface.hpp"
#include "vom/singular_db.hpp"
-#include <vapi/l2.api.vapi.hpp>
-
namespace VOM {
/**
* A MAC forwarding entry in the bridge-domain/L2-FIB
@@ -82,105 +80,6 @@ public:
*/
std::string to_string() const;
- /**
- * A command class that creates or updates the bridge_domain
- */
- class create_cmd : public rpc_cmd<HW::item<bool>, rc_t, vapi::L2fib_add_del>
- {
- public:
- /**
- * Constructor
- */
- create_cmd(HW::item<bool>& item,
- const mac_address_t& mac,
- uint32_t id,
- handle_t tx_intf);
-
- /**
- * 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 create_cmd& i) const;
-
- private:
- mac_address_t m_mac;
- uint32_t m_bd;
- handle_t m_tx_itf;
- };
-
- /**
- * A cmd class that deletes a bridge_domain
- */
- class delete_cmd : public rpc_cmd<HW::item<bool>, rc_t, vapi::L2fib_add_del>
- {
- public:
- /**
- * Constructor
- */
- delete_cmd(HW::item<bool>& item, const mac_address_t& mac, uint32_t id);
-
- /**
- * 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 delete_cmd& i) const;
-
- private:
- mac_address_t m_mac;
- uint32_t m_bd;
- };
-
- /**
- * A cmd class that Dumps all the interface spans
- */
- class dump_cmd : public VOM::dump_cmd<vapi::L2_fib_table_dump>
- {
- public:
- /**
- * Constructor
- */
- dump_cmd();
- 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;
- };
-
private:
/**
* Class definition for listeners to OM events
diff --git a/src/vpp-api/vom/bridge_domain_entry_cmds.cpp b/src/vpp-api/vom/bridge_domain_entry_cmds.cpp
index 990af069a90..ddb8bf14f12 100644
--- a/src/vpp-api/vom/bridge_domain_entry_cmds.cpp
+++ b/src/vpp-api/vom/bridge_domain_entry_cmds.cpp
@@ -13,13 +13,14 @@
* limitations under the License.
*/
-#include "vom/bridge_domain_entry.hpp"
+#include "vom/bridge_domain_entry_cmds.hpp"
namespace VOM {
-bridge_domain_entry::create_cmd::create_cmd(HW::item<bool>& item,
- const mac_address_t& mac,
- uint32_t bd,
- handle_t tx_itf)
+namespace bridge_domain_entry_cmds {
+create_cmd::create_cmd(HW::item<bool>& item,
+ const mac_address_t& mac,
+ uint32_t bd,
+ handle_t tx_itf)
: rpc_cmd(item)
, m_mac(mac)
, m_bd(bd)
@@ -28,14 +29,14 @@ bridge_domain_entry::create_cmd::create_cmd(HW::item<bool>& item,
}
bool
-bridge_domain_entry::create_cmd::operator==(const create_cmd& other) const
+create_cmd::operator==(const create_cmd& other) const
{
return ((m_mac == other.m_mac) && (m_tx_itf == other.m_tx_itf) &&
(m_bd == other.m_bd));
}
rc_t
-bridge_domain_entry::create_cmd::issue(connection& con)
+create_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -53,7 +54,7 @@ bridge_domain_entry::create_cmd::issue(connection& con)
}
std::string
-bridge_domain_entry::create_cmd::to_string() const
+create_cmd::to_string() const
{
std::ostringstream s;
s << "bridge-domain-entry-create: " << m_hw_item.to_string() << " bd:" << m_bd
@@ -62,9 +63,9 @@ bridge_domain_entry::create_cmd::to_string() const
return (s.str());
}
-bridge_domain_entry::delete_cmd::delete_cmd(HW::item<bool>& item,
- const mac_address_t& mac,
- uint32_t bd)
+delete_cmd::delete_cmd(HW::item<bool>& item,
+ const mac_address_t& mac,
+ uint32_t bd)
: rpc_cmd(item)
, m_mac(mac)
, m_bd(bd)
@@ -72,13 +73,13 @@ bridge_domain_entry::delete_cmd::delete_cmd(HW::item<bool>& item,
}
bool
-bridge_domain_entry::delete_cmd::operator==(const delete_cmd& other) const
+delete_cmd::operator==(const delete_cmd& other) const
{
return ((m_mac == other.m_mac) && (m_bd == other.m_bd));
}
rc_t
-bridge_domain_entry::delete_cmd::issue(connection& con)
+delete_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -97,7 +98,7 @@ bridge_domain_entry::delete_cmd::issue(connection& con)
}
std::string
-bridge_domain_entry::delete_cmd::to_string() const
+delete_cmd::to_string() const
{
std::ostringstream s;
s << "bridge-domain-entry-delete: " << m_hw_item.to_string() << " bd:" << m_bd
@@ -106,18 +107,18 @@ bridge_domain_entry::delete_cmd::to_string() const
return (s.str());
}
-bridge_domain_entry::dump_cmd::dump_cmd()
+dump_cmd::dump_cmd()
{
}
bool
-bridge_domain_entry::dump_cmd::operator==(const dump_cmd& other) const
+dump_cmd::operator==(const dump_cmd& other) const
{
return (true);
}
rc_t
-bridge_domain_entry::dump_cmd::issue(connection& con)
+dump_cmd::issue(connection& con)
{
m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
@@ -132,11 +133,12 @@ bridge_domain_entry::dump_cmd::issue(connection& con)
}
std::string
-bridge_domain_entry::dump_cmd::to_string() const
+dump_cmd::to_string() const
{
return ("bridge-domain-entry-dump");
}
}
+}
/*
* fd.io coding-style-patch-verification: ON
diff --git a/src/vpp-api/vom/bridge_domain_entry_cmds.hpp b/src/vpp-api/vom/bridge_domain_entry_cmds.hpp
new file mode 100644
index 00000000000..780c376b020
--- /dev/null
+++ b/src/vpp-api/vom/bridge_domain_entry_cmds.hpp
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2017 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_BRIDGE_DOMAIN_ENTRY_CMDS_H__
+#define __VOM_BRIDGE_DOMAIN_ENTRY_CMDS_H__
+
+#include "vom/bridge_domain_entry.hpp"
+#include "vom/dump_cmd.hpp"
+#include "vom/rpc_cmd.hpp"
+
+#include <vapi/l2.api.vapi.hpp>
+
+namespace VOM {
+namespace bridge_domain_entry_cmds {
+
+/**
+* A command class that creates or updates the bridge_domain
+*/
+class create_cmd : public rpc_cmd<HW::item<bool>, rc_t, vapi::L2fib_add_del>
+{
+public:
+ /**
+ * Constructor
+ */
+ create_cmd(HW::item<bool>& item,
+ const mac_address_t& mac,
+ uint32_t id,
+ handle_t tx_intf);
+
+ /**
+ * 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 create_cmd& i) const;
+
+private:
+ mac_address_t m_mac;
+ uint32_t m_bd;
+ handle_t m_tx_itf;
+};
+
+/**
+ * A cmd class that deletes a bridge_domain
+ */
+class delete_cmd : public rpc_cmd<HW::item<bool>, rc_t, vapi::L2fib_add_del>
+{
+public:
+ /**
+ * Constructor
+ */
+ delete_cmd(HW::item<bool>& item, const mac_address_t& mac, uint32_t id);
+
+ /**
+ * 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 delete_cmd& i) const;
+
+private:
+ mac_address_t m_mac;
+ uint32_t m_bd;
+};
+
+/**
+ * A cmd class that Dumps all the interface spans
+ */
+class dump_cmd : public VOM::dump_cmd<vapi::L2_fib_table_dump>
+{
+public:
+ /**
+ * Constructor
+ */
+ dump_cmd();
+ 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;
+};
+};
+};
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
+
+#endif
diff --git a/src/vpp-api/vom/dhcp_config.cpp b/src/vpp-api/vom/dhcp_config.cpp
index bf9b036b919..a7299267334 100644
--- a/src/vpp-api/vom/dhcp_config.cpp
+++ b/src/vpp-api/vom/dhcp_config.cpp
@@ -14,7 +14,7 @@
*/
#include "vom/dhcp_config.hpp"
-#include "vom/cmd.hpp"
+#include "vom/dhcp_config_cmds.hpp"
namespace VOM {
/**
@@ -62,7 +62,8 @@ void
dhcp_config::sweep()
{
if (m_binding) {
- HW::enqueue(new unbind_cmd(m_binding, m_itf->handle(), m_hostname));
+ HW::enqueue(
+ new dhcp_config_cmds::unbind_cmd(m_binding, m_itf->handle(), m_hostname));
}
HW::write();
}
@@ -77,8 +78,8 @@ void
dhcp_config::replay()
{
if (m_binding) {
- HW::enqueue(
- new bind_cmd(m_binding, m_itf->handle(), m_hostname, m_client_id));
+ HW::enqueue(new dhcp_config_cmds::bind_cmd(m_binding, m_itf->handle(),
+ m_hostname, m_client_id));
}
}
@@ -99,8 +100,8 @@ dhcp_config::update(const dhcp_config& desired)
* the desired state is always that the interface should be created
*/
if (!m_binding) {
- HW::enqueue(
- new bind_cmd(m_binding, m_itf->handle(), m_hostname, m_client_id));
+ HW::enqueue(new dhcp_config_cmds::bind_cmd(m_binding, m_itf->handle(),
+ m_hostname, m_client_id));
}
}
diff --git a/src/vpp-api/vom/dhcp_config.hpp b/src/vpp-api/vom/dhcp_config.hpp
index 9ce0635c939..f64a3c8a2e2 100644
--- a/src/vpp-api/vom/dhcp_config.hpp
+++ b/src/vpp-api/vom/dhcp_config.hpp
@@ -13,22 +13,20 @@
* limitations under the License.
*/
-#ifndef __VOM_DHCP_INTERFACE_H__
-#define __VOM_DHCP_INTERFACE_H__
+#ifndef __VOM_DHCP_CONFIG_H__
+#define __VOM_DHCP_CONFIG_H__
-#include "vom/dump_cmd.hpp"
#include "vom/hw.hpp"
#include "vom/inspect.hpp"
#include "vom/interface.hpp"
#include "vom/object_base.hpp"
#include "vom/om.hpp"
-#include "vom/rpc_cmd.hpp"
#include "vom/singular_db.hpp"
-#include "vom/sub_interface.hpp"
-
-#include <vapi/dhcp.api.vapi.hpp>
namespace VOM {
+namespace dhcp_config_cmds {
+class events_cmd;
+};
/**
* A representation of DHCP client configuration on an interface
*/
@@ -73,97 +71,6 @@ public:
static void dump(std::ostream& os);
/**
- * A command class that binds the DHCP config to the interface
- */
- class bind_cmd
- : public rpc_cmd<HW::item<bool>, rc_t, vapi::Dhcp_client_config>
- {
- public:
- /**
- * Constructor
- */
- bind_cmd(HW::item<bool>& item,
- const handle_t& itf,
- const std::string& hostname,
- const l2_address_t& client_id);
-
- /**
- * 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;
-
- /**
- * The DHCP client's hostname
- */
- const std::string m_hostname;
-
- /**
- * The DHCP client's ID
- */
- const l2_address_t m_client_id;
- };
-
- /**
- * A cmd class that Unbinds Dhcp Config from an interface
- */
- class unbind_cmd
- : public rpc_cmd<HW::item<bool>, rc_t, vapi::Dhcp_client_config>
- {
- public:
- /**
- * Constructor
- */
- unbind_cmd(HW::item<bool>& item,
- const handle_t& itf,
- const std::string& hostname);
-
- /**
- * 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;
-
- /**
- * The DHCP client's hostname
- */
- const std::string m_hostname;
- };
-
- /**
- * Forward declartion of the Event Command
- */
- class events_cmd;
-
- /**
* A class that listens to DHCP Events
*/
class event_listener
@@ -178,7 +85,7 @@ public:
* listener's virtual function invoked when a DHCP event is
* available to read
*/
- virtual void handle_dhcp_event(events_cmd* cmd) = 0;
+ virtual void handle_dhcp_event(dhcp_config_cmds::events_cmd* cmd) = 0;
/**
* Return the HW::item associated with this command
@@ -192,50 +99,6 @@ public:
HW::item<bool> m_status;
};
- /**
- * A functor class represents our desire to recieve interface events
- */
- class events_cmd
- : public event_cmd<vapi::Control_ping, vapi::Dhcp_compl_event>
- {
- public:
- /**
- * Constructor
- */
- events_cmd(event_listener& el);
-
- /**
- * Issue the command to VPP/HW - subscribe to DHCP events
- */
- rc_t issue(connection& con);
-
- /**
- * Retire the command - unsubscribe
- */
- void retire(connection& con);
- /**
- * convert to string format for debug purposes
- */
- std::string to_string() const;
-
- /**
- * Comparison operator - only used for UT
- */
- bool operator==(const events_cmd& i) const;
-
- /**
- * called in the VAPI RX thread when data is available.
- */
- void notify();
-
- private:
- void succeeded() {}
- /**
- * The listner of this command
- */
- event_listener& m_listener;
- };
-
private:
/**
* Class definition for listeners to OM events
diff --git a/src/vpp-api/vom/dhcp_config_cmds.cpp b/src/vpp-api/vom/dhcp_config_cmds.cpp
index 53262a3cac6..8e81a27f96e 100644
--- a/src/vpp-api/vom/dhcp_config_cmds.cpp
+++ b/src/vpp-api/vom/dhcp_config_cmds.cpp
@@ -13,15 +13,17 @@
* limitations under the License.
*/
-#include "vom/dhcp_config.hpp"
+#include "vom/dhcp_config_cmds.hpp"
DEFINE_VAPI_MSG_IDS_DHCP_API_JSON;
namespace VOM {
-dhcp_config::bind_cmd::bind_cmd(HW::item<bool>& item,
- const handle_t& itf,
- const std::string& hostname,
- const l2_address_t& client_id)
+namespace dhcp_config_cmds {
+
+bind_cmd::bind_cmd(HW::item<bool>& item,
+ const handle_t& itf,
+ const std::string& hostname,
+ const l2_address_t& client_id)
: rpc_cmd(item)
, m_itf(itf)
, m_hostname(hostname)
@@ -30,13 +32,13 @@ dhcp_config::bind_cmd::bind_cmd(HW::item<bool>& item,
}
bool
-dhcp_config::bind_cmd::operator==(const bind_cmd& other) const
+bind_cmd::operator==(const bind_cmd& other) const
{
return ((m_itf == other.m_itf) && (m_hostname == other.m_hostname));
}
rc_t
-dhcp_config::bind_cmd::issue(connection& con)
+bind_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -63,7 +65,7 @@ dhcp_config::bind_cmd::issue(connection& con)
}
std::string
-dhcp_config::bind_cmd::to_string() const
+bind_cmd::to_string() const
{
std::ostringstream s;
s << "Dhcp-config-bind: " << m_hw_item.to_string()
@@ -72,9 +74,9 @@ dhcp_config::bind_cmd::to_string() const
return (s.str());
}
-dhcp_config::unbind_cmd::unbind_cmd(HW::item<bool>& item,
- const handle_t& itf,
- const std::string& hostname)
+unbind_cmd::unbind_cmd(HW::item<bool>& item,
+ const handle_t& itf,
+ const std::string& hostname)
: rpc_cmd(item)
, m_itf(itf)
, m_hostname(hostname)
@@ -82,13 +84,13 @@ dhcp_config::unbind_cmd::unbind_cmd(HW::item<bool>& item,
}
bool
-dhcp_config::unbind_cmd::operator==(const unbind_cmd& other) const
+unbind_cmd::operator==(const unbind_cmd& other) const
{
return ((m_itf == other.m_itf) && (m_hostname == other.m_hostname));
}
rc_t
-dhcp_config::unbind_cmd::issue(connection& con)
+unbind_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -110,7 +112,7 @@ dhcp_config::unbind_cmd::issue(connection& con)
}
std::string
-dhcp_config::unbind_cmd::to_string() const
+unbind_cmd::to_string() const
{
std::ostringstream s;
s << "Dhcp-config-unbind: " << m_hw_item.to_string()
@@ -119,20 +121,20 @@ dhcp_config::unbind_cmd::to_string() const
return (s.str());
}
-dhcp_config::events_cmd::events_cmd(event_listener& el)
+events_cmd::events_cmd(dhcp_config::event_listener& el)
: event_cmd(el.status())
, m_listener(el)
{
}
bool
-dhcp_config::events_cmd::operator==(const events_cmd& other) const
+events_cmd::operator==(const events_cmd& other) const
{
return (true);
}
rc_t
-dhcp_config::events_cmd::issue(connection& con)
+events_cmd::issue(connection& con)
{
/*
* Set the call back to handle DHCP complete envets.
@@ -146,23 +148,23 @@ dhcp_config::events_cmd::issue(connection& con)
}
void
-dhcp_config::events_cmd::retire(connection& con)
+events_cmd::retire(connection& con)
{
}
void
-dhcp_config::events_cmd::notify()
+events_cmd::notify()
{
m_listener.handle_dhcp_event(this);
}
std::string
-dhcp_config::events_cmd::to_string() const
+events_cmd::to_string() const
{
return ("dhcp-events");
}
}
-
+};
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/src/vpp-api/vom/dhcp_config_cmds.hpp b/src/vpp-api/vom/dhcp_config_cmds.hpp
new file mode 100644
index 00000000000..863cf599b74
--- /dev/null
+++ b/src/vpp-api/vom/dhcp_config_cmds.hpp
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 2017 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_DHCP_CONFIG_CMDS_H__
+#define __VOM_DHCP_CONFIG_CMDS_H__
+
+#include "vom/dhcp_config.hpp"
+#include "vom/event_cmd.hpp"
+
+#include <vapi/dhcp.api.vapi.hpp>
+#include <vapi/vpe.api.vapi.hpp>
+
+namespace VOM {
+namespace dhcp_config_cmds {
+
+/**
+ * A command class that binds the DHCP config to the interface
+ */
+class bind_cmd : public rpc_cmd<HW::item<bool>, rc_t, vapi::Dhcp_client_config>
+{
+public:
+ /**
+ * Constructor
+ */
+ bind_cmd(HW::item<bool>& item,
+ const handle_t& itf,
+ const std::string& hostname,
+ const l2_address_t& client_id);
+
+ /**
+ * 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;
+
+ /**
+ * The DHCP client's hostname
+ */
+ const std::string m_hostname;
+
+ /**
+ * The DHCP client's ID
+ */
+ const l2_address_t m_client_id;
+};
+
+/**
+ * A cmd class that Unbinds Dhcp Config from an interface
+ */
+class unbind_cmd
+ : public rpc_cmd<HW::item<bool>, rc_t, vapi::Dhcp_client_config>
+{
+public:
+ /**
+ * Constructor
+ */
+ unbind_cmd(HW::item<bool>& item,
+ const handle_t& itf,
+ const std::string& hostname);
+
+ /**
+ * 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;
+
+ /**
+ * The DHCP client's hostname
+ */
+ const std::string m_hostname;
+};
+
+/**
+ * A functor class represents our desire to recieve interface events
+ */
+class events_cmd : public event_cmd<vapi::Control_ping, vapi::Dhcp_compl_event>
+{
+public:
+ /**
+ * Constructor
+ */
+ events_cmd(dhcp_config::event_listener& el);
+
+ /**
+ * Issue the command to VPP/HW - subscribe to DHCP events
+ */
+ rc_t issue(connection& con);
+
+ /**
+ * Retire the command - unsubscribe
+ */
+ void retire(connection& con);
+ /**
+ * convert to string format for debug purposes
+ */
+ std::string to_string() const;
+
+ /**
+ * Comparison operator - only used for UT
+ */
+ bool operator==(const events_cmd& i) const;
+
+ /**
+ * called in the VAPI RX thread when data is available.
+ */
+ void notify();
+
+private:
+ void succeeded() {}
+ /**
+ * The listner of this command
+ */
+ dhcp_config::event_listener& m_listener;
+};
+};
+};
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
+
+#endif
diff --git a/src/vpp-api/vom/hw.cpp b/src/vpp-api/vom/hw.cpp
index 56885525494..fee0e869d27 100644
--- a/src/vpp-api/vom/hw.cpp
+++ b/src/vpp-api/vom/hw.cpp
@@ -14,10 +14,9 @@
*/
#include "vom/hw.hpp"
+#include "vom/hw_cmds.hpp"
#include "vom/logger.hpp"
-#include <vapi/vpe.api.vapi.hpp>
-
namespace VOM {
HW::cmd_q::cmd_q()
: m_enabled(true)
@@ -270,12 +269,13 @@ HW::write()
bool
HW::poll()
{
- std::shared_ptr<cmd> poll(new Poll(m_poll_state));
+ std::shared_ptr<cmd> poll(new hw_cmds::poll(m_poll_state));
HW::enqueue(poll);
HW::write();
return (m_poll_state);
+ return (true);
}
template <>
@@ -299,33 +299,6 @@ HW::item<unsigned int>::to_string() const
<< "rc:" << item_rc.to_string() << " data:" << item_data << "]";
return (os.str());
}
-
-HW::Poll::Poll(HW::item<bool>& item)
- : rpc_cmd(item)
-{
-}
-
-rc_t
-HW::Poll::issue(connection& con)
-{
- msg_t req(con.ctx(), std::ref(*this));
-
- VAPI_CALL(req.execute());
-
- m_hw_item.set(wait());
-
- return (rc_t::OK);
-}
-
-std::string
-HW::Poll::to_string() const
-{
- std::ostringstream s;
-
- s << "poll: " << m_hw_item.to_string();
-
- return (s.str());
-}
}
/*
diff --git a/src/vpp-api/vom/hw.hpp b/src/vpp-api/vom/hw.hpp
index ef34a4c4542..eaa7cf09afb 100644
--- a/src/vpp-api/vom/hw.hpp
+++ b/src/vpp-api/vom/hw.hpp
@@ -22,13 +22,12 @@
#include <string>
#include <thread>
-#include <vapi/vapi.hpp>
-#include <vapi/vpe.api.vapi.hpp>
-
#include "vom/connection.hpp"
-#include "vom/rpc_cmd.hpp"
+#include "vom/types.hpp"
namespace VOM {
+
+class cmd;
class HW
{
public:
@@ -357,33 +356,6 @@ private:
* Only the OM can enable/disable HW
*/
friend class OM;
-
- /**
- * A command pool the HW for liveness
- */
- class Poll : public rpc_cmd<HW::item<bool>, rc_t, vapi::Control_ping>
- {
- public:
- /**
- * Constructor taking the HW::item to update
- */
- Poll(HW::item<bool>& item);
-
- /**
- * 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 Poll& i) const;
- };
};
/**
diff --git a/src/vpp-api/vom/hw_cmds.cpp b/src/vpp-api/vom/hw_cmds.cpp
new file mode 100644
index 00000000000..e628c354d71
--- /dev/null
+++ b/src/vpp-api/vom/hw_cmds.cpp
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2017 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/hw_cmds.hpp"
+
+namespace VOM {
+namespace hw_cmds {
+
+poll::poll(HW::item<bool>& item)
+ : rpc_cmd(item)
+{
+}
+
+rc_t
+poll::issue(connection& con)
+{
+ msg_t req(con.ctx(), std::ref(*this));
+
+ VAPI_CALL(req.execute());
+
+ m_hw_item.set(wait());
+
+ return (rc_t::OK);
+}
+
+std::string
+poll::to_string() const
+{
+ std::ostringstream s;
+
+ s << "poll: " << m_hw_item.to_string();
+
+ return (s.str());
+}
+}
+};
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
diff --git a/src/vpp-api/vom/hw_cmds.hpp b/src/vpp-api/vom/hw_cmds.hpp
new file mode 100644
index 00000000000..b499ccecca0
--- /dev/null
+++ b/src/vpp-api/vom/hw_cmds.hpp
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2017 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_HW_CMDS_H__
+#define __VOM_HW_CMDS_H__
+
+#include <vapi/vapi.hpp>
+#include <vapi/vpe.api.vapi.hpp>
+
+#include "vom/hw.hpp"
+#include "vom/rpc_cmd.hpp"
+
+namespace VOM {
+namespace hw_cmds {
+/**
+*A command poll the HW for liveness
+*/
+class poll : public rpc_cmd<HW::item<bool>, rc_t, vapi::Control_ping>
+{
+public:
+ /**
+ * Constructor taking the HW::item to update
+ */
+ poll(HW::item<bool>& item);
+
+ /**
+ * 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 poll& i) const;
+};
+};
+};
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
+
+#endif
diff --git a/src/vpp-api/vom/interface.cpp b/src/vpp-api/vom/interface.cpp
index 83da275f61f..8e270136d8b 100644
--- a/src/vpp-api/vom/interface.cpp
+++ b/src/vpp-api/vom/interface.cpp
@@ -14,8 +14,9 @@
*/
#include "vom/interface.hpp"
-#include "vom/cmd.hpp"
-#include "vom/l3_binding.hpp"
+#include "vom/interface_cmds.hpp"
+#include "vom/interface_factory.hpp"
+#include "vom/l3_binding_cmds.hpp"
#include "vom/logger.hpp"
#include "vom/prefix.hpp"
@@ -150,14 +151,16 @@ interface::sweep()
{
if (m_table_id) {
m_table_id.data() = route::DEFAULT_TABLE;
- HW::enqueue(new set_table_cmd(m_table_id, l3_proto_t::IPV4, m_hdl));
- HW::enqueue(new set_table_cmd(m_table_id, l3_proto_t::IPV6, m_hdl));
+ HW::enqueue(
+ new interface_cmds::set_table_cmd(m_table_id, l3_proto_t::IPV4, m_hdl));
+ HW::enqueue(
+ new interface_cmds::set_table_cmd(m_table_id, l3_proto_t::IPV6, m_hdl));
}
// If the interface is up, bring it down
if (m_state && interface::admin_state_t::UP == m_state.data()) {
m_state.data() = interface::admin_state_t::DOWN;
- HW::enqueue(new state_change_cmd(m_state, m_hdl));
+ HW::enqueue(new interface_cmds::state_change_cmd(m_state, m_hdl));
}
if (m_hdl) {
std::queue<cmd*> cmds;
@@ -175,12 +178,14 @@ interface::replay()
}
if (m_state && interface::admin_state_t::UP == m_state.data()) {
- HW::enqueue(new state_change_cmd(m_state, m_hdl));
+ HW::enqueue(new interface_cmds::state_change_cmd(m_state, m_hdl));
}
if (m_table_id) {
- HW::enqueue(new set_table_cmd(m_table_id, l3_proto_t::IPV4, m_hdl));
- HW::enqueue(new set_table_cmd(m_table_id, l3_proto_t::IPV6, m_hdl));
+ HW::enqueue(
+ new interface_cmds::set_table_cmd(m_table_id, l3_proto_t::IPV4, m_hdl));
+ HW::enqueue(
+ new interface_cmds::set_table_cmd(m_table_id, l3_proto_t::IPV6, m_hdl));
}
}
@@ -231,14 +236,14 @@ std::queue<cmd*>&
interface::mk_create_cmd(std::queue<cmd*>& q)
{
if (type_t::LOOPBACK == m_type) {
- q.push(new loopback_create_cmd(m_hdl, m_name));
+ q.push(new interface_cmds::loopback_create_cmd(m_hdl, m_name));
} else if (type_t::BVI == m_type) {
- q.push(new loopback_create_cmd(m_hdl, m_name));
- q.push(new set_tag(m_hdl, m_name));
+ q.push(new interface_cmds::loopback_create_cmd(m_hdl, m_name));
+ q.push(new interface_cmds::set_tag(m_hdl, m_name));
} else if (type_t::AFPACKET == m_type) {
- q.push(new af_packet_create_cmd(m_hdl, m_name));
+ q.push(new interface_cmds::af_packet_create_cmd(m_hdl, m_name));
} else if (type_t::TAP == m_type) {
- q.push(new tap_create_cmd(m_hdl, m_name));
+ q.push(new interface_cmds::tap_create_cmd(m_hdl, m_name));
}
return (q);
@@ -248,11 +253,11 @@ std::queue<cmd*>&
interface::mk_delete_cmd(std::queue<cmd*>& q)
{
if ((type_t::LOOPBACK == m_type) || (type_t::BVI == m_type)) {
- q.push(new loopback_delete_cmd(m_hdl));
+ q.push(new interface_cmds::loopback_delete_cmd(m_hdl));
} else if (type_t::AFPACKET == m_type) {
- q.push(new af_packet_delete_cmd(m_hdl, m_name));
+ q.push(new interface_cmds::af_packet_delete_cmd(m_hdl, m_name));
} else if (type_t::TAP == m_type) {
- q.push(new tap_delete_cmd(m_hdl));
+ q.push(new interface_cmds::tap_delete_cmd(m_hdl));
}
return (q);
@@ -273,14 +278,14 @@ interface::update(const interface& desired)
* change the interface state to that which is deisred
*/
if (m_state.update(desired.m_state)) {
- HW::enqueue(new state_change_cmd(m_state, m_hdl));
+ HW::enqueue(new interface_cmds::state_change_cmd(m_state, m_hdl));
}
/*
* change the interface state to that which is deisred
*/
if (m_l2_address.update(desired.m_l2_address)) {
- HW::enqueue(new set_mac_cmd(m_l2_address, m_hdl));
+ HW::enqueue(new interface_cmds::set_mac_cmd(m_l2_address, m_hdl));
}
/*
@@ -288,8 +293,10 @@ interface::update(const interface& desired)
* table ID
*/
if (!m_table_id && m_rd) {
- HW::enqueue(new set_table_cmd(m_table_id, l3_proto_t::IPV4, m_hdl));
- HW::enqueue(new set_table_cmd(m_table_id, l3_proto_t::IPV6, m_hdl));
+ HW::enqueue(
+ new interface_cmds::set_table_cmd(m_table_id, l3_proto_t::IPV4, m_hdl));
+ HW::enqueue(
+ new interface_cmds::set_table_cmd(m_table_id, l3_proto_t::IPV6, m_hdl));
}
}
@@ -359,14 +366,14 @@ interface::event_handler::handle_populate(const client_db::key_t& key)
/*
* dump VPP current states
*/
- std::shared_ptr<interface::dump_cmd> cmd(new interface::dump_cmd());
+ std::shared_ptr<interface_cmds::dump_cmd> cmd(new interface_cmds::dump_cmd());
HW::enqueue(cmd);
HW::write();
for (auto& itf_record : *cmd) {
std::unique_ptr<interface> itf =
- interface::new_interface(itf_record.get_payload());
+ interface_factory::new_interface(itf_record.get_payload());
if (itf && interface::type_t::LOCAL != itf->type()) {
VOM_LOG(log_level_t::DEBUG) << "dump: " << itf->to_string();
@@ -380,9 +387,9 @@ interface::event_handler::handle_populate(const client_db::key_t& key)
/**
* Get the address configured on the interface
*/
- std::shared_ptr<l3_binding::dump_v4_cmd> dcmd =
- std::make_shared<l3_binding::dump_v4_cmd>(
- l3_binding::dump_v4_cmd(itf->handle()));
+ std::shared_ptr<l3_binding_cmds::dump_v4_cmd> dcmd =
+ std::make_shared<l3_binding_cmds::dump_v4_cmd>(
+ l3_binding_cmds::dump_v4_cmd(itf->handle()));
HW::enqueue(dcmd);
HW::write();
diff --git a/src/vpp-api/vom/interface.hpp b/src/vpp-api/vom/interface.hpp
index 8863bc94868..6fdd1e1eb62 100644
--- a/src/vpp-api/vom/interface.hpp
+++ b/src/vpp-api/vom/interface.hpp
@@ -16,9 +16,7 @@
#ifndef __VOM_INTERFACE_H__
#define __VOM_INTERFACE_H__
-#include "vom/dump_cmd.hpp"
#include "vom/enum_base.hpp"
-#include "vom/event_cmd.hpp"
#include "vom/hw.hpp"
#include "vom/inspect.hpp"
#include "vom/object_base.hpp"
@@ -28,15 +26,16 @@
#include "vom/rpc_cmd.hpp"
#include "vom/singular_db.hpp"
-#include <vapi/af_packet.api.vapi.hpp>
-#include <vapi/interface.api.vapi.hpp>
-#include <vapi/stats.api.vapi.hpp>
-#include <vapi/tap.api.vapi.hpp>
-#include <vapi/vapi.hpp>
-#include <vapi/vpe.api.vapi.hpp>
-
namespace VOM {
/**
+ * Forward declaration of the stats and events command
+ */
+namespace interface_cmds {
+class stats_cmd;
+class events_cmd;
+};
+
+/**
* A representation of an interface in VPP
*/
class interface : public object_base
@@ -260,6 +259,11 @@ public:
interface::add(m_name, this->item());
}
+ /**
+ * add the created interface to the DB
+ */
+ void insert_interface() { interface::add(m_name, this->item()); }
+
virtual vapi_error_e operator()(MSG& reply)
{
int sw_if_index = reply.get_response().get_payload().sw_if_index;
@@ -289,75 +293,6 @@ public:
};
/**
- * A command class to create Loopback interfaces in VPP
- */
- class loopback_create_cmd : public create_cmd<vapi::Create_loopback>
- {
- public:
- /**
- * Constructor taking the HW::item to update
- * and the name of the interface to create
- */
- loopback_create_cmd(HW::item<handle_t>& item, const std::string& name);
- ~loopback_create_cmd() = default;
-
- /**
- * Issue the command to VPP/HW
- */
- rc_t issue(connection& con);
- /**
- * convert to string format for debug purposes
- */
- std::string to_string() const;
- };
-
- /**
- * A command class to create af_packet interfaces in VPP
- */
- class af_packet_create_cmd : public create_cmd<vapi::Af_packet_create>
- {
- public:
- /**
- * Constructor taking the HW::item to update
- * and the name of the interface to create
- */
- af_packet_create_cmd(HW::item<handle_t>& item, const std::string& name);
- ~af_packet_create_cmd() = default;
- /**
- * Issue the command to VPP/HW
- */
- rc_t issue(connection& con);
- /**
- * convert to string format for debug purposes
- */
- std::string to_string() const;
- };
-
- /**
- * A command class to create TAP interfaces in VPP
- */
- class tap_create_cmd : public create_cmd<vapi::Tap_connect>
- {
- public:
- /**
- * Constructor taking the HW::item to update
- * and the name of the interface to create
- */
- tap_create_cmd(HW::item<handle_t>& item, const std::string& name);
- ~tap_create_cmd() = default;
-
- /**
- * Issue the command to VPP/HW
- */
- rc_t issue(connection& con);
-
- /**
- * convert to string format for debug purposes
- */
- std::string to_string() const;
- };
-
- /**
* Base class for intterface Delete commands
*/
template <typename MSG>
@@ -394,231 +329,19 @@ public:
*/
void succeeded() {}
- protected:
/**
- * The name of the interface to be created
+ * add the created interface to the DB
*/
- const std::string m_name;
- };
-
- /**
- * A command class to delete loopback interfaces in VPP
- */
- class loopback_delete_cmd : public delete_cmd<vapi::Delete_loopback>
- {
- public:
- /**
- * Constructor taking the HW::item to update
- */
- loopback_delete_cmd(HW::item<handle_t>& item);
+ void remove_interface() { interface::remove(this->item()); }
+ protected:
/**
- * Issue the command to VPP/HW
- */
- rc_t issue(connection& con);
- /**
- * convert to string format for debug purposes
- */
- std::string to_string() const;
- };
-
- /**
- * A command class to delete af-packet interfaces in VPP
- */
- class af_packet_delete_cmd : public delete_cmd<vapi::Af_packet_delete>
- {
- public:
- /**
- * Constructor taking the HW::item to update
- * and the name of the interface to delete
- */
- af_packet_delete_cmd(HW::item<handle_t>& item, const std::string& name);
-
- /**
- * Issue the command to VPP/HW
- */
- rc_t issue(connection& con);
- /**
- * convert to string format for debug purposes
- */
- std::string to_string() const;
- };
-
- /**
- * A command class to delete TAP interfaces in VPP
- */
- class tap_delete_cmd : public delete_cmd<vapi::Tap_delete>
- {
- public:
- /**
- * Constructor taking the HW::item to update
- */
- tap_delete_cmd(HW::item<handle_t>& item);
-
- /**
- * Issue the command to VPP/HW
- */
- rc_t issue(connection& con);
- /**
- * convert to string format for debug purposes
- */
- std::string to_string() const;
- };
-
- /**
- * A command class to delete TAP interfaces in VPP
- */
- class set_tag
- : public rpc_cmd<HW::item<handle_t>, rc_t, vapi::Sw_interface_tag_add_del>
- {
- public:
- /**
- * Constructor taking the HW::item to update
- */
- set_tag(HW::item<handle_t>& item, const std::string& name);
-
- /**
- * 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 set_tag& i) const;
-
- private:
- /**
- * The tag to add
+ * The name of the interface to be created
*/
const std::string m_name;
};
/**
- * A cmd class that changes the admin state
- */
- class state_change_cmd : public rpc_cmd<HW::item<admin_state_t>,
- rc_t,
- vapi::Sw_interface_set_flags>
- {
- public:
- /**
- * Constructor taking the HW::item to update
- * and the name handle of the interface whose state is to change
- */
- state_change_cmd(HW::item<admin_state_t>& s, const HW::item<handle_t>& h);
-
- /**
- * 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 state_change_cmd& i) const;
-
- private:
- /**
- * the handle of the interface to update
- */
- const HW::item<handle_t>& m_hdl;
- };
-
- /**
- * A command class that binds an interface to an L3 table
- */
- class set_table_cmd : public rpc_cmd<HW::item<route::table_id_t>,
- rc_t,
- vapi::Sw_interface_set_table>
- {
- public:
- /**
- * Constructor taking the HW::item to update
- * and the name handle of the interface whose table is to change
- */
- set_table_cmd(HW::item<route::table_id_t>& item,
- const l3_proto_t& proto,
- const HW::item<handle_t>& h);
-
- /**
- * 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 set_table_cmd& i) const;
-
- private:
- /**
- * the handle of the interface to update
- */
- const HW::item<handle_t>& m_hdl;
-
- /**
- * The L3 protocol of the table
- */
- l3_proto_t m_proto;
- };
-
- /**
- * A command class that binds an interface to an L3 table
- */
- class set_mac_cmd : public rpc_cmd<HW::item<l2_address_t>,
- rc_t,
- vapi::Sw_interface_set_mac_address>
- {
- public:
- /**
- * Constructor taking the HW::item to update
- * and the handle of the interface
- */
- set_mac_cmd(HW::item<l2_address_t>& item, const HW::item<handle_t>& h);
-
- /**
- * 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 set_mac_cmd& i) const;
-
- private:
- /**
- * the handle of the interface to update
- */
- const HW::item<handle_t>& m_hdl;
- };
-
- /**
- * Forward declaration of the Event command
- */
- class events_cmd;
-
- /**
* A class that listens to interface Events
*/
class event_listener
@@ -633,7 +356,7 @@ public:
* Virtual function called on the listener when the command has data
* ready to process
*/
- virtual void handle_interface_event(events_cmd* cmd) = 0;
+ virtual void handle_interface_event(interface_cmds::events_cmd* cmd) = 0;
/**
* Return the HW::item representing the status
@@ -648,55 +371,6 @@ public:
};
/**
- * A command class represents our desire to recieve interface events
- */
- class events_cmd
- : public event_cmd<vapi::Want_interface_events, vapi::Sw_interface_event>
- {
- public:
- /**
- * Constructor taking the listner to notify
- */
- events_cmd(event_listener& el);
-
- /**
- * Issue the command to VPP/HW
- */
- rc_t issue(connection& con);
-
- /**
- * Retires the command - unsubscribe from the events.
- */
- void retire(connection& con);
-
- /**
- * convert to string format for debug purposes
- */
- std::string to_string() const;
-
- /**
- * Comparison operator - only used for UT
- */
- bool operator==(const events_cmd& i) const;
-
- /**
- * Called when it's time to poke the listeners
- */
- void notify();
-
- private:
- /**
- * The listeners to notify when data/events arrive
- */
- event_listener& m_listener;
- };
-
- /**
- * Forward declaration of the stat command
- */
- class stats_cmd;
-
- /**
* A class that listens to interface Stats
*/
class stat_listener
@@ -711,7 +385,7 @@ public:
* Virtual function called on the listener when the command has data
* ready to process
*/
- virtual void handle_interface_stat(stats_cmd* cmd) = 0;
+ virtual void handle_interface_stat(interface_cmds::stats_cmd* cmd) = 0;
/**
* Return the HW::item representing the status
@@ -726,78 +400,6 @@ public:
};
/**
- * A command class represents our desire to recieve interface stats
- */
- class stats_cmd : public event_cmd<vapi::Want_per_interface_combined_stats,
- vapi::Vnet_per_interface_combined_counters>
- {
- public:
- /**
- * Constructor taking the listner to notify
- */
- stats_cmd(stat_listener& el, const std::vector<handle_t>& interfaces);
-
- /**
- * Issue the command to VPP/HW
- */
- rc_t issue(connection& con);
-
- /**
- * Retires the command - unsubscribe from the stats.
- */
- void retire(connection& con);
-
- /**
- * convert to string format for debug purposes
- */
- std::string to_string() const;
-
- /**
- * Comparison operator - only used for UT
- */
- bool operator==(const stats_cmd& i) const;
-
- /**
- * Called when it's time to poke the listeners
- */
- void notify();
-
- private:
- /**
- * The listeners to notify when data/stats arrive
- */
- stat_listener& m_listener;
-
- std::vector<handle_t> m_swifindex;
- };
-
- /**
- * A cmd class that Dumps all the Vpp interfaces
- */
- class dump_cmd : public VOM::dump_cmd<vapi::Sw_interface_dump>
- {
- public:
- /**
- * Default Constructor
- */
- dump_cmd();
-
- /**
- * 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;
- };
-
- /**
* The the singular instance of the interface in the object_base-Model
*/
static std::shared_ptr<interface> find(const interface& temp);
@@ -819,12 +421,6 @@ public:
*/
static void dump(std::ostream& os);
- /**
- * Factory method to construct a new interface from the VPP record
- */
- static std::unique_ptr<interface> new_interface(
- const vapi_payload_sw_interface_details& vd);
-
protected:
/**
* Construct an interface object with a handle and a HW address
@@ -834,6 +430,7 @@ protected:
const std::string& name,
type_t type,
admin_state_t state);
+ friend class interface_factory;
/**
* The SW interface handle VPP has asigned to the interface
diff --git a/src/vpp-api/vom/interface_cmds.cpp b/src/vpp-api/vom/interface_cmds.cpp
index 306f987429b..4f6286f7bef 100644
--- a/src/vpp-api/vom/interface_cmds.cpp
+++ b/src/vpp-api/vom/interface_cmds.cpp
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-#include "vom/interface.hpp"
+#include "vom/interface_cmds.hpp"
#include "vom/cmd.hpp"
DEFINE_VAPI_MSG_IDS_VPE_API_JSON;
@@ -23,14 +23,15 @@ DEFINE_VAPI_MSG_IDS_TAP_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));
@@ -39,13 +40,13 @@ interface::loopback_create_cmd::issue(connection& con)
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;
@@ -53,14 +54,14 @@ interface::loopback_create_cmd::to_string() const
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));
@@ -76,13 +77,13 @@ interface::af_packet_create_cmd::issue(connection& con)
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;
@@ -90,14 +91,14 @@ interface::af_packet_create_cmd::to_string() const
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));
@@ -113,14 +114,14 @@ interface::tap_create_cmd::issue(connection& con)
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;
@@ -128,13 +129,13 @@ interface::tap_create_cmd::to_string() const
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));
@@ -146,12 +147,12 @@ interface::loopback_delete_cmd::issue(connection& con)
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();
@@ -159,14 +160,14 @@ interface::loopback_delete_cmd::to_string() const
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));
@@ -180,11 +181,11 @@ interface::af_packet_delete_cmd::issue(connection& con)
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();
@@ -192,21 +193,21 @@ interface::af_packet_delete_cmd::to_string() const
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();
@@ -214,22 +215,21 @@ interface::tap_delete_cmd::to_string() const
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));
@@ -245,7 +245,7 @@ interface::state_change_cmd::issue(connection& con)
}
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()
@@ -253,9 +253,9 @@ interface::state_change_cmd::to_string() const
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)
@@ -263,14 +263,14 @@ interface::set_table_cmd::set_table_cmd(HW::item<route::table_id_t>& table,
}
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));
@@ -287,7 +287,7 @@ interface::set_table_cmd::issue(connection& con)
}
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()
@@ -295,21 +295,21 @@ interface::set_table_cmd::to_string() const
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));
@@ -326,27 +326,27 @@ interface::set_mac_cmd::issue(connection& con)
}
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
@@ -370,7 +370,7 @@ interface::events_cmd::issue(connection& con)
}
void
-interface::events_cmd::retire(connection& con)
+events_cmd::retire(connection& con)
{
/*
* disable interface events.
@@ -387,13 +387,13 @@ interface::events_cmd::retire(connection& con)
}
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");
}
@@ -401,8 +401,8 @@ interface::events_cmd::to_string() const
/**
* Interface statistics
*/
-interface::stats_cmd::stats_cmd(stat_listener& el,
- const std::vector<handle_t>& interfaces)
+stats_cmd::stats_cmd(interface::stat_listener& el,
+ const std::vector<handle_t>& interfaces)
: event_cmd(el.status())
, m_listener(el)
, m_swifindex(interfaces)
@@ -410,13 +410,13 @@ interface::stats_cmd::stats_cmd(stat_listener& el,
}
bool
-interface::stats_cmd::operator==(const stats_cmd& other) const
+stats_cmd::operator==(const stats_cmd& other) const
{
return (true);
}
rc_t
-interface::stats_cmd::issue(connection& con)
+stats_cmd::issue(connection& con)
{
/*
* First set the clal back to handle the interface stats
@@ -451,34 +451,34 @@ interface::stats_cmd::issue(connection& con)
}
void
-interface::stats_cmd::retire(connection& con)
+stats_cmd::retire(connection& con)
{
}
void
-interface::stats_cmd::notify()
+stats_cmd::notify()
{
m_listener.handle_interface_stat(this);
}
std::string
-interface::stats_cmd::to_string() const
+stats_cmd::to_string() const
{
return ("itf-stats");
}
-interface::dump_cmd::dump_cmd()
+dump_cmd::dump_cmd()
{
}
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)));
@@ -493,19 +493,19 @@ interface::dump_cmd::issue(connection& con)
}
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));
@@ -521,7 +521,7 @@ interface::set_tag::issue(connection& con)
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;
@@ -530,11 +530,13 @@ interface::set_tag::to_string() const
}
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
*
diff --git a/src/vpp-api/vom/interface_cmds.hpp b/src/vpp-api/vom/interface_cmds.hpp
new file mode 100644
index 00000000000..4178be38e04
--- /dev/null
+++ b/src/vpp-api/vom/interface_cmds.hpp
@@ -0,0 +1,451 @@
+/*
+ * Copyright (c) 2017 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_INTERFACE_CMDS_H__
+#define __VOM_INTERFACE_CMDS_H__
+
+#include <vapi/vapi.hpp>
+
+#include "vom/dump_cmd.hpp"
+#include "vom/event_cmd.hpp"
+#include "vom/interface.hpp"
+#include "vom/rpc_cmd.hpp"
+
+#include <vapi/af_packet.api.vapi.hpp>
+#include <vapi/interface.api.vapi.hpp>
+#include <vapi/stats.api.vapi.hpp>
+#include <vapi/tap.api.vapi.hpp>
+#include <vapi/vpe.api.vapi.hpp>
+
+namespace VOM {
+
+namespace interface_cmds {
+/**
+ * Factory method to construct a new interface from the VPP record
+ */
+std::unique_ptr<interface> new_interface(
+ const vapi_payload_sw_interface_details& vd);
+
+/**
+ * A command class to create Loopback interfaces in VPP
+ */
+class loopback_create_cmd : public interface::create_cmd<vapi::Create_loopback>
+{
+public:
+ /**
+ * Constructor taking the HW::item to update
+ * and the name of the interface to create
+ */
+ loopback_create_cmd(HW::item<handle_t>& item, const std::string& name);
+ ~loopback_create_cmd() = default;
+
+ /**
+ * Issue the command to VPP/HW
+ */
+ rc_t issue(connection& con);
+
+ /**
+ * convert to string format for debug purposes
+ */
+ std::string to_string() const;
+};
+
+/**
+ * A command class to create af_packet interfaces in VPP
+ */
+class af_packet_create_cmd
+ : public interface::create_cmd<vapi::Af_packet_create>
+{
+public:
+ /**
+ * Constructor taking the HW::item to update
+ * and the name of the interface to create
+ */
+ af_packet_create_cmd(HW::item<handle_t>& item, const std::string& name);
+ ~af_packet_create_cmd() = default;
+ /**
+ * Issue the command to VPP/HW
+ */
+ rc_t issue(connection& con);
+ /**
+ * convert to string format for debug purposes
+ */
+ std::string to_string() const;
+};
+
+/**
+* A command class to create TAP interfaces in VPP
+*/
+class tap_create_cmd : public interface::create_cmd<vapi::Tap_connect>
+{
+public:
+ /**
+ * Constructor taking the HW::item to update
+ * and the name of the interface to create
+ */
+ tap_create_cmd(HW::item<handle_t>& item, const std::string& name);
+ ~tap_create_cmd() = default;
+
+ /**
+ * Issue the command to VPP/HW
+ */
+ rc_t issue(connection& con);
+
+ /**
+ * convert to string format for debug purposes
+ */
+ std::string to_string() const;
+};
+
+/**
+ * A command class to delete loopback interfaces in VPP
+ */
+class loopback_delete_cmd : public interface::delete_cmd<vapi::Delete_loopback>
+{
+public:
+ /**
+ * Constructor taking the HW::item to update
+ */
+ loopback_delete_cmd(HW::item<handle_t>& item);
+
+ /**
+ * Issue the command to VPP/HW
+ */
+ rc_t issue(connection& con);
+ /**
+ * convert to string format for debug purposes
+ */
+ std::string to_string() const;
+};
+
+/**
+ * A command class to delete af-packet interfaces in VPP
+ */
+class af_packet_delete_cmd
+ : public interface::delete_cmd<vapi::Af_packet_delete>
+{
+public:
+ /**
+ * Constructor taking the HW::item to update
+ * and the name of the interface to delete
+ */
+ af_packet_delete_cmd(HW::item<handle_t>& item, const std::string& name);
+
+ /**
+ * Issue the command to VPP/HW
+ */
+ rc_t issue(connection& con);
+ /**
+ * convert to string format for debug purposes
+ */
+ std::string to_string() const;
+};
+
+/**
+* A command class to delete TAP interfaces in VPP
+*/
+class tap_delete_cmd : public interface::delete_cmd<vapi::Tap_delete>
+{
+public:
+ /**
+ * Constructor taking the HW::item to update
+ */
+ tap_delete_cmd(HW::item<handle_t>& item);
+
+ /**
+ * Issue the command to VPP/HW
+ */
+ rc_t issue(connection& con);
+ /**
+ * convert to string format for debug purposes
+ */
+ std::string to_string() const;
+};
+
+/**
+ * A command class to set tag on interfaces
+ */
+class set_tag
+ : public rpc_cmd<HW::item<handle_t>, rc_t, vapi::Sw_interface_tag_add_del>
+{
+public:
+ /**
+ * Constructor taking the HW::item to update
+ */
+ set_tag(HW::item<handle_t>& item, const std::string& name);
+
+ /**
+ * 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 set_tag& i) const;
+
+private:
+ /**
+ * The tag to add
+ */
+ const std::string m_name;
+};
+
+/**
+ * A cmd class that changes the admin state
+ */
+class state_change_cmd : public rpc_cmd<HW::item<interface::admin_state_t>,
+ rc_t,
+ vapi::Sw_interface_set_flags>
+{
+public:
+ /**
+ * Constructor taking the HW::item to update
+ * and the name handle of the interface whose state is to change
+ */
+ state_change_cmd(HW::item<interface::admin_state_t>& s,
+ const HW::item<handle_t>& h);
+
+ /**
+ * 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 state_change_cmd& i) const;
+
+private:
+ /**
+ * the handle of the interface to update
+ */
+ const HW::item<handle_t>& m_hdl;
+};
+
+/**
+ * A command class that binds an interface to an L3 table
+ */
+class set_table_cmd : public rpc_cmd<HW::item<route::table_id_t>,
+ rc_t,
+ vapi::Sw_interface_set_table>
+{
+public:
+ /**
+ * Constructor taking the HW::item to update
+ * and the name handle of the interface whose table is to change
+ */
+ set_table_cmd(HW::item<route::table_id_t>& item,
+ const l3_proto_t& proto,
+ const HW::item<handle_t>& h);
+
+ /**
+ * 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 set_table_cmd& i) const;
+
+private:
+ /**
+ * the handle of the interface to update
+ */
+ const HW::item<handle_t>& m_hdl;
+
+ /**
+ * The L3 protocol of the table
+ */
+ l3_proto_t m_proto;
+};
+
+/**
+ * A command class that binds an interface to an L3 table
+ */
+class set_mac_cmd : public rpc_cmd<HW::item<l2_address_t>,
+ rc_t,
+ vapi::Sw_interface_set_mac_address>
+{
+public:
+ /**
+ * Constructor taking the HW::item to update
+ * and the handle of the interface
+ */
+ set_mac_cmd(HW::item<l2_address_t>& item, const HW::item<handle_t>& h);
+
+ /**
+ * 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 set_mac_cmd& i) const;
+
+private:
+ /**
+ * the handle of the interface to update
+ */
+ const HW::item<handle_t>& m_hdl;
+};
+
+/**
+ * A command class represents our desire to recieve interface events
+ */
+class events_cmd
+ : public event_cmd<vapi::Want_interface_events, vapi::Sw_interface_event>
+{
+public:
+ /**
+ * Constructor taking the listner to notify
+ */
+ events_cmd(interface::event_listener& el);
+
+ /**
+ * Issue the command to VPP/HW
+ */
+ rc_t issue(connection& con);
+
+ /**
+ * Retires the command - unsubscribe from the events.
+ */
+ void retire(connection& con);
+
+ /**
+ * convert to string format for debug purposes
+ */
+ std::string to_string() const;
+
+ /**
+ * Comparison operator - only used for UT
+ */
+ bool operator==(const events_cmd& i) const;
+
+ /**
+ * Called when it's time to poke the listeners
+ */
+ void notify();
+
+private:
+ /**
+ * The listeners to notify when data/events arrive
+ */
+ interface::interface::event_listener& m_listener;
+};
+
+/**
+ * A command class represents our desire to recieve interface stats
+ */
+class stats_cmd : public event_cmd<vapi::Want_per_interface_combined_stats,
+ vapi::Vnet_per_interface_combined_counters>
+{
+public:
+ /**
+ * Constructor taking the listner to notify
+ */
+ stats_cmd(interface::stat_listener& el,
+ const std::vector<handle_t>& interfaces);
+
+ /**
+ * Issue the command to VPP/HW
+ */
+ rc_t issue(connection& con);
+
+ /**
+ * Retires the command - unsubscribe from the stats.
+ */
+ void retire(connection& con);
+
+ /**
+ * convert to string format for debug purposes
+ */
+ std::string to_string() const;
+
+ /**
+ * Comparison operator - only used for UT
+ */
+ bool operator==(const stats_cmd& i) const;
+
+ /**
+ * Called when it's time to poke the listeners
+ */
+ void notify();
+
+private:
+ /**
+ * The listeners to notify when data/stats arrive
+ */
+ interface::interface::stat_listener& m_listener;
+
+ std::vector<handle_t> m_swifindex;
+};
+
+/**
+ * A cmd class that Dumps all the Vpp interfaces
+ */
+class dump_cmd : public VOM::dump_cmd<vapi::Sw_interface_dump>
+{
+public:
+ /**
+ * Default Constructor
+ */
+ dump_cmd();
+
+ /**
+ * 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;
+};
+};
+};
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
+#endif
diff --git a/src/vpp-api/vom/interface_factory.cpp b/src/vpp-api/vom/interface_factory.cpp
index aac968c1b3a..cd2d373f0bf 100644
--- a/src/vpp-api/vom/interface_factory.cpp
+++ b/src/vpp-api/vom/interface_factory.cpp
@@ -15,13 +15,13 @@
#include <boost/algorithm/string.hpp>
-#include "vom/interface.hpp"
+#include "vom/interface_factory.hpp"
#include "vom/sub_interface.hpp"
#include "vom/tap_interface.hpp"
namespace VOM {
std::unique_ptr<interface>
-interface::new_interface(const vapi_payload_sw_interface_details& vd)
+interface_factory::new_interface(const vapi_payload_sw_interface_details& vd)
{
std::unique_ptr<interface> up_itf;
@@ -29,12 +29,13 @@ interface::new_interface(const vapi_payload_sw_interface_details& vd)
* Determine the interface type from the name and VLAN attributes
*/
std::string name = reinterpret_cast<const char*>(vd.interface_name);
- type_t type = interface::type_t::from_string(name);
- admin_state_t state = interface::admin_state_t::from_int(vd.link_up_down);
+ interface::type_t type = interface::type_t::from_string(name);
+ interface::admin_state_t state =
+ interface::admin_state_t::from_int(vd.link_up_down);
handle_t hdl(vd.sw_if_index);
l2_address_t l2_address(vd.l2_address, vd.l2_address_length);
- if (type_t::AFPACKET == type) {
+ if (interface::type_t::AFPACKET == type) {
/*
* need to strip VPP's "host-" prefix from the interface name
*/
@@ -52,7 +53,7 @@ interface::new_interface(const vapi_payload_sw_interface_details& vd)
/*
* pull out the other special cases
*/
- if (type_t::TAP == type) {
+ if (interface::type_t::TAP == type) {
/*
* TAP interface
*/
@@ -67,7 +68,7 @@ interface::new_interface(const vapi_payload_sw_interface_details& vd)
interface parent(parts[0], type, state);
up_itf.reset(new sub_interface(hdl, parent, state, vd.sub_id));
- } else if (type_t::VXLAN == type) {
+ } else if (interface::type_t::VXLAN == type) {
/*
* there's not enough inforation in a SW interface record to
* construct
@@ -79,7 +80,7 @@ interface::new_interface(const vapi_payload_sw_interface_details& vd)
return (up_itf);
}
-}
+}; // namespace VOM
/*
* fd.io coding-style-patch-verification: ON
diff --git a/src/vpp-api/vom/interface_factory.hpp b/src/vpp-api/vom/interface_factory.hpp
new file mode 100644
index 00000000000..47faecc5934
--- /dev/null
+++ b/src/vpp-api/vom/interface_factory.hpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2017 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_INTERFACE_FACTORY_H__
+#define __VOM_INTERFACE_FACTORY_H__
+
+#include <vapi/vapi.hpp>
+
+#include "vom/interface.hpp"
+
+#include <vapi/interface.api.vapi.hpp>
+
+namespace VOM {
+
+class interface_factory
+{
+public:
+ /**
+ * Factory method to construct a new interface from the VPP record
+ */
+ static std::unique_ptr<interface> new_interface(
+ const vapi_payload_sw_interface_details& vd);
+};
+};
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
+#endif
diff --git a/src/vpp-api/vom/interface_ip6_nd.hpp b/src/vpp-api/vom/interface_ip6_nd.hpp
index 38845e36870..4c7f3915cf2 100644
--- a/src/vpp-api/vom/interface_ip6_nd.hpp
+++ b/src/vpp-api/vom/interface_ip6_nd.hpp
@@ -28,8 +28,6 @@
#include "vom/singular_db.hpp"
#include "vom/sub_interface.hpp"
-#include <vapi/ip.api.vapi.hpp>
-
namespace VOM {
/**
* A representation of L3 configuration on an interface
diff --git a/src/vpp-api/vom/interface_span.cpp b/src/vpp-api/vom/interface_span.cpp
index 88bec50ac3d..04c319259c9 100644
--- a/src/vpp-api/vom/interface_span.cpp
+++ b/src/vpp-api/vom/interface_span.cpp
@@ -14,7 +14,7 @@
*/
#include "vom/interface_span.hpp"
-#include "vom/cmd.hpp"
+#include "vom/interface_span_cmds.hpp"
namespace VOM {
/**
@@ -54,8 +54,8 @@ void
interface_span::sweep()
{
if (m_config) {
- HW::enqueue(
- new unconfig_cmd(m_config, m_itf_from->handle(), m_itf_to->handle()));
+ HW::enqueue(new interface_span_cmds::unconfig_cmd(
+ m_config, m_itf_from->handle(), m_itf_to->handle()));
}
HW::write();
}
@@ -70,8 +70,8 @@ void
interface_span::replay()
{
if (m_config) {
- HW::enqueue(new config_cmd(m_config, m_itf_from->handle(),
- m_itf_to->handle(), m_state));
+ HW::enqueue(new interface_span_cmds::config_cmd(
+ m_config, m_itf_from->handle(), m_itf_to->handle(), m_state));
}
}
@@ -90,8 +90,8 @@ void
interface_span::update(const interface_span& desired)
{
if (!m_config) {
- HW::enqueue(new config_cmd(m_config, m_itf_from->handle(),
- m_itf_to->handle(), m_state));
+ HW::enqueue(new interface_span_cmds::config_cmd(
+ m_config, m_itf_from->handle(), m_itf_to->handle(), m_state));
}
}
@@ -132,7 +132,8 @@ interface_span::event_handler::handle_replay()
void
interface_span::event_handler::handle_populate(const client_db::key_t& key)
{
- std::shared_ptr<interface_span::dump_cmd> cmd(new interface_span::dump_cmd());
+ std::shared_ptr<interface_span_cmds::dump_cmd> cmd(
+ new interface_span_cmds::dump_cmd());
HW::enqueue(cmd);
HW::write();
diff --git a/src/vpp-api/vom/interface_span.hpp b/src/vpp-api/vom/interface_span.hpp
index b70c3164853..8d3d7cb2532 100644
--- a/src/vpp-api/vom/interface_span.hpp
+++ b/src/vpp-api/vom/interface_span.hpp
@@ -16,17 +16,13 @@
#ifndef __VOM_INTERFACE_SPAN_H__
#define __VOM_INTERFACE_SPAN_H__
-#include "vom/dump_cmd.hpp"
#include "vom/hw.hpp"
#include "vom/inspect.hpp"
#include "vom/interface.hpp"
#include "vom/object_base.hpp"
#include "vom/om.hpp"
-#include "vom/rpc_cmd.hpp"
#include "vom/singular_db.hpp"
-#include <vapi/span.api.vapi.hpp>
-
namespace VOM {
/**
* A representation of interface span configuration
@@ -114,124 +110,6 @@ public:
*/
static std::shared_ptr<interface_span> find(const interface& i);
- /**
- * A command class that configures the interface span
- */
- class config_cmd : public rpc_cmd<HW::item<bool>,
- rc_t,
- vapi::Sw_interface_span_enable_disable>
- {
- public:
- /**
- * Constructor
- */
- config_cmd(HW::item<bool>& item,
- const handle_t& itf_from,
- const handle_t& itf_to,
- const state_t& state);
-
- /**
- * 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 config_cmd& i) const;
-
- private:
- /**
- * Reference to the interface to be mirrored
- */
- const handle_t& m_itf_from;
- /**
- * Reference to the interface where the traffic is mirrored
- */
- const handle_t& m_itf_to;
- /**
- * the state (rx, tx or both) of the interface to be mirrored
- */
- const state_t& m_state;
- };
-
- /**
- * A cmd class that Unconfigs interface span
- */
- class unconfig_cmd : public rpc_cmd<HW::item<bool>,
- rc_t,
- vapi::Sw_interface_span_enable_disable>
- {
- public:
- /**
- * Constructor
- */
- unconfig_cmd(HW::item<bool>& item,
- const handle_t& itf_from,
- const handle_t& itf_to);
-
- /**
- * 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 unconfig_cmd& i) const;
-
- private:
- /**
- * Reference to the interface to be mirrored
- */
- const handle_t& m_itf_from;
- /**
- * Reference to the interface where the traffic is mirrored
- */
- const handle_t& m_itf_to;
- };
-
- /**
- * A cmd class that Dumps all the interface spans
- */
- class dump_cmd : public VOM::dump_cmd<vapi::Sw_interface_span_dump>
- {
- public:
- /**
- * Constructor
- */
- dump_cmd();
- 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;
- };
-
private:
/**
* Class definition for listeners to OM events
diff --git a/src/vpp-api/vom/interface_span_cmds.cpp b/src/vpp-api/vom/interface_span_cmds.cpp
index 27fec801b89..3b8b8d25ec7 100644
--- a/src/vpp-api/vom/interface_span_cmds.cpp
+++ b/src/vpp-api/vom/interface_span_cmds.cpp
@@ -13,15 +13,17 @@
* limitations under the License.
*/
-#include "vom/interface_span.hpp"
+#include "vom/interface_span_cmds.hpp"
DEFINE_VAPI_MSG_IDS_SPAN_API_JSON;
namespace VOM {
-interface_span::config_cmd::config_cmd(HW::item<bool>& item,
- const handle_t& itf_from,
- const handle_t& itf_to,
- const interface_span::state_t& state)
+namespace interface_span_cmds {
+
+config_cmd::config_cmd(HW::item<bool>& item,
+ const handle_t& itf_from,
+ const handle_t& itf_to,
+ const interface_span::state_t& state)
: rpc_cmd(item)
, m_itf_from(itf_from)
, m_itf_to(itf_to)
@@ -30,14 +32,14 @@ interface_span::config_cmd::config_cmd(HW::item<bool>& item,
}
bool
-interface_span::config_cmd::operator==(const config_cmd& o) const
+config_cmd::operator==(const config_cmd& o) const
{
return ((m_itf_from == o.m_itf_from) && (m_itf_to == o.m_itf_to) &&
(m_state == o.m_state));
}
rc_t
-interface_span::config_cmd::issue(connection& con)
+config_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -55,7 +57,7 @@ interface_span::config_cmd::issue(connection& con)
}
std::string
-interface_span::config_cmd::to_string() const
+config_cmd::to_string() const
{
std::ostringstream s;
s << "itf-span-config: " << m_hw_item.to_string()
@@ -65,9 +67,9 @@ interface_span::config_cmd::to_string() const
return (s.str());
}
-interface_span::unconfig_cmd::unconfig_cmd(HW::item<bool>& item,
- const handle_t& itf_from,
- const handle_t& itf_to)
+unconfig_cmd::unconfig_cmd(HW::item<bool>& item,
+ const handle_t& itf_from,
+ const handle_t& itf_to)
: rpc_cmd(item)
, m_itf_from(itf_from)
, m_itf_to(itf_to)
@@ -75,13 +77,13 @@ interface_span::unconfig_cmd::unconfig_cmd(HW::item<bool>& item,
}
bool
-interface_span::unconfig_cmd::operator==(const unconfig_cmd& o) const
+unconfig_cmd::operator==(const unconfig_cmd& o) const
{
return ((m_itf_from == o.m_itf_from) && (m_itf_to == o.m_itf_to));
}
rc_t
-interface_span::unconfig_cmd::issue(connection& con)
+unconfig_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -100,7 +102,7 @@ interface_span::unconfig_cmd::issue(connection& con)
}
std::string
-interface_span::unconfig_cmd::to_string() const
+unconfig_cmd::to_string() const
{
std::ostringstream s;
s << "itf-span-unconfig: " << m_hw_item.to_string()
@@ -110,18 +112,18 @@ interface_span::unconfig_cmd::to_string() const
return (s.str());
}
-interface_span::dump_cmd::dump_cmd()
+dump_cmd::dump_cmd()
{
}
bool
-interface_span::dump_cmd::operator==(const dump_cmd& other) const
+dump_cmd::operator==(const dump_cmd& other) const
{
return (true);
}
rc_t
-interface_span::dump_cmd::issue(connection& con)
+dump_cmd::issue(connection& con)
{
m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
@@ -136,11 +138,13 @@ interface_span::dump_cmd::issue(connection& con)
}
std::string
-interface_span::dump_cmd::to_string() const
+dump_cmd::to_string() const
{
return ("interface-span-dump");
}
-}
+
+}; // namespace interface_span_cmds
+}; // namespace VOM
/*
* fd.io coding-style-patch-verification: ON
diff --git a/src/vpp-api/vom/interface_span_cmds.hpp b/src/vpp-api/vom/interface_span_cmds.hpp
new file mode 100644
index 00000000000..fa8096ebb10
--- /dev/null
+++ b/src/vpp-api/vom/interface_span_cmds.hpp
@@ -0,0 +1,154 @@
+/*
+ * Copyright (c) 2017 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_INTERFACE_SPAN_CMDS_H__
+#define __VOM_INTERFACE_SPAN_CMDS_H__
+
+#include "vom/dump_cmd.hpp"
+#include "vom/interface_span.hpp"
+#include "vom/rpc_cmd.hpp"
+
+#include <vapi/span.api.vapi.hpp>
+
+namespace VOM {
+namespace interface_span_cmds {
+
+/**
+ * A command class that configures the interface span
+ */
+class config_cmd
+ : public rpc_cmd<HW::item<bool>, rc_t, vapi::Sw_interface_span_enable_disable>
+{
+public:
+ /**
+ * Constructor
+ */
+ config_cmd(HW::item<bool>& item,
+ const handle_t& itf_from,
+ const handle_t& itf_to,
+ const interface_span::state_t& state);
+
+ /**
+ * 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 config_cmd& i) const;
+
+private:
+ /**
+ * Reference to the interface to be mirrored
+ */
+ const handle_t& m_itf_from;
+ /**
+ * Reference to the interface where the traffic is mirrored
+ */
+ const handle_t& m_itf_to;
+ /**
+ * the state (rx, tx or both) of the interface to be mirrored
+ */
+ const interface_span::state_t& m_state;
+};
+
+/**
+ * A cmd class that Unconfigs interface span
+ */
+class unconfig_cmd
+ : public rpc_cmd<HW::item<bool>, rc_t, vapi::Sw_interface_span_enable_disable>
+{
+public:
+ /**
+ * Constructor
+ */
+ unconfig_cmd(HW::item<bool>& item,
+ const handle_t& itf_from,
+ const handle_t& itf_to);
+
+ /**
+ * 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 unconfig_cmd& i) const;
+
+private:
+ /**
+ * Reference to the interface to be mirrored
+ */
+ const handle_t& m_itf_from;
+ /**
+ * Reference to the interface where the traffic is mirrored
+ */
+ const handle_t& m_itf_to;
+};
+
+/**
+ * A cmd class that Dumps all the interface spans
+ */
+class dump_cmd : public VOM::dump_cmd<vapi::Sw_interface_span_dump>
+{
+public:
+ /**
+ * Constructor
+ */
+ dump_cmd();
+ 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;
+};
+};
+};
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
+
+#endif
diff --git a/src/vpp-api/vom/ip_unnumbered.cpp b/src/vpp-api/vom/ip_unnumbered.cpp
index 7df391c0b69..ef693e9f140 100644
--- a/src/vpp-api/vom/ip_unnumbered.cpp
+++ b/src/vpp-api/vom/ip_unnumbered.cpp
@@ -14,7 +14,7 @@
*/
#include "vom/ip_unnumbered.hpp"
-#include "vom/cmd.hpp"
+#include "vom/ip_unnumbered_cmds.hpp"
namespace VOM {
/**
@@ -49,8 +49,8 @@ void
ip_unnumbered::sweep()
{
if (m_config) {
- HW::enqueue(
- new unconfig_cmd(m_config, m_itf->handle(), m_l3_itf->handle()));
+ HW::enqueue(new ip_unnumbered_cmds::unconfig_cmd(m_config, m_itf->handle(),
+ m_l3_itf->handle()));
}
HW::write();
}
@@ -65,7 +65,8 @@ void
ip_unnumbered::replay()
{
if (m_config) {
- HW::enqueue(new config_cmd(m_config, m_itf->handle(), m_l3_itf->handle()));
+ HW::enqueue(new ip_unnumbered_cmds::config_cmd(m_config, m_itf->handle(),
+ m_l3_itf->handle()));
}
}
@@ -83,7 +84,8 @@ void
ip_unnumbered::update(const ip_unnumbered& desired)
{
if (!m_config) {
- HW::enqueue(new config_cmd(m_config, m_itf->handle(), m_l3_itf->handle()));
+ HW::enqueue(new ip_unnumbered_cmds::config_cmd(m_config, m_itf->handle(),
+ m_l3_itf->handle()));
}
}
diff --git a/src/vpp-api/vom/ip_unnumbered.hpp b/src/vpp-api/vom/ip_unnumbered.hpp
index e6f5ef4399b..676c7780b86 100644
--- a/src/vpp-api/vom/ip_unnumbered.hpp
+++ b/src/vpp-api/vom/ip_unnumbered.hpp
@@ -21,7 +21,6 @@
#include "vom/interface.hpp"
#include "vom/object_base.hpp"
#include "vom/om.hpp"
-#include "vom/rpc_cmd.hpp"
#include "vom/singular_db.hpp"
namespace VOM {
@@ -76,84 +75,6 @@ public:
*/
static std::shared_ptr<ip_unnumbered> find(const interface& i);
- /**
- * A command class that configures the IP unnumbered
- */
- class config_cmd
- : public rpc_cmd<HW::item<bool>, rc_t, vapi::Sw_interface_set_unnumbered>
- {
- public:
- /**
- * Constructor
- */
- config_cmd(HW::item<bool>& item,
- const handle_t& itf,
- const handle_t& l3_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 config_cmd& i) const;
-
- private:
- /**
- * Reference to the interface for which the address is required
- */
- const handle_t& m_itf;
- /**
- * Reference to the interface which has an address
- */
- const handle_t& m_l3_itf;
- };
-
- /**
- * A cmd class that Unconfigs L3 Config from an interface
- */
- class unconfig_cmd
- : public rpc_cmd<HW::item<bool>, rc_t, vapi::Sw_interface_set_unnumbered>
- {
- public:
- /**
- * Constructor
- */
- unconfig_cmd(HW::item<bool>& item,
- const handle_t& itf,
- const handle_t& l3_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 unconfig_cmd& i) const;
-
- private:
- /**
- * Reference to the interface for which the address is required
- */
- const handle_t& m_itf;
- /**
- * Reference to the interface which has an address
- */
- const handle_t& m_l3_itf;
- };
-
private:
/**
* Class definition for listeners to OM events
diff --git a/src/vpp-api/vom/ip_unnumbered_cmds.cpp b/src/vpp-api/vom/ip_unnumbered_cmds.cpp
index 768d3562b18..4c1fcf6d465 100644
--- a/src/vpp-api/vom/ip_unnumbered_cmds.cpp
+++ b/src/vpp-api/vom/ip_unnumbered_cmds.cpp
@@ -13,14 +13,16 @@
* limitations under the License.
*/
-#include "vom/ip_unnumbered.hpp"
+#include "vom/ip_unnumbered_cmds.hpp"
#include <vapi/vpe.api.vapi.hpp>
namespace VOM {
-ip_unnumbered::config_cmd::config_cmd(HW::item<bool>& item,
- const handle_t& itf,
- const handle_t& l3_itf)
+namespace ip_unnumbered_cmds {
+
+config_cmd::config_cmd(HW::item<bool>& item,
+ const handle_t& itf,
+ const handle_t& l3_itf)
: rpc_cmd(item)
, m_itf(itf)
, m_l3_itf(l3_itf)
@@ -28,13 +30,13 @@ ip_unnumbered::config_cmd::config_cmd(HW::item<bool>& item,
}
bool
-ip_unnumbered::config_cmd::operator==(const config_cmd& o) const
+config_cmd::operator==(const config_cmd& o) const
{
return ((m_itf == o.m_itf) && (m_l3_itf == o.m_l3_itf));
}
rc_t
-ip_unnumbered::config_cmd::issue(connection& con)
+config_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -51,7 +53,7 @@ ip_unnumbered::config_cmd::issue(connection& con)
}
std::string
-ip_unnumbered::config_cmd::to_string() const
+config_cmd::to_string() const
{
std::ostringstream s;
s << "IP-unnumberd-config: " << m_hw_item.to_string()
@@ -60,9 +62,9 @@ ip_unnumbered::config_cmd::to_string() const
return (s.str());
}
-ip_unnumbered::unconfig_cmd::unconfig_cmd(HW::item<bool>& item,
- const handle_t& itf,
- const handle_t& l3_itf)
+unconfig_cmd::unconfig_cmd(HW::item<bool>& item,
+ const handle_t& itf,
+ const handle_t& l3_itf)
: rpc_cmd(item)
, m_itf(itf)
, m_l3_itf(l3_itf)
@@ -70,13 +72,13 @@ ip_unnumbered::unconfig_cmd::unconfig_cmd(HW::item<bool>& item,
}
bool
-ip_unnumbered::unconfig_cmd::operator==(const unconfig_cmd& o) const
+unconfig_cmd::operator==(const unconfig_cmd& o) const
{
return ((m_itf == o.m_itf) && (m_l3_itf == o.m_l3_itf));
}
rc_t
-ip_unnumbered::unconfig_cmd::issue(connection& con)
+unconfig_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -94,7 +96,7 @@ ip_unnumbered::unconfig_cmd::issue(connection& con)
}
std::string
-ip_unnumbered::unconfig_cmd::to_string() const
+unconfig_cmd::to_string() const
{
std::ostringstream s;
s << "IP-unnumberd-unconfig: " << m_hw_item.to_string()
@@ -102,7 +104,9 @@ ip_unnumbered::unconfig_cmd::to_string() const
return (s.str());
}
-}
+
+}; // namespace ip_unnumbered_cmds
+}; // namespace VOM
/*
* fd.io coding-style-patch-verification: ON
diff --git a/src/vpp-api/vom/ip_unnumbered_cmds.hpp b/src/vpp-api/vom/ip_unnumbered_cmds.hpp
new file mode 100644
index 00000000000..0bb70276e45
--- /dev/null
+++ b/src/vpp-api/vom/ip_unnumbered_cmds.hpp
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2017 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_IP_UNNUMBERED_CMDS_H__
+#define __VOM_IP_UNNUMBERED_CMDS_H__
+
+#include "vom/ip_unnumbered.hpp"
+#include "vom/rpc_cmd.hpp"
+
+#include <vapi/interface.api.vapi.hpp>
+
+namespace VOM {
+namespace ip_unnumbered_cmds {
+
+/**
+*A command class that configures the IP unnumbered
+*/
+class config_cmd
+ : public rpc_cmd<HW::item<bool>, rc_t, vapi::Sw_interface_set_unnumbered>
+{
+public:
+ /**
+ * Constructor
+ */
+ config_cmd(HW::item<bool>& item, const handle_t& itf, const handle_t& l3_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 config_cmd& i) const;
+
+private:
+ /**
+ * Reference to the interface for which the address is required
+ */
+ const handle_t& m_itf;
+ /**
+ * Reference to the interface which has an address
+ */
+ const handle_t& m_l3_itf;
+};
+
+/**
+ * A cmd class that Unconfigs L3 Config from an interface
+ */
+class unconfig_cmd
+ : public rpc_cmd<HW::item<bool>, rc_t, vapi::Sw_interface_set_unnumbered>
+{
+public:
+ /**
+ * Constructor
+ */
+ unconfig_cmd(HW::item<bool>& item,
+ const handle_t& itf,
+ const handle_t& l3_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 unconfig_cmd& i) const;
+
+private:
+ /**
+ * Reference to the interface for which the address is required
+ */
+ const handle_t& m_itf;
+ /**
+ * Reference to the interface which has an address
+ */
+ const handle_t& m_l3_itf;
+};
+
+}; // namespace ip_unnumbered_cmds
+}; // namespace VOM
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
+
+#endif
diff --git a/src/vpp-api/vom/l2_binding.cpp b/src/vpp-api/vom/l2_binding.cpp
index 3bdc8f9cd0b..e380760805c 100644
--- a/src/vpp-api/vom/l2_binding.cpp
+++ b/src/vpp-api/vom/l2_binding.cpp
@@ -14,7 +14,7 @@
*/
#include "vom/l2_binding.hpp"
-#include "vom/cmd.hpp"
+#include "vom/l2_binding_cmds.hpp"
namespace VOM {
/**
@@ -79,8 +79,9 @@ void
l2_binding::sweep()
{
if (m_binding && handle_t::INVALID != m_itf->handle()) {
- HW::enqueue(new unbind_cmd(m_binding, m_itf->handle(), m_bd->id(),
- interface::type_t::BVI == m_itf->type()));
+ HW::enqueue(
+ new l2_binding_cmds::unbind_cmd(m_binding, m_itf->handle(), m_bd->id(),
+ interface::type_t::BVI == m_itf->type()));
}
// no need to undo the VTR operation.
@@ -91,12 +92,14 @@ void
l2_binding::replay()
{
if (m_binding && handle_t::INVALID != m_itf->handle()) {
- HW::enqueue(new bind_cmd(m_binding, m_itf->handle(), m_bd->id(),
- interface::type_t::BVI == m_itf->type()));
+ HW::enqueue(
+ new l2_binding_cmds::bind_cmd(m_binding, m_itf->handle(), m_bd->id(),
+ interface::type_t::BVI == m_itf->type()));
}
if (m_vtr_op && handle_t::INVALID != m_itf->handle()) {
- HW::enqueue(new set_vtr_op_cmd(m_vtr_op, m_itf->handle(), m_vtr_op_tag));
+ HW::enqueue(new l2_binding_cmds::set_vtr_op_cmd(m_vtr_op, m_itf->handle(),
+ m_vtr_op_tag));
}
}
@@ -134,15 +137,17 @@ l2_binding::update(const l2_binding& desired)
* the desired state is always that the interface should be created
*/
if (rc_t::OK != m_binding.rc()) {
- HW::enqueue(new bind_cmd(m_binding, m_itf->handle(), m_bd->id(),
- interface::type_t::BVI == m_itf->type()));
+ HW::enqueue(
+ new l2_binding_cmds::bind_cmd(m_binding, m_itf->handle(), m_bd->id(),
+ interface::type_t::BVI == m_itf->type()));
}
/*
* set the VTR operation is request
*/
if (m_vtr_op.update(desired.m_vtr_op)) {
- HW::enqueue(new set_vtr_op_cmd(m_vtr_op, m_itf->handle(), m_vtr_op_tag));
+ HW::enqueue(new l2_binding_cmds::set_vtr_op_cmd(m_vtr_op, m_itf->handle(),
+ m_vtr_op_tag));
}
}
diff --git a/src/vpp-api/vom/l2_binding.hpp b/src/vpp-api/vom/l2_binding.hpp
index 2f65e38b46e..0e6f7fc0d68 100644
--- a/src/vpp-api/vom/l2_binding.hpp
+++ b/src/vpp-api/vom/l2_binding.hpp
@@ -22,9 +22,7 @@
#include "vom/interface.hpp"
#include "vom/object_base.hpp"
#include "vom/om.hpp"
-#include "vom/rpc_cmd.hpp"
#include "vom/singular_db.hpp"
-#include "vom/vxlan_tunnel.hpp"
namespace VOM {
/**
@@ -89,140 +87,6 @@ public:
*/
void set(const l2_vtr_op_t& op, uint16_t tag);
- /**
- * A functor class that binds L2 configuration to an interface
- */
- class bind_cmd
- : public rpc_cmd<HW::item<bool>, rc_t, vapi::Sw_interface_set_l2_bridge>
- {
- public:
- /**
- * Constructor
- */
- bind_cmd(HW::item<bool>& item,
- const handle_t& itf,
- uint32_t bd,
- bool is_bvi);
-
- /**
- * 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:
- /**
- * The interface to bind
- */
- const handle_t m_itf;
-
- /**
- * The bridge-domain to bind to
- */
- uint32_t m_bd;
-
- /**
- * Is it a BVI interface that is being bound
- */
- bool m_is_bvi;
- };
-
- /**
- * A cmd class that Unbinds L2 configuration from an interface
- */
- class unbind_cmd
- : public rpc_cmd<HW::item<bool>, rc_t, vapi::Sw_interface_set_l2_bridge>
- {
- public:
- /**
- * Constructor
- */
- unbind_cmd(HW::item<bool>& item,
- const handle_t& itf,
- uint32_t bd,
- bool is_bvi);
-
- /**
- * 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:
- /**
- * The interface to bind
- */
- const handle_t m_itf;
-
- /**
- * The bridge-domain to bind to
- */
- uint32_t m_bd;
-
- /**
- * Is it a BVI interface that is being bound
- */
- bool m_is_bvi;
- };
-
- /**
- * A cmd class sets the VTR operation
- */
- class set_vtr_op_cmd : public rpc_cmd<HW::item<l2_vtr_op_t>,
- rc_t,
- vapi::L2_interface_vlan_tag_rewrite>
- {
- public:
- /**
- * Constructor
- */
- set_vtr_op_cmd(HW::item<l2_vtr_op_t>& item,
- const handle_t& itf,
- uint16_t tag);
-
- /**
- * 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 set_vtr_op_cmd& i) const;
-
- private:
- /**
- * The interface to bind
- */
- const handle_t m_itf;
-
- /**
- * The tag for the operation
- */
- uint16_t m_tag;
- };
-
private:
/**
* Class definition for listeners to OM events
diff --git a/src/vpp-api/vom/l2_binding_cmds.cpp b/src/vpp-api/vom/l2_binding_cmds.cpp
index a6ed136842c..6b67c7096e8 100644
--- a/src/vpp-api/vom/l2_binding_cmds.cpp
+++ b/src/vpp-api/vom/l2_binding_cmds.cpp
@@ -13,13 +13,14 @@
* limitations under the License.
*/
-#include "vom/l2_binding.hpp"
+#include "vom/l2_binding_cmds.hpp"
namespace VOM {
-l2_binding::bind_cmd::bind_cmd(HW::item<bool>& item,
- const handle_t& itf,
- uint32_t bd,
- bool is_bvi)
+namespace l2_binding_cmds {
+bind_cmd::bind_cmd(HW::item<bool>& item,
+ const handle_t& itf,
+ uint32_t bd,
+ bool is_bvi)
: rpc_cmd(item)
, m_itf(itf)
, m_bd(bd)
@@ -28,14 +29,14 @@ l2_binding::bind_cmd::bind_cmd(HW::item<bool>& item,
}
bool
-l2_binding::bind_cmd::operator==(const bind_cmd& other) const
+bind_cmd::operator==(const bind_cmd& other) const
{
return ((m_itf == other.m_itf) && (m_bd == other.m_bd) &&
(m_is_bvi == other.m_is_bvi));
}
rc_t
-l2_binding::bind_cmd::issue(connection& con)
+bind_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -54,7 +55,7 @@ l2_binding::bind_cmd::issue(connection& con)
}
std::string
-l2_binding::bind_cmd::to_string() const
+bind_cmd::to_string() const
{
std::ostringstream s;
s << "L2-bind: " << m_hw_item.to_string() << " itf:" << m_itf.to_string()
@@ -63,10 +64,10 @@ l2_binding::bind_cmd::to_string() const
return (s.str());
}
-l2_binding::unbind_cmd::unbind_cmd(HW::item<bool>& item,
- const handle_t& itf,
- uint32_t bd,
- bool is_bvi)
+unbind_cmd::unbind_cmd(HW::item<bool>& item,
+ const handle_t& itf,
+ uint32_t bd,
+ bool is_bvi)
: rpc_cmd(item)
, m_itf(itf)
, m_bd(bd)
@@ -75,14 +76,14 @@ l2_binding::unbind_cmd::unbind_cmd(HW::item<bool>& item,
}
bool
-l2_binding::unbind_cmd::operator==(const unbind_cmd& other) const
+unbind_cmd::operator==(const unbind_cmd& other) const
{
return ((m_itf == other.m_itf) && (m_bd == other.m_bd) &&
(m_is_bvi == other.m_is_bvi));
}
rc_t
-l2_binding::unbind_cmd::issue(connection& con)
+unbind_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -102,7 +103,7 @@ l2_binding::unbind_cmd::issue(connection& con)
}
std::string
-l2_binding::unbind_cmd::to_string() const
+unbind_cmd::to_string() const
{
std::ostringstream s;
s << "L2-unbind: " << m_hw_item.to_string() << " itf:" << m_itf.to_string()
@@ -111,9 +112,9 @@ l2_binding::unbind_cmd::to_string() const
return (s.str());
}
-l2_binding::set_vtr_op_cmd::set_vtr_op_cmd(HW::item<l2_vtr_op_t>& item,
- const handle_t& itf,
- uint16_t tag)
+set_vtr_op_cmd::set_vtr_op_cmd(HW::item<l2_binding::l2_vtr_op_t>& item,
+ const handle_t& itf,
+ uint16_t tag)
: rpc_cmd(item)
, m_itf(itf)
, m_tag(tag)
@@ -121,7 +122,7 @@ l2_binding::set_vtr_op_cmd::set_vtr_op_cmd(HW::item<l2_vtr_op_t>& item,
}
bool
-l2_binding::set_vtr_op_cmd::operator==(const set_vtr_op_cmd& other) const
+set_vtr_op_cmd::operator==(const set_vtr_op_cmd& other) const
{
return (
(m_hw_item.data() == other.m_hw_item.data() && m_itf == other.m_itf) &&
@@ -129,7 +130,7 @@ l2_binding::set_vtr_op_cmd::operator==(const set_vtr_op_cmd& other) const
}
rc_t
-l2_binding::set_vtr_op_cmd::issue(connection& con)
+set_vtr_op_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -148,7 +149,7 @@ l2_binding::set_vtr_op_cmd::issue(connection& con)
}
std::string
-l2_binding::set_vtr_op_cmd::to_string() const
+set_vtr_op_cmd::to_string() const
{
std::ostringstream s;
s << "L2-set-vtr-op: " << m_hw_item.to_string()
@@ -156,7 +157,9 @@ l2_binding::set_vtr_op_cmd::to_string() const
return (s.str());
}
-}
+
+}; // namespace l2_binding_cmds
+}; // namespace VOM
/*
* fd.io coding-style-patch-verification: ON
diff --git a/src/vpp-api/vom/l2_binding_cmds.hpp b/src/vpp-api/vom/l2_binding_cmds.hpp
new file mode 100644
index 00000000000..d105c18a40d
--- /dev/null
+++ b/src/vpp-api/vom/l2_binding_cmds.hpp
@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 2017 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_L2_BINDING_CMDS_H__
+#define __VOM_L2_BINDING_CMDS_H__
+
+#include "vom/l2_binding.hpp"
+#include "vom/rpc_cmd.hpp"
+
+#include <vapi/l2.api.vapi.hpp>
+#include <vapi/vpe.api.vapi.hpp>
+
+namespace VOM {
+namespace l2_binding_cmds {
+
+/**
+ * A functor class that binds L2 configuration to an interface
+ */
+class bind_cmd
+ : public rpc_cmd<HW::item<bool>, rc_t, vapi::Sw_interface_set_l2_bridge>
+{
+public:
+ /**
+ * Constructor
+ */
+ bind_cmd(HW::item<bool>& item, const handle_t& itf, uint32_t bd, bool is_bvi);
+
+ /**
+ * 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:
+ /**
+ * The interface to bind
+ */
+ const handle_t m_itf;
+
+ /**
+ * The bridge-domain to bind to
+ */
+ uint32_t m_bd;
+
+ /**
+ * Is it a BVI interface that is being bound
+ */
+ bool m_is_bvi;
+};
+
+/**
+ * A cmd class that Unbinds L2 configuration from an interface
+ */
+class unbind_cmd
+ : public rpc_cmd<HW::item<bool>, rc_t, vapi::Sw_interface_set_l2_bridge>
+{
+public:
+ /**
+ * Constructor
+ */
+ unbind_cmd(HW::item<bool>& item,
+ const handle_t& itf,
+ uint32_t bd,
+ bool is_bvi);
+
+ /**
+ * 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:
+ /**
+ * The interface to bind
+ */
+ const handle_t m_itf;
+
+ /**
+ * The bridge-domain to bind to
+ */
+ uint32_t m_bd;
+
+ /**
+ * Is it a BVI interface that is being bound
+ */
+ bool m_is_bvi;
+};
+
+/**
+ * A cmd class sets the VTR operation
+ */
+class set_vtr_op_cmd : public rpc_cmd<HW::item<l2_binding::l2_vtr_op_t>,
+ rc_t,
+ vapi::L2_interface_vlan_tag_rewrite>
+{
+public:
+ /**
+ * Constructor
+ */
+ set_vtr_op_cmd(HW::item<l2_binding::l2_vtr_op_t>& item,
+ const handle_t& itf,
+ uint16_t tag);
+
+ /**
+ * 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 set_vtr_op_cmd& i) const;
+
+private:
+ /**
+ * The interface to bind
+ */
+ const handle_t m_itf;
+
+ /**
+ * The tag for the operation
+ */
+ uint16_t m_tag;
+};
+
+}; // namespace l2_binding_cmds
+}; // namespace VOM
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
+
+#endif
diff --git a/src/vpp-api/vom/l3_binding.cpp b/src/vpp-api/vom/l3_binding.cpp
index 0d5f4149e26..8bc7c7c3af3 100644
--- a/src/vpp-api/vom/l3_binding.cpp
+++ b/src/vpp-api/vom/l3_binding.cpp
@@ -14,7 +14,7 @@
*/
#include "vom/l3_binding.hpp"
-#include "vom/cmd.hpp"
+#include "vom/l3_binding_cmds.hpp"
namespace VOM {
singular_db<l3_binding::key_type_t, l3_binding> l3_binding::m_db;
@@ -50,7 +50,8 @@ void
l3_binding::sweep()
{
if (m_binding) {
- HW::enqueue(new unbind_cmd(m_binding, m_itf->handle(), m_pfx));
+ HW::enqueue(
+ new l3_binding_cmds::unbind_cmd(m_binding, m_itf->handle(), m_pfx));
}
HW::write();
}
@@ -59,7 +60,8 @@ void
l3_binding::replay()
{
if (m_binding) {
- HW::enqueue(new bind_cmd(m_binding, m_itf->handle(), m_pfx));
+ HW::enqueue(
+ new l3_binding_cmds::bind_cmd(m_binding, m_itf->handle(), m_pfx));
}
}
@@ -86,7 +88,8 @@ l3_binding::update(const l3_binding& desired)
* the desired state is always that the interface should be created
*/
if (!m_binding) {
- HW::enqueue(new bind_cmd(m_binding, m_itf->handle(), m_pfx));
+ HW::enqueue(
+ new l3_binding_cmds::bind_cmd(m_binding, m_itf->handle(), m_pfx));
}
}
diff --git a/src/vpp-api/vom/l3_binding.hpp b/src/vpp-api/vom/l3_binding.hpp
index 2166b44bb94..d94ff696b23 100644
--- a/src/vpp-api/vom/l3_binding.hpp
+++ b/src/vpp-api/vom/l3_binding.hpp
@@ -16,17 +16,13 @@
#ifndef __VOM_L3_BINDING_H__
#define __VOM_L3_BINDING_H__
-#include "vom/dump_cmd.hpp"
#include "vom/hw.hpp"
#include "vom/inspect.hpp"
#include "vom/interface.hpp"
#include "vom/object_base.hpp"
#include "vom/om.hpp"
-#include "vom/rpc_cmd.hpp"
#include "vom/singular_db.hpp"
-#include <vapi/ip.api.vapi.hpp>
-
namespace VOM {
/**
* A representation of L3 configuration on an interface
@@ -80,124 +76,6 @@ public:
*/
static std::deque<std::shared_ptr<l3_binding>> find(const interface& i);
- /**
- * A functor class that binds the L3 config to the interface
- */
- class bind_cmd
- : public rpc_cmd<HW::item<bool>, rc_t, vapi::Sw_interface_add_del_address>
- {
- public:
- /**
- * Constructor
- */
- bind_cmd(HW::item<bool>& item,
- const handle_t& itf,
- const route::prefix_t& pfx);
-
- /**
- * 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 interface to bind to
- */
- const handle_t& m_itf;
-
- /**
- * The prefix to bind
- */
- const route::prefix_t& m_pfx;
- };
-
- /**
- * A cmd class that Unbinds L3 Config from an interface
- */
- class unbind_cmd
- : public rpc_cmd<HW::item<bool>, rc_t, vapi::Sw_interface_add_del_address>
- {
- public:
- /**
- * Constructor
- */
- unbind_cmd(HW::item<bool>& item,
- const handle_t& itf,
- const route::prefix_t& pfx);
-
- /**
- * 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 interface to unbind fomr
- */
- const handle_t& m_itf;
-
- /**
- * The prefix to unbind
- */
- const route::prefix_t& m_pfx;
- };
-
- /**
- * A cmd class that Dumps all the IPv4 L3 configs
- */
- class dump_v4_cmd : public dump_cmd<vapi::Ip_address_dump>
- {
- public:
- /**
- * Constructor
- */
- dump_v4_cmd(const handle_t& itf);
- dump_v4_cmd(const dump_v4_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_v4_cmd& i) const;
-
- private:
- /**
- * HW reutrn code
- */
- HW::item<bool> item;
-
- /**
- * The interface to get the addresses for
- */
- const handle_t& m_itf;
- };
-
private:
/**
* Class definition for listeners to OM events
diff --git a/src/vpp-api/vom/l3_binding_cmds.cpp b/src/vpp-api/vom/l3_binding_cmds.cpp
index 788d30f892f..66691f86059 100644
--- a/src/vpp-api/vom/l3_binding_cmds.cpp
+++ b/src/vpp-api/vom/l3_binding_cmds.cpp
@@ -13,14 +13,15 @@
* limitations under the License.
*/
-#include "vom/l3_binding.hpp"
+#include "vom/l3_binding_cmds.hpp"
DEFINE_VAPI_MSG_IDS_IP_API_JSON;
namespace VOM {
-l3_binding::bind_cmd::bind_cmd(HW::item<bool>& item,
- const handle_t& itf,
- const route::prefix_t& pfx)
+namespace l3_binding_cmds {
+bind_cmd::bind_cmd(HW::item<bool>& item,
+ const handle_t& itf,
+ const route::prefix_t& pfx)
: rpc_cmd(item)
, m_itf(itf)
, m_pfx(pfx)
@@ -28,13 +29,13 @@ l3_binding::bind_cmd::bind_cmd(HW::item<bool>& item,
}
bool
-l3_binding::bind_cmd::operator==(const bind_cmd& other) const
+bind_cmd::operator==(const bind_cmd& other) const
{
return ((m_itf == other.m_itf) && (m_pfx == other.m_pfx));
}
rc_t
-l3_binding::bind_cmd::issue(connection& con)
+bind_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -53,7 +54,7 @@ l3_binding::bind_cmd::issue(connection& con)
}
std::string
-l3_binding::bind_cmd::to_string() const
+bind_cmd::to_string() const
{
std::ostringstream s;
s << "L3-bind: " << m_hw_item.to_string() << " itf:" << m_itf.to_string()
@@ -62,9 +63,9 @@ l3_binding::bind_cmd::to_string() const
return (s.str());
}
-l3_binding::unbind_cmd::unbind_cmd(HW::item<bool>& item,
- const handle_t& itf,
- const route::prefix_t& pfx)
+unbind_cmd::unbind_cmd(HW::item<bool>& item,
+ const handle_t& itf,
+ const route::prefix_t& pfx)
: rpc_cmd(item)
, m_itf(itf)
, m_pfx(pfx)
@@ -72,13 +73,13 @@ l3_binding::unbind_cmd::unbind_cmd(HW::item<bool>& item,
}
bool
-l3_binding::unbind_cmd::operator==(const unbind_cmd& other) const
+unbind_cmd::operator==(const unbind_cmd& other) const
{
return ((m_itf == other.m_itf) && (m_pfx == other.m_pfx));
}
rc_t
-l3_binding::unbind_cmd::issue(connection& con)
+unbind_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -98,7 +99,7 @@ l3_binding::unbind_cmd::issue(connection& con)
}
std::string
-l3_binding::unbind_cmd::to_string() const
+unbind_cmd::to_string() const
{
std::ostringstream s;
s << "L3-unbind: " << m_hw_item.to_string() << " itf:" << m_itf.to_string()
@@ -107,24 +108,24 @@ l3_binding::unbind_cmd::to_string() const
return (s.str());
}
-l3_binding::dump_v4_cmd::dump_v4_cmd(const handle_t& hdl)
+dump_v4_cmd::dump_v4_cmd(const handle_t& hdl)
: m_itf(hdl)
{
}
-l3_binding::dump_v4_cmd::dump_v4_cmd(const dump_v4_cmd& d)
+dump_v4_cmd::dump_v4_cmd(const dump_v4_cmd& d)
: m_itf(d.m_itf)
{
}
bool
-l3_binding::dump_v4_cmd::operator==(const dump_v4_cmd& other) const
+dump_v4_cmd::operator==(const dump_v4_cmd& other) const
{
return (true);
}
rc_t
-l3_binding::dump_v4_cmd::issue(connection& con)
+dump_v4_cmd::issue(connection& con)
{
m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
@@ -140,11 +141,13 @@ l3_binding::dump_v4_cmd::issue(connection& con)
}
std::string
-l3_binding::dump_v4_cmd::to_string() const
+dump_v4_cmd::to_string() const
{
return ("L3-binding-dump");
}
-}
+
+}; // namespace l3_binding_cmds
+}; // namespace VOM
/*
* fd.io coding-style-patch-verification: ON
diff --git a/src/vpp-api/vom/l3_binding_cmds.hpp b/src/vpp-api/vom/l3_binding_cmds.hpp
new file mode 100644
index 00000000000..1387bc47f5d
--- /dev/null
+++ b/src/vpp-api/vom/l3_binding_cmds.hpp
@@ -0,0 +1,158 @@
+/*
+ * Copyright (c) 2017 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_L3_BINDING_CMDS_H__
+#define __VOM_L3_BINDING_CMDS_H__
+
+#include "vom/dump_cmd.hpp"
+#include "vom/l3_binding.hpp"
+#include "vom/rpc_cmd.hpp"
+
+#include <vapi/interface.api.vapi.hpp>
+#include <vapi/ip.api.vapi.hpp>
+
+namespace VOM {
+namespace l3_binding_cmds {
+
+/**
+ * A functor class that binds the L3 config to the interface
+ */
+class bind_cmd
+ : public rpc_cmd<HW::item<bool>, rc_t, vapi::Sw_interface_add_del_address>
+{
+public:
+ /**
+ * Constructor
+ */
+ bind_cmd(HW::item<bool>& item,
+ const handle_t& itf,
+ const route::prefix_t& pfx);
+
+ /**
+ * 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 interface to bind to
+ */
+ const handle_t& m_itf;
+
+ /**
+ * The prefix to bind
+ */
+ const route::prefix_t& m_pfx;
+};
+
+/**
+ * A cmd class that Unbinds L3 Config from an interface
+ */
+class unbind_cmd
+ : public rpc_cmd<HW::item<bool>, rc_t, vapi::Sw_interface_add_del_address>
+{
+public:
+ /**
+ * Constructor
+ */
+ unbind_cmd(HW::item<bool>& item,
+ const handle_t& itf,
+ const route::prefix_t& pfx);
+
+ /**
+ * 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 interface to unbind fomr
+ */
+ const handle_t& m_itf;
+
+ /**
+ * The prefix to unbind
+ */
+ const route::prefix_t& m_pfx;
+};
+
+/**
+ * A cmd class that Dumps all the IPv4 L3 configs
+ */
+class dump_v4_cmd : public dump_cmd<vapi::Ip_address_dump>
+{
+public:
+ /**
+ * Constructor
+ */
+ dump_v4_cmd(const handle_t& itf);
+ dump_v4_cmd(const dump_v4_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_v4_cmd& i) const;
+
+private:
+ /**
+ * HW reutrn code
+ */
+ HW::item<bool> item;
+
+ /**
+ * The interface to get the addresses for
+ */
+ const handle_t& m_itf;
+};
+
+}; // namespace l3_binding_cmds
+}; // namespace VOM
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
+
+#endif
diff --git a/src/vpp-api/vom/lldp_binding.cpp b/src/vpp-api/vom/lldp_binding.cpp
index 453f57d37db..05d51bbf0b1 100644
--- a/src/vpp-api/vom/lldp_binding.cpp
+++ b/src/vpp-api/vom/lldp_binding.cpp
@@ -14,7 +14,7 @@
*/
#include "vom/lldp_binding.hpp"
-#include "vom/cmd.hpp"
+#include "vom/lldp_binding_cmds.hpp"
namespace VOM {
/**
@@ -50,7 +50,7 @@ void
lldp_binding::sweep()
{
if (m_binding) {
- HW::enqueue(new unbind_cmd(m_binding, m_itf->handle()));
+ HW::enqueue(new lldp_binding_cmds::unbind_cmd(m_binding, m_itf->handle()));
}
HW::write();
}
@@ -65,7 +65,8 @@ void
lldp_binding::replay()
{
if (m_binding) {
- HW::enqueue(new bind_cmd(m_binding, m_itf->handle(), m_port_desc));
+ HW::enqueue(
+ new lldp_binding_cmds::bind_cmd(m_binding, m_itf->handle(), m_port_desc));
}
}
@@ -86,7 +87,8 @@ lldp_binding::update(const lldp_binding& desired)
* the desired state is always that the interface should be created
*/
if (!m_binding) {
- HW::enqueue(new bind_cmd(m_binding, m_itf->handle(), m_port_desc));
+ HW::enqueue(
+ new lldp_binding_cmds::bind_cmd(m_binding, m_itf->handle(), m_port_desc));
}
}
diff --git a/src/vpp-api/vom/lldp_binding.hpp b/src/vpp-api/vom/lldp_binding.hpp
index 993a2fd3d4b..896708f699a 100644
--- a/src/vpp-api/vom/lldp_binding.hpp
+++ b/src/vpp-api/vom/lldp_binding.hpp
@@ -16,17 +16,12 @@
#ifndef __VOM_LLDP_BINDING_H__
#define __VOM_LLDP_BINDING_H__
-#include "vom/dump_cmd.hpp"
#include "vom/hw.hpp"
#include "vom/inspect.hpp"
#include "vom/interface.hpp"
#include "vom/object_base.hpp"
#include "vom/om.hpp"
-#include "vom/rpc_cmd.hpp"
#include "vom/singular_db.hpp"
-#include "vom/sub_interface.hpp"
-
-#include <vapi/lldp.api.vapi.hpp>
namespace VOM {
/**
@@ -64,79 +59,6 @@ public:
*/
static void dump(std::ostream& os);
- /**
- * A command class that binds the LLDP config to the interface
- */
- class bind_cmd
- : public rpc_cmd<HW::item<bool>, rc_t, vapi::Sw_interface_set_lldp>
- {
- public:
- /**
- * Constructor
- */
- bind_cmd(HW::item<bool>& item,
- const handle_t& itf,
- const std::string& port_desc);
-
- /**
- * 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;
-
- /**
- * The LLDP client's hostname
- */
- const std::string m_port_desc;
- };
-
- /**
- * A cmd class that Unbinds Lldp Config from an interface
- */
- class unbind_cmd
- : public rpc_cmd<HW::item<bool>, rc_t, vapi::Sw_interface_set_lldp>
- {
- 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;
- };
-
private:
/**
* Class definition for listeners to OM events
diff --git a/src/vpp-api/vom/lldp_binding_cmds.cpp b/src/vpp-api/vom/lldp_binding_cmds.cpp
index 9718c59b8f0..7dacdafe20f 100644
--- a/src/vpp-api/vom/lldp_binding_cmds.cpp
+++ b/src/vpp-api/vom/lldp_binding_cmds.cpp
@@ -13,14 +13,16 @@
* limitations under the License.
*/
-#include "vom/lldp_binding.hpp"
+#include "vom/lldp_binding_cmds.hpp"
DEFINE_VAPI_MSG_IDS_LLDP_API_JSON;
namespace VOM {
-lldp_binding::bind_cmd::bind_cmd(HW::item<bool>& item,
- const handle_t& itf,
- const std::string& port_desc)
+namespace lldp_binding_cmds {
+
+bind_cmd::bind_cmd(HW::item<bool>& item,
+ const handle_t& itf,
+ const std::string& port_desc)
: rpc_cmd(item)
, m_itf(itf)
, m_port_desc(port_desc)
@@ -28,13 +30,13 @@ lldp_binding::bind_cmd::bind_cmd(HW::item<bool>& item,
}
bool
-lldp_binding::bind_cmd::operator==(const bind_cmd& other) const
+bind_cmd::operator==(const bind_cmd& other) const
{
return ((m_itf == other.m_itf) && (m_port_desc == other.m_port_desc));
}
rc_t
-lldp_binding::bind_cmd::issue(connection& con)
+bind_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -53,7 +55,7 @@ lldp_binding::bind_cmd::issue(connection& con)
}
std::string
-lldp_binding::bind_cmd::to_string() const
+bind_cmd::to_string() const
{
std::ostringstream s;
s << "Lldp-bind: " << m_hw_item.to_string() << " itf:" << m_itf.to_string()
@@ -62,20 +64,20 @@ lldp_binding::bind_cmd::to_string() const
return (s.str());
}
-lldp_binding::unbind_cmd::unbind_cmd(HW::item<bool>& item, const handle_t& itf)
+unbind_cmd::unbind_cmd(HW::item<bool>& item, const handle_t& itf)
: rpc_cmd(item)
, m_itf(itf)
{
}
bool
-lldp_binding::unbind_cmd::operator==(const unbind_cmd& other) const
+unbind_cmd::operator==(const unbind_cmd& other) const
{
return (m_itf == other.m_itf);
}
rc_t
-lldp_binding::unbind_cmd::issue(connection& con)
+unbind_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -92,14 +94,16 @@ lldp_binding::unbind_cmd::issue(connection& con)
}
std::string
-lldp_binding::unbind_cmd::to_string() const
+unbind_cmd::to_string() const
{
std::ostringstream s;
s << "Lldp-unbind: " << m_hw_item.to_string() << " itf:" << m_itf.to_string();
return (s.str());
}
-}
+
+}; // namespace lldp_binding_cmds
+}; // namespace VOM
/*
* fd.io coding-style-patch-verification: ON
diff --git a/src/vpp-api/vom/lldp_binding_cmds.hpp b/src/vpp-api/vom/lldp_binding_cmds.hpp
new file mode 100644
index 00000000000..b3038017e06
--- /dev/null
+++ b/src/vpp-api/vom/lldp_binding_cmds.hpp
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2017 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_LLDP_BINDING_CMDS_H__
+#define __VOM_LLDP_BINDING_CMDS_H__
+
+#include "vom/dump_cmd.hpp"
+#include "vom/lldp_binding.hpp"
+#include "vom/rpc_cmd.hpp"
+
+#include <vapi/lldp.api.vapi.hpp>
+
+namespace VOM {
+namespace lldp_binding_cmds {
+
+/**
+*A command class that binds the LLDP config to the interface
+*/
+class bind_cmd
+ : public rpc_cmd<HW::item<bool>, rc_t, vapi::Sw_interface_set_lldp>
+{
+public:
+ /**
+ * Constructor
+ */
+ bind_cmd(HW::item<bool>& item,
+ const handle_t& itf,
+ const std::string& port_desc);
+
+ /**
+ * 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;
+
+ /**
+ * The LLDP client's hostname
+ */
+ const std::string m_port_desc;
+};
+
+/**
+ * A cmd class that Unbinds Lldp Config from an interface
+ */
+class unbind_cmd
+ : public rpc_cmd<HW::item<bool>, rc_t, vapi::Sw_interface_set_lldp>
+{
+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 lldp_binding_cmds
+}; // naemspace VOM
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
+
+#endif
diff --git a/src/vpp-api/vom/lldp_global.cpp b/src/vpp-api/vom/lldp_global.cpp
index 92526189d34..e7d425e12d9 100644
--- a/src/vpp-api/vom/lldp_global.cpp
+++ b/src/vpp-api/vom/lldp_global.cpp
@@ -14,7 +14,7 @@
*/
#include "vom/lldp_global.hpp"
-#include "vom/cmd.hpp"
+#include "vom/lldp_global_cmds.hpp"
namespace VOM {
/**
@@ -64,8 +64,8 @@ void
lldp_global::replay()
{
if (m_binding) {
- HW::enqueue(
- new config_cmd(m_binding, m_system_name, m_tx_hold, m_tx_interval));
+ HW::enqueue(new lldp_global_cmds::config_cmd(m_binding, m_system_name,
+ m_tx_hold, m_tx_interval));
}
}
@@ -84,8 +84,8 @@ void
lldp_global::update(const lldp_global& desired)
{
if (!m_binding) {
- HW::enqueue(
- new config_cmd(m_binding, m_system_name, m_tx_hold, m_tx_interval));
+ HW::enqueue(new lldp_global_cmds::config_cmd(m_binding, m_system_name,
+ m_tx_hold, m_tx_interval));
}
}
diff --git a/src/vpp-api/vom/lldp_global.hpp b/src/vpp-api/vom/lldp_global.hpp
index 9426ba001ae..743f9f72070 100644
--- a/src/vpp-api/vom/lldp_global.hpp
+++ b/src/vpp-api/vom/lldp_global.hpp
@@ -16,13 +16,11 @@
#ifndef __VOM_LLDP_GLOBAL_H__
#define __VOM_LLDP_GLOBAL_H__
-#include "vom/dump_cmd.hpp"
#include "vom/hw.hpp"
#include "vom/inspect.hpp"
#include "vom/interface.hpp"
#include "vom/object_base.hpp"
#include "vom/om.hpp"
-#include "vom/rpc_cmd.hpp"
#include "vom/singular_db.hpp"
#include "vom/sub_interface.hpp"
diff --git a/src/vpp-api/vom/lldp_global_cmds.cpp b/src/vpp-api/vom/lldp_global_cmds.cpp
index 9d44a7cbca1..8237114f789 100644
--- a/src/vpp-api/vom/lldp_global_cmds.cpp
+++ b/src/vpp-api/vom/lldp_global_cmds.cpp
@@ -13,13 +13,14 @@
* limitations under the License.
*/
-#include "vom/lldp_global.hpp"
+#include "vom/lldp_global_cmds.hpp"
namespace VOM {
-lldp_global::config_cmd::config_cmd(HW::item<bool>& item,
- const std::string& system_name,
- uint32_t tx_hold,
- uint32_t tx_interval)
+namespace lldp_global_cmds {
+config_cmd::config_cmd(HW::item<bool>& item,
+ const std::string& system_name,
+ uint32_t tx_hold,
+ uint32_t tx_interval)
: rpc_cmd(item)
, m_system_name(system_name)
, m_tx_hold(tx_hold)
@@ -28,13 +29,13 @@ lldp_global::config_cmd::config_cmd(HW::item<bool>& item,
}
bool
-lldp_global::config_cmd::operator==(const config_cmd& other) const
+config_cmd::operator==(const config_cmd& other) const
{
return (m_system_name == other.m_system_name);
}
rc_t
-lldp_global::config_cmd::issue(connection& con)
+config_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -53,7 +54,7 @@ lldp_global::config_cmd::issue(connection& con)
}
std::string
-lldp_global::config_cmd::to_string() const
+config_cmd::to_string() const
{
std::ostringstream s;
s << "Lldp-global-config: " << m_hw_item.to_string()
@@ -62,7 +63,9 @@ lldp_global::config_cmd::to_string() const
return (s.str());
}
-}
+
+}; // namespace lldp_global_cmds
+}; // namespace VOM
/*
* fd.io coding-style-patch-verification: ON
diff --git a/src/vpp-api/vom/lldp_global_cmds.hpp b/src/vpp-api/vom/lldp_global_cmds.hpp
new file mode 100644
index 00000000000..e4f8f37e4e6
--- /dev/null
+++ b/src/vpp-api/vom/lldp_global_cmds.hpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2017 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_LLDP_GLOBAL_CMDS_H__
+#define __VOM_LLDP_GLOBAL_CMDS_H__
+
+#include "vom/dump_cmd.hpp"
+#include "vom/lldp_global.hpp"
+#include "vom/rpc_cmd.hpp"
+
+#include <vapi/lldp.api.vapi.hpp>
+
+namespace VOM {
+namespace lldp_global_cmds {
+
+/**
+* A command class that binds the LLDP global to the interface
+*/
+class config_cmd : public rpc_cmd<HW::item<bool>, rc_t, vapi::Lldp_config>
+{
+public:
+ /**
+ * Constructor
+ */
+ config_cmd(HW::item<bool>& item,
+ const std::string& system_name,
+ uint32_t tx_hold,
+ uint32_t tx_interval);
+
+ /**
+ * 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 config_cmd& i) const;
+
+private:
+ /**
+ * The system name
+ */
+ const std::string m_system_name;
+
+ /**
+ * TX timer configs
+ */
+ uint32_t m_tx_hold;
+ uint32_t m_tx_interval;
+};
+
+}; // namespace lldp_global_cmds
+}; // namespace VOM
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
+
+#endif
diff --git a/src/vpp-api/vom/nat_binding.cpp b/src/vpp-api/vom/nat_binding.cpp
index beb76bd8494..ce73ae44b54 100644
--- a/src/vpp-api/vom/nat_binding.cpp
+++ b/src/vpp-api/vom/nat_binding.cpp
@@ -15,6 +15,7 @@
#include "vom/nat_binding.hpp"
#include "vom/cmd.hpp"
+#include "vom/nat_binding_cmds.hpp"
namespace VOM {
singular_db<const nat_binding::key_t, nat_binding> nat_binding::m_db;
@@ -64,7 +65,8 @@ nat_binding::sweep()
{
if (m_binding) {
if (direction_t::INPUT == m_dir) {
- HW::enqueue(new unbind_44_input_cmd(m_binding, m_itf->handle(), m_zone));
+ HW::enqueue(new nat_binding_cmds::unbind_44_input_cmd(
+ m_binding, m_itf->handle(), m_zone));
} else {
assert(!"Unimplemented");
}
@@ -77,7 +79,8 @@ nat_binding::replay()
{
if (m_binding) {
if (direction_t::INPUT == m_dir) {
- HW::enqueue(new bind_44_input_cmd(m_binding, m_itf->handle(), m_zone));
+ HW::enqueue(new nat_binding_cmds::bind_44_input_cmd(
+ m_binding, m_itf->handle(), m_zone));
} else {
assert(!"Unimplemented");
}
@@ -92,7 +95,8 @@ nat_binding::update(const nat_binding& desired)
*/
if (!m_binding) {
if (direction_t::INPUT == m_dir) {
- HW::enqueue(new bind_44_input_cmd(m_binding, m_itf->handle(), m_zone));
+ HW::enqueue(new nat_binding_cmds::bind_44_input_cmd(
+ m_binding, m_itf->handle(), m_zone));
} else {
assert(!"Unimplemented");
}
diff --git a/src/vpp-api/vom/nat_binding.hpp b/src/vpp-api/vom/nat_binding.hpp
index 6e871f9aa91..2f6d67f907f 100644
--- a/src/vpp-api/vom/nat_binding.hpp
+++ b/src/vpp-api/vom/nat_binding.hpp
@@ -20,14 +20,11 @@
#include "vom/interface.hpp"
#include "vom/object_base.hpp"
#include "vom/om.hpp"
-#include "vom/rpc_cmd.hpp"
#include "vom/singular_db.hpp"
-#include <vapi/nat.api.vapi.hpp>
-
namespace VOM {
/**
- * A Clas representing the binding of an L2 interface to a bridge-domain
+ * A Class representing the binding of an L2 interface to a bridge-domain
* and the properties of that binding.
*/
class nat_binding : public object_base
@@ -104,123 +101,6 @@ public:
*/
static void dump(std::ostream& os);
- /**
- * A functor class that binds L2 configuration to an interface
- */
- class bind_44_input_cmd
- : public rpc_cmd<HW::item<bool>,
- rc_t,
- vapi::Nat44_interface_add_del_feature>
- {
- public:
- /**
- * Constructor
- */
- bind_44_input_cmd(HW::item<bool>& item,
- const handle_t& itf,
- const zone_t& zone);
-
- /**
- * 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_44_input_cmd& i) const;
-
- private:
- /**
- * The interface to bind
- */
- const handle_t m_itf;
-
- /**
- * The zone the interface is in
- */
- const zone_t m_zone;
- };
-
- /**
- * A cmd class that Unbinds L2 configuration from an interface
- */
- class unbind_44_input_cmd
- : public rpc_cmd<HW::item<bool>,
- rc_t,
- vapi::Nat44_interface_add_del_feature>
- {
- public:
- /**
- * Constructor
- */
- unbind_44_input_cmd(HW::item<bool>& item,
- const handle_t& itf,
- const zone_t& zone);
-
- /**
- * 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_44_input_cmd& i) const;
-
- private:
- /**
- * The interface to bind
- */
- const handle_t m_itf;
-
- /**
- * The zone the interface is in
- */
- const zone_t m_zone;
- };
-
- /**
- * A cmd class that Dumps all the nat_statics
- */
- class dump_44_cmd : public dump_cmd<vapi::Nat44_interface_dump>
- {
- public:
- /**
- * Constructor
- */
- dump_44_cmd();
- dump_44_cmd(const dump_44_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_44_cmd& i) const;
-
- private:
- /**
- * HW reutrn code
- */
- HW::item<bool> item;
- };
-
private:
/**
* Class definition for listeners to OM events
@@ -290,7 +170,7 @@ private:
/**
* HW configuration for the binding. The bool representing the
* do/don't bind.
- */
+ */
HW::item<bool> m_binding;
/**
diff --git a/src/vpp-api/vom/nat_binding_cmds.cpp b/src/vpp-api/vom/nat_binding_cmds.cpp
index 38630c13c42..106ec5edac9 100644
--- a/src/vpp-api/vom/nat_binding_cmds.cpp
+++ b/src/vpp-api/vom/nat_binding_cmds.cpp
@@ -13,12 +13,13 @@
* limitations under the License.
*/
-#include "vom/nat_binding.hpp"
+#include "vom/nat_binding_cmds.hpp"
namespace VOM {
-nat_binding::bind_44_input_cmd::bind_44_input_cmd(HW::item<bool>& item,
- const handle_t& itf,
- const zone_t& zone)
+namespace nat_binding_cmds {
+bind_44_input_cmd::bind_44_input_cmd(HW::item<bool>& item,
+ const handle_t& itf,
+ const nat_binding::zone_t& zone)
: rpc_cmd(item)
, m_itf(itf)
, m_zone(zone)
@@ -26,19 +27,19 @@ nat_binding::bind_44_input_cmd::bind_44_input_cmd(HW::item<bool>& item,
}
bool
-nat_binding::bind_44_input_cmd::operator==(const bind_44_input_cmd& other) const
+bind_44_input_cmd::operator==(const bind_44_input_cmd& other) const
{
return ((m_itf == other.m_itf) && (m_zone == other.m_zone));
}
rc_t
-nat_binding::bind_44_input_cmd::issue(connection& con)
+bind_44_input_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
auto& payload = req.get_request().get_payload();
payload.is_add = 1;
- payload.is_inside = (zone_t::INSIDE == m_zone ? 1 : 0);
+ payload.is_inside = (nat_binding::zone_t::INSIDE == m_zone ? 1 : 0);
payload.sw_if_index = m_itf.value();
VAPI_CALL(req.execute());
@@ -49,7 +50,7 @@ nat_binding::bind_44_input_cmd::issue(connection& con)
}
std::string
-nat_binding::bind_44_input_cmd::to_string() const
+bind_44_input_cmd::to_string() const
{
std::ostringstream s;
s << "nat-44-input-binding-create: " << m_hw_item.to_string()
@@ -58,9 +59,9 @@ nat_binding::bind_44_input_cmd::to_string() const
return (s.str());
}
-nat_binding::unbind_44_input_cmd::unbind_44_input_cmd(HW::item<bool>& item,
- const handle_t& itf,
- const zone_t& zone)
+unbind_44_input_cmd::unbind_44_input_cmd(HW::item<bool>& item,
+ const handle_t& itf,
+ const nat_binding::zone_t& zone)
: rpc_cmd(item)
, m_itf(itf)
, m_zone(zone)
@@ -68,20 +69,19 @@ nat_binding::unbind_44_input_cmd::unbind_44_input_cmd(HW::item<bool>& item,
}
bool
-nat_binding::unbind_44_input_cmd::operator==(
- const unbind_44_input_cmd& other) const
+unbind_44_input_cmd::operator==(const unbind_44_input_cmd& other) const
{
return ((m_itf == other.m_itf) && (m_zone == other.m_zone));
}
rc_t
-nat_binding::unbind_44_input_cmd::issue(connection& con)
+unbind_44_input_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
auto& payload = req.get_request().get_payload();
payload.is_add = 0;
- payload.is_inside = (zone_t::INSIDE == m_zone ? 1 : 0);
+ payload.is_inside = (nat_binding::zone_t::INSIDE == m_zone ? 1 : 0);
payload.sw_if_index = m_itf.value();
VAPI_CALL(req.execute());
@@ -92,7 +92,7 @@ nat_binding::unbind_44_input_cmd::issue(connection& con)
}
std::string
-nat_binding::unbind_44_input_cmd::to_string() const
+unbind_44_input_cmd::to_string() const
{
std::ostringstream s;
s << "nat-44-input-binding-create: " << m_hw_item.to_string()
@@ -101,22 +101,22 @@ nat_binding::unbind_44_input_cmd::to_string() const
return (s.str());
}
-nat_binding::dump_44_cmd::dump_44_cmd()
+dump_44_cmd::dump_44_cmd()
{
}
-nat_binding::dump_44_cmd::dump_44_cmd(const dump_44_cmd& d)
+dump_44_cmd::dump_44_cmd(const dump_44_cmd& d)
{
}
bool
-nat_binding::dump_44_cmd::operator==(const dump_44_cmd& other) const
+dump_44_cmd::operator==(const dump_44_cmd& other) const
{
return (true);
}
rc_t
-nat_binding::dump_44_cmd::issue(connection& con)
+dump_44_cmd::issue(connection& con)
{
m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
@@ -128,11 +128,12 @@ nat_binding::dump_44_cmd::issue(connection& con)
}
std::string
-nat_binding::dump_44_cmd::to_string() const
+dump_44_cmd::to_string() const
{
return ("nat-binding-dump");
}
}
+}
/*
* fd.io coding-style-patch-verification: ON
diff --git a/src/vpp-api/vom/nat_binding_cmds.hpp b/src/vpp-api/vom/nat_binding_cmds.hpp
new file mode 100644
index 00000000000..ed9048a9da3
--- /dev/null
+++ b/src/vpp-api/vom/nat_binding_cmds.hpp
@@ -0,0 +1,131 @@
+#ifndef __VOM_NAT_BINDING_CMDS_H__
+#define __VOM_NAT_BINDING_CMDS_H__
+
+#include "vom/nat_binding.hpp"
+#include "vom/rpc_cmd.hpp"
+#include "vom/dump_cmd.hpp"
+
+#include <vapi/nat.api.vapi.hpp>
+
+namespace VOM {
+namespace nat_binding_cmds {
+/**
+ * A functor class that binds L2 configuration to an interface
+ */
+class bind_44_input_cmd
+ : public rpc_cmd<HW::item<bool>,
+ rc_t,
+ vapi::Nat44_interface_add_del_feature>
+{
+public:
+ /**
+ * Constructor
+ */
+ bind_44_input_cmd(HW::item<bool>& item,
+ const handle_t& itf,
+ const nat_binding::zone_t& zone);
+
+ /**
+ * 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_44_input_cmd& i) const;
+
+private:
+ /**
+ * The interface to bind
+ */
+ const handle_t m_itf;
+
+ /**
+ * The zone the interface is in
+ */
+ const nat_binding::zone_t m_zone;
+};
+
+/**
+ * A cmd class that Unbinds L2 configuration from an interface
+ */
+class unbind_44_input_cmd
+ : public rpc_cmd<HW::item<bool>,
+ rc_t,
+ vapi::Nat44_interface_add_del_feature>
+{
+public:
+ /**
+ * Constructor
+ */
+ unbind_44_input_cmd(HW::item<bool>& item,
+ const handle_t& itf,
+ const nat_binding::zone_t& zone);
+
+ /**
+ * 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_44_input_cmd& i) const;
+
+private:
+ /**
+ * The interface to bind
+ */
+ const handle_t m_itf;
+
+ /**
+ * The zone the interface is in
+ */
+ const nat_binding::zone_t m_zone;
+};
+
+/**
+ * A cmd class that Dumps all the nat_statics
+ */
+class dump_44_cmd : public dump_cmd<vapi::Nat44_interface_dump>
+{
+public:
+ /**
+ * Constructor
+ */
+ dump_44_cmd();
+ dump_44_cmd(const dump_44_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_44_cmd& i) const;
+
+private:
+ /**
+ * HW reutrn code
+ */
+ HW::item<bool> item;
+};
+};
+};
+
+#endif
diff --git a/src/vpp-api/vom/nat_static.cpp b/src/vpp-api/vom/nat_static.cpp
index afc46f2457a..619cc3b6602 100644
--- a/src/vpp-api/vom/nat_static.cpp
+++ b/src/vpp-api/vom/nat_static.cpp
@@ -14,6 +14,7 @@
*/
#include "vom/nat_static.hpp"
+#include "vom/nat_static_cmds.hpp"
namespace VOM {
singular_db<nat_static::key_t, nat_static> nat_static::m_db;
@@ -59,8 +60,8 @@ nat_static::sweep()
{
if (m_hw) {
if (m_inside.is_v4()) {
- HW::enqueue(
- new delete_44_cmd(m_hw, m_rd->table_id(), m_inside.to_v4(), m_outside));
+ HW::enqueue(new nat_static_cmds::delete_44_cmd(
+ m_hw, m_rd->table_id(), m_inside.to_v4(), m_outside));
}
}
HW::write();
@@ -71,8 +72,8 @@ nat_static::replay()
{
if (m_hw) {
if (m_inside.is_v4()) {
- HW::enqueue(
- new create_44_cmd(m_hw, m_rd->table_id(), m_inside.to_v4(), m_outside));
+ HW::enqueue(new nat_static_cmds::create_44_cmd(
+ m_hw, m_rd->table_id(), m_inside.to_v4(), m_outside));
}
}
}
@@ -85,8 +86,8 @@ nat_static::update(const nat_static& r)
*/
if (rc_t::OK != m_hw.rc()) {
if (m_inside.is_v4()) {
- HW::enqueue(
- new create_44_cmd(m_hw, m_rd->table_id(), m_inside.to_v4(), m_outside));
+ HW::enqueue(new nat_static_cmds::create_44_cmd(
+ m_hw, m_rd->table_id(), m_inside.to_v4(), m_outside));
}
}
}
diff --git a/src/vpp-api/vom/nat_static.hpp b/src/vpp-api/vom/nat_static.hpp
index 1aa4a5e79c3..1560968a6ed 100644
--- a/src/vpp-api/vom/nat_static.hpp
+++ b/src/vpp-api/vom/nat_static.hpp
@@ -16,13 +16,10 @@
#ifndef __VOM_NAT_STATIC_H__
#define __VOM_NAT_STATIC_H__
-#include "vom/dump_cmd.hpp"
#include "vom/route.hpp"
#include "vom/singular_db.hpp"
#include "vom/types.hpp"
-#include <vapi/nat.api.vapi.hpp>
-
namespace VOM {
/**
* A entry in the ARP termination table of a Bridge Domain
@@ -87,111 +84,6 @@ public:
*/
std::string to_string() const;
- /**
- * A command class that creates NAT 44 static mapping
- */
- class create_44_cmd
- : public rpc_cmd<HW::item<bool>, rc_t, vapi::Nat44_add_del_static_mapping>
- {
- public:
- /**
- * Constructor
- */
- create_44_cmd(HW::item<bool>& item,
- route::table_id_t id,
- const boost::asio::ip::address_v4& inside,
- const boost::asio::ip::address_v4& outside);
-
- /**
- * 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 create_44_cmd& i) const;
-
- private:
- route::table_id_t m_id;
- const boost::asio::ip::address_v4 m_inside;
- const boost::asio::ip::address_v4 m_outside;
- };
-
- /**
- * A cmd class that deletes a NAT 44 static mapping
- */
- class delete_44_cmd
- : public rpc_cmd<HW::item<bool>, rc_t, vapi::Nat44_add_del_static_mapping>
- {
- public:
- /**
- * Constructor
- */
- delete_44_cmd(HW::item<bool>& item,
- route::table_id_t id,
- const boost::asio::ip::address_v4& inside,
- const boost::asio::ip::address_v4& outside);
-
- /**
- * 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 delete_44_cmd& i) const;
-
- private:
- route::table_id_t m_id;
- const boost::asio::ip::address_v4 m_inside;
- const boost::asio::ip::address_v4 m_outside;
- };
-
- /**
- * A cmd class that Dumps all the nat_statics
- */
- class dump_44_cmd : public dump_cmd<vapi::Nat44_static_mapping_dump>
- {
- public:
- /**
- * Constructor
- */
- dump_44_cmd();
- dump_44_cmd(const dump_44_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_44_cmd& i) const;
-
- private:
- /**
- * HW reutrn code
- */
- HW::item<bool> item;
- };
-
private:
/**
* Class definition for listeners to OM events
diff --git a/src/vpp-api/vom/nat_static_cmds.cpp b/src/vpp-api/vom/nat_static_cmds.cpp
index 4325f3703f3..2abe0d2b658 100644
--- a/src/vpp-api/vom/nat_static_cmds.cpp
+++ b/src/vpp-api/vom/nat_static_cmds.cpp
@@ -13,16 +13,17 @@
* limitations under the License.
*/
-#include "vom/nat_static.hpp"
+#include "vom/nat_static_cmds.hpp"
DEFINE_VAPI_MSG_IDS_NAT_API_JSON;
namespace VOM {
-nat_static::create_44_cmd::create_44_cmd(
- HW::item<bool>& item,
- route::table_id_t id,
- const boost::asio::ip::address_v4& inside,
- const boost::asio::ip::address_v4& outside)
+namespace nat_static_cmds {
+
+create_44_cmd::create_44_cmd(HW::item<bool>& item,
+ route::table_id_t id,
+ const boost::asio::ip::address_v4& inside,
+ const boost::asio::ip::address_v4& outside)
: rpc_cmd(item)
, m_id(id)
, m_inside(inside)
@@ -31,14 +32,14 @@ nat_static::create_44_cmd::create_44_cmd(
}
bool
-nat_static::create_44_cmd::operator==(const create_44_cmd& other) const
+create_44_cmd::operator==(const create_44_cmd& other) const
{
return ((m_id == other.m_id) && (m_inside == other.m_inside) &&
(m_outside == other.m_outside));
}
rc_t
-nat_static::create_44_cmd::issue(connection& con)
+create_44_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -60,7 +61,7 @@ nat_static::create_44_cmd::issue(connection& con)
}
std::string
-nat_static::create_44_cmd::to_string() const
+create_44_cmd::to_string() const
{
std::ostringstream s;
s << "nat-44-static-create: " << m_hw_item.to_string() << " table:" << m_id
@@ -70,11 +71,10 @@ nat_static::create_44_cmd::to_string() const
return (s.str());
}
-nat_static::delete_44_cmd::delete_44_cmd(
- HW::item<bool>& item,
- route::table_id_t id,
- const boost::asio::ip::address_v4& inside,
- const boost::asio::ip::address_v4& outside)
+delete_44_cmd::delete_44_cmd(HW::item<bool>& item,
+ route::table_id_t id,
+ const boost::asio::ip::address_v4& inside,
+ const boost::asio::ip::address_v4& outside)
: rpc_cmd(item)
, m_id(id)
, m_inside(inside)
@@ -83,14 +83,14 @@ nat_static::delete_44_cmd::delete_44_cmd(
}
bool
-nat_static::delete_44_cmd::operator==(const delete_44_cmd& other) const
+delete_44_cmd::operator==(const delete_44_cmd& other) const
{
return ((m_id == other.m_id) && (m_inside == other.m_inside) &&
(m_outside == other.m_outside));
}
rc_t
-nat_static::delete_44_cmd::issue(connection& con)
+delete_44_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -113,7 +113,7 @@ nat_static::delete_44_cmd::issue(connection& con)
}
std::string
-nat_static::delete_44_cmd::to_string() const
+delete_44_cmd::to_string() const
{
std::ostringstream s;
s << "nat-44-static-delete: " << m_hw_item.to_string() << " table:" << m_id
@@ -123,22 +123,22 @@ nat_static::delete_44_cmd::to_string() const
return (s.str());
}
-nat_static::dump_44_cmd::dump_44_cmd()
+dump_44_cmd::dump_44_cmd()
{
}
-nat_static::dump_44_cmd::dump_44_cmd(const dump_44_cmd& d)
+dump_44_cmd::dump_44_cmd(const dump_44_cmd& d)
{
}
bool
-nat_static::dump_44_cmd::operator==(const dump_44_cmd& other) const
+dump_44_cmd::operator==(const dump_44_cmd& other) const
{
return (true);
}
rc_t
-nat_static::dump_44_cmd::issue(connection& con)
+dump_44_cmd::issue(connection& con)
{
m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
@@ -150,11 +150,12 @@ nat_static::dump_44_cmd::issue(connection& con)
}
std::string
-nat_static::dump_44_cmd::to_string() const
+dump_44_cmd::to_string() const
{
return ("nat-static-dump");
}
-}
+} // namespace nat_static_cmds
+} // namespace VOM
/*
* fd.io coding-style-patch-verification: ON
diff --git a/src/vpp-api/vom/nat_static_cmds.hpp b/src/vpp-api/vom/nat_static_cmds.hpp
new file mode 100644
index 00000000000..1db2571a558
--- /dev/null
+++ b/src/vpp-api/vom/nat_static_cmds.hpp
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2017 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_NAT_STATIC_CMDS_H__
+#define __VOM_NAT_STATIC_CMDS_H__
+
+#include "nat_static.hpp"
+#include "vom/dump_cmd.hpp"
+
+#include <vapi/nat.api.vapi.hpp>
+
+namespace VOM {
+namespace nat_static_cmds {
+
+/**
+ * A command class that creates NAT 44 static mapping
+ */
+class create_44_cmd
+ : public rpc_cmd<HW::item<bool>, rc_t, vapi::Nat44_add_del_static_mapping>
+{
+public:
+ /**
+ * Constructor
+ */
+ create_44_cmd(HW::item<bool>& item,
+ route::table_id_t id,
+ const boost::asio::ip::address_v4& inside,
+ const boost::asio::ip::address_v4& outside);
+
+ /**
+ * 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 create_44_cmd& i) const;
+
+private:
+ route::table_id_t m_id;
+ const boost::asio::ip::address_v4 m_inside;
+ const boost::asio::ip::address_v4 m_outside;
+};
+
+/**
+ * A cmd class that deletes a NAT 44 static mapping
+ */
+class delete_44_cmd
+ : public rpc_cmd<HW::item<bool>, rc_t, vapi::Nat44_add_del_static_mapping>
+{
+public:
+ /**
+ * Constructor
+ */
+ delete_44_cmd(HW::item<bool>& item,
+ route::table_id_t id,
+ const boost::asio::ip::address_v4& inside,
+ const boost::asio::ip::address_v4& outside);
+
+ /**
+ * 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 delete_44_cmd& i) const;
+
+private:
+ route::table_id_t m_id;
+ const boost::asio::ip::address_v4 m_inside;
+ const boost::asio::ip::address_v4 m_outside;
+};
+
+/**
+ * A cmd class that Dumps all the nat_statics
+ */
+class dump_44_cmd : public dump_cmd<vapi::Nat44_static_mapping_dump>
+{
+public:
+ /**
+ * Constructor
+ */
+ dump_44_cmd();
+ dump_44_cmd(const dump_44_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_44_cmd& i) const;
+
+private:
+ /**
+ * HW reutrn code
+ */
+ HW::item<bool> item;
+};
+}; // namespace nat_static_cmds
+}; // namespace vom
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
+
+#endif
diff --git a/src/vpp-api/vom/neighbour.cpp b/src/vpp-api/vom/neighbour.cpp
index c4dcf1f81df..12b13ca6559 100644
--- a/src/vpp-api/vom/neighbour.cpp
+++ b/src/vpp-api/vom/neighbour.cpp
@@ -14,6 +14,7 @@
*/
#include "vom/neighbour.hpp"
+#include "vom/neighbour_cmds.hpp"
namespace VOM {
singular_db<neighbour::key_t, neighbour> neighbour::m_db;
@@ -49,7 +50,8 @@ void
neighbour::sweep()
{
if (m_hw) {
- HW::enqueue(new delete_cmd(m_hw, m_itf->handle(), m_mac, m_ip_addr));
+ HW::enqueue(
+ new neighbour_cmds::delete_cmd(m_hw, m_itf->handle(), m_mac, m_ip_addr));
}
HW::write();
}
@@ -58,7 +60,8 @@ void
neighbour::replay()
{
if (m_hw) {
- HW::enqueue(new create_cmd(m_hw, m_itf->handle(), m_mac, m_ip_addr));
+ HW::enqueue(
+ new neighbour_cmds::create_cmd(m_hw, m_itf->handle(), m_mac, m_ip_addr));
}
}
@@ -79,7 +82,8 @@ neighbour::update(const neighbour& r)
* create the table if it is not yet created
*/
if (rc_t::OK != m_hw.rc()) {
- HW::enqueue(new create_cmd(m_hw, m_itf->handle(), m_mac, m_ip_addr));
+ HW::enqueue(
+ new neighbour_cmds::create_cmd(m_hw, m_itf->handle(), m_mac, m_ip_addr));
}
}
@@ -131,9 +135,9 @@ neighbour::populate_i(const client_db::key_t& key,
/*
* dump VPP current states
*/
- std::shared_ptr<neighbour::dump_cmd> cmd =
- std::make_shared<neighbour::dump_cmd>(
- neighbour::dump_cmd(itf->handle(), proto));
+ std::shared_ptr<neighbour_cmds::dump_cmd> cmd =
+ std::make_shared<neighbour_cmds::dump_cmd>(
+ neighbour_cmds::dump_cmd(itf->handle(), proto));
HW::enqueue(cmd);
HW::write();
diff --git a/src/vpp-api/vom/neighbour.hpp b/src/vpp-api/vom/neighbour.hpp
index 141b98b672f..85577f077a9 100644
--- a/src/vpp-api/vom/neighbour.hpp
+++ b/src/vpp-api/vom/neighbour.hpp
@@ -16,13 +16,10 @@
#ifndef __VOM_NEIGHBOUR_H__
#define __VOM_NEIGHBOUR_H__
-#include "vom/dump_cmd.hpp"
#include "vom/interface.hpp"
#include "vom/singular_db.hpp"
#include "vom/types.hpp"
-#include <vapi/l2.api.vapi.hpp>
-
namespace VOM {
/**
* A entry in the ARP termination table of a Bridge Domain
@@ -81,121 +78,6 @@ public:
*/
std::string to_string() const;
- /**
- * A command class that creates or updates the bridge domain ARP Entry
- */
- class create_cmd
- : public rpc_cmd<HW::item<bool>, rc_t, vapi::Ip_neighbor_add_del>
- {
- public:
- /**
- * Constructor
- */
- create_cmd(HW::item<bool>& item,
- handle_t itf,
- const mac_address_t& mac,
- const boost::asio::ip::address& ip_addr);
-
- /**
- * 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 create_cmd& i) const;
-
- private:
- handle_t m_itf;
- mac_address_t m_mac;
- boost::asio::ip::address m_ip_addr;
- };
-
- /**
- * A cmd class that deletes a bridge domain ARP entry
- */
- class delete_cmd
- : public rpc_cmd<HW::item<bool>, rc_t, vapi::Ip_neighbor_add_del>
- {
- public:
- /**
- * Constructor
- */
- delete_cmd(HW::item<bool>& item,
- handle_t itf,
- const mac_address_t& mac,
- const boost::asio::ip::address& ip_addr);
-
- /**
- * 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 delete_cmd& i) const;
-
- private:
- handle_t m_itf;
- mac_address_t m_mac;
- boost::asio::ip::address m_ip_addr;
- };
-
- /**
- * A cmd class that Dumps all the neighbours
- */
- class dump_cmd : public VOM::dump_cmd<vapi::Ip_neighbor_dump>
- {
- public:
- /**
- * Constructor
- */
- dump_cmd(const handle_t& itf, const l3_proto_t& proto);
- 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 dump
- */
- handle_t m_itf;
-
- /**
- * V4 or V6
- */
- l3_proto_t m_proto;
- };
-
private:
/**
* Class definition for listeners to OM events
diff --git a/src/vpp-api/vom/neighbour_cmds.cpp b/src/vpp-api/vom/neighbour_cmds.cpp
index 2062bc3ee0d..2f3c200d5fb 100644
--- a/src/vpp-api/vom/neighbour_cmds.cpp
+++ b/src/vpp-api/vom/neighbour_cmds.cpp
@@ -13,13 +13,14 @@
* limitations under the License.
*/
-#include "vom/neighbour.hpp"
+#include "vom/neighbour_cmds.hpp"
namespace VOM {
-neighbour::create_cmd::create_cmd(HW::item<bool>& item,
- handle_t itf,
- const mac_address_t& mac,
- const boost::asio::ip::address& ip_addr)
+namespace neighbour_cmds {
+create_cmd::create_cmd(HW::item<bool>& item,
+ handle_t itf,
+ const mac_address_t& mac,
+ const boost::asio::ip::address& ip_addr)
: rpc_cmd(item)
, m_itf(itf)
, m_mac(mac)
@@ -28,14 +29,14 @@ neighbour::create_cmd::create_cmd(HW::item<bool>& item,
}
bool
-neighbour::create_cmd::operator==(const create_cmd& other) const
+create_cmd::operator==(const create_cmd& other) const
{
return ((m_mac == other.m_mac) && (m_ip_addr == other.m_ip_addr) &&
(m_itf == other.m_itf));
}
rc_t
-neighbour::create_cmd::issue(connection& con)
+create_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -54,7 +55,7 @@ neighbour::create_cmd::issue(connection& con)
}
std::string
-neighbour::create_cmd::to_string() const
+create_cmd::to_string() const
{
std::ostringstream s;
s << "nieghbour-create: " << m_hw_item.to_string()
@@ -64,10 +65,10 @@ neighbour::create_cmd::to_string() const
return (s.str());
}
-neighbour::delete_cmd::delete_cmd(HW::item<bool>& item,
- handle_t itf,
- const mac_address_t& mac,
- const boost::asio::ip::address& ip_addr)
+delete_cmd::delete_cmd(HW::item<bool>& item,
+ handle_t itf,
+ const mac_address_t& mac,
+ const boost::asio::ip::address& ip_addr)
: rpc_cmd(item)
, m_itf(itf)
, m_mac(mac)
@@ -76,14 +77,14 @@ neighbour::delete_cmd::delete_cmd(HW::item<bool>& item,
}
bool
-neighbour::delete_cmd::operator==(const delete_cmd& other) const
+delete_cmd::operator==(const delete_cmd& other) const
{
return ((m_mac == other.m_mac) && (m_ip_addr == other.m_ip_addr) &&
(m_itf == other.m_itf));
}
rc_t
-neighbour::delete_cmd::issue(connection& con)
+delete_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -103,7 +104,7 @@ neighbour::delete_cmd::issue(connection& con)
}
std::string
-neighbour::delete_cmd::to_string() const
+delete_cmd::to_string() const
{
std::ostringstream s;
s << "neighbour-delete: " << m_hw_item.to_string()
@@ -113,26 +114,26 @@ neighbour::delete_cmd::to_string() const
return (s.str());
}
-neighbour::dump_cmd::dump_cmd(const handle_t& hdl, const l3_proto_t& proto)
+dump_cmd::dump_cmd(const handle_t& hdl, const l3_proto_t& proto)
: m_itf(hdl)
, m_proto(proto)
{
}
-neighbour::dump_cmd::dump_cmd(const dump_cmd& d)
+dump_cmd::dump_cmd(const dump_cmd& d)
: m_itf(d.m_itf)
, m_proto(d.m_proto)
{
}
bool
-neighbour::dump_cmd::operator==(const dump_cmd& other) const
+dump_cmd::operator==(const dump_cmd& other) const
{
return (true);
}
rc_t
-neighbour::dump_cmd::issue(connection& con)
+dump_cmd::issue(connection& con)
{
m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
@@ -148,11 +149,12 @@ neighbour::dump_cmd::issue(connection& con)
}
std::string
-neighbour::dump_cmd::to_string() const
+dump_cmd::to_string() const
{
return ("neighbour-dump");
}
-}
+} // namespace neighbour_cmds
+} // namespace vom
/*
* fd.io coding-style-patch-verification: ON
diff --git a/src/vpp-api/vom/neighbour_cmds.hpp b/src/vpp-api/vom/neighbour_cmds.hpp
new file mode 100644
index 00000000000..fe6dd155cd9
--- /dev/null
+++ b/src/vpp-api/vom/neighbour_cmds.hpp
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2017 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_NEIGHBOUR_CMDS_H__
+#define __VOM_NEIGHBOUR_CMDS_H__
+
+#include "vom/dump_cmd.hpp"
+#include "neighbour.hpp"
+
+#include <vapi/ip.api.vapi.hpp>
+
+namespace VOM {
+namespace neighbour_cmds {
+
+/**
+ * A command class that creates or updates the bridge domain ARP Entry
+ */
+class create_cmd
+ : public rpc_cmd<HW::item<bool>, rc_t, vapi::Ip_neighbor_add_del>
+{
+public:
+ /**
+ * Constructor
+ */
+ create_cmd(HW::item<bool>& item,
+ handle_t itf,
+ const mac_address_t& mac,
+ const boost::asio::ip::address& ip_addr);
+
+ /**
+ * 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 create_cmd& i) const;
+
+private:
+ handle_t m_itf;
+ mac_address_t m_mac;
+ boost::asio::ip::address m_ip_addr;
+};
+
+/**
+ * A cmd class that deletes a bridge domain ARP entry
+ */
+class delete_cmd
+ : public rpc_cmd<HW::item<bool>, rc_t, vapi::Ip_neighbor_add_del>
+{
+public:
+ /**
+ * Constructor
+ */
+ delete_cmd(HW::item<bool>& item,
+ handle_t itf,
+ const mac_address_t& mac,
+ const boost::asio::ip::address& ip_addr);
+
+ /**
+ * 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 delete_cmd& i) const;
+
+private:
+ handle_t m_itf;
+ mac_address_t m_mac;
+ boost::asio::ip::address m_ip_addr;
+};
+
+/**
+ * A cmd class that Dumps all the neighbours
+ */
+class dump_cmd : public VOM::dump_cmd<vapi::Ip_neighbor_dump>
+{
+public:
+ /**
+ * Constructor
+ */
+ dump_cmd(const handle_t& itf, const l3_proto_t& proto);
+ 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 dump
+ */
+ handle_t m_itf;
+
+ /**
+ * V4 or V6
+ */
+ l3_proto_t m_proto;
+};
+
+}; // namespace neighbour_cmds
+}; // namespace vom
+#endif
+
diff --git a/src/vpp-api/vom/route.cpp b/src/vpp-api/vom/route.cpp
index e239f8c4f62..ece0768e634 100644
--- a/src/vpp-api/vom/route.cpp
+++ b/src/vpp-api/vom/route.cpp
@@ -14,10 +14,9 @@
*/
#include "vom/route.hpp"
+#include "vom/route_cmds.hpp"
#include "vom/singular_db.hpp"
-#include <vapi/ip.api.vapi.hpp>
-
namespace VOM {
namespace route {
singular_db<ip_route::key_t, ip_route> ip_route::m_db;
@@ -112,47 +111,6 @@ path::operator<(const path& p) const
return (false);
}
-void
-path::to_vpp(vapi_payload_ip_add_del_route& payload) const
-{
- payload.is_drop = 0;
- payload.is_unreach = 0;
- payload.is_prohibit = 0;
- payload.is_local = 0;
- payload.is_classify = 0;
- payload.is_multipath = 0;
- payload.is_resolve_host = 0;
- payload.is_resolve_attached = 0;
-
- if (nh_proto_t::ETHERNET == m_nh_proto) {
- payload.is_l2_bridged = 1;
- }
-
- if (special_t::STANDARD == m_type) {
- uint8_t path_v6;
- to_bytes(m_nh, &path_v6, payload.next_hop_address);
-
- if (m_rd) {
- payload.next_hop_table_id = m_rd->table_id();
- }
- if (m_interface) {
- payload.next_hop_sw_if_index = m_interface->handle().value();
- }
- } else if (special_t::DROP == m_type) {
- payload.is_drop = 1;
- } else if (special_t::UNREACH == m_type) {
- payload.is_unreach = 1;
- } else if (special_t::PROHIBIT == m_type) {
- payload.is_prohibit = 1;
- } else if (special_t::LOCAL == m_type) {
- payload.is_local = 1;
- }
- payload.next_hop_weight = m_weight;
- payload.next_hop_preference = m_preference;
- payload.next_hop_via_label = 0;
- payload.classify_table_index = 0;
-}
-
std::string
path::to_string() const
{
@@ -173,6 +131,48 @@ path::to_string() const
return (s.str());
}
+path::special_t
+path::type() const
+{
+ return m_type;
+}
+
+nh_proto_t
+path::nh_proto() const
+{
+ return m_nh_proto;
+}
+
+const boost::asio::ip::address&
+path::nh() const
+{
+ return m_nh;
+}
+
+std::shared_ptr<route_domain>
+path::rd() const
+{
+ return m_rd;
+}
+
+std::shared_ptr<interface>
+path::itf() const
+{
+ return m_interface;
+}
+
+uint8_t
+path::weight() const
+{
+ return m_weight;
+}
+
+uint8_t
+path::preference() const
+{
+ return m_preference;
+}
+
ip_route::ip_route(const prefix_t& prefix)
: m_hw(false)
, m_rd(route_domain::get_default())
@@ -221,7 +221,8 @@ void
ip_route::sweep()
{
if (m_hw) {
- HW::enqueue(new delete_cmd(m_hw, m_rd->table_id(), m_prefix));
+ HW::enqueue(
+ new ip_route_cmds::delete_cmd(m_hw, m_rd->table_id(), m_prefix));
}
HW::write();
}
@@ -230,7 +231,8 @@ void
ip_route::replay()
{
if (m_hw) {
- HW::enqueue(new update_cmd(m_hw, m_rd->table_id(), m_prefix, m_paths));
+ HW::enqueue(
+ new ip_route_cmds::update_cmd(m_hw, m_rd->table_id(), m_prefix, m_paths));
}
}
std::string
@@ -251,7 +253,8 @@ ip_route::update(const ip_route& r)
* create the table if it is not yet created
*/
if (rc_t::OK != m_hw.rc()) {
- HW::enqueue(new update_cmd(m_hw, m_rd->table_id(), m_prefix, m_paths));
+ HW::enqueue(
+ new ip_route_cmds::update_cmd(m_hw, m_rd->table_id(), m_prefix, m_paths));
}
}
@@ -289,8 +292,10 @@ ip_route::event_handler::handle_replay()
void
ip_route::event_handler::handle_populate(const client_db::key_t& key)
{
- std::shared_ptr<ip_route::dump_v4_cmd> cmd_v4(new ip_route::dump_v4_cmd());
- std::shared_ptr<ip_route::dump_v6_cmd> cmd_v6(new ip_route::dump_v6_cmd());
+ std::shared_ptr<ip_route_cmds::dump_v4_cmd> cmd_v4(
+ new ip_route_cmds::dump_v4_cmd());
+ std::shared_ptr<ip_route_cmds::dump_v6_cmd> cmd_v6(
+ new ip_route_cmds::dump_v6_cmd());
HW::enqueue(cmd_v4);
HW::enqueue(cmd_v6);
diff --git a/src/vpp-api/vom/route.hpp b/src/vpp-api/vom/route.hpp
index d175bee80eb..4f27ff1d20b 100644
--- a/src/vpp-api/vom/route.hpp
+++ b/src/vpp-api/vom/route.hpp
@@ -21,8 +21,6 @@
#include "vom/route_domain.hpp"
#include "vom/singular_db.hpp"
-#include <vapi/ip.api.vapi.hpp>
-
namespace VOM {
/**
* Types belonging to Routing
@@ -110,7 +108,6 @@ public:
/**
* Convert the path into the VPP API representation
*/
- void to_vpp(vapi_type_fib_path& path) const;
void to_vpp(vapi_payload_ip_add_del_route& payload) const;
/**
@@ -123,6 +120,17 @@ public:
*/
std::string to_string() const;
+ /**
+ * Getters
+ */
+ special_t type() const;
+ nh_proto_t nh_proto() const;
+ const boost::asio::ip::address& nh() const;
+ std::shared_ptr<route_domain> rd() const;
+ std::shared_ptr<interface> itf() const;
+ uint8_t weight() const;
+ uint8_t preference() const;
+
private:
/**
* The special path tpye
@@ -237,140 +245,6 @@ public:
*/
std::string to_string() const;
- /**
- * A command class that creates or updates the route
- */
- class update_cmd
- : public rpc_cmd<HW::item<bool>, rc_t, vapi::Ip_add_del_route>
- {
- public:
- /**
- * Constructor
- */
- update_cmd(HW::item<bool>& item,
- table_id_t id,
- const prefix_t& prefix,
- const path_list_t& paths);
-
- /**
- * 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 update_cmd& i) const;
-
- private:
- route::table_id_t m_id;
- prefix_t m_prefix;
- const path_list_t m_paths;
- };
-
- /**
- * A cmd class that deletes a route
- */
- class delete_cmd
- : public rpc_cmd<HW::item<bool>, rc_t, vapi::Ip_add_del_route>
- {
- public:
- /**
- * Constructor
- */
- delete_cmd(HW::item<bool>& item, table_id_t id, const prefix_t& prefix);
-
- /**
- * 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 delete_cmd& i) const;
-
- private:
- route::table_id_t m_id;
- prefix_t m_prefix;
- };
-
- /**
- * A cmd class that Dumps ipv4 fib
- */
- class dump_v4_cmd : public VOM::dump_cmd<vapi::Ip_fib_dump>
- {
- public:
- /**
- * Constructor
- */
- dump_v4_cmd();
- dump_v4_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_v4_cmd& i) const;
-
- private:
- /**
- * HW reutrn code
- */
- HW::item<bool> item;
- };
-
- /**
- * A cmd class that Dumps ipv6 fib
- */
- class dump_v6_cmd : public VOM::dump_cmd<vapi::Ip6_fib_dump>
- {
- public:
- /**
- * Constructor
- */
- dump_v6_cmd();
- dump_v6_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_v6_cmd& i) const;
-
- private:
- /**
- * HW reutrn code
- */
- HW::item<bool> item;
- };
-
private:
/**
* Class definition for listeners to OM events
diff --git a/src/vpp-api/vom/route_cmds.cpp b/src/vpp-api/vom/route_cmds.cpp
index 66dd2865e1a..0d012a2946b 100644
--- a/src/vpp-api/vom/route_cmds.cpp
+++ b/src/vpp-api/vom/route_cmds.cpp
@@ -15,14 +15,57 @@
#include <sstream>
-#include "vom/route.hpp"
+#include "vom/route_cmds.hpp"
namespace VOM {
namespace route {
-ip_route::update_cmd::update_cmd(HW::item<bool>& item,
- table_id_t id,
- const prefix_t& prefix,
- const path_list_t& paths)
+namespace ip_route_cmds {
+
+static void
+to_vpp(const route::path& p, vapi_payload_ip_add_del_route& payload)
+{
+ payload.is_drop = 0;
+ payload.is_unreach = 0;
+ payload.is_prohibit = 0;
+ payload.is_local = 0;
+ payload.is_classify = 0;
+ payload.is_multipath = 0;
+ payload.is_resolve_host = 0;
+ payload.is_resolve_attached = 0;
+
+ if (nh_proto_t::ETHERNET == p.nh_proto()) {
+ payload.is_l2_bridged = 1;
+ }
+
+ if (route::path::special_t::STANDARD == p.type()) {
+ uint8_t path_v6;
+ to_bytes(p.nh(), &path_v6, payload.next_hop_address);
+
+ if (p.rd()) {
+ payload.next_hop_table_id = p.rd()->table_id();
+ }
+ if (p.itf()) {
+ payload.next_hop_sw_if_index = p.itf()->handle().value();
+ }
+ } else if (route::path::special_t::DROP == p.type()) {
+ payload.is_drop = 1;
+ } else if (route::path::special_t::UNREACH == p.type()) {
+ payload.is_unreach = 1;
+ } else if (route::path::special_t::PROHIBIT == p.type()) {
+ payload.is_prohibit = 1;
+ } else if (route::path::special_t::LOCAL == p.type()) {
+ payload.is_local = 1;
+ }
+ payload.next_hop_weight = p.weight();
+ payload.next_hop_preference = p.preference();
+ payload.next_hop_via_label = 0;
+ payload.classify_table_index = 0;
+}
+
+update_cmd::update_cmd(HW::item<bool>& item,
+ table_id_t id,
+ const prefix_t& prefix,
+ const path_list_t& paths)
: rpc_cmd(item)
, m_id(id)
, m_prefix(prefix)
@@ -33,13 +76,13 @@ ip_route::update_cmd::update_cmd(HW::item<bool>& item,
}
bool
-ip_route::update_cmd::operator==(const update_cmd& other) const
+update_cmd::operator==(const update_cmd& other) const
{
return ((m_prefix == other.m_prefix) && (m_id == other.m_id));
}
rc_t
-ip_route::update_cmd::issue(connection& con)
+update_cmd::issue(connection& con)
{
msg_t req(con.ctx(), 0, std::ref(*this));
@@ -53,7 +96,7 @@ ip_route::update_cmd::issue(connection& con)
&payload.dst_address_length);
for (auto& p : m_paths)
- p.to_vpp(payload);
+ to_vpp(p, payload);
VAPI_CALL(req.execute());
@@ -63,7 +106,7 @@ ip_route::update_cmd::issue(connection& con)
}
std::string
-ip_route::update_cmd::to_string() const
+update_cmd::to_string() const
{
std::ostringstream s;
s << "ip-route-create: " << m_hw_item.to_string() << " table-id:" << m_id
@@ -72,9 +115,9 @@ ip_route::update_cmd::to_string() const
return (s.str());
}
-ip_route::delete_cmd::delete_cmd(HW::item<bool>& item,
- table_id_t id,
- const prefix_t& prefix)
+delete_cmd::delete_cmd(HW::item<bool>& item,
+ table_id_t id,
+ const prefix_t& prefix)
: rpc_cmd(item)
, m_id(id)
, m_prefix(prefix)
@@ -82,13 +125,13 @@ ip_route::delete_cmd::delete_cmd(HW::item<bool>& item,
}
bool
-ip_route::delete_cmd::operator==(const delete_cmd& other) const
+delete_cmd::operator==(const delete_cmd& other) const
{
return ((m_prefix == other.m_prefix) && (m_id == other.m_id));
}
rc_t
-ip_route::delete_cmd::issue(connection& con)
+delete_cmd::issue(connection& con)
{
msg_t req(con.ctx(), 0, std::ref(*this));
@@ -108,7 +151,7 @@ ip_route::delete_cmd::issue(connection& con)
}
std::string
-ip_route::delete_cmd::to_string() const
+delete_cmd::to_string() const
{
std::ostringstream s;
s << "ip-route-delete: " << m_hw_item.to_string() << " id:" << m_id
@@ -117,18 +160,18 @@ ip_route::delete_cmd::to_string() const
return (s.str());
}
-ip_route::dump_v4_cmd::dump_v4_cmd()
+dump_v4_cmd::dump_v4_cmd()
{
}
bool
-ip_route::dump_v4_cmd::operator==(const dump_v4_cmd& other) const
+dump_v4_cmd::operator==(const dump_v4_cmd& other) const
{
return (true);
}
rc_t
-ip_route::dump_v4_cmd::issue(connection& con)
+dump_v4_cmd::issue(connection& con)
{
m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
@@ -140,23 +183,23 @@ ip_route::dump_v4_cmd::issue(connection& con)
}
std::string
-ip_route::dump_v4_cmd::to_string() const
+dump_v4_cmd::to_string() const
{
return ("ip-route-v4-dump");
}
-ip_route::dump_v6_cmd::dump_v6_cmd()
+dump_v6_cmd::dump_v6_cmd()
{
}
bool
-ip_route::dump_v6_cmd::operator==(const dump_v6_cmd& other) const
+dump_v6_cmd::operator==(const dump_v6_cmd& other) const
{
return (true);
}
rc_t
-ip_route::dump_v6_cmd::issue(connection& con)
+dump_v6_cmd::issue(connection& con)
{
m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
@@ -168,16 +211,17 @@ ip_route::dump_v6_cmd::issue(connection& con)
}
std::string
-ip_route::dump_v6_cmd::to_string() const
+dump_v6_cmd::to_string() const
{
return ("ip-route-v6-dump");
}
-}
-}
-/*
- * fd.io coding-style-patch-verification: ON
- *
- * Local Variables:
- * eval: (c-set-style "mozilla")
- * End:
- */
+} // namespace ip_route_cmds
+} // namespace route
+} // namespace vom
+ /*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
diff --git a/src/vpp-api/vom/route_cmds.hpp b/src/vpp-api/vom/route_cmds.hpp
new file mode 100644
index 00000000000..f2c10ff60ad
--- /dev/null
+++ b/src/vpp-api/vom/route_cmds.hpp
@@ -0,0 +1,173 @@
+/*
+ * Copyright (c) 2017 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_ROUTE_CMDS_H__
+#define __VOM_ROUTE_CMDS_H__
+
+#include "vom/dump_cmd.hpp"
+#include "vom/route.hpp"
+#include "vom/rpc_cmd.hpp"
+
+#include <vapi/ip.api.vapi.hpp>
+
+namespace VOM {
+namespace route {
+namespace ip_route_cmds {
+
+/**
+ * A command class that creates or updates the route
+ */
+class update_cmd : public rpc_cmd<HW::item<bool>, rc_t, vapi::Ip_add_del_route>
+{
+public:
+ /**
+ * Constructor
+ */
+ update_cmd(HW::item<bool>& item,
+ table_id_t id,
+ const prefix_t& prefix,
+ const path_list_t& paths);
+
+ /**
+ * 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 update_cmd& i) const;
+
+private:
+ route::table_id_t m_id;
+ prefix_t m_prefix;
+ const path_list_t m_paths;
+};
+
+/**
+ * A cmd class that deletes a route
+ */
+class delete_cmd : public rpc_cmd<HW::item<bool>, rc_t, vapi::Ip_add_del_route>
+{
+public:
+ /**
+ * Constructor
+ */
+ delete_cmd(HW::item<bool>& item, table_id_t id, const prefix_t& prefix);
+
+ /**
+ * 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 delete_cmd& i) const;
+
+private:
+ route::table_id_t m_id;
+ prefix_t m_prefix;
+};
+
+/**
+ * A cmd class that Dumps ipv4 fib
+ */
+class dump_v4_cmd : public VOM::dump_cmd<vapi::Ip_fib_dump>
+{
+public:
+ /**
+ * Constructor
+ */
+ dump_v4_cmd();
+ dump_v4_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_v4_cmd& i) const;
+
+private:
+ /**
+ * HW reutrn code
+ */
+ HW::item<bool> item;
+};
+
+/**
+ * A cmd class that Dumps ipv6 fib
+ */
+class dump_v6_cmd : public VOM::dump_cmd<vapi::Ip6_fib_dump>
+{
+public:
+ /**
+ * Constructor
+ */
+ dump_v6_cmd();
+ dump_v6_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_v6_cmd& i) const;
+
+private:
+ /**
+ * HW reutrn code
+ */
+ HW::item<bool> item;
+};
+
+}; // namespace ip_route_cmds
+}; // namespace route
+}; // namespace VOM
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
+
+#endif
diff --git a/src/vpp-api/vom/route_domain.cpp b/src/vpp-api/vom/route_domain.cpp
index 8ae5785e9f6..f173fd7a250 100644
--- a/src/vpp-api/vom/route_domain.cpp
+++ b/src/vpp-api/vom/route_domain.cpp
@@ -15,6 +15,7 @@
#include "vom/route_domain.hpp"
#include "vom/cmd.hpp"
+#include "vom/route_domain_cmds.hpp"
namespace VOM {
/**
@@ -55,10 +56,12 @@ void
route_domain::sweep()
{
if (m_hw_v4) {
- HW::enqueue(new delete_cmd(m_hw_v4, l3_proto_t::IPV4, m_table_id));
+ HW::enqueue(
+ new route_domain_cmds::delete_cmd(m_hw_v4, l3_proto_t::IPV4, m_table_id));
}
if (m_hw_v6) {
- HW::enqueue(new delete_cmd(m_hw_v6, l3_proto_t::IPV6, m_table_id));
+ HW::enqueue(
+ new route_domain_cmds::delete_cmd(m_hw_v6, l3_proto_t::IPV6, m_table_id));
}
HW::write();
}
@@ -67,10 +70,12 @@ void
route_domain::replay()
{
if (m_hw_v4) {
- HW::enqueue(new create_cmd(m_hw_v4, l3_proto_t::IPV4, m_table_id));
+ HW::enqueue(
+ new route_domain_cmds::create_cmd(m_hw_v4, l3_proto_t::IPV4, m_table_id));
}
if (m_hw_v6) {
- HW::enqueue(new create_cmd(m_hw_v6, l3_proto_t::IPV6, m_table_id));
+ HW::enqueue(
+ new route_domain_cmds::create_cmd(m_hw_v6, l3_proto_t::IPV6, m_table_id));
}
}
@@ -125,10 +130,12 @@ route_domain::update(const route_domain& desired)
* create the table if it is not yet created
*/
if (rc_t::OK != m_hw_v4.rc()) {
- HW::enqueue(new create_cmd(m_hw_v4, l3_proto_t::IPV4, m_table_id));
+ HW::enqueue(
+ new route_domain_cmds::create_cmd(m_hw_v4, l3_proto_t::IPV4, m_table_id));
}
if (rc_t::OK != m_hw_v6.rc()) {
- HW::enqueue(new create_cmd(m_hw_v6, l3_proto_t::IPV6, m_table_id));
+ HW::enqueue(
+ new route_domain_cmds::create_cmd(m_hw_v6, l3_proto_t::IPV6, m_table_id));
}
}
diff --git a/src/vpp-api/vom/route_domain.hpp b/src/vpp-api/vom/route_domain.hpp
index 5d3b8914aca..0639fb95925 100644
--- a/src/vpp-api/vom/route_domain.hpp
+++ b/src/vpp-api/vom/route_domain.hpp
@@ -92,84 +92,6 @@ public:
*/
void replay(void);
- /**
- * A command class that creates the IP table
- */
- class create_cmd
- : public rpc_cmd<HW::item<bool>, rc_t, vapi::Ip_table_add_del>
- {
- public:
- /**
- * Constructor
- */
- create_cmd(HW::item<bool>& item, l3_proto_t proto, route::table_id_t id);
-
- /**
- * 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 create_cmd& i) const;
-
- private:
- /**
- * table-ID to create
- */
- route::table_id_t m_id;
-
- /**
- * L3 protocol of the table
- */
- l3_proto_t m_proto;
- };
-
- /**
- * A cmd class that Deletes the IP Table
- */
- class delete_cmd
- : public rpc_cmd<HW::item<bool>, rc_t, vapi::Ip_table_add_del>
- {
- public:
- /**
- * Constructor
- */
- delete_cmd(HW::item<bool>& item, l3_proto_t proto, route::table_id_t id);
-
- /**
- * 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 delete_cmd& i) const;
-
- private:
- /**
- * table-ID to create
- */
- route::table_id_t m_id;
-
- /**
- * L3 protocol of the table
- */
- l3_proto_t m_proto;
- };
-
private:
/**
* Commit the acculmulated changes into VPP. i.e. to a 'HW" write.
@@ -217,7 +139,7 @@ private:
*/
static singular_db<route::table_id_t, route_domain> m_db;
};
-};
+}; // namespace VOM
/*
* fd.io coding-style-patch-verification: ON
diff --git a/src/vpp-api/vom/route_domain_cmds.cpp b/src/vpp-api/vom/route_domain_cmds.cpp
index c3f817f79f1..845497f5989 100644
--- a/src/vpp-api/vom/route_domain_cmds.cpp
+++ b/src/vpp-api/vom/route_domain_cmds.cpp
@@ -13,13 +13,14 @@
* limitations under the License.
*/
-#include "vom/route_domain.hpp"
+#include "vom/route_domain_cmds.hpp"
namespace VOM {
+namespace route_domain_cmds {
-route_domain::create_cmd::create_cmd(HW::item<bool>& item,
- l3_proto_t proto,
- route::table_id_t id)
+create_cmd::create_cmd(HW::item<bool>& item,
+ l3_proto_t proto,
+ route::table_id_t id)
: rpc_cmd(item)
, m_id(id)
, m_proto(proto)
@@ -27,13 +28,13 @@ route_domain::create_cmd::create_cmd(HW::item<bool>& item,
}
bool
-route_domain::create_cmd::operator==(const create_cmd& other) const
+create_cmd::operator==(const create_cmd& other) const
{
return (m_id == other.m_id);
}
rc_t
-route_domain::create_cmd::issue(connection& con)
+create_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -50,7 +51,7 @@ route_domain::create_cmd::issue(connection& con)
}
std::string
-route_domain::create_cmd::to_string() const
+create_cmd::to_string() const
{
std::ostringstream s;
s << "ip-table-create: " << m_hw_item.to_string() << " id:" << m_id
@@ -59,9 +60,9 @@ route_domain::create_cmd::to_string() const
return (s.str());
}
-route_domain::delete_cmd::delete_cmd(HW::item<bool>& item,
- l3_proto_t proto,
- route::table_id_t id)
+delete_cmd::delete_cmd(HW::item<bool>& item,
+ l3_proto_t proto,
+ route::table_id_t id)
: rpc_cmd(item)
, m_id(id)
, m_proto(proto)
@@ -69,13 +70,13 @@ route_domain::delete_cmd::delete_cmd(HW::item<bool>& item,
}
bool
-route_domain::delete_cmd::operator==(const delete_cmd& other) const
+delete_cmd::operator==(const delete_cmd& other) const
{
return (m_id == other.m_id);
}
rc_t
-route_domain::delete_cmd::issue(connection& con)
+delete_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -93,7 +94,7 @@ route_domain::delete_cmd::issue(connection& con)
}
std::string
-route_domain::delete_cmd::to_string() const
+delete_cmd::to_string() const
{
std::ostringstream s;
s << "ip-table-delete: " << m_hw_item.to_string() << " id:" << m_id
@@ -101,11 +102,12 @@ route_domain::delete_cmd::to_string() const
return (s.str());
}
-}
-/*
- * fd.io coding-style-patch-verification: ON
- *
- * Local Variables:
- * eval: (c-set-style "mozilla")
- * End:
- */
+} // namespace route_domain_cmds
+} // namespace VOM
+ /*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
diff --git a/src/vpp-api/vom/route_domain_cmds.hpp b/src/vpp-api/vom/route_domain_cmds.hpp
new file mode 100644
index 00000000000..f3911bd59f0
--- /dev/null
+++ b/src/vpp-api/vom/route_domain_cmds.hpp
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2017 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_ROUTE_DOMAIN_CMDS_H__
+#define __VOM_ROUTE_DOMAIN_CMDS_H__
+
+#include "vom/route_domain.hpp"
+#include "vom/rpc_cmd.hpp"
+
+#include <vapi/ip.api.vapi.hpp>
+
+namespace VOM {
+namespace route_domain_cmds {
+
+/**
+ * A command class that creates the IP table
+ */
+class create_cmd : public rpc_cmd<HW::item<bool>, rc_t, vapi::Ip_table_add_del>
+{
+public:
+ /**
+ * Constructor
+ */
+ create_cmd(HW::item<bool>& item, l3_proto_t proto, route::table_id_t id);
+
+ /**
+ * 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 create_cmd& i) const;
+
+private:
+ /**
+ * table-ID to create
+ */
+ route::table_id_t m_id;
+
+ /**
+ * L3 protocol of the table
+ */
+ l3_proto_t m_proto;
+};
+
+/**
+ * A cmd class that Deletes the IP Table
+ */
+class delete_cmd : public rpc_cmd<HW::item<bool>, rc_t, vapi::Ip_table_add_del>
+{
+public:
+ /**
+ * Constructor
+ */
+ delete_cmd(HW::item<bool>& item, l3_proto_t proto, route::table_id_t id);
+
+ /**
+ * 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 delete_cmd& i) const;
+
+private:
+ /**
+ * table-ID to create
+ */
+ route::table_id_t m_id;
+
+ /**
+ * L3 protocol of the table
+ */
+ l3_proto_t m_proto;
+};
+
+}; // namespace route_domain_cmds
+}; // namespace VOM
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
+
+#endif
diff --git a/src/vpp-api/vom/singular_db.hpp b/src/vpp-api/vom/singular_db.hpp
index 707389b5844..bc49c88551f 100644
--- a/src/vpp-api/vom/singular_db.hpp
+++ b/src/vpp-api/vom/singular_db.hpp
@@ -19,6 +19,8 @@
#include <memory>
#include <ostream>
+#include "vom/logger.hpp"
+
namespace VOM {
/**
* A Database to store the unique 'singular' instances of a single object
diff --git a/src/vpp-api/vom/sub_interface.cpp b/src/vpp-api/vom/sub_interface.cpp
index de56bf2fbac..ea7fa419f75 100644
--- a/src/vpp-api/vom/sub_interface.cpp
+++ b/src/vpp-api/vom/sub_interface.cpp
@@ -14,6 +14,7 @@
*/
#include "vom/sub_interface.hpp"
+#include "vom/sub_interface_cmds.hpp"
namespace VOM {
/**
@@ -64,7 +65,8 @@ sub_interface::mk_name(const interface& parent, vlan_id_t vlan)
std::queue<cmd*>&
sub_interface::mk_create_cmd(std::queue<cmd*>& q)
{
- q.push(new create_cmd(m_hdl, name(), m_parent->handle(), m_vlan));
+ q.push(new sub_interface_cmds::create_cmd(m_hdl, name(), m_parent->handle(),
+ m_vlan));
return (q);
}
@@ -72,7 +74,7 @@ sub_interface::mk_create_cmd(std::queue<cmd*>& q)
std::queue<cmd*>&
sub_interface::mk_delete_cmd(std::queue<cmd*>& q)
{
- q.push(new delete_cmd(m_hdl));
+ q.push(new sub_interface_cmds::delete_cmd(m_hdl));
return (q);
}
diff --git a/src/vpp-api/vom/sub_interface.hpp b/src/vpp-api/vom/sub_interface.hpp
index d780c8a070b..5878f45e251 100644
--- a/src/vpp-api/vom/sub_interface.hpp
+++ b/src/vpp-api/vom/sub_interface.hpp
@@ -48,75 +48,6 @@ public:
*/
std::shared_ptr<sub_interface> singular() const;
- /**
- * A functor class that creates an interface
- */
- class create_cmd : public interface::create_cmd<vapi::Create_vlan_subif>
- {
- public:
- /**
- * Cstrunctor taking the reference to the parent
- * and the sub-interface's VLAN
- */
- create_cmd(HW::item<handle_t>& item,
- const std::string& name,
- const handle_t& parent,
- uint16_t vlan);
-
- /**
- * 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 create_cmd& i) const;
-
- private:
- /**
- * Refernece to the parents handle
- */
- const handle_t& m_parent;
-
- /**
- * The VLAN of the sub-interface
- */
- uint16_t m_vlan;
- };
-
- /**
- * A cmd class that Delete an interface
- */
- class delete_cmd : public interface::delete_cmd<vapi::Delete_subif>
- {
- public:
- /**
- * Constructor
- */
- delete_cmd(HW::item<handle_t>& item);
-
- /**
- * 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 delete_cmd& i) const;
- };
-
private:
/**
* Construct with handle
@@ -125,6 +56,8 @@ private:
const interface& parent,
admin_state_t state,
vlan_id_t vlan);
+ friend class interface_factory;
+
/**
* The interface class can construct interfaces with handles
*/
diff --git a/src/vpp-api/vom/sub_interface_cmds.cpp b/src/vpp-api/vom/sub_interface_cmds.cpp
index 2d417c7b138..47af69268d1 100644
--- a/src/vpp-api/vom/sub_interface_cmds.cpp
+++ b/src/vpp-api/vom/sub_interface_cmds.cpp
@@ -13,16 +13,18 @@
* limitations under the License.
*/
-#include "vom/sub_interface.hpp"
+#include "vom/sub_interface_cmds.hpp"
#include "vom/cmd.hpp"
#include <vapi/vpe.api.vapi.hpp>
namespace VOM {
-sub_interface::create_cmd::create_cmd(HW::item<handle_t>& item,
- const std::string& name,
- const handle_t& parent,
- uint16_t vlan)
+namespace sub_interface_cmds {
+
+create_cmd::create_cmd(HW::item<handle_t>& item,
+ const std::string& name,
+ const handle_t& parent,
+ uint16_t vlan)
: interface::create_cmd<vapi::Create_vlan_subif>(item, name)
, m_parent(parent)
, m_vlan(vlan)
@@ -30,14 +32,14 @@ sub_interface::create_cmd::create_cmd(HW::item<handle_t>& item,
}
bool
-sub_interface::create_cmd::operator==(const create_cmd& other) const
+create_cmd::operator==(const create_cmd& other) const
{
return ((m_name == other.m_name) && (m_parent == other.m_parent) &&
(m_vlan == other.m_vlan));
}
rc_t
-sub_interface::create_cmd::issue(connection& con)
+create_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -50,14 +52,14 @@ sub_interface::create_cmd::issue(connection& con)
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
-sub_interface::create_cmd::to_string() const
+create_cmd::to_string() const
{
std::ostringstream s;
s << "sub-itf-create: " << m_hw_item.to_string() << " parent:" << m_parent
@@ -65,19 +67,19 @@ sub_interface::create_cmd::to_string() const
return (s.str());
}
-sub_interface::delete_cmd::delete_cmd(HW::item<handle_t>& item)
+delete_cmd::delete_cmd(HW::item<handle_t>& item)
: interface::delete_cmd<vapi::Delete_subif>(item)
{
}
bool
-sub_interface::delete_cmd::operator==(const delete_cmd& other) const
+delete_cmd::operator==(const delete_cmd& other) const
{
return (m_hw_item == other.m_hw_item);
}
rc_t
-sub_interface::delete_cmd::issue(connection& con)
+delete_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -89,12 +91,12 @@ sub_interface::delete_cmd::issue(connection& con)
wait();
m_hw_item.set(rc_t::NOOP);
- interface::remove(m_hw_item);
+ remove_interface();
return (rc_t::OK);
}
std::string
-sub_interface::delete_cmd::to_string() const
+delete_cmd::to_string() const
{
std::ostringstream s;
@@ -102,11 +104,12 @@ sub_interface::delete_cmd::to_string() const
return (s.str());
}
-}
-/*
- * fd.io coding-style-patch-verification: ON
- *
- * Local Variables:
- * eval: (c-set-style "mozilla")
- * End:
- */
+} // namespace sub_interface_cmds
+} // namespace VOM
+ /*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
diff --git a/src/vpp-api/vom/sub_interface_cmds.hpp b/src/vpp-api/vom/sub_interface_cmds.hpp
new file mode 100644
index 00000000000..1447bf35cbe
--- /dev/null
+++ b/src/vpp-api/vom/sub_interface_cmds.hpp
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2017 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_SUB_INTERFACE_CMDS_H__
+#define __VOM_SUB_INTERFACE_CMDS_H__
+
+#include "vom/dump_cmd.hpp"
+#include "vom/rpc_cmd.hpp"
+#include "vom/sub_interface.hpp"
+
+#include <vapi/vpe.api.vapi.hpp>
+
+namespace VOM {
+namespace sub_interface_cmds {
+
+/**
+ * A functor class that creates an interface
+ */
+class create_cmd : public interface::create_cmd<vapi::Create_vlan_subif>
+{
+public:
+ /**
+ * Cstrunctor taking the reference to the parent
+ * and the sub-interface's VLAN
+ */
+ create_cmd(HW::item<handle_t>& item,
+ const std::string& name,
+ const handle_t& parent,
+ uint16_t vlan);
+
+ /**
+ * 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 create_cmd& i) const;
+
+private:
+ /**
+ * Refernece to the parents handle
+ */
+ const handle_t& m_parent;
+
+ /**
+ * The VLAN of the sub-interface
+ */
+ uint16_t m_vlan;
+};
+
+/**
+ * A cmd class that Delete an interface
+ */
+class delete_cmd : public interface::delete_cmd<vapi::Delete_subif>
+{
+public:
+ /**
+ * Constructor
+ */
+ delete_cmd(HW::item<handle_t>& item);
+
+ /**
+ * 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 delete_cmd& i) const;
+};
+
+}; // namespace sub_interface_cmds
+}; // namespace VOM
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
+
+#endif
diff --git a/src/vpp-api/vom/tap_interface.cpp b/src/vpp-api/vom/tap_interface.cpp
index d776c486c72..4b6c7875b32 100644
--- a/src/vpp-api/vom/tap_interface.cpp
+++ b/src/vpp-api/vom/tap_interface.cpp
@@ -14,7 +14,7 @@
*/
#include "vom/tap_interface.hpp"
-#include "vom/cmd.hpp"
+#include "vom/tap_interface_cmds.hpp"
#include <vapi/vpe.api.vapi.hpp>
@@ -69,7 +69,8 @@ tap_interface::tap_interface(const tap_interface& o)
std::queue<cmd*>&
tap_interface::mk_create_cmd(std::queue<cmd*>& q)
{
- q.push(new create_cmd(m_hdl, name(), m_prefix, m_l2_address));
+ q.push(
+ new tap_interface_cmds::create_cmd(m_hdl, name(), m_prefix, m_l2_address));
return (q);
}
@@ -77,7 +78,7 @@ tap_interface::mk_create_cmd(std::queue<cmd*>& q)
std::queue<cmd*>&
tap_interface::mk_delete_cmd(std::queue<cmd*>& q)
{
- q.push(new delete_cmd(m_hdl));
+ q.push(new tap_interface_cmds::delete_cmd(m_hdl));
return (q);
}
@@ -100,7 +101,8 @@ tap_interface::event_handler::handle_populate(const client_db::key_t& key)
/*
* dump VPP current states
*/
- std::shared_ptr<tap_interface::dump_cmd> cmd(new tap_interface::dump_cmd());
+ std::shared_ptr<tap_interface_cmds::dump_cmd> cmd(
+ new tap_interface_cmds::dump_cmd());
HW::enqueue(cmd);
HW::write();
diff --git a/src/vpp-api/vom/tap_interface.hpp b/src/vpp-api/vom/tap_interface.hpp
index af90b7bb9d6..08dba501572 100644
--- a/src/vpp-api/vom/tap_interface.hpp
+++ b/src/vpp-api/vom/tap_interface.hpp
@@ -42,75 +42,6 @@ public:
*/
std::shared_ptr<tap_interface> singular() const;
- /**
- * A functor class that creates an interface
- */
- class create_cmd : public interface::create_cmd<vapi::Tap_connect>
- {
- public:
- create_cmd(HW::item<handle_t>& item,
- const std::string& name,
- route::prefix_t& prefix,
- const l2_address_t& l2_address);
-
- /**
- * Issue the command to VPP/HW
- */
- rc_t issue(connection& con);
- /**
- * convert to string format for debug purposes
- */
- std::string to_string() const;
-
- private:
- route::prefix_t& m_prefix;
- const l2_address_t& m_l2_address;
- };
-
- /**
- *
- */
- class delete_cmd : public interface::delete_cmd<vapi::Tap_delete>
- {
- public:
- delete_cmd(HW::item<handle_t>& item);
-
- /**
- * Issue the command to VPP/HW
- */
- rc_t issue(connection& con);
- /**
- * convert to string format for debug purposes
- */
- std::string to_string() const;
- };
-
- /**
- * A cmd class that Dumps all the Vpp Interfaces
- */
- class dump_cmd : public VOM::dump_cmd<vapi::Sw_interface_tap_dump>
- {
- public:
- /**
- * Default Constructor
- */
- dump_cmd();
-
- /**
- * 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:
/**
* Class definition for listeners to OM events
@@ -151,6 +82,8 @@ private:
admin_state_t state,
route::prefix_t prefix);
+ friend class interface_factory;
+
/**
* Ip Prefix
*/
diff --git a/src/vpp-api/vom/tap_interface_cmds.cpp b/src/vpp-api/vom/tap_interface_cmds.cpp
index f616fd0b4ab..799b9afd58a 100644
--- a/src/vpp-api/vom/tap_interface_cmds.cpp
+++ b/src/vpp-api/vom/tap_interface_cmds.cpp
@@ -13,16 +13,16 @@
* limitations under the License.
*/
-#include "vom/tap_interface.hpp"
-#include "vom/cmd.hpp"
+#include "vom/tap_interface_cmds.hpp"
#include <vapi/tap.api.vapi.hpp>
namespace VOM {
-tap_interface::create_cmd::create_cmd(HW::item<handle_t>& item,
- const std::string& name,
- route::prefix_t& prefix,
- const l2_address_t& l2_address)
+namespace tap_interface_cmds {
+create_cmd::create_cmd(HW::item<handle_t>& item,
+ const std::string& name,
+ route::prefix_t& prefix,
+ const l2_address_t& l2_address)
: interface::create_cmd<vapi::Tap_connect>(item, name)
, m_prefix(prefix)
, m_l2_address(l2_address)
@@ -30,7 +30,7 @@ tap_interface::create_cmd::create_cmd(HW::item<handle_t>& item,
}
rc_t
-tap_interface::create_cmd::issue(connection& con)
+create_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -63,7 +63,7 @@ tap_interface::create_cmd::issue(connection& con)
}
std::string
-tap_interface::create_cmd::to_string() const
+create_cmd::to_string() const
{
std::ostringstream s;
s << "tap-intf-create: " << m_hw_item.to_string()
@@ -72,20 +72,20 @@ tap_interface::create_cmd::to_string() const
return (s.str());
}
-tap_interface::delete_cmd::delete_cmd(HW::item<handle_t>& item)
+delete_cmd::delete_cmd(HW::item<handle_t>& item)
: interface::delete_cmd<vapi::Tap_delete>(item)
{
}
rc_t
-tap_interface::delete_cmd::issue(connection& con)
+delete_cmd::issue(connection& con)
{
// finally... call VPP
return rc_t::OK;
}
std::string
-tap_interface::delete_cmd::to_string() const
+delete_cmd::to_string() const
{
std::ostringstream s;
s << "tap-itf-delete: " << m_hw_item.to_string();
@@ -93,18 +93,18 @@ tap_interface::delete_cmd::to_string() const
return (s.str());
}
-tap_interface::dump_cmd::dump_cmd()
+dump_cmd::dump_cmd()
{
}
bool
-tap_interface::dump_cmd::operator==(const dump_cmd& other) const
+dump_cmd::operator==(const dump_cmd& other) const
{
return (true);
}
rc_t
-tap_interface::dump_cmd::issue(connection& con)
+dump_cmd::issue(connection& con)
{
m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
@@ -116,11 +116,12 @@ tap_interface::dump_cmd::issue(connection& con)
}
std::string
-tap_interface::dump_cmd::to_string() const
+dump_cmd::to_string() const
{
return ("tap-itf-dump");
}
-}
+} // namespace tap_interface_cmds
+} // namespace VOM
/*
* fd.io coding-style-patch-verification: ON
diff --git a/src/vpp-api/vom/tap_interface_cmds.hpp b/src/vpp-api/vom/tap_interface_cmds.hpp
new file mode 100644
index 00000000000..1c1a3468c9b
--- /dev/null
+++ b/src/vpp-api/vom/tap_interface_cmds.hpp
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2017 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_TAP_INTERFACE_CMDS_H__
+#define __VOM_TAP_INTERFACE_CMDS_H__
+
+#include "vom/interface.hpp"
+#include "vom/tap_interface.hpp"
+#include "vom/dump_cmd.hpp"
+#include "vom/rpc_cmd.hpp"
+
+#include <vapi/interface.api.vapi.hpp>
+#include <vapi/tap.api.vapi.hpp>
+
+namespace VOM {
+namespace tap_interface_cmds {
+
+/**
+ * A functor class that creates an interface
+ */
+class create_cmd : public interface::create_cmd<vapi::Tap_connect>
+{
+public:
+ create_cmd(HW::item<handle_t>& item,
+ const std::string& name,
+ route::prefix_t& prefix,
+ const l2_address_t& l2_address);
+
+ /**
+ * Issue the command to VPP/HW
+ */
+ rc_t issue(connection& con);
+ /**
+ * convert to string format for debug purposes
+ */
+ std::string to_string() const;
+
+private:
+ route::prefix_t& m_prefix;
+ const l2_address_t& m_l2_address;
+};
+
+/**
+ * A functor class that deletes a Tap interface
+ */
+class delete_cmd : public interface::delete_cmd<vapi::Tap_delete>
+{
+public:
+ delete_cmd(HW::item<handle_t>& item);
+
+ /**
+ * Issue the command to VPP/HW
+ */
+ rc_t issue(connection& con);
+ /**
+ * convert to string format for debug purposes
+ */
+ std::string to_string() const;
+};
+
+/**
+ * A cmd class that Dumps all the Vpp Interfaces
+ */
+class dump_cmd : public VOM::dump_cmd<vapi::Sw_interface_tap_dump>
+{
+public:
+ /**
+ * Default Constructor
+ */
+ dump_cmd();
+
+ /**
+ * 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;
+};
+
+}; // namespace tap_interface_cmds
+}; // namespace VOM
+
+#endif
diff --git a/src/vpp-api/vom/vxlan_tunnel.cpp b/src/vpp-api/vom/vxlan_tunnel.cpp
index 7079021ee6e..abb278b1882 100644
--- a/src/vpp-api/vom/vxlan_tunnel.cpp
+++ b/src/vpp-api/vom/vxlan_tunnel.cpp
@@ -15,6 +15,7 @@
#include "vom/vxlan_tunnel.hpp"
#include "vom/logger.hpp"
+#include "vom/vxlan_tunnel_cmds.hpp"
namespace VOM {
const std::string VXLAN_TUNNEL_NAME = "vxlan-tunnel-itf";
@@ -134,7 +135,7 @@ void
vxlan_tunnel::sweep()
{
if (m_hdl) {
- HW::enqueue(new delete_cmd(m_hdl, m_tep));
+ HW::enqueue(new vxlan_tunnel_cmds::delete_cmd(m_hdl, m_tep));
}
HW::write();
}
@@ -143,7 +144,7 @@ void
vxlan_tunnel::replay()
{
if (m_hdl) {
- HW::enqueue(new create_cmd(m_hdl, name(), m_tep));
+ HW::enqueue(new vxlan_tunnel_cmds::create_cmd(m_hdl, name(), m_tep));
}
}
@@ -174,7 +175,7 @@ vxlan_tunnel::update(const vxlan_tunnel& desired)
* the desired state is always that the interface should be created
*/
if (!m_hdl) {
- HW::enqueue(new create_cmd(m_hdl, name(), m_tep));
+ HW::enqueue(new vxlan_tunnel_cmds::create_cmd(m_hdl, name(), m_tep));
}
}
@@ -218,7 +219,8 @@ vxlan_tunnel::event_handler::handle_populate(const client_db::key_t& key)
/*
* dump VPP current states
*/
- std::shared_ptr<vxlan_tunnel::dump_cmd> cmd(new vxlan_tunnel::dump_cmd());
+ std::shared_ptr<vxlan_tunnel_cmds::dump_cmd> cmd(
+ new vxlan_tunnel_cmds::dump_cmd());
HW::enqueue(cmd);
HW::write();
diff --git a/src/vpp-api/vom/vxlan_tunnel.hpp b/src/vpp-api/vom/vxlan_tunnel.hpp
index 845cd6aee45..a0b3e9afa3e 100644
--- a/src/vpp-api/vom/vxlan_tunnel.hpp
+++ b/src/vpp-api/vom/vxlan_tunnel.hpp
@@ -23,11 +23,8 @@
#include "vom/om.hpp"
#include "vom/prefix.hpp"
#include "vom/route_domain.hpp"
-#include "vom/rpc_cmd.hpp"
#include "vom/singular_db.hpp"
-#include <vapi/vxlan.api.vapi.hpp>
-
namespace VOM {
/**
* A representation of a VXLAN Tunnel in VPP
@@ -129,101 +126,6 @@ public:
*/
static void dump(std::ostream& os);
- /**
- * A Command class that creates an VXLAN tunnel
- */
- class create_cmd : public interface::create_cmd<vapi::Vxlan_add_del_tunnel>
- {
- public:
- /**
- * Create command constructor taking HW item to update and the
- * endpoint values
- */
- create_cmd(HW::item<handle_t>& item,
- const std::string& name,
- const endpoint_t& ep);
-
- /**
- * 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 create_cmd& i) const;
-
- private:
- /**
- * Enpoint values of the tunnel to be created
- */
- const endpoint_t m_ep;
- };
-
- /**
- * A functor class that creates an VXLAN tunnel
- */
- class delete_cmd : public interface::delete_cmd<vapi::Vxlan_add_del_tunnel>
- {
- public:
- /**
- * delete command constructor taking HW item to update and the
- * endpoint values
- */
- delete_cmd(HW::item<handle_t>& item, const endpoint_t& ep);
-
- /**
- * 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 delete_cmd& i) const;
-
- private:
- /**
- * Enpoint values of the tunnel to be deleted
- */
- const endpoint_t m_ep;
- };
-
- /**
- * A cmd class that Dumps all the Vpp interfaces
- */
- class dump_cmd : public VOM::dump_cmd<vapi::Vxlan_tunnel_dump>
- {
- public:
- /**
- * Default Constructor
- */
- dump_cmd();
-
- /**
- * 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:
/**
* Class definition for listeners to OM events
@@ -318,7 +220,8 @@ private:
* Ostream output for a tunnel endpoint
*/
std::ostream& operator<<(std::ostream& os, const vxlan_tunnel::endpoint_t& ep);
-};
+
+}; // namespace VOM
/*
* fd.io coding-style-patch-verification: ON
diff --git a/src/vpp-api/vom/vxlan_tunnel_cmds.cpp b/src/vpp-api/vom/vxlan_tunnel_cmds.cpp
index 9a4a1312c4a..ca4ccf3c38a 100644
--- a/src/vpp-api/vom/vxlan_tunnel_cmds.cpp
+++ b/src/vpp-api/vom/vxlan_tunnel_cmds.cpp
@@ -13,27 +13,29 @@
* limitations under the License.
*/
-#include "vom/vxlan_tunnel.hpp"
+#include "vom/vxlan_tunnel_cmds.hpp"
DEFINE_VAPI_MSG_IDS_VXLAN_API_JSON;
namespace VOM {
-vxlan_tunnel::create_cmd::create_cmd(HW::item<handle_t>& item,
- const std::string& name,
- const endpoint_t& ep)
+namespace vxlan_tunnel_cmds {
+
+create_cmd::create_cmd(HW::item<handle_t>& item,
+ const std::string& name,
+ const vxlan_tunnel::endpoint_t& ep)
: interface::create_cmd<vapi::Vxlan_add_del_tunnel>(item, name)
, m_ep(ep)
{
}
bool
-vxlan_tunnel::create_cmd::operator==(const create_cmd& other) const
+create_cmd::operator==(const create_cmd& other) const
{
return (m_ep == other.m_ep);
}
rc_t
-vxlan_tunnel::create_cmd::issue(connection& con)
+create_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -52,14 +54,14 @@ vxlan_tunnel::create_cmd::issue(connection& con)
m_hw_item = wait();
if (m_hw_item) {
- interface::add(m_name, m_hw_item);
+ insert_interface();
}
return rc_t::OK;
}
std::string
-vxlan_tunnel::create_cmd::to_string() const
+create_cmd::to_string() const
{
std::ostringstream s;
s << "vxlan-tunnel-create: " << m_hw_item.to_string() << m_ep.to_string();
@@ -67,21 +69,21 @@ vxlan_tunnel::create_cmd::to_string() const
return (s.str());
}
-vxlan_tunnel::delete_cmd::delete_cmd(HW::item<handle_t>& item,
- const endpoint_t& ep)
+delete_cmd::delete_cmd(HW::item<handle_t>& item,
+ const vxlan_tunnel::endpoint_t& ep)
: interface::delete_cmd<vapi::Vxlan_add_del_tunnel>(item)
, m_ep(ep)
{
}
bool
-vxlan_tunnel::delete_cmd::operator==(const delete_cmd& other) const
+delete_cmd::operator==(const delete_cmd& other) const
{
return (m_ep == other.m_ep);
}
rc_t
-vxlan_tunnel::delete_cmd::issue(connection& con)
+delete_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
@@ -100,12 +102,12 @@ vxlan_tunnel::delete_cmd::issue(connection& con)
wait();
m_hw_item.set(rc_t::NOOP);
- interface::remove(m_hw_item);
+ remove_interface();
return (rc_t::OK);
}
std::string
-vxlan_tunnel::delete_cmd::to_string() const
+delete_cmd::to_string() const
{
std::ostringstream s;
s << "vxlan-tunnel-delete: " << m_hw_item.to_string() << m_ep.to_string();
@@ -113,18 +115,18 @@ vxlan_tunnel::delete_cmd::to_string() const
return (s.str());
}
-vxlan_tunnel::dump_cmd::dump_cmd()
+dump_cmd::dump_cmd()
{
}
bool
-vxlan_tunnel::dump_cmd::operator==(const dump_cmd& other) const
+dump_cmd::operator==(const dump_cmd& other) const
{
return (true);
}
rc_t
-vxlan_tunnel::dump_cmd::issue(connection& con)
+dump_cmd::issue(connection& con)
{
m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
@@ -139,11 +141,12 @@ vxlan_tunnel::dump_cmd::issue(connection& con)
}
std::string
-vxlan_tunnel::dump_cmd::to_string() const
+dump_cmd::to_string() const
{
return ("Vpp-vxlan_tunnels-Dump");
}
-}
+} // namespace vxlan_tunnel_cmds
+} // namespace VOM
/*
* fd.io coding-style-patch-verification: ON
diff --git a/src/vpp-api/vom/vxlan_tunnel_cmds.hpp b/src/vpp-api/vom/vxlan_tunnel_cmds.hpp
new file mode 100644
index 00000000000..4a8e5990391
--- /dev/null
+++ b/src/vpp-api/vom/vxlan_tunnel_cmds.hpp
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2017 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_VXLAN_TUNNEL_CMDS_H__
+#define __VOM_VXLAN_TUNNEL_CMDS_H__
+
+#include "vom/dump_cmd.hpp"
+#include "vom/rpc_cmd.hpp"
+#include "vom/vxlan_tunnel.hpp"
+
+#include <vapi/vapi.hpp>
+#include <vapi/vxlan.api.vapi.hpp>
+
+namespace VOM {
+namespace vxlan_tunnel_cmds {
+
+/**
+ * A Command class that creates an VXLAN tunnel
+ */
+class create_cmd : public interface::create_cmd<vapi::Vxlan_add_del_tunnel>
+{
+public:
+ /**
+ * Create command constructor taking HW item to update and the
+ * endpoint values
+ */
+ create_cmd(HW::item<handle_t>& item,
+ const std::string& name,
+ const vxlan_tunnel::endpoint_t& ep);
+
+ /**
+ * 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 create_cmd& i) const;
+
+private:
+ /**
+ * Enpoint values of the tunnel to be created
+ */
+ const vxlan_tunnel::endpoint_t m_ep;
+};
+
+/**
+ * A functor class that creates an VXLAN tunnel
+ */
+class delete_cmd : public interface::delete_cmd<vapi::Vxlan_add_del_tunnel>
+{
+public:
+ /**
+ * delete command constructor taking HW item to update and the
+ * endpoint values
+ */
+ delete_cmd(HW::item<handle_t>& item, const vxlan_tunnel::endpoint_t& ep);
+
+ /**
+ * 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 delete_cmd& i) const;
+
+private:
+ /**
+ * Enpoint values of the tunnel to be deleted
+ */
+ const vxlan_tunnel::endpoint_t m_ep;
+};
+
+/**
+ * A cmd class that Dumps all the Vpp interfaces
+ */
+class dump_cmd : public VOM::dump_cmd<vapi::Vxlan_tunnel_dump>
+{
+public:
+ /**
+ * Default Constructor
+ */
+ dump_cmd();
+
+ /**
+ * 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;
+};
+
+}; // namespace vxlan_tunnel_cmds
+}; // namespace VOM
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
+
+#endif