[PATCH] libosmocore[master]: gsm0480: refactor gsm0480_decode_ss_request

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 Jan 17 06:46:36 UTC 2018


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

gsm0480: refactor gsm0480_decode_ss_request

Change-Id: Iba734db97ab516f8fce816c4e4225b97b93619f1
---
M src/gsm/gsm0480.c
1 file changed, 14 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/37/5837/1

diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index 25f97a2..ca00999 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -255,17 +255,24 @@
 int gsm0480_decode_ss_request(const struct gsm48_hdr *hdr, uint16_t len,
 				struct ss_request *req)
 {
-	int rc = 0;
+	uint8_t pdisc;
 
-	if (gsm48_hdr_pdisc(hdr) == GSM48_PDISC_NC_SS) {
-		req->transaction_id = hdr->proto_discr & 0x70;
-		rc = parse_ss(hdr, len - sizeof(*hdr), req);
+	/**
+	 * Check Protocol Discriminator
+	 * see TS GSM 04.07 and GSM 04.80
+	 */
+	pdisc = gsm48_hdr_pdisc(hdr);
+	if (pdisc != GSM48_PDISC_NC_SS) {
+		LOGP(0, LOGL_ERROR, "Dropping message with "
+			"unsupported pdisc=%02x\n", pdisc);
+		return 0;
 	}
 
-	if (!rc)
-		LOGP(0, LOGL_DEBUG, "Error occurred while parsing received SS!\n");
+	/* GSM 04.80 3.3 Transaction Identifier */
+	req->transaction_id = hdr->proto_discr & 0x70;
 
-	return rc;
+	/* Parse SS request */
+	return parse_ss(hdr, len - sizeof(*hdr), req);
 }
 
 static int parse_ss(const struct gsm48_hdr *hdr, uint16_t len, struct ss_request *req)

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

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