From 9ff82892da2b58ba344b2f6e70256d08947b9c34 Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Thu, 29 Jan 2015 14:17:51 +0100 Subject: gprs: Use 'Network failure' as default cause This commit adds a check after a GSUP message has been decoded whether it is an error message and does not contain a cause value. If his is the case, the cause value is set to 'Network failure', so that this cause if effectively the default value for error messages. Sponsored-by: On-Waves ehf --- openbsc/src/gprs/gprs_subscriber.c | 3 +++ openbsc/tests/sgsn/sgsn_test.c | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/openbsc/src/gprs/gprs_subscriber.c b/openbsc/src/gprs/gprs_subscriber.c index 4434324ab..0009685b1 100644 --- a/openbsc/src/gprs/gprs_subscriber.c +++ b/openbsc/src/gprs/gprs_subscriber.c @@ -514,6 +514,9 @@ int gprs_subscr_rx_gsup_message(struct msgb *msg) return -GMM_CAUSE_INV_MAND_INFO; } + if (!gsup_msg.cause && GPRS_GSUP_IS_MSGT_ERROR(gsup_msg.message_type)) + gsup_msg.cause = GMM_CAUSE_NET_FAIL; + subscr = gprs_subscr_get_by_imsi(gsup_msg.imsi); if (!subscr) { diff --git a/openbsc/tests/sgsn/sgsn_test.c b/openbsc/tests/sgsn/sgsn_test.c index 25e031014..1036e41fc 100644 --- a/openbsc/tests/sgsn/sgsn_test.c +++ b/openbsc/tests/sgsn/sgsn_test.c @@ -451,6 +451,11 @@ static void test_subscriber_gsup(void) 0x02, 0x01, 0x02, /* IMSI unknown in HLR */ }; + static const uint8_t purge_ms_err_no_cause[] = { + 0x0d, + TEST_GSUP_IMSI1_IE, + }; + static const uint8_t purge_ms_res[] = { 0x0e, TEST_GSUP_IMSI1_IE, @@ -588,6 +593,11 @@ static void test_subscriber_gsup(void) sizeof(purge_ms_err)); OSMO_ASSERT(rc == -GMM_CAUSE_IMSI_UNKNOWN); + /* Inject PurgeMsErr() GSUP message */ + rc = rx_gsup_message(purge_ms_err_no_cause, + sizeof(purge_ms_err_no_cause)); + OSMO_ASSERT(rc == -GMM_CAUSE_NET_FAIL); + /* Inject InsertSubscrData GSUP message (unknown IMSI) */ last_updated_subscr = NULL; rc = rx_gsup_message(insert_data_req, sizeof(insert_data_req)); -- cgit v1.2.3