FD.io VPP  v18.04-17-g3a0d853
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: ON
141  *
142  * Local Variables:
143  * eval: (c-set-style "mozilla")
144  * End:
145  */
146 
147 #endif
A member interface mode.
Definition: bond_member.hpp:32
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
int i
A bond-member.
Definition: bond_member.hpp:26
void bond_enslave(vlib_main_t *vm, bond_enslave_args_t *args)
Definition: cli.c:403
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
#define v
Definition: acl.c:495
static const mode_t ACTIVE
Active member interface mode.
Definition: bond_member.hpp:37
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
bool operator==(const enum_base &e) const
Comparison operator.
Definition: enum_base.hpp:41
A representation of an interface in VPP.
Definition: interface.hpp:41
void to_vpp(vapi_payload_bond_enslave &bond_enslave) const
convert to VPP
Definition: bond_member.cpp:41
A type declaration of an interface handle in VPP.
Definition: types.hpp:236
A member interface rate.
Definition: bond_member.hpp:58
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
const std::string & to_string() const
convert to string format for debug purposes
Definition: enum_base.hpp:36
const handle_t hdl(void) const
Get the interface handle.
Definition: bond_member.cpp:78