FD.io VPP  v21.10.1-2-g0a485f517
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 
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 
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 
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: OFF
157  *
158  * Local Variables:
159  * eval: (c-set-style "mozilla")
160  * End:
161  */
VOM::HW::item< bool >
VOM::dump_cmd< vapi::Bd_ip_mac_dump >::msg_t
vapi::Bd_ip_mac_dump msg_t
Definition: dump_cmd.hpp:46
mac
vl_api_mac_address_t mac
Definition: l2.api:559
VOM::rpc_cmd< HW::item< bool >, vapi::Bd_ip_mac_add_del >::wait
rc_t wait()
Wait on the commands promise.
Definition: rpc_cmd.hpp:82
VOM::HW::item::set
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
VOM::bridge_domain_arp_entry_cmds::create_cmd::operator==
bool operator==(const create_cmd &i) const
Comparison operator - only used for UT.
Definition: bridge_domain_arp_entry_cmds.cpp:34
VOM
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
VOM::rc_t::OK
const static rc_t OK
The HW write was successfull.
Definition: types.hpp:109
VOM::bridge_domain_arp_entry_cmds::create_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: bridge_domain_arp_entry_cmds.cpp:57
VOM::bridge_domain_arp_entry_cmds::dump_cmd::operator==
bool operator==(const dump_cmd &i) const
Comparison operator - only used for UT.
Definition: bridge_domain_arp_entry_cmds.cpp:126
VOM::rpc_cmd
A base class for all RPC commands to VPP.
Definition: rpc_cmd.hpp:40
VOM::bridge_domain_arp_entry_cmds::delete_cmd::delete_cmd
delete_cmd(HW::item< bool > &item, uint32_t id, const mac_address_t &mac, const boost::asio::ip::address &ip_addr)
Constructor.
Definition: bridge_domain_arp_entry_cmds.cpp:67
VOM::bridge_domain_arp_entry_cmds::dump_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: bridge_domain_arp_entry_cmds.cpp:132
con
Connection con
Definition: vapi_cpp_test.cpp:56
VOM::bridge_domain_arp_entry_cmds::create_cmd
A command class that creates or updates the bridge domain ARP Entry.
Definition: bridge_domain_arp_entry_cmds.hpp:31
VOM::bridge_domain_arp_entry_cmds::delete_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: bridge_domain_arp_entry_cmds.cpp:86
VOM::rpc_cmd< HW::item< bool >, vapi::Bd_ip_mac_add_del >::m_hw_item
HW::item< bool > & m_hw_item
A reference to an object's HW::item that the command will update.
Definition: rpc_cmd.hpp:134
VOM::dump_cmd< vapi::Bd_ip_mac_dump >::m_dump
std::unique_ptr< vapi::Bd_ip_mac_dump > m_dump
The VAPI event registration.
Definition: dump_cmd.hpp:143
bd_id
u32 bd_id
Definition: gbp.api:188
VAPI_CALL
#define VAPI_CALL(_stmt)
Convenince wrapper macro for error handling in VAPI sends.
Definition: types.hpp:29
VOM::bridge_domain_arp_entry_cmds::create_cmd::create_cmd
create_cmd(HW::item< bool > &item, uint32_t id, const mac_address_t &mac, const boost::asio::ip::address &ip_addr)
Constructor.
Definition: bridge_domain_arp_entry_cmds.cpp:22
VOM::connection
A representation of the connection to VPP.
Definition: connection.hpp:33
VOM::dump_cmd< vapi::Bd_ip_mac_dump >::wait
rc_t wait()
Wait for the issue of the command to complete.
Definition: dump_cmd.hpp:93
VOM::bridge_domain_arp_entry_cmds::dump_cmd
A cmd class that Dumps all arp termination tables.
Definition: bridge_domain_arp_entry_cmds.hpp:101
VOM::rc_t::NOOP
const static rc_t NOOP
The HW write/update action was/has not been attempted.
Definition: types.hpp:104
address
manual_print typedef address
Definition: ip_types.api:96
VOM::HW::item::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: hw.hpp:161
VOM::to_api
vapi_enum_ip_neighbor_flags to_api(const neighbour::flags_t &f)
Definition: api_types.cpp:21
VOM::rpc_cmd< HW::item< bool >, vapi::Bd_ip_mac_add_del >::msg_t
vapi::Bd_ip_mac_add_del msg_t
convenient typedef
Definition: rpc_cmd.hpp:46
VOM::mac_address_t::to_string
std::string to_string() const
String conversion.
Definition: types.cpp:148
VOM::mac_address_t
Type def of a Ethernet address.
Definition: types.hpp:295
VOM::bridge_domain_arp_entry_cmds::create_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: bridge_domain_arp_entry_cmds.cpp:41
VOM::bridge_domain_arp_entry_cmds::delete_cmd
A cmd class that deletes a bridge domain ARP entry.
Definition: bridge_domain_arp_entry_cmds.hpp:66
item
cJSON * item
Definition: cJSON.h:222
VOM::dump_cmd< vapi::Bd_ip_mac_dump >::dump_cmd
dump_cmd()
Default Constructor.
Definition: dump_cmd.hpp:55
bridge_domain_arp_entry_cmds.hpp
VOM::rc_t
Error codes that VPP will return during a HW write.
Definition: types.hpp:89
VOM::bridge_domain_arp_entry_cmds::dump_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: bridge_domain_arp_entry_cmds.cpp:147
VOM::bridge_domain_arp_entry_cmds::delete_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: bridge_domain_arp_entry_cmds.cpp:105
VOM::bridge_domain_arp_entry_cmds::delete_cmd::operator==
bool operator==(const delete_cmd &i) const
Comparison operator - only used for UT.
Definition: bridge_domain_arp_entry_cmds.cpp:79
api_types.hpp
string
const char *const string
Definition: cJSON.h:172