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,
23 const l2_binding::l2_port_type_t& port_type)
27 , m_port_type(port_type)
32 bind_cmd::operator==(const bind_cmd& other) const
34 return ((m_itf == other.m_itf) && (m_bd == other.m_bd) &&
35 (m_port_type == other.m_port_type));
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 if (m_port_type == l2_binding::l2_port_type_t::L2_PORT_TYPE_BVI)
48 payload.port_type = L2_API_PORT_TYPE_BVI;
49 else if (m_port_type == l2_binding::l2_port_type_t::L2_PORT_TYPE_UU_FWD)
50 payload.port_type = L2_API_PORT_TYPE_UU_FWD;
52 payload.port_type = L2_API_PORT_TYPE_NORMAL;
56 VAPI_CALL(req.execute());
62 bind_cmd::to_string() const
65 s << "L2-bind: " << m_hw_item.to_string() << " itf:" << m_itf.to_string()
66 << " bd:" << m_bd << " port-type:" << m_port_type.to_string();
71 unbind_cmd::unbind_cmd(HW::item<bool>& item,
74 const l2_binding::l2_port_type_t& port_type)
78 , m_port_type(port_type)
83 unbind_cmd::operator==(const unbind_cmd& other) const
85 return ((m_itf == other.m_itf) && (m_bd == other.m_bd) &&
86 (m_port_type == other.m_port_type));
90 unbind_cmd::issue(connection& con)
92 msg_t req(con.ctx(), std::ref(*this));
94 auto& payload = req.get_request().get_payload();
95 payload.rx_sw_if_index = m_itf.value();
98 if (m_port_type == l2_binding::l2_port_type_t::L2_PORT_TYPE_BVI)
99 payload.port_type = L2_API_PORT_TYPE_BVI;
100 else if (m_port_type == l2_binding::l2_port_type_t::L2_PORT_TYPE_UU_FWD)
101 payload.port_type = L2_API_PORT_TYPE_UU_FWD;
103 payload.port_type = L2_API_PORT_TYPE_NORMAL;
107 VAPI_CALL(req.execute());
110 m_hw_item.set(rc_t::NOOP);
116 unbind_cmd::to_string() const
118 std::ostringstream s;
119 s << "L2-unbind: " << m_hw_item.to_string() << " itf:" << m_itf.to_string()
120 << " bd:" << m_bd << " port-type:" << m_port_type;
124 }; // namespace l2_binding_cmds
128 * fd.io coding-style-patch-verification: ON
131 * eval: (c-set-style "mozilla")