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/sub_interface_cmds.hpp"
17 #include "vom/cmd.hpp"
19 #include <vapi/vpe.api.vapi.hpp>
22 namespace sub_interface_cmds {
24 create_cmd::create_cmd(HW::item<handle_t>& item,
25 const std::string& name,
26 const handle_t& parent,
28 : interface::create_cmd<vapi::Create_vlan_subif>(item, name)
35 create_cmd::operator==(const create_cmd& other) const
37 return ((m_name == other.m_name) && (m_parent == other.m_parent) &&
38 (m_vlan == other.m_vlan));
42 create_cmd::issue(connection& con)
44 msg_t req(con.ctx(), std::ref(*this));
46 auto& payload = req.get_request().get_payload();
47 payload.sw_if_index = m_parent.value();
48 payload.vlan_id = m_vlan;
50 VAPI_CALL(req.execute());
54 if (m_hw_item.rc() == rc_t::OK) {
62 create_cmd::to_string() const
65 s << "sub-itf-create: " << m_hw_item.to_string() << " parent:" << m_parent
66 << " vlan:" << m_vlan;
70 delete_cmd::delete_cmd(HW::item<handle_t>& item)
71 : interface::delete_cmd<vapi::Delete_subif>(item)
76 delete_cmd::operator==(const delete_cmd& other) const
78 return (m_hw_item == other.m_hw_item);
82 delete_cmd::issue(connection& con)
84 msg_t req(con.ctx(), std::ref(*this));
86 auto& payload = req.get_request().get_payload();
87 payload.sw_if_index = m_hw_item.data().value();
89 VAPI_CALL(req.execute());
92 m_hw_item.set(rc_t::NOOP);
99 delete_cmd::to_string() const
101 std::ostringstream s;
103 s << "sub-itf-delete: " << m_hw_item.to_string();
107 } // namespace sub_interface_cmds
110 * fd.io coding-style-patch-verification: ON
113 * eval: (c-set-style "mozilla")