FD.io VPP  v18.01.2-1-g9b554f3
Vector Packet Processing
bridge_domain_arp_entry.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 singular_db<bridge_domain_arp_entry::key_t, bridge_domain_arp_entry>
22  bridge_domain_arp_entry::m_db;
23 
24 bridge_domain_arp_entry::event_handler bridge_domain_arp_entry::m_evh;
25 
27  const bridge_domain& bd,
28  const boost::asio::ip::address& ip_addr,
29  const mac_address_t& mac)
30  : m_hw(false)
31  , m_bd(bd.singular())
32  , m_ip_addr(ip_addr)
33  , m_mac(mac)
34 {
35 }
36 
38  const boost::asio::ip::address& ip_addr,
39  const mac_address_t& mac)
40  : m_hw(false)
41  , m_bd(nullptr)
42  , m_ip_addr(ip_addr)
43  , m_mac(mac)
44 {
45  /*
46  * the route goes in the default table
47  */
49 
50  m_bd = bd.singular();
51 }
52 
54  const bridge_domain_arp_entry& bde)
55  : m_hw(bde.m_hw)
56  , m_bd(bde.m_bd)
57  , m_ip_addr(bde.m_ip_addr)
58  , m_mac(bde.m_mac)
59 {
60 }
61 
63 {
64  sweep();
65 
66  // not in the DB anymore.
67  m_db.release(key(), this);
68 }
69 
72 {
73  return (std::make_pair(m_bd->key(), m_ip_addr));
74 }
75 
76 bool
78 {
79  return ((key() == bdae.key()) && (m_mac == bdae.m_mac));
80 }
81 
82 void
83 bridge_domain_arp_entry::sweep()
84 {
85  if (m_hw) {
87  m_mac, m_ip_addr));
88  }
89  HW::write();
90 }
91 
92 void
94 {
95  if (m_hw) {
97  m_mac, m_ip_addr));
98  }
99 }
100 
101 std::string
103 {
104  std::ostringstream s;
105  s << "bridge-domain-arp-entry:[" << m_bd->to_string() << ", "
106  << m_mac.to_string() << ", " << m_ip_addr.to_string() << "]";
107 
108  return (s.str());
109 }
110 
111 void
112 bridge_domain_arp_entry::update(const bridge_domain_arp_entry& r)
113 {
114  /*
115  * create the table if it is not yet created
116  */
117  if (rc_t::OK != m_hw.rc()) {
119  m_mac, m_ip_addr));
120  }
121 }
122 
123 std::shared_ptr<bridge_domain_arp_entry>
124 bridge_domain_arp_entry::find_or_add(const bridge_domain_arp_entry& temp)
125 {
126  return (m_db.find_or_add(temp.key(), temp));
127 }
128 
129 std::shared_ptr<bridge_domain_arp_entry>
131 {
132  return (m_db.find(k));
133 }
134 
135 std::shared_ptr<bridge_domain_arp_entry>
137 {
138  return find_or_add(*this);
139 }
140 
141 void
143 {
144  m_db.dump(os);
145 }
146 
147 bridge_domain_arp_entry::event_handler::event_handler()
148 {
149  OM::register_listener(this);
150  inspect::register_handler({ "bd-arp" },
151  "bridge domain ARP termination entries", this);
152 }
153 
154 void
155 bridge_domain_arp_entry::event_handler::handle_replay()
156 {
157  m_db.replay();
158 }
159 
160 void
161 bridge_domain_arp_entry::event_handler::handle_populate(
162  const client_db::key_t& key)
163 {
164 }
165 
167 bridge_domain_arp_entry::event_handler::order() const
168 {
169  return (dependency_t::ENTRY);
170 }
171 
172 void
174 {
175  m_db.dump(os);
176 }
177 }
178 /*
179  * fd.io coding-style-patch-verification: ON
180  *
181  * Local Variables:
182  * eval: (c-set-style "mozilla")
183  * End:
184  */
std::shared_ptr< bridge_domain_arp_entry > singular() const
Return the matching &#39;singular instance&#39;.
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
std::string to_string() const
String conversion.
Definition: types.cpp:141
static rc_t write()
Write/Execute all commands hitherto enqueued.
Definition: hw.cpp:225
bridge_domain_arp_entry(const bridge_domain &bd, const boost::asio::ip::address &ip_addr, const mac_address_t &mac)
Construct a bridge domain ARP Entry in the given bridge domain.
void replay(void)
replay the object to create it in hardware
rc_t rc() const
Get the HW return code.
Definition: hw.hpp:118
static void dump(std::ostream &os)
Dump all bridge_domain-doamin into the stream provided.
std::pair< bridge_domain::key_t, boost::asio::ip::address > key_t
The key for a bridge_domain ARP entry; the BD, IP address and MAC address.
A base class for all object_base in the VPP object_base-Model.
A cmd class that deletes a bridge domain ARP entry.
const key_t key() const
Return the object&#39;s key.
~bridge_domain_arp_entry()
Destructor.
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 const rc_t OK
The HW write was successfull.
Definition: types.hpp:106
static void enqueue(cmd *f)
Enqueue A command for execution.
Definition: hw.cpp:189
std::shared_ptr< bridge_domain > singular() const
Return the matchin &#39;singular&#39; instance of the bridge-domain.
bool operator==(const bridge_domain_arp_entry &bdae) const
comparison operator
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
void show(char *chroot_path, int verbose)
Definition: svmtool.c:105
Entries in Tables.
std::string to_string() const
Convert to string for debugging.
Type def of a Ethernet address.
Definition: types.hpp:221
A command class that creates or updates the bridge domain ARP Entry.
static std::shared_ptr< bridge_domain_arp_entry > find(const key_t &k)
Find the instnace of the bridge_domain domain in the OM.
static bool register_listener(listener *listener)
Register a listener of events.
Definition: om.cpp:124
static const uint32_t DEFAULT_TABLE
The value of the defaultbridge domain.
A entry in the ARP termination table of a Bridge Domain.