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/arp_proxy_config.hpp"
17 #include "vom/arp_proxy_config_cmds.hpp"
18 #include "vom/singular_db_funcs.hpp"
21 singular_db<arp_proxy_config::key_t, arp_proxy_config> arp_proxy_config::m_db;
23 arp_proxy_config::event_handler arp_proxy_config::m_evh;
25 arp_proxy_config::arp_proxy_config(const boost::asio::ip::address_v4& low,
26 const boost::asio::ip::address_v4& high)
33 arp_proxy_config::arp_proxy_config(const arp_proxy_config& o)
36 , m_config(o.m_config)
40 arp_proxy_config::~arp_proxy_config()
44 // not in the DB anymore.
45 m_db.release(std::make_pair(m_low, m_high), this);
49 arp_proxy_config::sweep()
53 new arp_proxy_config_cmds::unconfig_cmd(m_config, m_low, m_high));
59 arp_proxy_config::dump(std::ostream& os)
65 arp_proxy_config::replay()
68 HW::enqueue(new arp_proxy_config_cmds::config_cmd(m_config, m_low, m_high));
73 arp_proxy_config::to_string() const
77 << " low:" << m_low.to_string() << " high:" << m_high.to_string();
83 arp_proxy_config::update(const arp_proxy_config& desired)
86 HW::enqueue(new arp_proxy_config_cmds::config_cmd(m_config, m_low, m_high));
90 std::shared_ptr<arp_proxy_config>
91 arp_proxy_config::find_or_add(const arp_proxy_config& temp)
93 return (m_db.find_or_add(std::make_pair(temp.m_low, temp.m_high), temp));
96 std::shared_ptr<arp_proxy_config>
97 arp_proxy_config::singular() const
99 return find_or_add(*this);
102 arp_proxy_config::event_handler::event_handler()
104 OM::register_listener(this);
105 inspect::register_handler({ "arp-proxy-config" }, "ARP Proxy configurations",
110 arp_proxy_config::event_handler::handle_replay()
116 arp_proxy_config::event_handler::handle_populate(const client_db::key_t& key)
118 // VPP provides no dump for ARP proxy.
122 arp_proxy_config::event_handler::order() const
124 return (dependency_t::GLOBAL);
128 arp_proxy_config::event_handler::show(std::ostream& os)
134 operator<<(std::ostream& os, const arp_proxy_config::key_t& key)
136 os << "[" << key.first << ", " << key.second << "]";
142 * fd.io coding-style-patch-verification: ON
145 * eval: (c-set-style "mozilla")