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_CONTRACT_H__
17 #define __VOM_GBP_CONTRACT_H__
19 #include "vom/acl_list.hpp"
20 #include "vom/gbp_endpoint.hpp"
21 #include "vom/interface.hpp"
22 #include "vom/singular_db.hpp"
23 #include "vom/types.hpp"
28 * A entry in the ARP termination table of a Bridge Domain
30 class gbp_contract : public object_base
34 * The key for a contract is the pari of EPG-IDs
36 typedef std::pair<epg_id_t, epg_id_t> key_t;
39 * Construct a GBP contract
41 gbp_contract(epg_id_t src_epg_id,
43 const ACL::l3_list& acl);
48 gbp_contract(const gbp_contract& r);
56 * Return the object's key
58 const key_t key() const;
63 bool operator==(const gbp_contract& bdae) const;
66 * Return the matching 'singular instance'
68 std::shared_ptr<gbp_contract> singular() const;
71 * Find the instnace of the bridge_domain domain in the OM
73 static std::shared_ptr<gbp_contract> find(const key_t& k);
76 * Dump all bridge_domain-doamin into the stream provided
78 static void dump(std::ostream& os);
81 * replay the object to create it in hardware
86 * Convert to string for debugging
88 std::string to_string() const;
92 * Class definition for listeners to OM events
94 class event_handler : public OM::listener, public inspect::command_handler
98 virtual ~event_handler() = default;
101 * Handle a populate event
103 void handle_populate(const client_db::key_t& key);
106 * Handle a replay event
108 void handle_replay();
111 * Show the object in the Singular DB
113 void show(std::ostream& os);
116 * Get the sortable Id of the listener
118 dependency_t order() const;
122 * event_handler to register with OM
124 static event_handler m_evh;
127 * Commit the acculmulated changes into VPP. i.e. to a 'HW" write.
129 void update(const gbp_contract& obj);
132 * Find or add the instance of the contract domain in the OM
134 static std::shared_ptr<gbp_contract> find_or_add(const gbp_contract& temp);
137 * It's the VPPHW class that updates the objects in HW
142 * It's the singular_db class that calls replay()
144 friend class singular_db<key_t, gbp_contract>;
147 * Sweep/reap the object if still stale
152 * HW configuration for the result of creating the endpoint
159 epg_id_t m_src_epg_id;
162 * The destination EPG ID
164 epg_id_t m_dst_epg_id;
167 * The ACL applied to traffic between the gourps
169 std::shared_ptr<ACL::l3_list> m_acl;
172 * A map of all bridge_domains
174 static singular_db<key_t, gbp_contract> m_db;
177 std::ostream& operator<<(std::ostream& os, const gbp_contract::key_t& key);
181 * fd.io coding-style-patch-verification: ON
184 * eval: (c-set-style "mozilla")