FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
gbp_route_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_route_domain_cmds {
20 
22  scope_t scope,
23  const handle_t ip4_uu_fwd,
24  const handle_t ip6_uu_fwd)
25  : rpc_cmd(item)
26  , m_scope(scope)
27  , m_ip4_uu_fwd(ip4_uu_fwd)
28  , m_ip6_uu_fwd(ip6_uu_fwd)
29 {
30 }
31 
32 bool
34 {
35  return ((m_hw_item.data() == other.m_hw_item.data()) &&
36  (m_scope == other.m_scope) && (m_ip4_uu_fwd == other.m_ip4_uu_fwd) &&
37  (m_ip6_uu_fwd == other.m_ip6_uu_fwd));
38 }
39 
40 rc_t
42 {
43  msg_t req(con.ctx(), std::ref(*this));
44 
45  auto& payload = req.get_request().get_payload();
46 
47  payload.rd.rd_id = m_hw_item.data();
48  payload.rd.scope = m_scope;
49  payload.rd.ip4_table_id = m_hw_item.data();
50  payload.rd.ip6_table_id = m_hw_item.data();
51  payload.rd.ip4_uu_sw_if_index = m_ip4_uu_fwd.value();
52  payload.rd.ip6_uu_sw_if_index = m_ip6_uu_fwd.value();
53 
54  VAPI_CALL(req.execute());
55 
56  return (wait());
57 }
58 
61 {
62  std::ostringstream s;
63  s << "gbp-route-domain: " << m_hw_item.to_string() << " scope:" << m_scope
64  << " ip4-uu-fwd:" << m_ip4_uu_fwd.to_string()
65  << " ip6-uu-fwd:" << m_ip6_uu_fwd.to_string();
66 
67  return (s.str());
68 }
69 
71  : rpc_cmd(item)
72 {
73 }
74 
75 bool
77 {
78  return (m_hw_item.data() == other.m_hw_item.data());
79 }
80 
81 rc_t
83 {
84  msg_t req(con.ctx(), std::ref(*this));
85 
86  auto& payload = req.get_request().get_payload();
87 
88  payload.rd_id = m_hw_item.data();
89 
90  VAPI_CALL(req.execute());
91 
92  wait();
94 
95  return rc_t::OK;
96 }
97 
100 {
101  std::ostringstream s;
102  s << "gbp-route-domain: " << m_hw_item.to_string();
103 
104  return (s.str());
105 }
106 
107 bool
108 dump_cmd::operator==(const dump_cmd& other) const
109 {
110  return (true);
111 }
112 
113 rc_t
115 {
116  m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
117 
118  VAPI_CALL(m_dump->execute());
119 
120  wait();
121 
122  return rc_t::OK;
123 }
124 
127 {
128  return ("gbp-route-domain-dump");
129 }
130 
131 }; // namespace gbp_route_domain_cmds
132 }; // namespace VOM
133 
134 /*
135  * fd.io coding-style-patch-verification: OFF
136  *
137  * Local Variables:
138  * eval: (c-set-style "mozilla")
139  * End:
140  */
VOM::HW::item< uint32_t >
VOM::gbp_route_domain_cmds::delete_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: gbp_route_domain_cmds.cpp:82
VOM::dump_cmd< vapi::Gbp_route_domain_dump >::msg_t
vapi::Gbp_route_domain_dump msg_t
Definition: dump_cmd.hpp:46
VOM::gbp_route_domain_cmds::delete_cmd::delete_cmd
delete_cmd(HW::item< uint32_t > &item)
Constructor.
Definition: gbp_route_domain_cmds.cpp:70
VOM::rpc_cmd< HW::item< uint32_t >, vapi::Gbp_route_domain_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::scope_t
uint16_t scope_t
Definition: gbp_types.hpp:28
VOM::rc_t::OK
const static rc_t OK
The HW write was successfull.
Definition: types.hpp:109
VOM::handle_t::value
uint32_t value() const
get the value of the handle
Definition: types.cpp:93
VOM::rpc_cmd
A base class for all RPC commands to VPP.
Definition: rpc_cmd.hpp:40
con
Connection con
Definition: vapi_cpp_test.cpp:56
VOM::gbp_route_domain_cmds::delete_cmd::operator==
bool operator==(const delete_cmd &i) const
Comparison operator - only used for UT.
Definition: gbp_route_domain_cmds.cpp:76
VOM::rpc_cmd< HW::item< uint32_t >, vapi::Gbp_route_domain_add >::m_hw_item
HW::item< uint32_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_route_domain_dump >::m_dump
std::unique_ptr< vapi::Gbp_route_domain_dump > m_dump
The VAPI event registration.
Definition: dump_cmd.hpp:143
VOM::gbp_route_domain_cmds::delete_cmd
A cmd class that Delete an Route-Domain.
Definition: gbp_route_domain_cmds.hpp:65
VOM::gbp_route_domain_cmds::create_cmd::create_cmd
create_cmd(HW::item< uint32_t > &item, scope_t scope, const handle_t ip4_uu_fwd, const handle_t ip6_uu_fwd)
Constructor.
Definition: gbp_route_domain_cmds.cpp:21
VAPI_CALL
#define VAPI_CALL(_stmt)
Convenince wrapper macro for error handling in VAPI sends.
Definition: types.hpp:29
VOM::gbp_route_domain_cmds::create_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: gbp_route_domain_cmds.cpp:60
VOM::connection
A representation of the connection to VPP.
Definition: connection.hpp:33
VOM::dump_cmd< vapi::Gbp_route_domain_dump >::wait
rc_t wait()
Wait for the issue of the command to complete.
Definition: dump_cmd.hpp:93
VOM::rc_t::NOOP
const static rc_t NOOP
The HW write/update action was/has not been attempted.
Definition: types.hpp:104
scope
vl_api_gbp_scope_t scope
Definition: gbp.api:78
VOM::gbp_route_domain_cmds::create_cmd
A command class that creates an Route-Domain.
Definition: gbp_route_domain_cmds.hpp:30
VOM::handle_t
A type declaration of an interface handle in VPP.
Definition: types.hpp:233
VOM::gbp_route_domain_cmds::delete_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: gbp_route_domain_cmds.cpp:99
VOM::HW::item::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: hw.hpp:161
VOM::gbp_route_domain_cmds::dump_cmd
A cmd class that Dumps all the route domains.
Definition: gbp_route_domain_cmds.hpp:92
VOM::rpc_cmd< HW::item< uint32_t >, vapi::Gbp_route_domain_add >::msg_t
vapi::Gbp_route_domain_add msg_t
convenient typedef
Definition: rpc_cmd.hpp:46
VOM::HW::item::data
T & data()
Return the data read/written.
Definition: hw.hpp:109
VOM::handle_t::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: types.cpp:69
VOM::gbp_route_domain_cmds::dump_cmd::operator==
bool operator==(const dump_cmd &i) const
Comparison operator - only used for UT.
Definition: gbp_route_domain_cmds.cpp:108
gbp_route_domain_cmds.hpp
item
cJSON * item
Definition: cJSON.h:222
VOM::gbp_route_domain_cmds::dump_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: gbp_route_domain_cmds.cpp:114
VOM::gbp_route_domain_cmds::create_cmd::operator==
bool operator==(const create_cmd &i) const
Comparison operator - only used for UT.
Definition: gbp_route_domain_cmds.cpp:33
VOM::gbp_route_domain_cmds::create_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: gbp_route_domain_cmds.cpp:41
VOM::gbp_route_domain_cmds::dump_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: gbp_route_domain_cmds.cpp:126
VOM::rc_t
Error codes that VPP will return during a HW write.
Definition: types.hpp:89
string
const char *const string
Definition: cJSON.h:172