FD.io VPP  v19.01.3-6-g70449b9b9
Vector Packet Processing
gbp_endpoint_group.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 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_GBP_ENDPOINT_GROUP_H__
17 #define __VOM_GBP_ENDPOINT_GROUP_H__
18 
19 #include "vom/interface.hpp"
20 #include "vom/singular_db.hpp"
21 #include "vom/types.hpp"
22 
24 #include "vom/gbp_route_domain.hpp"
25 
26 namespace VOM {
27 
28 /**
29  * EPG IDs are 32 bit integers
30  */
31 typedef uint32_t epg_id_t;
32 
33 /**
34  * A entry in the ARP termination table of a Bridge Domain
35  */
37 {
38 public:
39  /**
40  * The key for a GBP endpoint group is its ID
41  */
42  typedef epg_id_t key_t;
43 
44  /**
45  * Construct a GBP endpoint_group
46  */
47  gbp_endpoint_group(epg_id_t epg_id,
48  const interface& itf,
49  const gbp_route_domain& rd,
50  const gbp_bridge_domain& bd);
51  gbp_endpoint_group(epg_id_t epg_id,
52  const gbp_route_domain& rd,
53  const gbp_bridge_domain& bd);
54 
55  /**
56  * Copy Construct
57  */
59 
60  /**
61  * Destructor
62  */
64 
65  /**
66  * Return the object's key
67  */
68  const key_t key() const;
69 
70  /**
71  * comparison operator
72  */
73  bool operator==(const gbp_endpoint_group& bdae) const;
74 
75  /**
76  * Return the matching 'singular instance'
77  */
78  std::shared_ptr<gbp_endpoint_group> singular() const;
79 
80  /**
81  * Find the instnace of the bridge_domain domain in the OM
82  */
83  static std::shared_ptr<gbp_endpoint_group> find(const key_t& k);
84 
85  /**
86  * Dump all bridge_domain-doamin into the stream provided
87  */
88  static void dump(std::ostream& os);
89 
90  /**
91  * replay the object to create it in hardware
92  */
93  void replay(void);
94 
95  /**
96  * Convert to string for debugging
97  */
98  std::string to_string() const;
99 
100  /**
101  * Get the ID of the EPG
102  */
103  epg_id_t id() const;
104 
105  const std::shared_ptr<gbp_route_domain> get_route_domain();
106  const std::shared_ptr<gbp_bridge_domain> get_bridge_domain();
107 
108 private:
109  /**
110  * Class definition for listeners to OM events
111  */
113  {
114  public:
115  event_handler();
116  virtual ~event_handler() = default;
117 
118  /**
119  * Handle a populate event
120  */
121  void handle_populate(const client_db::key_t& key);
122 
123  /**
124  * Handle a replay event
125  */
126  void handle_replay();
127 
128  /**
129  * Show the object in the Singular DB
130  */
131  void show(std::ostream& os);
132 
133  /**
134  * Get the sortable Id of the listener
135  */
136  dependency_t order() const;
137  };
138 
139  /**
140  * event_handler to register with OM
141  */
142  static event_handler m_evh;
143 
144  /**
145  * Commit the acculmulated changes into VPP. i.e. to a 'HW" write.
146  */
147  void update(const gbp_endpoint_group& obj);
148 
149  /**
150  * Find or add the instnace of the bridge_domain domain in the OM
151  */
152  static std::shared_ptr<gbp_endpoint_group> find_or_add(
153  const gbp_endpoint_group& temp);
154 
155  /*
156  * It's the VPPHW class that updates the objects in HW
157  */
158  friend class OM;
159 
160  /**
161  * It's the singular_db class that calls replay()
162  */
163  friend class singular_db<key_t, gbp_endpoint_group>;
164 
165  /**
166  * Sweep/reap the object if still stale
167  */
168  void sweep(void);
169 
170  /**
171  * HW configuration for the result of creating the endpoint_group
172  */
173  HW::item<bool> m_hw;
174 
175  /**
176  * The EPG ID
177  */
178  epg_id_t m_epg_id;
179 
180  /**
181  * The uplink interface for the endpoint group
182  */
183  std::shared_ptr<interface> m_itf;
184 
185  /**
186  * The route-domain the EPG uses
187  */
188  std::shared_ptr<gbp_route_domain> m_rd;
189 
190  /**
191  * The bridge-domain the EPG uses
192  */
193  std::shared_ptr<gbp_bridge_domain> m_bd;
194 
195  /**
196  * A map of all bridge_domains
197  */
199 };
200 
201 }; // namespace
202 
203 /*
204  * fd.io coding-style-patch-verification: ON
205  *
206  * Local Variables:
207  * eval: (c-set-style "mozilla")
208  * End:
209  */
210 
211 #endif
const key_t key() const
Return the object&#39;s key.
const std::shared_ptr< gbp_bridge_domain > get_bridge_domain()
const std::string key_t
In the opflex world each entity is known by a URI which can be converted into a string.
Definition: client_db.hpp:51
uint32_t epg_id_t
EPG IDs are 32 bit integers.
const std::shared_ptr< gbp_route_domain > get_route_domain()
A entry in the ARP termination table of a Bridge Domain.
u16 epg_id
Definition: gbp.api:116
gbp_endpoint_group(epg_id_t epg_id, const interface &itf, const gbp_route_domain &rd, const gbp_bridge_domain &bd)
Construct a GBP endpoint_group.
A Database to store the unique &#39;singular&#39; instances of a single object type.
Definition: singular_db.hpp:33
void replay(void)
replay the object to create it in hardware
A representation of an interface in VPP.
Definition: interface.hpp:41
A entry in the ARP termination table of a Bridge Domain.
Class definition for listeners to OM events.
Definition: om.hpp:284
inspect command handler Handler
Definition: inspect.hpp:54
void event_handler(void *tls_async)
Definition: tls_async.c:340
dependency_t
There needs to be a strict order in which object types are read from VPP (at boot time) and replayed ...
Definition: types.hpp:43
The interface to writing objects into VPP OM.
Definition: om.hpp:140
static void dump(std::ostream &os)
Dump all bridge_domain-doamin into the stream provided.
epg_id_t key_t
The key for a GBP endpoint group is its ID.
A base class for all object_base in the VPP object_base-Model.
Definition: object_base.hpp:29
A entry in the ARP termination table of a Route Domain.
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
void show(char *chroot_path, int verbose)
Definition: svmtool.c:105
bool operator==(const gbp_endpoint_group &bdae) const
comparison operator
epg_id_t id() const
Get the ID of the EPG.
static std::shared_ptr< gbp_endpoint_group > find(const key_t &k)
Find the instnace of the bridge_domain domain in the OM.
std::shared_ptr< gbp_endpoint_group > singular() const
Return the matching &#39;singular instance&#39;.
std::string to_string() const
Convert to string for debugging.