From ed651d2485a51b57bf6090f4f58fd356118c6835 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 7 Nov 2018 15:25:05 +0100 Subject: Support cipher mode reject with extended cause * add function to generate cipher mode reject with extended (2-byte) Cause IE * add function to get (extended) Cause value * add corresponding (extended cause) test * update existing (non-extended cause) test * use enum as a parameter for existing non-extended version to make interface more unified Change-Id: Id5509b94a18180a44f45300caaa02b843c166fa3 Related: OS#3187 --- src/gsm/gsm0808_utils.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/gsm/gsm0808_utils.c') diff --git a/src/gsm/gsm0808_utils.c b/src/gsm/gsm0808_utils.c index 2348105d..c58d8284 100644 --- a/src/gsm/gsm0808_utils.c +++ b/src/gsm/gsm0808_utils.c @@ -1235,6 +1235,22 @@ void gsm48_mr_cfg_from_gsm0808_sc_cfg(struct gsm48_multi_rate_conf *cfg, cfg->icmi = 1; } +int gsm0808_get_cipher_reject_cause(const struct tlv_parsed *tp) +{ + const uint8_t *buf = TLVP_VAL_MINLEN(tp, GSM0808_IE_CAUSE, 1); + + if (!buf) + return -EBADMSG; + + if (TLVP_LEN(tp, GSM0808_IE_CAUSE) > 1) { + if (!gsm0808_cause_ext(buf[0])) + return -EINVAL; + return buf[1]; + } + + return buf[0]; +} + /*! Print a human readable name of the cell identifier to the char buffer. * This is useful both for struct gsm0808_cell_id and struct gsm0808_cell_id_list2. * See also gsm0808_cell_id_name() and gsm0808_cell_id_list_name(). -- cgit v1.2.3