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.hpp"
22 ip_route::update_cmd::update_cmd(HW::item<bool>& item,
24 const prefix_t& prefix,
25 const path_list_t& paths)
32 assert(paths.size() == 1);
36 ip_route::update_cmd::operator==(const update_cmd& other) const
38 return ((m_prefix == other.m_prefix) && (m_id == other.m_id));
42 ip_route::update_cmd::issue(connection& con)
44 msg_t req(con.ctx(), 0, std::ref(*this));
46 auto& payload = req.get_request().get_payload();
48 payload.table_id = m_id;
50 payload.is_multipath = 0;
52 m_prefix.to_vpp(&payload.is_ipv6, payload.dst_address,
53 &payload.dst_address_length);
55 for (auto& p : m_paths)
58 VAPI_CALL(req.execute());
60 m_hw_item.set(wait());
66 ip_route::update_cmd::to_string() const
69 s << "ip-route-create: " << m_hw_item.to_string() << " table-id:" << m_id
70 << " prefix:" << m_prefix.to_string() << " paths:" << m_paths;
75 ip_route::delete_cmd::delete_cmd(HW::item<bool>& item,
77 const prefix_t& prefix)
85 ip_route::delete_cmd::operator==(const delete_cmd& other) const
87 return ((m_prefix == other.m_prefix) && (m_id == other.m_id));
91 ip_route::delete_cmd::issue(connection& con)
93 msg_t req(con.ctx(), 0, std::ref(*this));
95 auto& payload = req.get_request().get_payload();
96 payload.table_id = m_id;
99 m_prefix.to_vpp(&payload.is_ipv6, payload.dst_address,
100 &payload.dst_address_length);
102 VAPI_CALL(req.execute());
105 m_hw_item.set(rc_t::NOOP);
111 ip_route::delete_cmd::to_string() const
113 std::ostringstream s;
114 s << "ip-route-delete: " << m_hw_item.to_string() << " id:" << m_id
115 << " prefix:" << m_prefix.to_string();
120 ip_route::dump_v4_cmd::dump_v4_cmd()
125 ip_route::dump_v4_cmd::operator==(const dump_v4_cmd& other) const
131 ip_route::dump_v4_cmd::issue(connection& con)
133 m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
135 VAPI_CALL(m_dump->execute());
143 ip_route::dump_v4_cmd::to_string() const
145 return ("ip-route-v4-dump");
148 ip_route::dump_v6_cmd::dump_v6_cmd()
153 ip_route::dump_v6_cmd::operator==(const dump_v6_cmd& other) const
159 ip_route::dump_v6_cmd::issue(connection& con)
161 m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
163 VAPI_CALL(m_dump->execute());
171 ip_route::dump_v6_cmd::to_string() const
173 return ("ip-route-v6-dump");
178 * fd.io coding-style-patch-verification: ON
181 * eval: (c-set-style "mozilla")