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_BINDING_H__
17 #define __VOM_ARP_PROXY_BINDING_H__
19 #include "vom/arp_proxy_config.hpp"
21 #include "vom/inspect.hpp"
22 #include "vom/interface.hpp"
23 #include "vom/object_base.hpp"
25 #include "vom/singular_db.hpp"
29 * A representation of LLDP client configuration on an interface
31 class arp_proxy_binding : public object_base
35 * Construct a new object matching the desried state
37 arp_proxy_binding(const interface& itf, const arp_proxy_config& proxy_cfg);
42 arp_proxy_binding(const arp_proxy_binding& o);
50 * Return the 'singular' of the LLDP binding that matches this object
52 std::shared_ptr<arp_proxy_binding> singular() const;
55 * convert to string format for debug purposes
57 std::string to_string() const;
60 * Dump all LLDP bindings into the stream provided
62 static void dump(std::ostream& os);
66 * Class definition for listeners to OM events
68 class event_handler : public OM::listener, public inspect::command_handler
72 virtual ~event_handler() = default;
75 * Handle a populate event
77 void handle_populate(const client_db::key_t& key);
80 * Handle a replay event
85 * Show the object in the Singular DB
87 void show(std::ostream& os);
90 * Get the sortable Id of the listener
92 dependency_t order() const;
96 * event_handler to register with OM
98 static event_handler m_evh;
101 * Enquue commonds to the VPP command Q for the update
103 void update(const arp_proxy_binding& obj);
106 * Find or add LLDP binding to the OM
108 static std::shared_ptr<arp_proxy_binding> find_or_add(
109 const arp_proxy_binding& temp);
112 * It's the OM class that calls singular()
117 * It's the singular_db class that calls replay()
119 friend class singular_db<interface::key_type, arp_proxy_binding>;
122 * Sweep/reap the object if still stale
127 * replay the object to create it in hardware
132 * A reference counting pointer to the interface on which LLDP config
133 * resides. By holding the reference here, we can guarantee that
134 * this object will outlive the interface
136 const std::shared_ptr<interface> m_itf;
139 * A reference counting pointer to the prxy config.
141 const std::shared_ptr<arp_proxy_config> m_arp_proxy_cfg;
144 * HW configuration for the binding. The bool representing the
147 HW::item<bool> m_binding;
150 * A map of all ArpProxy bindings keyed against the interface.
152 static singular_db<interface::key_type, arp_proxy_binding> m_db;
157 * fd.io coding-style-patch-verification: ON
160 * eval: (c-set-style "mozilla")