FD.io VPP  v20.09-64-g4f7b92f0a
Vector Packet Processing
nat64_db.h File Reference

NAT64 DB. More...

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

Go to the source code of this file.

Data Structures

struct  nat64_db_bib_entry_key_t
 
struct  nat64_db_bib_t
 
struct  nat64_db_st_entry_key_t
 
struct  nat64_db_st_t
 
struct  nat64_db_s
 

Typedefs

typedef void(* nat64_db_free_addr_port_function_t) (struct nat64_db_s *db, ip4_address_t *addr, u16 port, u8 proto)
 Call back function to free NAT64 pool address and port when BIB entry is deleted. More...
 
typedef struct nat64_db_s nat64_db_t
 
typedef int(* nat64_db_bib_walk_fn_t) (nat64_db_bib_entry_t *bibe, void *ctx)
 Call back function when walking NAT64 BIB, non-zero return value stop walk. More...
 
typedef int(* nat64_db_st_walk_fn_t) (nat64_db_st_entry_t *ste, void *ctx)
 Call back function when walking NAT64 session table, non-zero return value stop walk. More...
 

Functions

typedef CLIB_PACKED (struct { ip6_address_t in_addr;u16 in_port;ip4_address_t out_addr;u16 out_port;u32 fib_index;u32 ses_num;u8 proto;u8 is_static;}) nat64_db_bib_entry_t
 
typedef CLIB_PACKED (struct { ip6_address_t in_r_addr;ip4_address_t out_r_addr;u16 r_port;u32 bibe_index;u32 expire;u8 proto;u8 tcp_state;}) nat64_db_st_entry_t
 
int nat64_db_init (nat64_db_t *db, u32 bib_buckets, uword bib_memory_size, u32 st_buckets, uword st_memory_size, nat64_db_free_addr_port_function_t free_addr_port_cb)
 Initialize NAT64 DB. More...
 
nat64_db_bib_entry_t * nat64_db_bib_entry_create (u32 thread_index, nat64_db_t *db, ip6_address_t *in_addr, ip4_address_t *out_addr, u16 in_port, u16 out_port, u32 fib_index, u8 proto, u8 is_static)
 Create new NAT64 BIB entry. More...
 
void nat64_db_bib_entry_free (u32 thread_index, nat64_db_t *db, nat64_db_bib_entry_t *bibe)
 Free NAT64 BIB entry. More...
 
void nat64_db_bib_walk (nat64_db_t *db, u8 proto, nat64_db_bib_walk_fn_t fn, void *ctx)
 Walk NAT64 BIB. More...
 
nat64_db_bib_entry_t * nat64_db_bib_entry_find (nat64_db_t *db, ip46_address_t *addr, u16 port, u8 proto, u32 fib_index, u8 is_ip6)
 Find NAT64 BIB entry. More...
 
nat64_db_bib_entry_t * nat64_db_bib_entry_by_index (nat64_db_t *db, u8 proto, u32 bibe_index)
 Get BIB entry by index and protocol. More...
 
nat64_db_st_entry_t * nat64_db_st_entry_create (u32 thread_index, nat64_db_t *db, nat64_db_bib_entry_t *bibe, ip6_address_t *in_r_addr, ip4_address_t *out_r_addr, u16 r_port)
 Create new NAT64 session table entry. More...
 
void nat64_db_st_entry_free (u32 thread_index, nat64_db_t *db, nat64_db_st_entry_t *ste)
 Free NAT64 session table entry. More...
 
nat64_db_st_entry_t * nat64_db_st_entry_find (nat64_db_t *db, ip46_address_t *l_addr, ip46_address_t *r_addr, u16 l_port, u16 r_port, u8 proto, u32 fib_index, u8 is_ip6)
 Find NAT64 session table entry. More...
 
void nat64_db_st_walk (nat64_db_t *db, u8 proto, nat64_db_st_walk_fn_t fn, void *ctx)
 Walk NAT64 session table. More...
 
void nad64_db_st_free_expired (u32 thread_index, nat64_db_t *db, u32 now)
 Free expired session entries in session tables. More...
 
void nat64_db_free_out_addr (u32 thread_index, nat64_db_t *db, ip4_address_t *out_addr)
 Free sessions using specific outside address. More...
 
u32 nat64_db_st_entry_get_index (nat64_db_t *db, nat64_db_st_entry_t *ste)
 
