aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/tests/gtphub
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2015-12-01 00:23:45 +0100
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2015-12-03 11:44:19 +0100
commit10fc02447279a322e1d362a31dec5c8f8bafb6f8 (patch)
treeb2df2703d14a27c04058253907335d0d828b13e4 /openbsc/tests/gtphub
parent2f67125c3237f63800c5601f1aaddda62ce192a2 (diff)
gtphub: handle Delete PDP Context.
During resolution of the header TEI, also return the tunnel struct that resolved the TEI, so the Delete PDP Ctx code does not need to look it up again. Upon Delete PDP Ctx Request, remember the IEs and that a request was made. Upon Delete PDP Ctx Response, find the pending delete and remove the corresponding tunnel, iff the response indicates success. Add a context deletion to regression tests, rename the test appropriately. Sponsored-by: On-Waves ehi
Diffstat (limited to 'openbsc/tests/gtphub')
-rw-r--r--openbsc/tests/gtphub/gtphub_test.c76
-rw-r--r--openbsc/tests/gtphub/gtphub_test.ok2
2 files changed, 74 insertions, 4 deletions
diff --git a/openbsc/tests/gtphub/gtphub_test.c b/openbsc/tests/gtphub/gtphub_test.c
index b0ede11b9..fea55e03d 100644
--- a/openbsc/tests/gtphub/gtphub_test.c
+++ b/openbsc/tests/gtphub/gtphub_test.c
@@ -954,9 +954,75 @@ static int create_pdp_ctx()
return 1;
}
-static void test_create_pdp_ctx(void)
+#define MSG_DEL_PDP_CTX_REQ(tei, seq) \
+ "32" /* 0b001'1 0010: version 1, protocol GTP, with seq nr. */ \
+ "14" /* type 20: Delete PDP Context Request */ \
+ "0008" /* msg length = 8 + len (2 octets) */ \
+ tei /* TEI Ctrl */ \
+ seq /* Sequence nr (2 octets) */ \
+ "00" /* N-PDU 0 */ \
+ "00" /* No extensions */ \
+ /* IEs */ \
+ "13fe" /* 19: Teardown ind = 0 */ \
+ "1400" /* 20: NSAPI = 0*/ \
+
+#define MSG_DEL_PDP_CTX_RSP(tei, seq) \
+ "32" /* 0b001'1 0010: version 1, protocol GTP, with seq nr. */ \
+ "15" /* type 21: Delete PDP Context Response */ \
+ "0006" /* msg length = 8 + len (2 octets) */ \
+ tei /* TEI Ctrl */ \
+ seq /* Sequence nr (2 octets) */ \
+ "00" /* N-PDU 0 */ \
+ "00" /* No extensions */ \
+ /* IEs */ \
+ "01" /* 1: Cause */ \
+ "80" /* value = 0b10000000 = response, no rejection. */ \
+
+static int delete_pdp_ctx(void)
+{
+ now += GTPH_EXPIRE_QUICKLY_SECS + 1;
+ gtphub_gc(hub, now);
+
+ LVL2_ASSERT(tunnels_are(
+ "192.168.42.23 (TEI C 321=1 / U 123=2)"
+ " <-> 192.168.43.34 (TEI C 765=3 / U 567=4)"
+ " @21945\n"));
+
+ /* TEI Ctrl from above and next sequence after abcd. */
+ const char *gtp_req_from_sgsn = MSG_DEL_PDP_CTX_REQ("00000003", "abce");
+ const char *gtp_req_to_ggsn = MSG_DEL_PDP_CTX_REQ("00000765", "6d32");
+
+ LVL2_ASSERT(msg_from_sgsn_c(&sgsn_sender,
+ &resolved_ggsn_addr,
+ gtp_req_from_sgsn,
+ gtp_req_to_ggsn));
+
+ /* 21945 + 31 = 21976 */
+ LVL2_ASSERT(tunnels_are(
+ "192.168.42.23 (TEI C 321=1 / U 123=2)"
+ " <-> 192.168.43.34 (TEI C 765=3 / U 567=4)"
+ " @21976\n"));
+
+ const char *gtp_resp_from_ggsn =
+ MSG_DEL_PDP_CTX_RSP("00000001", "6d32");
+ const char *gtp_resp_to_sgsn =
+ MSG_DEL_PDP_CTX_RSP("00000321", "abce");
+
+ /* The response should go back to whichever port the request came from
+ * (unmapped by sequence nr) */
+ LVL2_ASSERT(msg_from_ggsn_c(&resolved_ggsn_addr,
+ &sgsn_sender,
+ gtp_resp_from_ggsn,
+ gtp_resp_to_sgsn));
+
+ LVL2_ASSERT(tunnels_are(""));
+
+ return 1;
+}
+
+static void test_one_pdp_ctx(void)
{
- LOG("test_create_pdp_ctx");
+ LOG("test_one_pdp_ctx");
OSMO_ASSERT(setup_test_hub());
OSMO_ASSERT(create_pdp_ctx());
@@ -982,6 +1048,10 @@ static void test_create_pdp_ctx(void)
"192.168.42.23 (TEI C 321=1 / U 123=2)"
" <-> 192.168.43.34 (TEI C 765=3 / U 567=4)"
" @21945\n"));
+
+ OSMO_ASSERT(delete_pdp_ctx());
+ OSMO_ASSERT(tunnels_are(""));
+
OSMO_ASSERT(clear_test_hub());
}
@@ -1108,7 +1178,7 @@ int main(int argc, char **argv)
test_nr_map_wrap();
test_expiry();
test_echo();
- test_create_pdp_ctx();
+ test_one_pdp_ctx();
test_user_data();
printf("Done\n");
diff --git a/openbsc/tests/gtphub/gtphub_test.ok b/openbsc/tests/gtphub/gtphub_test.ok
index 24b9aad12..8f66b9d59 100644
--- a/openbsc/tests/gtphub/gtphub_test.ok
+++ b/openbsc/tests/gtphub/gtphub_test.ok
@@ -1,5 +1,5 @@
test_echo
-test_create_pdp_ctx
+test_one_pdp_ctx
- __wrap_gtphub_resolve_ggsn_addr():
returning GGSN addr from imsi 240010123456789 ni internet: 192.168.43.34 port 2123
test_user_data