FD.io VPP  v19.04.4-rc0-5-ge88582fac
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  const handle_t bvi,
23  const handle_t uu_fwd,
24  const handle_t bm_flood,
26  : rpc_cmd(item)
27  , m_bvi(bvi)
28  , m_uu_fwd(uu_fwd)
29  , m_bm_flood(bm_flood)
30  , m_flags(flags)
31 {
32 }
33 
34 bool
36 {
37  return ((m_hw_item.data() == other.m_hw_item.data()) &&
38  (m_bvi == other.m_bvi) && (m_uu_fwd == other.m_uu_fwd) &&
39  (m_bm_flood == other.m_bm_flood) && (m_flags == other.m_flags));
40 }
41 
42 rc_t
44 {
45  msg_t req(con.ctx(), std::ref(*this));
46 
47  auto& payload = req.get_request().get_payload();
48 
49  payload.bd.bd_id = m_hw_item.data();
50  payload.bd.bvi_sw_if_index = m_bvi.value();
51  payload.bd.uu_fwd_sw_if_index = m_uu_fwd.value();
52  payload.bd.bm_flood_sw_if_index = m_bm_flood.value();
53 
54  vapi_enum_gbp_bridge_domain_flags flags = GBP_BD_API_FLAG_NONE;
56  flags = static_cast<vapi_enum_gbp_bridge_domain_flags>(
59  flags = static_cast<vapi_enum_gbp_bridge_domain_flags>(
62  flags = static_cast<vapi_enum_gbp_bridge_domain_flags>(
65  flags = static_cast<vapi_enum_gbp_bridge_domain_flags>(
67 
68  payload.bd.flags = flags;
69  VAPI_CALL(req.execute());
70 
71  return (wait());
72 }
73 
74 std::string
76 {
77  std::ostringstream s;
78  s << "gbp-bridge-domain: " << m_hw_item.to_string()
79  << " flags:" << m_flags.to_string() << " bvi:" << m_bvi.to_string()
80  << " uu-fwd:" << m_uu_fwd.to_string();
81 
82  return (s.str());
83 }
84 
86  : rpc_cmd(item)
87 {
88 }
89 
90 bool
92 {
93  return (m_hw_item.data() == other.m_hw_item.data());
94 }
95 
96 rc_t
98 {
99  msg_t req(con.ctx(), std::ref(*this));
100 
101  auto& payload = req.get_request().get_payload();
102 
103  payload.bd_id = m_hw_item.data();
104 
105  VAPI_CALL(req.execute());
106 
107  wait();
109 
110  return rc_t::OK;
111 }
112 
113 std::string
115 {
116  std::ostringstream s;
117  s << "gbp-bridge-domain: " << m_hw_item.to_string();
118 
119  return (s.str());
120 }
121 
122 bool
123 dump_cmd::operator==(const dump_cmd& other) const
124 {
125  return (true);
126 }
127 
128 rc_t
130 {
131  m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
132 
133  VAPI_CALL(m_dump->execute());
134 
135  wait();
136 
137  return rc_t::OK;
138 }
139 
140 std::string
142 {
143  return ("gbp-bridge-domain-dump");
144 }
145 
146 }; // namespace gbp_bridge_domain_cmds
147 }; // namespace VOM
148 
149 /*
150  * fd.io coding-style-patch-verification: ON
151  *
152  * Local Variables:
153  * eval: (c-set-style "mozilla")
154  * End:
155  */
static const rc_t NOOP
The HW write/update action was/has not been attempted.
Definition: types.hpp:104
u32 flags
Definition: vhost_user.h:115
rc_t issue(connection &con)
Issue the command to VPP/HW.
uint32_t value() const
get the value of the handle
Definition: types.cpp:93
bool operator==(const dump_cmd &i) const
Comparison operator - only used for UT.
A cmd class that Delete an Bridge-Domain.
Error codes that VPP will return during a HW write.
Definition: types.hpp:89
A cmd class that Dumps all the bridge domains.
T & data()
Return the data read/written.
Definition: hw.hpp:109
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 command class that creates an Bridge-Domain.
rc_t issue(connection &con)
Issue the command to VPP/HW.
create_cmd(HW::item< uint32_t > &item, const handle_t bvi, const handle_t uu_fwd, const handle_t bm_flood, const gbp_bridge_domain::flags_t &flags)
Constructor.
A representation of the connection to VPP.
Definition: connection.hpp:33
rc_t issue(connection &con)
Issue the command to VPP/HW.
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
std::string to_string() const
convert to string format for debug purposes
std::string to_string() const
convert to string format for debug purposes
Definition: types.cpp:69
A type declaration of an interface handle in VPP.
Definition: types.hpp:233
delete_cmd(HW::item< uint32_t > &item)
Constructor.
const std::string & to_string() const
convert to string format for debug purposes
Definition: enum_base.hpp:36
bool operator==(const delete_cmd &i) const
Comparison operator - only used for UT.
static const rc_t OK
The HW write was successfull.
Definition: types.hpp:109
bool operator==(const create_cmd &i) const
Comparison operator - only used for UT.
vapi::Connection & ctx()
Retrun the VAPI context the commands will use.
Definition: connection.cpp:49
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
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::string to_string() const
convert to string format for debug purposes
HW::item< uint32_t > & m_hw_item
A reference to an object&#39;s HW::item that the command will update.
Definition: rpc_cmd.hpp:134
HW::item< uint32_t > & item()
return the HW item the command updates
Definition: rpc_cmd.hpp:66
vapi::Gbp_bridge_domain_add msg_t
convenient typedef
Definition: rpc_cmd.hpp:46