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/ip_unnumbered.hpp"
17 #include "vom/ip_unnumbered_cmds.hpp"
18 #include "vom/singular_db_funcs.hpp"
22 * A DB of all LLDP configs
24 singular_db<ip_unnumbered::key_t, ip_unnumbered> ip_unnumbered::m_db;
26 ip_unnumbered::event_handler ip_unnumbered::m_evh;
28 ip_unnumbered::ip_unnumbered(const interface& itf, const interface& l3_itf)
29 : m_itf(itf.singular())
30 , m_l3_itf(l3_itf.singular())
34 ip_unnumbered::ip_unnumbered(const ip_unnumbered& o)
36 , m_l3_itf(o.m_l3_itf)
37 , m_config(o.m_config)
41 ip_unnumbered::~ip_unnumbered()
45 // not in the DB anymore.
46 m_db.release(m_itf->key(), this);
50 ip_unnumbered::sweep()
53 HW::enqueue(new ip_unnumbered_cmds::unconfig_cmd(m_config, m_itf->handle(),
60 ip_unnumbered::dump(std::ostream& os)
66 ip_unnumbered::replay()
69 HW::enqueue(new ip_unnumbered_cmds::config_cmd(m_config, m_itf->handle(),
75 ip_unnumbered::to_string() const
78 s << "IP Unnumbered-config:"
79 << " itf:" << m_itf->to_string() << " l3-itf:" << m_l3_itf->to_string();
85 ip_unnumbered::update(const ip_unnumbered& desired)
88 HW::enqueue(new ip_unnumbered_cmds::config_cmd(m_config, m_itf->handle(),
93 std::shared_ptr<ip_unnumbered>
94 ip_unnumbered::find_or_add(const ip_unnumbered& temp)
96 return (m_db.find_or_add(temp.m_itf->key(), temp));
99 std::shared_ptr<ip_unnumbered>
100 ip_unnumbered::singular() const
102 return find_or_add(*this);
105 ip_unnumbered::event_handler::event_handler()
107 OM::register_listener(this);
108 inspect::register_handler({ "ip-un" }, "IP unnumbered configurations", this);
112 ip_unnumbered::event_handler::handle_replay()
118 ip_unnumbered::event_handler::handle_populate(const client_db::key_t& key)
120 std::shared_ptr<ip_unnumbered_cmds::dump_cmd> cmd =
121 std::make_shared<ip_unnumbered_cmds::dump_cmd>();
126 for (auto& ip_record : *cmd) {
127 auto& payload = ip_record.get_payload();
129 VOM_LOG(log_level_t::DEBUG) << "ip-unnumbered dump: "
130 << " itf: " << payload.sw_if_index
131 << " ip: " << payload.ip_sw_if_index;
133 std::shared_ptr<interface> itf = interface::find(payload.sw_if_index);
134 std::shared_ptr<interface> ip_itf = interface::find(payload.ip_sw_if_index);
137 ip_unnumbered ipun(*itf, *ip_itf);
138 OM::commit(key, ipun);
144 ip_unnumbered::event_handler::order() const
146 return (dependency_t::BINDING);
150 ip_unnumbered::event_handler::show(std::ostream& os)
157 * fd.io coding-style-patch-verification: ON
160 * eval: (c-set-style "mozilla")