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.hpp"
17 #include "vom/bond_group_binding.hpp"
18 #include "vom/bond_group_binding_cmds.hpp"
19 #include "vom/bond_interface_cmds.hpp"
23 * Construct a new object matching the desried state
25 bond_interface::bond_interface(const std::string& name,
29 : interface(name, type_t::BOND, state)
30 , m_l2_address(l2_address_t::ZERO)
36 bond_interface::bond_interface(const std::string& name,
38 const l2_address_t& l2_address,
41 : interface(name, type_t::BOND, state)
42 , m_l2_address(l2_address)
48 bond_interface::~bond_interface()
54 bond_interface::bond_interface(const bond_interface& o)
56 , m_l2_address(o.m_l2_address)
62 std::shared_ptr<bond_interface>
63 bond_interface::find(const handle_t& hdl)
65 return std::dynamic_pointer_cast<bond_interface>(interface::find(hdl));
69 bond_interface::set(bond_interface::mode_t mode)
75 bond_interface::set(bond_interface::lb_t lb)
81 bond_interface::to_string() const
85 s << this->interface::to_string() << " mode:" << m_mode.to_string()
86 << " lb:" << m_lb.to_string();
92 bond_interface::mk_create_cmd(std::queue<cmd*>& q)
94 q.push(new bond_interface_cmds::create_cmd(m_hdl, name(), m_mode, m_lb,
101 bond_interface::mk_delete_cmd(std::queue<cmd*>& q)
103 q.push(new bond_interface_cmds::delete_cmd(m_hdl));
108 std::shared_ptr<bond_interface>
109 bond_interface::singular() const
111 return std::dynamic_pointer_cast<bond_interface>(singular_i());
114 std::shared_ptr<interface>
115 bond_interface::singular_i() const
117 return m_db.find_or_add(name(), *this);
121 bond_interface::set(handle_t& handle)
123 this->interface::set(handle);
126 const bond_interface::mode_t bond_interface::mode_t::ROUND_ROBIN(1,
128 const bond_interface::mode_t bond_interface::mode_t::ACTIVE_BACKUP(
131 const bond_interface::mode_t bond_interface::mode_t::XOR(3, "xor");
132 const bond_interface::mode_t bond_interface::mode_t::BROADCAST(4, "broadcast");
133 const bond_interface::mode_t bond_interface::mode_t::LACP(5, "lacp");
134 const bond_interface::mode_t bond_interface::mode_t::UNSPECIFIED(0,
137 const bond_interface::mode_t
138 bond_interface::mode_t::from_numeric_val(uint8_t numeric)
141 return (bond_interface::mode_t::ROUND_ROBIN);
144 return (bond_interface::mode_t::ACTIVE_BACKUP);
147 return (bond_interface::mode_t::XOR);
150 return (bond_interface::mode_t::BROADCAST);
153 return (bond_interface::mode_t::LACP);
156 return (bond_interface::mode_t::UNSPECIFIED);
159 bond_interface::mode_t::mode_t(int v, const std::string& s)
160 : enum_base<bond_interface::mode_t>(v, s)
164 const bond_interface::lb_t bond_interface::lb_t::L2(0, "l2");
165 const bond_interface::lb_t bond_interface::lb_t::L34(1, "l34");
166 const bond_interface::lb_t bond_interface::lb_t::L23(2, "l23");
167 const bond_interface::lb_t bond_interface::lb_t::UNSPECIFIED(~0, "unspecified");
169 const bond_interface::lb_t
170 bond_interface::lb_t::from_numeric_val(uint8_t numeric)
173 return (bond_interface::lb_t::L2);
176 return (bond_interface::lb_t::L34);
179 return (bond_interface::lb_t::L23);
182 return (bond_interface::lb_t::UNSPECIFIED);
185 bond_interface::lb_t::lb_t(int v, const std::string& s)
186 : enum_base<bond_interface::lb_t>(v, s)
192 * fd.io coding-style-patch-verification: ON
195 * eval: (c-set-style "mozilla")