From a337b9c37a9ff561b9c6a2e7c4b2a65dfa3b0e7f Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 27 Jun 2016 15:51:34 +0200 Subject: 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 --- src/gsm/gsm_04_08_gprs.c | 31 ++++++++++++++++++++++++++++++- src/gsm/libosmogsm.map | 1 + 2 files changed, 31 insertions(+), 1 deletion(-) (limited to 'src/gsm') 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 - +#include #include +#include + /* 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; -- cgit v1.2.3