FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
gbp_ext_itf.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_EXT_ITF_H__
17 #define __VOM_GBP_EXT_ITF_H__
18 
20 #include "vom/gbp_route_domain.hpp"
21 #include "vom/interface.hpp"
22 #include "vom/singular_db.hpp"
23 
24 namespace VOM {
25 /**
26  * A enternal interface for GBP
27  */
28 class gbp_ext_itf : public object_base
29 {
30 public:
31  /**
32  * The key for a GBP ext_itf interface
33  */
35 
36  /**
37  * Construct a GBP ext_itf
38  */
39  gbp_ext_itf(const interface& itf,
40  const gbp_bridge_domain& gbd,
41  const gbp_route_domain& grd);
42 
43  /**
44  * Copy Construct
45  */
46  gbp_ext_itf(const gbp_ext_itf& r);
47 
48  /**
49  * Destructor
50  */
51  ~gbp_ext_itf();
52 
53  /**
54  * Return the object's key
55  */
56  const key_t key() const;
57 
58  /**
59  * comparison operator
60  */
61  bool operator==(const gbp_ext_itf& bdae) const;
62 
63  /**
64  * Return the matching 'singular instance'
65  */
66  std::shared_ptr<gbp_ext_itf> singular() const;
67 
68  /**
69  * Find the instnace of the ext_itf interface in the OM
70  */
71  static std::shared_ptr<gbp_ext_itf> find(const key_t& k);
72 
73  /**
74  * Dump all bridge_domain-doamin into the stream provided
75  */
76  static void dump(std::ostream& os);
77 
78  /**
79  * replay the object to create it in hardware
80  */
81  void replay(void);
82 
83  /**
84  * Convert to string for debugging
85  */
86  std::string to_string() const;
87 
88  /**
89  * return the ext_itfulation interface's handle
90  */
91  const handle_t& handle() const;
92 
93 private:
94  /**
95  * Class definition for listeners to OM events
96  */
98  {
99  public:
100  event_handler();
101  virtual ~event_handler() = default;
102 
103  /**
104  * Handle a populate event
105  */
106  void handle_populate(const client_db::key_t& key);
107 
108  /**
109  * Handle a replay event
110  */
111  void handle_replay();
112 
113  /**
114  * Show the object in the Singular DB
115  */
116  void show(std::ostream& os);
117 
118  /**
119  * Get the sortable Id of the listener
120  */
121  dependency_t order() const;
122  };
123 
124  /**
125  * event_handler to register with OM
126  */
127  static event_handler m_evh;
128 
129  /**
130  * Commit the acculmulated changes into VPP. i.e. to a 'HW" write.
131  */
132  void update(const gbp_ext_itf& obj);
133 
134  /**
135  * Find or add the instnace of the bridge_domain domain in the OM
136  */
137  static std::shared_ptr<gbp_ext_itf> find_or_add(const gbp_ext_itf& temp);
138 
139  /*
140  * It's the VPPHW class that updates the objects in HW
141  */
142  friend class OM;
143 
144  /**
145  * It's the singular_db class that calls replay()
146  */
147  friend class singular_db<key_t, gbp_ext_itf>;
148 
149  /**
150  * Sweep/reap the object if still stale
151  */
152  void sweep(void);
153 
154  /**
155  * HW configuration for the result of creating the ext_itf
156  */
157  HW::item<bool> m_hw;
158 
159  /**
160  * The interface the ext_itf is attached to.
161  */
162  std::shared_ptr<interface> m_itf;
163 
164  /**
165  * The BD & RD the ext_itf is in
166  */
167  std::shared_ptr<gbp_bridge_domain> m_bd;
168  std::shared_ptr<gbp_route_domain> m_rd;
169 
170  /**
171  * A map of all bridge_domains
172  */
174 };
175 
176 }; // namespace VOM
177 
178 /*
179  * fd.io coding-style-patch-verification: OFF
180  *
181  * Local Variables:
182  * eval: (c-set-style "mozilla")
183  * End:
184  */
185 
186 #endif
VOM::HW::item< bool >
VOM
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
VOM::gbp_bridge_domain
A entry in the ARP termination table of a Bridge Domain.
Definition: gbp_bridge_domain.hpp:29
VOM::dependency_t
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
VOM::OM
The interface to writing objects into VPP OM.
Definition: om.hpp:140
VOM::gbp_ext_itf
A enternal interface for GBP.
Definition: gbp_ext_itf.hpp:28
VOM::inspect::command_handler
inspect command handler Handler
Definition: inspect.hpp:54
gbp_bridge_domain.hpp
VOM::OM::listener
Class definition for listeners to OM events.
Definition: om.hpp:284
r
vnet_hw_if_output_node_runtime_t * r
Definition: interface_output.c:1071
VOM::gbp_ext_itf::handle
const handle_t & handle() const
return the ext_itfulation interface's handle
Definition: gbp_ext_itf.cpp:57
VOM::gbp_ext_itf::dump
static void dump(std::ostream &os)
Dump all bridge_domain-doamin into the stream provided.
Definition: gbp_ext_itf.cpp:125
VOM::gbp_ext_itf::gbp_ext_itf
gbp_ext_itf(const interface &itf, const gbp_bridge_domain &gbd, const gbp_route_domain &grd)
Construct a GBP ext_itf.
Definition: gbp_ext_itf.cpp:26
VOM::gbp_ext_itf::find
static std::shared_ptr< gbp_ext_itf > find(const key_t &k)
Find the instnace of the ext_itf interface in the OM.
Definition: gbp_ext_itf.cpp:113
VOM::gbp_ext_itf::operator==
bool operator==(const gbp_ext_itf &bdae) const
comparison operator
Definition: gbp_ext_itf.cpp:63
VOM::interface
A representation of an interface in VPP.
Definition: interface.hpp:41
VOM::client_db::key_t
const typedef 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
VOM::handle_t
A type declaration of an interface handle in VPP.
Definition: types.hpp:233
VOM::gbp_ext_itf::to_string
std::string to_string() const
Convert to string for debugging.
Definition: gbp_ext_itf.cpp:88
VOM::gbp_ext_itf::singular
std::shared_ptr< gbp_ext_itf > singular() const
Return the matching 'singular instance'.
Definition: gbp_ext_itf.cpp:119
singular_db.hpp
interface.hpp
VOM::gbp_route_domain
A entry in the ARP termination table of a Route Domain.
Definition: gbp_route_domain.hpp:30
VOM::gbp_ext_itf::key
const key_t key() const
Return the object's key.
Definition: gbp_ext_itf.cpp:51
VOM::singular_db
A Database to store the unique 'singular' instances of a single object type.
Definition: singular_db.hpp:33
VOM::gbp_ext_itf::key_t
interface::key_t key_t
The key for a GBP ext_itf interface.
Definition: gbp_ext_itf.hpp:34
VOM::interface::key_t
std::string key_t
The key for interface's key.
Definition: interface.hpp:56
show
void show(char *chroot_path, int verbose)
Definition: svmtool.c:104
event_handler
void event_handler(void *tls_async)
Definition: tls_async.c:334
VOM::gbp_ext_itf::replay
void replay(void)
replay the object to create it in hardware
Definition: gbp_ext_itf.cpp:79
VOM::object_base
A base class for all object_base in the VPP object_base-Model.
Definition: object_base.hpp:29
gbp_route_domain.hpp
VOM::gbp_ext_itf::~gbp_ext_itf
~gbp_ext_itf()
Destructor.
Definition: gbp_ext_itf.cpp:44
string
const char *const string
Definition: cJSON.h:172