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_VXLAN_H__
17 #define __VOM_GBP_VXLAN_H__
19 #include "vom/gbp_bridge_domain.hpp"
20 #include "vom/gbp_route_domain.hpp"
22 #include "vom/inspect.hpp"
23 #include "vom/interface.hpp"
24 #include "vom/singular_db.hpp"
28 * A representation of a GBP_VXLAN Tunnel in VPP
30 class gbp_vxlan : public interface
36 typedef uint32_t key_t;
39 * Construct a new object matching the desried state
41 gbp_vxlan(uint32_t vni,
42 const gbp_bridge_domain& gbd,
43 const boost::asio::ip::address_v4& src);
44 gbp_vxlan(uint32_t vni,
45 const gbp_route_domain& grd,
46 const boost::asio::ip::address_v4& src);
56 gbp_vxlan(const gbp_vxlan& o);
58 bool operator==(const gbp_vxlan& vt) const;
61 * Return the matching 'singular instance'
63 std::shared_ptr<gbp_vxlan> singular() const;
66 * Return the object's key
68 const key_t key() const;
71 * Debug rpint function
73 virtual std::string to_string() const;
76 * Return VPP's handle to this object
78 const handle_t& handle() const;
81 * Dump all L3Configs into the stream provided
83 static void dump(std::ostream& os);
86 * Find the GBP_VXLAN tunnel in the OM
88 static std::shared_ptr<gbp_vxlan> find(const key_t k);
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 handle 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_vxlan& obj);
132 * Return the matching 'instance' of the sub-interface
133 * over-ride from the base class
135 std::shared_ptr<interface> singular_i() const;
138 * Find the GBP_VXLAN tunnel in the OM
140 static std::shared_ptr<gbp_vxlan> find_or_add(const gbp_vxlan& temp);
143 * It's the VPPHW class that updates the objects in HW
148 * It's the singular_db class that calls replay()
150 friend class singular_db<key_t, gbp_vxlan>;
153 * Sweep/reap the object if still stale
158 * replay the object to create it in hardware
166 std::shared_ptr<gbp_bridge_domain> m_gbd;
167 std::shared_ptr<gbp_route_domain> m_grd;
168 boost::asio::ip::address_v4 m_src;
171 * A map of all VLAN tunnela against thier key
173 static singular_db<key_t, gbp_vxlan> m_db;
176 * Construct a unique name for the tunnel
178 static std::string mk_name(uint32_t vni);
184 * fd.io coding-style-patch-verification: ON
187 * eval: (c-set-style "mozilla")