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 #ifndef __VOM_BOND_INTERFACE_H__
17 #define __VOM_BOND_INTERFACE_H__
19 #include "vom/interface.hpp"
23 * A bond-interface. e.g. a bond interface
25 class bond_interface : public interface
29 * A bond interface mode
31 struct mode_t : enum_base<mode_t>
34 * Round-Robin bond interface mode
36 const static mode_t ROUND_ROBIN;
38 * Active-backup bond interface mode
40 const static mode_t ACTIVE_BACKUP;
42 * XOR bond interface mode
44 const static mode_t XOR;
46 * Broadcast bond interface mode
48 const static mode_t BROADCAST;
50 * LACP bond interface mode
52 const static mode_t LACP;
54 * Unspecificed bond interface mode
56 const static mode_t UNSPECIFIED;
59 * Convert VPP's value of the bond to a mode
61 static const mode_t from_numeric_val(uint8_t v);
65 * Private constructor taking the value and the string name
67 mode_t(int v, const std::string& s);
71 * A bond interface load balance
73 struct lb_t : enum_base<lb_t>
76 * L2 bond interface lb
80 * L34 bond interface lb
82 const static lb_t L34;
84 * L23 bond interface lb
86 const static lb_t L23;
88 * Unspecificed bond interface lb
90 const static lb_t UNSPECIFIED;
93 * Convert VPP's value of the bond to a lb
95 static const lb_t from_numeric_val(uint8_t v);
99 * Private constructor taking the value and the string name
101 lb_t(int v, const std::string& s);
104 bond_interface(const std::string& name,
107 lb_t lb = lb_t::UNSPECIFIED);
109 bond_interface(const std::string& name,
111 const l2_address_t& l2_address,
113 lb_t lb = lb_t::UNSPECIFIED);
116 bond_interface(const bond_interface& o);
119 * The the singular instance of the bond interface in the DB by handle
121 static std::shared_ptr<bond_interface> find(const handle_t& hdl);
124 * Return the matching 'singular instance' of the BOND interface
126 std::shared_ptr<bond_interface> singular() const;
131 void set(mode_t mode);
141 virtual std::string to_string() const;
147 void set(handle_t& handle);
148 friend class interface_factory;
152 * l2 address on bond interface
154 l2_address_t m_l2_address;
157 * mode on bond interface
162 * lb mode on bond interface
167 * Return the matching 'instance' of the sub-interface
168 * over-ride from the base class
170 std::shared_ptr<interface> singular_i() const;
173 * Virtual functions to construct an interface create commands.
175 virtual std::queue<cmd*>& mk_create_cmd(std::queue<cmd*>& cmds);
178 * Virtual functions to construct an interface delete commands.
180 virtual std::queue<cmd*>& mk_delete_cmd(std::queue<cmd*>& cmds);
183 * It's the OM class that call singular()
190 * fd.io coding-style-patch-verification: ON
193 * eval: (c-set-style "mozilla")