NAT: VPP-1552 code migration from old multiarch scheme
[vpp.git] / src / plugins / nat / nat.h
index 1346720..c9139b3 100644 (file)
@@ -165,6 +165,7 @@ typedef enum
 #define NAT44_SES_O2I_FIN_ACK 8
 #define NAT44_SES_I2O_SYN 16
 #define NAT44_SES_O2I_SYN 32
+#define NAT44_SES_RST     64
 
 /* Session flags */
 #define SNAT_SESSION_FLAG_STATIC_MAPPING       1
@@ -174,6 +175,7 @@ typedef enum
 #define SNAT_SESSION_FLAG_ENDPOINT_DEPENDENT   16
 #define SNAT_SESSION_FLAG_FWD_BYPASS           32
 #define SNAT_SESSION_FLAG_AFFINITY             64
+#define SNAT_SESSION_FLAG_OUTPUT_FEATURE       128
 
 /* NAT interface flags */
 #define NAT_INTERFACE_FLAG_IS_INSIDE 1
@@ -220,6 +222,9 @@ typedef CLIB_PACKED(struct
   u8 state;
   u32 i2o_fin_seq;
   u32 o2i_fin_seq;
+
+  /* user index */
+  u32 user_index;
 }) snat_session_t;
 /* *INDENT-ON* */
 
@@ -488,11 +493,34 @@ typedef struct snat_main_s
   u32 fq_in2out_output_index;
   u32 fq_out2in_index;
 
-  /* in2out and out2in node index */
+  /* node indexes */
+  u32 error_node_index;
+
   u32 in2out_node_index;
   u32 in2out_output_node_index;
+  u32 in2out_fast_node_index;
+  u32 in2out_slowpath_node_index;
+  u32 in2out_slowpath_output_node_index;
+  u32 in2out_reass_node_index;
+  u32 ed_in2out_node_index;
+  u32 ed_in2out_slowpath_node_index;
+  u32 ed_in2out_reass_node_index;
   u32 out2in_node_index;
-  u32 error_node_index;
+  u32 out2in_fast_node_index;
+  u32 out2in_reass_node_index;
+  u32 ed_out2in_node_index;
+  u32 ed_out2in_slowpath_node_index;
+  u32 ed_out2in_reass_node_index;
+  u32 det_in2out_node_index;
+  u32 det_out2in_node_index;
+
+  u32 hairpinning_node_index;
+  u32 hairpin_dst_node_index;
+  u32 hairpin_src_node_index;
+  u32 ed_hairpinning_node_index;
+  u32 ed_hairpin_dst_node_index;
+  u32 ed_hairpin_src_node_index;
+
 
   /* Deterministic NAT mappings */
   snat_det_map_t *det_maps;
@@ -527,6 +555,10 @@ typedef struct snat_main_s
   u16 mss_clamping;
   u16 mss_value_net;
 
+  /* counters/gauges */
+  vlib_simple_counter_main_t total_users;
+  vlib_simple_counter_main_t total_sessions;
+
   /* API message ID base */
   u16 msg_id_base;
 
@@ -673,6 +705,12 @@ unformat_function_t unformat_snat_protocol;
 */
 #define is_lb_static_mapping(sm) (sm->flags & NAT_STATIC_MAPPING_FLAG_LB)
 
+/** \brief Check if client initiating TCP connection (received SYN from client)
+    @param t TCP header
+    @return 1 if client initiating TCP connection
+*/
+#define tcp_is_init(t) ((t->flags & TCP_FLAG_SYN) && !(t->flags & TCP_FLAG_ACK))
+
 /* logging */
 #define nat_log_err(...) \
   vlib_log(VLIB_LOG_LEVEL_ERR, snat_main.log_class, __VA_ARGS__)
@@ -848,6 +886,11 @@ int nat44_add_del_lb_static_mapping (ip4_address_t e_addr, u16 e_port,
                                     twice_nat_type_t twice_nat,
                                     u8 out2in_only, u8 * tag, u32 affinity);
 
+int nat44_lb_static_mapping_add_del_local (ip4_address_t e_addr, u16 e_port,
+                                          ip4_address_t l_addr, u16 l_port,
+                                          snat_protocol_t proto, u32 vrf_id,
+                                          u8 probability, u8 is_add);
+
 clib_error_t *snat_api_init (vlib_main_t * vm, snat_main_t * sm);
 
 /**