FD.io VPP  v17.10-9-gd594711
Vector Packet Processing
nat64.h File Reference

NAT64 global declarations. More...

+ Include dependency graph for nat64.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  nat64_prefix_t
 
struct  nat64_main_t
 

Macros

#define foreach_nat64_tcp_ses_state
 
#define u8_ptr_add(ptr, index)   (((u8 *)ptr) + index)
 
#define u16_net_add(u, val)   clib_host_to_net_u16(clib_net_to_host_u16(u) + (val))
 

Typedefs

typedef int(* nat64_pool_addr_walk_fn_t) (snat_address_t *addr, void *ctx)
 Call back function when walking addresses in NAT64 pool, non-zero return value stop walk. More...
 
typedef int(* nat64_interface_walk_fn_t) (snat_interface_t *i, void *ctx)
 Call back function when walking interfaces with NAT64 feature, non-zero return value stop walk. More...
 
typedef int(* nat64_prefix_walk_fn_t) (nat64_prefix_t *pref64, void *ctx)
 Call back function when walking addresses in NAT64 prefixes, non-zero return value stop walk. More...
 

Enumerations

enum  nat64_tcp_ses_state_t { foreach_nat64_tcp_ses_state }
 

Functions

int nat64_add_del_pool_addr (ip4_address_t *addr, u32 vrf_id, u8 is_add)
 Add/delete address to NAT64 pool. More...
 
void nat64_pool_addr_walk (nat64_pool_addr_walk_fn_t fn, void *ctx)
 Walk NAT64 pool. More...
 
int nat64_add_del_interface (u32 sw_if_index, u8 is_inside, u8 is_add)
 Enable/disable NAT64 feature on the interface. More...
 
void nat64_interfaces_walk (nat64_interface_walk_fn_t fn, void *ctx)
 Walk NAT64 interfaces. More...
 
clib_error_tnat64_init (vlib_main_t *vm)
 Initialize NAT64. More...
 
int nat64_add_del_static_bib_entry (ip6_address_t *in_addr, ip4_address_t *out_addr, u16 in_port, u16 out_port, u8 proto, u32 vrf_id, u8 is_add)
 Add/delete static NAT64 BIB entry. More...
 
int nat64_alloc_out_addr_and_port (u32 fib_index, snat_protocol_t proto, ip4_address_t *addr, u16 *port)
 Alloce IPv4 address and port pair from NAT64 pool. More...
 
void nat64_free_out_addr_and_port (ip4_address_t *addr, u16 port, snat_protocol_t proto)
 Free IPv4 address and port pair from NAT64 pool. More...
 
int nat64_set_udp_timeout (u32 timeout)
 Set UDP session timeout. More...
 
u32 nat64_get_udp_timeout (void)
 Get UDP session timeout. More...
 
int nat64_set_icmp_timeout (u32 timeout)
 Set ICMP session timeout. More...
 
u32 nat64_get_icmp_timeout (void)
 Get ICMP session timeout. More...
 
int nat64_set_tcp_timeouts (u32 trans, u32 est, u32 incoming_syn)
 Set TCP session timeouts. More...
 
u32 nat64_get_tcp_trans_timeout (void)
 Get TCP transitory timeout. More...
 
u32 nat64_get_tcp_est_timeout (void)
 Get TCP established timeout. More...
 
u32 nat64_get_tcp_incoming_syn_timeout (void)
 Get TCP incoming SYN timeout. More...
 
void nat64_session_reset_timeout (nat64_db_st_entry_t *ste, vlib_main_t *vm)
 Reset NAT64 session timeout. More...
 
void nat64_tcp_session_set_state (nat64_db_st_entry_t *ste, tcp_header_t *tcp, u8 is_ip6)
 Set NAT64 TCP session state. More...
 
int nat64_add_del_prefix (ip6_address_t *prefix, u8 plen, u32 vrf_id, u8 is_add)
 Add/delete NAT64 prefix. More...
 
void nat64_prefix_walk (nat64_prefix_walk_fn_t fn, void *ctx)
 Walk NAT64 prefixes. More...
 
