FD.io VPP  v21.06-3-gbb25fbf28
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  * The iterator type
41  */
44 
45  static const_iterator_t cbegin();
46  static const_iterator_t cend();
47 
48  /**
49  * Construct a new object matching the desried state
50  */
52 
53  /**
54  * Copy Constructor
55  */
56  route_domain(const route_domain& o);
57 
58  /**
59  * Destructor
60  */
61  ~route_domain();
62 
63  /**
64  * comparison operator - for UT
65  */
66  bool operator==(const route_domain& r) const;
67 
68  /**
69  * Return the matching 'singular instance'
70  */
71  std::shared_ptr<route_domain> singular() const;
72 
73  /**
74  * Debug print function
75  */
76  std::string to_string() const;
77 
78  /**
79  * Get the table ID
80  */
82 
83  /**
84  * Get the route-domain's key
85  */
86  key_t key() const;
87 
88  /**
89  * Find the instnace of the route domain in the OM
90  */
91  static std::shared_ptr<route_domain> find(const key_t& temp);
92 
93  /**
94  * Dump all route-doamin into the stream provided
95  */
96  static void dump(std::ostream& os);
97 
98  /**
99  * Return the sigular instance for the default table
100  */
101  static std::shared_ptr<route_domain> get_default();
102 
103  /**
104  * replay the object to create it in hardware
105  */
106  void replay(void);
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  * Instance of the 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 route_domain& obj);
148 
149  /**
150  * Find or add the instnace of the route domain in the OM
151  */
152  static std::shared_ptr<route_domain> find_or_add(const route_domain& temp);
153 
154  /*
155  * It's the OM class that updates the objects in HW
156  */
157  friend class OM;
158 
159  /**
160  * It's the singular_db class that calls replay()
161  */
162  friend class singular_db<route::table_id_t, route_domain>;
163 
164  /**
165  * Sweep/reap the object if still stale
166  */
167  void sweep(void);
168 
169  /**
170  * HW configuration for the result of creating the v4 table
171  */
172  HW::item<bool> m_hw_v4;
173 
174  /**
175  * HW configuration for the result of creating the v6 table
176  */
177  HW::item<bool> m_hw_v6;
178 
179  /**
180  * VPP understands Table-IDs not table names.
181  * The table IDs for V4 and V6 are the same.
182  */
183  route::table_id_t m_table_id;
184 
185  /**
186  * A map of all interfaces key against the interface's name
187  */
188  static singular_db<route::table_id_t, route_domain> m_db;
189 };
190 }; // namespace VOM
191 
192 /*
193  * fd.io coding-style-patch-verification: OFF
194  *
195  * Local Variables:
196  * eval: (c-set-style "mozilla")
197  * End:
198  */
199 
200 #endif
VOM::HW::item
A HW::item is data that is either to be written to or read from VPP/HW.
Definition: hw.hpp:44
VOM::route_domain::table_id
route::table_id_t table_id() const
Get the table ID.
Definition: route_domain.cpp:54
VOM::route_domain::to_string
std::string to_string() const
Debug print function.
Definition: route_domain.cpp:113
VOM::route_domain::operator==
bool operator==(const route_domain &r) const
comparison operator - for UT
Definition: route_domain.cpp:48
VOM
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
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
om.hpp
VOM::OM
The interface to writing objects into VPP OM.
Definition: om.hpp:140
VOM::inspect::command_handler
inspect command handler Handler
Definition: inspect.hpp:54
VOM::route_domain::key
key_t key() const
Get the route-domain's key.
Definition: route_domain.cpp:60
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::singular_db::const_iterator
std::map< KEY, std::weak_ptr< OBJ > >::const_iterator const_iterator
Iterator.
Definition: singular_db.hpp:45
VOM::route_domain::const_iterator_t
singular_db< const key_t, route_domain >::const_iterator const_iterator_t
The iterator type.
Definition: route_domain.hpp:43
VOM::route_domain::get_default
static std::shared_ptr< route_domain > get_default()
Return the sigular instance for the default table.
Definition: route_domain.cpp:146
VOM::route_domain::replay
void replay(void)
replay the object to create it in hardware
Definition: route_domain.cpp:92
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
inspect.hpp
singular_db.hpp
prefix.hpp
VOM::route_domain::cbegin
static const_iterator_t cbegin()
Definition: route_domain.cpp:66
VOM::route_domain::~route_domain
~route_domain()
Destructor.
Definition: route_domain.cpp:104
VOM::route_domain
A route-domain is a VRF.
Definition: route_domain.hpp:31
VOM::route_domain::route_domain
route_domain(route::table_id_t id)
Construct a new object matching the desried state.
Definition: route_domain.cpp:33
VOM::singular_db
A Database to store the unique 'singular' instances of a single object type.
Definition: singular_db.hpp:33
VOM::route_domain::cend
static const_iterator_t cend()
Definition: route_domain.cpp:72
VOM::route_domain::dump
static void dump(std::ostream &os)
Dump all route-doamin into the stream provided.
Definition: route_domain.cpp:166
VOM::route_domain::singular
std::shared_ptr< route_domain > singular() const
Return the matching 'singular instance'.
Definition: route_domain.cpp:160
VOM::route::table_id_t
uint32_t table_id_t
type def the table-id
Definition: prefix.hpp:121
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::object_base
A base class for all object_base in the VPP object_base-Model.
Definition: object_base.hpp:29
object_base.hpp
VOM::route_domain::key_t
route::table_id_t key_t
The Key for a route-domain.
Definition: route_domain.hpp:37
VOM::route_domain::find
static std::shared_ptr< route_domain > find(const key_t &temp)
Find the instnace of the route domain in the OM.
Definition: route_domain.cpp:124
string
const char *const string
Definition: cJSON.h:172