FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
bond_interface.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_INTERFACE_H__
17 #define __VOM_BOND_INTERFACE_H__
18 
19 #include "vom/interface.hpp"
20 
21 namespace VOM {
22 /**
23  * A bond-interface. e.g. a bond interface
24  */
25 class bond_interface : public interface
26 {
27 public:
28  /**
29  * A bond interface mode
30  */
31  struct mode_t : enum_base<mode_t>
32  {
33  /**
34  * Round-Robin bond interface mode
35  */
36  const static mode_t ROUND_ROBIN;
37  /**
38  * Active-backup bond interface mode
39  */
40  const static mode_t ACTIVE_BACKUP;
41  /**
42  * XOR bond interface mode
43  */
44  const static mode_t XOR;
45  /**
46  * Broadcast bond interface mode
47  */
48  const static mode_t BROADCAST;
49  /**
50  * LACP bond interface mode
51  */
52  const static mode_t LACP;
53  /**
54  * Unspecified bond interface mode
55  */
56  const static mode_t UNSPECIFIED;
57 
58  /**
59  * Convert VPP's value of the bond to a mode
60  */
61  static const mode_t from_numeric_val(uint8_t v);
62 
63  private:
64  /**
65  * Private constructor taking the value and the string name
66  */
67  mode_t(int v, const std::string& s);
68  };
69 
70  /**
71  * A bond interface load balance
72  */
73  struct lb_t : enum_base<lb_t>
74  {
75  /**
76  * L2 bond interface lb
77  */
78  const static lb_t L2;
79  /**
80  * L34 bond interface lb
81  */
82  const static lb_t L34;
83  /**
84  * L23 bond interface lb
85  */
86  const static lb_t L23;
87  /**
88  * Unspecified bond interface lb
89  */
90  const static lb_t UNSPECIFIED;
91 
92  /**
93  * Convert VPP's value of the bond to a lb
94  */
95  static const lb_t from_numeric_val(uint8_t v);
96 
97  private:
98  /**
99  * Private constructor taking the value and the string name
100  */
101  lb_t(int v, const std::string& s);
102  };
103 
106  mode_t mode,
107  lb_t lb = lb_t::UNSPECIFIED);
108 
111  const l2_address_t& l2_address,
112  mode_t mode,
113  lb_t lb = lb_t::UNSPECIFIED);
114 
115  ~bond_interface();
116  bond_interface(const bond_interface& o);
117 
118  /**
119  * The the singular instance of the bond interface in the DB by handle
120  */
121  static std::shared_ptr<bond_interface> find(const handle_t& hdl);
122 
123  /**
124  * Return the matching 'singular instance' of the BOND interface
125  */
126  std::shared_ptr<bond_interface> singular() const;
127 
128  /**
129  * set the mode
130  */
131  void set(mode_t mode);
132 
133  /**
134  * set the lb
135  */
136  void set(lb_t lb);
137 
138  /**
139  * convert to string
140  */
141  virtual std::string to_string() const;
142 
143 protected:
144  /**
145  * set the handle
146  */
147  void set(handle_t& handle);
148  friend class interface_factory;
149 
150 private:
151  /**
152  * l2 address on bond interface
153  */
154  l2_address_t m_l2_address;
155 
156  /**
157  * mode on bond interface
158  */
159  mode_t m_mode;
160 
161  /**
162  * lb mode on bond interface
163  */
164  lb_t m_lb;
165 
166  /**
167  * Return the matching 'instance' of the sub-interface
168  * over-ride from the base class
169  */
170  std::shared_ptr<interface> singular_i() const;
171 
172  /**
173  * Virtual functions to construct an interface create commands.
174  */
175  virtual std::queue<cmd*>& mk_create_cmd(std::queue<cmd*>& cmds);
176 
177  /**
178  * Virtual functions to construct an interface delete commands.
179  */
180  virtual std::queue<cmd*>& mk_delete_cmd(std::queue<cmd*>& cmds);
181 
182  /*
183  * It's the OM class that call singular()
184  */
185  friend class OM;
186 };
187 }
188 
189 /*
190  * fd.io coding-style-patch-verification: OFF
191  *
192  * Local Variables:
193  * eval: (c-set-style "mozilla")
194  * End:
195  */
196 
197 #endif
VOM::interface::l2_address
const l2_address_t & l2_address() const
Return the L2 Address.
Definition: interface.cpp:158
VOM::bond_interface
A bond-interface.
Definition: bond_interface.hpp:25
VOM::bond_interface::lb_t::L23
const static lb_t L23
L23 bond interface lb.
Definition: bond_interface.hpp:86
VOM::bond_interface::mode_t::BROADCAST
const static mode_t BROADCAST
Broadcast bond interface mode.
Definition: bond_interface.hpp:48
VOM
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
VOM::bond_interface::to_string
virtual std::string to_string() const
convert to string
Definition: bond_interface.cpp:81
VOM::OM
The interface to writing objects into VPP OM.
Definition: om.hpp:140
VOM::bond_interface::set
void set(mode_t mode)
set the mode
Definition: bond_interface.cpp:69
mode
vl_api_tunnel_mode_t mode
Definition: gre.api:48
VOM::bond_interface::mode_t::LACP
const static mode_t LACP
LACP bond interface mode.
Definition: bond_interface.hpp:52
state
vl_api_dhcp_client_state_t state
Definition: dhcp.api:201
VOM::bond_interface::lb_t
A bond interface load balance.
Definition: bond_interface.hpp:73
VOM::interface::name
const std::string & name() const
Return the interface type.
Definition: interface.cpp:271
VOM::bond_interface::lb_t::L34
const static lb_t L34
L34 bond interface lb.
Definition: bond_interface.hpp:82
VOM::bond_interface::lb_t::from_numeric_val
static const lb_t from_numeric_val(uint8_t v)
Convert VPP's value of the bond to a lb.
Definition: bond_interface.cpp:170
VOM::bond_interface::~bond_interface
~bond_interface()
Definition: bond_interface.cpp:48
VOM::interface_factory
Definition: interface_factory.hpp:36
VOM::bond_interface::lb_t::UNSPECIFIED
const static lb_t UNSPECIFIED
Unspecified bond interface lb.
Definition: bond_interface.hpp:90
VOM::bond_interface::mode_t::XOR
const static mode_t XOR
XOR bond interface mode.
Definition: bond_interface.hpp:44
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_interface::mode_t::ACTIVE_BACKUP
const static mode_t ACTIVE_BACKUP
Active-backup bond interface mode.
Definition: bond_interface.hpp:40
VOM::interface::handle
const handle_t & handle() const
Return VPP's handle to this object.
Definition: interface.cpp:146
VOM::bond_interface::lb_t::L2
const static lb_t L2
L2 bond interface lb.
Definition: bond_interface.hpp:78
VOM::l2_address_t
Type def of a L2 address as read from VPP.
Definition: types.hpp:339
VOM::bond_interface::mode_t
A bond interface mode.
Definition: bond_interface.hpp:31
VOM::interface::admin_state_t
The admin state of the interface.
Definition: interface.hpp:138
interface.hpp
VOM::bond_interface::mode_t::UNSPECIFIED
const static mode_t UNSPECIFIED
Unspecified bond interface mode.
Definition: bond_interface.hpp:56
VOM::bond_interface::mode_t::ROUND_ROBIN
const static mode_t ROUND_ROBIN
Round-Robin bond interface mode.
Definition: bond_interface.hpp:36
VOM::bond_interface::find
static std::shared_ptr< bond_interface > find(const handle_t &hdl)
The the singular instance of the bond interface in the DB by handle.
Definition: bond_interface.cpp:63
VOM::bond_interface::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_interface.cpp:138
VOM::bond_interface::singular
std::shared_ptr< bond_interface > singular() const
Return the matching 'singular instance' of the BOND interface.
Definition: bond_interface.cpp:109
VOM::bond_interface::bond_interface
bond_interface(const std::string &name, admin_state_t state, mode_t mode, lb_t lb=lb_t::UNSPECIFIED)
Construct a new object matching the desried state.
Definition: bond_interface.cpp:25
string
const char *const string
Definition: cJSON.h:172