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,
37 update_cmd::operator==(const update_cmd& other) const
39 return ((m_prefix == other.m_prefix) && (m_id == other.m_id) &&
40 (m_path == other.m_path));
44 update_cmd::issue(connection& con)
46 msg_t req(con.ctx(), 0, std::ref(*this));
48 auto& payload = req.get_request().get_payload();
50 payload.table_id = m_id;
52 payload.is_multipath = 0;
54 m_prefix.to_vpp(&payload.is_ipv6, payload.dst_address,
55 &payload.dst_address_length);
56 to_vpp(m_path, payload);
58 VAPI_CALL(req.execute());
64 update_cmd::to_string() const
67 s << "ip-route-create: " << m_hw_item.to_string() << " table-id:" << m_id
68 << " prefix:" << m_prefix.to_string() << " paths:" << m_path.to_string();
73 delete_cmd::delete_cmd(HW::item<bool>& item,
75 const prefix_t& prefix,
85 delete_cmd::operator==(const delete_cmd& other) const
87 return ((m_prefix == other.m_prefix) && (m_id == other.m_id) &&
88 (m_path == other.m_path));
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);
102 to_vpp(m_path, payload);
104 VAPI_CALL(req.execute());
107 m_hw_item.set(rc_t::NOOP);
113 delete_cmd::to_string() const
115 std::ostringstream s;
116 s << "ip-route-delete: " << m_hw_item.to_string() << " id:" << m_id
117 << " prefix:" << m_prefix.to_string() << " paths:" << m_path.to_string();
122 dump_v4_cmd::dump_v4_cmd()
127 dump_v4_cmd::operator==(const dump_v4_cmd& other) const
133 dump_v4_cmd::issue(connection& con)
135 m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
137 VAPI_CALL(m_dump->execute());
145 dump_v4_cmd::to_string() const
147 return ("ip-route-v4-dump");
150 dump_v6_cmd::dump_v6_cmd()
155 dump_v6_cmd::operator==(const dump_v6_cmd& other) const
161 dump_v6_cmd::issue(connection& con)
163 m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
165 VAPI_CALL(m_dump->execute());
173 dump_v6_cmd::to_string() const
175 return ("ip-route-v6-dump");
177 } // namespace ip_route_cmds
181 * fd.io coding-style-patch-verification: ON
184 * eval: (c-set-style "mozilla")