blob: 8c33cd47b799955cd740a7d988cfc4924afcc11b [file] [log] [blame]
Neale Ranns812ed392017-10-16 04:20:13 -07001/*
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
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070016#include "vom/acl_binding_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070017
18DEFINE_VAPI_MSG_IDS_ACL_API_JSON;
19
20namespace VOM {
21namespace ACL {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070022namespace binding_cmds {
Neale Ranns812ed392017-10-16 04:20:13 -070023template <>
24rc_t
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070025l3_bind_cmd::issue(connection& con)
Neale Ranns812ed392017-10-16 04:20:13 -070026{
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
42template <>
Mohsin Kazmib5eb3b12018-02-26 18:36:17 +010043std::string
44l3_bind_cmd::to_string() const
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
53template <>
Neale Ranns812ed392017-10-16 04:20:13 -070054rc_t
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070055l3_unbind_cmd::issue(connection& con)
Neale Ranns812ed392017-10-16 04:20:13 -070056{
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
72template <>
Mohsin Kazmib5eb3b12018-02-26 18:36:17 +010073std::string
74l3_unbind_cmd::to_string() const
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
83template <>
Neale Ranns812ed392017-10-16 04:20:13 -070084rc_t
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070085l3_dump_cmd::issue(connection& con)
Neale Ranns812ed392017-10-16 04:20:13 -070086{
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
99template <>
Mohsin Kazmib5eb3b12018-02-26 18:36:17 +0100100std::string
101l3_dump_cmd::to_string() const
102{
103 return ("l3-acl-bind-dump");
104}
105
106template <>
Neale Ranns812ed392017-10-16 04:20:13 -0700107rc_t
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700108l2_bind_cmd::issue(connection& con)
Neale Ranns812ed392017-10-16 04:20:13 -0700109{
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;
Neale Ranns812ed392017-10-16 04:20:13 -0700115 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
124template <>
Mohsin Kazmib5eb3b12018-02-26 18:36:17 +0100125std::string
126l2_bind_cmd::to_string() const
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
135template <>
Neale Ranns812ed392017-10-16 04:20:13 -0700136rc_t
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700137l2_unbind_cmd::issue(connection& con)
Neale Ranns812ed392017-10-16 04:20:13 -0700138{
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;
Neale Ranns812ed392017-10-16 04:20:13 -0700144 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
153template <>
Mohsin Kazmib5eb3b12018-02-26 18:36:17 +0100154std::string
155l2_unbind_cmd::to_string() const
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
164template <>
Neale Ranns812ed392017-10-16 04:20:13 -0700165rc_t
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700166l2_dump_cmd::issue(connection& con)
Neale Ranns812ed392017-10-16 04:20:13 -0700167{
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}
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700179
Mohsin Kazmib5eb3b12018-02-26 18:36:17 +0100180template <>
181std::string
182l2_dump_cmd::to_string() const
183{
184 return ("l2-acl-bind-dump");
185}
186
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700187}; // namespace binding_cmds
188}; // namespace ACL
189}; // namespace VOM
Neale Ranns812ed392017-10-16 04:20:13 -0700190
191/*
192 * fd.io coding-style-patch-verification: ON
193 *
194 * Local Variables:
195 * eval: (c-set-style "mozilla")
196 * End:
197 */