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 | |
| 16 | #include "vom/acl_binding.hpp" |
| 17 | |
| 18 | DEFINE_VAPI_MSG_IDS_ACL_API_JSON; |
| 19 | |
| 20 | namespace VOM { |
| 21 | namespace ACL { |
| 22 | template <> |
| 23 | rc_t |
| 24 | l3_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 | |
| 41 | template <> |
| 42 | rc_t |
| 43 | l3_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 | |
| 60 | template <> |
| 61 | rc_t |
| 62 | l3_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 | |
| 76 | template <> |
| 77 | rc_t |
| 78 | l2_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 | |
| 95 | template <> |
| 96 | rc_t |
| 97 | l2_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 | |
| 114 | template <> |
| 115 | rc_t |
| 116 | l2_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 | */ |