aboutsummaryrefslogtreecommitdiffstats
path: root/src/vpp-api/vom/route_cmds.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/vpp-api/vom/route_cmds.cpp')
-rw-r--r--src/vpp-api/vom/route_cmds.cpp108
1 files changed, 76 insertions, 32 deletions
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:
+ */