nat64_db_st_entry_t * nat64_db_st_entry_by_index (nat64_db_t *db, u8 proto, u32 ste_index)
 Get ST entry by index and protocol. More...
 

Detailed Description

NAT64 DB.

Definition in file nat64_db.h.

Typedef Documentation

◆ nat64_db_bib_walk_fn_t

typedef int(* nat64_db_bib_walk_fn_t) (nat64_db_bib_entry_t *bibe, void *ctx)

Call back function when walking NAT64 BIB, non-zero return value stop walk.

Definition at line 197 of file nat64_db.h.

◆ nat64_db_free_addr_port_function_t

typedef void(* nat64_db_free_addr_port_function_t) (struct nat64_db_s *db, ip4_address_t *addr, u16 port, u8 proto)

Call back function to free NAT64 pool address and port when BIB entry is deleted.

Definition at line 132 of file nat64_db.h.

◆ nat64_db_st_walk_fn_t

typedef int(* nat64_db_st_walk_fn_t) (nat64_db_st_entry_t *ste, void *ctx)

Call back function when walking NAT64 session table, non-zero return value stop walk.

Definition at line 299 of file nat64_db.h.

◆ nat64_db_t

typedef struct nat64_db_s nat64_db_t

Function Documentation

◆ CLIB_PACKED() [1/2]

typedef CLIB_PACKED ( struct { ip6_address_t in_addr;u16 in_port;ip4_address_t out_addr;u16 out_port;u32 fib_index;u32 ses_num;u8 proto;u8 is_static;}  )

◆ CLIB_PACKED() [2/2]

typedef CLIB_PACKED ( struct { ip6_address_t in_r_addr;ip4_address_t out_r_addr;u16 r_port;u32 bibe_index;u32 expire;u8 proto;u8 tcp_state;}  )

◆ nad64_db_st_free_expired()

void nad64_db_st_free_expired ( u32  thread_index,
nat64_db_t db,
u32  now 
)

Free expired session entries in session tables.

Parameters
thread_indexthread index.
dbNAT64 DB.
nowCurrent time.

Definition at line 651 of file nat64_db.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat64_db_bib_entry_by_index()

nat64_db_bib_entry_t* nat64_db_bib_entry_by_index ( nat64_db_t db,
u8  proto,
u32  bibe_index 
)

Get BIB entry by index and protocol.

Parameters
dbNAT64 DB.
protoL4 protocol.
bibe_indexBIB entry index.
Returns
BIB entry if found.

Definition at line 302 of file nat64_db.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat64_db_bib_entry_create()

nat64_db_bib_entry_t* nat64_db_bib_entry_create ( u32  thread_index,
nat64_db_t db,
ip6_address_t *  in_addr,
ip4_address_t out_addr,
u16  in_port,
u16  out_port,
u32  fib_index,
u8  proto,
u8  is_static 
)

Create new NAT64 BIB entry.

Parameters
thread_indexthread index.
dbNAT64 DB.
in_addrInside IPv6 address.
out_addrOutside IPv4 address.
in_portInside port number.
out_portOutside port number.
fib_indexFIB index.
protoL4 protocol.
is_static1 if static, 0 if dynamic.
Returns
BIB entry on success, 0 otherwise.

Definition at line 53 of file nat64_db.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat64_db_bib_entry_find()

nat64_db_bib_entry_t* nat64_db_bib_entry_find ( nat64_db_t db,
ip46_address_t *  addr,
u16  port,
u8  proto,
u32  fib_index,
u8  is_ip6 
)

Find NAT64 BIB entry.

Parameters
dbNAT64 DB.
addrIP address.
portPort number.
protoL4 protocol.
fib_indexFIB index.
is_ip61 if find by IPv6 (inside) address, 0 by IPv4 (outside).
Returns
BIB entry if found.

Definition at line 209 of file nat64_db.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat64_db_bib_entry_free()

void nat64_db_bib_entry_free ( u32  thread_index,
nat64_db_t db,
nat64_db_bib_entry_t *  bibe 
)

Free NAT64 BIB entry.

Parameters
thread_indexthread index.
dbNAT64 DB.
bibeBIB entry.

Definition at line 129 of file nat64_db.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat64_db_bib_walk()

void nat64_db_bib_walk ( nat64_db_t db,
u8  proto,
nat64_db_bib_walk_fn_t  fn,
void *  ctx 
)

