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_ARP_PROXY_CONFIG_H__
17 #define __VOM_ARP_PROXY_CONFIG_H__
19 #include "vom/dump_cmd.hpp"
21 #include "vom/inspect.hpp"
22 #include "vom/object_base.hpp"
24 #include "vom/rpc_cmd.hpp"
25 #include "vom/singular_db.hpp"
27 #include <vapi/vpe.api.vapi.hpp>
31 * A representation of LLDP client configuration on an interface
33 class arp_proxy_config : public object_base
39 typedef std::pair<boost::asio::ip::address_v4, boost::asio::ip::address_v4>
43 * Construct a new object matching the desried state
45 arp_proxy_config(const boost::asio::ip::address_v4& low,
46 const boost::asio::ip::address_v4& high);
51 arp_proxy_config(const arp_proxy_config& o);
59 * Return the 'singular' of the LLDP config that matches this object
61 std::shared_ptr<arp_proxy_config> singular() const;
64 * convert to string format for debug purposes
66 std::string to_string() const;
69 * Dump all LLDP configs into the stream provided
71 static void dump(std::ostream& os);
74 * A command class that adds the ARP Proxy config
77 : public rpc_cmd<HW::item<bool>, rc_t, vapi::Proxy_arp_add_del>
83 config_cmd(HW::item<bool>& item,
84 const boost::asio::ip::address_v4& lo,
85 const boost::asio::ip::address_v4& high);
88 * Issue the command to VPP/HW
90 rc_t issue(connection& con);
92 * convert to string format for debug purposes
94 std::string to_string() const;
97 * Comparison operator - only used for UT
99 bool operator==(const config_cmd& i) const;
105 const boost::asio::ip::address_v4 m_low;
106 const boost::asio::ip::address_v4 m_high;
110 * A cmd class that Unconfigs ArpProxy Config from an interface
113 : public rpc_cmd<HW::item<bool>, rc_t, vapi::Proxy_arp_add_del>
119 unconfig_cmd(HW::item<bool>& item,
120 const boost::asio::ip::address_v4& lo,
121 const boost::asio::ip::address_v4& hig);
124 * Issue the command to VPP/HW
126 rc_t issue(connection& con);
128 * convert to string format for debug purposes
130 std::string to_string() const;
133 * Comparison operator - only used for UT
135 bool operator==(const unconfig_cmd& i) const;
141 const boost::asio::ip::address_v4 m_low;
142 const boost::asio::ip::address_v4 m_high;
147 * Class definition for listeners to OM events
149 class event_handler : public OM::listener, public inspect::command_handler
153 virtual ~event_handler() = default;
156 * Handle a populate event
158 void handle_populate(const client_db::key_t& key);
161 * Handle a replay event
163 void handle_replay();
166 * Show the object in the Singular DB
168 void show(std::ostream& os);
171 * Get the sortable Id of the listener
173 dependency_t order() const;
177 * event_handler to register with OM
179 static event_handler m_evh;
182 * Enquue commonds to the VPP command Q for the update
184 void update(const arp_proxy_config& obj);
187 * Find or add LLDP config to the OM
189 static std::shared_ptr<arp_proxy_config> find_or_add(
190 const arp_proxy_config& temp);
193 * It's the OM class that calls singular()
198 * It's the singular_db class that calls replay()
200 friend class singular_db<arp_proxy_config::key_t, arp_proxy_config>;
203 * Sweep/reap the object if still stale
208 * replay the object to create it in hardware
215 const boost::asio::ip::address_v4 m_low;
216 const boost::asio::ip::address_v4 m_high;
219 * A map of all ArpProxy configs keyed against the interface.
221 static singular_db<arp_proxy_config::key_t, arp_proxy_config> m_db;
224 * HW configuration for the config. The bool representing the
225 * do/don't configured/unconfigured.
227 HW::item<bool> m_config;
230 std::ostream& operator<<(std::ostream& os, const arp_proxy_config::key_t& key);
234 * fd.io coding-style-patch-verification: ON
237 * eval: (c-set-style "mozilla")