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/lldp_global.hpp"
17 #include "vom/lldp_global_cmds.hpp"
18 #include "vom/singular_db_funcs.hpp"
22 * A DB of all LLDP configs
24 singular_db<std::string, lldp_global> lldp_global::m_db;
26 lldp_global::event_handler lldp_global::m_evh;
28 lldp_global::lldp_global(const std::string& system_name,
31 : m_system_name(system_name)
33 , m_tx_interval(tx_interval)
37 lldp_global::lldp_global(const lldp_global& o)
38 : m_system_name(o.m_system_name)
39 , m_tx_hold(o.m_tx_hold)
40 , m_tx_interval(o.m_tx_interval)
44 lldp_global::~lldp_global()
48 // not in the DB anymore.
49 m_db.release(m_system_name, this);
52 const lldp_global::key_t&
53 lldp_global::key() const
55 return (m_system_name);
59 lldp_global::operator==(const lldp_global& l) const
61 return ((key() == l.key()) && (m_tx_hold == l.m_tx_hold) &&
62 (m_tx_interval == l.m_tx_interval));
68 // no means to remove this in VPP
72 lldp_global::dump(std::ostream& os)
81 HW::enqueue(new lldp_global_cmds::config_cmd(m_binding, m_system_name,
82 m_tx_hold, m_tx_interval));
87 lldp_global::to_string() const
91 << " system_name:" << m_system_name << " tx-hold:" << m_tx_hold
92 << " tx-interval:" << m_tx_interval;
98 lldp_global::update(const lldp_global& desired)
101 HW::enqueue(new lldp_global_cmds::config_cmd(m_binding, m_system_name,
102 m_tx_hold, m_tx_interval));
106 std::shared_ptr<lldp_global>
107 lldp_global::find_or_add(const lldp_global& temp)
109 return (m_db.find_or_add(temp.key(), temp));
112 std::shared_ptr<lldp_global>
113 lldp_global::find(const key_t& k)
115 return (m_db.find(k));
118 std::shared_ptr<lldp_global>
119 lldp_global::singular() const
121 return find_or_add(*this);
124 lldp_global::event_handler::event_handler()
126 OM::register_listener(this);
127 inspect::register_handler({ "lldp-global" }, "LLDP global configurations",
132 lldp_global::event_handler::handle_replay()
138 lldp_global::event_handler::handle_populate(const client_db::key_t& key)
144 lldp_global::event_handler::order() const
146 return (dependency_t::GLOBAL);
150 lldp_global::event_handler::show(std::ostream& os)
157 * fd.io coding-style-patch-verification: ON
160 * eval: (c-set-style "mozilla")