FD.io VPP  v18.07.1-19-g511ce25
Vector Packet Processing
gbp_contract.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_CONTRACT_H__
17 #define __VOM_GBP_CONTRACT_H__
18 
19 #include "vom/acl_list.hpp"
20 #include "vom/gbp_endpoint.hpp"
21 #include "vom/interface.hpp"
22 #include "vom/singular_db.hpp"
23 #include "vom/types.hpp"
24 
25 namespace VOM {
26 
27 /**
28  * A entry in the ARP termination table of a Bridge Domain
29  */
30 class gbp_contract : public object_base
31 {
32 public:
33  /**
34  * The key for a contract is the pari of EPG-IDs
35  */
36  typedef std::pair<epg_id_t, epg_id_t> key_t;
37 
38  /**
39  * Construct a GBP contract
40  */
41  gbp_contract(epg_id_t src_epg_id,
42  epg_id_t dst_epg_id,
43  const ACL::l3_list& acl);
44 
45  /**
46  * Copy Construct
47  */
48  gbp_contract(const gbp_contract& r);
49 
50  /**
51  * Destructor
52  */
53  ~gbp_contract();
54 
55  /**
56  * Return the object's key
57  */
58  const key_t key() const;
59 
60  /**
61  * comparison operator
62  */
63  bool operator==(const gbp_contract& bdae) const;
64 
65  /**
66  * Return the matching 'singular instance'
67  */
68  std::shared_ptr<gbp_contract> singular() const;
69 
70  /**
71  * Find the instnace of the bridge_domain domain in the OM
72  */
73  static std::shared_ptr<gbp_contract> find(const key_t& k);
74 
75  /**
76  * Dump all bridge_domain-doamin into the stream provided
77  */
78  static void dump(std::ostream& os);
79 
80  /**
81  * replay the object to create it in hardware
82  */
83  void replay(void);
84 
85  /**
86  * Convert to string for debugging
87  */
88  std::string to_string() const;
89 
90 private:
91  /**
92  * Class definition for listeners to OM events
93  */
95  {
96  public:
97  event_handler();
98  virtual ~event_handler() = default;
99 
100  /**
101  * Handle a populate event
102  */
103  void handle_populate(const client_db::key_t& key);
104 
105  /**
106  * Handle a replay event
107  */
108  void handle_replay();
109 
110  /**
111  * Show the object in the Singular DB
112  */
113  void show(std::ostream& os);
114 
115  /**
116  * Get the sortable Id of the listener
117  */
118  dependency_t order() const;
119  };
120 
121  /**
122  * event_handler to register with OM
123  */
124  static event_handler m_evh;
125 
126  /**
127  * Commit the acculmulated changes into VPP. i.e. to a 'HW" write.
128  */
129  void update(const gbp_contract& obj);
130 
131  /**
132  * Find or add the instance of the contract domain in the OM
133  */
134  static std::shared_ptr<gbp_contract> find_or_add(const gbp_contract& temp);
135 
136  /*
137  * It's the VPPHW class that updates the objects in HW
138  */
139  friend class OM;
140 
141  /**
142  * It's the singular_db class that calls replay()
143  */
144  friend class singular_db<key_t, gbp_contract>;
145 
146  /**
147  * Sweep/reap the object if still stale
148  */
149  void sweep(void);
150 
151  /**
152  * HW configuration for the result of creating the endpoint
153  */
154  HW::item<bool> m_hw;
155 
156  /**
157  * The source EPG ID
158  */
159  epg_id_t m_src_epg_id;
160 
161  /**
162  * The destination EPG ID
163  */
164  epg_id_t m_dst_epg_id;
165 
166  /**
167  * The ACL applied to traffic between the gourps
168  */
169  std::shared_ptr<ACL::l3_list> m_acl;
170 
171  /**
172  * A map of all bridge_domains
173  */
175 };
176 
177 std::ostream& operator<<(std::ostream& os, const gbp_contract::key_t& key);
178 }; // namespace
179 
180 /*
181  * fd.io coding-style-patch-verification: ON
182  *
183  * Local Variables:
184  * eval: (c-set-style "mozilla")
185  * End:
186  */
187 
188 #endif
const key_t key() const
Return the object&#39;s key.
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
An ACL list comprises a set of match actions rules to be applied to packets.
Definition: acl_list.hpp:37
uint32_t epg_id_t
EPG IDs are 32 bit integers.
static void dump(std::ostream &os)
Dump all bridge_domain-doamin into the stream provided.
gbp_contract(epg_id_t src_epg_id, epg_id_t dst_epg_id, const ACL::l3_list &acl)
Construct a GBP contract.
std::shared_ptr< gbp_contract > singular() const
Return the matching &#39;singular instance&#39;.
bool operator==(const gbp_contract &bdae) const
comparison operator
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
A entry in the ARP termination table of a Bridge Domain.
~gbp_contract()
Destructor.
std::pair< epg_id_t, epg_id_t > key_t
The key for a contract is the pari of EPG-IDs.
Class definition for listeners to OM events.
Definition: om.hpp:284
inspect command handler Handler
Definition: inspect.hpp:54
std::string to_string() const
Convert to string for debugging.
void event_handler(void *tls_async)
Definition: tls_async.c:311
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
std::ostream & operator<<(std::ostream &os, const std::pair< direction_t, interface::key_t > &key)
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
void show(char *chroot_path, int verbose)
Definition: svmtool.c:105
static std::shared_ptr< gbp_contract > find(const key_t &k)
Find the instnace of the bridge_domain domain in the OM.