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.hpp"
17 #include "vom/cmd.hpp"
19 #include <vapi/vpe.api.vapi.hpp>
22 sub_interface::create_cmd::create_cmd(HW::item<handle_t>& item,
23 const std::string& name,
24 const handle_t& parent,
26 : interface::create_cmd<vapi::Create_vlan_subif>(item, name)
33 sub_interface::create_cmd::operator==(const create_cmd& other) const
35 return ((m_name == other.m_name) && (m_parent == other.m_parent) &&
36 (m_vlan == other.m_vlan));
40 sub_interface::create_cmd::issue(connection& con)
42 msg_t req(con.ctx(), std::ref(*this));
44 auto& payload = req.get_request().get_payload();
45 payload.sw_if_index = m_parent.value();
46 payload.vlan_id = m_vlan;
48 VAPI_CALL(req.execute());
52 if (m_hw_item.rc() == rc_t::OK) {
53 interface::add(m_name, m_hw_item);
60 sub_interface::create_cmd::to_string() const
63 s << "sub-itf-create: " << m_hw_item.to_string() << " parent:" << m_parent
64 << " vlan:" << m_vlan;
68 sub_interface::delete_cmd::delete_cmd(HW::item<handle_t>& item)
69 : interface::delete_cmd<vapi::Delete_subif>(item)
74 sub_interface::delete_cmd::operator==(const delete_cmd& other) const
76 return (m_hw_item == other.m_hw_item);
80 sub_interface::delete_cmd::issue(connection& con)
82 msg_t req(con.ctx(), std::ref(*this));
84 auto& payload = req.get_request().get_payload();
85 payload.sw_if_index = m_hw_item.data().value();
87 VAPI_CALL(req.execute());
90 m_hw_item.set(rc_t::NOOP);
92 interface::remove(m_hw_item);
97 sub_interface::delete_cmd::to_string() const
101 s << "sub-itf-delete: " << m_hw_item.to_string();
107 * fd.io coding-style-patch-verification: ON
110 * eval: (c-set-style "mozilla")