2 * Copyright (c) 2018 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/bond_interface_cmds.hpp"
18 DEFINE_VAPI_MSG_IDS_BOND_API_JSON;
21 namespace bond_interface_cmds {
22 create_cmd::create_cmd(HW::item<handle_t>& item,
23 const std::string& name,
24 const bond_interface::mode_t& mode,
25 const bond_interface::lb_t& lb,
26 const l2_address_t& l2_address)
27 : interface::create_cmd<vapi::Bond_create>(item, name)
30 , m_l2_address(l2_address)
35 create_cmd::issue(connection& con)
37 msg_t req(con.ctx(), std::ref(*this));
39 auto& payload = req.get_request().get_payload();
41 if (m_l2_address != l2_address_t::ZERO) {
42 m_l2_address.to_bytes(payload.mac_address, 6);
43 payload.use_custom_mac = 1;
46 payload.mode = m_mode.value();
47 if ((m_mode == bond_interface::mode_t::XOR ||
48 m_mode == bond_interface::mode_t::LACP) &&
49 m_lb != bond_interface::lb_t::UNSPECIFIED)
50 payload.lb = m_lb.value();
52 VAPI_CALL(req.execute());
55 if (m_hw_item.rc() == rc_t::OK) {
63 create_cmd::to_string() const
66 s << "bond-intf-create: " << m_hw_item.to_string();
71 delete_cmd::delete_cmd(HW::item<handle_t>& item)
72 : interface::delete_cmd<vapi::Bond_delete>(item)
77 delete_cmd::issue(connection& con)
79 msg_t req(con.ctx(), std::ref(*this));
81 auto& payload = req.get_request().get_payload();
82 payload.sw_if_index = m_hw_item.data().value();
84 VAPI_CALL(req.execute());
87 m_hw_item.set(rc_t::NOOP);
94 delete_cmd::to_string() const
97 s << "bond-itf-delete: " << m_hw_item.to_string();
107 dump_cmd::operator==(const dump_cmd& other) const
113 dump_cmd::issue(connection& con)
115 m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
117 VAPI_CALL(m_dump->execute());
125 dump_cmd::to_string() const
127 return ("bond-itf-dump");
129 } // namespace bond_interface_cmds
133 * fd.io coding-style-patch-verification: ON
136 * eval: (c-set-style "mozilla")