X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Fnat%2Fnat64_db.h;h=f1b93cf8928780ee8358de6c338e00698bc9ec98;hb=b4d3053;hp=394ca875bbb68d33549765b797e71a6c821fab2b;hpb=2ba92e32e0197f676dd905e5edcb4ff3e1bec241;p=vpp.git diff --git a/src/plugins/nat/nat64_db.h b/src/plugins/nat/nat64_db.h index 394ca875bbb..f1b93cf8928 100644 --- a/src/plugins/nat/nat64_db.h +++ b/src/plugins/nat/nat64_db.h @@ -68,6 +68,9 @@ typedef struct /* BIB lookup */ clib_bihash_24_8_t in2out; clib_bihash_24_8_t out2in; + + u32 limit; + u32 bib_entries_num; } nat64_db_bib_t; typedef struct @@ -115,22 +118,44 @@ typedef struct /* session lookup */ clib_bihash_48_8_t in2out; clib_bihash_48_8_t out2in; + + u32 limit; + u32 st_entries_num; } nat64_db_st_t; -typedef struct +struct nat64_db_s; + +/** + * @brief Call back function to free NAT64 pool address and port when BIB + * entry is deleted. + */ +typedef void (*nat64_db_free_addr_port_function_t) (struct nat64_db_s * db, + ip4_address_t * addr, + u16 port, u8 proto); + +typedef struct nat64_db_s { nat64_db_bib_t bib; nat64_db_st_t st; + nat64_db_free_addr_port_function_t free_addr_port_cb; + u8 addr_free; } nat64_db_t; /** * @brief Initialize NAT64 DB. * * @param db NAT64 DB. + * @param bib_buckets Number of BIB hash buckets. + * @param bib_memory_size Memory size of BIB hash. + * @param st_buckets Number of session table hash buckets. + * @param st_memory_size Memory size of session table hash. + * @param free_addr_port_cb Call back function to free address and port. * * @returns 0 on success, non-zero value otherwise. */ -int nat64_db_init (nat64_db_t * db); +int nat64_db_init (nat64_db_t * db, u32 bib_buckets, u32 bib_memory_size, + u32 st_buckets, u32 st_memory_size, + nat64_db_free_addr_port_function_t free_addr_port_cb); /** * @brief Create new NAT64 BIB entry. @@ -296,6 +321,27 @@ void nad64_db_st_free_expired (nat64_db_t * db, u32 now); */ void nat64_db_free_out_addr (nat64_db_t * db, ip4_address_t * out_addr); +/* + * @brief Get ST entry index. + * + * @param db NAT64 DB. + * @param ste ST entry. + * + * @return ST entry index on success, ~0 otherwise. + */ +u32 nat64_db_st_entry_get_index (nat64_db_t * db, nat64_db_st_entry_t * ste); + +/** + * @brief Get ST entry by index and protocol. + * + * @param db NAT64 DB. + * @param proto L4 protocol. + * @param bibe_index ST entry index. + * + * @return BIB entry if found. + */ +nat64_db_st_entry_t *nat64_db_st_entry_by_index (nat64_db_t * db, + u8 proto, u32 ste_index); #endif /* __included_nat64_db_h__ */ /*