FD.io VPP  v21.01.1
Vector Packet Processing
gbp_ext_itf_cmds.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 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 
16 #include "vom/gbp_ext_itf_cmds.hpp"
17 
18 namespace VOM {
19 namespace gbp_ext_itf_cmds {
20 
22  const handle_t& itf,
23  uint32_t bd_id,
24  uint32_t rd_id)
25  : rpc_cmd(item)
26  , m_itf(itf)
27  , m_bd_id(bd_id)
28  , m_rd_id(rd_id)
29 {
30 }
31 
32 bool
34 {
35  return ((m_itf == other.m_itf) && (m_bd_id == other.m_bd_id) &&
36  (m_rd_id == other.m_rd_id));
37 }
38 
39 rc_t
41 {
42  msg_t req(con.ctx(), std::ref(*this));
43 
44  auto& payload = req.get_request().get_payload();
45  payload.is_add = 1;
46  payload.ext_itf.sw_if_index = m_itf.value();
47  payload.ext_itf.bd_id = m_bd_id;
48  payload.ext_itf.rd_id = m_rd_id;
49 
50  VAPI_CALL(req.execute());
51 
52  return (wait());
53 }
54 
57 {
58  std::ostringstream s;
59  s << "gbp-ext_itf-create: " << m_hw_item.to_string() << " itf:" << m_itf
60  << " bd-id:" << m_bd_id << " rd-id:" << m_rd_id;
61 
62  return (s.str());
63 }
64 
66  : rpc_cmd(item)
67  , m_itf(itf)
68 {
69 }
70 
71 bool
73 {
74  return (m_itf == other.m_itf);
75 }
76 
77 rc_t
79 {
80  msg_t req(con.ctx(), std::ref(*this));
81 
82  auto& payload = req.get_request().get_payload();
83  payload.is_add = 0;
84  payload.ext_itf.sw_if_index = m_itf.value();
85  payload.ext_itf.bd_id = ~0;
86  payload.ext_itf.rd_id = ~0;
87 
88  VAPI_CALL(req.execute());
89 
90  return (wait());
91 }
92 
95 {
96  std::ostringstream s;
97  s << "gbp-ext-itf-delete: " << m_hw_item.to_string() << " itf:" << m_itf;
98 
99  return (s.str());
100 }
101 
102 bool
103 dump_cmd::operator==(const dump_cmd& other) const
104 {
105  return (true);
106 }
107 
108 rc_t
110 {
111  m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
112 
113  VAPI_CALL(m_dump->execute());
114 
115  wait();
116 
117  return rc_t::OK;
118 }
119 
122 {
123  return ("gbp-ext-itf-dump");
124 }
125 
126 }; // namespace gbp_ext_itf_cmds
127 }; // namespace VOM
128 
129 /*
130  * fd.io coding-style-patch-verification: OFF
131  *
132  * Local Variables:
133  * eval: (c-set-style "mozilla")
134  * End:
135  */
create_cmd(HW::item< bool > &item, const handle_t &itf, uint32_t bd_id, uint32_t rd_id)
Constructor.
uint32_t value() const
get the value of the handle
Definition: types.cpp:93
A cmd class that Dumps all the GBP ext_itfs.
std::string to_string() const
convert to string format for debug purposes
rc_t issue(connection &con)
Issue the command to VPP/HW.
const char *const string
Definition: cJSON.h:172
u32 rd_id
Definition: gbp.api:35
Error codes that VPP will return during a HW write.
Definition: types.hpp:89
rc_t issue(connection &con)
Issue the command to VPP/HW.
rc_t issue(connection &con)
Issue the command to VPP/HW.
rc_t wait()
Wait on the commands promise.
Definition: rpc_cmd.hpp:82
std::string to_string() const
convert to string format for debug purposes
Definition: hw.hpp:161
A representation of the connection to VPP.
Definition: connection.hpp:33
bool operator==(const delete_cmd &i) const
Comparison operator - only used for UT.
u32 bd_id
Definition: gbp.api:188
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
bool operator==(const dump_cmd &i) const
Comparison operator - only used for UT.
std::string to_string() const
convert to string format for debug purposes
delete_cmd(HW::item< bool > &item, const handle_t &itf)
Constructor.
A type declaration of an interface handle in VPP.
Definition: types.hpp:233
cJSON * item
Definition: cJSON.h:222
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
A cmd class that deletes a GBP ext_itf.
A command class that creates or updates the GBP ext_itf.
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::Gbp_ext_itf_add_del msg_t
convenient typedef
Definition: rpc_cmd.hpp:46
std::string to_string() const
convert to string format for debug purposes