FD.io VPP  v18.07-rc0-415-g6c78436
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  m_hw_item.set(wait());
38 
39  return rc_t::OK;
40 }
41 
42 template <>
43 std::string
45 {
46  std::ostringstream s;
47  s << "l3-acl-bind:[" << m_direction.to_string()
48  << " itf:" << m_itf.to_string() << " acl:" << m_acl.to_string() << "]";
49 
50  return (s.str());
51 }
52 
53 template <>
54 rc_t
56 {
57  msg_t req(con.ctx(), std::ref(*this));
58 
59  auto& payload = req.get_request().get_payload();
60  payload.sw_if_index = m_itf.value();
61  payload.is_add = 0;
62  payload.is_input = (m_direction == direction_t::INPUT ? 1 : 0);
63  payload.acl_index = m_acl.value();
64 
65  VAPI_CALL(req.execute());
66 
67  m_hw_item.set(wait());
68 
69  return rc_t::OK;
70 }
71 
72 template <>
73 std::string
75 {
76  std::ostringstream s;
77  s << "l3-acl-unbind:[" << m_direction.to_string()
78  << " itf:" << m_itf.to_string() << " acl:" << m_acl.to_string() << "]";
79 
80  return (s.str());
81 }
82 
83 template <>
84 rc_t
86 {
87  m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
88 
89  auto& payload = m_dump->get_request().get_payload();
90  payload.sw_if_index = ~0;
91 
92  VAPI_CALL(m_dump->execute());
93 
94  wait();
95 
96  return rc_t::OK;
97 }
98 
99 template <>
100 std::string
102 {
103  return ("l3-acl-bind-dump");
104 }
105 
106 template <>
107 rc_t
109 {
110  msg_t req(con.ctx(), std::ref(*this));
111 
112  auto& payload = req.get_request().get_payload();
113  payload.sw_if_index = m_itf.value();
114  payload.is_add = 1;
115  payload.acl_index = m_acl.value();
116 
117  VAPI_CALL(req.execute());
118 
119  m_hw_item.set(wait());
120 
121  return rc_t::OK;
122 }
123 
124 template <>
125 std::string
127 {
128  std::ostringstream s;
129  s << "l2-acl-bind:[" << m_direction.to_string()
130  << " itf:" << m_itf.to_string() << " acl:" << m_acl.to_string() << "]";
131 
132  return (s.str());
133 }
134 
135 template <>
136 rc_t
138 {
139  msg_t req(con.ctx(), std::ref(*this));
140 
141  auto& payload = req.get_request().get_payload();
142  payload.sw_if_index = m_itf.value();
143  payload.is_add = 0;
144  payload.acl_index = m_acl.value();
145 
146  VAPI_CALL(req.execute());
147 
148  m_hw_item.set(wait());
149 
150  return rc_t::OK;
151 }
152 
153 template <>
154 std::string
156 {
157  std::ostringstream s;
158  s << "l2-acl-unbind:[" << m_direction.to_string()
159  << " itf:" << m_itf.to_string() << " acl:" << m_acl.to_string() << "]";
160 
161  return (s.str());
162 }
163 
164 template <>
165 rc_t
167 {
168  m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
169 
170  auto& payload = m_dump->get_request().get_payload();
171  payload.sw_if_index = ~0;
172 
173  VAPI_CALL(m_dump->execute());
174 
175  wait();
176 
177  return rc_t::OK;
178 }
179 
180 template <>
181 std::string
183 {
184  return ("l2-acl-bind-dump");
185 }
186 
187 }; // namespace binding_cmds
188 }; // namespace ACL
189 }; // namespace VOM
190 
191 /*
192  * fd.io coding-style-patch-verification: ON
193  *
194  * Local Variables:
195  * eval: (c-set-style "mozilla")
196  * End:
197  */
HW::item< bool > & m_hw_item
A reference to an object&#39;s HW::item that the command will update.
Definition: rpc_cmd.hpp:135
rc_t issue(connection &con)
Issue the command to VPP/HW.
uint32_t value() const
get the value of the handle
Definition: types.cpp:93
Error codes that VPP will return during a HW write.
Definition: types.hpp:90
static const direction_t INPUT
Permit Direction.
Definition: types.hpp:154
rc_t issue(connection &con)
Issue the command to VPP/HW.
rc_t issue(connection &con)
Issue the command to VPP/HW.
std::string to_string() const
convert to string format for debug purposes
Definition: types.cpp:69
A representation of the connection to VPP.
Definition: connection.hpp:33
std::string to_string() const
convert to string format for debug purposes
#define VAPI_CALL(_stmt)
Convenince wrapper macro for error handling in VAPI sends.
Definition: types.hpp:29
std::string to_string() const
convert to string format for debug purposes
static const rc_t OK
The HW write was successfull.
Definition: types.hpp:112
std::string to_string() const
convert to string format for debug purposes
vapi::Connection & ctx()
Retrun the VAPI context the commands will use.
Definition: connection.cpp:49
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
void set(const rc_t &rc)
Set the HW return code - should only be called from the family of Command objects.
Definition: hw.hpp:124
DEFINE_VAPI_MSG_IDS_ACL_API_JSON
const std::string & to_string() const
convert to string format for debug purposes
Definition: enum_base.hpp:36
rc_t wait()
Wait on the commands promise.
Definition: rpc_cmd.hpp:89