FD.io VPP  v21.06-3-gbb25fbf28
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  * Endpoint flags
35  */
36  struct flags_t : enum_base<flags_t>
37  {
38  const static flags_t NONE;
39  const static flags_t BOUNCE;
40  const static flags_t REMOTE;
41  const static flags_t LEARNT;
42  const static flags_t EXTERNAL;
43 
44  private:
45  /**
46  * Private constructor taking the value and the string name
47  */
48  flags_t(int v, const std::string& s);
49  };
50 
51  /**
52  * The key for a GBP endpoint; interface and IP
53  */
54  typedef std::pair<interface::key_t, mac_address_t> key_t;
55 
56  /**
57  * Construct a GBP endpoint
58  */
59  gbp_endpoint(const interface& itf,
60  const std::vector<boost::asio::ip::address>& ip_addr,
61  const mac_address_t& mac,
62  const gbp_endpoint_group& epg,
63  const flags_t& flags = flags_t::NONE);
64 
65  /**
66  * Copy Construct
67  */
68  gbp_endpoint(const gbp_endpoint& r);
69 
70  /**
71  * Destructor
72  */
73  ~gbp_endpoint();
74 
75  /**
76  * Return the object's key
77  */
78  const key_t key() const;
79 
80  /**
81  * comparison operator
82  */
83  bool operator==(const gbp_endpoint& bdae) const;
84 
85  /**
86  * Return the matching 'singular instance'
87  */
88  std::shared_ptr<gbp_endpoint> singular() const;
89 
90  /**
91  * Find the instnace of the bridge_domain domain in the OM
92  */
93  static std::shared_ptr<gbp_endpoint> find(const key_t& k);
94 
95  /**
96  * Dump all bridge_domain-doamin into the stream provided
97  */
98  static void dump(std::ostream& os);
99 
100  /**
101  * replay the object to create it in hardware
102  */
103  void replay(void);
104 
105  /**
106  * Convert to string for debugging
107  */
108  std::string to_string() const;
109 
110 private:
111  /**
112  * Class definition for listeners to OM events
113  */
115  {
116  public:
117  event_handler();
118  virtual ~event_handler() = default;
119 
120  /**
121  * Handle a populate event
122  */
123  void handle_populate(const client_db::key_t& key);
124 
125  /**
126  * Handle a replay event
127  */
128  void handle_replay();
129 
130  /**
131  * Show the object in the Singular DB
132  */
133  void show(std::ostream& os);
134 
135  /**
136  * Get the sortable Id of the listener
137  */
138  dependency_t order() const;
139  };
140 
141  /**
142  * event_handler to register with OM
143  */
144  static event_handler m_evh;
145 
146  /**
147  * Commit the acculmulated changes into VPP. i.e. to a 'HW" write.
148  */
149  void update(const gbp_endpoint& obj);
150 
151  /**
152  * Find or add the instnace of the bridge_domain domain in the OM
153  */
154  static std::shared_ptr<gbp_endpoint> find_or_add(const gbp_endpoint& temp);
155 
156  /*
157  * It's the VPPHW class that updates the objects in HW
158  */
159  friend class OM;
160 
161  /**
162  * It's the singular_db class that calls replay()
163  */
165 
166  /**
167  * Sweep/reap the object if still stale
168  */
169  void sweep(void);
170 
171  /**
172  * HW configuration for the result of creating the endpoint
173  */
174  HW::item<handle_t> m_hdl;
175 
176  /**
177  * The interface the endpoint is attached to.
178  */
179  std::shared_ptr<interface> m_itf;
180 
181  /**
182  * The IP address of the endpoint
183  */
184  std::vector<boost::asio::ip::address> m_ips;
185 
186  /**
187  * The MAC address of the endpoint
188  */
189  mac_address_t m_mac;
190 
191  /**
192  * The EPG the endpoint is in
193  */
194  std::shared_ptr<gbp_endpoint_group> m_epg;
195 
196  /**
197  * Endpoint flags
198  */
199  flags_t m_flags;
200 
201  /**
202  * A map of all bridge_domains
203  */
205 };
206 
207 std::ostream& operator<<(std::ostream& os, const gbp_endpoint::key_t& key);
208 }; // namespace
209 
210 /*
211  * fd.io coding-style-patch-verification: OFF
212  *
213  * Local Variables:
214  * eval: (c-set-style "mozilla")
215  * End:
216  */
217 
218 #endif
VOM::HW::item< handle_t >
VOM::gbp_endpoint::flags_t::EXTERNAL
const static flags_t EXTERNAL
Definition: gbp_endpoint.hpp:42
mac
vl_api_mac_address_t mac
Definition: l2.api:559
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
VOM::gbp_endpoint::singular
std::shared_ptr< gbp_endpoint > singular() const
Return the matching 'singular instance'.
Definition: gbp_endpoint.cpp:136
VOM::gbp_endpoint::~gbp_endpoint
~gbp_endpoint()
Destructor.
Definition: gbp_endpoint.cpp:63
VOM::OM
The interface to writing objects into VPP OM.
Definition: om.hpp:140
VOM::gbp_endpoint::key_t
std::pair< interface::key_t, mac_address_t > key_t
The key for a GBP endpoint; interface and IP.
Definition: gbp_endpoint.hpp:54
VOM::inspect::command_handler
inspect command handler Handler
Definition: inspect.hpp:54
VOM::OM::listener
Class definition for listeners to OM events.
Definition: om.hpp:284
gbp_endpoint_group.hpp
r
vnet_hw_if_output_node_runtime_t * r
Definition: interface_output.c:1071
key
typedef key
Definition: ipsec_types.api:88
VOM::gbp_endpoint::gbp_endpoint
gbp_endpoint(const interface &itf, const std::vector< boost::asio::ip::address > &ip_addr, const mac_address_t &mac, const gbp_endpoint_group &epg, const flags_t &flags=flags_t::NONE)
Construct a GBP endpoint.
Definition: gbp_endpoint.cpp:38
VOM::gbp_endpoint::flags_t::BOUNCE
const static flags_t BOUNCE
Definition: gbp_endpoint.hpp:39
VOM::gbp_endpoint::flags_t::LEARNT
const static flags_t LEARNT
Definition: gbp_endpoint.hpp:41
VOM::enum_base
A template base class for all enum types.
Definition: enum_base.hpp:30
VOM::gbp_endpoint::flags_t
Endpoint flags.
Definition: gbp_endpoint.hpp:36
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::gbp_endpoint::dump
static void dump(std::ostream &os)
Dump all bridge_domain-doamin into the stream provided.
Definition: gbp_endpoint.cpp:142
VOM::gbp_endpoint::key
const key_t key() const
Return the object's key.
Definition: gbp_endpoint.cpp:70
VOM::gbp_endpoint::to_string
std::string to_string() const
Convert to string for debugging.
Definition: gbp_endpoint.cpp:101
VOM::gbp_endpoint::operator==
bool operator==(const gbp_endpoint &bdae) const
comparison operator
Definition: gbp_endpoint.cpp:76
VOM::operator<<
std::ostream & operator<<(std::ostream &os, const std::pair< direction_t, interface::key_t > &key)
Definition: acl_binding.cpp:201
VOM::gbp_endpoint::flags_t::REMOTE
const static flags_t REMOTE
Definition: gbp_endpoint.hpp:40
VOM::gbp_endpoint::replay
void replay(void)
replay the object to create it in hardware
Definition: gbp_endpoint.cpp:92
singular_db.hpp
VOM::gbp_endpoint
A GBP Enpoint (i.e.
Definition: gbp_endpoint.hpp:30
VOM::mac_address_t
Type def of a Ethernet address.
Definition: types.hpp:295
interface.hpp
VOM::singular_db
A Database to store the unique 'singular' instances of a single object type.
Definition: singular_db.hpp:33
VOM::gbp_endpoint::flags_t::NONE
const static flags_t NONE
Definition: gbp_endpoint.hpp:38
VOM::gbp_endpoint::find
static std::shared_ptr< gbp_endpoint > find(const key_t &k)
Find the instnace of the bridge_domain domain in the OM.
Definition: gbp_endpoint.cpp:130
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_endpoint_group
A entry in the ARP termination table of a Bridge Domain.
Definition: gbp_endpoint_group.hpp:32
VOM::object_base
A base class for all object_base in the VPP object_base-Model.
Definition: object_base.hpp:29
string
const char *const string
Definition: cJSON.h:172
flags
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105