FD.io VPP  v21.10.1-2-g0a485f517
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  */
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  */
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  */
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  */
130  HW::item<bool> item;
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  */
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  */
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  */
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  */
235  HW::item<bool> item;
236 };
237 
238 }; // namespace nat_static_cmds
239 }; // namespace vom
240 
241 /*
242  * fd.io coding-style-patch-verification: OFF
243  *
244  * Local Variables:
245  * eval: (c-set-style "mozilla")
246  * End:
247  */
248 
249 #endif
VOM::HW::item< bool >
VOM::nat_static_cmds::dump_44_cmd::dump_44_cmd
dump_44_cmd()=default
Constructor.
VOM::nat_static_cmds::dump_44_cmd::~dump_44_cmd
~dump_44_cmd()=default
VOM
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
VOM::nat_static_cmds::dump_44_cmd::operator==
bool operator==(const dump_44_cmd &i) const
Comparison operator - only used for UT.
Definition: nat_static_cmds.cpp:124
VOM::nat_static_cmds::delete_44_cmd::delete_44_cmd
delete_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.
Definition: nat_static_cmds.cpp:72
VOM::nat_static_cmds::create_66_cmd
A command class that creates NAT 66 static mapping.
Definition: nat_static_cmds.hpp:136
VOM::nat_static_cmds::dump_66_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: nat_static_cmds.cpp:245
VOM::nat_static_cmds::dump_66_cmd
A cmd class that Dumps all the nat_statics.
Definition: nat_static_cmds.hpp:208
VOM::rpc_cmd
A base class for all RPC commands to VPP.
Definition: rpc_cmd.hpp:40
con
Connection con
Definition: vapi_cpp_test.cpp:56
VOM::nat_static_cmds::dump_44_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: nat_static_cmds.cpp:130
VOM::nat_static_cmds::dump_44_cmd
A cmd class that Dumps all the nat_statics.
Definition: nat_static_cmds.hpp:103
VOM::nat_static_cmds::delete_44_cmd
A cmd class that deletes a NAT 44 static mapping.
Definition: nat_static_cmds.hpp:67
VOM::nat_static_cmds::delete_66_cmd::delete_66_cmd
delete_66_cmd(HW::item< bool > &item, route::table_id_t id, const boost::asio::ip::address_v6 &inside, const boost::asio::ip::address_v6 &outside)
Constructor.
Definition: nat_static_cmds.cpp:191
VOM::nat_static_cmds::delete_66_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: nat_static_cmds.cpp:209
VOM::nat_static_cmds::create_44_cmd
A command class that creates NAT 44 static mapping.
Definition: nat_static_cmds.hpp:31
VOM::nat_static_cmds::dump_66_cmd::~dump_66_cmd
~dump_66_cmd()=default
VOM::nat_static_cmds::delete_66_cmd::operator==
bool operator==(const delete_66_cmd &i) const
Comparison operator - only used for UT.
Definition: nat_static_cmds.cpp:202
VOM::nat_static_cmds::create_44_cmd::create_44_cmd
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.
Definition: nat_static_cmds.cpp:24
VOM::nat_static_cmds::dump_44_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: nat_static_cmds.cpp:142
nat_static.hpp
VOM::connection
A representation of the connection to VPP.
Definition: connection.hpp:33
VOM::nat_static_cmds::delete_44_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: nat_static_cmds.cpp:113
VOM::nat_static_cmds::create_44_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: nat_static_cmds.cpp:62
VOM::nat_static_cmds::create_44_cmd::operator==
bool operator==(const create_44_cmd &i) const
Comparison operator - only used for UT.
Definition: nat_static_cmds.cpp:35
dump_cmd.hpp
VOM::nat_static_cmds::delete_44_cmd::operator==
bool operator==(const delete_44_cmd &i) const
Comparison operator - only used for UT.
Definition: nat_static_cmds.cpp:83
VOM::nat_static_cmds::create_66_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: nat_static_cmds.cpp:165
VOM::nat_static_cmds::dump_66_cmd::dump_66_cmd
dump_66_cmd()=default
Constructor.
VOM::rpc_cmd< HW::item< bool >, vapi::Nat44_add_del_static_mapping >::item
HW::item< bool > & item()
return the HW item the command updates
Definition: rpc_cmd.hpp:66
VOM::nat_static_cmds::delete_44_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: nat_static_cmds.cpp:90
VOM::nat_static_cmds::create_66_cmd::create_66_cmd
create_66_cmd(HW::item< bool > &item, route::table_id_t id, const boost::asio::ip::address_v6 &inside, const boost::asio::ip::address_v6 &outside)
Constructor.
Definition: nat_static_cmds.cpp:147
VOM::nat_static_cmds::create_66_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: nat_static_cmds.cpp:181
VOM::nat_static_cmds::create_44_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: nat_static_cmds.cpp:42
VOM::nat_static_cmds::dump_66_cmd::operator==
bool operator==(const dump_66_cmd &i) const
Comparison operator - only used for UT.
Definition: nat_static_cmds.cpp:239
VOM::nat_static_cmds::dump_66_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: nat_static_cmds.cpp:257
i
int i
Definition: flowhash_template.h:376
VOM::route::table_id_t
uint32_t table_id_t
type def the table-id
Definition: prefix.hpp:121
VOM::nat_static_cmds::delete_66_cmd
A cmd class that deletes a NAT 66 static mapping.
Definition: nat_static_cmds.hpp:172
VOM::rc_t
Error codes that VPP will return during a HW write.
Definition: types.hpp:89
VOM::dump_cmd
A base class for VPP dump commands.
Definition: dump_cmd.hpp:43
VOM::nat_static_cmds::delete_66_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: nat_static_cmds.cpp:228
VOM::nat_static_cmds::create_66_cmd::operator==
bool operator==(const create_66_cmd &i) const
Comparison operator - only used for UT.
Definition: nat_static_cmds.cpp:158
string
const char *const string
Definition: cJSON.h:172