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/route_api_types.hpp>
19 #include <vom/route_cmds.hpp>
23 namespace ip_route_cmds {
25 update_cmd::update_cmd(HW::item<bool>& item,
27 const prefix_t& prefix,
28 const path_list_t& paths)
35 assert(paths.size() == 1);
39 update_cmd::operator==(const update_cmd& other) const
41 return ((m_prefix == other.m_prefix) && (m_id == other.m_id));
45 update_cmd::issue(connection& con)
47 msg_t req(con.ctx(), 0, std::ref(*this));
49 auto& payload = req.get_request().get_payload();
51 payload.table_id = m_id;
53 payload.is_multipath = 0;
55 m_prefix.to_vpp(&payload.is_ipv6, payload.dst_address,
56 &payload.dst_address_length);
58 for (auto& p : m_paths)
61 VAPI_CALL(req.execute());
67 update_cmd::to_string() const
70 s << "ip-route-create: " << m_hw_item.to_string() << " table-id:" << m_id
71 << " prefix:" << m_prefix.to_string() << " paths:" << m_paths;
76 delete_cmd::delete_cmd(HW::item<bool>& item,
78 const prefix_t& prefix)
86 delete_cmd::operator==(const delete_cmd& other) const
88 return ((m_prefix == other.m_prefix) && (m_id == other.m_id));
92 delete_cmd::issue(connection& con)
94 msg_t req(con.ctx(), 0, std::ref(*this));
96 auto& payload = req.get_request().get_payload();
97 payload.table_id = m_id;
100 m_prefix.to_vpp(&payload.is_ipv6, payload.dst_address,
101 &payload.dst_address_length);
103 VAPI_CALL(req.execute());
106 m_hw_item.set(rc_t::NOOP);
112 delete_cmd::to_string() const
114 std::ostringstream s;
115 s << "ip-route-delete: " << m_hw_item.to_string() << " id:" << m_id
116 << " prefix:" << m_prefix.to_string();
121 dump_v4_cmd::dump_v4_cmd()
126 dump_v4_cmd::operator==(const dump_v4_cmd& other) const
132 dump_v4_cmd::issue(connection& con)
134 m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
136 VAPI_CALL(m_dump->execute());
144 dump_v4_cmd::to_string() const
146 return ("ip-route-v4-dump");
149 dump_v6_cmd::dump_v6_cmd()
154 dump_v6_cmd::operator==(const dump_v6_cmd& other) const
160 dump_v6_cmd::issue(connection& con)
162 m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
164 VAPI_CALL(m_dump->execute());
172 dump_v6_cmd::to_string() const
174 return ("ip-route-v6-dump");
176 } // namespace ip_route_cmds
180 * fd.io coding-style-patch-verification: ON
183 * eval: (c-set-style "mozilla")