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_RECIRC_H__
17 #define __VOM_GBP_RECIRC_H__
19 #include "vom/gbp_endpoint_group.hpp"
20 #include "vom/interface.hpp"
21 #include "vom/singular_db.hpp"
25 * A recirculation interface for GBP use pre/post NAT
27 class gbp_recirc : public object_base
31 * The key for a GBP recirc interface
33 typedef interface::key_t key_t;
35 struct type_t : public enum_base<type_t>
38 * Internal recirclation interfaces accept per-NAT translation
39 * traffic from the external/NAT EPG and inject into the
40 * private/NAT-inside EPG
42 const static type_t INTERNAL;
45 * External recirculation interfaces accept post-NAT translation
46 * traffic from the internal EPG and inject into the
49 const static type_t EXTERNAL;
52 type_t(int v, const std::string s);
56 * Construct a GBP recirc
58 gbp_recirc(const interface& itf,
60 const gbp_endpoint_group& epg);
65 gbp_recirc(const gbp_recirc& r);
73 * Return the object's key
75 const key_t key() const;
80 bool operator==(const gbp_recirc& bdae) const;
83 * Return the matching 'singular instance'
85 std::shared_ptr<gbp_recirc> singular() const;
88 * Find the instnace of the recirc interface in the OM
90 static std::shared_ptr<gbp_recirc> find(const key_t& k);
93 * Dump all bridge_domain-doamin into the stream provided
95 static void dump(std::ostream& os);
98 * replay the object to create it in hardware
103 * Convert to string for debugging
105 std::string to_string() const;
108 * return the recirculation interface's handle
110 const handle_t& handle() const;
114 * Class definition for listeners to OM events
116 class event_handler : public OM::listener, public inspect::command_handler
120 virtual ~event_handler() = default;
123 * Handle a populate event
125 void handle_populate(const client_db::key_t& key);
128 * Handle a replay event
130 void handle_replay();
133 * Show the object in the Singular DB
135 void show(std::ostream& os);
138 * Get the sortable Id of the listener
140 dependency_t order() const;
144 * event_handler to register with OM
146 static event_handler m_evh;
149 * Commit the acculmulated changes into VPP. i.e. to a 'HW" write.
151 void update(const gbp_recirc& obj);
154 * Find or add the instnace of the bridge_domain domain in the OM
156 static std::shared_ptr<gbp_recirc> find_or_add(const gbp_recirc& temp);
159 * It's the VPPHW class that updates the objects in HW
164 * It's the singular_db class that calls replay()
166 friend class singular_db<key_t, gbp_recirc>;
169 * Sweep/reap the object if still stale
174 * HW configuration for the result of creating the recirc
179 * The interface the recirc is attached to.
181 std::shared_ptr<interface> m_itf;
184 * Is the reicrc for the external (i.e. post-NAT) or internal
189 * The EPG the recirc is in
191 std::shared_ptr<gbp_endpoint_group> m_epg;
194 * A map of all bridge_domains
196 static singular_db<key_t, gbp_recirc> m_db;
202 * fd.io coding-style-patch-verification: ON
205 * eval: (c-set-style "mozilla")