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 #include "vom/bridge_domain_arp_entry.hpp"
20 singular_db<bridge_domain_arp_entry::key_t, bridge_domain_arp_entry>
21 bridge_domain_arp_entry::m_db;
23 bridge_domain_arp_entry::event_handler bridge_domain_arp_entry::m_evh;
25 bridge_domain_arp_entry::bridge_domain_arp_entry(
26 const bridge_domain& bd,
27 const mac_address_t& mac,
28 const boost::asio::ip::address& ip_addr)
36 bridge_domain_arp_entry::bridge_domain_arp_entry(
37 const mac_address_t& mac,
38 const boost::asio::ip::address& ip_addr)
45 * the route goes in the default table
47 bridge_domain bd(bridge_domain::DEFAULT_TABLE);
52 bridge_domain_arp_entry::bridge_domain_arp_entry(
53 const bridge_domain_arp_entry& bde)
57 , m_ip_addr(bde.m_ip_addr)
61 bridge_domain_arp_entry::~bridge_domain_arp_entry()
65 // not in the DB anymore.
66 m_db.release(std::make_tuple(m_bd->id(), m_mac, m_ip_addr), this);
70 bridge_domain_arp_entry::sweep()
73 HW::enqueue(new delete_cmd(m_hw, m_bd->id(), m_mac, m_ip_addr));
79 bridge_domain_arp_entry::replay()
82 HW::enqueue(new create_cmd(m_hw, m_bd->id(), m_mac, m_ip_addr));
87 bridge_domain_arp_entry::to_string() const
90 s << "bridge-domain-arp-entry:[" << m_bd->to_string() << ", "
91 << m_mac.to_string() << ", " << m_ip_addr.to_string() << "]";
97 bridge_domain_arp_entry::update(const bridge_domain_arp_entry& r)
100 * create the table if it is not yet created
102 if (rc_t::OK != m_hw.rc()) {
103 HW::enqueue(new create_cmd(m_hw, m_bd->id(), m_mac, m_ip_addr));
107 std::shared_ptr<bridge_domain_arp_entry>
108 bridge_domain_arp_entry::find_or_add(const bridge_domain_arp_entry& temp)
110 return (m_db.find_or_add(
111 std::make_tuple(temp.m_bd->id(), temp.m_mac, temp.m_ip_addr), temp));
114 std::shared_ptr<bridge_domain_arp_entry>
115 bridge_domain_arp_entry::singular() const
117 return find_or_add(*this);
121 bridge_domain_arp_entry::dump(std::ostream& os)
127 operator<<(std::ostream& os, const bridge_domain_arp_entry::key_t& key)
129 os << "[" << std::get<0>(key) << ", " << std::get<1>(key) << ", "
130 << std::get<2>(key) << "]";
135 bridge_domain_arp_entry::event_handler::event_handler()
137 OM::register_listener(this);
138 inspect::register_handler({ "bd-arp" },
139 "bridge domain ARP termination entries", this);
143 bridge_domain_arp_entry::event_handler::handle_replay()
149 bridge_domain_arp_entry::event_handler::handle_populate(
150 const client_db::key_t& key)
155 bridge_domain_arp_entry::event_handler::order() const
157 return (dependency_t::ENTRY);
161 bridge_domain_arp_entry::event_handler::show(std::ostream& os)
167 * fd.io coding-style-patch-verification: ON
170 * eval: (c-set-style "mozilla")