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.hpp"
18 DEFINE_VAPI_MSG_IDS_IP_API_JSON;
21 l3_binding::bind_cmd::bind_cmd(HW::item<bool>& item,
23 const route::prefix_t& pfx)
31 l3_binding::bind_cmd::operator==(const bind_cmd& other) const
33 return ((m_itf == other.m_itf) && (m_pfx == other.m_pfx));
37 l3_binding::bind_cmd::issue(connection& con)
39 msg_t req(con.ctx(), std::ref(*this));
41 auto& payload = req.get_request().get_payload();
42 payload.sw_if_index = m_itf.value();
46 m_pfx.to_vpp(&payload.is_ipv6, payload.address, &payload.address_length);
48 VAPI_CALL(req.execute());
50 m_hw_item.set(wait());
56 l3_binding::bind_cmd::to_string() const
59 s << "L3-bind: " << m_hw_item.to_string() << " itf:" << m_itf.to_string()
60 << " pfx:" << m_pfx.to_string();
65 l3_binding::unbind_cmd::unbind_cmd(HW::item<bool>& item,
67 const route::prefix_t& pfx)
75 l3_binding::unbind_cmd::operator==(const unbind_cmd& other) const
77 return ((m_itf == other.m_itf) && (m_pfx == other.m_pfx));
81 l3_binding::unbind_cmd::issue(connection& con)
83 msg_t req(con.ctx(), std::ref(*this));
85 auto& payload = req.get_request().get_payload();
86 payload.sw_if_index = m_itf.value();
90 m_pfx.to_vpp(&payload.is_ipv6, payload.address, &payload.address_length);
92 VAPI_CALL(req.execute());
95 m_hw_item.set(rc_t::NOOP);
101 l3_binding::unbind_cmd::to_string() const
103 std::ostringstream s;
104 s << "L3-unbind: " << m_hw_item.to_string() << " itf:" << m_itf.to_string()
105 << " pfx:" << m_pfx.to_string();
110 l3_binding::dump_v4_cmd::dump_v4_cmd(const handle_t& hdl)
115 l3_binding::dump_v4_cmd::dump_v4_cmd(const dump_v4_cmd& d)
121 l3_binding::dump_v4_cmd::operator==(const dump_v4_cmd& other) const
127 l3_binding::dump_v4_cmd::issue(connection& con)
129 m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
131 auto& payload = m_dump->get_request().get_payload();
132 payload.sw_if_index = m_itf.value();
135 VAPI_CALL(m_dump->execute());
143 l3_binding::dump_v4_cmd::to_string() const
145 return ("L3-binding-dump");
150 * fd.io coding-style-patch-verification: ON
153 * eval: (c-set-style "mozilla")