[PATCH] libosmocore[master]: gsm0480: copy the raw USSD data, its DCS and length

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
Wed Apr 4 03:58:56 UTC 2018


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

gsm0480: copy the raw USSD data, its DCS and length

As it was already documented before, the 'ss_request' struct has
a rudiment of deprecated 'ussd_request' struct - the 'ussd_text'
field. It represents the data either of an INVOKE component,
either of a RETURN_RESULT component, encoded as ASCII in case
if DCS is 0x0f (i.e. decoded by the code itself), otherwise
raw bytes 'as is'.

Previously, there was no possibility to distinguish between
ASCII and raw bytes with different DCS. Moreover, the payload
decoding is not desired in some cases.

Let's introduce the new fields, which will carry the raw
unmodified payload, its length and DCS (Data Coding Scheme).

Change-Id: Ia193d175021e145bb3b131290231f307dbefc64a
---
M include/osmocom/gsm/gsm0480.h
M src/gsm/gsm0480.c
2 files changed, 29 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/25/7625/1

diff --git a/include/osmocom/gsm/gsm0480.h b/include/osmocom/gsm/gsm0480.h
index 05c26df..b0b6aa2 100644
--- a/include/osmocom/gsm/gsm0480.h
+++ b/include/osmocom/gsm/gsm0480.h
@@ -67,6 +67,18 @@
 	uint8_t ussd_text[GSM0480_USSD_OCTET_STRING_LEN];
 
 	/**
+	 * Represents the data of either an INVOKE, either
+	 * a RETURN_RESULT component 'as is'. Useful when
+	 * decoding is not supported or not desired.
+	 *
+	 * Shall be always followed by its length (in bytes)
+	 * and DCS (Data Coding Scheme).
+	 */
+	uint8_t ussd_data[GSM0480_USSD_OCTET_STRING_LEN];
+	uint8_t ussd_data_len; /* Length in bytes */
+	uint8_t ussd_data_dcs; /* Data Coding Scheme */
+
+	/**
 	 * GSM TS 04.80, section 3.3 "Transaction identifier"
 	 * See GSM TS 04.07, section 11.2.3 for details.
 	 */
diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index 0072812..38082b3 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -557,6 +557,11 @@
 
 	memcpy(req->ussd_text, uss_req_data + 2, num_chars);
 
+	/* Copy the data 'as is' */
+	memcpy(req->ussd_data, uss_req_data + 2, num_chars);
+	req->ussd_data_len = num_chars;
+	req->ussd_data_dcs = 0x00;
+
 	return 1;
 }
 
@@ -580,6 +585,17 @@
 
 	/* Get DCS (Data Coding Scheme) */
 	dcs = uss_req_data[4];
+	/* Get the amount of bytes */
+	num_chars = uss_req_data[6];
+
+	/* Prevent a mobile-originated buffer-overrun! */
+	if (num_chars > GSM0480_USSD_OCTET_STRING_LEN)
+		num_chars = GSM0480_USSD_OCTET_STRING_LEN;
+
+	/* Copy the data 'as is' */
+	memcpy(req->ussd_data, uss_req_data + 7, num_chars);
+	req->ussd_data_len = num_chars;
+	req->ussd_data_dcs = dcs;
 
 	/**
 	 * According to GSM 04.08, 4.4.2 "ASN.1 data types":
@@ -588,7 +604,7 @@
 	 */
 	if (dcs == 0x0F) {
 		/* Calculate the amount of 7-bit characters */
-		num_chars = (uss_req_data[6] * 8) / 7;
+		num_chars = (num_chars * 8) / 7;
 
 		/* Prevent a mobile-originated buffer-overrun! */
 		if (num_chars > GSM0480_USSD_7BIT_STRING_LEN)
@@ -599,15 +615,7 @@
 
 		return 1;
 	} else {
-		/* Get the amount of 8-bit characters */
-		num_chars = uss_req_data[6];
-
-		/* Prevent a mobile-originated buffer-overrun! */
-		if (num_chars > GSM0480_USSD_OCTET_STRING_LEN)
-			num_chars = GSM0480_USSD_OCTET_STRING_LEN;
-
 		memcpy(req->ussd_text, &(uss_req_data[7]), num_chars);
-
 		return 1;
 	}
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia193d175021e145bb3b131290231f307dbefc64a
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