FD.io VPP  v19.04.1-1-ge4a0f9f
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  const handle_t ip4_uu_fwd,
23  const handle_t ip6_uu_fwd)
24  : rpc_cmd(item)
25  , m_ip4_uu_fwd(ip4_uu_fwd)
26  , m_ip6_uu_fwd(ip6_uu_fwd)
27 {
28 }
29 
30 bool
32 {
33  return ((m_hw_item.data() == other.m_hw_item.data()) &&
34  (m_ip4_uu_fwd == other.m_ip4_uu_fwd) &&
35  (m_ip6_uu_fwd == other.m_ip6_uu_fwd));
36 }
37 
38 rc_t
40 {
41  msg_t req(con.ctx(), std::ref(*this));
42 
43  auto& payload = req.get_request().get_payload();
44 
45  payload.rd.rd_id = m_hw_item.data();
46  payload.rd.ip4_table_id = m_hw_item.data();
47  payload.rd.ip6_table_id = m_hw_item.data();
48  payload.rd.ip4_uu_sw_if_index = m_ip4_uu_fwd.value();
49  payload.rd.ip6_uu_sw_if_index = m_ip6_uu_fwd.value();
50 
51  VAPI_CALL(req.execute());
52 
53  return (wait());
54 }
55 
56 std::string
58 {
59  std::ostringstream s;
60  s << "gbp-route-domain: " << m_hw_item.to_string()
61  << " ip4-uu-fwd:" << m_ip4_uu_fwd.to_string()
62  << " ip6-uu-fwd:" << m_ip6_uu_fwd.to_string();
63 
64  return (s.str());
65 }
66 
68  : rpc_cmd(item)
69 {
70 }
71 
72 bool
74 {
75  return (m_hw_item.data() == other.m_hw_item.data());
76 }
77 
78 rc_t
80 {
81  msg_t req(con.ctx(), std::ref(*this));
82 
83  auto& payload = req.get_request().get_payload();
84 
85  payload.rd_id = m_hw_item.data();
86 
87  VAPI_CALL(req.execute());
88 
89  wait();
91 
92  return rc_t::OK;
93 }
94 
95 std::string
97 {
98  std::ostringstream s;
99  s << "gbp-route-domain: " << m_hw_item.to_string();
100 
101  return (s.str());
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-route-domain-dump");
126 }
127 
128 }; // namespace gbp_route_domain_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  */
std::string to_string() const
convert to string format for debug purposes
static const rc_t NOOP
The HW write/update action was/has not been attempted.
Definition: types.hpp:104
A cmd class that Dumps all the route domains.
uint32_t value() const
get the value of the handle
Definition: types.cpp:93
rc_t issue(connection &con)
Issue the command to VPP/HW.
delete_cmd(HW::item< uint32_t > &item)
Constructor.
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
T & data()
Return the data read/written.
Definition: hw.hpp:109
std::string to_string() const
convert to string format for debug purposes
Definition: types.cpp:69
rc_t issue(connection &con)
Issue the command to VPP/HW.
A representation of the connection to VPP.
Definition: connection.hpp:33
A cmd class that Delete an Route-Domain.
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.
A command class that creates an Route-Domain.
A type declaration of an interface handle in VPP.
Definition: types.hpp:233
static const rc_t OK
The HW write was successfull.
Definition: types.hpp:109
rc_t issue(connection &con)
Issue the command to VPP/HW.
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
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
create_cmd(HW::item< uint32_t > &item, const handle_t ip4_uu_fwd, const handle_t ip6_uu_fwd)
Constructor.
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
bool operator==(const delete_cmd &i) const
Comparison operator - only used for UT.
bool operator==(const create_cmd &i) const
Comparison operator - only used for UT.
std::string to_string() const
convert to string format for debug purposes
HW::item< uint32_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< uint32_t > & item()
return the HW item the command updates
Definition: rpc_cmd.hpp:66
vapi::Gbp_route_domain_add msg_t
convenient typedef
Definition: rpc_cmd.hpp:46