FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
bridge_domain_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 
18 namespace VOM {
19 namespace bridge_domain_entry_cmds {
21  const mac_address_t& mac,
22  uint32_t bd,
23  handle_t tx_itf,
24  bool is_bvi)
25  : rpc_cmd(item)
26  , m_mac(mac)
27  , m_bd(bd)
28  , m_tx_itf(tx_itf)
29  , m_is_bvi(is_bvi)
30 {
31 }
32 
33 bool
35 {
36  return ((m_mac == other.m_mac) && (m_tx_itf == other.m_tx_itf) &&
37  (m_bd == other.m_bd) && (m_is_bvi == other.m_is_bvi));
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.bd_id = m_bd;
47  payload.is_add = 1;
48  m_mac.to_bytes(payload.mac, 6);
49  payload.sw_if_index = m_tx_itf.value();
50  payload.bvi_mac = m_is_bvi;
51 
52  VAPI_CALL(req.execute());
53 
54  return (wait());
55 }
56 
59 {
60  std::ostringstream s;
61  s << "bridge-domain-entry-create: " << m_hw_item.to_string() << " bd:" << m_bd
62  << " mac:" << m_mac.to_string() << " tx:" << m_tx_itf
63  << " bvi:" << m_is_bvi;
64 
65  return (s.str());
66 }
67 
69  const mac_address_t& mac,
70  uint32_t bd,
71  bool is_bvi)
72  : rpc_cmd(item)
73  , m_mac(mac)
74  , m_bd(bd)
75  , m_is_bvi(is_bvi)
76 {
77 }
78 
79 bool
81 {
82  return ((m_mac == other.m_mac) && (m_bd == other.m_bd) &&
83  (m_is_bvi == other.m_is_bvi));
84 }
85 
86 rc_t
88 {
89  msg_t req(con.ctx(), std::ref(*this));
90 
91  auto& payload = req.get_request().get_payload();
92  payload.bd_id = m_bd;
93  payload.is_add = 0;
94  m_mac.to_bytes(payload.mac, 6);
95  payload.sw_if_index = ~0;
96  payload.bvi_mac = m_is_bvi;
97 
98  VAPI_CALL(req.execute());
99 
100  wait();
102 
103  return rc_t::OK;
104 }
105 
108 {
109  std::ostringstream s;
110  s << "bridge-domain-entry-delete: " << m_hw_item.to_string() << " bd:" << m_bd
111  << " mac:" << m_mac.to_string() << " bvi:" << m_is_bvi;
112 
113  return (s.str());
114 }
115 
117 {
118 }
119 
120 bool
121 dump_cmd::operator==(const dump_cmd& other) const
122 {
123  return (true);
124 }
125 
126 rc_t
128 {
129  m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
130 
131  auto& payload = m_dump->get_request().get_payload();
132  payload.bd_id = ~0;
133 
134  VAPI_CALL(m_dump->execute());
135 
136  wait();
137 
138  return rc_t::OK;
139 }
140 
143 {
144  return ("bridge-domain-entry-dump");
145 }
146 }
147 }
148 
149 /*
150  * fd.io coding-style-patch-verification: OFF
151  *
152  * Local Variables:
153  * eval: (c-set-style "mozilla")
154  * End:
155  */
VOM::HW::item< bool >
bridge_domain_entry_cmds.hpp
VOM::dump_cmd< vapi::L2_fib_table_dump >::msg_t
vapi::L2_fib_table_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::L2fib_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
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_entry_cmds::dump_cmd
A cmd class that Dumps all the interface spans.
Definition: bridge_domain_entry_cmds.hpp:103
VOM::handle_t::value
uint32_t value() const
get the value of the handle
Definition: types.cpp:93
VOM::bridge_domain_entry_cmds::create_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: bridge_domain_entry_cmds.cpp:41
VOM::rpc_cmd
A base class for all RPC commands to VPP.
Definition: rpc_cmd.hpp:40
con
Connection con
Definition: vapi_cpp_test.cpp:56
VOM::rpc_cmd< HW::item< bool >, vapi::L2fib_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::L2_fib_table_dump >::m_dump
std::unique_ptr< vapi::L2_fib_table_dump > m_dump
The VAPI event registration.
Definition: dump_cmd.hpp:143
VOM::bridge_domain_entry_cmds::create_cmd::operator==
bool operator==(const create_cmd &i) const
Comparison operator - only used for UT.
Definition: bridge_domain_entry_cmds.cpp:34
VAPI_CALL
#define VAPI_CALL(_stmt)
Convenince wrapper macro for error handling in VAPI sends.
Definition: types.hpp:29
VOM::bridge_domain_entry_cmds::dump_cmd::operator==
bool operator==(const dump_cmd &i) const
Comparison operator - only used for UT.
Definition: bridge_domain_entry_cmds.cpp:121
VOM::connection
A representation of the connection to VPP.
Definition: connection.hpp:33
VOM::mac_address_t::to_bytes
void to_bytes(uint8_t *array, uint8_t len) const
Convert to byte array.
Definition: types.cpp:140
VOM::dump_cmd< vapi::L2_fib_table_dump >::wait
rc_t wait()
Wait for the issue of the command to complete.
Definition: dump_cmd.hpp:93
VOM::bridge_domain_entry_cmds::delete_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: bridge_domain_entry_cmds.cpp:87
VOM::rc_t::NOOP
const static rc_t NOOP
The HW write/update action was/has not been attempted.
Definition: types.hpp:104
VOM::bridge_domain_entry_cmds::create_cmd::create_cmd
create_cmd(HW::item< bool > &item, const mac_address_t &mac, uint32_t id, handle_t tx_intf, bool is_bvi)
Constructor.
Definition: bridge_domain_entry_cmds.cpp:20
VOM::bridge_domain_entry_cmds::dump_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: bridge_domain_entry_cmds.cpp:127
VOM::handle_t
A type declaration of an interface handle in VPP.
Definition: types.hpp:233
VOM::HW::item::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: hw.hpp:161
VOM::rpc_cmd< HW::item< bool >, vapi::L2fib_add_del >::msg_t
vapi::L2fib_add_del msg_t
convenient typedef
Definition: rpc_cmd.hpp:46
VOM::bridge_domain_entry_cmds::delete_cmd::delete_cmd
delete_cmd(HW::item< bool > &item, const mac_address_t &mac, uint32_t id, bool is_bvi)
Constructor.
Definition: bridge_domain_entry_cmds.cpp:68
VOM::mac_address_t::to_string
std::string to_string() const
String conversion.
Definition: types.cpp:148
VOM::bridge_domain_entry_cmds::create_cmd
A command class that creates or updates the bridge_domain.
Definition: bridge_domain_entry_cmds.hpp:31
VOM::mac_address_t
Type def of a Ethernet address.
Definition: types.hpp:295
VOM::bridge_domain_entry_cmds::create_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: bridge_domain_entry_cmds.cpp:58
VOM::bridge_domain_entry_cmds::delete_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: bridge_domain_entry_cmds.cpp:107
item
cJSON * item
Definition: cJSON.h:222
VOM::bridge_domain_entry_cmds::delete_cmd
A cmd class that deletes a bridge_domain.
Definition: bridge_domain_entry_cmds.hpp:68
VOM::bridge_domain_entry_cmds::dump_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: bridge_domain_entry_cmds.cpp:142
VOM::bridge_domain_entry_cmds::dump_cmd::dump_cmd
dump_cmd()
Constructor.
Definition: bridge_domain_entry_cmds.cpp:116
VOM::rc_t
Error codes that VPP will return during a HW write.
Definition: types.hpp:89
VOM::bridge_domain_entry_cmds::delete_cmd::operator==
bool operator==(const delete_cmd &i) const
Comparison operator - only used for UT.
Definition: bridge_domain_entry_cmds.cpp:80
string
const char *const string
Definition: cJSON.h:172