summaryrefslogtreecommitdiffstats
path: root/include/osmocom/gsm
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2018-11-07 13:16:54 +0100
committerHarald Welte <laforge@gnumonks.org>2018-11-18 20:14:06 +0000
commitaa934630530af05a84b62b204ce4da7688c5e3ad (patch)
tree34eb73668b997ca14a5d81b286a6b6d23cda6e0c /include/osmocom/gsm
parentc0d1de36f3e378364b1c02e98a3870394e3d457e (diff)
Update 3GPP TS 08.08 Cause handling
* add Class definitions * add helper to check for extended bit * add helper to get Cause's Class * use enum in gsm0808_cause_name() and gsm0808_create_cipher_reject() to avoid confusion between class and cause * update gsm0808_create_cipher_reject() comments Change-Id: I31b31dfc22eb4b6b07089e1255246ac458125340 Related: OS#3187
Diffstat (limited to 'include/osmocom/gsm')
-rw-r--r--include/osmocom/gsm/gsm0808.h5
-rw-r--r--include/osmocom/gsm/gsm0808_utils.h15
-rw-r--r--include/osmocom/gsm/protocol/gsm_08_08.h12
3 files changed, 29 insertions, 3 deletions
diff --git a/include/osmocom/gsm/gsm0808.h b/include/osmocom/gsm/gsm0808.h
index 652aae99..66f7c277 100644
--- a/include/osmocom/gsm/gsm0808.h
+++ b/include/osmocom/gsm/gsm0808.h
@@ -50,7 +50,7 @@ struct msgb *gsm0808_create_clear_complete(void);
struct msgb *gsm0808_create_cipher(const struct gsm0808_encrypt_info *ei,
const uint8_t *cipher_response_mode);
struct msgb *gsm0808_create_cipher_complete(struct msgb *layer3, uint8_t alg_id);
-struct msgb *gsm0808_create_cipher_reject(uint8_t cause);
+struct msgb *gsm0808_create_cipher_reject(enum gsm0808_cause cause);
struct msgb *gsm0808_create_classmark_request();
struct msgb *gsm0808_create_classmark_update(const uint8_t *cm2, uint8_t cm2_len,
const uint8_t *cm3, uint8_t cm3_len);
@@ -178,7 +178,8 @@ const struct tlv_definition *gsm0808_att_tlvdef(void);
const char *gsm0808_bssmap_name(uint8_t msg_type);
const char *gsm0808_bssap_name(uint8_t msg_type);
-const char *gsm0808_cause_name(uint8_t cause);
+const char *gsm0808_cause_name(enum gsm0808_cause cause);
+const char *gsm0808_cause_class_name(enum gsm0808_cause_class class);
extern const struct value_string gsm0808_lcls_config_names[];
extern const struct value_string gsm0808_lcls_control_names[];
diff --git a/include/osmocom/gsm/gsm0808_utils.h b/include/osmocom/gsm/gsm0808_utils.h
index f70dbdb6..b56e2635 100644
--- a/include/osmocom/gsm/gsm0808_utils.h
+++ b/include/osmocom/gsm/gsm0808_utils.h
@@ -107,7 +107,20 @@ int gsm0808_speech_codec_from_chan_type(struct gsm0808_speech_codec *sc,
uint16_t gsm0808_sc_cfg_from_gsm48_mr_cfg(const struct gsm48_multi_rate_conf *cfg, bool fr);
void gsm48_mr_cfg_from_gsm0808_sc_cfg(struct gsm48_multi_rate_conf *cfg, uint16_t s15_s0);
-/*! Return 3GPP TS 48.008 3.2.2.49 Current Channel Type 1 from enum gsm_chan_t. */
+/*! \returns 3GPP TS 08.08 §3.2.2.5 Class of a given Cause */
+static inline enum gsm0808_cause_class gsm0808_cause_class(enum gsm0808_cause cause)
+{
+ return (cause << 1) >> 4;
+}
+
+/*! \returns true if 3GPP TS 08.08 §3.2.2.5 Class has extended bit set */
+static inline bool gsm0808_cause_ext(enum gsm0808_cause cause)
+{
+ /* check that cause looks like 1XXX0000 where XXX represent class */
+ return (cause & 0x80) && !(cause & 0x0F);
+}
+
+/*! \returns 3GPP TS 48.008 3.2.2.49 Current Channel Type 1 from enum gsm_chan_t. */
static inline uint8_t gsm0808_current_channel_type_1(enum gsm_chan_t type)
{
switch (type) {
diff --git a/include/osmocom/gsm/protocol/gsm_08_08.h b/include/osmocom/gsm/protocol/gsm_08_08.h
index 8431ace5..2317e784 100644
--- a/include/osmocom/gsm/protocol/gsm_08_08.h
+++ b/include/osmocom/gsm/protocol/gsm_08_08.h
@@ -384,6 +384,18 @@ enum gsm0808_cause {
GSM0808_CAUSE_DTM_HO_TIMER_EXPIRY = 0x62,
};
+/* 3GPP TS 08.08 §3.2.2.5 Cause Class */
+enum gsm0808_cause_class {
+ GSM0808_CAUSE_CLASS_NORM0 = 0,
+ GSM0808_CAUSE_CLASS_NORM1 = 1,
+ GSM0808_CAUSE_CLASS_RES_UNAVAIL = 2,
+ GSM0808_CAUSE_CLASS_SRV_OPT_NA = 3,
+ GSM0808_CAUSE_CLASS_SRV_OPT_NIMPL = 4,
+ GSM0808_CAUSE_CLASS_INVAL = 5,
+ GSM0808_CAUSE_CLASS_PERR = 6,
+ GSM0808_CAUSE_CLASS_INTW = 7,
+};
+
/* GSM 08.08 3.2.2.11 Channel Type */
enum gsm0808_chan_indicator {
GSM0808_CHAN_SPEECH = 1,