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/interface.hpp"
21 #include "vom/singular_db.hpp"
22 #include "vom/types.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 pari of EPG-IDs
35 typedef bridge_domain::key_t key_t;
38 * Construct a GBP bridge_domain
40 gbp_bridge_domain(const bridge_domain& bd, const interface& bvi);
41 gbp_bridge_domain(const bridge_domain& bd,
43 const interface& uu_fwd);
44 gbp_bridge_domain(const bridge_domain& bd,
45 const std::shared_ptr<interface> bvi,
46 const std::shared_ptr<interface> uu_fwd);
47 gbp_bridge_domain(const bridge_domain& bd,
49 const std::shared_ptr<interface> uu_fwd);
54 gbp_bridge_domain(const gbp_bridge_domain& r);
62 * Return the object's key
64 const key_t key() const;
67 * Return the bridge domain's VPP ID
74 bool operator==(const gbp_bridge_domain& bdae) const;
77 * Return the matching 'singular instance'
79 std::shared_ptr<gbp_bridge_domain> singular() const;
82 * Find the instnace of the bridge_domain domain in the OM
84 static std::shared_ptr<gbp_bridge_domain> find(const key_t& k);
87 * Dump all bridge_domain-doamin into the stream provided
89 static void dump(std::ostream& os);
92 * replay the object to create it in hardware
97 * Convert to string for debugging
99 std::string to_string() const;
101 const std::shared_ptr<bridge_domain> get_bridge_domain();
102 const std::shared_ptr<interface> get_bvi();
106 * Class definition for listeners to OM events
108 class event_handler : public OM::listener, public inspect::command_handler
112 virtual ~event_handler() = default;
115 * Handle a populate event
117 void handle_populate(const client_db::key_t& key);
120 * Handle a replay event
122 void handle_replay();
125 * Show the object in the Singular DB
127 void show(std::ostream& os);
130 * Get the sortable Id of the listener
132 dependency_t order() const;
136 * event_handler to register with OM
138 static event_handler m_evh;
141 * Commit the acculmulated changes into VPP. i.e. to a 'HW" write.
143 void update(const gbp_bridge_domain& obj);
146 * Find or add the instance of the bridge_domain domain in the OM
148 static std::shared_ptr<gbp_bridge_domain> find_or_add(
149 const gbp_bridge_domain& temp);
152 * It's the VPPHW class that updates the objects in HW
157 * It's the singular_db class that calls replay()
159 friend class singular_db<key_t, gbp_bridge_domain>;
162 * Sweep/reap the object if still stale
167 * HW configuration for the result of creating the endpoint
169 HW::item<uint32_t> m_id;
171 std::shared_ptr<bridge_domain> m_bd;
172 std::shared_ptr<interface> m_bvi;
173 std::shared_ptr<interface> m_uu_fwd;
176 * A map of all bridge_domains
178 static singular_db<key_t, gbp_bridge_domain> m_db;
184 * fd.io coding-style-patch-verification: ON
187 * eval: (c-set-style "mozilla")