FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
vxlan_gbp_tunnel_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 #include "vom/api_types.hpp"
18 
20 
21 namespace VOM {
22 namespace vxlan_gbp_tunnel_cmds {
23 
25  const std::string& name,
26  const vxlan_tunnel::endpoint_t& ep,
27  bool is_l2,
28  handle_t mcast_itf)
29  : interface::create_cmd<vapi::Vxlan_gbp_tunnel_add_del>(item, name)
30  , m_ep(ep)
31  , m_is_l2(is_l2)
32  , m_mcast_itf(mcast_itf)
33 {
34 }
35 
36 bool
38 {
39  return (m_ep == other.m_ep);
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.is_add = 1;
50 
51  to_api(m_ep.src, payload.tunnel.src);
52  to_api(m_ep.dst, payload.tunnel.dst);
53  payload.tunnel.mcast_sw_if_index = m_mcast_itf.value();
54  payload.tunnel.encap_table_id = 0;
55  payload.tunnel.vni = m_ep.vni;
56  payload.tunnel.instance = ~0;
57  payload.tunnel.mode =
59 
60  VAPI_CALL(req.execute());
61 
62  wait();
63 
64  if (rc_t::OK == m_hw_item.rc()) {
66  }
67 
68  return rc_t::OK;
69 }
70 
73 {
74  std::ostringstream s;
75  s << "vxlan-gbp-tunnel-create: " << m_hw_item.to_string() << " "
76  << m_ep.to_string();
77 
78  return (s.str());
79 }
80 
82  const vxlan_tunnel::endpoint_t& ep)
83  : interface::delete_cmd<vapi::Vxlan_gbp_tunnel_add_del>(item)
84  , m_ep(ep)
85 {
86 }
87 
88 bool
90 {
91  return (m_ep == other.m_ep);
92 }
93 
94 rc_t
96 {
97  msg_t req(con.ctx(), std::ref(*this));
98 
99  auto payload = req.get_request().get_payload();
100 
101  payload.is_add = 0;
102 
103  to_api(m_ep.src, payload.tunnel.src);
104  to_api(m_ep.dst, payload.tunnel.dst);
105  payload.tunnel.mcast_sw_if_index = ~0;
106  payload.tunnel.encap_table_id = 0;
107  payload.tunnel.vni = m_ep.vni;
108 
109  VAPI_CALL(req.execute());
110 
111  wait();
113 
115  return (rc_t::OK);
116 }
117 
120 {
121  std::ostringstream s;
122  s << "vxlan-gbp-tunnel-delete: " << m_hw_item.to_string() << m_ep.to_string();
123 
124  return (s.str());
125 }
126 
128 {
129 }
130 
131 bool
132 dump_cmd::operator==(const dump_cmd& other) const
133 {
134  return (true);
135 }
136 
137 rc_t
139 {
140  m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
141 
142  auto& payload = m_dump->get_request().get_payload();
143  payload.sw_if_index = ~0;
144 
145  VAPI_CALL(m_dump->execute());
146 
147  wait();
148 
149  return rc_t::OK;
150 }
151 
154 {
155  return ("vxlan-gbp-tunnel-dump");
156 }
157 } // namespace vxlan_tunnel_cmds
158 } // namespace VOM
159 
160 /*
161  * fd.io coding-style-patch-verification: OFF
162  *
163  * Local Variables:
164  * eval: (c-set-style "mozilla")
165  * End:
166  */
VOM::vxlan_gbp_tunnel_cmds::dump_cmd
A cmd class that Dumps all the Vpp interfaces.
Definition: vxlan_gbp_tunnel_cmds.hpp:104
VOM::HW::item< handle_t >
VOM::vxlan_tunnel::endpoint_t::dst
boost::asio::ip::address dst
The destination IP address of the endpoint.
Definition: vxlan_tunnel.hpp:70
VOM::dump_cmd< vapi::Vxlan_gbp_tunnel_dump >::msg_t
vapi::Vxlan_gbp_tunnel_dump msg_t
Definition: dump_cmd.hpp:46
VOM::rpc_cmd< HW::item< handle_t >, vapi::Vxlan_gbp_tunnel_add_del >::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
VXLAN_GBP_API_TUNNEL_MODE_L3
@ VXLAN_GBP_API_TUNNEL_MODE_L3
Definition: vxlan_gbp.api:24
VOM::handle_t::value
uint32_t value() const
get the value of the handle
Definition: types.cpp:93
VOM::vxlan_gbp_tunnel_cmds::create_cmd::operator==
bool operator==(const create_cmd &i) const
Comparison operator - only used for UT.
Definition: vxlan_gbp_tunnel_cmds.cpp:37
con
Connection con
Definition: vapi_cpp_test.cpp:56
DEFINE_VAPI_MSG_IDS_VXLAN_GBP_API_JSON
DEFINE_VAPI_MSG_IDS_VXLAN_GBP_API_JSON
Definition: vxlan_gbp_tunnel_cmds.cpp:19
VOM::rpc_cmd< HW::item< handle_t >, vapi::Vxlan_gbp_tunnel_add_del >::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::Vxlan_gbp_tunnel_dump >::m_dump
std::unique_ptr< vapi::Vxlan_gbp_tunnel_dump > m_dump
The VAPI event registration.
Definition: dump_cmd.hpp:143
VOM::vxlan_tunnel::endpoint_t::vni
uint32_t vni
The VNI of the endpoint.
Definition: vxlan_tunnel.hpp:75
VOM::interface::create_cmd< vapi::Vxlan_gbp_tunnel_add_del >::insert_interface
void insert_interface()
add the created interface to the DB
Definition: interface.hpp:343
VOM::vxlan_gbp_tunnel_cmds::create_cmd::create_cmd
create_cmd(HW::item< handle_t > &item, const std::string &name, const vxlan_tunnel::endpoint_t &ep, bool is_l2, handle_t mcast_itf)
Create command constructor taking HW item to update and the endpoint values.
Definition: vxlan_gbp_tunnel_cmds.cpp:24
VAPI_CALL
#define VAPI_CALL(_stmt)
Convenince wrapper macro for error handling in VAPI sends.
Definition: types.hpp:29
VOM::vxlan_gbp_tunnel_cmds::dump_cmd::dump_cmd
dump_cmd()
Default Constructor.
Definition: vxlan_gbp_tunnel_cmds.cpp:127
VOM::vxlan_gbp_tunnel_cmds::create_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: vxlan_gbp_tunnel_cmds.cpp:43
VOM::vxlan_gbp_tunnel_cmds::delete_cmd::delete_cmd
delete_cmd(HW::item< handle_t > &item, const vxlan_tunnel::endpoint_t &ep)
delete command constructor taking HW item to update and the endpoint values
Definition: vxlan_gbp_tunnel_cmds.cpp:81
VOM::connection
A representation of the connection to VPP.
Definition: connection.hpp:33
VOM::dump_cmd< vapi::Vxlan_gbp_tunnel_dump >::wait
rc_t wait()
Wait for the issue of the command to complete.
Definition: dump_cmd.hpp:93
VOM::vxlan_tunnel::endpoint_t::src
boost::asio::ip::address src
The src IP address of the endpoint.
Definition: vxlan_tunnel.hpp:65
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
VOM::handle_t
A type declaration of an interface handle in VPP.
Definition: types.hpp:233
VOM::vxlan_gbp_tunnel_cmds::delete_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: vxlan_gbp_tunnel_cmds.cpp:95
VOM::HW::item::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: hw.hpp:161
VOM::vxlan_gbp_tunnel_cmds::delete_cmd
A functor class that creates an VXLAN tunnel.
Definition: vxlan_gbp_tunnel_cmds.hpp:70
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::Vxlan_gbp_tunnel_add_del >::msg_t
vapi::Vxlan_gbp_tunnel_add_del 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::Vxlan_gbp_tunnel_add_del >::remove_interface
void remove_interface()
remove the deleted interface from the DB
Definition: interface.hpp:412
VOM::vxlan_gbp_tunnel_cmds::dump_cmd::operator==
bool operator==(const dump_cmd &i) const
Comparison operator - only used for UT.
Definition: vxlan_gbp_tunnel_cmds.cpp:132
VOM::vxlan_tunnel::endpoint_t::to_string
std::string to_string() const
Debug print function.
Definition: vxlan_tunnel.cpp:59
item
cJSON * item
Definition: cJSON.h:222
VOM::vxlan_gbp_tunnel_cmds::dump_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: vxlan_gbp_tunnel_cmds.cpp:138
VOM::vxlan_gbp_tunnel_cmds::create_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: vxlan_gbp_tunnel_cmds.cpp:72
VOM::vxlan_gbp_tunnel_cmds::create_cmd
A Command class that creates an VXLAN tunnel.
Definition: vxlan_gbp_tunnel_cmds.hpp:31
VOM::vxlan_gbp_tunnel_cmds::delete_cmd::operator==
bool operator==(const delete_cmd &i) const
Comparison operator - only used for UT.
Definition: vxlan_gbp_tunnel_cmds.cpp:89
vxlan_gbp_tunnel_cmds.hpp
VOM::vxlan_gbp_tunnel_cmds::delete_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: vxlan_gbp_tunnel_cmds.cpp:119
vapi
Forward declarations.
Definition: vapi.hpp:44
VXLAN_GBP_API_TUNNEL_MODE_L2
@ VXLAN_GBP_API_TUNNEL_MODE_L2
Definition: vxlan_gbp.api:23
VOM::rc_t
Error codes that VPP will return during a HW write.
Definition: types.hpp:89
api_types.hpp
VOM::vxlan_tunnel::endpoint_t
Combaintion of attributes that are a unique key for a VXLAN tunnel.
Definition: vxlan_tunnel.hpp:39
VOM::vxlan_gbp_tunnel_cmds::dump_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: vxlan_gbp_tunnel_cmds.cpp:153
string
const char *const string
Definition: cJSON.h:172