Walk NAT64 BIB.

Parameters
dbNAT64 DB.
protoBIB L4 protocol:
  • 255 all BIBs
  • 6 TCP BIB
  • 17 UDP BIB
  • 1/58 ICMP BIB

u - otherwise "unknown" protocol BIB

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

Definition at line 251 of file nat64_db.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat64_db_free_out_addr()

void nat64_db_free_out_addr ( u32  thread_index,
nat64_db_t db,
ip4_address_t out_addr 
)

Free sessions using specific outside address.

Parameters
thread_indexthread index.
dbNAT64 DB.
out_addrOutside address to match.

Definition at line 685 of file nat64_db.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat64_db_init()

int nat64_db_init ( nat64_db_t db,
u32  bib_buckets,
uword  bib_memory_size,
u32  st_buckets,
uword  st_memory_size,
nat64_db_free_addr_port_function_t  free_addr_port_cb 
)

Initialize NAT64 DB.

Parameters
dbNAT64 DB.
bib_bucketsNumber of BIB hash buckets.
bib_memory_sizeMemory size of BIB hash.
st_bucketsNumber of session table hash buckets.
st_memory_sizeMemory size of session table hash.
free_addr_port_cbCall back function to free address and port.
Returns
0 on success, non-zero value otherwise.

Definition at line 26 of file nat64_db.c.

+ Here is the caller graph for this function:

◆ nat64_db_st_entry_by_index()

nat64_db_st_entry_t* nat64_db_st_entry_by_index ( nat64_db_t db,
u8  proto,
u32  ste_index 
)

Get ST entry by index and protocol.

Parameters
dbNAT64 DB.
protoL4 protocol.
bibe_indexST entry index.
Returns
BIB entry if found.

Definition at line 628 of file nat64_db.c.

+ Here is the call graph for this function:

◆ nat64_db_st_entry_create()

nat64_db_st_entry_t* nat64_db_st_entry_create ( u32  thread_index,
nat64_db_t db,
nat64_db_bib_entry_t *  bibe,
ip6_address_t *  in_r_addr,
ip4_address_t out_r_addr,
u16  r_port 
)

Create new NAT64 session table entry.

Parameters
thread_indexthread index.
dbNAT64 DB.
bibeCorresponding BIB entry.
in_r_addrInside IPv6 address of the remote host.
out_r_addrOutside IPv4 address of the remote host.
r_portRemote host port number.
Returns
BIB entry on success, 0 otherwise.

Definition at line 376 of file nat64_db.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat64_db_st_entry_find()

nat64_db_st_entry_t* nat64_db_st_entry_find ( nat64_db_t db,
ip46_address_t *  l_addr,
ip46_address_t *  r_addr,
u16  l_port,
u16  r_port,
u8  proto,
u32  fib_index,
u8  is_ip6 
)

Find NAT64 session table entry.

Parameters
dbNAT64 DB.
l_addrLocal host address.
r_addrRemote host address.
l_portLocal host port number.
r_portRemote host port number.
protoL4 protocol.
fib_indexFIB index.
is_ip61 if find by IPv6 (inside) address, 0 by IPv4 (outside).
Returns
BIB entry if found.

Definition at line 557 of file nat64_db.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat64_db_st_entry_free()

void nat64_db_st_entry_free ( u32  thread_index,
nat64_db_t db,
nat64_db_st_entry_t *  ste 
)

Free NAT64 session table entry.

Parameters
thread_indexthread index.
dbNAT64 DB.
steSession table entry.

Definition at line 472 of file nat64_db.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nat64_db_st_entry_get_index()

u32 nat64_db_st_entry_get_index ( nat64_db_t db,
nat64_db_st_entry_t *  ste 
)

Definition at line 605 of file nat64_db.c.

+ Here is the call graph for this function:

◆ nat64_db_st_walk()

void nat64_db_st_walk ( nat64_db_t db,
u8  proto,
nat64_db_st_walk_fn_t  fn,
void *  ctx 
)

Walk NAT64 session table.

Parameters
dbNAT64 DB.
protoL4 protocol:
  • 255 all session tables
  • 6 TCP session table
  • 17 UDP session table
  • 1/58 ICMP session table
  • otherwise "unknown" protocol session table
fnThe function to invoke on each entry visited.
ctxA context passed in the visit function.

Definition at line 325 of file nat64_db.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function: