aboutsummaryrefslogtreecommitdiffstats
path: root/src/vpp-api
diff options
context:
space:
mode:
Diffstat (limited to 'src/vpp-api')
-rw-r--r--src/vpp-api/vom/nat_binding.cpp66
-rw-r--r--src/vpp-api/vom/nat_binding_cmds.cpp120
-rw-r--r--src/vpp-api/vom/nat_binding_cmds.hpp118
3 files changed, 172 insertions, 132 deletions
diff --git a/src/vpp-api/vom/nat_binding.cpp b/src/vpp-api/vom/nat_binding.cpp
index eca3f9041f0..64b7a1007ac 100644
--- a/src/vpp-api/vom/nat_binding.cpp
+++ b/src/vpp-api/vom/nat_binding.cpp
@@ -85,11 +85,20 @@ nat_binding::sweep()
{
if (m_binding) {
if (direction_t::INPUT == m_dir) {
- HW::enqueue(new nat_binding_cmds::unbind_44_input_cmd(
- m_binding, m_itf->handle(), m_zone));
+ if (l3_proto_t::IPV4 == m_proto) {
+ HW::enqueue(new nat_binding_cmds::unbind_44_input_cmd(
+ m_binding, m_itf->handle(), m_zone));
+ } else {
+ HW::enqueue(new nat_binding_cmds::unbind_66_input_cmd(
+ m_binding, m_itf->handle(), m_zone));
+ }
} else {
- HW::enqueue(new nat_binding_cmds::unbind_44_output_cmd(
- m_binding, m_itf->handle(), m_zone));
+ if (l3_proto_t::IPV4 == m_proto) {
+ HW::enqueue(new nat_binding_cmds::unbind_44_output_cmd(
+ m_binding, m_itf->handle(), m_zone));
+ } else {
+ VOM_LOG(log_level_t::ERROR) << "NAT 66 output feature not supported";
+ }
}
}
HW::write();
@@ -100,11 +109,20 @@ nat_binding::replay()
{
if (m_binding) {
if (direction_t::INPUT == m_dir) {
- HW::enqueue(new nat_binding_cmds::bind_44_input_cmd(
- m_binding, m_itf->handle(), m_zone));
+ if (l3_proto_t::IPV4 == m_proto) {
+ HW::enqueue(new nat_binding_cmds::bind_44_input_cmd(
+ m_binding, m_itf->handle(), m_zone));
+ } else {
+ HW::enqueue(new nat_binding_cmds::bind_66_input_cmd(
+ m_binding, m_itf->handle(), m_zone));
+ }
} else {
- HW::enqueue(new nat_binding_cmds::bind_44_output_cmd(
- m_binding, m_itf->handle(), m_zone));
+ if (l3_proto_t::IPV4 == m_proto) {
+ HW::enqueue(new nat_binding_cmds::bind_44_output_cmd(
+ m_binding, m_itf->handle(), m_zone));
+ } else {
+ VOM_LOG(log_level_t::ERROR) << "NAT 66 output feature not supported";
+ }
}
}
}
@@ -117,11 +135,20 @@ nat_binding::update(const nat_binding& desired)
*/
if (!m_binding) {
if (direction_t::INPUT == m_dir) {
- HW::enqueue(new nat_binding_cmds::bind_44_input_cmd(
- m_binding, m_itf->handle(), m_zone));
+ if (l3_proto_t::IPV4 == m_proto) {
+ HW::enqueue(new nat_binding_cmds::bind_44_input_cmd(
+ m_binding, m_itf->handle(), m_zone));
+ } else {
+ HW::enqueue(new nat_binding_cmds::bind_66_input_cmd(
+ m_binding, m_itf->handle(), m_zone));
+ }
} else {
- HW::enqueue(new nat_binding_cmds::bind_44_output_cmd(
- m_binding, m_itf->handle(), m_zone));
+ if (l3_proto_t::IPV4 == m_proto) {
+ HW::enqueue(new nat_binding_cmds::bind_44_output_cmd(
+ m_binding, m_itf->handle(), m_zone));
+ } else {
+ VOM_LOG(log_level_t::ERROR) << "NAT 66 output feature not supported";
+ }
}
}
}
@@ -214,6 +241,21 @@ nat_binding::event_handler::handle_populate(const client_db::key_t& key)
zone_t::from_vpp(payload.is_inside));
OM::commit(key, nb);
}
+
+ std::shared_ptr<nat_binding_cmds::dump_input_66_cmd> i6cmd =
+ std::make_shared<nat_binding_cmds::dump_input_66_cmd>();
+
+ HW::enqueue(i6cmd);
+ HW::write();
+
+ for (auto& record : *i6cmd) {
+ auto& payload = record.get_payload();
+
+ std::shared_ptr<interface> itf = interface::find(payload.sw_if_index);
+ nat_binding nb(*itf, direction_t::INPUT, l3_proto_t::IPV6,
+ zone_t::from_vpp(payload.is_inside));
+ OM::commit(key, nb);
+ }
}
dependency_t
diff --git a/src/vpp-api/vom/nat_binding_cmds.cpp b/src/vpp-api/vom/nat_binding_cmds.cpp
index 66b2827abc2..4d98268249a 100644
--- a/src/vpp-api/vom/nat_binding_cmds.cpp
+++ b/src/vpp-api/vom/nat_binding_cmds.cpp
@@ -214,7 +214,7 @@ dump_input_44_cmd::issue(connection& con)
std::string
dump_input_44_cmd::to_string() const
{
- return ("nat-input-binding-dump");
+ return ("nat-44-input-binding-dump");
}
dump_output_44_cmd::dump_output_44_cmd()
@@ -246,7 +246,123 @@ dump_output_44_cmd::issue(connection& con)
std::string
dump_output_44_cmd::to_string() const
{
- return ("nat-output-binding-dump");
+ return ("nat-44-output-binding-dump");
+}
+
+bind_66_input_cmd::bind_66_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)
+{
+}
+
+bool
+bind_66_input_cmd::operator==(const bind_66_input_cmd& other) const
+{
+ return ((m_itf == other.m_itf) && (m_zone == other.m_zone));
+}
+
+rc_t
+bind_66_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 = (nat_binding::zone_t::INSIDE == m_zone ? 1 : 0);
+ payload.sw_if_index = m_itf.value();
+
+ VAPI_CALL(req.execute());
+
+ m_hw_item.set(wait());
+
+ return rc_t::OK;
+}
+
+std::string
+bind_66_input_cmd::to_string() const
+{
+ std::ostringstream s;
+ s << "nat-66-input-binding-create: " << m_hw_item.to_string()
+ << " itf:" << m_itf << " " << m_zone.to_string();
+
+ return (s.str());
+}
+
+unbind_66_input_cmd::unbind_66_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)
+{
+}
+
+bool
+unbind_66_input_cmd::operator==(const unbind_66_input_cmd& other) const
+{
+ return ((m_itf == other.m_itf) && (m_zone == other.m_zone));
+}
+
+rc_t
+unbind_66_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 = (nat_binding::zone_t::INSIDE == m_zone ? 1 : 0);
+ payload.sw_if_index = m_itf.value();
+
+ VAPI_CALL(req.execute());
+
+ m_hw_item.set(wait());
+
+ return rc_t::OK;
+}
+
+std::string
+unbind_66_input_cmd::to_string() const
+{
+ std::ostringstream s;
+ s << "nat-66-input-binding-create: " << m_hw_item.to_string()
+ << " itf:" << m_itf << " " << m_zone.to_string();
+
+ return (s.str());
+}
+
+dump_input_66_cmd::dump_input_66_cmd()
+{
+}
+
+dump_input_66_cmd::dump_input_66_cmd(const dump_input_66_cmd& d)
+{
+}
+
+bool
+dump_input_66_cmd::operator==(const dump_input_66_cmd& other) const
+{
+ return (true);
+}
+
+rc_t
+dump_input_66_cmd::issue(connection& con)
+{
+ m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
+
+ VAPI_CALL(m_dump->execute());
+
+ wait();
+
+ return rc_t::OK;
+}
+
+std::string
+dump_input_66_cmd::to_string() const
+{
+ return ("nat-66-input-binding-dump");
}
}; // namespace nat_binding_cmds
diff --git a/src/vpp-api/vom/nat_binding_cmds.hpp b/src/vpp-api/vom/nat_binding_cmds.hpp
index 1b51192a73c..aa5a200515e 100644
--- a/src/vpp-api/vom/nat_binding_cmds.hpp
+++ b/src/vpp-api/vom/nat_binding_cmds.hpp
@@ -337,90 +337,6 @@ private:
};
/**
- * A functor class that binds a NAT configuration to an output interface
- */
-/* class bind_66_output_cmd */
-/* : public rpc_cmd<HW::item<bool>, */
-/* rc_t, */
-/* vapi::Nat66_interface_add_del_output_feature> */
-/* { */
-/* public: */
-/* /\** */
-/* * Constructor */
-/* *\/ */
-/* bind_66_output_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_66_output_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 a NAT configuration from an output interface */
-/* *\/ */
-/* class unbind_66_output_cmd */
-/* : public rpc_cmd<HW::item<bool>, */
-/* rc_t, */
-/* vapi::Nat66_interface_add_del_output_feature> */
-/* { */
-/* public: */
-/* /\** */
-/* * Constructor */
-/* *\/ */
-/* unbind_66_output_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_66_output_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_input_66_cmd : public dump_cmd<vapi::Nat66_interface_dump>
@@ -453,40 +369,6 @@ private:
HW::item<bool> item;
};
-/**
- * A cmd class that Dumps all the nat_statics
- */
-/* class dump_output_66_cmd */
-/* : public dump_cmd<vapi::Nat66_interface_output_feature_dump> */
-/* { */
-/* public: */
-/* /\** */
-/* * Constructor */
-/* *\/ */
-/* dump_output_66_cmd(); */
-/* dump_output_66_cmd(const dump_output_66_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_output_66_cmd& i) const; */
-
-/* private: */
-/* /\** */
-/* * HW reutrn code */
-/* *\/ */
-/* HW::item<bool> item; */
-/* }; */
-
}; // namespace nat_binding_cmds
}; // namespace VOM