Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 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 | |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 16 | #include "vom/acl_binding_cmds.hpp" |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 17 | |
| 18 | DEFINE_VAPI_MSG_IDS_ACL_API_JSON; |
| 19 | |
| 20 | namespace VOM { |
| 21 | namespace ACL { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 22 | namespace binding_cmds { |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 23 | template <> |
| 24 | rc_t |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 25 | l3_bind_cmd::issue(connection& con) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 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 <> |
Mohsin Kazmi | b5eb3b1 | 2018-02-26 18:36:17 +0100 | [diff] [blame^] | 43 | std::string |
| 44 | l3_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 | |
| 53 | template <> |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 54 | rc_t |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 55 | l3_unbind_cmd::issue(connection& con) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 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 <> |
Mohsin Kazmi | b5eb3b1 | 2018-02-26 18:36:17 +0100 | [diff] [blame^] | 73 | std::string |
| 74 | l3_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 | |
| 83 | template <> |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 84 | rc_t |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 85 | l3_dump_cmd::issue(connection& con) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 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 <> |
Mohsin Kazmi | b5eb3b1 | 2018-02-26 18:36:17 +0100 | [diff] [blame^] | 100 | std::string |
| 101 | l3_dump_cmd::to_string() const |
| 102 | { |
| 103 | return ("l3-acl-bind-dump"); |
| 104 | } |
| 105 | |
| 106 | template <> |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 107 | rc_t |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 108 | l2_bind_cmd::issue(connection& con) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 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; |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 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 <> |
Mohsin Kazmi | b5eb3b1 | 2018-02-26 18:36:17 +0100 | [diff] [blame^] | 125 | std::string |
| 126 | l2_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 | |
| 135 | template <> |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 136 | rc_t |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 137 | l2_unbind_cmd::issue(connection& con) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 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; |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 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 <> |
Mohsin Kazmi | b5eb3b1 | 2018-02-26 18:36:17 +0100 | [diff] [blame^] | 154 | std::string |
| 155 | l2_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 | |
| 164 | template <> |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 165 | rc_t |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 166 | l2_dump_cmd::issue(connection& con) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 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 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 179 | |
Mohsin Kazmi | b5eb3b1 | 2018-02-26 18:36:17 +0100 | [diff] [blame^] | 180 | template <> |
| 181 | std::string |
| 182 | l2_dump_cmd::to_string() const |
| 183 | { |
| 184 | return ("l2-acl-bind-dump"); |
| 185 | } |
| 186 | |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 187 | }; // namespace binding_cmds |
| 188 | }; // namespace ACL |
| 189 | }; // namespace VOM |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 190 | |
| 191 | /* |
| 192 | * fd.io coding-style-patch-verification: ON |
| 193 | * |
| 194 | * Local Variables: |
| 195 | * eval: (c-set-style "mozilla") |
| 196 | * End: |
| 197 | */ |