FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
gbp_bridge_domain_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 gbp_bridge_domain_cmds {
20 
22  u32 rd_id,
23  const handle_t bvi,
24  const handle_t uu_fwd,
25  const handle_t bm_flood,
27  : rpc_cmd(item)
28  , m_rd_id(rd_id)
29  , m_bvi(bvi)
30  , m_uu_fwd(uu_fwd)
31  , m_bm_flood(bm_flood)
32  , m_flags(flags)
33 {
34 }
35 
36 bool
38 {
39  return ((m_hw_item.data() == other.m_hw_item.data()) &&
40  (m_rd_id == other.m_rd_id) && (m_bvi == other.m_bvi) &&
41  (m_uu_fwd == other.m_uu_fwd) && (m_bm_flood == other.m_bm_flood) &&
42  (m_flags == other.m_flags));
43 }
44 
45 rc_t
47 {
48  msg_t req(con.ctx(), std::ref(*this));
49 
50  auto& payload = req.get_request().get_payload();
51 
52  payload.bd.bd_id = m_hw_item.data();
53  payload.bd.rd_id = m_rd_id;
54  payload.bd.bvi_sw_if_index = m_bvi.value();
55  payload.bd.uu_fwd_sw_if_index = m_uu_fwd.value();
56  payload.bd.bm_flood_sw_if_index = m_bm_flood.value();
57 
58  vapi_enum_gbp_bridge_domain_flags flags = GBP_BD_API_FLAG_NONE;
60  flags = static_cast<vapi_enum_gbp_bridge_domain_flags>(
63  flags = static_cast<vapi_enum_gbp_bridge_domain_flags>(
66  flags = static_cast<vapi_enum_gbp_bridge_domain_flags>(
69  flags = static_cast<vapi_enum_gbp_bridge_domain_flags>(
71 
72  payload.bd.flags = flags;
73  VAPI_CALL(req.execute());
74 
75  return (wait());
76 }
77 
80 {
81  std::ostringstream s;
82  s << "gbp-bridge-domain: " << m_hw_item.to_string()
83  << " flags:" << m_flags.to_string() << " bvi:" << m_bvi.to_string()
84  << " uu-fwd:" << m_uu_fwd.to_string();
85 
86  return (s.str());
87 }
88 
90  : rpc_cmd(item)
91 {
92 }
93 
94 bool
96 {
97  return (m_hw_item.data() == other.m_hw_item.data());
98 }
99 
100 rc_t
102 {
103  msg_t req(con.ctx(), std::ref(*this));
104 
105  auto& payload = req.get_request().get_payload();
106 
107  payload.bd_id = m_hw_item.data();
108 
109  VAPI_CALL(req.execute());
110 
111  wait();
113 
114  return rc_t::OK;
115 }
116 
119 {
120  std::ostringstream s;
121  s << "gbp-bridge-domain: " << m_hw_item.to_string();
122 
123  return (s.str());
124 }
125 
126 bool
127 dump_cmd::operator==(const dump_cmd& other) const
128 {
129  return (true);
130 }
131 
132 rc_t
134 {
135  m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
136 
137  VAPI_CALL(m_dump->execute());
138 
139  wait();
140 
141  return rc_t::OK;
142 }
143 
146 {
147  return ("gbp-bridge-domain-dump");
148 }
149 
150 }; // namespace gbp_bridge_domain_cmds
151 }; // namespace VOM
152 
153 /*
154  * fd.io coding-style-patch-verification: OFF
155  *
156  * Local Variables:
157  * eval: (c-set-style "mozilla")
158  * End:
159  */
VOM::HW::item< uint32_t >
VOM::gbp_bridge_domain_cmds::delete_cmd::operator==
bool operator==(const delete_cmd &i) const
Comparison operator - only used for UT.
Definition: gbp_bridge_domain_cmds.cpp:95
VOM::gbp_bridge_domain::flags_t::UCAST_ARP
const static flags_t UCAST_ARP
Definition: gbp_bridge_domain.hpp:43
VOM::dump_cmd< vapi::Gbp_bridge_domain_dump >::msg_t
vapi::Gbp_bridge_domain_dump msg_t
Definition: dump_cmd.hpp:46
VOM::gbp_bridge_domain_cmds::dump_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: gbp_bridge_domain_cmds.cpp:133
VOM::rpc_cmd< HW::item< uint32_t >, vapi::Gbp_bridge_domain_add >::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::gbp_bridge_domain::flags_t::DO_NOT_LEARN
const static flags_t DO_NOT_LEARN
Definition: gbp_bridge_domain.hpp:40
VOM::handle_t::value
uint32_t value() const
get the value of the handle
Definition: types.cpp:93
VOM::rpc_cmd
A base class for all RPC commands to VPP.
Definition: rpc_cmd.hpp:40
VOM::gbp_bridge_domain_cmds::create_cmd::operator==
bool operator==(const create_cmd &i) const
Comparison operator - only used for UT.
Definition: gbp_bridge_domain_cmds.cpp:37
VOM::gbp_bridge_domain_cmds::delete_cmd::delete_cmd
delete_cmd(HW::item< uint32_t > &item)
Constructor.
Definition: gbp_bridge_domain_cmds.cpp:89
con
Connection con
Definition: vapi_cpp_test.cpp:56
VOM::gbp_bridge_domain_cmds::dump_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: gbp_bridge_domain_cmds.cpp:145
VOM::rpc_cmd< HW::item< uint32_t >, vapi::Gbp_bridge_domain_add >::m_hw_item
HW::item< uint32_t > & 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::Gbp_bridge_domain_dump >::m_dump
std::unique_ptr< vapi::Gbp_bridge_domain_dump > m_dump
The VAPI event registration.
Definition: dump_cmd.hpp:143
VAPI_CALL
#define VAPI_CALL(_stmt)
Convenince wrapper macro for error handling in VAPI sends.
Definition: types.hpp:29
VOM::connection
A representation of the connection to VPP.
Definition: connection.hpp:33
VOM::dump_cmd< vapi::Gbp_bridge_domain_dump >::wait
rc_t wait()
Wait for the issue of the command to complete.
Definition: dump_cmd.hpp:93
VOM::rc_t::NOOP
const static rc_t NOOP
The HW write/update action was/has not been attempted.
Definition: types.hpp:104
VOM::handle_t
A type declaration of an interface handle in VPP.
Definition: types.hpp:233
VOM::gbp_bridge_domain_cmds::create_cmd
A command class that creates an Bridge-Domain.
Definition: gbp_bridge_domain_cmds.hpp:30
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< uint32_t >, vapi::Gbp_bridge_domain_add >::msg_t
vapi::Gbp_bridge_domain_add msg_t
convenient typedef
Definition: rpc_cmd.hpp:46
VOM::enum_base::to_string
const std::string & to_string() const
convert to string format for debug purposes
Definition: enum_base.hpp:36
rd_id
u32 rd_id
Definition: gbp.api:35
VOM::HW::item::data
T & data()
Return the data read/written.
Definition: hw.hpp:109
VOM::gbp_bridge_domain_cmds::delete_cmd
A cmd class that Delete an Bridge-Domain.
Definition: gbp_bridge_domain_cmds.hpp:69
VOM::handle_t::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: types.cpp:69
GBP_BD_API_FLAG_UU_FWD_DROP
@ GBP_BD_API_FLAG_UU_FWD_DROP
Definition: gbp.api:27
GBP_BD_API_FLAG_NONE
@ GBP_BD_API_FLAG_NONE
Definition: gbp.api:25
VOM::gbp_bridge_domain::flags_t
Definition: gbp_bridge_domain.hpp:37
VOM::gbp_bridge_domain_cmds::delete_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: gbp_bridge_domain_cmds.cpp:101
u32
unsigned int u32
Definition: types.h:88
VOM::gbp_bridge_domain_cmds::create_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: gbp_bridge_domain_cmds.cpp:79
GBP_BD_API_FLAG_UCAST_ARP
@ GBP_BD_API_FLAG_UCAST_ARP
Definition: gbp.api:29
GBP_BD_API_FLAG_MCAST_DROP
@ GBP_BD_API_FLAG_MCAST_DROP
Definition: gbp.api:28
item
cJSON * item
Definition: cJSON.h:222
VOM::gbp_bridge_domain::flags_t::UU_FWD_DROP
const static flags_t UU_FWD_DROP
Definition: gbp_bridge_domain.hpp:41
VOM::gbp_bridge_domain_cmds::create_cmd::create_cmd
create_cmd(HW::item< uint32_t > &item, u32 rd_id, const handle_t bvi, const handle_t uu_fwd, const handle_t bm_flood, const gbp_bridge_domain::flags_t &flags)
Constructor.
Definition: gbp_bridge_domain_cmds.cpp:21
VOM::gbp_bridge_domain::flags_t::MCAST_DROP
const static flags_t MCAST_DROP
Definition: gbp_bridge_domain.hpp:42
VOM::gbp_bridge_domain_cmds::dump_cmd::operator==
bool operator==(const dump_cmd &i) const
Comparison operator - only used for UT.
Definition: gbp_bridge_domain_cmds.cpp:127
VOM::rc_t
Error codes that VPP will return during a HW write.
Definition: types.hpp:89
VOM::gbp_bridge_domain_cmds::delete_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: gbp_bridge_domain_cmds.cpp:118
gbp_bridge_domain_cmds.hpp
VOM::gbp_bridge_domain_cmds::dump_cmd
A cmd class that Dumps all the bridge domains.
Definition: gbp_bridge_domain_cmds.hpp:96
GBP_BD_API_FLAG_DO_NOT_LEARN
@ GBP_BD_API_FLAG_DO_NOT_LEARN
Definition: gbp.api:26
VOM::gbp_bridge_domain_cmds::create_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: gbp_bridge_domain_cmds.cpp:46
string
const char *const string
Definition: cJSON.h:172
flags
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105