summaryrefslogtreecommitdiffstats
path: root/src/plugins/snat/nat64_db.c
diff options
context:
space:
mode:
authorMatus Fabian <matfabia@cisco.com>2017-08-16 05:37:36 -0700
committerOle Trøan <otroan@employees.org>2017-08-16 15:56:32 +0000
commitab9a59c19a2765e001dd24a8f3e51882b6806e2d (patch)
tree5b18ac297b7b9f1f7220dd151930156484d66d04 /src/plugins/snat/nat64_db.c
parentd292ab1e0f600c20d380a93180cccb6226c220e3 (diff)
SNAT: Make proto optional in nat64_bib_dump (VPP-942)
make proto optional in nat64_bib_dump and nat64_st_dump Change-Id: Idd102ce2b1555d38783fd22c84e46b4c48570edc Signed-off-by: Matus Fabian <matfabia@cisco.com>
Diffstat (limited to 'src/plugins/snat/nat64_db.c')
-rw-r--r--src/plugins/snat/nat64_db.c110
1 files changed, 76 insertions, 34 deletions
diff --git a/src/plugins/snat/nat64_db.c b/src/plugins/snat/nat64_db.c
index b6e199c69a9..9584827e4da 100644
--- a/src/plugins/snat/nat64_db.c
+++ b/src/plugins/snat/nat64_db.c
@@ -217,28 +217,49 @@ nat64_db_bib_walk (nat64_db_t * db, u8 proto,
{
nat64_db_bib_entry_t *bib, *bibe;
- switch (ip_proto_to_snat_proto (proto))
+ if (proto == 255)
{
-/* *INDENT-OFF* */
-#define _(N, i, n, s) \
- case SNAT_PROTOCOL_##N: \
+ /* *INDENT-OFF* */
+ #define _(N, i, n, s) \
bib = db->bib._##n##_bib; \
- break;
+ pool_foreach (bibe, bib, ({ \
+ if (fn (bibe, ctx)) \
+ return; \
+ }));
foreach_snat_protocol
-#undef _
-/* *INDENT-ON* */
- default:
+ #undef _
bib = db->bib._unk_proto_bib;
- break;
+ pool_foreach (bibe, bib, ({
+ if (fn (bibe, ctx))
+ return;
+ }));
+ /* *INDENT-ON* */
+ }
+ else
+ {
+ switch (ip_proto_to_snat_proto (proto))
+ {
+ /* *INDENT-OFF* */
+ #define _(N, i, n, s) \
+ case SNAT_PROTOCOL_##N: \
+ bib = db->bib._##n##_bib; \
+ break;
+ foreach_snat_protocol
+ #undef _
+ /* *INDENT-ON* */
+ default:
+ bib = db->bib._unk_proto_bib;
+ break;
+ }
+
+ /* *INDENT-OFF* */
+ pool_foreach (bibe, bib,
+ ({
+ if (fn (bibe, ctx))
+ return;
+ }));
+ /* *INDENT-ON* */
}
-
- /* *INDENT-OFF* */
- pool_foreach (bibe, bib,
- ({
- if (fn (bibe, ctx))
- return;
- }));
- /* *INDENT-ON* */
}
nat64_db_bib_entry_t *
@@ -270,28 +291,49 @@ nat64_db_st_walk (nat64_db_t * db, u8 proto,
{
nat64_db_st_entry_t *st, *ste;
- switch (ip_proto_to_snat_proto (proto))
+ if (proto == 255)
{
-/* *INDENT-OFF* */
-#define _(N, i, n, s) \
- case SNAT_PROTOCOL_##N: \
+ /* *INDENT-OFF* */
+ #define _(N, i, n, s) \
st = db->st._##n##_st; \
- break;
+ pool_foreach (ste, st, ({ \
+ if (fn (ste, ctx)) \
+ return; \
+ }));
foreach_snat_protocol
-#undef _
-/* *INDENT-ON* */
- default:
+ #undef _
st = db->st._unk_proto_st;
- break;
+ pool_foreach (ste, st, ({
+ if (fn (ste, ctx))
+ return;
+ }));
+ /* *INDENT-ON* */
+ }
+ else
+ {
+ 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;
+ }
+
+ /* *INDENT-OFF* */
+ pool_foreach (ste, st,
+ ({
+ if (fn (ste, ctx))
+ return;
+ }));
+ /* *INDENT-ON* */
}
-
- /* *INDENT-OFF* */
- pool_foreach (ste, st,
- ({
- if (fn (ste, ctx))
- return;
- }));
- /* *INDENT-ON* */
}
nat64_db_st_entry_t *