FD.io VPP  v18.10-34-gcce845e
Vector Packet Processing
gbp_endpoint.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_ENDPOINT_H__
17 #define __VOM_GBP_ENDPOINT_H__
18 
19 #include <ostream>
20 #include <vector>
21 
23 #include "vom/interface.hpp"
24 #include "vom/singular_db.hpp"
25 
26 namespace VOM {
27 /**
28  * A GBP Enpoint (i.e. a VM)
29  */
30 class gbp_endpoint : public object_base
31 {
32 public:
33  /**
34  * The key for a GBP endpoint; interface and IP
35  */
36  typedef std::pair<interface::key_t, mac_address_t> key_t;
37 
38  /**
39  * Construct a GBP endpoint
40  */
41  gbp_endpoint(const interface& itf,
42  const std::vector<boost::asio::ip::address>& ip_addr,
43  const mac_address_t& mac,
44  const gbp_endpoint_group& epg);
45 
46  /**
47  * Copy Construct
48  */
49  gbp_endpoint(const gbp_endpoint& r);
50 
51  /**
52  * Destructor
53  */
54  ~gbp_endpoint();
55 
56  /**
57  * Return the object's key
58  */
59  const key_t key() const;
60 
61  /**
62  * comparison operator
63  */
64  bool operator==(const gbp_endpoint& bdae) const;
65 
66  /**
67  * Return the matching 'singular instance'
68  */
69  std::shared_ptr<gbp_endpoint> singular() const;
70 
71  /**
72  * Find the instnace of the bridge_domain domain in the OM
73  */
74  static std::shared_ptr<gbp_endpoint> find(const key_t& k);
75 
76  /**
77  * Dump all bridge_domain-doamin into the stream provided
78  */
79  static void dump(std::ostream& os);
80 
81  /**
82  * replay the object to create it in hardware
83  */
84  void replay(void);
85 
86  /**
87  * Convert to string for debugging
88  */
89  std::string to_string() const;
90 
91 private:
92  /**
93  * Class definition for listeners to OM events
94  */
96  {
97  public:
98  event_handler();
99  virtual ~event_handler() = default;
100 
101  /**
102  * Handle a populate event
103  */
104  void handle_populate(const client_db::key_t& key);
105 
106  /**
107  * Handle a replay event
108  */
109  void handle_replay();
110 
111  /**
112  * Show the object in the Singular DB
113  */
114  void show(std::ostream& os);
115 
116  /**
117  * Get the sortable Id of the listener
118  */
119  dependency_t order() const;
120  };
121 
122  /**
123  * event_handler to register with OM
124  */
125  static event_handler m_evh;
126 
127  /**
128  * Commit the acculmulated changes into VPP. i.e. to a 'HW" write.
129  */
130  void update(const gbp_endpoint& obj);
131 
132  /**
133  * Find or add the instnace of the bridge_domain domain in the OM
134  */
135  static std::shared_ptr<gbp_endpoint> find_or_add(const gbp_endpoint& temp);
136 
137  /*
138  * It's the VPPHW class that updates the objects in HW
139  */
140  friend class OM;
141 
142  /**
143  * It's the singular_db class that calls replay()
144  */
145  friend class singular_db<key_t, gbp_endpoint>;
146 
147  /**
148  * Sweep/reap the object if still stale
149  */
150  void sweep(void);
151 
152  /**
153  * HW configuration for the result of creating the endpoint
154  */
155  HW::item<handle_t> m_hdl;
156 
157  /**
158  * The interface the endpoint is attached to.
159  */
160  std::shared_ptr<interface> m_itf;
161 
162  /**
163  * The IP address of the endpoint
164  */
165  std::vector<boost::asio::ip::address> m_ips;
166 
167  /**
168  * The MAC address of the endpoint
169  */
170  mac_address_t m_mac;
171 
172  /**
173  * The EPG the endpoint is in
174  */
175  std::shared_ptr<gbp_endpoint_group> m_epg;
176 
177  /**
178  * A map of all bridge_domains
179  */
181 };
182 
183 std::ostream& operator<<(std::ostream& os, const gbp_endpoint::key_t& key);
184 }; // namespace
185 
186 /*
187  * fd.io coding-style-patch-verification: ON
188  *
189  * Local Variables:
190  * eval: (c-set-style "mozilla")
191  * End:
192  */
193 
194 #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
std::shared_ptr< gbp_endpoint > singular() const
Return the matching &#39;singular instance&#39;.
gbp_endpoint(const interface &itf, const std::vector< boost::asio::ip::address > &ip_addr, const mac_address_t &mac, const gbp_endpoint_group &epg)
Construct a GBP endpoint.
std::pair< interface::key_t, mac_address_t > key_t
The key for a GBP endpoint; interface and IP.
~gbp_endpoint()
Destructor.
A GBP Enpoint (i.e.
A Database to store the unique &#39;singular&#39; instances of a single object type.
Definition: singular_db.hpp:33
static void dump(std::ostream &os)
Dump all bridge_domain-doamin into the stream provided.
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
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
void replay(void)
replay the object to create it in hardware
A base class for all object_base in the VPP object_base-Model.
Definition: object_base.hpp:29
std::string to_string() const
Convert to string for debugging.
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
static std::shared_ptr< gbp_endpoint > find(const key_t &k)
Find the instnace of the bridge_domain domain in the OM.
void show(char *chroot_path, int verbose)
Definition: svmtool.c:105
bool operator==(const gbp_endpoint &bdae) const
comparison operator
Type def of a Ethernet address.
Definition: types.hpp:290
vl_api_mac_address_t mac
Definition: gbp.api:31