FD.io VPP  v19.04.2-12-g66b1689
Vector Packet Processing
route_domain.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_ROUTE_DOMAIN_H__
17 #define __VOM_ROUTE_DOMAIN_H__
18 
19 #include "vom/inspect.hpp"
20 #include "vom/object_base.hpp"
21 #include "vom/om.hpp"
22 #include "vom/prefix.hpp"
23 #include "vom/singular_db.hpp"
24 
25 namespace VOM {
26 /**
27  * A route-domain is a VRF.
28  * creating a route-domain object will construct both an IPv4
29  * and IPv6 table.
30  */
31 class route_domain : public object_base
32 {
33 public:
34  /**
35  * The Key for a route-domain
36  */
38 
39  /**
40  * Construct a new object matching the desried state
41  */
43 
44  /**
45  * Copy Constructor
46  */
47  route_domain(const route_domain& o);
48 
49  /**
50  * Destructor
51  */
52  ~route_domain();
53 
54  /**
55  * comparison operator - for UT
56  */
57  bool operator==(const route_domain& r) const;
58 
59  /**
60  * Return the matching 'singular instance'
61  */
62  std::shared_ptr<route_domain> singular() const;
63 
64  /**
65  * Debug print function
66  */
67  std::string to_string() const;
68 
69  /**
70  * Get the table ID
71  */
73 
74  /**
75  * Get the route-domain's key
76  */
77  key_t key() const;
78 
79  /**
80  * Find the instnace of the route domain in the OM
81  */
82  static std::shared_ptr<route_domain> find(const key_t& temp);
83 
84  /**
85  * Dump all route-doamin into the stream provided
86  */
87  static void dump(std::ostream& os);
88 
89  /**
90  * Return the sigular instance for the default table
91  */
92  static std::shared_ptr<route_domain> get_default();
93 
94  /**
95  * replay the object to create it in hardware
96  */
97  void replay(void);
98 
99 private:
100  /**
101  * Class definition for listeners to OM events
102  */
104  {
105  public:
106  event_handler();
107  virtual ~event_handler() = default;
108 
109  /**
110  * Handle a populate event
111  */
112  void handle_populate(const client_db::key_t& key);
113 
114  /**
115  * Handle a replay event
116  */
117  void handle_replay();
118 
119  /**
120  * Show the object in the Singular DB
121  */
122  void show(std::ostream& os);
123 
124  /**
125  * Get the sortable Id of the listener
126  */
127  dependency_t order() const;
128  };
129 
130  /**
131  * Instance of the event handler to register with OM
132  */
133  static event_handler m_evh;
134 
135  /**
136  * Commit the acculmulated changes into VPP. i.e. to a 'HW" write.
137  */
138  void update(const route_domain& obj);
139 
140  /**
141  * Find or add the instnace of the route domain in the OM
142  */
143  static std::shared_ptr<route_domain> find_or_add(const route_domain& temp);
144 
145  /*
146  * It's the OM class that updates the objects in HW
147  */
148  friend class OM;
149 
150  /**
151  * It's the singular_db class that calls replay()
152  */
153  friend class singular_db<route::table_id_t, route_domain>;
154 
155  /**
156  * Sweep/reap the object if still stale
157  */
158  void sweep(void);
159 
160  /**
161  * HW configuration for the result of creating the v4 table
162  */
163  HW::item<bool> m_hw_v4;
164 
165  /**
166  * HW configuration for the result of creating the v6 table
167  */
168  HW::item<bool> m_hw_v6;
169 
170  /**
171  * VPP understands Table-IDs not table names.
172  * The table IDs for V4 and V6 are the same.
173  */
174  route::table_id_t m_table_id;
175 
176  /**
177  * A map of all interfaces key against the interface's name
178  */
179  static singular_db<route::table_id_t, route_domain> m_db;
180 };
181 }; // namespace VOM
182 
183 /*
184  * fd.io coding-style-patch-verification: ON
185  *
186  * Local Variables:
187  * eval: (c-set-style "mozilla")
188  * End:
189  */
190 
191 #endif
uint32_t table_id_t
type def the table-id
Definition: prefix.hpp:82
static std::shared_ptr< route_domain > find(const key_t &temp)
Find the instnace of the route domain in the OM.
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
A HW::item is data that is either to be written to or read from VPP/HW.
Definition: hw.hpp:44
A route-domain is a VRF.
route::table_id_t table_id() const
Get the table ID.
static std::shared_ptr< route_domain > get_default()
Return the sigular instance for the default table.
void replay(void)
replay the object to create it in hardware
A Database to store the unique &#39;singular&#39; instances of a single object type.
Definition: singular_db.hpp:33
std::shared_ptr< route_domain > singular() const
Return the matching &#39;singular instance&#39;.
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
A base class for all object_base in the VPP object_base-Model.
Definition: object_base.hpp:29
bool operator==(const route_domain &r) const
comparison operator - for UT
std::string to_string() const
Debug print function.
route_domain(route::table_id_t id)
Construct a new object matching the desried state.
key_t key() const
Get the route-domain&#39;s key.
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
~route_domain()
Destructor.
void show(char *chroot_path, int verbose)
Definition: svmtool.c:105
static void dump(std::ostream &os)
Dump all route-doamin into the stream provided.
route::table_id_t key_t
The Key for a route-domain.