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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 #ifndef __VOM_GBP_BRIDGE_DOMAIN_H__
17 #define __VOM_GBP_BRIDGE_DOMAIN_H__
19 #include "vom/bridge_domain.hpp"
20 #include "vom/gbp_route_domain.hpp"
21 #include "vom/interface.hpp"
22 #include "vom/singular_db.hpp"
27 * A entry in the ARP termination table of a Bridge Domain
29 class gbp_bridge_domain : public object_base
33 * The key for a bridge_domain is the pair of EPG-IDs
35 typedef bridge_domain::key_t key_t;
37 struct flags_t : enum_base<flags_t>
39 const static flags_t NONE;
40 const static flags_t DO_NOT_LEARN;
41 const static flags_t UU_FWD_DROP;
42 const static flags_t MCAST_DROP;
43 const static flags_t UCAST_ARP;
45 static const flags_t& from_vpp(int i);
48 flags_t(int v, const std::string& s);
53 * Construct a GBP bridge_domain
55 gbp_bridge_domain(const bridge_domain& bd,
56 const gbp_route_domain& rd,
58 const flags_t& flags = flags_t::NONE);
59 gbp_bridge_domain(const bridge_domain& bd,
60 const gbp_route_domain& rd,
62 const interface& uu_fwd,
63 const interface& bm_flood,
64 const flags_t& flags = flags_t::NONE);
65 gbp_bridge_domain(const bridge_domain& bd,
66 const gbp_route_domain& rd,
67 const std::shared_ptr<interface> bvi,
68 const std::shared_ptr<interface> uu_fwd,
69 const std::shared_ptr<interface> bm_flood,
70 const flags_t& flags = flags_t::NONE);
71 gbp_bridge_domain(const bridge_domain& bd,
72 const gbp_route_domain& rd,
74 const std::shared_ptr<interface> uu_fwd,
75 const std::shared_ptr<interface> bm_flood,
76 const flags_t& flags = flags_t::NONE);
81 gbp_bridge_domain(const gbp_bridge_domain& r);
89 * Return the object's key
91 const key_t key() const;
94 * Return the bridge domain's VPP ID
101 bool operator==(const gbp_bridge_domain& bdae) const;
104 * Return the matching 'singular instance'
106 std::shared_ptr<gbp_bridge_domain> singular() const;
109 * Find the instnace of the bridge_domain domain in the OM
111 static std::shared_ptr<gbp_bridge_domain> find(const key_t& k);
114 * Dump all bridge_domain-doamin into the stream provided
116 static void dump(std::ostream& os);
119 * replay the object to create it in hardware
124 * Convert to string for debugging
126 std::string to_string() const;
128 const std::shared_ptr<bridge_domain> get_bridge_domain() const;
129 const std::shared_ptr<interface> get_bvi() const;
133 * Class definition for listeners to OM events
135 class event_handler : public OM::listener, public inspect::command_handler
139 virtual ~event_handler() = default;
142 * Handle a populate event
144 void handle_populate(const client_db::key_t& key);
147 * Handle a replay event
149 void handle_replay();
152 * Show the object in the Singular DB
154 void show(std::ostream& os);
157 * Get the sortable Id of the listener
159 dependency_t order() const;
163 * event_handler to register with OM
165 static event_handler m_evh;
168 * Commit the acculmulated changes into VPP. i.e. to a 'HW" write.
170 void update(const gbp_bridge_domain& obj);
173 * Find or add the instance of the bridge_domain domain in the OM
175 static std::shared_ptr<gbp_bridge_domain> find_or_add(
176 const gbp_bridge_domain& temp);
179 * It's the VPPHW class that updates the objects in HW
184 * It's the singular_db class that calls replay()
186 friend class singular_db<key_t, gbp_bridge_domain>;
189 * Sweep/reap the object if still stale
194 * HW configuration for the result of creating the endpoint
196 HW::item<uint32_t> m_id;
198 std::shared_ptr<bridge_domain> m_bd;
199 std::shared_ptr<gbp_route_domain> m_rd;
200 std::shared_ptr<interface> m_bvi;
201 std::shared_ptr<interface> m_uu_fwd;
202 std::shared_ptr<interface> m_bm_flood;
206 * A map of all bridge_domains
208 static singular_db<key_t, gbp_bridge_domain> m_db;
214 * fd.io coding-style-patch-verification: ON
217 * eval: (c-set-style "mozilla")