[PATCH] libosmocore[master]: GSUP: implement simple session management support

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Vadim Yanitskiy gerrit-no-reply at lists.osmocom.org
Mon Apr 9 19:32:45 UTC 2018


Review at  https://gerrit.osmocom.org/7700

GSUP: implement simple session management support

Unlike TCAP/MAP, GSUP is just a transport layer without the
dialogue/context. This makes impossible to have a session
based communication (e.g. USSD) over GSUP.

This change introduces two new IEs:

  - OSMO_GSUP_SESSION_ID_IE,
  - OSMO_GSUP_SESSION_STATE_IE,

which can be used to indicate that the message is related to
a session with given ID, and to manage a session state, i.e.
initiate, continue, and finish.

Also, this change introduces a group of new messages intended
for requesting a new (unused) session ID before its initiation.

Change-Id: I1cee271fed0284a134ffed103c0d4bebbcfde2a8
Related: OS#1597
---
M TODO-RELEASE
M include/osmocom/gsm/gsup.h
M src/gsm/gsup.c
M tests/gsup/gsup_test.c
M tests/gsup/gsup_test.err
M tests/gsup/gsup_test.ok
6 files changed, 96 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/00/7700/1

diff --git a/TODO-RELEASE b/TODO-RELEASE
index 16496d6..65b0fa8 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -13,3 +13,5 @@
 fsm		fsmc / fsm.h			added callback for graceful exit => ABI changed
 gsm		gsm0480.c / gsm0480.h		the 'ss_request' struct extended with ussd_data,
 						ussd_data_len, and ussd_data_dcs => ABI changed
+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 1a8a3b2..08f89e1 100644
--- a/include/osmocom/gsm/gsup.h
+++ b/include/osmocom/gsm/gsup.h
@@ -81,6 +81,18 @@
 	OSMO_GSUP_AUTS_IE			= 0x26,
 	OSMO_GSUP_RES_IE			= 0x27,
 	OSMO_GSUP_CN_DOMAIN_IE			= 0x28,
+
+	/**
+	 * Session management
+	 *
+	 * SESSION_ID is used to distinguish between concurrent
+	 * sessions, and shall be unique for each active one.
+	 *
+	 * SESSION_STATE indicates the current state of a session,
+	 * see the 'osmo_gsup_session_state' enum for details.
+	 */
+	OSMO_GSUP_SESSION_ID_IE			= 0x30,
+	OSMO_GSUP_SESSION_STATE_IE		= 0x31,
 };
 
 /*! GSUP message type */
@@ -110,6 +122,19 @@
 	OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST	= 0b00011100,
 	OSMO_GSUP_MSGT_LOCATION_CANCEL_ERROR	= 0b00011101,
 	OSMO_GSUP_MSGT_LOCATION_CANCEL_RESULT	= 0b00011110,
+
+	/**
+	 * Unlike TCAP/MAP, GSUP is just a transport layer without the
+	 * dialogue/context. The following messages are intended for
+	 * session-based communications, e.g. USSD over GSUP.
+	 *
+	 * This message can be used by one of two communicating
+	 * entries in order to request a new (unused) session ID
+	 * before initiating a new session.
+	 */
+	OSMO_GSUP_MSGT_SESSION_ID_REQUEST	= 0b00100000,
+	OSMO_GSUP_MSGT_SESSION_ID_ERROR		= 0b00100001,
+	OSMO_GSUP_MSGT_SESSION_ID_RESULT	= 0b00100010,
 };
 
 #define OSMO_GSUP_IS_MSGT_REQUEST(msgt) (((msgt) & 0b00000011) == 0b00)
@@ -129,6 +154,17 @@
 enum osmo_gsup_cn_domain {
 	OSMO_GSUP_CN_DOMAIN_PS			= 1,
 	OSMO_GSUP_CN_DOMAIN_CS			= 2,
+};
+
+enum osmo_gsup_session_state {
+	/* Undefined session state */
+	OSMO_GSUP_SESSION_STATE_NONE		= 0x00,
+	/* Request to initiate a new session */
+	OSMO_GSUP_SESSION_STATE_BEGIN		= 0x01,
+	/* Communication within the existing session */
+	OSMO_GSUP_SESSION_STATE_CONTINUE	= 0x02,
+	/* Indication of the session end */
+	OSMO_GSUP_SESSION_STATE_END		= 0x03,
 };
 
 /*! parsed/decoded PDP context information */
@@ -175,6 +211,10 @@
 	enum osmo_gsup_cn_domain	cn_domain;
 	const uint8_t			*pdp_charg_enc;
 	size_t				pdp_charg_enc_len;
+
+	/*! Session management fields */
+	enum osmo_gsup_session_state	session_state;
+	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 b6ac56d..78818c5 100644
--- a/src/gsm/gsup.c
+++ b/src/gsm/gsup.c
@@ -62,6 +62,11 @@
 	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_SESSION_ID_REQUEST),
+	OSMO_VALUE_STRING(OSMO_GSUP_MSGT_SESSION_ID_ERROR),
+	OSMO_VALUE_STRING(OSMO_GSUP_MSGT_SESSION_ID_RESULT),
+
 	{ 0, NULL }
 };
 
@@ -385,6 +390,14 @@
 			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 +577,14 @@
 				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 b55f1d9..fb17e15 100644
--- a/tests/gsup/gsup_test.c
+++ b/tests/gsup/gsup_test.c
@@ -171,6 +171,20 @@
 			0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
 	};
 
+	static const uint8_t send_session_id_req[] = {
+		0x20, /* OSMO_GSUP_MSGT_SESSION_ID_REQUEST */
+		TEST_IMSI_IE,
+	};
+
+	static const uint8_t send_session_id_res[] = {
+		0x22, /* OSMO_GSUP_MSGT_SESSION_ID_RESULT */
+		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 +218,10 @@
 			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)},
+		{"Session ID request",
+			send_session_id_req, sizeof(send_session_id_req)},
+		{"Session ID response",
+			send_session_id_res, sizeof(send_session_id_res)},
 	};
 
 	printf("Test GSUP message decoding/encoding\n");
@@ -267,7 +285,7 @@
 					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 05c64fe..6e56b95 100644
--- a/tests/gsup/gsup_test.err
+++ b/tests/gsup/gsup_test.err
@@ -40,6 +40,12 @@
   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: 20 01 08 21 43 65 87 09 21 43 f5 
+  original message:  20 01 08 21 43 65 87 09 21 43 f5 
+  IMSI:              123456789012345
+  generated message: 22 01 08 21 43 65 87 09 21 43 f5 30 04 de ad be ef 31 01 01 
+  original message:  22 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 +60,8 @@
   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 11 truncations, 11 parse failures
+  message 15: 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 +77,5 @@
   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 2816 modifications, 510 parse failures
+  message 15: tested 5120 modifications, 1026 parse failures
diff --git a/tests/gsup/gsup_test.ok b/tests/gsup/gsup_test.ok
index 49a85ba..960e516 100644
--- a/tests/gsup/gsup_test.ok
+++ b/tests/gsup/gsup_test.ok
@@ -27,4 +27,8 @@
           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 Session ID request
+          Session ID request OK
+  Testing Session ID response
+          Session ID response OK
 Done.

-- 
To view, visit https://gerrit.osmocom.org/7700
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1cee271fed0284a134ffed103c0d4bebbcfde2a8
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>



More information about the gerrit-log mailing list