[PATCH 2/4] core: Fix handling GSM0480_MTYPE_FACILITY, it has only LV and facility_ie

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/OpenBSC@lists.osmocom.org/.

Sergey.Kostanbaev sergey.kostanbaev at gmail.com
Wed Nov 25 10:37:02 UTC 2015


From: Sergey Kostanbaev <Sergey.Kostanbaev at gmail.com>

According to gsm0480 FACILITY message contains LV header not TLV as in 
REGISTER or RETURN_RESULT

---
 src/gsm/gsm0480.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index 9bd54fa..5d1377f 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -196,6 +196,8 @@ static int parse_ss(const struct gsm48_hdr *hdr,
 		    uint16_t len, struct ss_request *req);
 static int parse_ss_info_elements(const uint8_t *ussd_ie, uint16_t len,
 				  struct ss_request *req);
+static int parse_ss_facility(const uint8_t *ss_facility, uint16_t len,
+			     struct ss_request *req);
 static int parse_facility_ie(const uint8_t *facility_ie, uint16_t length,
 			     struct ss_request *req);
 static int parse_ss_invoke(const uint8_t *invoke_data, uint16_t length,
@@ -271,9 +273,11 @@ static int parse_ss(const struct gsm48_hdr *hdr, uint16_t len, struct ss_request
 		req->ussd_text[0] = 0xFF;
 		break;
 	case GSM0480_MTYPE_REGISTER:
-	case GSM0480_MTYPE_FACILITY:
 		rc &= parse_ss_info_elements(&hdr->data[0], len - sizeof(*hdr), req);
 		break;
+	case GSM0480_MTYPE_FACILITY:
+		rc &= parse_ss_facility(&hdr->data[0], len - sizeof(*hdr), req);
+		break;
 	default:
 		LOGP(0, LOGL_DEBUG, "Unknown GSM 04.80 message-type field 0x%02x\n",
 			hdr->msg_type);
@@ -284,6 +288,18 @@ static int parse_ss(const struct gsm48_hdr *hdr, uint16_t len, struct ss_request
 	return rc;
 }
 
+static int parse_ss_facility(const uint8_t *ss_facility, uint16_t len,
+			     struct ss_request *req)
+{
+	uint8_t facility_length;
+
+	facility_length = ss_facility[0];
+	if (len - 1 < facility_length)
+		return 0;
+
+	return parse_facility_ie(ss_facility + 1, facility_length, req);
+}
+
 static int parse_ss_info_elements(const uint8_t *ss_ie, uint16_t len,
 				  struct ss_request *req)
 {
-- 
1.9.1




More information about the OpenBSC mailing list