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/l2_binding.hpp"
19 l2_binding::bind_cmd::bind_cmd(HW::item<bool>& item,
31 l2_binding::bind_cmd::operator==(const bind_cmd& other) const
33 return ((m_itf == other.m_itf) && (m_bd == other.m_bd) &&
34 (m_is_bvi == other.m_is_bvi));
38 l2_binding::bind_cmd::issue(connection& con)
40 msg_t req(con.ctx(), std::ref(*this));
42 auto& payload = req.get_request().get_payload();
43 payload.rx_sw_if_index = m_itf.value();
46 payload.bvi = m_is_bvi;
49 VAPI_CALL(req.execute());
51 m_hw_item.set(wait());
57 l2_binding::bind_cmd::to_string() const
60 s << "L2-bind: " << m_hw_item.to_string() << " itf:" << m_itf.to_string()
66 l2_binding::unbind_cmd::unbind_cmd(HW::item<bool>& item,
78 l2_binding::unbind_cmd::operator==(const unbind_cmd& other) const
80 return ((m_itf == other.m_itf) && (m_bd == other.m_bd) &&
81 (m_is_bvi == other.m_is_bvi));
85 l2_binding::unbind_cmd::issue(connection& con)
87 msg_t req(con.ctx(), std::ref(*this));
89 auto& payload = req.get_request().get_payload();
90 payload.rx_sw_if_index = m_itf.value();
93 payload.bvi = m_is_bvi;
96 VAPI_CALL(req.execute());
99 m_hw_item.set(rc_t::NOOP);
105 l2_binding::unbind_cmd::to_string() const
107 std::ostringstream s;
108 s << "L2-unbind: " << m_hw_item.to_string() << " itf:" << m_itf.to_string()
114 l2_binding::set_vtr_op_cmd::set_vtr_op_cmd(HW::item<l2_vtr_op_t>& item,
124 l2_binding::set_vtr_op_cmd::operator==(const set_vtr_op_cmd& other) const
127 (m_hw_item.data() == other.m_hw_item.data() && m_itf == other.m_itf) &&
128 (m_tag == other.m_tag));
132 l2_binding::set_vtr_op_cmd::issue(connection& con)
134 msg_t req(con.ctx(), std::ref(*this));
136 auto& payload = req.get_request().get_payload();
137 payload.sw_if_index = m_itf.value();
138 payload.vtr_op = m_hw_item.data().value();
139 payload.push_dot1q = 1;
140 payload.tag1 = m_tag;
142 VAPI_CALL(req.execute());
145 m_hw_item.set(rc_t::NOOP);
151 l2_binding::set_vtr_op_cmd::to_string() const
153 std::ostringstream s;
154 s << "L2-set-vtr-op: " << m_hw_item.to_string()
155 << " itf:" << m_itf.to_string() << " tag:" << m_tag;
162 * fd.io coding-style-patch-verification: ON
165 * eval: (c-set-style "mozilla")