/* 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
/* 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.
*/
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__ */
/*