FD.io VPP  v18.01.2-1-g9b554f3
Vector Packet Processing
arp_proxy_binding.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 
18 
19 namespace VOM {
20 
21 /**
22  * A DB of all ARP proxy bindings configs
23  */
24 singular_db<interface::key_t, arp_proxy_binding> arp_proxy_binding::m_db;
25 
26 arp_proxy_binding::event_handler arp_proxy_binding::m_evh;
27 
29  const arp_proxy_config& proxy_cfg)
30  : m_itf(itf.singular())
31  , m_arp_proxy_cfg(proxy_cfg.singular())
32  , m_binding(true)
33 {
34 }
35 
37  : m_itf(o.m_itf)
38  , m_arp_proxy_cfg(o.m_arp_proxy_cfg)
39  , m_binding(o.m_binding)
40 {
41 }
42 
44 {
45  sweep();
46 
47  // not in the DB anymore.
48  m_db.release(m_itf->key(), this);
49 }
50 
51 void
52 arp_proxy_binding::sweep()
53 {
54  if (m_binding) {
56  new arp_proxy_binding_cmds::unbind_cmd(m_binding, m_itf->handle()));
57  }
58  HW::write();
59 }
60 
61 void
62 arp_proxy_binding::dump(std::ostream& os)
63 {
64  m_db.dump(os);
65 }
66 
67 void
68 arp_proxy_binding::replay()
69 {
70  if (m_binding) {
72  new arp_proxy_binding_cmds::bind_cmd(m_binding, m_itf->handle()));
73  }
74 }
75 
76 std::string
78 {
79  std::ostringstream s;
80  s << "ArpProxy-binding: " << m_itf->to_string();
81 
82  return (s.str());
83 }
84 
85 void
86 arp_proxy_binding::update(const arp_proxy_binding& desired)
87 {
88  /*
89  * the desired state is always that the interface should be created
90  */
91  if (!m_binding) {
93  new arp_proxy_binding_cmds::bind_cmd(m_binding, m_itf->handle()));
94  }
95 }
96 
97 std::shared_ptr<arp_proxy_binding>
98 arp_proxy_binding::find_or_add(const arp_proxy_binding& temp)
99 {
100  return (m_db.find_or_add(temp.m_itf->key(), temp));
101 }
102 
103 std::shared_ptr<arp_proxy_binding>
105 {
106  return find_or_add(*this);
107 }
108 
109 arp_proxy_binding::event_handler::event_handler()
110 {
111  OM::register_listener(this);
112  inspect::register_handler({ "arp-proxy" }, "ARP proxy bindings", this);
113 }
114 
115 void
116 arp_proxy_binding::event_handler::handle_replay()
117 {
118  m_db.replay();
119 }
120 
121 void
122 arp_proxy_binding::event_handler::handle_populate(const client_db::key_t& key)
123 {
124  // FIXME
125 }
126 
128 arp_proxy_binding::event_handler::order() const
129 {
130  return (dependency_t::BINDING);
131 }
132 
133 void
135 {
136  m_db.dump(os);
137 }
138 }
139 /*
140  * fd.io coding-style-patch-verification: ON
141  *
142  * Local Variables:
143  * eval: (c-set-style "mozilla")
144  * End:
145  */
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
std::shared_ptr< arp_proxy_binding > singular() const
Return the &#39;singular&#39; of the LLDP binding that matches this object.
static void dump(std::ostream &os)
Dump all LLDP bindings into the stream provided.
std::string to_string() const
convert to string format for debug purposes
A representation of LLDP client configuration on an interface.
A cmd class that Unbinds ArpProxy Config from an interface.
A representation of an interface in VPP.
Definition: interface.hpp:41
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
A representation of LLDP client configuration on an interface.
Then L2/objects that bind to interfaces, BD, ACLS, etc.
A command class that binds the LLDP config to the interface.
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
void show(char *chroot_path, int verbose)
Definition: svmtool.c:105
arp_proxy_binding(const interface &itf, const arp_proxy_config &proxy_cfg)
Construct a new object matching the desried state.
static bool register_listener(listener *listener)
Register a listener of events.
Definition: om.cpp:124
~arp_proxy_binding()
Destructor.