diff options
-rw-r--r-- | include/osmocom/gsm/protocol/gsm_04_08_gprs.h | 5 | ||||
-rw-r--r-- | src/gsm/gsm_04_08_gprs.c | 31 | ||||
-rw-r--r-- | src/gsm/libosmogsm.map | 1 |
3 files changed, 36 insertions, 1 deletions
diff --git a/include/osmocom/gsm/protocol/gsm_04_08_gprs.h b/include/osmocom/gsm/protocol/gsm_04_08_gprs.h index e0e887fa..ed9a596a 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 @@ enum gsm48_qos_sdu_err { 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 5c00ea00..7018777b 100644 --- a/src/gsm/gsm_04_08_gprs.c +++ b/src/gsm/gsm_04_08_gprs.c @@ -21,9 +21,11 @@ #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 */ /* 10.5.5.14 GPRS MM Cause / Table 10.5.147 */ @@ -108,6 +110,33 @@ const struct value_string gsm48_gsm_cause_names_[] = { 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 ebeabcdc..96f615e3 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -44,6 +44,7 @@ gprs_cipher_supported; gprs_cipher_key_length; gprs_tlli_type; gprs_tmsi2tlli; +gprs_ms_net_cap_gea_supported; gsm48_gmm_cause_names; gsm48_gsm_cause_names; |