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_member.hpp"
20 * Construct a new object matching the desried state
22 bond_member::bond_member(const interface& itf, mode_t mode, rate_t rate)
23 : m_itf(itf.singular())
29 bond_member::~bond_member()
33 bond_member::bond_member(const bond_member& o)
41 bond_member::to_vpp(vapi_payload_bond_enslave& bond_enslave) const
43 bond_enslave.sw_if_index = m_itf->handle().value();
44 bond_enslave.is_passive = (m_mode == mode_t::PASSIVE) ? 1 : 0;
45 bond_enslave.is_long_timeout = (m_rate == rate_t::SLOW) ? 1 : 0;
49 bond_member::to_string() const
53 s << m_itf->to_string() << " mode:" << m_mode.to_string()
54 << " rate:" << m_rate.to_string();
60 bond_member::operator<(const bond_member& itf) const
62 return (m_itf->handle() < itf.m_itf->handle());
66 bond_member::set(mode_t mode)
72 bond_member::set(rate_t rate)
78 bond_member::hdl(void) const
80 return m_itf->handle();
84 bond_member::operator==(const bond_member& b) const
86 return ((m_itf == b.m_itf) && (m_mode == b.m_mode) && (m_rate == b.m_rate));
89 const bond_member::mode_t bond_member::mode_t::ACTIVE(0, "active");
90 const bond_member::mode_t bond_member::mode_t::PASSIVE(1, "passive");
92 const bond_member::mode_t
93 bond_member::mode_t::from_numeric_val(uint8_t numeric)
96 return (bond_member::mode_t::ACTIVE);
98 return (bond_member::mode_t::PASSIVE);
101 bond_member::mode_t::mode_t(int v, const std::string& s)
102 : enum_base<bond_member::mode_t>(v, s)
106 const bond_member::rate_t bond_member::rate_t::FAST(0, "fast");
107 const bond_member::rate_t bond_member::rate_t::SLOW(1, "slow");
109 const bond_member::rate_t
110 bond_member::rate_t::from_numeric_val(uint8_t numeric)
113 return (bond_member::rate_t::FAST);
115 return (bond_member::rate_t::SLOW);
118 bond_member::rate_t::rate_t(int v, const std::string& s)
119 : enum_base<bond_member::rate_t>(v, s)
125 * fd.io coding-style-patch-verification: ON
128 * eval: (c-set-style "mozilla")