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_cmds.hpp"
19 namespace l2_binding_cmds {
20 bind_cmd::bind_cmd(HW::item<bool>& item,
32 bind_cmd::operator==(const bind_cmd& other) const
34 return ((m_itf == other.m_itf) && (m_bd == other.m_bd) &&
35 (m_is_bvi == other.m_is_bvi));
39 bind_cmd::issue(connection& con)
41 msg_t req(con.ctx(), std::ref(*this));
43 auto& payload = req.get_request().get_payload();
44 payload.rx_sw_if_index = m_itf.value();
47 payload.bvi = m_is_bvi;
50 VAPI_CALL(req.execute());
52 m_hw_item.set(wait());
58 bind_cmd::to_string() const
61 s << "L2-bind: " << m_hw_item.to_string() << " itf:" << m_itf.to_string()
67 unbind_cmd::unbind_cmd(HW::item<bool>& item,
79 unbind_cmd::operator==(const unbind_cmd& other) const
81 return ((m_itf == other.m_itf) && (m_bd == other.m_bd) &&
82 (m_is_bvi == other.m_is_bvi));
86 unbind_cmd::issue(connection& con)
88 msg_t req(con.ctx(), std::ref(*this));
90 auto& payload = req.get_request().get_payload();
91 payload.rx_sw_if_index = m_itf.value();
94 payload.bvi = m_is_bvi;
97 VAPI_CALL(req.execute());
100 m_hw_item.set(rc_t::NOOP);
106 unbind_cmd::to_string() const
108 std::ostringstream s;
109 s << "L2-unbind: " << m_hw_item.to_string() << " itf:" << m_itf.to_string()
115 set_vtr_op_cmd::set_vtr_op_cmd(HW::item<l2_binding::l2_vtr_op_t>& item,
125 set_vtr_op_cmd::operator==(const set_vtr_op_cmd& other) const
128 (m_hw_item.data() == other.m_hw_item.data() && m_itf == other.m_itf) &&
129 (m_tag == other.m_tag));
133 set_vtr_op_cmd::issue(connection& con)
135 msg_t req(con.ctx(), std::ref(*this));
137 auto& payload = req.get_request().get_payload();
138 payload.sw_if_index = m_itf.value();
139 payload.vtr_op = m_hw_item.data().value();
140 payload.push_dot1q = 1;
141 payload.tag1 = m_tag;
143 VAPI_CALL(req.execute());
151 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;
160 }; // namespace l2_binding_cmds
164 * fd.io coding-style-patch-verification: ON
167 * eval: (c-set-style "mozilla")