void nat64_compose_ip6 (ip6_address_t *ip6, ip4_address_t *ip4, u32 fib_index)
 Compose IPv4-embedded IPv6 addresses. More...
 
void nat64_extract_ip4 (ip6_address_t *ip6, ip4_address_t *ip4, u32 fib_index)
 Extract IPv4 address from the IPv4-embedded IPv6 addresses. More...
 

Variables

nat64_main_t nat64_main
 
vlib_node_registration_t nat64_in2out_node
 (constructor) VLIB_REGISTER_NODE (nat64_in2out_node) More...
 
vlib_node_registration_t nat64_out2in_node
 (constructor) VLIB_REGISTER_NODE (nat64_out2in_node) More...
 

Detailed Description

NAT64 global declarations.

Definition in file nat64.h.

Macro Definition Documentation

#define foreach_nat64_tcp_ses_state
Value:
_(0, CLOSED, "closed") \
_(1, V4_INIT, "v4-init") \
_(2, V6_INIT, "v6-init") \
_(3, ESTABLISHED, "established") \
_(4, V4_FIN_RCV, "v4-fin-rcv") \
_(5, V6_FIN_RCV, "v6-fin-rcv") \
_(6, V6_FIN_V4_FIN_RCV, "v6-fin-v4-fin-rcv") \
_(7, TRANS, "trans")

Definition at line 25 of file nat64.h.

#define u16_net_add (   u,
  val 
)    clib_host_to_net_u16(clib_net_to_host_u16(u) + (val))

Definition at line 312 of file nat64.h.

#define u8_ptr_add (   ptr,
  index 
)    (((u8 *)ptr) + index)

Definition at line 311 of file nat64.h.

Typedef Documentation

typedef int(* nat64_interface_walk_fn_t) (snat_interface_t *i, void *ctx)

Call back function when walking interfaces with NAT64 feature, non-zero return value stop walk.

Definition at line 120 of file nat64.h.

typedef int(* nat64_pool_addr_walk_fn_t) (snat_address_t *addr, void *ctx)

Call back function when walking addresses in NAT64 pool, non-zero return value stop walk.

Definition at line 95 of file nat64.h.

typedef int(* nat64_prefix_walk_fn_t) (nat64_prefix_t *pref64, void *ctx)

Call back function when walking addresses in NAT64 prefixes, non-zero return value stop walk.

Definition at line 282 of file nat64.h.

Enumeration Type Documentation

Enumerator
foreach_nat64_tcp_ses_state 

Definition at line 35 of file nat64.h.

Function Documentation

int nat64_add_del_interface ( u32  sw_if_index,
u8  is_inside,
u8  is_add 
)

Enable/disable NAT64 feature on the interface.

Parameters
sw_if_indexIndex of the interface.
is_inside1 if inside, 0 if outside.
is_add1 if add, 0 if delete.
Returns
0 on success, non-zero value otherwise.

Definition at line 166 of file nat64.c.

+ Here is the caller graph for this function:

int nat64_add_del_pool_addr ( ip4_address_t addr,
u32  vrf_id,
u8  is_add 
)

Add/delete address to NAT64 pool.

Parameters
addrIPv4 address.
vrf_idVRF id of tenant, ~0 means independent of VRF.
is_add1 if add, 0 if delete.
Returns
0 on success, non-zero value otherwise.

Definition at line 83 of file nat64.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int nat64_add_del_prefix ( ip6_address_t prefix,
u8  plen,
u32  vrf_id,
u8  is_add 
)

Add/delete NAT64 prefix.

Parameters
prefixNAT64 prefix.
plenPrefix length.
vrf_idVRF id of tenant.
is_add1 if add, 0 if delete.
Returns
0 on success, non-zero value otherwise.

Definition at line 622 of file nat64.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int nat64_add_del_static_bib_entry ( ip6_address_t in_addr,
ip4_address_t out_addr,
u16  in_port,
u16  out_port,
u8  proto,
u32  vrf_id,
u8  is_add 
)

Add/delete static NAT64 BIB entry.

