FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
bond_member.hpp
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 #ifndef __VOM_BOND_MEMBER_H__
17 #define __VOM_BOND_MEMBER_H__
18 
19 #include "vom/interface.hpp"
20 #include <vapi/bond.api.vapi.hpp>
21 
22 namespace VOM {
23 /**
24  * A bond-member. e.g. a bond_member interface
25  */
27 {
28 public:
29  /**
30  * A member interface mode
31  */
32  struct mode_t : enum_base<mode_t>
33  {
34  /**
35  * Active member interface mode
36  */
37  const static mode_t ACTIVE;
38  /**
39  * Passive member interface mode
40  */
41  const static mode_t PASSIVE;
42 
43  /**
44  * Convert VPP's value of the bond to a mode
45  */
46  static const mode_t from_numeric_val(uint8_t v);
47 
48  private:
49  /**
50  * Private constructor taking the value and the string name
51  */
52  mode_t(int v, const std::string& s);
53  };
54 
55  /**
56  * A member interface rate
57  */
58  struct rate_t : enum_base<rate_t>
59  {
60  /**
61  * Fast member interface rate
62  */
63  const static rate_t FAST;
64  /**
65  * SLOW member interface rate
66  */
67  const static rate_t SLOW;
68 
69  /**
70  * Convert VPP's value of the bond to a mode
71  */
72  static const rate_t from_numeric_val(uint8_t v);
73 
74  private:
75  /**
76  * Private constructor taking the value and the string name
77  */
78  rate_t(int v, const std::string& s);
79  };
80 
81  bond_member(const interface& itf, mode_t mode, rate_t rate);
82 
83  ~bond_member();
84  bond_member(const bond_member& o);
85 
86  /**
87  * convert to VPP
88  */
89  void to_vpp(vapi_payload_bond_enslave& bond_enslave) const;
90 
91  /**
92  * set the mode
93  */
94  void set(mode_t mode);
95 
96  /**
97  * set the rate
98  */
99  void set(rate_t rate);
100 
101  /**
102  * convert to string
103  */
104  std::string to_string(void) const;
105 
106  /**
107  * less-than operator
108  */
109  bool operator<(const bond_member& mem_itf) const;
110 
111  /**
112  * Get the interface handle
113  */
114  const handle_t hdl(void) const;
115 
116  /**
117  * equality operator
118  */
119  bool operator==(const bond_member& i) const;
120 
121 private:
122  /**
123  * Refernece conter lock on the parent
124  */
125  const std::shared_ptr<interface> m_itf;
126 
127  /**
128  * passive vs active member
129  */
130  mode_t m_mode;
131 
132  /**
133  * slow 90sec. vs. fast 3sec timeout
134  */
135  rate_t m_rate;
136 };
137 }
138 
139 /*
140  * fd.io coding-style-patch-verification: OFF
141  *
142  * Local Variables:
143  * eval: (c-set-style "mozilla")
144  * End:
145  */
146 
147 #endif
VOM
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
VOM::bond_member::to_vpp
void to_vpp(vapi_payload_bond_enslave &bond_enslave) const
convert to VPP
Definition: bond_member.cpp:41
VOM::bond_member::to_string
std::string to_string(void) const
convert to string
Definition: bond_member.cpp:49
VOM::bond_member::mode_t::PASSIVE
const static mode_t PASSIVE
Passive member interface mode.
Definition: bond_member.hpp:41
VOM::bond_member::rate_t::from_numeric_val
static const rate_t from_numeric_val(uint8_t v)
Convert VPP's value of the bond to a mode.
Definition: bond_member.cpp:110
mode
vl_api_tunnel_mode_t mode
Definition: gre.api:48
VOM::bond_member::operator==
bool operator==(const bond_member &i) const
equality operator
Definition: bond_member.cpp:84
VOM::bond_member::rate_t::SLOW
const static rate_t SLOW
SLOW member interface rate.
Definition: bond_member.hpp:67
VOM::bond_member::set
void set(mode_t mode)
set the mode
Definition: bond_member.cpp:66
VOM::bond_member::operator<
bool operator<(const bond_member &mem_itf) const
less-than operator
Definition: bond_member.cpp:60
VOM::bond_member::bond_member
bond_member(const interface &itf, mode_t mode, rate_t rate)
Construct a new object matching the desried state.
Definition: bond_member.cpp:22
VOM::enum_base
A template base class for all enum types.
Definition: enum_base.hpp:30
VOM::interface
A representation of an interface in VPP.
Definition: interface.hpp:41
VOM::handle_t
A type declaration of an interface handle in VPP.
Definition: types.hpp:233
VOM::bond_member::mode_t::ACTIVE
const static mode_t ACTIVE
Active member interface mode.
Definition: bond_member.hpp:37
VOM::bond_member::rate_t
A member interface rate.
Definition: bond_member.hpp:58
VOM::bond_member::~bond_member
~bond_member()
Definition: bond_member.cpp:29
VOM::bond_member::mode_t::from_numeric_val
static const mode_t from_numeric_val(uint8_t v)
Convert VPP's value of the bond to a mode.
Definition: bond_member.cpp:93
interface.hpp
VOM::bond_member
A bond-member.
Definition: bond_member.hpp:26
i
int i
Definition: flowhash_template.h:376
VOM::bond_member::rate_t::FAST
const static rate_t FAST
Fast member interface rate.
Definition: bond_member.hpp:63
string
const char *const string
Definition: cJSON.h:172
VOM::bond_member::mode_t
A member interface mode.
Definition: bond_member.hpp:32
VOM::bond_member::hdl
const handle_t hdl(void) const
Get the interface handle.
Definition: bond_member.cpp:78