aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/nat/nat64_db.c
diff options
context:
space:
mode:
authorMatus Fabian <matfabia@cisco.com>2017-08-15 06:59:19 -0700
committerOle Trøan <otroan@employees.org>2017-11-07 21:58:31 +0000
commitefcd1e9e1d7dda4e4ea3db5750925cd8f6894f4d (patch)
tree63c07cf6a94820a5fb2c3935082b6a02f6d210d3 /src/plugins/nat/nat64_db.c
parent20ab0a4943f7509f6e07d6c614eee90c80c8b963 (diff)
SNAT: IP fragmentation (VPP-890)
Translation of fragmented packets. Change-Id: I9b1f2e9433ce273638080f32c2d3bff39c49899d Signed-off-by: Matus Fabian <matfabia@cisco.com>
Diffstat (limited to 'src/plugins/nat/nat64_db.c')
-rw-r--r--src/plugins/nat/nat64_db.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/plugins/nat/nat64_db.c b/src/plugins/nat/nat64_db.c
index da73ceee2d1..008a137da10 100644
--- a/src/plugins/nat/nat64_db.c
+++ b/src/plugins/nat/nat64_db.c
@@ -529,6 +529,52 @@ nat64_db_st_entry_find (nat64_db_t * db, ip46_address_t * l_addr,
return ste;
}
+u32
+nat64_db_st_entry_get_index (nat64_db_t * db, nat64_db_st_entry_t * ste)
+{
+ nat64_db_st_entry_t *st;
+
+ switch (ip_proto_to_snat_proto (ste->proto))
+ {
+/* *INDENT-OFF* */
+#define _(N, i, n, s) \
+ case SNAT_PROTOCOL_##N: \
+ st = db->st._##n##_st; \
+ break;
+ foreach_snat_protocol
+#undef _
+/* *INDENT-ON* */
+ default:
+ st = db->st._unk_proto_st;
+ return (u32) ~ 0;
+ }
+
+ return ste - st;
+}
+
+nat64_db_st_entry_t *
+nat64_db_st_entry_by_index (nat64_db_t * db, u8 proto, u32 ste_index)
+{
+ nat64_db_st_entry_t *st;
+
+ switch (ip_proto_to_snat_proto (proto))
+ {
+/* *INDENT-OFF* */
+#define _(N, i, n, s) \
+ case SNAT_PROTOCOL_##N: \
+ st = db->st._##n##_st; \
+ break;
+ foreach_snat_protocol
+#undef _
+/* *INDENT-ON* */
+ default:
+ st = db->st._unk_proto_st;
+ break;
+ }
+
+ return pool_elt_at_index (st, ste_index);
+}
+
void
nad64_db_st_free_expired (nat64_db_t * db, u32 now)
{