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"
17 #include "vom/bridge_domain_arp_entry_cmds.hpp"
21 singular_db<bridge_domain_arp_entry::key_t, bridge_domain_arp_entry>
22 bridge_domain_arp_entry::m_db;
24 bridge_domain_arp_entry::event_handler bridge_domain_arp_entry::m_evh;
26 bridge_domain_arp_entry::bridge_domain_arp_entry(
27 const bridge_domain& bd,
28 const boost::asio::ip::address& ip_addr,
29 const mac_address_t& mac)
37 bridge_domain_arp_entry::bridge_domain_arp_entry(
38 const boost::asio::ip::address& ip_addr,
39 const mac_address_t& mac)
46 * the route goes in the default table
48 bridge_domain bd(bridge_domain::DEFAULT_TABLE);
53 bridge_domain_arp_entry::bridge_domain_arp_entry(
54 const bridge_domain_arp_entry& bde)
57 , m_ip_addr(bde.m_ip_addr)
62 bridge_domain_arp_entry::~bridge_domain_arp_entry()
66 // not in the DB anymore.
67 m_db.release(key(), this);
70 const bridge_domain_arp_entry::key_t
71 bridge_domain_arp_entry::key() const
73 return (std::make_pair(m_bd->key(), m_ip_addr));
77 bridge_domain_arp_entry::operator==(const bridge_domain_arp_entry& bdae) const
79 return ((key() == bdae.key()) && (m_mac == bdae.m_mac));
83 bridge_domain_arp_entry::sweep()
86 HW::enqueue(new bridge_domain_arp_entry_cmds::delete_cmd(m_hw, m_bd->id(),
93 bridge_domain_arp_entry::replay()
96 HW::enqueue(new bridge_domain_arp_entry_cmds::create_cmd(m_hw, m_bd->id(),
102 bridge_domain_arp_entry::to_string() const
104 std::ostringstream s;
105 s << "bridge-domain-arp-entry:[" << m_bd->to_string() << ", "
106 << m_mac.to_string() << ", " << m_ip_addr.to_string() << "]";
112 bridge_domain_arp_entry::update(const bridge_domain_arp_entry& r)
115 * create the table if it is not yet created
117 if (rc_t::OK != m_hw.rc()) {
118 HW::enqueue(new bridge_domain_arp_entry_cmds::create_cmd(m_hw, m_bd->id(),
123 std::shared_ptr<bridge_domain_arp_entry>
124 bridge_domain_arp_entry::find_or_add(const bridge_domain_arp_entry& temp)
126 return (m_db.find_or_add(temp.key(), temp));
129 std::shared_ptr<bridge_domain_arp_entry>
130 bridge_domain_arp_entry::find(const key_t& k)
132 return (m_db.find(k));
135 std::shared_ptr<bridge_domain_arp_entry>
136 bridge_domain_arp_entry::singular() const
138 return find_or_add(*this);
142 bridge_domain_arp_entry::dump(std::ostream& os)
147 bridge_domain_arp_entry::event_handler::event_handler()
149 OM::register_listener(this);
150 inspect::register_handler({ "bd-arp" },
151 "bridge domain ARP termination entries", this);
155 bridge_domain_arp_entry::event_handler::handle_replay()
161 bridge_domain_arp_entry::event_handler::handle_populate(
162 const client_db::key_t& key)
167 bridge_domain_arp_entry::event_handler::order() const
169 return (dependency_t::ENTRY);
173 bridge_domain_arp_entry::event_handler::show(std::ostream& os)
179 operator<<(std::ostream& os, const bridge_domain_arp_entry::key_t& key)
181 os << "[" << key.first << ", " << key.second << "]";
187 * fd.io coding-style-patch-verification: ON
190 * eval: (c-set-style "mozilla")