blob: 27d50434c3bddb07dac24acf7eb23970286b5cf0 [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
16#include "vom/acl_binding.hpp"
17
18DEFINE_VAPI_MSG_IDS_ACL_API_JSON;
19
20namespace VOM {
21namespace ACL {
22template <>
23rc_t
24l3_binding::bind_cmd::issue(connection& con)
25{
26 msg_t req(con.ctx(), std::ref(*this));
27
28 auto& payload = req.get_request().get_payload();
29 payload.sw_if_index = m_itf.value();
30 payload.is_add = 1;
31 payload.is_input = (m_direction == direction_t::INPUT ? 1 : 0);
32 payload.acl_index = m_acl.value();
33
34 VAPI_CALL(req.execute());
35
36 m_hw_item.set(wait());
37
38 return rc_t::OK;
39}
40
41template <>
42rc_t
43l3_binding::unbind_cmd::issue(connection& con)
44{
45 msg_t req(con.ctx(), std::ref(*this));
46
47 auto& payload = req.get_request().get_payload();
48 payload.sw_if_index = m_itf.value();
49 payload.is_add = 0;
50 payload.is_input = (m_direction == direction_t::INPUT ? 1 : 0);
51 payload.acl_index = m_acl.value();
52
53 VAPI_CALL(req.execute());
54
55 m_hw_item.set(wait());
56
57 return rc_t::OK;
58}
59
60template <>
61rc_t
62l3_binding::dump_cmd::issue(connection& con)
63{
64 m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
65
66 auto& payload = m_dump->get_request().get_payload();
67 payload.sw_if_index = ~0;
68
69 VAPI_CALL(m_dump->execute());
70
71 wait();
72
73 return rc_t::OK;
74}
75
76template <>
77rc_t
78l2_binding::bind_cmd::issue(connection& con)
79{
80 msg_t req(con.ctx(), std::ref(*this));
81
82 auto& payload = req.get_request().get_payload();
83 payload.sw_if_index = m_itf.value();
84 payload.is_add = 1;
85 // payload.is_input = (m_direction == direction_t::INPUT ? 1 : 0);
86 payload.acl_index = m_acl.value();
87
88 VAPI_CALL(req.execute());
89
90 m_hw_item.set(wait());
91
92 return rc_t::OK;
93}
94
95template <>
96rc_t
97l2_binding::unbind_cmd::issue(connection& con)
98{
99 msg_t req(con.ctx(), std::ref(*this));
100
101 auto& payload = req.get_request().get_payload();
102 payload.sw_if_index = m_itf.value();
103 payload.is_add = 0;
104 // payload.is_input = (m_direction == direction_t::INPUT ? 1 : 0);
105 payload.acl_index = m_acl.value();
106
107 VAPI_CALL(req.execute());
108
109 m_hw_item.set(wait());
110
111 return rc_t::OK;
112}
113
114template <>
115rc_t
116l2_binding::dump_cmd::issue(connection& con)
117{
118 m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
119
120 auto& payload = m_dump->get_request().get_payload();
121 payload.sw_if_index = ~0;
122
123 VAPI_CALL(m_dump->execute());
124
125 wait();
126
127 return rc_t::OK;
128}
129}
130}
131
132/*
133 * fd.io coding-style-patch-verification: ON
134 *
135 * Local Variables:
136 * eval: (c-set-style "mozilla")
137 * End:
138 */