23 #ifndef __included_det44_h__ 24 #define __included_det44_h__ 44 #define foreach_det44_session_state \ 45 _(0, UNKNOWN, "unknown") \ 46 _(1, UDP_ACTIVE, "udp-active") \ 47 _(2, TCP_SYN_SENT, "tcp-syn-sent") \ 48 _(3, TCP_ESTABLISHED, "tcp-established") \ 49 _(4, TCP_FIN_WAIT, "tcp-fin-wait") \ 50 _(5, TCP_CLOSE_WAIT, "tcp-close-wait") \ 51 _(6, TCP_CLOSING, "tcp-closing") \ 52 _(7, TCP_LAST_ACK, "tcp-last-ack") \ 53 _(8, TCP_CLOSED, "tcp-closed") \ 54 _(9, ICMP_ACTIVE, "icmp-active") 58 #define _(v, N, s) DET44_SESSION_##N = v, 63 #define DET44_SES_PER_USER 1000 209 #define det44_log_err(...) \ 210 vlib_log(VLIB_LOG_LEVEL_ERR, det44_main.log_class, __VA_ARGS__) 211 #define det44_log_warn(...) \ 212 vlib_log(VLIB_LOG_LEVEL_WARNING, det44_main.log_class, __VA_ARGS__) 213 #define det44_log_notice(...) \ 214 vlib_log(VLIB_LOG_LEVEL_NOTICE, det44_main.log_class, __VA_ARGS__) 215 #define det44_log_info(...) \ 216 vlib_log(VLIB_LOG_LEVEL_INFO, det44_main.log_class, __VA_ARGS__) 217 #define det44_log_debug(...)\ 218 vlib_log(VLIB_LOG_LEVEL_DEBUG, det44_main.log_class, __VA_ARGS__) 221 #define DET44_INTERFACE_FLAG_IS_INSIDE 1 222 #define DET44_INTERFACE_FLAG_IS_OUTSIDE 2 228 #define det44_interface_is_inside(i) i->flags & DET44_INTERFACE_FLAG_IS_INSIDE 234 #define det44_interface_is_outside(i) i->flags & DET44_INTERFACE_FLAG_IS_OUTSIDE 267 u8 * dont_translate);
273 u8 * dont_translate);
275 icmp46_header_t * icmp0,
u32 sw_if_index0,
277 u32 next0,
u32 thread_index,
void *d,
void *e);
279 icmp46_header_t * icmp0,
u32 sw_if_index0,
281 u32 next0,
u32 thread_index,
void *d,
void *e);
299 if (is_addr_in_net(user_addr, &mp->in_addr, mp->in_plen))
314 if (is_addr_in_net(out_addr, &mp->out_addr, mp->out_plen))
325 u32 in_offset, out_offset;
327 in_offset = clib_net_to_host_u32 (in_addr->
as_u32) -
331 clib_host_to_net_u32 (clib_net_to_host_u32 (dm->
out_addr.
as_u32) +
340 u32 in_offset1, in_offset2, out_offset;
342 out_offset = clib_net_to_host_u32 (out_addr->
as_u32) -
347 clib_host_to_net_u32 (clib_net_to_host_u32 (dm->
in_addr.
as_u32) +
348 in_offset1 + in_offset2);
369 return &dm->
sessions[i + user_offset];
386 ses = &dm->
sessions[i + user_offset];
390 return &dm->
sessions[i + user_offset];
417 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)
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
struct nat_timeouts_s::@74 tcp
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()
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
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)
struct nat_timeouts_s nat_timeouts_t
snat_det_map_t * det_maps
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
ip4_main_t ip4_main
Global ip4 main structure.
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