aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/osmo-bsc_nat/bsc_nat_rewrite_trie.c
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2013-06-25 11:44:01 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-07-31 16:36:40 +0200
commitddf191eafc079cb26e2956a611d59e5235de1798 (patch)
treef1c012375d24c6f58e14c8606a11fb671d3b1da2 /openbsc/src/osmo-bsc_nat/bsc_nat_rewrite_trie.c
parent85d3b34ed2c3b627fca50c82abe426b7239b62a3 (diff)
nat: Allow to use the prefix lookup to rewrite numbers
* Increase the rewritten rule to five digits (this is the easiest for the unit test). This will add another 40kb to the runtime size. * Create a unit test that tests adding and removing the prefix rules. * Use the regexp match to replace from one package
Diffstat (limited to 'openbsc/src/osmo-bsc_nat/bsc_nat_rewrite_trie.c')
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_nat_rewrite_trie.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_rewrite_trie.c b/openbsc/src/osmo-bsc_nat/bsc_nat_rewrite_trie.c
index 57043acc9..faceb59b5 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat_rewrite_trie.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat_rewrite_trie.c
@@ -21,6 +21,7 @@
#include <openbsc/nat_rewrite_trie.h>
#include <openbsc/debug.h>
+#include <openbsc/vty.h>
#include <osmocom/core/talloc.h>
#include <osmocom/core/utils.h>
@@ -238,3 +239,21 @@ void nat_rewrite_dump(struct nat_rewrite *rewrite)
{
nat_rewrite_dump_rec(&rewrite->rule);
}
+
+static void nat_rewrite_dump_rec_vty(struct vty *vty, struct nat_rewrite_rule *rule)
+{
+ int i;
+ if (!rule->empty)
+ vty_out(vty, "%s,%s%s", rule->prefix, rule->rewrite, VTY_NEWLINE);
+
+ for (i = 0; i < ARRAY_SIZE(rule->rules); ++i) {
+ if (!rule->rules[i])
+ continue;
+ nat_rewrite_dump_rec_vty(vty, rule->rules[i]);
+ }
+}
+
+void nat_rewrite_dump_vty(struct vty *vty, struct nat_rewrite *rewrite)
+{
+ nat_rewrite_dump_rec_vty(vty, &rewrite->rule);
+}