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_ENDPOINT_GROUP_H__
17 #define __VOM_GBP_ENDPOINT_GROUP_H__
19 #include "vom/interface.hpp"
20 #include "vom/singular_db.hpp"
21 #include "vom/types.hpp"
23 #include "vom/gbp_bridge_domain.hpp"
24 #include "vom/gbp_route_domain.hpp"
29 * EPG IDs are 32 bit integers
31 typedef uint32_t epg_id_t;
34 * A entry in the ARP termination table of a Bridge Domain
36 class gbp_endpoint_group : public object_base
40 * The key for a GBP endpoint group is its ID
42 typedef epg_id_t key_t;
45 * Construct a GBP endpoint_group
47 gbp_endpoint_group(epg_id_t epg_id,
49 const gbp_route_domain& rd,
50 const gbp_bridge_domain& bd);
51 gbp_endpoint_group(epg_id_t epg_id,
52 const gbp_route_domain& rd,
53 const gbp_bridge_domain& bd);
58 gbp_endpoint_group(const gbp_endpoint_group& r);
63 ~gbp_endpoint_group();
66 * Return the object's key
68 const key_t key() const;
73 bool operator==(const gbp_endpoint_group& bdae) const;
76 * Return the matching 'singular instance'
78 std::shared_ptr<gbp_endpoint_group> singular() const;
81 * Find the instnace of the bridge_domain domain in the OM
83 static std::shared_ptr<gbp_endpoint_group> find(const key_t& k);
86 * Dump all bridge_domain-doamin into the stream provided
88 static void dump(std::ostream& os);
91 * replay the object to create it in hardware
96 * Convert to string for debugging
98 std::string to_string() const;
101 * Get the ID of the EPG
105 const std::shared_ptr<gbp_route_domain> get_route_domain();
106 const std::shared_ptr<gbp_bridge_domain> get_bridge_domain();
110 * Class definition for listeners to OM events
112 class event_handler : public OM::listener, public inspect::command_handler
116 virtual ~event_handler() = default;
119 * Handle a populate event
121 void handle_populate(const client_db::key_t& key);
124 * Handle a replay event
126 void handle_replay();
129 * Show the object in the Singular DB
131 void show(std::ostream& os);
134 * Get the sortable Id of the listener
136 dependency_t order() const;
140 * event_handler to register with OM
142 static event_handler m_evh;
145 * Commit the acculmulated changes into VPP. i.e. to a 'HW" write.
147 void update(const gbp_endpoint_group& obj);
150 * Find or add the instnace of the bridge_domain domain in the OM
152 static std::shared_ptr<gbp_endpoint_group> find_or_add(
153 const gbp_endpoint_group& temp);
156 * It's the VPPHW class that updates the objects in HW
161 * It's the singular_db class that calls replay()
163 friend class singular_db<key_t, gbp_endpoint_group>;
166 * Sweep/reap the object if still stale
171 * HW configuration for the result of creating the endpoint_group
181 * The uplink interface for the endpoint group
183 std::shared_ptr<interface> m_itf;
186 * The route-domain the EPG uses
188 std::shared_ptr<gbp_route_domain> m_rd;
191 * The bridge-domain the EPG uses
193 std::shared_ptr<gbp_bridge_domain> m_bd;
196 * A map of all bridge_domains
198 static singular_db<key_t, gbp_endpoint_group> m_db;
204 * fd.io coding-style-patch-verification: ON
207 * eval: (c-set-style "mozilla")