[MERGED] libosmocore[master]: Add function to check MS GEA capabilities

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/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Wed Jun 29 16:33:25 UTC 2016


Harald Welte has submitted this change and it was merged.

Change subject: Add function to check MS GEA capabilities
......................................................................


Add function to check MS GEA capabilities

Add function which parses MS network capability IE value for bits
indicating support for particular version of GEA.

Change-Id: I785cef37dd272a2fab9b172f6e1392f865174e9a
Relates: OS#1582
---
M include/osmocom/gsm/protocol/gsm_04_08_gprs.h
M src/gsm/gsm_04_08_gprs.c
M src/gsm/libosmogsm.map
3 files changed, 36 insertions(+), 1 deletion(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/include/osmocom/gsm/protocol/gsm_04_08_gprs.h b/include/osmocom/gsm/protocol/gsm_04_08_gprs.h
index e0e887f..ed9a596 100644
--- a/include/osmocom/gsm/protocol/gsm_04_08_gprs.h
+++ b/include/osmocom/gsm/protocol/gsm_04_08_gprs.h
@@ -2,7 +2,9 @@
 #define _GSM48_GPRS_H
 
 #include <stdint.h>
+#include <stdbool.h>
 #include <osmocom/gsm/protocol/gsm_04_08.h>
+#include <osmocom/crypt/gprs_cipher.h>
 
 /* Table 10.4 / 10.4a, GPRS Mobility Management (GMM) */
 #define GSM48_MT_GMM_ATTACH_REQ		0x01
@@ -362,6 +364,9 @@
 	GSM48_QOS_SERR_1e_1		= 0x07,
 };
 
+bool gprs_ms_net_cap_gea_supported(const uint8_t *ms_net_cap, uint8_t cap_len,
+				   enum gprs_ciph_algo gea);
+
 /* Figure 10.5.138/24.008 / Chapter 10.5.6.5 */
 struct gsm48_qos {
 	/* octet 3 */
diff --git a/src/gsm/gsm_04_08_gprs.c b/src/gsm/gsm_04_08_gprs.c
index 5c00ea0..7018777 100644
--- a/src/gsm/gsm_04_08_gprs.c
+++ b/src/gsm/gsm_04_08_gprs.c
@@ -21,8 +21,10 @@
 
 
 #include <osmocom/gsm/protocol/gsm_04_08_gprs.h>
-
+#include <osmocom/crypt/gprs_cipher.h>
 #include <osmocom/core/utils.h>
+
+#include <stdbool.h>
 
 /* Protocol related stuff, should go into libosmocore */
 
@@ -108,6 +110,33 @@
 
 const struct value_string *gsm48_gsm_cause_names = gsm48_gsm_cause_names_;
 
+/*! \brief Check if MS supports particular version of GEA by inspecting
+ *         MS network capability IE specified in 3GPP TS 24.008
+ *  \param[in] ms_net_cap Buffer with raw MS network capability IE value,
+ *                        3 - 10 bytes
+ *  \param[in] cap_len Length of ms_net_cap, in bytes
+ *  \param[in] gea Version of GEA to check
+ *  \returns true if given version is supported by MS, false otherwise
+ */
+bool gprs_ms_net_cap_gea_supported(const uint8_t *ms_net_cap, uint8_t cap_len,
+				   enum gprs_ciph_algo gea)
+{
+	switch (gea) {
+	case GPRS_ALGO_GEA0:
+		return true;
+	case GPRS_ALGO_GEA1: /* 1st bit is GEA1: */
+		return 0x80 & ms_net_cap[0];
+	case GPRS_ALGO_GEA2: /* extended GEA bits start from 2nd bit */
+		return 0x40 & ms_net_cap[1]; /* of the next byte */
+	case GPRS_ALGO_GEA3:
+		return 0x20 & ms_net_cap[1];
+	case GPRS_ALGO_GEA4:
+		return 0x10 & ms_net_cap[1];
+	default:
+		return false;
+	}
+}
+
 /* 10.5.5.2 */
 const struct value_string gprs_att_t_strs_[] = {
 	{ GPRS_ATT_T_ATTACH,		"GPRS attach" },
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index ebeabcd..96f615e 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -44,6 +44,7 @@
 gprs_cipher_key_length;
 gprs_tlli_type;
 gprs_tmsi2tlli;
+gprs_ms_net_cap_gea_supported;
 
 gsm48_gmm_cause_names;
 gsm48_gsm_cause_names;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I785cef37dd272a2fab9b172f6e1392f865174e9a
Gerrit-PatchSet: 3
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list