23 #ifndef __included_det44_h__ 24 #define __included_det44_h__ 45 #define foreach_det44_session_state \ 46 _(0, UNKNOWN, "unknown") \ 47 _(1, UDP_ACTIVE, "udp-active") \ 48 _(2, TCP_SYN_SENT, "tcp-syn-sent") \ 49 _(3, TCP_ESTABLISHED, "tcp-established") \ 50 _(4, TCP_FIN_WAIT, "tcp-fin-wait") \ 51 _(5, TCP_CLOSE_WAIT, "tcp-close-wait") \ 52 _(6, TCP_CLOSING, "tcp-closing") \ 53 _(7, TCP_LAST_ACK, "tcp-last-ack") \ 54 _(8, TCP_CLOSED, "tcp-closed") \ 55 _(9, ICMP_ACTIVE, "icmp-active") 59 #define _(v, N, s) DET44_SESSION_##N = v, 64 #define DET44_SES_PER_USER 1000 194 #define det44_log_err(...) \ 195 vlib_log(VLIB_LOG_LEVEL_ERR, det44_main.log_class, __VA_ARGS__) 196 #define det44_log_warn(...) \ 197 vlib_log(VLIB_LOG_LEVEL_WARNING, det44_main.log_class, __VA_ARGS__) 198 #define det44_log_notice(...) \ 199 vlib_log(VLIB_LOG_LEVEL_NOTICE, det44_main.log_class, __VA_ARGS__) 200 #define det44_log_info(...) \ 201 vlib_log(VLIB_LOG_LEVEL_INFO, det44_main.log_class, __VA_ARGS__) 202 #define det44_log_debug(...)\ 203 vlib_log(VLIB_LOG_LEVEL_DEBUG, det44_main.log_class, __VA_ARGS__) 206 #define DET44_INTERFACE_FLAG_IS_INSIDE 1 207 #define DET44_INTERFACE_FLAG_IS_OUTSIDE 2 213 #define det44_interface_is_inside(i) i->flags & DET44_INTERFACE_FLAG_IS_INSIDE 219 #define det44_interface_is_outside(i) i->flags & DET44_INTERFACE_FLAG_IS_OUTSIDE 252 u8 * dont_translate);
258 u8 * dont_translate);
260 icmp46_header_t * icmp0,
u32 sw_if_index0,
262 u32 next0,
u32 thread_index,
void *d,
void *e);
264 icmp46_header_t * icmp0,
u32 sw_if_index0,
266 u32 next0,
u32 thread_index,
void *d,
void *e);
310 u32 in_offset, out_offset;
312 in_offset = clib_net_to_host_u32 (in_addr->
as_u32) -
316 clib_host_to_net_u32 (clib_net_to_host_u32 (dm->
out_addr.
as_u32) +
325 u32 in_offset1, in_offset2, out_offset;
327 out_offset = clib_net_to_host_u32 (out_addr->
as_u32) -
332 clib_host_to_net_u32 (clib_net_to_host_u32 (dm->
in_addr.
as_u32) +
333 in_offset1 + in_offset2);
354 return &dm->
sessions[i + user_offset];
371 ses = &dm->
sessions[i + user_offset];
375 return &dm->
sessions[i + user_offset];
402 return &dm->
sessions[i + user_offset];
enum fib_source_t_ fib_source_t
The different sources that can create a route.
static_always_inline snat_det_session_t * snat_det_get_ses_by_out(snat_det_map_t *dm, ip4_address_t *in_addr, u64 out_key)
static_always_inline void snat_det_reverse(snat_det_map_t *dm, ip4_address_t *out_addr, u16 out_port, ip4_address_t *in_addr)
nat_timeouts_t det44_get_timeouts()
#define clib_atomic_add_fetch(a, b)
#define pool_foreach(VAR, POOL)
Iterate through pool.
vl_api_ip_port_and_mask_t dst_port
u32 det44_icmp_in2out(vlib_buffer_t *b0, ip4_header_t *ip0, icmp46_header_t *icmp0, u32 sw_if_index0, u32 rx_fib_index0, vlib_node_runtime_t *node, u32 next0, u32 thread_index, void *d, void *e)
struct det44_main_s det44_main_t
NAT port/address allocation lib.
format_function_t format_det_map_ses
static_always_inline u32 snat_det_user_ses_offset(ip4_address_t *addr, u8 plen)
u32 icmp_match_in2out_det(vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, ip4_address_t *addr, u16 *port, u32 *fib_index, nat_protocol_t *proto, void *d, void *e, u8 *dont_translate)
Get address and port values to be used for ICMP packet translation and create session if needed...
det44_fib_t * outside_fibs
static_always_inline u8 plugin_enabled()
#define static_always_inline
int det44_plugin_disable()
ip4_address_t ext_host_addr
int det44_plugin_enable()
static uword pow2_mask(uword x)
static_always_inline snat_det_session_t * snat_det_find_ses_by_in(snat_det_map_t *dm, ip4_address_t *in_addr, u16 in_port, snat_det_out_key_t out_key)
static_always_inline snat_det_session_t * snat_det_ses_create(u32 thread_index, snat_det_map_t *dm, ip4_address_t *in_addr, u16 in_port, snat_det_out_key_t *out)
static_always_inline snat_det_map_t * snat_det_map_by_out(ip4_address_t *out_addr)
u32 det44_icmp_out2in(vlib_buffer_t *b0, ip4_header_t *ip0, icmp46_header_t *icmp0, u32 sw_if_index0, u32 rx_fib_index0, vlib_node_runtime_t *node, u32 next0, u32 thread_index, void *d, void *e)
snat_det_session_t * sessions
IPv4 shallow virtual reassembly.
static_always_inline int is_addr_in_net(ip4_address_t *addr, ip4_address_t *net, u8 plen)
snat_det_map_t * det_maps
void nat_ipfix_logging_max_entries_per_user(u32 thread_index, u32 limit, u32 src_ip)
Generate maximum entries per user exceeded event.
static_always_inline void snat_det_forward(snat_det_map_t *dm, ip4_address_t *in_addr, ip4_address_t *out_addr, u16 *lo_port)
sll srl srl sll sra u16x4 i
int snat_det_add_map(ip4_address_t *in_addr, u8 in_plen, ip4_address_t *out_addr, u8 out_plen, int is_add)
Add/delete deterministic NAT mapping.
static_always_inline void snat_det_ses_close(snat_det_map_t *dm, snat_det_session_t *ses)
vlib_main_t vlib_node_runtime_t * node
vlib_node_registration_t det44_out2in_node
(constructor) VLIB_REGISTER_NODE (det44_out2in_node)
#define DET44_SES_PER_USER
u32 icmp_match_out2in_det(vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, ip4_address_t *addr, u16 *port, u32 *fib_index, nat_protocol_t *proto, void *d, void *e, u8 *dont_translate)
Get address and port values to be used for ICMP packet translation and create session if needed...
#define foreach_det44_session_state
void det44_reset_timeouts()
vlib_node_registration_t det44_in2out_node
(constructor) VLIB_REGISTER_NODE (det44_in2out_node)
struct _vlib_node_registration vlib_node_registration_t
det44_interface_t * interfaces
#define clib_atomic_bool_cmp_and_swap(addr, old, new)
VLIB buffer representation.
clib_error_t * det44_api_hookup(vlib_main_t *vm)
vlib_log_class_t log_class
int det44_set_timeouts(nat_timeouts_t *timeouts)
u32 expire_walk_node_index
int det44_interface_add_del(u32 sw_if_index, u8 is_inside, int is_del)
static_always_inline snat_det_map_t * snat_det_map_by_user(ip4_address_t *user_addr)
vl_api_interface_index_t sw_if_index