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_binding.hpp"
17 #include "vom/arp_proxy_binding_cmds.hpp"
18 #include "vom/singular_db_funcs.hpp"
23 * A DB of all ARP proxy bindings configs
25 singular_db<interface::key_t, arp_proxy_binding> arp_proxy_binding::m_db;
27 arp_proxy_binding::event_handler arp_proxy_binding::m_evh;
29 arp_proxy_binding::arp_proxy_binding(const interface& itf)
30 : m_itf(itf.singular())
35 arp_proxy_binding::arp_proxy_binding(const arp_proxy_binding& o)
37 , m_binding(o.m_binding)
41 arp_proxy_binding::~arp_proxy_binding()
44 m_db.release(m_itf->key(), this);
48 arp_proxy_binding::sweep()
52 new arp_proxy_binding_cmds::unbind_cmd(m_binding, m_itf->handle()));
58 arp_proxy_binding::dump(std::ostream& os)
64 arp_proxy_binding::replay()
68 new arp_proxy_binding_cmds::bind_cmd(m_binding, m_itf->handle()));
73 arp_proxy_binding::to_string() const
76 s << "ArpProxy-binding: " << m_itf->to_string();
82 arp_proxy_binding::update(const arp_proxy_binding& desired)
85 * the desired state is always that the interface should be created
89 new arp_proxy_binding_cmds::bind_cmd(m_binding, m_itf->handle()));
93 std::shared_ptr<arp_proxy_binding>
94 arp_proxy_binding::find_or_add(const arp_proxy_binding& temp)
96 return (m_db.find_or_add(temp.m_itf->key(), temp));
99 std::shared_ptr<arp_proxy_binding>
100 arp_proxy_binding::singular() const
102 return find_or_add(*this);
105 arp_proxy_binding::event_handler::event_handler()
107 OM::register_listener(this);
108 inspect::register_handler({ "arp-proxy-binding" }, "ARP proxy bindings",
113 arp_proxy_binding::event_handler::handle_replay()
119 arp_proxy_binding::event_handler::handle_populate(const client_db::key_t& key)
121 std::shared_ptr<arp_proxy_binding_cmds::dump_cmd> cmd =
122 std::make_shared<arp_proxy_binding_cmds::dump_cmd>();
127 for (auto& record : *cmd) {
128 auto& payload = record.get_payload();
130 std::shared_ptr<interface> itf = interface::find(payload.sw_if_index);
133 arp_proxy_binding ab(*itf);
136 VOM_LOG(log_level_t::ERROR) << "arp-proxy-binding dump:"
137 << " itf:" << payload.sw_if_index;
143 arp_proxy_binding::event_handler::order() const
145 return (dependency_t::BINDING);
149 arp_proxy_binding::event_handler::show(std::ostream& os)
155 * fd.io coding-style-patch-verification: ON
158 * eval: (c-set-style "mozilla")