Neale Ranns | 041fa50 | 2017-12-20 08:49:51 -0800 | [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 | #ifndef __VOM_NAT_BINDING_CMDS_H__ |
| 17 | #define __VOM_NAT_BINDING_CMDS_H__ |
| 18 | |
Neale Ranns | 041fa50 | 2017-12-20 08:49:51 -0800 | [diff] [blame] | 19 | #include "vom/dump_cmd.hpp" |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 20 | #include "vom/nat_binding.hpp" |
| 21 | #include "vom/rpc_cmd.hpp" |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 22 | |
| 23 | #include <vapi/nat.api.vapi.hpp> |
| 24 | |
| 25 | namespace VOM { |
| 26 | namespace nat_binding_cmds { |
| 27 | /** |
Neale Ranns | 041fa50 | 2017-12-20 08:49:51 -0800 | [diff] [blame] | 28 | * A functor class that binds a NAT configuration to an input interface |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 29 | */ |
| 30 | class bind_44_input_cmd |
Neale Ranns | 041fa50 | 2017-12-20 08:49:51 -0800 | [diff] [blame] | 31 | : public rpc_cmd<HW::item<bool>, rc_t, vapi::Nat44_interface_add_del_feature> |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 32 | { |
| 33 | public: |
Neale Ranns | 041fa50 | 2017-12-20 08:49:51 -0800 | [diff] [blame] | 34 | /** |
| 35 | * Constructor |
| 36 | */ |
| 37 | bind_44_input_cmd(HW::item<bool>& item, |
| 38 | const handle_t& itf, |
| 39 | const nat_binding::zone_t& zone); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 40 | |
Neale Ranns | 041fa50 | 2017-12-20 08:49:51 -0800 | [diff] [blame] | 41 | /** |
| 42 | * Issue the command to VPP/HW |
| 43 | */ |
| 44 | rc_t issue(connection& con); |
| 45 | /** |
| 46 | * convert to string format for debug purposes |
| 47 | */ |
| 48 | std::string to_string() const; |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 49 | |
Neale Ranns | 041fa50 | 2017-12-20 08:49:51 -0800 | [diff] [blame] | 50 | /** |
| 51 | * Comparison operator - only used for UT |
| 52 | */ |
| 53 | bool operator==(const bind_44_input_cmd& i) const; |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 54 | |
| 55 | private: |
Neale Ranns | 041fa50 | 2017-12-20 08:49:51 -0800 | [diff] [blame] | 56 | /** |
| 57 | * The interface to bind |
| 58 | */ |
| 59 | const handle_t m_itf; |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 60 | |
Neale Ranns | 041fa50 | 2017-12-20 08:49:51 -0800 | [diff] [blame] | 61 | /** |
| 62 | * The zone the interface is in |
| 63 | */ |
| 64 | const nat_binding::zone_t m_zone; |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | /** |
Neale Ranns | 041fa50 | 2017-12-20 08:49:51 -0800 | [diff] [blame] | 68 | * A cmd class that unbinds a NAT configuration from an input interface |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 69 | */ |
| 70 | class unbind_44_input_cmd |
Neale Ranns | 041fa50 | 2017-12-20 08:49:51 -0800 | [diff] [blame] | 71 | : public rpc_cmd<HW::item<bool>, rc_t, vapi::Nat44_interface_add_del_feature> |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 72 | { |
| 73 | public: |
Neale Ranns | 041fa50 | 2017-12-20 08:49:51 -0800 | [diff] [blame] | 74 | /** |
| 75 | * Constructor |
| 76 | */ |
| 77 | unbind_44_input_cmd(HW::item<bool>& item, |
| 78 | const handle_t& itf, |
| 79 | const nat_binding::zone_t& zone); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 80 | |
Neale Ranns | 041fa50 | 2017-12-20 08:49:51 -0800 | [diff] [blame] | 81 | /** |
| 82 | * Issue the command to VPP/HW |
| 83 | */ |
| 84 | rc_t issue(connection& con); |
| 85 | /** |
| 86 | * convert to string format for debug purposes |
| 87 | */ |
| 88 | std::string to_string() const; |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 89 | |
Neale Ranns | 041fa50 | 2017-12-20 08:49:51 -0800 | [diff] [blame] | 90 | /** |
| 91 | * Comparison operator - only used for UT |
| 92 | */ |
| 93 | bool operator==(const unbind_44_input_cmd& i) const; |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 94 | |
| 95 | private: |
Neale Ranns | 041fa50 | 2017-12-20 08:49:51 -0800 | [diff] [blame] | 96 | /** |
| 97 | * The interface to bind |
| 98 | */ |
| 99 | const handle_t m_itf; |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 100 | |
Neale Ranns | 041fa50 | 2017-12-20 08:49:51 -0800 | [diff] [blame] | 101 | /** |
| 102 | * The zone the interface is in |
| 103 | */ |
| 104 | const nat_binding::zone_t m_zone; |
| 105 | }; |
| 106 | |
| 107 | /** |
| 108 | * A functor class that binds a NAT configuration to an output interface |
| 109 | */ |
| 110 | class bind_44_output_cmd |
| 111 | : public rpc_cmd<HW::item<bool>, |
| 112 | rc_t, |
| 113 | vapi::Nat44_interface_add_del_output_feature> |
| 114 | { |
| 115 | public: |
| 116 | /** |
| 117 | * Constructor |
| 118 | */ |
| 119 | bind_44_output_cmd(HW::item<bool>& item, |
| 120 | const handle_t& itf, |
| 121 | const nat_binding::zone_t& zone); |
| 122 | |
| 123 | /** |
| 124 | * Issue the command to VPP/HW |
| 125 | */ |
| 126 | rc_t issue(connection& con); |
| 127 | /** |
| 128 | * convert to string format for debug purposes |
| 129 | */ |
| 130 | std::string to_string() const; |
| 131 | |
| 132 | /** |
| 133 | * Comparison operator - only used for UT |
| 134 | */ |
| 135 | bool operator==(const bind_44_output_cmd& i) const; |
| 136 | |
| 137 | private: |
| 138 | /** |
| 139 | * The interface to bind |
| 140 | */ |
| 141 | const handle_t m_itf; |
| 142 | |
| 143 | /** |
| 144 | * The zone the interface is in |
| 145 | */ |
| 146 | const nat_binding::zone_t m_zone; |
| 147 | }; |
| 148 | |
| 149 | /** |
| 150 | * A cmd class that unbinds a NAT configuration from an output interface |
| 151 | */ |
| 152 | class unbind_44_output_cmd |
| 153 | : public rpc_cmd<HW::item<bool>, |
| 154 | rc_t, |
| 155 | vapi::Nat44_interface_add_del_output_feature> |
| 156 | { |
| 157 | public: |
| 158 | /** |
| 159 | * Constructor |
| 160 | */ |
| 161 | unbind_44_output_cmd(HW::item<bool>& item, |
| 162 | const handle_t& itf, |
| 163 | const nat_binding::zone_t& zone); |
| 164 | |
| 165 | /** |
| 166 | * Issue the command to VPP/HW |
| 167 | */ |
| 168 | rc_t issue(connection& con); |
| 169 | /** |
| 170 | * convert to string format for debug purposes |
| 171 | */ |
| 172 | std::string to_string() const; |
| 173 | |
| 174 | /** |
| 175 | * Comparison operator - only used for UT |
| 176 | */ |
| 177 | bool operator==(const unbind_44_output_cmd& i) const; |
| 178 | |
| 179 | private: |
| 180 | /** |
| 181 | * The interface to bind |
| 182 | */ |
| 183 | const handle_t m_itf; |
| 184 | |
| 185 | /** |
| 186 | * The zone the interface is in |
| 187 | */ |
| 188 | const nat_binding::zone_t m_zone; |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 189 | }; |
| 190 | |
| 191 | /** |
| 192 | * A cmd class that Dumps all the nat_statics |
| 193 | */ |
Neale Ranns | 041fa50 | 2017-12-20 08:49:51 -0800 | [diff] [blame] | 194 | class dump_input_44_cmd : public dump_cmd<vapi::Nat44_interface_dump> |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 195 | { |
| 196 | public: |
Neale Ranns | 041fa50 | 2017-12-20 08:49:51 -0800 | [diff] [blame] | 197 | /** |
| 198 | * Constructor |
| 199 | */ |
| 200 | dump_input_44_cmd(); |
| 201 | dump_input_44_cmd(const dump_input_44_cmd& d); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 202 | |
Neale Ranns | 041fa50 | 2017-12-20 08:49:51 -0800 | [diff] [blame] | 203 | /** |
| 204 | * Issue the command to VPP/HW |
| 205 | */ |
| 206 | rc_t issue(connection& con); |
| 207 | /** |
| 208 | * convert to string format for debug purposes |
| 209 | */ |
| 210 | std::string to_string() const; |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 211 | |
Neale Ranns | 041fa50 | 2017-12-20 08:49:51 -0800 | [diff] [blame] | 212 | /** |
| 213 | * Comparison operator - only used for UT |
| 214 | */ |
| 215 | bool operator==(const dump_input_44_cmd& i) const; |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 216 | |
| 217 | private: |
Neale Ranns | 041fa50 | 2017-12-20 08:49:51 -0800 | [diff] [blame] | 218 | /** |
| 219 | * HW reutrn code |
| 220 | */ |
| 221 | HW::item<bool> item; |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 222 | }; |
Neale Ranns | 041fa50 | 2017-12-20 08:49:51 -0800 | [diff] [blame] | 223 | |
| 224 | /** |
| 225 | * A cmd class that Dumps all the nat_statics |
| 226 | */ |
| 227 | class dump_output_44_cmd |
| 228 | : public dump_cmd<vapi::Nat44_interface_output_feature_dump> |
| 229 | { |
| 230 | public: |
| 231 | /** |
| 232 | * Constructor |
| 233 | */ |
| 234 | dump_output_44_cmd(); |
| 235 | dump_output_44_cmd(const dump_output_44_cmd& d); |
| 236 | |
| 237 | /** |
| 238 | * Issue the command to VPP/HW |
| 239 | */ |
| 240 | rc_t issue(connection& con); |
| 241 | /** |
| 242 | * convert to string format for debug purposes |
| 243 | */ |
| 244 | std::string to_string() const; |
| 245 | |
| 246 | /** |
| 247 | * Comparison operator - only used for UT |
| 248 | */ |
| 249 | bool operator==(const dump_output_44_cmd& i) const; |
| 250 | |
| 251 | private: |
| 252 | /** |
| 253 | * HW reutrn code |
| 254 | */ |
| 255 | HW::item<bool> item; |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 256 | }; |
Neale Ranns | 041fa50 | 2017-12-20 08:49:51 -0800 | [diff] [blame] | 257 | |
| 258 | }; // namespace nat_binding_cmds |
| 259 | }; // namespace VOM |
| 260 | |
| 261 | /* |
| 262 | * fd.io coding-style-patch-verification: ON |
| 263 | * |
| 264 | * Local Variables: |
| 265 | * eval: (c-set-style "mozilla") |
| 266 | * End: |
| 267 | */ |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 268 | |
| 269 | #endif |