FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
acl_ethertype_cmds.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 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 ACL {
20 namespace acl_ethertype_cmds {
21 
23  const handle_t& itf,
25  : rpc_cmd(item)
26  , m_itf(itf)
27  , m_le(le)
28 {
29 }
30 
31 bool
32 bind_cmd::operator==(const bind_cmd& other) const
33 {
34  return (m_itf == other.m_itf && m_le == other.m_le);
35 }
36 
37 rc_t
39 {
40  msg_t req(con.ctx(), m_le.size(), std::ref(*this));
41  uint32_t i = 0;
42  uint8_t n_input = 0;
43 
44  auto& payload = req.get_request().get_payload();
45  payload.sw_if_index = m_itf.value();
46  payload.count = m_le.size();
47 
48  auto it = m_le.cbegin();
49  while (it != m_le.cend()) {
50  payload.whitelist[i] = it->getEthertype();
51  if (it->getDirection() == direction_t::INPUT)
52  n_input++;
53  ++it;
54  ++i;
55  }
56 
57  payload.n_input = n_input;
58 
59  VAPI_CALL(req.execute());
60 
61  return (wait());
62 }
63 
66 {
67  std::ostringstream s;
68  s << "ACL-Ethertype: " << m_hw_item.to_string()
69  << " itf:" << m_itf.to_string() << " ethertype-rules:";
70  auto it = m_le.cbegin();
71  while (it != m_le.cend()) {
72  s << it->to_string();
73  ++it;
74  }
75 
76  s << " rules-size:" << m_le.size();
77 
78  return (s.str());
79 }
80 
82  : rpc_cmd(item)
83  , m_itf(itf)
84 {
85 }
86 
87 bool
89 {
90  return (m_itf == other.m_itf);
91 }
92 
93 rc_t
95 {
96  msg_t req(con.ctx(), 0, std::ref(*this));
97 
98  auto& payload = req.get_request().get_payload();
99  payload.sw_if_index = m_itf.value();
100  payload.count = 0;
101 
102  payload.n_input = 0;
103 
104  VAPI_CALL(req.execute());
105 
106  wait();
108 
109  return rc_t::OK;
110 }
111 
114 {
115  std::ostringstream s;
116  s << "ACL-Ethertype-Unbind: " << m_hw_item.to_string()
117  << " itf:" << m_itf.to_string();
118  return (s.str());
119 }
120 
122  : m_itf(hdl)
123 {
124 }
125 
127  : m_itf(d.m_itf)
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 = m_itf.value();
144 
145  VAPI_CALL(m_dump->execute());
146 
147  wait();
148 
149  return rc_t::OK;
150 }
151 
154 {
155  return ("acl-ethertype-dump");
156 }
157 }; // namespace acl_ethertype_cmds
158 }; // namespace ACL
159 }; // namespace VOM
160 
161 /*
162  * fd.io coding-style-patch-verification: OFF
163  *
164  * Local Variables:
165  * eval: (c-set-style "mozilla")
166  * End:
167  */
VOM::HW::item< bool >
VOM::dump_cmd< vapi::Acl_interface_etype_whitelist_dump >::msg_t
vapi::Acl_interface_etype_whitelist_dump msg_t
Definition: dump_cmd.hpp:46
VOM::rpc_cmd< HW::item< bool >, vapi::Acl_interface_set_etype_whitelist >::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::ACL::acl_ethertype::ethertype_rules_t
std::multiset< ethertype_rule_t > ethertype_rules_t
The ethertype container.
Definition: acl_ethertype.hpp:100
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
VOM::handle_t::value
uint32_t value() const
get the value of the handle
Definition: types.cpp:93
VOM::ACL::acl_ethertype_cmds::bind_cmd::bind_cmd
bind_cmd(HW::item< bool > &item, const handle_t &itf, const acl_ethertype::ethertype_rules_t &le)
Constructor.
Definition: acl_ethertype_cmds.cpp:22
VOM::rpc_cmd
A base class for all RPC commands to VPP.
Definition: rpc_cmd.hpp:40
VOM::ACL::acl_ethertype_cmds::dump_cmd::operator==
bool operator==(const dump_cmd &i) const
Comparison operator - only used for UT.
Definition: acl_ethertype_cmds.cpp:132
con
Connection con
Definition: vapi_cpp_test.cpp:56
VOM::ACL::acl_ethertype_cmds::bind_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: acl_ethertype_cmds.cpp:65
VOM::rpc_cmd< HW::item< bool >, vapi::Acl_interface_set_etype_whitelist >::m_hw_item
HW::item< bool > & 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::Acl_interface_etype_whitelist_dump >::m_dump
std::unique_ptr< vapi::Acl_interface_etype_whitelist_dump > m_dump
The VAPI event registration.
Definition: dump_cmd.hpp:143
VAPI_CALL
#define VAPI_CALL(_stmt)
Convenince wrapper macro for error handling in VAPI sends.
Definition: types.hpp:29
VOM::ACL::acl_ethertype_cmds::unbind_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: acl_ethertype_cmds.cpp:113
VOM::connection
A representation of the connection to VPP.
Definition: connection.hpp:33
VOM::dump_cmd< vapi::Acl_interface_etype_whitelist_dump >::wait
rc_t wait()
Wait for the issue of the command to complete.
Definition: dump_cmd.hpp:93
VOM::ACL::acl_ethertype_cmds::bind_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: acl_ethertype_cmds.cpp:38
VOM::ACL::acl_ethertype_cmds::unbind_cmd::operator==
bool operator==(const unbind_cmd &i) const
Comparison operator - only used for UT.
Definition: acl_ethertype_cmds.cpp:88
VOM::rc_t::NOOP
const static rc_t NOOP
The HW write/update action was/has not been attempted.
Definition: types.hpp:104
i
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:261
VOM::direction_t::INPUT
const static direction_t INPUT
Permit Direction.
Definition: types.hpp:151
VOM::handle_t
A type declaration of an interface handle in VPP.
Definition: types.hpp:233
VOM::ACL::acl_ethertype_cmds::unbind_cmd
A command class that unbinds the ethertype list to the interface.
Definition: acl_ethertype_cmds.hpp:71
it
save_rewrite_length must be aligned so that reass doesn t overwrite it
Definition: buffer.h:421
VOM::HW::item::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: hw.hpp:161
VOM::ACL::acl_ethertype_cmds::dump_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: acl_ethertype_cmds.cpp:138
VOM::ACL::acl_ethertype_cmds::dump_cmd
A cmd class that Dumps all the acl ethertypes on given interface.
Definition: acl_ethertype_cmds.hpp:104
VOM::rpc_cmd< HW::item< bool >, vapi::Acl_interface_set_etype_whitelist >::msg_t
vapi::Acl_interface_set_etype_whitelist msg_t
convenient typedef
Definition: rpc_cmd.hpp:46
VOM::handle_t::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: types.cpp:69
VOM::ACL::acl_ethertype_cmds::dump_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: acl_ethertype_cmds.cpp:153
VOM::ACL::acl_ethertype_cmds::bind_cmd::operator==
bool operator==(const bind_cmd &i) const
Comparison operator - only used for UT.
Definition: acl_ethertype_cmds.cpp:32
VOM::ACL::acl_ethertype_cmds::unbind_cmd::unbind_cmd
unbind_cmd(HW::item< bool > &item, const handle_t &itf)
Constructor.
Definition: acl_ethertype_cmds.cpp:81
VOM::ACL::acl_ethertype_cmds::unbind_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: acl_ethertype_cmds.cpp:94
item
cJSON * item
Definition: cJSON.h:222
VOM::dump_cmd< vapi::Acl_interface_etype_whitelist_dump >::dump_cmd
dump_cmd()
Default Constructor.
Definition: dump_cmd.hpp:55
VOM::rc_t
Error codes that VPP will return during a HW write.
Definition: types.hpp:89
acl_ethertype_cmds.hpp
VOM::ACL::acl_ethertype_cmds::bind_cmd
A command class that binds the ethertype list to the interface.
Definition: acl_ethertype_cmds.hpp:31
VOM::dependency_t::ACL
@ ACL
ACLs.
string
const char *const string
Definition: cJSON.h:172