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"
19 namespace ip_punt_redirect_cmds {
21 config_cmd::config_cmd(HW::item<bool>& item,
22 const handle_t& rx_itf,
23 const handle_t& tx_itf,
24 const boost::asio::ip::address& addr)
33 config_cmd::operator==(const config_cmd& o) const
35 return ((m_rx_itf == o.m_rx_itf) && (m_tx_itf == o.m_tx_itf) &&
36 (m_addr == o.m_addr));
40 config_cmd::issue(connection& con)
42 msg_t req(con.ctx(), std::ref(*this));
44 auto& payload = req.get_request().get_payload();
47 payload.rx_sw_if_index = m_rx_itf.value();
48 payload.tx_sw_if_index = m_tx_itf.value();
50 to_bytes(m_addr, &payload.is_ip6, payload.nh);
52 VAPI_CALL(req.execute());
58 config_cmd::to_string() const
61 s << "IP-punt-redirect-config: " << 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.rx_sw_if_index = m_rx_itf.value();
95 payload.tx_sw_if_index = m_tx_itf.value();
97 to_bytes(m_addr, &payload.is_ip6, payload.nh);
99 VAPI_CALL(req.execute());
102 m_hw_item.set(rc_t::NOOP);
108 unconfig_cmd::to_string() const
110 std::ostringstream s;
111 s << "IP-punt-redirect-unconfig: " << m_hw_item.to_string()
112 << " rx-itf:" << m_rx_itf.to_string() << " tx-itf:" << m_tx_itf.to_string()
113 << " next-hop:" << m_addr.to_string();
118 }; // namespace ip_punt_redirect_cmds
122 * fd.io coding-style-patch-verification: ON
125 * eval: (c-set-style "mozilla")