Parameters
in_addrInside IPv6 address.
out_addrOutside IPv4 address.
in_portInside port number.
out_portOutside port number.
protoL4 protocol.
vrf_idVRF id of tenant.
is_add1 if add, 0 if delete.
Returns
0 on success, non-zero value otherwise.

Definition at line 352 of file nat64.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int nat64_alloc_out_addr_and_port ( u32  fib_index,
snat_protocol_t  proto,
ip4_address_t addr,
u16 port 
)

Alloce IPv4 address and port pair from NAT64 pool.

Parameters
fib_indexFIB index of tenant.
protoL4 protocol.
addrAllocated IPv4 address.
portAllocated port number.
Returns
0 on success, non-zero value otherwise.

Definition at line 234 of file nat64.c.

+ Here is the caller graph for this function:

void nat64_compose_ip6 ( ip6_address_t ip6,
ip4_address_t ip4,
u32  fib_index 
)

Compose IPv4-embedded IPv6 addresses.

Parameters
ip6IPv4-embedded IPv6 addresses.
ip4IPv4 address.
fib_indexTenant FIB index.

Definition at line 685 of file nat64.c.

+ Here is the caller graph for this function:

void nat64_extract_ip4 ( ip6_address_t ip6,
ip4_address_t ip4,
u32  fib_index 
)

Extract IPv4 address from the IPv4-embedded IPv6 addresses.

Parameters
ip6IPv4-embedded IPv6 addresses.
ip4IPv4 address.
fib_indexTenant FIB index.

Definition at line 756 of file nat64.c.

+ Here is the caller graph for this function:

void nat64_free_out_addr_and_port ( ip4_address_t addr,
u16  port,
snat_protocol_t  proto 
)

Free IPv4 address and port pair from NAT64 pool.

Parameters
addrIPv4 address to free.
portPort number to free.
protoL4 protocol.
Returns
0 on success, non-zero value otherwise.

Definition at line 320 of file nat64.c.

+ Here is the caller graph for this function:

u32 nat64_get_icmp_timeout ( void  )

Get ICMP session timeout.

Returns
ICMP session timeout in seconds.

Definition at line 461 of file nat64.c.

+ Here is the caller graph for this function:

u32 nat64_get_tcp_est_timeout ( void  )

Get TCP established timeout.

Returns
TCP established timeout in seconds.

Definition at line 500 of file nat64.c.

+ Here is the caller graph for this function:

u32 nat64_get_tcp_incoming_syn_timeout ( void  )

Get TCP incoming SYN timeout.

Returns
TCP incoming SYN timeout in seconds.

Definition at line 508 of file nat64.c.

+ Here is the caller graph for this function:

u32 nat64_get_tcp_trans_timeout ( void  )

Get TCP transitory timeout.

Returns
TCP transitory timeout in seconds.

Definition at line 492 of file nat64.c.

+ Here is the caller graph for this function:

u32 nat64_get_udp_timeout ( void  )

Get UDP session timeout.

Returns
UDP session timeout in seconds.

Definition at line 440 of file nat64.c.

+ Here is the caller graph for this function:

clib_error_t* nat64_init ( vlib_main_t vm)

Initialize NAT64.

Parameters
vmvlib main.
Returns
error code.

Definition at line 51 of file nat64.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void nat64_interfaces_walk ( nat64_interface_walk_fn_t  fn,
void *  ctx 
)

Walk NAT64 interfaces.

Parameters
fnThe function to invoke on each entry visited.
ctxA context passed in the visit function.

Definition at line 219 of file nat64.c.

+ Here is the caller graph for this function:

void nat64_pool_addr_walk ( nat64_pool_addr_walk_fn_t  fn,
void *  ctx 
)

Walk NAT64 pool.

Parameters
fnThe function to invoke on each entry visited.
ctxA context passed in the visit function.

Definition at line 151 of file nat64.c.

+ Here is the caller graph for this function:

void nat64_prefix_walk ( nat64_prefix_walk_fn_t  fn,
void *  ctx 
)

Walk NAT64 prefixes.

Parameters
fnThe function to invoke on each entry visited.
ctxA context passed in the visit function.

Definition at line 670 of file nat64.c.

+ Here is the caller graph for this function:

