19 #ifndef __included_nat_inlines_h__ 20 #define __included_nat_inlines_h__ 29 snat_proto = (ip_proto == IP_PROTOCOL_UDP) ? SNAT_PROTOCOL_UDP : snat_proto;
30 snat_proto = (ip_proto == IP_PROTOCOL_TCP) ? SNAT_PROTOCOL_TCP : snat_proto;
32 (ip_proto == IP_PROTOCOL_ICMP) ? SNAT_PROTOCOL_ICMP : snat_proto;
34 (ip_proto == IP_PROTOCOL_ICMP6) ? SNAT_PROTOCOL_ICMP : snat_proto;
44 ip_proto = (snat_proto == SNAT_PROTOCOL_UDP) ? IP_PROTOCOL_UDP : ip_proto;
45 ip_proto = (snat_proto == SNAT_PROTOCOL_TCP) ? IP_PROTOCOL_TCP : ip_proto;
46 ip_proto = (snat_proto == SNAT_PROTOCOL_ICMP) ? IP_PROTOCOL_ICMP : ip_proto;
56 case ICMP4_destination_unreachable:
57 case ICMP4_time_exceeded:
58 case ICMP4_parameter_problem:
59 case ICMP4_source_quench:
61 case ICMP4_alternate_host_address:
69 u32 sw_if_index0,
u32 ip4_addr)
107 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
110 n_left_from =
vec_len (bi_vector);
112 while (n_left_from > 0)
115 while (n_left_from > 0 && n_left_to_next > 0)
117 u32 bi0 = to_next[0] = from[0];
125 n_left_to_next, bi0, next);
154 u_key.
addr = ses->in2out.addr;
157 if (!clib_bihash_search_8_8 (&tsm->
user_hash, &kv, &value))
179 ses->i2o_fin_seq = clib_net_to_host_u32 (tcp->seq_number);
184 if (clib_net_to_host_u32 (tcp->ack_number) > ses->o2i_fin_seq)
204 ses->o2i_fin_seq = clib_net_to_host_u32 (tcp->seq_number);
209 if (clib_net_to_host_u32 (tcp->ack_number) > ses->i2o_fin_seq)
228 s->total_bytes += bytes;
239 s->per_user_list_head_index, s->per_user_index);
#define snat_is_session_static(s)
Check if SNAT session is created from static mapping.
#define NAT44_SES_I2O_FIN
u8 runtime_data[0]
Function dependent node-runtime data.
static_always_inline u8 icmp_is_error_message(icmp46_header_t *icmp)
ip4_address_t * ip4_interface_first_address(ip4_main_t *im, u32 sw_if_index, ip_interface_address_t **result_ia)
static void make_sm_kv(clib_bihash_kv_8_8_t *kv, ip4_address_t *addr, u8 proto, u32 fib_index, u16 port)
#define nat44_is_ses_closed(s)
#define NAT44_SES_O2I_FIN
struct _tcp_header tcp_header_t
static int nat44_set_tcp_session_state_o2i(snat_main_t *sm, snat_session_t *ses, tcp_header_t *tcp, u32 thread_index)
clib_bihash_8_8_t user_hash
u32 max_translations_per_user
#define static_always_inline
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
static u8 maximum_sessions_exceeded(snat_main_t *sm, u32 thread_index)
static void nat44_delete_session(snat_main_t *sm, snat_session_t *ses, u32 thread_index)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
void nat_free_session_data(snat_main_t *sm, snat_session_t *s, u32 thread_index)
static void clib_dlist_addtail(dlist_elt_t *pool, u32 head_index, u32 new_index)
#define pool_put(P, E)
Free an object E in pool P.
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
vlib_error_t error
Error code for buffers to be enqueued to error handler.
#define nat_log_debug(...)
static u8 snat_proto_to_ip_proto(snat_protocol_t snat_proto)
static void nat44_session_update_counters(snat_session_t *s, f64 now, uword bytes)
8 octet key, 8 octet key value pair
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
static void make_ed_kv(clib_bihash_kv_16_8_t *kv, ip4_address_t *l_addr, ip4_address_t *r_addr, u8 proto, u32 fib_index, u16 l_port, u16 r_port)
static int nat44_set_tcp_session_state_i2o(snat_main_t *sm, snat_session_t *ses, tcp_header_t *tcp, u32 thread_index)
Set TCP session state.
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
#define pool_put_index(p, i)
Free pool element with given index.
static void nat44_session_update_lru(snat_main_t *sm, snat_session_t *s, u32 thread_index)
Per-user LRU list maintenance.
static void clib_dlist_remove(dlist_elt_t *pool, u32 index)
format_function_t format_snat_session
static u32 ip_proto_to_snat_proto(u8 ip_proto)
The NAT inline functions.
static void user_session_increment(snat_main_t *sm, snat_user_t *u, u8 is_static)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
snat_main_per_thread_data_t * per_thread_data
static u8 is_interface_addr(snat_main_t *sm, vlib_node_runtime_t *node, u32 sw_if_index0, u32 ip4_addr)
#define NAT44_SES_I2O_FIN_ACK
static void nat_send_all_to_node(vlib_main_t *vm, u32 *bi_vector, vlib_node_runtime_t *node, vlib_error_t *error, u32 next)
#define NAT44_SES_O2I_FIN_ACK
snat_session_t * sessions
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static uword pool_elts(void *v)
Number of active elements in a pool.