FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
acl_binding_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 
16 #include "vom/acl_binding_cmds.hpp"
17 
19 
20 namespace VOM {
21 namespace ACL {
22 namespace binding_cmds {
23 template <>
24 rc_t
26 {
27  msg_t req(con.ctx(), std::ref(*this));
28 
29  auto& payload = req.get_request().get_payload();
30  payload.sw_if_index = m_itf.value();
31  payload.is_add = 1;
32  payload.is_input = (m_direction == direction_t::INPUT ? 1 : 0);
33  payload.acl_index = m_acl.value();
34 
35  VAPI_CALL(req.execute());
36 
37  return (wait());
38 }
39 
40 template <>
43 {
44  std::ostringstream s;
45  s << "l3-acl-bind:[" << m_direction.to_string()
46  << " itf:" << m_itf.to_string() << " acl:" << m_acl.to_string() << "]";
47 
48  return (s.str());
49 }
50 
51 template <>
52 rc_t
54 {
55  msg_t req(con.ctx(), std::ref(*this));
56 
57  auto& payload = req.get_request().get_payload();
58  payload.sw_if_index = m_itf.value();
59  payload.is_add = 0;
60  payload.is_input = (m_direction == direction_t::INPUT ? 1 : 0);
61  payload.acl_index = m_acl.value();
62 
63  VAPI_CALL(req.execute());
64 
65  return (wait());
66 }
67 
68 template <>
71 {
72  std::ostringstream s;
73  s << "l3-acl-unbind:[" << m_direction.to_string()
74  << " itf:" << m_itf.to_string() << " acl:" << m_acl.to_string() << "]";
75 
76  return (s.str());
77 }
78 
79 template <>
80 rc_t
82 {
83  m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
84 
85  auto& payload = m_dump->get_request().get_payload();
86  payload.sw_if_index = ~0;
87 
88  VAPI_CALL(m_dump->execute());
89 
90  wait();
91 
92  return rc_t::OK;
93 }
94 
95 template <>
98 {
99  return ("l3-acl-bind-dump");
100 }
101 
102 template <>
103 rc_t
105 {
106  msg_t req(con.ctx(), std::ref(*this));
107 
108  auto& payload = req.get_request().get_payload();
109  payload.sw_if_index = m_itf.value();
110  payload.is_add = 1;
111  payload.acl_index = m_acl.value();
112 
113  VAPI_CALL(req.execute());
114 
115  return (wait());
116 }
117 
118 template <>
121 {
122  std::ostringstream s;
123  s << "l2-acl-bind:[" << m_direction.to_string()
124  << " itf:" << m_itf.to_string() << " acl:" << m_acl.to_string() << "]";
125 
126  return (s.str());
127 }
128 
129 template <>
130 rc_t
132 {
133  msg_t req(con.ctx(), std::ref(*this));
134 
135  auto& payload = req.get_request().get_payload();
136  payload.sw_if_index = m_itf.value();
137  payload.is_add = 0;
138  payload.acl_index = m_acl.value();
139 
140  VAPI_CALL(req.execute());
141 
142  return (wait());
143 }
144 
145 template <>
148 {
149  std::ostringstream s;
150  s << "l2-acl-unbind:[" << m_direction.to_string()
151  << " itf:" << m_itf.to_string() << " acl:" << m_acl.to_string() << "]";
152 
153  return (s.str());
154 }
155 
156 template <>
157 rc_t
158 l2_dump_cmd::issue(connection& con)
159 {
160  m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
161 
162  auto& payload = m_dump->get_request().get_payload();
163  payload.sw_if_index = ~0;
164 
165  VAPI_CALL(m_dump->execute());
166 
167  wait();
168 
169  return rc_t::OK;
170 }
171 
172 template <>
175 {
176  return ("l2-acl-bind-dump");
177 }
178 
179 }; // namespace binding_cmds
180 }; // namespace ACL
181 }; // namespace VOM
182 
183 /*
184  * fd.io coding-style-patch-verification: OFF
185  *
186  * Local Variables:
187  * eval: (c-set-style "mozilla")
188  * End:
189  */
DEFINE_VAPI_MSG_IDS_ACL_API_JSON
DEFINE_VAPI_MSG_IDS_ACL_API_JSON
Definition: acl_binding_cmds.cpp:18
VOM::ACL::binding_cmds::dump_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: acl_binding_cmds.cpp:81
VOM::dump_cmd< DUMP >::msg_t
DUMP msg_t
Definition: dump_cmd.hpp:46
VOM::rpc_cmd< HW::item< bool >, BIND >::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
acl_binding_cmds.hpp
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
con
Connection con
Definition: vapi_cpp_test.cpp:56
VOM::dump_cmd< DUMP >::m_dump
std::unique_ptr< DUMP > m_dump
The VAPI event registration.
Definition: dump_cmd.hpp:143
VOM::ACL::binding_cmds::dump_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: acl_binding_cmds.cpp:97
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::dump_cmd< DUMP >::wait
rc_t wait()
Wait for the issue of the command to complete.
Definition: dump_cmd.hpp:93
VOM::direction_t::INPUT
const static direction_t INPUT
Permit Direction.
Definition: types.hpp:151
VOM::ACL::binding_cmds::bind_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: acl_binding_cmds.cpp:25
VOM::ACL::binding_cmds::unbind_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: acl_binding_cmds.cpp:70
VOM::rpc_cmd< HW::item< bool >, BIND >::msg_t
BIND msg_t
convenient typedef
Definition: rpc_cmd.hpp:46
VOM::enum_base::to_string
const std::string & to_string() const
convert to string format for debug purposes
Definition: enum_base.hpp:36
VOM::ACL::binding_cmds::bind_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: acl_binding_cmds.cpp:42
VOM::handle_t::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: types.cpp:69
VOM::rc_t
Error codes that VPP will return during a HW write.
Definition: types.hpp:89
VOM::ACL::binding_cmds::unbind_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: acl_binding_cmds.cpp:53
string
const char *const string
Definition: cJSON.h:172