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__
20 #include "vom/inspect.hpp"
21 #include "vom/object_base.hpp"
23 #include "vom/singular_db.hpp"
27 * A representation of LLDP client configuration on an interface
29 class arp_proxy_config : public object_base
35 typedef std::pair<boost::asio::ip::address_v4, boost::asio::ip::address_v4>
39 * Construct a new object matching the desried state
41 arp_proxy_config(const boost::asio::ip::address_v4& low,
42 const boost::asio::ip::address_v4& high);
47 arp_proxy_config(const arp_proxy_config& o);
55 * Return the 'singular' of the LLDP config that matches this object
57 std::shared_ptr<arp_proxy_config> singular() const;
60 * convert to string format for debug purposes
62 std::string to_string() const;
65 * Dump all LLDP configs into the stream provided
67 static void dump(std::ostream& os);
71 * Class definition for listeners to OM events
73 class event_handler : public OM::listener, public inspect::command_handler
77 virtual ~event_handler() = default;
80 * Handle a populate event
82 void handle_populate(const client_db::key_t& key);
85 * Handle a replay event
90 * Show the object in the Singular DB
92 void show(std::ostream& os);
95 * Get the sortable Id of the listener
97 dependency_t order() const;
101 * event_handler to register with OM
103 static event_handler m_evh;
106 * Enquue commonds to the VPP command Q for the update
108 void update(const arp_proxy_config& obj);
111 * Find or add LLDP config to the OM
113 static std::shared_ptr<arp_proxy_config> find_or_add(
114 const arp_proxy_config& temp);
117 * It's the OM class that calls singular()
122 * It's the singular_db class that calls replay()
124 friend class singular_db<arp_proxy_config::key_t, arp_proxy_config>;
127 * Sweep/reap the object if still stale
132 * replay the object to create it in hardware
139 const boost::asio::ip::address_v4 m_low;
140 const boost::asio::ip::address_v4 m_high;
143 * A map of all ArpProxy configs keyed against the interface.
145 static singular_db<arp_proxy_config::key_t, arp_proxy_config> m_db;
148 * HW configuration for the config. The bool representing the
149 * do/don't configured/unconfigured.
151 HW::item<bool> m_config;
154 std::ostream& operator<<(std::ostream& os, const arp_proxy_config::key_t& key);
158 * fd.io coding-style-patch-verification: ON
161 * eval: (c-set-style "mozilla")