2 * Copyright (c) 2018 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/igmp_binding.hpp"
17 #include "vom/igmp_binding_cmds.hpp"
18 #include "vom/singular_db_funcs.hpp"
23 * A DB of all igmp bindings configs
25 singular_db<igmp_binding::key_t, igmp_binding> igmp_binding::m_db;
27 igmp_binding::event_handler igmp_binding::m_evh;
29 igmp_binding::igmp_binding(const interface& itf)
30 : m_itf(itf.singular())
35 igmp_binding::igmp_binding(const igmp_binding& o)
37 , m_binding(o.m_binding)
41 igmp_binding::~igmp_binding()
44 m_db.release(key(), this);
48 igmp_binding::operator==(const igmp_binding& l) const
50 return (*m_itf == *l.m_itf);
53 const igmp_binding::key_t
54 igmp_binding::key() const
56 return (m_itf->key());
63 HW::enqueue(new igmp_binding_cmds::unbind_cmd(m_binding, m_itf->handle()));
69 igmp_binding::dump(std::ostream& os)
75 igmp_binding::replay()
78 HW::enqueue(new igmp_binding_cmds::bind_cmd(m_binding, m_itf->handle()));
83 igmp_binding::to_string() const
86 s << "igmp-binding: [" << m_itf->to_string() << " mode:host]";
92 igmp_binding::update(const igmp_binding& desired)
95 * the desired state is always that the interface should be created
98 HW::enqueue(new igmp_binding_cmds::bind_cmd(m_binding, m_itf->handle()));
102 std::shared_ptr<igmp_binding>
103 igmp_binding::find_or_add(const igmp_binding& temp)
105 return (m_db.find_or_add(temp.key(), temp));
108 std::shared_ptr<igmp_binding>
109 igmp_binding::find(const key_t& k)
111 return (m_db.find(k));
114 std::shared_ptr<igmp_binding>
115 igmp_binding::singular() const
117 return find_or_add(*this);
120 std::shared_ptr<interface>
121 igmp_binding::itf() const
126 igmp_binding::event_handler::event_handler()
128 OM::register_listener(this);
129 inspect::register_handler({ "igmp-binding" }, "IGMP bindings", this);
133 igmp_binding::event_handler::handle_replay()
139 igmp_binding::event_handler::handle_populate(const client_db::key_t& key)
141 /* done with igmp_dump in igmp_listen */
145 igmp_binding::event_handler::order() const
147 return (dependency_t::BINDING);
151 igmp_binding::event_handler::show(std::ostream& os)
157 * fd.io coding-style-patch-verification: ON
160 * eval: (c-set-style "mozilla")