diff options
author | Jacob Erlbeck <jerlbeck@sysmocom.de> | 2014-10-21 13:09:55 +0200 |
---|---|---|
committer | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2014-10-27 15:34:14 +0100 |
commit | 5a38f6470e74b0d7d7746fa65573f2acf76197eb (patch) | |
tree | 88067f681b17a67c685035a33aa4ea2aabc3dae8 /openbsc/tests/sgsn/sgsn_test.c | |
parent | b9ab0d4f398aff18e1f0c28d4aac09ac4707a24b (diff) |
sgsn: Handle Detach Requests even when there is no mmctx
Currently, when a Detach Request is received with an unknown TLLI,
it is answered by another Detach Request (!), even when a power_off
Type is used.
This patch uses gsm48_rx_gmm_det_req to handle the message instead.
So this function is changed to cope with a NULL mmctx. In that case
it doesn't unassign the llme, so this must be done manually
afterwards.
Sponsored-by: On-Waves ehf
Diffstat (limited to 'openbsc/tests/sgsn/sgsn_test.c')
-rw-r--r-- | openbsc/tests/sgsn/sgsn_test.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/openbsc/tests/sgsn/sgsn_test.c b/openbsc/tests/sgsn/sgsn_test.c index cb3c29472..05d1ee0ef 100644 --- a/openbsc/tests/sgsn/sgsn_test.c +++ b/openbsc/tests/sgsn/sgsn_test.c @@ -221,6 +221,41 @@ static void test_gmm_detach_power_off(void) OSMO_ASSERT(!ictx); } +/* + * Test that a GMM Detach will remove the associated LLME if there is no MMCTX. + */ +static void test_gmm_detach_no_mmctx(void) +{ + struct gprs_llc_lle *lle; + uint32_t local_tlli; + struct msgb *msg; + + printf("Testing GMM detach (no MMCTX)\n"); + + /* DTAP - Detach Request (MO) */ + /* normal detach, power_off = 0 */ + static const unsigned char detach_req[] = { + 0x08, 0x05, 0x01, 0x18, 0x05, 0xf4, 0xef, 0xe2, + 0xb7, 0x00, 0x19, 0x03, 0xb9, 0x97, 0xcb + }; + + /* Create an LLME */ + OSMO_ASSERT(count(gprs_llme_list()) == 0); + local_tlli = gprs_tmsi2tlli(0x23, TLLI_LOCAL); + lle = gprs_lle_get_or_create(local_tlli, 3); + + OSMO_ASSERT(count(gprs_llme_list()) == 1); + + /* inject the detach */ + msg = create_msg(detach_req, ARRAY_SIZE(detach_req)); + msgb_tlli(msg) = local_tlli; + gsm0408_gprs_rcvmsg(msg, lle->llme); + msgb_free(msg); + + /* verify that the LLME is gone */ + OSMO_ASSERT(count(gprs_llme_list()) == 0); +} + static struct log_info_cat gprs_categories[] = { [DMM] = { .name = "DMM", @@ -285,6 +320,7 @@ int main(int argc, char **argv) test_llme(); test_gmm_detach(); test_gmm_detach_power_off(); + test_gmm_detach_no_mmctx(); printf("Done\n"); return 0; } |