diff --git a/TODO-RELEASE b/TODO-RELEASE index 8ccfa491e..d9848136c 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -7,3 +7,5 @@ # If any interfaces have been added since the last public release: c:r:a + 1. # If any interfaces have been removed or changed since the last public release: c:r:0. #library what description / commit summary line +gsup gsup.h the 'osmo_gsup_message' struct extended with + session information => ABI changed diff --git a/include/osmocom/gsm/gsup.h b/include/osmocom/gsm/gsup.h index a7fa82080..5f456991e 100644 --- a/include/osmocom/gsm/gsup.h +++ b/include/osmocom/gsm/gsup.h @@ -82,6 +82,9 @@ enum osmo_gsup_iei { OSMO_GSUP_AUTS_IE = 0x26, OSMO_GSUP_RES_IE = 0x27, OSMO_GSUP_CN_DOMAIN_IE = 0x28, + + OSMO_GSUP_SESSION_ID_IE = 0x30, + OSMO_GSUP_SESSION_STATE_IE = 0x31, }; /*! GSUP message type */ @@ -132,6 +135,18 @@ enum osmo_gsup_cn_domain { OSMO_GSUP_CN_DOMAIN_CS = 2, }; +/*! TCAP-like session state */ +enum osmo_gsup_session_state { + /*! Undefined session state */ + OSMO_GSUP_SESSION_STATE_NONE = 0x00, + /*! Initiation of a new session */ + OSMO_GSUP_SESSION_STATE_BEGIN = 0x01, + /*! Communication of an existing session */ + OSMO_GSUP_SESSION_STATE_CONTINUE = 0x02, + /*! Indication of the session end */ + OSMO_GSUP_SESSION_STATE_END = 0x03, +}; + /*! parsed/decoded PDP context information */ struct osmo_gsup_pdp_info { unsigned int context_id; @@ -176,6 +191,12 @@ struct osmo_gsup_message { enum osmo_gsup_cn_domain cn_domain; const uint8_t *pdp_charg_enc; size_t pdp_charg_enc_len; + + /*! Session state \ref osmo_gsup_session_state */ + enum osmo_gsup_session_state session_state; + /*! Unique session identifier and origination flag. + * Encoded only when \ref session_state != 0x00 */ + uint32_t session_id; }; 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 b6ac56d9e..8663f449e 100644 --- a/src/gsm/gsup.c +++ b/src/gsm/gsup.c @@ -385,6 +385,14 @@ int osmo_gsup_decode(const uint8_t *const_data, size_t data_len, gsup_msg->pdp_charg_enc_len = value_len; break; + case OSMO_GSUP_SESSION_ID_IE: + gsup_msg->session_id = osmo_decode_big_endian(value, value_len); + break; + + case OSMO_GSUP_SESSION_STATE_IE: + gsup_msg->session_state = *value; + break; + default: LOGP(DLGSUP, LOGL_NOTICE, "GSUP IE type %d unknown\n", iei); @@ -564,6 +572,14 @@ int osmo_gsup_encode(struct msgb *msg, const struct osmo_gsup_message *gsup_msg) gsup_msg->pdp_charg_enc_len, gsup_msg->pdp_charg_enc); } + if ((u8 = gsup_msg->session_state)) { + size_t len = sizeof(gsup_msg->session_id); + uint8_t *sid = osmo_encode_big_endian(gsup_msg->session_id, len); + + msgb_tlv_put(msg, OSMO_GSUP_SESSION_ID_IE, len, sid); + msgb_tlv_put(msg, OSMO_GSUP_SESSION_STATE_IE, sizeof(u8), &u8); + } + return 0; } diff --git a/tests/gsup/gsup_test.c b/tests/gsup/gsup_test.c index acc7274fc..6ead7d280 100644 --- a/tests/gsup/gsup_test.c +++ b/tests/gsup/gsup_test.c @@ -171,6 +171,15 @@ static void test_gsup_messages_dec_enc(void) 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, }; + static const uint8_t dummy_session_ies[] = { + 0x2b, /* Dummy value, we only interested in IE coding */ + TEST_IMSI_IE, + + /* Session ID and state */ + 0x30, 0x04, 0xde, 0xad, 0xbe, 0xef, + 0x31, 0x01, 0x01, + }; + static const struct test { char *name; const uint8_t *data; @@ -204,6 +213,8 @@ static void test_gsup_messages_dec_enc(void) send_auth_info_res_umts, sizeof(send_auth_info_res_umts)}, {"Send Authentication Info Request with AUTS and RAND (UMTS)", send_auth_info_req_auts, sizeof(send_auth_info_req_auts)}, + {"Dummy message with session IEs", + dummy_session_ies, sizeof(dummy_session_ies)}, }; printf("Test GSUP message decoding/encoding\n"); @@ -267,7 +278,7 @@ 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_CN_DOMAIN_IE); + OSMO_ASSERT(t->data[j+0] <= OSMO_GSUP_SESSION_STATE_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 05c64fe4a..5c010e6cf 100644 --- a/tests/gsup/gsup_test.err +++ b/tests/gsup/gsup_test.err @@ -40,6 +40,9 @@ generated message: 08 01 08 21 43 65 87 09 21 43 f5 26 0e 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 20 10 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 original message: 08 01 08 21 43 65 87 09 21 43 f5 26 0e 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 20 10 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 IMSI: 123456789012345 + 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 message 0: tested 11 truncations, 11 parse failures message 1: tested 14 truncations, 13 parse failures message 2: tested 83 truncations, 81 parse failures @@ -54,6 +57,7 @@ message 11: tested 13 truncations, 12 parse failures message 12: tested 211 truncations, 209 parse failures message 13: tested 45 truncations, 43 parse failures + message 14: tested 20 truncations, 18 parse failures DLGSUP Stopping DLGSUP logging message 0: tested 2816 modifications, 510 parse failures message 1: tested 3584 modifications, 768 parse failures @@ -69,3 +73,4 @@ DLGSUP Stopping DLGSUP logging message 11: tested 3328 modifications, 767 parse failures message 12: tested 54016 modifications, 4622 parse failures message 13: tested 11520 modifications, 1026 parse failures + message 14: tested 5120 modifications, 1026 parse failures diff --git a/tests/gsup/gsup_test.ok b/tests/gsup/gsup_test.ok index 49a85ba67..1f5990259 100644 --- a/tests/gsup/gsup_test.ok +++ b/tests/gsup/gsup_test.ok @@ -27,4 +27,6 @@ Test GSUP message decoding/encoding Send Authentication Info Result with IK, CK, AUTN and RES (UMTS) OK Testing Send Authentication Info Request with AUTS and RAND (UMTS) Send Authentication Info Request with AUTS and RAND (UMTS) OK + Testing Dummy message with session IEs + Dummy message with session IEs OK Done.