FD.io VPP  v19.08.3-2-gbabecb413
Vector Packet Processing
bond_member.cpp
Go to the documentation of this file.
1 /*
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:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
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.
14  */
15 
16 #include "vom/bond_member.hpp"
17 
18 namespace VOM {
19 /**
20  * Construct a new object matching the desried state
21  */
23  : m_itf(itf.singular())
24  , m_mode(mode)
25  , m_rate(rate)
26 {
27 }
28 
30 {
31 }
32 
34  : m_itf(o.m_itf)
35  , m_mode(o.m_mode)
36  , m_rate(o.m_rate)
37 {
38 }
39 
40 void
41 bond_member::to_vpp(vapi_payload_bond_enslave& bond_enslave) const
42 {
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;
46 }
47 
48 std::string
50 {
51  std::ostringstream s;
52 
53  s << m_itf->to_string() << " mode:" << m_mode.to_string()
54  << " rate:" << m_rate.to_string();
55 
56  return (s.str());
57 }
58 
59 bool
61 {
62  return (m_itf->handle() < itf.m_itf->handle());
63 }
64 
65 void
67 {
68  m_mode = mode;
69 }
70 
71 void
73 {
74  m_rate = rate;
75 }
76 
77 const handle_t
78 bond_member::hdl(void) const
79 {
80  return m_itf->handle();
81 }
82 
83 bool
85 {
86  return ((m_itf == b.m_itf) && (m_mode == b.m_mode) && (m_rate == b.m_rate));
87 }
88 
91 
94 {
95  if (0 == numeric)
96  return (bond_member::mode_t::ACTIVE);
97 
98  return (bond_member::mode_t::PASSIVE);
99 }
100 
101 bond_member::mode_t::mode_t(int v, const std::string& s)
103 {
104 }
105 
108 
111 {
112  if (0 == numeric)
113  return (bond_member::rate_t::FAST);
114 
115  return (bond_member::rate_t::SLOW);
116 }
117 
118 bond_member::rate_t::rate_t(int v, const std::string& s)
120 {
121 }
122 }; // namespace VOM
123 
124 /*
125  * fd.io coding-style-patch-verification: ON
126  *
127  * Local Variables:
128  * eval: (c-set-style "mozilla")
129  * End:
130  */
A member interface mode.
Definition: bond_member.hpp:32
bool operator==(const bond_member &i) const
equality operator
Definition: bond_member.cpp:84
static const rate_t SLOW
SLOW member interface rate.
Definition: bond_member.hpp:67
bond_member(const interface &itf, mode_t mode, rate_t rate)
Construct a new object matching the desried state.
Definition: bond_member.cpp:22
A template base class for all enum types.
Definition: enum_base.hpp:30
void to_vpp(vapi_payload_bond_enslave &bond_enslave) const
convert to VPP
Definition: bond_member.cpp:41
A bond-member.
Definition: bond_member.hpp:26
void bond_enslave(vlib_main_t *vm, bond_enslave_args_t *args)
Definition: cli.c:561
bool operator<(const bond_member &mem_itf) const
less-than operator
Definition: bond_member.cpp:60
static const rate_t FAST
Fast member interface rate.
Definition: bond_member.hpp:63
static const mode_t ACTIVE
Active member interface mode.
Definition: bond_member.hpp:37
std::string to_string(void) const
convert to string
Definition: bond_member.cpp:49
static const mode_t PASSIVE
Passive member interface mode.
Definition: bond_member.hpp:41
static const mode_t from_numeric_val(uint8_t v)
Convert VPP&#39;s value of the bond to a mode.
Definition: bond_member.cpp:93
static const rate_t from_numeric_val(uint8_t v)
Convert VPP&#39;s value of the bond to a mode.
A representation of an interface in VPP.
Definition: interface.hpp:41
A type declaration of an interface handle in VPP.
Definition: types.hpp:233
const std::string & to_string() const
convert to string format for debug purposes
Definition: enum_base.hpp:36
vl_api_vxlan_gbp_api_tunnel_mode_t mode
Definition: vxlan_gbp.api:44
const handle_t hdl(void) const
Get the interface handle.
Definition: bond_member.cpp:78
void set(mode_t mode)
set the mode
Definition: bond_member.cpp:66
A member interface rate.
Definition: bond_member.hpp:58
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19