diff options
author | Max <msuraev@sysmocom.de> | 2016-06-27 15:51:34 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2016-06-29 16:33:25 +0000 |
commit | a337b9c37a9ff561b9c6a2e7c4b2a65dfa3b0e7f (patch) | |
tree | 73f753e7e00a9b795f63c83ea820be8a37da4ea6 /src/gsm | |
parent | ceae1237528f91f44e226225207ac70a2cf842ec (diff) |
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
Diffstat (limited to 'src/gsm')
-rw-r--r-- | src/gsm/gsm_04_08_gprs.c | 31 | ||||
-rw-r--r-- | src/gsm/libosmogsm.map | 1 |
2 files changed, 31 insertions, 1 deletions
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; |