2 * Copyright (c) 2017 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
18 #include <vom/api_types.hpp>
19 #include <vom/route_api_types.hpp>
20 #include <vom/route_cmds.hpp>
24 namespace ip_route_cmds {
26 update_cmd::update_cmd(HW::item<handle_t>& item,
28 const prefix_t& prefix,
29 const path_list_t& pl)
38 update_cmd::operator==(const update_cmd& other) const
40 return ((m_prefix == other.m_prefix) && (m_id == other.m_id) &&
41 (m_pl == other.m_pl));
45 update_cmd::issue(connection& con)
47 msg_t req(con.ctx(), m_pl.size(), std::ref(*this));
49 auto& payload = req.get_request().get_payload();
51 payload.route.table_id = m_id;
53 payload.is_multipath = 1;
55 payload.route.table_id = m_id;
56 payload.route.prefix = to_api(m_prefix);
60 to_api(p, payload.route.paths[ii++]);
62 VAPI_CALL(req.execute());
68 update_cmd::to_string() const
71 s << "ip-route-create: " << m_hw_item.to_string() << " table-id:" << m_id
72 << " prefix:" << m_prefix.to_string() << " paths:";
74 s << p.to_string() << " ";
79 delete_cmd::delete_cmd(HW::item<handle_t>& item,
81 const prefix_t& prefix)
89 delete_cmd::operator==(const delete_cmd& other) const
91 return ((m_prefix == other.m_prefix) && (m_id == other.m_id));
95 delete_cmd::issue(connection& con)
97 msg_t req(con.ctx(), 0, std::ref(*this));
99 auto& payload = req.get_request().get_payload();
101 payload.is_multipath = 0;
103 payload.route.table_id = m_id;
104 payload.route.n_paths = 0;
105 payload.route.table_id = m_id;
106 payload.route.prefix = to_api(m_prefix);
108 VAPI_CALL(req.execute());
111 m_hw_item.set(rc_t::NOOP);
117 delete_cmd::to_string() const
119 std::ostringstream s;
120 s << "ip-route-delete: " << m_hw_item.to_string() << " id:" << m_id
121 << " prefix:" << m_prefix.to_string();
126 dump_cmd::dump_cmd(route::table_id_t id, const l3_proto_t& proto)
133 dump_cmd::operator==(const dump_cmd& other) const
139 dump_cmd::issue(connection& con)
141 m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
143 auto& payload = m_dump->get_request().get_payload();
145 payload.table.table_id = m_id;
146 payload.table.is_ip6 = m_proto.is_ipv6();
148 VAPI_CALL(m_dump->execute());
156 dump_cmd::to_string() const
158 return ("ip-route-v4-dump");
161 } // namespace ip_route_cmds
166 * fd.io coding-style-patch-verification: ON
169 * eval: (c-set-style "mozilla")