2 * Copyright (c) 2018 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_EXT_ITF_H__
17 #define __VOM_GBP_EXT_ITF_H__
19 #include "vom/gbp_bridge_domain.hpp"
20 #include "vom/gbp_route_domain.hpp"
21 #include "vom/interface.hpp"
22 #include "vom/singular_db.hpp"
26 * A enternal interface for GBP
28 class gbp_ext_itf : public object_base
32 * The key for a GBP ext_itf interface
34 typedef interface::key_t key_t;
37 * Construct a GBP ext_itf
39 gbp_ext_itf(const interface& itf,
40 const gbp_bridge_domain& gbd,
41 const gbp_route_domain& grd);
46 gbp_ext_itf(const gbp_ext_itf& r);
54 * Return the object's key
56 const key_t key() const;
61 bool operator==(const gbp_ext_itf& bdae) const;
64 * Return the matching 'singular instance'
66 std::shared_ptr<gbp_ext_itf> singular() const;
69 * Find the instnace of the ext_itf interface in the OM
71 static std::shared_ptr<gbp_ext_itf> find(const key_t& k);
74 * Dump all bridge_domain-doamin into the stream provided
76 static void dump(std::ostream& os);
79 * replay the object to create it in hardware
84 * Convert to string for debugging
86 std::string to_string() const;
89 * return the ext_itfulation interface's handle
91 const handle_t& handle() const;
95 * Class definition for listeners to OM events
97 class event_handler : public OM::listener, public inspect::command_handler
101 virtual ~event_handler() = default;
104 * Handle a populate event
106 void handle_populate(const client_db::key_t& key);
109 * Handle a replay event
111 void handle_replay();
114 * Show the object in the Singular DB
116 void show(std::ostream& os);
119 * Get the sortable Id of the listener
121 dependency_t order() const;
125 * event_handler to register with OM
127 static event_handler m_evh;
130 * Commit the acculmulated changes into VPP. i.e. to a 'HW" write.
132 void update(const gbp_ext_itf& obj);
135 * Find or add the instnace of the bridge_domain domain in the OM
137 static std::shared_ptr<gbp_ext_itf> find_or_add(const gbp_ext_itf& temp);
140 * It's the VPPHW class that updates the objects in HW
145 * It's the singular_db class that calls replay()
147 friend class singular_db<key_t, gbp_ext_itf>;
150 * Sweep/reap the object if still stale
155 * HW configuration for the result of creating the ext_itf
160 * The interface the ext_itf is attached to.
162 std::shared_ptr<interface> m_itf;
165 * The BD & RD the ext_itf is in
167 std::shared_ptr<gbp_bridge_domain> m_bd;
168 std::shared_ptr<gbp_route_domain> m_rd;
171 * A map of all bridge_domains
173 static singular_db<key_t, gbp_ext_itf> m_db;
179 * fd.io coding-style-patch-verification: ON
182 * eval: (c-set-style "mozilla")