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/mroute_cmds.hpp"
20 #include "vom/route_api_types.hpp"
24 namespace ip_mroute_cmds {
26 update_cmd::update_cmd(HW::item<bool>& item,
28 const mprefix_t& mprefix,
30 const itf_flags_t& flags)
40 update_cmd::operator==(const update_cmd& other) const
42 return ((m_mprefix == other.m_mprefix) && (m_id == other.m_id));
46 update_cmd::issue(connection& con)
48 msg_t req(con.ctx(), 1, std::ref(*this));
50 auto& payload = req.get_request().get_payload();
54 payload.route.table_id = m_id;
55 payload.route.prefix = to_api(m_mprefix);
57 to_api(m_path, payload.route.paths[0].path);
58 payload.route.paths[0].itf_flags = to_api(m_flags);
60 VAPI_CALL(req.execute());
66 update_cmd::to_string() const
69 s << "ip-mroute-create: " << m_hw_item.to_string() << " table-id:" << m_id
70 << " mprefix:" << m_mprefix.to_string() << " path:" << m_path.to_string()
71 << " flags:" << m_flags;
76 delete_cmd::delete_cmd(HW::item<bool>& item,
78 const mprefix_t& mprefix,
80 const itf_flags_t& flags)
90 delete_cmd::operator==(const delete_cmd& other) const
92 return ((m_mprefix == other.m_mprefix) && (m_id == other.m_id));
96 delete_cmd::issue(connection& con)
98 msg_t req(con.ctx(), 1, std::ref(*this));
100 auto& payload = req.get_request().get_payload();
103 payload.route.table_id = m_id;
104 payload.route.prefix = to_api(m_mprefix);
106 to_api(m_path, payload.route.paths[0].path);
107 payload.route.paths[0].itf_flags = to_api(m_flags);
109 VAPI_CALL(req.execute());
112 m_hw_item.set(rc_t::NOOP);
118 delete_cmd::to_string() const
120 std::ostringstream s;
121 s << "ip-mroute-delete: " << m_hw_item.to_string() << " id:" << m_id
122 << " mprefix:" << m_mprefix.to_string();
127 dump_cmd::dump_cmd(route::table_id_t id, const l3_proto_t& proto)
134 dump_cmd::operator==(const dump_cmd& other) const
140 dump_cmd::issue(connection& con)
142 m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
144 auto& payload = m_dump->get_request().get_payload();
146 payload.table.table_id = m_id;
147 payload.table.is_ip6 = m_proto.is_ipv6();
149 VAPI_CALL(m_dump->execute());
157 dump_cmd::to_string() const
159 std::ostringstream s;
160 s << "ip-mroute-dump: id:" << m_id << " proto:" << m_proto.to_string();
165 } // namespace ip_mroute_cmds
166 } // namespace mroute
169 * fd.io coding-style-patch-verification: ON
172 * eval: (c-set-style "mozilla")