FD.io VPP  v20.09-64-g4f7b92f0a
Vector Packet Processing
nat_static_cmds.hpp
Go to the documentation of this file.
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 #ifndef __VOM_NAT_STATIC_CMDS_H__
17 #define __VOM_NAT_STATIC_CMDS_H__
18 
19 #include "nat_static.hpp"
20 #include "vom/dump_cmd.hpp"
21 
22 #include <vapi/nat.api.vapi.hpp>
23 #include <vapi/nat66.api.vapi.hpp>
24 
25 namespace VOM {
26 namespace nat_static_cmds {
27 
28 /**
29  * A command class that creates NAT 44 static mapping
30  */
32  : public rpc_cmd<HW::item<bool>, vapi::Nat44_add_del_static_mapping>
33 {
34 public:
35  /**
36  * Constructor
37  */
40  const boost::asio::ip::address_v4& inside,
41  const boost::asio::ip::address_v4& outside);
42 
43  /**
44  * Issue the command to VPP/HW
45  */
46  rc_t issue(connection& con);
47 
48  /**
49  * convert to string format for debug purposes
50  */
51  std::string to_string() const;
52 
53  /**
54  * Comparison operator - only used for UT
55  */
56  bool operator==(const create_44_cmd& i) const;
57 
58 private:
59  route::table_id_t m_id;
60  const boost::asio::ip::address_v4 m_inside;
61  const boost::asio::ip::address_v4 m_outside;
62 };
63 
64 /**
65  * A cmd class that deletes a NAT 44 static mapping
66  */
68  : public rpc_cmd<HW::item<bool>, vapi::Nat44_add_del_static_mapping>
69 {
70 public:
71  /**
72  * Constructor
73  */
76  const boost::asio::ip::address_v4& inside,
77  const boost::asio::ip::address_v4& outside);
78 
79  /**
80  * Issue the command to VPP/HW
81  */
82  rc_t issue(connection& con);
83 
84  /**
85  * convert to string format for debug purposes
86  */
87  std::string to_string() const;
88 
89  /**
90  * Comparison operator - only used for UT
91  */
92  bool operator==(const delete_44_cmd& i) const;
93 
94 private:
95  route::table_id_t m_id;
96  const boost::asio::ip::address_v4 m_inside;
97  const boost::asio::ip::address_v4 m_outside;
98 };
99 
100 /**
101  * A cmd class that Dumps all the nat_statics
102  */
103 class dump_44_cmd : public dump_cmd<vapi::Nat44_static_mapping_dump>
104 {
105 public:
106  /**
107  * Constructor
108  */
109  dump_44_cmd() = default;
110  ~dump_44_cmd() = default;
111 
112  /**
113  * Issue the command to VPP/HW
114  */
115  rc_t issue(connection& con);
116  /**
117  * convert to string format for debug purposes
118  */
119  std::string to_string() const;
120 
121  /**
122  * Comparison operator - only used for UT
123  */
124  bool operator==(const dump_44_cmd& i) const;
125 
126 private:
127  /**
128  * HW reutrn code
129  */
131 };
132 
133 /**
134  * A command class that creates NAT 66 static mapping
135  */
137  : public rpc_cmd<HW::item<bool>, vapi::Nat66_add_del_static_mapping>
138 {
139 public:
140  /**
141  * Constructor
142  */
145  const boost::asio::ip::address_v6& inside,
146  const boost::asio::ip::address_v6& outside);
147 
148  /**
149  * Issue the command to VPP/HW
150  */
151  rc_t issue(connection& con);
152 
153  /**
154  * convert to string format for debug purposes
155  */
156  std::string to_string() const;
157 
158  /**
159  * Comparison operator - only used for UT
160  */
161  bool operator==(const create_66_cmd& i) const;
162 
163 private:
164  route::table_id_t m_id;
165  const boost::asio::ip::address_v6 m_inside;
166  const boost::asio::ip::address_v6 m_outside;
167 };
168 
169 /**
170  * A cmd class that deletes a NAT 66 static mapping
171  */
173  : public rpc_cmd<HW::item<bool>, vapi::Nat66_add_del_static_mapping>
174 {
175 public:
176  /**
177  * Constructor
178  */
181  const boost::asio::ip::address_v6& inside,
182  const boost::asio::ip::address_v6& outside);
183 
184  /**
185  * Issue the command to VPP/HW
186  */
187  rc_t issue(connection& con);
188 
189  /**
190  * convert to string format for debug purposes
191  */
192  std::string to_string() const;
193 
194  /**
195  * Comparison operator - only used for UT
196  */
197  bool operator==(const delete_66_cmd& i) const;
198 
199 private:
200  route::table_id_t m_id;
201  const boost::asio::ip::address_v6 m_inside;
202  const boost::asio::ip::address_v6 m_outside;
203 };
204 
205 /**
206  * A cmd class that Dumps all the nat_statics
207  */
208 class dump_66_cmd : public dump_cmd<vapi::Nat66_static_mapping_dump>
209 {
210 public:
211  /**
212  * Constructor
213  */
214  dump_66_cmd() = default;
215  ~dump_66_cmd() = default;
216 
217  /**
218  * Issue the command to VPP/HW
219  */
220  rc_t issue(connection& con);
221  /**
222  * convert to string format for debug purposes
223  */
224  std::string to_string() const;
225 
226  /**
227  * Comparison operator - only used for UT
228  */
229  bool operator==(const dump_66_cmd& i) const;
230 
231 private:
232  /**
233  * HW reutrn code
234  */
236 };
237 
238 }; // namespace nat_static_cmds
239 }; // namespace vom
240 
241 /*
242  * fd.io coding-style-patch-verification: ON
243  *
244  * Local Variables:
245  * eval: (c-set-style "mozilla")
246  * End:
247  */
248 
249 #endif
A cmd class that deletes a NAT 44 static mapping.
uint32_t table_id_t
type def the table-id
Definition: prefix.hpp:121
bool operator==(const create_44_cmd &i) const
Comparison operator - only used for UT.
A command class that creates NAT 44 static mapping.
rc_t issue(connection &con)
Issue the command to VPP/HW.
create_44_cmd(HW::item< bool > &item, route::table_id_t id, const boost::asio::ip::address_v4 &inside, const boost::asio::ip::address_v4 &outside)
Constructor.
Error codes that VPP will return during a HW write.
Definition: types.hpp:89
A representation of the connection to VPP.
Definition: connection.hpp:33
A base class for all RPC commands to VPP.
Definition: rpc_cmd.hpp:40
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:317
A cmd class that deletes a NAT 66 static mapping.
std::string to_string() const
convert to string format for debug purposes
A cmd class that Dumps all the nat_statics.
A cmd class that Dumps all the nat_statics.
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
A command class that creates NAT 66 static mapping.
A base class for VPP dump commands.
Definition: dump_cmd.hpp:43
HW::item< bool > & item()
return the HW item the command updates
Definition: rpc_cmd.hpp:66