X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Fsnat%2Fsnat.h;h=f4e1c5c0007d1599492206af240d4db1e3a75b62;hb=586afd762bfa149f5ca167bd5fd5a0cd59ce94fe;hp=9cfd6be222e145dc1b45f2c74a7ba1da058f4754;hpb=066f034b903bda6e938bec1b12f01edef65ee9c4;p=vpp.git diff --git a/src/plugins/snat/snat.h b/src/plugins/snat/snat.h index 9cfd6be222e..f4e1c5c0007 100644 --- a/src/plugins/snat/snat.h +++ b/src/plugins/snat/snat.h @@ -217,9 +217,20 @@ typedef struct { dlist_elt_t * list_pool; } snat_main_per_thread_data_t; +struct snat_main_s; + +typedef u32 snat_icmp_match_function_t (struct snat_main_s *sm, + vlib_node_runtime_t *node, + u32 thread_index, + vlib_buffer_t *b0, + snat_session_key_t *p_key, + snat_session_key_t *p_value, + u8 *p_dont_translate, + void *d); + typedef u32 (snat_get_worker_function_t) (ip4_header_t * ip, u32 rx_fib_index); -typedef struct { +typedef struct snat_main_s { /* Main lookup tables */ clib_bihash_8_8_t out2in; clib_bihash_8_8_t in2out; @@ -233,6 +244,9 @@ typedef struct { /* Translated packets worker lookup => IP address + port number */ clib_bihash_8_8_t worker_by_out; + snat_icmp_match_function_t * icmp_match_in2out_cb; + snat_icmp_match_function_t * icmp_match_out2in_cb; + u32 num_workers; u32 first_worker_index; u32 next_worker; @@ -383,4 +397,45 @@ snat_proto_to_ip_proto (snat_protocol_t snat_proto) return ip_proto; } +typedef struct { + u16 src_port, dst_port; +} tcp_udp_header_t; + +u32 icmp_match_in2out_fast(snat_main_t *sm, vlib_node_runtime_t *node, + u32 thread_index, vlib_buffer_t *b0, + snat_session_key_t *p_key, + snat_session_key_t *p_value, + u8 *p_dont_translate, void *d); +u32 icmp_match_in2out_slow(snat_main_t *sm, vlib_node_runtime_t *node, + u32 thread_index, vlib_buffer_t *b0, + snat_session_key_t *p_key, + snat_session_key_t *p_value, + u8 *p_dont_translate, void *d); +u32 icmp_match_out2in_fast(snat_main_t *sm, vlib_node_runtime_t *node, + u32 thread_index, vlib_buffer_t *b0, + snat_session_key_t *p_key, + snat_session_key_t *p_value, + u8 *p_dont_translate, void *d); +u32 icmp_match_out2in_slow(snat_main_t *sm, vlib_node_runtime_t *node, + u32 thread_index, vlib_buffer_t *b0, + snat_session_key_t *p_key, + snat_session_key_t *p_value, + u8 *p_dont_translate, void *d); + +static_always_inline u8 +icmp_is_error_message (icmp46_header_t * icmp) +{ + switch(icmp->type) + { + case ICMP4_destination_unreachable: + case ICMP4_time_exceeded: + case ICMP4_parameter_problem: + case ICMP4_source_quench: + case ICMP4_redirect: + case ICMP4_alternate_host_address: + return 1; + } + return 0; +} + #endif /* __included_snat_h__ */