2 * Copyright (c) 2018 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.
16 #include "vom/ip_punt_redirect_cmds.hpp"
17 #include <vom/api_types.hpp>
20 namespace ip_punt_redirect_cmds {
22 config_cmd::config_cmd(HW::item<bool>& item,
23 const handle_t rx_itf,
24 const handle_t tx_itf,
25 const boost::asio::ip::address& addr)
34 config_cmd::operator==(const config_cmd& o) const
36 return ((m_rx_itf == o.m_rx_itf) && (m_tx_itf == o.m_tx_itf) &&
37 (m_addr == o.m_addr));
41 config_cmd::issue(connection& con)
43 msg_t req(con.ctx(), std::ref(*this));
45 auto& payload = req.get_request().get_payload();
48 payload.punt.rx_sw_if_index = m_rx_itf.value();
49 payload.punt.tx_sw_if_index = m_tx_itf.value();
50 to_api(m_addr, payload.punt.nh);
52 VAPI_CALL(req.execute());
58 config_cmd::to_string() const
61 s << "IP-punt-redirect: " << m_hw_item.to_string()
62 << " rx-itf:" << m_rx_itf.to_string() << " tx-itf:" << m_tx_itf.to_string()
63 << " next-hop:" << m_addr;
68 unconfig_cmd::unconfig_cmd(HW::item<bool>& item,
69 const handle_t rx_itf,
70 const handle_t tx_itf,
71 const boost::asio::ip::address& addr)
80 unconfig_cmd::operator==(const unconfig_cmd& o) const
82 return ((m_rx_itf == o.m_rx_itf) && (m_tx_itf == o.m_tx_itf) &&
83 (m_addr == o.m_addr));
87 unconfig_cmd::issue(connection& con)
89 msg_t req(con.ctx(), std::ref(*this));
91 auto& payload = req.get_request().get_payload();
94 payload.punt.rx_sw_if_index = m_rx_itf.value();
95 payload.punt.tx_sw_if_index = m_tx_itf.value();
96 to_api(m_addr, payload.punt.nh);
98 VAPI_CALL(req.execute());
101 m_hw_item.set(rc_t::NOOP);
107 unconfig_cmd::to_string() const
109 std::ostringstream s;
110 s << "IP-punt-redirect-unconfig: " << m_hw_item.to_string()
111 << " rx-itf:" << m_rx_itf.to_string() << " tx-itf:" << m_tx_itf.to_string()
112 << " next-hop:" << m_addr.to_string();
118 dump_cmd::operator==(const dump_cmd& other) const
124 dump_cmd::issue(connection& con)
126 m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
128 VAPI_CALL(m_dump->execute());
136 dump_cmd::to_string() const
138 return ("ip-punt-redirect-dump");
141 }; // namespace ip_punt_redirect_cmds
145 * fd.io coding-style-patch-verification: ON
148 * eval: (c-set-style "mozilla")