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