FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
l2_vtr_cmds.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 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/l2_vtr_cmds.hpp"
17 
18 namespace VOM {
19 namespace l2_vtr_cmds {
20 
22  const handle_t& itf,
23  uint16_t tag)
24  : rpc_cmd(item)
25  , m_itf(itf)
26  , m_tag(tag)
27 {
28 }
29 
30 bool
31 set_cmd::operator==(const set_cmd& other) const
32 {
33  return (
34  (m_hw_item.data() == other.m_hw_item.data() && m_itf == other.m_itf) &&
35  (m_tag == other.m_tag));
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  payload.sw_if_index = m_itf.value();
45  payload.vtr_op = m_hw_item.data().value();
46  payload.push_dot1q = 1;
47  payload.tag1 = m_tag;
48 
49  VAPI_CALL(req.execute());
50 
51  return (wait());
52 }
53 
56 {
57  std::ostringstream s;
58  s << "L2-vtr-set: " << m_hw_item.to_string() << " itf:" << m_itf.to_string()
59  << " tag:" << m_tag;
60 
61  return (s.str());
62 }
63 
64 }; // namespace vtr_cmds
65 }; // namespace VOM
66 
67 /*
68  * fd.io coding-style-patch-verification: OFF
69  *
70  * Local Variables:
71  * eval: (c-set-style "mozilla")
72  * End:
73  */
VOM::HW::item< l2_vtr::option_t >
VOM::rpc_cmd< HW::item< l2_vtr::option_t >, vapi::L2_interface_vlan_tag_rewrite >::wait
rc_t wait()
Wait on the commands promise.
Definition: rpc_cmd.hpp:82
VOM
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
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
VOM::l2_vtr_cmds::set_cmd::operator==
bool operator==(const set_cmd &i) const
Comparison operator - only used for UT.
Definition: l2_vtr_cmds.cpp:31
con
Connection con
Definition: vapi_cpp_test.cpp:56
VOM::rpc_cmd< HW::item< l2_vtr::option_t >, vapi::L2_interface_vlan_tag_rewrite >::m_hw_item
HW::item< l2_vtr::option_t > & m_hw_item
A reference to an object's HW::item that the command will update.
Definition: rpc_cmd.hpp:134
VOM::l2_vtr_cmds::set_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: l2_vtr_cmds.cpp:39
VOM::enum_base::value
int value() const
Return the value of the enum - same as integer conversion.
Definition: enum_base.hpp:88
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::l2_vtr_cmds::set_cmd::set_cmd
set_cmd(HW::item< l2_vtr::option_t > &item, const handle_t &itf, uint16_t tag)
Constructor.
Definition: l2_vtr_cmds.cpp:21
VOM::handle_t
A type declaration of an interface handle in VPP.
Definition: types.hpp:233
VOM::HW::item::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: hw.hpp:161
VOM::l2_vtr_cmds::set_cmd
A cmd class sets the VTR operation.
Definition: l2_vtr_cmds.hpp:29
l2_vtr_cmds.hpp
VOM::rpc_cmd< HW::item< l2_vtr::option_t >, vapi::L2_interface_vlan_tag_rewrite >::msg_t
vapi::L2_interface_vlan_tag_rewrite 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::l2_vtr_cmds::set_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: l2_vtr_cmds.cpp:55
item
cJSON * item
Definition: cJSON.h:222
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