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_BRIDGE_DOMAIN_ARP_ENTRY_H__
17 #define __VOM_BRIDGE_DOMAIN_ARP_ENTRY_H__
19 #include "vom/bridge_domain.hpp"
20 #include "vom/interface.hpp"
21 #include "vom/singular_db.hpp"
22 #include "vom/types.hpp"
26 * A entry in the ARP termination table of a Bridge Domain
28 class bridge_domain_arp_entry : public object_base
32 * The key for a bridge_domain ARP entry;
33 * the BD, IP address and MAC address
35 typedef std::pair<bridge_domain::key_t, boost::asio::ip::address> key_t;
38 * Construct a bridge domain ARP Entry in the given bridge domain
40 bridge_domain_arp_entry(const bridge_domain& bd,
41 const boost::asio::ip::address& ip_addr,
42 const mac_address_t& mac);
45 * Construct a bridge domain ARP entry in the default table
47 bridge_domain_arp_entry(const boost::asio::ip::address& ip_addr,
48 const mac_address_t& mac);
53 bridge_domain_arp_entry(const bridge_domain_arp_entry& r);
58 ~bridge_domain_arp_entry();
61 * Return the object's key
63 const key_t key() const;
68 bool operator==(const bridge_domain_arp_entry& bdae) const;
71 * Return the matching 'singular instance'
73 std::shared_ptr<bridge_domain_arp_entry> singular() const;
76 * Find the instnace of the bridge_domain domain in the OM
78 static std::shared_ptr<bridge_domain_arp_entry> find(const key_t& k);
81 * Dump all bridge_domain-doamin into the stream provided
83 static void dump(std::ostream& os);
86 * replay the object to create it in hardware
91 * Convert to string for debugging
93 std::string to_string() const;
97 * Class definition for listeners to OM events
99 class event_handler : public OM::listener, public inspect::command_handler
103 virtual ~event_handler() = default;
106 * Handle a populate event
108 void handle_populate(const client_db::key_t& key);
111 * Handle a replay event
113 void handle_replay();
116 * Show the object in the Singular DB
118 void show(std::ostream& os);
121 * Get the sortable Id of the listener
123 dependency_t order() const;
127 * event_handler to register with OM
129 static event_handler m_evh;
132 * Commit the acculmulated changes into VPP. i.e. to a 'HW" write.
134 void update(const bridge_domain_arp_entry& obj);
137 * Find or add the instnace of the bridge_domain domain in the OM
139 static std::shared_ptr<bridge_domain_arp_entry> find_or_add(
140 const bridge_domain_arp_entry& 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, bridge_domain_arp_entry>;
153 * Sweep/reap the object if still stale
158 * HW configuration for the result of creating the bridge_domain
163 * The bridge_domain domain the bridge_domain is in.
165 std::shared_ptr<bridge_domain> m_bd;
170 boost::asio::ip::address m_ip_addr;
178 * A map of all bridge_domains
180 static singular_db<key_t, bridge_domain_arp_entry> m_db;
183 std::ostream& operator<<(std::ostream& os,
184 const bridge_domain_arp_entry::key_t& key);
188 * fd.io coding-style-patch-verification: ON
191 * eval: (c-set-style "mozilla")