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_ROUTE_DOMAIN_H__
17 #define __VOM_GBP_ROUTE_DOMAIN_H__
19 #include "vom/interface.hpp"
20 #include "vom/route_domain.hpp"
21 #include "vom/singular_db.hpp"
22 #include "vom/types.hpp"
27 * A entry in the ARP termination table of a Route Domain
29 class gbp_route_domain : public object_base
33 * The key for a route_domain is the pari of EPG-IDs
35 typedef route_domain::key_t key_t;
38 * Construct a GBP route_domain
40 gbp_route_domain(const route_domain& rd);
42 gbp_route_domain(const route_domain& rd,
43 const interface& ip4_uu_fwd,
44 const interface& ip6_uu_fwd);
49 gbp_route_domain(const gbp_route_domain& r);
57 * Return the object's key
59 const key_t key() const;
62 * Return the route domain's VPP ID
69 bool operator==(const gbp_route_domain& rdae) const;
72 * Return the matching 'singular instance'
74 std::shared_ptr<gbp_route_domain> singular() const;
77 * Find the instnace of the route_domain domain in the OM
79 static std::shared_ptr<gbp_route_domain> find(const key_t& k);
82 * Dump all route_domain-doamin into the stream provided
84 static void dump(std::ostream& os);
87 * replay the object to create it in hardware
92 * Convert to string for debugging
94 std::string to_string() const;
98 * Class definition for listeners to OM events
100 class event_handler : public OM::listener, public inspect::command_handler
104 virtual ~event_handler() = default;
107 * Handle a populate event
109 void handle_populate(const client_db::key_t& key);
112 * Handle a replay event
114 void handle_replay();
117 * Show the object in the Singular DB
119 void show(std::ostream& os);
122 * Get the sortable Id of the listener
124 dependency_t order() const;
128 * event_handler to register with OM
130 static event_handler m_evh;
133 * Commit the acculmulated changes into VPP. i.e. to a 'HW" write.
135 void update(const gbp_route_domain& obj);
138 * Find or add the instance of the route_domain domain in the OM
140 static std::shared_ptr<gbp_route_domain> find_or_add(
141 const gbp_route_domain& temp);
144 * It's the VPPHW class that updates the objects in HW
149 * It's the singular_db class that calls replay()
151 friend class singular_db<key_t, gbp_route_domain>;
154 * Sweep/reap the object if still stale
159 * HW configuration for the result of creating the endpoint
161 HW::item<uint32_t> m_id;
163 std::shared_ptr<route_domain> m_rd;
164 std::shared_ptr<interface> m_ip4_uu_fwd;
165 std::shared_ptr<interface> m_ip6_uu_fwd;
168 * A map of all route_domains
170 static singular_db<key_t, gbp_route_domain> m_db;
176 * fd.io coding-style-patch-verification: ON
179 * eval: (c-set-style "mozilla")