FD.io VPP  v19.01.3-6-g70449b9b9
Vector Packet Processing
gbp_vxlan_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 
16 #include "vom/gbp_vxlan_cmds.hpp"
17 
18 #include <vapi/tap.api.vapi.hpp>
19 
20 namespace VOM {
21 namespace gbp_vxlan_cmds {
23  const std::string& name,
24  uint32_t vni,
25  bool is_l2,
26  uint32_t bd_rd)
27  : interface::create_cmd<vapi::Gbp_vxlan_tunnel_add>(item, name)
28  , m_vni(vni)
29  , m_is_l2(is_l2)
30  , m_bd_rd(bd_rd)
31 {
32 }
33 
34 rc_t
36 {
37  msg_t req(con.ctx(), std::ref(*this));
38 
39  auto& payload = req.get_request().get_payload();
40 
41  payload.tunnel.vni = m_vni;
42  payload.tunnel.bd_rd_id = m_bd_rd;
43  if (m_is_l2)
44  payload.tunnel.mode = GBP_VXLAN_TUNNEL_MODE_L2;
45  else
46  payload.tunnel.mode = GBP_VXLAN_TUNNEL_MODE_L3;
47 
48  VAPI_CALL(req.execute());
49 
50  wait();
51  if (m_hw_item.rc() == rc_t::OK) {
53  }
54 
55  return (m_hw_item.rc());
56 }
57 
58 std::string
60 {
61  std::ostringstream s;
62  s << "gbp-vxlan-create: " << m_hw_item.to_string() << " vni:" << m_vni
63  << " bd/rd:" << m_bd_rd;
64 
65  return (s.str());
66 }
67 
69  : interface::delete_cmd<vapi::Gbp_vxlan_tunnel_del>(item)
70  , m_vni(vni)
71 {
72 }
73 
74 rc_t
76 {
77  msg_t req(con.ctx(), std::ref(*this));
78 
79  auto& payload = req.get_request().get_payload();
80  payload.vni = m_vni;
81 
82  VAPI_CALL(req.execute());
83 
84  wait();
86 
88  return rc_t::OK;
89 }
90 
91 std::string
93 {
94  std::ostringstream s;
95  s << "gbp-vxlan-delete: " << m_hw_item.to_string() << " vni:" << m_vni;
96 
97  return (s.str());
98 }
99 
101 {
102 }
103 
104 bool
105 dump_cmd::operator==(const dump_cmd& other) const
106 {
107  return (true);
108 }
109 
110 rc_t
112 {
113  m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
114 
115  VAPI_CALL(m_dump->execute());
116 
117  wait();
118 
119  return rc_t::OK;
120 }
121 
122 std::string
124 {
125  return ("gbp-vxlan-dump");
126 }
127 
128 } // namespace gbp_vxlan_cmds
129 } // namespace VOM
130 
131 /*
132  * fd.io coding-style-patch-verification: ON
133  *
134  * Local Variables:
135  * eval: (c-set-style "mozilla")
136  * End:
137  */
static const rc_t NOOP
The HW write/update action was/has not been attempted.
Definition: types.hpp:104
rc_t issue(connection &con)
Issue the command to VPP/HW.
void remove_interface()
remove the deleted interface from the DB
Definition: interface.hpp:404
rc_t rc() const
Get the HW return code.
Definition: hw.hpp:119
A cmd class that Dumps all the bridge domains.
Error codes that VPP will return during a HW write.
Definition: types.hpp:89
std::string to_string() const
convert to string format for debug purposes
Definition: hw.hpp:161
Forward declarations.
Definition: vapi.hpp:44
A command class that creates an Bridge-Domain.
bool operator==(const dump_cmd &i) const
Comparison operator - only used for UT.
rc_t issue(connection &con)
Issue the command to VPP/HW.
A representation of the connection to VPP.
Definition: connection.hpp:33
std::string to_string() const
convert to string format for debug purposes
u8 name[64]
Definition: memclnt.api:152
#define VAPI_CALL(_stmt)
Convenince wrapper macro for error handling in VAPI sends.
Definition: types.hpp:29
A cmd class that Delete an Bridge-Domain.
create_cmd(HW::item< handle_t > &item, const std::string &name, uint32_t vni, bool is_l2, uint32_t bd_rd)
Constructor.
A representation of an interface in VPP.
Definition: interface.hpp:41
rc_t issue(connection &con)
Issue the command to VPP/HW.
std::string to_string() const
convert to string format for debug purposes
static const rc_t OK
The HW write was successfull.
Definition: types.hpp:109
delete_cmd(HW::item< handle_t > &item, uint32_t vni)
Constructor.
vapi::Connection & ctx()
Retrun the VAPI context the commands will use.
Definition: connection.cpp:49
std::string to_string() const
convert to string format for debug purposes
void insert_interface()
add the created interface to the DB
Definition: interface.hpp:335
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
u32 vni
Definition: vxlan_gbp.api:36
HW::item< handle_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< handle_t > & item()
return the HW item the command updates
Definition: rpc_cmd.hpp:66
vapi::Gbp_vxlan_tunnel_add msg_t
convenient typedef
Definition: rpc_cmd.hpp:46