From 36c7b33ccc66eee29efa98120e00952532c8e122 Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Sat, 31 Mar 2018 05:23:09 +0700 Subject: [PATCH] GSUP: introduce new messages for SS/USSD payloads In order to be able to transfer SS/USSD messages via GSUP, this change introduces the following new message types: - OSMO_GSUP_MSGT_PROC_SS_*, and the following new IE: - OSMO_GSUP_SS_INFO_IE which represents an ASN.1 encoded MAP payload coming to/from the mobile station 'as is', without any transcoding. Change-Id: Ie17a78043a35fffbdd59e80fd2b2da39cce5e532 Related: OS#1597 --- TODO-RELEASE | 1 + include/osmocom/gsm/gsup.h | 11 +++++++++ src/gsm/gsup.c | 15 ++++++++++++ tests/gsup/gsup_test.c | 47 +++++++++++++++++++++++++++++++++++++- tests/gsup/gsup_test.err | 10 ++++++++ tests/gsup/gsup_test.ok | 4 ++++ 6 files changed, 87 insertions(+), 1 deletion(-) diff --git a/TODO-RELEASE b/TODO-RELEASE index d9848136c..7b225cc4c 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -9,3 +9,4 @@ #library what description / commit summary line gsup gsup.h the 'osmo_gsup_message' struct extended with session information => ABI changed + SS/USSD information => ABI changed diff --git a/include/osmocom/gsm/gsup.h b/include/osmocom/gsm/gsup.h index 5f456991e..dd2749346 100644 --- a/include/osmocom/gsm/gsup.h +++ b/include/osmocom/gsm/gsup.h @@ -85,6 +85,9 @@ enum osmo_gsup_iei { OSMO_GSUP_SESSION_ID_IE = 0x30, OSMO_GSUP_SESSION_STATE_IE = 0x31, + + /*! Supplementary Services payload */ + OSMO_GSUP_SS_INFO_IE = 0x35, }; /*! GSUP message type */ @@ -114,6 +117,10 @@ enum osmo_gsup_message_type { OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST = 0b00011100, OSMO_GSUP_MSGT_LOCATION_CANCEL_ERROR = 0b00011101, OSMO_GSUP_MSGT_LOCATION_CANCEL_RESULT = 0b00011110, + + OSMO_GSUP_MSGT_PROC_SS_REQUEST = 0b00100000, + OSMO_GSUP_MSGT_PROC_SS_ERROR = 0b00100001, + OSMO_GSUP_MSGT_PROC_SS_RESULT = 0b00100010, }; #define OSMO_GSUP_IS_MSGT_REQUEST(msgt) (((msgt) & 0b00000011) == 0b00) @@ -197,6 +204,10 @@ struct osmo_gsup_message { /*! Unique session identifier and origination flag. * Encoded only when \ref session_state != 0x00 */ uint32_t session_id; + + /*! ASN.1 encoded MAP payload for Supplementary Services */ + uint8_t *ss_info; + size_t ss_info_len; }; int osmo_gsup_decode(const uint8_t *data, size_t data_len, diff --git a/src/gsm/gsup.c b/src/gsm/gsup.c index 8663f449e..b4b60b20f 100644 --- a/src/gsm/gsup.c +++ b/src/gsm/gsup.c @@ -62,6 +62,11 @@ const struct value_string osmo_gsup_message_type_names[] = { OSMO_VALUE_STRING(OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST), OSMO_VALUE_STRING(OSMO_GSUP_MSGT_LOCATION_CANCEL_ERROR), OSMO_VALUE_STRING(OSMO_GSUP_MSGT_LOCATION_CANCEL_RESULT), + + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_PROC_SS_REQUEST), + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_PROC_SS_ERROR), + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_PROC_SS_RESULT), + { 0, NULL } }; @@ -393,6 +398,11 @@ int osmo_gsup_decode(const uint8_t *const_data, size_t data_len, gsup_msg->session_state = *value; break; + case OSMO_GSUP_SS_INFO_IE: + gsup_msg->ss_info = value; + gsup_msg->ss_info_len = value_len; + break; + default: LOGP(DLGSUP, LOGL_NOTICE, "GSUP IE type %d unknown\n", iei); @@ -580,6 +590,11 @@ int osmo_gsup_encode(struct msgb *msg, const struct osmo_gsup_message *gsup_msg) msgb_tlv_put(msg, OSMO_GSUP_SESSION_STATE_IE, sizeof(u8), &u8); } + if (gsup_msg->ss_info) { + msgb_tlv_put(msg, OSMO_GSUP_SS_INFO_IE, + gsup_msg->ss_info_len, gsup_msg->ss_info); + } + return 0; } diff --git a/tests/gsup/gsup_test.c b/tests/gsup/gsup_test.c index 6ead7d280..9712d77ba 100644 --- a/tests/gsup/gsup_test.c +++ b/tests/gsup/gsup_test.c @@ -180,6 +180,43 @@ static void test_gsup_messages_dec_enc(void) 0x31, 0x01, 0x01, }; + static const uint8_t send_ussd_req[] = { + 0x20, /* OSMO_GSUP_MSGT_PROC_SS_REQUEST */ + TEST_IMSI_IE, + + /* Session ID and state */ + 0x30, 0x04, 0xde, 0xad, 0xbe, 0xef, + 0x31, 0x01, 0x01, + + /* SS/USSD information IE */ + 0x35, 0x14, + /* ASN.1 encoded MAP payload */ + 0xa1, 0x12, + 0x02, 0x01, /* Component: invoke */ + 0x01, /* invokeID = 1 */ + /* opCode: processUnstructuredSS-Request */ + 0x02, 0x01, 0x3b, 0x30, 0x0a, 0x04, 0x01, 0x0f, + 0x04, 0x05, 0xaa, 0x18, 0x0c, 0x36, 0x02, + }; + + static const uint8_t send_ussd_res[] = { + 0x22, /* OSMO_GSUP_MSGT_PROC_SS_RESULT */ + TEST_IMSI_IE, + + /* Session ID and state */ + 0x30, 0x04, 0xde, 0xad, 0xbe, 0xef, + 0x31, 0x01, 0x03, + + /* SS/USSD information IE */ + 0x35, 0x08, + /* ASN.1 encoded MAP payload */ + 0xa3, 0x06, + 0x02, 0x01, /* Component: returnError */ + 0x01, /* invokeID = 1 */ + /* localValue: unknownAlphabet */ + 0x02, 0x01, 0x47, + }; + static const struct test { char *name; const uint8_t *data; @@ -215,6 +252,10 @@ static void test_gsup_messages_dec_enc(void) send_auth_info_req_auts, sizeof(send_auth_info_req_auts)}, {"Dummy message with session IEs", dummy_session_ies, sizeof(dummy_session_ies)}, + {"SS/USSD processUnstructuredSS-Request / Invoke", + send_ussd_req, sizeof(send_ussd_req)}, + {"SS/USSD processUnstructuredSS-Request / ReturnResult", + send_ussd_res, sizeof(send_ussd_res)}, }; printf("Test GSUP message decoding/encoding\n"); @@ -278,7 +319,11 @@ static void test_gsup_messages_dec_enc(void) osmo_hexdump(t->data + j, ie_end - j)); OSMO_ASSERT(j <= ie_end - 2); - OSMO_ASSERT(t->data[j+0] <= OSMO_GSUP_SESSION_STATE_IE); + /** + * FIXME: share the maximal IE value somehow + * in order to avoid manual updating of this + */ + OSMO_ASSERT(t->data[j+0] <= OSMO_GSUP_SS_INFO_IE); OSMO_ASSERT(t->data[j+1] <= ie_end - j - 2); ie_end = j; diff --git a/tests/gsup/gsup_test.err b/tests/gsup/gsup_test.err index 5c010e6cf..ac71ac24e 100644 --- a/tests/gsup/gsup_test.err +++ b/tests/gsup/gsup_test.err @@ -43,6 +43,12 @@ generated message: 2b 01 08 21 43 65 87 09 21 43 f5 30 04 de ad be ef 31 01 01 original message: 2b 01 08 21 43 65 87 09 21 43 f5 30 04 de ad be ef 31 01 01 IMSI: 123456789012345 + generated message: 20 01 08 21 43 65 87 09 21 43 f5 30 04 de ad be ef 31 01 01 35 14 a1 12 02 01 01 02 01 3b 30 0a 04 01 0f 04 05 aa 18 0c 36 02 + original message: 20 01 08 21 43 65 87 09 21 43 f5 30 04 de ad be ef 31 01 01 35 14 a1 12 02 01 01 02 01 3b 30 0a 04 01 0f 04 05 aa 18 0c 36 02 + IMSI: 123456789012345 + generated message: 22 01 08 21 43 65 87 09 21 43 f5 30 04 de ad be ef 31 01 03 35 08 a3 06 02 01 01 02 01 47 + original message: 22 01 08 21 43 65 87 09 21 43 f5 30 04 de ad be ef 31 01 03 35 08 a3 06 02 01 01 02 01 47 + IMSI: 123456789012345 message 0: tested 11 truncations, 11 parse failures message 1: tested 14 truncations, 13 parse failures message 2: tested 83 truncations, 81 parse failures @@ -58,6 +64,8 @@ message 12: tested 211 truncations, 209 parse failures message 13: tested 45 truncations, 43 parse failures message 14: tested 20 truncations, 18 parse failures + message 15: tested 42 truncations, 39 parse failures + message 16: tested 30 truncations, 27 parse failures DLGSUP Stopping DLGSUP logging message 0: tested 2816 modifications, 510 parse failures message 1: tested 3584 modifications, 768 parse failures @@ -74,3 +82,5 @@ DLGSUP Stopping DLGSUP logging message 12: tested 54016 modifications, 4622 parse failures message 13: tested 11520 modifications, 1026 parse failures message 14: tested 5120 modifications, 1026 parse failures + message 15: tested 10752 modifications, 1256 parse failures + message 16: tested 7680 modifications, 1265 parse failures diff --git a/tests/gsup/gsup_test.ok b/tests/gsup/gsup_test.ok index 1f5990259..d63dd2d68 100644 --- a/tests/gsup/gsup_test.ok +++ b/tests/gsup/gsup_test.ok @@ -29,4 +29,8 @@ Test GSUP message decoding/encoding Send Authentication Info Request with AUTS and RAND (UMTS) OK Testing Dummy message with session IEs Dummy message with session IEs OK + Testing SS/USSD processUnstructuredSS-Request / Invoke + SS/USSD processUnstructuredSS-Request / Invoke OK + Testing SS/USSD processUnstructuredSS-Request / ReturnResult + SS/USSD processUnstructuredSS-Request / ReturnResult OK Done.