FD.io VPP  v18.01-8-g0eacf49
Vector Packet Processing
ip_unnumbered.cpp
Go to the documentation of this file.
1 /*
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:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
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.
14  */
15 
16 #include "vom/ip_unnumbered.hpp"
18 
19 namespace VOM {
20 /**
21  * A DB of all LLDP configs
22  */
23 singular_db<ip_unnumbered::key_t, ip_unnumbered> ip_unnumbered::m_db;
24 
25 ip_unnumbered::event_handler ip_unnumbered::m_evh;
26 
28  : m_itf(itf.singular())
29  , m_l3_itf(l3_itf.singular())
30 {
31 }
32 
34  : m_itf(o.m_itf)
35  , m_l3_itf(o.m_l3_itf)
36  , m_config(o.m_config)
37 {
38 }
39 
41 {
42  sweep();
43 
44  // not in the DB anymore.
45  m_db.release(m_itf->key(), this);
46 }
47 
48 void
49 ip_unnumbered::sweep()
50 {
51  if (m_config) {
52  HW::enqueue(new ip_unnumbered_cmds::unconfig_cmd(m_config, m_itf->handle(),
53  m_l3_itf->handle()));
54  }
55  HW::write();
56 }
57 
58 void
59 ip_unnumbered::dump(std::ostream& os)
60 {
61  m_db.dump(os);
62 }
63 
64 void
65 ip_unnumbered::replay()
66 {
67  if (m_config) {
68  HW::enqueue(new ip_unnumbered_cmds::config_cmd(m_config, m_itf->handle(),
69  m_l3_itf->handle()));
70  }
71 }
72 
73 std::string
75 {
76  std::ostringstream s;
77  s << "IP Unnumbered-config:"
78  << " itf:" << m_itf->to_string() << " l3-itf:" << m_l3_itf->to_string();
79 
80  return (s.str());
81 }
82 
83 void
84 ip_unnumbered::update(const ip_unnumbered& desired)
85 {
86  if (!m_config) {
87  HW::enqueue(new ip_unnumbered_cmds::config_cmd(m_config, m_itf->handle(),
88  m_l3_itf->handle()));
89  }
90 }
91 
92 std::shared_ptr<ip_unnumbered>
93 ip_unnumbered::find_or_add(const ip_unnumbered& temp)
94 {
95  return (m_db.find_or_add(temp.m_itf->key(), temp));
96 }
97 
98 std::shared_ptr<ip_unnumbered>
100 {
101  return find_or_add(*this);
102 }
103 
104 ip_unnumbered::event_handler::event_handler()
105 {
106  OM::register_listener(this);
107  inspect::register_handler({ "ip-un" }, "IP unnumbered configurations", this);
108 }
109 
110 void
111 ip_unnumbered::event_handler::handle_replay()
112 {
113  m_db.replay();
114 }
115 
116 void
117 ip_unnumbered::event_handler::handle_populate(const client_db::key_t& key)
118 {
119  // VPP provides no dump for IP unnumbered
120 }
121 
123 ip_unnumbered::event_handler::order() const
124 {
125  return (dependency_t::BINDING);
126 }
127 
128 void
129 ip_unnumbered::event_handler::show(std::ostream& os)
130 {
131  m_db.dump(os);
132 }
133 }
134 
135 /*
136  * fd.io coding-style-patch-verification: ON
137  *
138  * Local Variables:
139  * eval: (c-set-style "mozilla")
140  * End:
141  */
A command class that configures the IP unnumbered.
std::string to_string() const
convert to string format for debug purposes
const std::string key_t
In the opflex world each entity is known by a URI which can be converted into a string.
Definition: client_db.hpp:51
static void register_handler(const std::vector< std::string > &cmds, const std::string &help, command_handler *ch)
Register a command handler for inspection.
Definition: inspect.cpp:85
static rc_t write()
Write/Execute all commands hitherto enqueued.
Definition: hw.cpp:225
A cmd class that Unconfigs L3 Config from an interface.
std::shared_ptr< ip_unnumbered > singular() const
Return the &#39;singular instance&#39; of the L3-Config that matches this object.
~ip_unnumbered()
Destructor.
A representation of IP unnumbered configuration on an interface.
A representation of an interface in VPP.
Definition: interface.hpp:41
static void dump(std::ostream &os)
Dump all ip_unnumbereds into the stream provided.
dependency_t
There needs to be a strict order in which object types are read from VPP (at boot time) and replayed ...
Definition: types.hpp:43
static void enqueue(cmd *f)
Enqueue A command for execution.
Definition: hw.cpp:189
ip_unnumbered(const interface &itf, const interface &l3_itf)
Construct a new object matching the desried state.
Then L2/objects that bind to interfaces, BD, ACLS, etc.
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
void show(char *chroot_path, int verbose)
Definition: svmtool.c:105
static bool register_listener(listener *listener)
Register a listener of events.
Definition: om.cpp:124