FD.io VPP  v18.10-34-gcce845e
Vector Packet Processing
gbp_recirc.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_GBP_RECIRC_H__
17 #define __VOM_GBP_RECIRC_H__
18 
20 #include "vom/interface.hpp"
21 #include "vom/singular_db.hpp"
22 
23 namespace VOM {
24 /**
25  * A recirculation interface for GBP use pre/post NAT
26  */
27 class gbp_recirc : public object_base
28 {
29 public:
30  /**
31  * The key for a GBP recirc interface
32  */
34 
35  struct type_t : public enum_base<type_t>
36  {
37  /**
38  * Internal recirclation interfaces accept per-NAT translation
39  * traffic from the external/NAT EPG and inject into the
40  * private/NAT-inside EPG
41  */
42  const static type_t INTERNAL;
43 
44  /**
45  * External recirculation interfaces accept post-NAT translation
46  * traffic from the internal EPG and inject into the
47  * NAT EPG
48  */
49  const static type_t EXTERNAL;
50 
51  private:
52  type_t(int v, const std::string s);
53  };
54 
55  /**
56  * Construct a GBP recirc
57  */
58  gbp_recirc(const interface& itf,
59  const type_t& type,
60  const gbp_endpoint_group& epg);
61 
62  /**
63  * Copy Construct
64  */
65  gbp_recirc(const gbp_recirc& r);
66 
67  /**
68  * Destructor
69  */
70  ~gbp_recirc();
71 
72  /**
73  * Return the object's key
74  */
75  const key_t key() const;
76 
77  /**
78  * comparison operator
79  */
80  bool operator==(const gbp_recirc& bdae) const;
81 
82  /**
83  * Return the matching 'singular instance'
84  */
85  std::shared_ptr<gbp_recirc> singular() const;
86 
87  /**
88  * Find the instnace of the recirc interface in the OM
89  */
90  static std::shared_ptr<gbp_recirc> find(const key_t& k);
91 
92  /**
93  * Dump all bridge_domain-doamin into the stream provided
94  */
95  static void dump(std::ostream& os);
96 
97  /**
98  * replay the object to create it in hardware
99  */
100  void replay(void);
101 
102  /**
103  * Convert to string for debugging
104  */
105  std::string to_string() const;
106 
107  /**
108  * return the recirculation interface's handle
109  */
110  const handle_t& handle() const;
111 
112 private:
113  /**
114  * Class definition for listeners to OM events
115  */
117  {
118  public:
119  event_handler();
120  virtual ~event_handler() = default;
121 
122  /**
123  * Handle a populate event
124  */
125  void handle_populate(const client_db::key_t& key);
126 
127  /**
128  * Handle a replay event
129  */
130  void handle_replay();
131 
132  /**
133  * Show the object in the Singular DB
134  */
135  void show(std::ostream& os);
136 
137  /**
138  * Get the sortable Id of the listener
139  */
140  dependency_t order() const;
141  };
142 
143  /**
144  * event_handler to register with OM
145  */
146  static event_handler m_evh;
147 
148  /**
149  * Commit the acculmulated changes into VPP. i.e. to a 'HW" write.
150  */
151  void update(const gbp_recirc& obj);
152 
153  /**
154  * Find or add the instnace of the bridge_domain domain in the OM
155  */
156  static std::shared_ptr<gbp_recirc> find_or_add(const gbp_recirc& temp);
157 
158  /*
159  * It's the VPPHW class that updates the objects in HW
160  */
161  friend class OM;
162 
163  /**
164  * It's the singular_db class that calls replay()
165  */
166  friend class singular_db<key_t, gbp_recirc>;
167 
168  /**
169  * Sweep/reap the object if still stale
170  */
171  void sweep(void);
172 
173  /**
174  * HW configuration for the result of creating the recirc
175  */
176  HW::item<bool> m_hw;
177 
178  /**
179  * The interface the recirc is attached to.
180  */
181  std::shared_ptr<interface> m_itf;
182 
183  /**
184  * Is the reicrc for the external (i.e. post-NAT) or internal
185  */
186  type_t m_type;
187 
188  /**
189  * The EPG the recirc is in
190  */
191  std::shared_ptr<gbp_endpoint_group> m_epg;
192 
193  /**
194  * A map of all bridge_domains
195  */
196  static singular_db<key_t, gbp_recirc> m_db;
197 };
198 
199 }; // namespace VOM
200 
201 /*
202  * fd.io coding-style-patch-verification: ON
203  *
204  * Local Variables:
205  * eval: (c-set-style "mozilla")
206  * End:
207  */
208 
209 #endif
void replay(void)
replay the object to create it in hardware
Definition: gbp_recirc.cpp:87
A template base class for all enum types.
Definition: enum_base.hpp:30
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
std::shared_ptr< gbp_recirc > singular() const
Return the matching &#39;singular instance&#39;.
Definition: gbp_recirc.cpp:127
static void dump(std::ostream &os)
Dump all bridge_domain-doamin into the stream provided.
Definition: gbp_recirc.cpp:133
~gbp_recirc()
Destructor.
Definition: gbp_recirc.cpp:52
const handle_t & handle() const
return the recirculation interface&#39;s handle
Definition: gbp_recirc.cpp:65
interface::key_t key_t
The key for a GBP recirc interface.
Definition: gbp_recirc.hpp:33
#define v
Definition: acl.c:496
A Database to store the unique &#39;singular&#39; instances of a single object type.
Definition: singular_db.hpp:33
A recirculation interface for GBP use pre/post NAT.
Definition: gbp_recirc.hpp:27
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
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
static const type_t EXTERNAL
External recirculation interfaces accept post-NAT translation traffic from the internal EPG and injec...
Definition: gbp_recirc.hpp:49
A type declaration of an interface handle in VPP.
Definition: types.hpp:228
void event_handler(void *tls_async)
Definition: tls_async.c:339
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
gbp_recirc(const interface &itf, const type_t &type, const gbp_endpoint_group &epg)
Construct a GBP recirc.
Definition: gbp_recirc.cpp:34
A base class for all object_base in the VPP object_base-Model.
Definition: object_base.hpp:29
static std::shared_ptr< gbp_recirc > find(const key_t &k)
Find the instnace of the recirc interface in the OM.
Definition: gbp_recirc.cpp:121
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
static const type_t INTERNAL
Internal recirclation interfaces accept per-NAT translation traffic from the external/NAT EPG and inj...
Definition: gbp_recirc.hpp:42
void show(char *chroot_path, int verbose)
Definition: svmtool.c:105
const std::string & to_string() const
convert to string format for debug purposes
Definition: enum_base.hpp:36
std::string key_t
The key for interface&#39;s key.
Definition: interface.hpp:56
const key_t key() const
Return the object&#39;s key.
Definition: gbp_recirc.cpp:59