aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-10-28 15:27:00 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-10-28 15:27:00 +0200
commit74779c68f79765db7d66f95b456202d2b8dd51ae (patch)
tree033d8ea632ce5c0c955f9c57a453fb99693311fa
parentd414c06fd9cf1eee53d17fba5bad94b4dc3fbf2a (diff)
nat: Add test case for matching phone numbersopenbsc/0.9.10
Add the test case for matching '*' and for not matching at all
-rw-r--r--openbsc/tests/bsc-nat/bsc_nat_test.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/openbsc/tests/bsc-nat/bsc_nat_test.c b/openbsc/tests/bsc-nat/bsc_nat_test.c
index 7a2557fe6..aac28704e 100644
--- a/openbsc/tests/bsc-nat/bsc_nat_test.c
+++ b/openbsc/tests/bsc-nat/bsc_nat_test.c
@@ -878,6 +878,68 @@ static void test_setup_rewrite()
}
msgb_free(out);
+
+ /* Make sure that a wildcard is matching */
+ entry.mnc = "*";
+ msg = msgb_alloc(4096, "test_dt_filter");
+ copy_to_msg(msg, cc_setup_national, ARRAY_SIZE(cc_setup_national));
+ parsed = bsc_nat_parse(msg);
+ if (!parsed) {
+ fprintf(stderr, "FAIL: Could not parse ID resp\n");
+ abort();
+ }
+
+ out = bsc_nat_rewrite_setup(nat, msg, parsed, imsi);
+ if (!out) {
+ fprintf(stderr, "FAIL: A new message should be created.\n");
+ abort();
+ }
+
+ if (msg == out) {
+ fprintf(stderr, "FAIL: The message should have changed\n");
+ abort();
+ }
+
+ if (out->len != ARRAY_SIZE(cc_setup_national_patched)) {
+ fprintf(stderr, "FAIL: Length is wrong.\n");
+ abort();
+ }
+
+ if (memcmp(cc_setup_national_patched, out->data, out->len) != 0) {
+ fprintf(stderr, "FAIL: Data is wrong.\n");
+ fprintf(stderr, "Data was: %s\n", hexdump(out->data, out->len));
+ abort();
+ }
+
+ msgb_free(out);
+
+ /* Make sure that a wildcard is matching */
+ entry.mnc = "09";
+ msg = msgb_alloc(4096, "test_dt_filter");
+ copy_to_msg(msg, cc_setup_national, ARRAY_SIZE(cc_setup_national));
+ parsed = bsc_nat_parse(msg);
+ if (!parsed) {
+ fprintf(stderr, "FAIL: Could not parse ID resp\n");
+ abort();
+ }
+
+ out = bsc_nat_rewrite_setup(nat, msg, parsed, imsi);
+ if (out != msg) {
+ fprintf(stderr, "FAIL: The message should be unchanged.\n");
+ abort();
+ }
+
+ if (out->len != ARRAY_SIZE(cc_setup_national)) {
+ fprintf(stderr, "FAIL: Foo\n");
+ abort();
+ }
+
+ if (memcmp(out->data, cc_setup_national, ARRAY_SIZE(cc_setup_national)) != 0) {
+ fprintf(stderr, "FAIL: The message should really be unchanged.\n");
+ abort();
+ }
+
+ msgb_free(out);
}
int main(int argc, char **argv)