X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=extras%2Fvom%2Fvom%2Froute_cmds.cpp;h=78676c225befa60b1957a57e0f012c46ecc4bd34;hb=7c0eb56f4;hp=26d6593df7803b316f215265a56316a00eefeeb8;hpb=7c03ed47d5acfa39820f9553999caa01cf47dba4;p=vpp.git diff --git a/extras/vom/vom/route_cmds.cpp b/extras/vom/vom/route_cmds.cpp index 26d6593df78..78676c225be 100644 --- a/extras/vom/vom/route_cmds.cpp +++ b/extras/vom/vom/route_cmds.cpp @@ -15,6 +15,7 @@ #include +#include #include #include @@ -22,41 +23,41 @@ namespace VOM { namespace route { namespace ip_route_cmds { -update_cmd::update_cmd(HW::item& item, +update_cmd::update_cmd(HW::item& item, table_id_t id, const prefix_t& prefix, - const path_list_t& paths) - : rpc_cmd(item) + const path_list_t& pl) + : srpc_cmd(item) , m_id(id) , m_prefix(prefix) - , m_paths(paths) + , m_pl(pl) { - // no multipath yet. - assert(paths.size() == 1); } bool update_cmd::operator==(const update_cmd& other) const { - return ((m_prefix == other.m_prefix) && (m_id == other.m_id)); + return ((m_prefix == other.m_prefix) && (m_id == other.m_id) && + (m_pl == other.m_pl)); } rc_t update_cmd::issue(connection& con) { - msg_t req(con.ctx(), 0, std::ref(*this)); + msg_t req(con.ctx(), m_pl.size(), std::ref(*this)); auto& payload = req.get_request().get_payload(); - payload.table_id = m_id; + payload.route.table_id = m_id; payload.is_add = 1; - payload.is_multipath = 0; + payload.is_multipath = 1; - m_prefix.to_vpp(&payload.is_ipv6, payload.dst_address, - &payload.dst_address_length); + payload.route.table_id = m_id; + payload.route.prefix = to_api(m_prefix); - for (auto& p : m_paths) - to_vpp(p, payload); + uint32_t ii = 0; + for (auto& p : m_pl) + to_api(p, payload.route.paths[ii++]); VAPI_CALL(req.execute()); @@ -68,12 +69,14 @@ update_cmd::to_string() const { std::ostringstream s; s << "ip-route-create: " << m_hw_item.to_string() << " table-id:" << m_id - << " prefix:" << m_prefix.to_string() << " paths:" << m_paths; + << " prefix:" << m_prefix.to_string() << " paths:"; + for (auto p : m_pl) + s << p.to_string() << " "; return (s.str()); } -delete_cmd::delete_cmd(HW::item& item, +delete_cmd::delete_cmd(HW::item& item, table_id_t id, const prefix_t& prefix) : rpc_cmd(item) @@ -94,11 +97,13 @@ delete_cmd::issue(connection& con) msg_t req(con.ctx(), 0, std::ref(*this)); auto& payload = req.get_request().get_payload(); - payload.table_id = m_id; payload.is_add = 0; + payload.is_multipath = 0; - m_prefix.to_vpp(&payload.is_ipv6, payload.dst_address, - &payload.dst_address_length); + payload.route.table_id = m_id; + payload.route.n_paths = 0; + payload.route.table_id = m_id; + payload.route.prefix = to_api(m_prefix); VAPI_CALL(req.execute()); @@ -118,48 +123,27 @@ delete_cmd::to_string() const return (s.str()); } -dump_v4_cmd::dump_v4_cmd() +dump_cmd::dump_cmd(route::table_id_t id, const l3_proto_t& proto) + : m_id(id) + , m_proto(proto) { } bool -dump_v4_cmd::operator==(const dump_v4_cmd& other) const +dump_cmd::operator==(const dump_cmd& other) const { return (true); } rc_t -dump_v4_cmd::issue(connection& con) +dump_cmd::issue(connection& con) { m_dump.reset(new msg_t(con.ctx(), std::ref(*this))); - VAPI_CALL(m_dump->execute()); + auto& payload = m_dump->get_request().get_payload(); - wait(); - - return rc_t::OK; -} - -std::string -dump_v4_cmd::to_string() const -{ - return ("ip-route-v4-dump"); -} - -dump_v6_cmd::dump_v6_cmd() -{ -} - -bool -dump_v6_cmd::operator==(const dump_v6_cmd& other) const -{ - return (true); -} - -rc_t -dump_v6_cmd::issue(connection& con) -{ - m_dump.reset(new msg_t(con.ctx(), std::ref(*this))); + payload.table.table_id = m_id; + payload.table.is_ip6 = m_proto.is_ipv6(); VAPI_CALL(m_dump->execute()); @@ -169,17 +153,19 @@ dump_v6_cmd::issue(connection& con) } std::string -dump_v6_cmd::to_string() const +dump_cmd::to_string() const { - return ("ip-route-v6-dump"); + return ("ip-route-v4-dump"); } + } // namespace ip_route_cmds } // namespace route } // namespace vom - /* - * fd.io coding-style-patch-verification: ON - * - * Local Variables: - * eval: (c-set-style "mozilla") - * End: - */ + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "mozilla") + * End: + */