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.
16 #include "vom/l3_binding_cmds.hpp"
18 DEFINE_VAPI_MSG_IDS_IP_API_JSON;
21 namespace l3_binding_cmds {
22 bind_cmd::bind_cmd(HW::item<bool>& item,
24 const route::prefix_t& pfx)
32 bind_cmd::operator==(const bind_cmd& other) const
34 return ((m_itf == other.m_itf) && (m_pfx == other.m_pfx));
38 bind_cmd::issue(connection& con)
40 msg_t req(con.ctx(), std::ref(*this));
42 auto& payload = req.get_request().get_payload();
43 payload.sw_if_index = m_itf.value();
47 m_pfx.to_vpp(&payload.is_ipv6, payload.address, &payload.address_length);
49 VAPI_CALL(req.execute());
55 bind_cmd::to_string() const
58 s << "L3-bind: " << m_hw_item.to_string() << " itf:" << m_itf.to_string()
59 << " pfx:" << m_pfx.to_string();
64 unbind_cmd::unbind_cmd(HW::item<bool>& item,
66 const route::prefix_t& pfx)
74 unbind_cmd::operator==(const unbind_cmd& other) const
76 return ((m_itf == other.m_itf) && (m_pfx == other.m_pfx));
80 unbind_cmd::issue(connection& con)
82 msg_t req(con.ctx(), std::ref(*this));
84 auto& payload = req.get_request().get_payload();
85 payload.sw_if_index = m_itf.value();
89 m_pfx.to_vpp(&payload.is_ipv6, payload.address, &payload.address_length);
91 VAPI_CALL(req.execute());
94 m_hw_item.set(rc_t::NOOP);
100 unbind_cmd::to_string() const
102 std::ostringstream s;
103 s << "L3-unbind: " << m_hw_item.to_string() << " itf:" << m_itf.to_string()
104 << " pfx:" << m_pfx.to_string();
109 dump_v4_cmd::dump_v4_cmd(const handle_t& hdl)
114 dump_v4_cmd::dump_v4_cmd(const dump_v4_cmd& d)
120 dump_v4_cmd::operator==(const dump_v4_cmd& other) const
126 dump_v4_cmd::issue(connection& con)
128 m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
130 auto& payload = m_dump->get_request().get_payload();
131 payload.sw_if_index = m_itf.value();
134 VAPI_CALL(m_dump->execute());
142 dump_v4_cmd::to_string() const
144 return ("L3-binding-dump");
147 }; // namespace l3_binding_cmds
151 * fd.io coding-style-patch-verification: ON
154 * eval: (c-set-style "mozilla")