FD.io VPP  v21.10.1-2-g0a485f517
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 #include "vom/api_types.hpp"
18 
19 namespace VOM {
20 namespace gbp_vxlan_cmds {
22  const std::string& name,
23  const boost::asio::ip::address_v4& src,
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_src(src)
29  , m_vni(vni)
30  , m_is_l2(is_l2)
31  , m_bd_rd(bd_rd)
32 {
33 }
34 
35 rc_t
37 {
38  msg_t req(con.ctx(), std::ref(*this));
39 
40  auto& payload = req.get_request().get_payload();
41 
42  payload.tunnel.vni = m_vni;
43  payload.tunnel.bd_rd_id = m_bd_rd;
44  if (m_is_l2)
45  payload.tunnel.mode = GBP_VXLAN_TUNNEL_MODE_L2;
46  else
47  payload.tunnel.mode = GBP_VXLAN_TUNNEL_MODE_L3;
48  to_api(m_src, payload.tunnel.src);
49 
50  VAPI_CALL(req.execute());
51 
52  wait();
53  if (m_hw_item.rc() == rc_t::OK) {
55  }
56 
57  return (m_hw_item.rc());
58 }
59 
62 {
63  std::ostringstream s;
64  s << "gbp-vxlan-create: " << m_hw_item.to_string() << " vni:" << m_vni
65  << " bd/rd:" << m_bd_rd;
66 
67  return (s.str());
68 }
69 
71  : interface::delete_cmd<vapi::Gbp_vxlan_tunnel_del>(item)
72  , m_vni(vni)
73 {
74 }
75 
76 rc_t
78 {
79  msg_t req(con.ctx(), std::ref(*this));
80 
81  auto& payload = req.get_request().get_payload();
82  payload.vni = m_vni;
83 
84  VAPI_CALL(req.execute());
85 
86  wait();
88 
90  return rc_t::OK;
91 }
92 
95 {
96  std::ostringstream s;
97  s << "gbp-vxlan-delete: " << m_hw_item.to_string() << " vni:" << m_vni;
98 
99  return (s.str());
100 }
101 
103 {
104 }
105 
106 bool
107 dump_cmd::operator==(const dump_cmd& other) const
108 {
109  return (true);
110 }
111 
112 rc_t
114 {
115  m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
116 
117  VAPI_CALL(m_dump->execute());
118 
119  wait();
120 
121  return rc_t::OK;
122 }
123 
126 {
127  return ("gbp-vxlan-dump");
128 }
129 
130 } // namespace gbp_vxlan_cmds
131 } // namespace VOM
132 
133 /*
134  * fd.io coding-style-patch-verification: OFF
135  *
136  * Local Variables:
137  * eval: (c-set-style "mozilla")
138  * End:
139  */
VOM::HW::item< handle_t >
VOM::dump_cmd< vapi::Gbp_vxlan_tunnel_dump >::msg_t
vapi::Gbp_vxlan_tunnel_dump msg_t
Definition: dump_cmd.hpp:46
VOM::rpc_cmd< HW::item< handle_t >, vapi::Gbp_vxlan_tunnel_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
name
string name[64]
Definition: fib.api:25
vni
u32 vni
Definition: flow_types.api:160
con
Connection con
Definition: vapi_cpp_test.cpp:56
GBP_VXLAN_TUNNEL_MODE_L2
@ GBP_VXLAN_TUNNEL_MODE_L2
Definition: gbp.api:379
VOM::gbp_vxlan_cmds::create_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: gbp_vxlan_cmds.cpp:61
VOM::gbp_vxlan_cmds::dump_cmd::dump_cmd
dump_cmd()
Constructor.
Definition: gbp_vxlan_cmds.cpp:102
VOM::rpc_cmd< HW::item< handle_t >, vapi::Gbp_vxlan_tunnel_add >::m_hw_item
HW::item< handle_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_vxlan_tunnel_dump >::m_dump
std::unique_ptr< vapi::Gbp_vxlan_tunnel_dump > m_dump
The VAPI event registration.
Definition: dump_cmd.hpp:143
gbp_vxlan_cmds.hpp
VOM::interface::create_cmd< vapi::Gbp_vxlan_tunnel_add >::insert_interface
void insert_interface()
add the created interface to the DB
Definition: interface.hpp:343
VOM::gbp_vxlan_cmds::delete_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: gbp_vxlan_cmds.cpp:94
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::gbp_vxlan_cmds::delete_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: gbp_vxlan_cmds.cpp:77
VOM::dump_cmd< vapi::Gbp_vxlan_tunnel_dump >::wait
rc_t wait()
Wait for the issue of the command to complete.
Definition: dump_cmd.hpp:93
VOM::gbp_vxlan_cmds::dump_cmd
A cmd class that Dumps all the bridge domains.
Definition: gbp_vxlan_cmds.hpp:96
VOM::interface
A representation of an interface in VPP.
Definition: interface.hpp:41
VOM::rc_t::NOOP
const static rc_t NOOP
The HW write/update action was/has not been attempted.
Definition: types.hpp:104
src
vl_api_address_t src
Definition: gre.api:54
VOM::gbp_vxlan_cmds::create_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: gbp_vxlan_cmds.cpp:36
VOM::HW::item::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: hw.hpp:161
VOM::gbp_vxlan_cmds::create_cmd
A command class that creates an Bridge-Domain.
Definition: gbp_vxlan_cmds.hpp:30
VOM::gbp_vxlan_cmds::create_cmd::create_cmd
create_cmd(HW::item< handle_t > &item, const std::string &name, const boost::asio::ip::address_v4 &src, uint32_t vni, bool is_l2, uint32_t bd_rd)
Constructor.
Definition: gbp_vxlan_cmds.cpp:21
VOM::to_api
vapi_enum_ip_neighbor_flags to_api(const neighbour::flags_t &f)
Definition: api_types.cpp:21
VOM::rpc_cmd< HW::item< handle_t >, vapi::Gbp_vxlan_tunnel_add >::msg_t
vapi::Gbp_vxlan_tunnel_add msg_t
convenient typedef
Definition: rpc_cmd.hpp:46
VOM::HW::item::rc
rc_t rc() const
Get the HW return code.
Definition: hw.hpp:119
VOM::interface::delete_cmd< vapi::Gbp_vxlan_tunnel_del >::remove_interface
void remove_interface()
remove the deleted interface from the DB
Definition: interface.hpp:412
VOM::gbp_vxlan_cmds::dump_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: gbp_vxlan_cmds.cpp:125
VOM::gbp_vxlan_cmds::dump_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: gbp_vxlan_cmds.cpp:113
item
cJSON * item
Definition: cJSON.h:222
VOM::gbp_vxlan_cmds::delete_cmd
A cmd class that Delete an Bridge-Domain.
Definition: gbp_vxlan_cmds.hpp:67
vapi
Forward declarations.
Definition: vapi.hpp:44
VOM::rc_t
Error codes that VPP will return during a HW write.
Definition: types.hpp:89
GBP_VXLAN_TUNNEL_MODE_L3
@ GBP_VXLAN_TUNNEL_MODE_L3
Definition: gbp.api:380
VOM::gbp_vxlan_cmds::delete_cmd::delete_cmd
delete_cmd(HW::item< handle_t > &item, uint32_t vni)
Constructor.
Definition: gbp_vxlan_cmds.cpp:70
api_types.hpp
VOM::gbp_vxlan_cmds::dump_cmd::operator==
bool operator==(const dump_cmd &i) const
Comparison operator - only used for UT.
Definition: gbp_vxlan_cmds.cpp:107
string
const char *const string
Definition: cJSON.h:172