summaryrefslogtreecommitdiffstats
path: root/src/plugins/nat/lib
diff options
context:
space:
mode:
authorFilip Varga <fivarga@cisco.com>2020-09-14 11:20:16 +0200
committerOle Tr�an <otroan@employees.org>2020-10-07 09:05:50 +0000
commit1f36023d29137825b8a09578d09b955046c2415b (patch)
treec00726718d9d8b4f5ecc74c45d9a2d790deb0250 /src/plugins/nat/lib
parentd1762e614d1e05cbeda4d91e921fa663b2b46c03 (diff)
nat: move nat64 to a subfeature
Type: refactor Change-Id: I3b9e17164647d2019b1f40cffeed63393345219e Signed-off-by: Filip Varga <fivarga@cisco.com>
Diffstat (limited to 'src/plugins/nat/lib')
-rw-r--r--src/plugins/nat/lib/lib.h30
-rw-r--r--src/plugins/nat/lib/nat_inlines.h24
2 files changed, 53 insertions, 1 deletions
diff --git a/src/plugins/nat/lib/lib.h b/src/plugins/nat/lib/lib.h
index bd1c43338e6..febe829ce56 100644
--- a/src/plugins/nat/lib/lib.h
+++ b/src/plugins/nat/lib/lib.h
@@ -19,6 +19,28 @@
#ifndef included_nat_lib_h__
#define included_nat_lib_h__
+#include <vlibapi/api.h>
+
+/* NAT API Configuration flags */
+#define foreach_nat_config_flag \
+ _(0x01, IS_TWICE_NAT) \
+ _(0x02, IS_SELF_TWICE_NAT) \
+ _(0x04, IS_OUT2IN_ONLY) \
+ _(0x08, IS_ADDR_ONLY) \
+ _(0x10, IS_OUTSIDE) \
+ _(0x20, IS_INSIDE) \
+ _(0x40, IS_STATIC) \
+ _(0x80, IS_EXT_HOST_VALID)
+
+typedef enum nat_config_flags_t_
+{
+#define _(n,f) NAT_API_##f = n,
+ foreach_nat_config_flag
+#undef _
+} nat_config_flags_t;
+
+#define foreach_nat_counter _ (tcp) _ (udp) _ (icmp) _ (other) _ (drops)
+
#define foreach_nat_error \
_ (VALUE_EXIST, -1, "Value already exists") \
_ (NO_SUCH_ENTRY, -2, "No such entry") \
@@ -45,6 +67,14 @@ typedef enum
#undef _
} nat_protocol_t;
+/* default session timeouts */
+#define NAT_UDP_TIMEOUT 300
+#define NAT_TCP_TRANSITORY_TIMEOUT 240
+#define NAT_TCP_ESTABLISHED_TIMEOUT 7440
+#define NAT_ICMP_TIMEOUT 60
+
+// TODO: move common formating definitions here
+
#endif /* included_nat_lib_h__ */
/*
* fd.io coding-style-patch-verification: ON
diff --git a/src/plugins/nat/lib/nat_inlines.h b/src/plugins/nat/lib/nat_inlines.h
index fc8e160bb2b..c75b8043cc1 100644
--- a/src/plugins/nat/lib/nat_inlines.h
+++ b/src/plugins/nat/lib/nat_inlines.h
@@ -13,9 +13,21 @@
* limitations under the License.
*/
+#ifndef __included_lib_nat_inlines_h__
+#define __included_lib_nat_inlines_h__
+
#include <vnet/tcp/tcp_packet.h>
#include <vnet/ip/ip4_packet.h>
+static inline void
+increment_v4_address (ip4_address_t * a)
+{
+ u32 v;
+
+ v = clib_net_to_host_u32 (a->as_u32) + 1;
+ a->as_u32 = clib_host_to_net_u32 (v);
+}
+
always_inline void
mss_clamping (u16 mss_clamping, tcp_header_t * tcp, ip_csum_t * sum)
{
@@ -54,7 +66,7 @@ mss_clamping (u16 mss_clamping, tcp_header_t * tcp, ip_csum_t * sum)
mss = *(u16 *) (data + 2);
if (clib_net_to_host_u16 (mss) > mss_clamping)
{
- u16 mss_value_net = clib_host_to_net_u16(mss_clamping);
+ u16 mss_value_net = clib_host_to_net_u16 (mss_clamping);
*sum =
ip_csum_update (*sum, mss, mss_value_net, ip4_header_t,
length);
@@ -64,3 +76,13 @@ mss_clamping (u16 mss_clamping, tcp_header_t * tcp, ip_csum_t * sum)
}
}
}
+
+#endif /* __included_lib_nat_inlines_h__ */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */