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_VXLAN_TUNNEL_H__
17 #define __VOM_VXLAN_TUNNEL_H__
20 #include "vom/inspect.hpp"
21 #include "vom/interface.hpp"
22 #include "vom/object_base.hpp"
24 #include "vom/prefix.hpp"
25 #include "vom/route_domain.hpp"
26 #include "vom/singular_db.hpp"
30 * A representation of a VXLAN Tunnel in VPP
32 class vxlan_tunnel : public interface
36 * Combaintion of attributes that are a unique key
46 * Constructor taking endpoint values
48 endpoint_t(const boost::asio::ip::address& src,
49 const boost::asio::ip::address& dst,
53 * less-than operator for map storage
55 bool operator<(const endpoint_t& o) const;
60 bool operator==(const endpoint_t& o) const;
63 * Debug print function
65 std::string to_string() const;
68 * The src IP address of the endpoint
70 boost::asio::ip::address src;
73 * The destination IP address of the endpoint
75 boost::asio::ip::address dst;
78 * The VNI of the endpoint
84 * Construct a new object matching the desried state
86 vxlan_tunnel(const boost::asio::ip::address& src,
87 const boost::asio::ip::address& dst,
91 * Construct a new object matching the desried state with a handle
94 vxlan_tunnel(const handle_t& hdl,
95 const boost::asio::ip::address& src,
96 const boost::asio::ip::address& dst,
107 vxlan_tunnel(const vxlan_tunnel& o);
110 * Return the matching 'singular instance'
112 std::shared_ptr<vxlan_tunnel> singular() const;
115 * Debug rpint function
117 virtual std::string to_string() const;
120 * Return VPP's handle to this object
122 const handle_t& handle() const;
125 * Dump all L3Configs into the stream provided
127 static void dump(std::ostream& os);
131 * Class definition for listeners to OM events
133 class event_handler : public OM::listener, public inspect::command_handler
137 virtual ~event_handler() = default;
140 * Handle a populate event
142 void handle_populate(const client_db::key_t& key);
145 * Handle a replay event
147 void handle_replay();
150 * Show the object in the Singular DB
152 void show(std::ostream& os);
155 * Get the sortable Id of the listener
157 dependency_t order() const;
161 * Event handle to register with OM
163 static event_handler m_evh;
166 * Commit the acculmulated changes into VPP. i.e. to a 'HW" write.
168 void update(const vxlan_tunnel& obj);
171 * Return the matching 'instance' of the sub-interface
172 * over-ride from the base class
174 std::shared_ptr<interface> singular_i() const;
177 * Find the VXLAN tunnel in the OM
179 static std::shared_ptr<vxlan_tunnel> find_or_add(const vxlan_tunnel& temp);
182 * It's the VPPHW class that updates the objects in HW
187 * It's the singular_db class that calls replay()
189 friend class singular_db<endpoint_t, vxlan_tunnel>;
192 * Sweep/reap the object if still stale
197 * replay the object to create it in hardware
207 * A map of all VLAN tunnela against thier key
209 static singular_db<endpoint_t, vxlan_tunnel> m_db;
212 * Construct a unique name for the tunnel
214 static std::string mk_name(const boost::asio::ip::address& src,
215 const boost::asio::ip::address& dst,
220 * Ostream output for a tunnel endpoint
222 std::ostream& operator<<(std::ostream& os, const vxlan_tunnel::endpoint_t& ep);
227 * fd.io coding-style-patch-verification: ON
230 * eval: (c-set-style "mozilla")