aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/tests/bsc-nat/bsc_nat_test.c
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2012-03-26 16:21:42 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2012-03-26 16:22:08 +0200
commit09db1a44bc56e81780954555acfbc1bf2fb7cc81 (patch)
treece061abab59c5afdf17e31f6dff579d04f1f376c /openbsc/tests/bsc-nat/bsc_nat_test.c
parent2f2be578cbda0f3cecaf72058502e5780ad2f4cb (diff)
nat: Add another test case for TP-SRR clearing and number rewrite
Diffstat (limited to 'openbsc/tests/bsc-nat/bsc_nat_test.c')
-rw-r--r--openbsc/tests/bsc-nat/bsc_nat_test.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/openbsc/tests/bsc-nat/bsc_nat_test.c b/openbsc/tests/bsc-nat/bsc_nat_test.c
index c6187f9c5..f8ba57b8a 100644
--- a/openbsc/tests/bsc-nat/bsc_nat_test.c
+++ b/openbsc/tests/bsc-nat/bsc_nat_test.c
@@ -1078,15 +1078,15 @@ static void test_sms_smsc_rewrite()
static void test_sms_number_rewrite(void)
{
- struct msgb *msg = msgb_alloc(4096, "SMSC rewrite"), *out;
+ struct msgb *msg, *out;
struct bsc_nat_parsed *parsed;
const char *imsi = "515039900406700";
struct bsc_nat *nat = bsc_nat_alloc();
/* a fake list */
- struct osmo_config_list num_entries;
- struct osmo_config_entry num_entry;
+ struct osmo_config_list num_entries, clear_entries;
+ struct osmo_config_entry num_entry, clear_entry;
INIT_LLIST_HEAD(&num_entries.entry);
num_entry.mcc = "^515039";
@@ -1101,6 +1101,7 @@ static void test_sms_number_rewrite(void)
/*
* Check if the SMSC address is changed
*/
+ msg = msgb_alloc(4096, "SMSC rewrite");
copy_to_msg(msg, smsc_rewrite, ARRAY_SIZE(smsc_rewrite));
parsed = bsc_nat_parse(msg);
if (!parsed) {
@@ -1117,6 +1118,34 @@ static void test_sms_number_rewrite(void)
verify_msg(out, smsc_rewrite_num_patched,
ARRAY_SIZE(smsc_rewrite_num_patched));
msgb_free(out);
+
+ /*
+ * Now with TP-SRR rewriting enabled
+ */
+ INIT_LLIST_HEAD(&clear_entries.entry);
+ clear_entry.mcc = "^515039";
+ clear_entry.option = "";
+ clear_entry.text = "";
+ llist_add_tail(&clear_entry.list, &clear_entries.entry);
+ bsc_nat_num_rewr_entry_adapt(nat, &nat->sms_clear_tp_srr, &clear_entries);
+
+ msg = msgb_alloc(4096, "SMSC rewrite");
+ copy_to_msg(msg, smsc_rewrite, ARRAY_SIZE(smsc_rewrite));
+ parsed = bsc_nat_parse(msg);
+ if (!parsed) {
+ printf("FAIL: Could not parse SMS\n");
+ abort();
+ }
+
+ out = bsc_nat_rewrite_msg(nat, msg, parsed, imsi);
+ if (out == msg) {
+ printf("FAIL: This should have changed.\n");
+ abort();
+ }
+
+ verify_msg(out, smsc_rewrite_num_patched_tp_srr,
+ ARRAY_SIZE(smsc_rewrite_num_patched_tp_srr));
+ msgb_free(out);
}
int main(int argc, char **argv)