FD.io VPP  v19.08.3-2-gbabecb413
Vector Packet Processing
bridge_domain_arp_entry_cmds.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 
17 #include "vom/api_types.hpp"
18 
19 namespace VOM {
20 namespace bridge_domain_arp_entry_cmds {
21 
23  uint32_t bd,
24  const mac_address_t& mac,
25  const boost::asio::ip::address& ip_addr)
26  : rpc_cmd(item)
27  , m_bd(bd)
28  , m_mac(mac)
29  , m_ip_addr(ip_addr)
30 {
31 }
32 
33 bool
35 {
36  return ((m_mac == other.m_mac) && (m_ip_addr == other.m_ip_addr) &&
37  (m_bd == other.m_bd));
38 }
39 
40 rc_t
42 {
43  msg_t req(con.ctx(), std::ref(*this));
44 
45  auto& payload = req.get_request().get_payload();
46  payload.entry.bd_id = m_bd;
47  payload.is_add = 1;
48  to_api(m_mac, payload.entry.mac);
49  to_api(m_ip_addr, payload.entry.ip);
50 
51  VAPI_CALL(req.execute());
52 
53  return (wait());
54 }
55 
56 std::string
58 {
59  std::ostringstream s;
60  s << "bridge-domain-arp-entry-create: " << m_hw_item.to_string()
61  << " bd:" << m_bd << " mac:" << m_mac.to_string()
62  << " ip:" << m_ip_addr.to_string();
63 
64  return (s.str());
65 }
66 
68  uint32_t bd,
69  const mac_address_t& mac,
70  const boost::asio::ip::address& ip_addr)
71  : rpc_cmd(item)
72  , m_bd(bd)
73  , m_mac(mac)
74  , m_ip_addr(ip_addr)
75 {
76 }
77 
78 bool
80 {
81  return ((m_mac == other.m_mac) && (m_ip_addr == other.m_ip_addr) &&
82  (m_bd == other.m_bd));
83 }
84 
85 rc_t
87 {
88  msg_t req(con.ctx(), std::ref(*this));
89 
90  auto& payload = req.get_request().get_payload();
91  payload.entry.bd_id = m_bd;
92  payload.is_add = 0;
93  to_api(m_mac, payload.entry.mac);
94  to_api(m_ip_addr, payload.entry.ip);
95 
96  VAPI_CALL(req.execute());
97 
98  wait();
100 
101  return rc_t::OK;
102 }
103 
104 std::string
106 {
107  std::ostringstream s;
108  s << "bridge-domain-arp-entry-delete: " << m_hw_item.to_string()
109  << " bd:" << m_bd << " mac:" << m_mac.to_string()
110  << " ip:" << m_ip_addr.to_string();
111 
112  return (s.str());
113 }
114 
116  : m_bd(bd_id)
117 {
118 }
119 
121  : m_bd(d.m_bd)
122 {
123 }
124 
125 bool
126 dump_cmd::operator==(const dump_cmd& other) const
127 {
128  return (true);
129 }
130 
131 rc_t
133 {
134  m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
135 
136  auto& payload = m_dump->get_request().get_payload();
137  payload.bd_id = m_bd;
138 
139  VAPI_CALL(m_dump->execute());
140 
141  wait();
142 
143  return rc_t::OK;
144 }
145 
146 std::string
148 {
149  return ("bridge-domain-arp-entry-dump");
150 }
151 
152 }; // namespace bridge_domain_arp_entry
153 }; // namespace VOM
154 
155 /*
156  * fd.io coding-style-patch-verification: ON
157  *
158  * Local Variables:
159  * eval: (c-set-style "mozilla")
160  * End:
161  */
static const rc_t NOOP
The HW write/update action was/has not been attempted.
Definition: types.hpp:104
typedef address
Definition: ip_types.api:83
vl_api_mac_address_t mac
Definition: l2.api:490
bool operator==(const delete_cmd &i) const
Comparison operator - only used for UT.
Error codes that VPP will return during a HW write.
Definition: types.hpp:89
vapi_enum_ip_neighbor_flags to_api(const neighbour::flags_t &f)
Definition: api_types.cpp:21
rc_t wait()
Wait on the commands promise.
Definition: rpc_cmd.hpp:82
A cmd class that Dumps all arp termination tables.
std::string to_string() const
convert to string format for debug purposes
Definition: hw.hpp:161
std::string to_string() const
convert to string format for debug purposes
A representation of the connection to VPP.
Definition: connection.hpp:33
rc_t issue(connection &con)
Issue the command to VPP/HW.
dump_cmd()
Default Constructor.
Definition: dump_cmd.hpp:55
u32 bd_id
Definition: gbp.api:274
A base class for all RPC commands to VPP.
Definition: rpc_cmd.hpp:40
#define VAPI_CALL(_stmt)
Convenince wrapper macro for error handling in VAPI sends.
Definition: types.hpp:29
delete_cmd(HW::item< bool > &item, uint32_t id, const mac_address_t &mac, const boost::asio::ip::address &ip_addr)
Constructor.
A cmd class that deletes a bridge domain ARP entry.
bool operator==(const dump_cmd &i) const
Comparison operator - only used for UT.
static const rc_t OK
The HW write was successfull.
Definition: types.hpp:109
rc_t wait()
Wait for the issue of the command to complete.
Definition: dump_cmd.hpp:93
std::string to_string() const
convert to string format for debug purposes
vapi::Connection & ctx()
Retrun the VAPI context the commands will use.
Definition: connection.cpp:49
std::string to_string() const
String conversion.
Definition: types.cpp:148
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
rc_t issue(connection &con)
Issue the command to VPP/HW.
std::string to_string() const
convert to string format for debug purposes
create_cmd(HW::item< bool > &item, uint32_t id, const mac_address_t &mac, const boost::asio::ip::address &ip_addr)
Constructor.
void set(const rc_t &rc)
Set the HW return code - should only be called from the family of Command objects.
Definition: hw.hpp:125
std::unique_ptr< vapi::Bd_ip_mac_dump > m_dump
The VAPI event registration.
Definition: dump_cmd.hpp:143
rc_t issue(connection &con)
Issue the command to VPP/HW.
bool operator==(const create_cmd &i) const
Comparison operator - only used for UT.
Type def of a Ethernet address.
Definition: types.hpp:295
A command class that creates or updates the bridge domain ARP Entry.
HW::item< bool > & m_hw_item
A reference to an object&#39;s HW::item that the command will update.
Definition: rpc_cmd.hpp:134
HW::item< bool > & item()
return the HW item the command updates
Definition: rpc_cmd.hpp:66
vapi::Bd_ip_mac_add_del msg_t
convenient typedef
Definition: rpc_cmd.hpp:46