void nat64_session_reset_timeout ( nat64_db_st_entry_t *  ste,
vlib_main_t vm 
)

Reset NAT64 session timeout.

Parameters
steSession table entry.
vmVLIB main.

Definition at line 516 of file nat64.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int nat64_set_icmp_timeout ( u32  timeout)

Set ICMP session timeout.

Parameters
timeoutTimeout value in seconds (if 0 reset to default value 60sec).
Returns
0 on success, non-zero value otherwise.

Definition at line 448 of file nat64.c.

+ Here is the caller graph for this function:

int nat64_set_tcp_timeouts ( u32  trans,
u32  est,
u32  incoming_syn 
)

Set TCP session timeouts.

Parameters
transTransitory timeout in seconds (if 0 reset to default value 240sec).
estEstablished timeout in seconds (if 0 reset to default value 7440sec).
incoming_synIncoming SYN timeout in seconds (if 0 reset to default value 6sec).
Returns
0 on success, non-zero value otherwise.

Definition at line 469 of file nat64.c.

+ Here is the caller graph for this function:

int nat64_set_udp_timeout ( u32  timeout)

Set UDP session timeout.

Parameters
timeoutTimeout value in seconds (if 0 reset to default value 300sec).
Returns
0 on success, non-zero value otherwise.

Definition at line 425 of file nat64.c.

+ Here is the caller graph for this function:

void nat64_tcp_session_set_state ( nat64_db_st_entry_t *  ste,
tcp_header_t tcp,
u8  is_ip6 
)

Set NAT64 TCP session state.

Parameters
steSession table entry.
tcpTCP header.
is_ip61 if IPv6 packet, 0 if IPv4.

Definition at line 555 of file nat64.c.

Variable Documentation

vlib_node_registration_t nat64_in2out_node
Initial value:
= {
.function = nat64_in2out_node_fn,
.name = "nat64-in2out",
.vector_size = sizeof (u32),
.format_trace = format_nat64_in2out_trace,
.error_strings = nat64_in2out_error_strings,
.n_next_nodes = NAT64_IN2OUT_N_NEXT,
.next_nodes = {
[NAT64_IN2OUT_NEXT_DROP] = "error-drop",
[NAT64_IN2OUT_NEXT_IP4_LOOKUP] = "ip4-lookup",
[NAT64_IN2OUT_NEXT_IP6_LOOKUP] = "ip6-lookup",
[NAT64_IN2OUT_NEXT_SLOWPATH] = "nat64-in2out-slowpath",
},
}
static u8 * format_nat64_in2out_trace(u8 *s, va_list *args)
Definition: nat64_in2out.c:32
static char * nat64_in2out_error_strings[]
Definition: nat64_in2out.c:65
#define ARRAY_LEN(x)
Definition: clib.h:59
unsigned int u32
Definition: types.h:88
static uword nat64_in2out_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)

(constructor) VLIB_REGISTER_NODE (nat64_in2out_node)

Definition at line 1061 of file nat64_in2out.c.

nat64_main_t nat64_main

Definition at line 25 of file nat64.c.

vlib_node_registration_t nat64_out2in_node
Initial value:
= {
.function = nat64_out2in_node_fn,
.name = "nat64-out2in",
.vector_size = sizeof (u32),
.format_trace = format_nat64_out2in_trace,
.error_strings = nat64_out2in_error_strings,.n_next_nodes = 2,
.next_nodes = {
[NAT64_OUT2IN_NEXT_DROP] = "error-drop",
[NAT64_OUT2IN_NEXT_LOOKUP] = "ip6-lookup",
},
}
static char * nat64_out2in_error_strings[]
Definition: nat64_out2in.c:60
static u8 * format_nat64_out2in_trace(u8 *s, va_list *args)
Definition: nat64_out2in.c:31
#define ARRAY_LEN(x)
Definition: clib.h:59
static uword nat64_out2in_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: nat64_out2in.c:372
unsigned int u32
Definition: types.h:88

(constructor) VLIB_REGISTER_NODE (nat64_out2in_node)

Definition at line 470 of file nat64_out2in.c.