mirror of https://gerrit.osmocom.org/libosmocore
gsm0808: Make a function to extract Cause IE publicly available.
Function gsm0808_get_cipher_reject_cause() was previously available in private gsm0808_utils.h. In practice, the exact same code is useful to extract Cause IE value from any of the many other BSSMAP messages which use it. So let's rename it to gsm0808_get_cause() and make it avilable to everyone to use. Change-Id: Idf2b99e9ef014eba26e3d4f0f38c2714d3a0520a
This commit is contained in:
parent
3c0a87ca4b
commit
fdfe25b105
|
@ -315,6 +315,10 @@ const char *gsm0808_bssap_name(uint8_t msg_type);
|
|||
const char *gsm0808_cause_name(enum gsm0808_cause cause);
|
||||
const char *gsm0808_cause_class_name(enum gsm0808_cause_class class);
|
||||
|
||||
/*! Parse Cause TLV 3GPP TS 08.08 §3.2.2.5
|
||||
* \returns Cause value */
|
||||
enum gsm0808_cause gsm0808_get_cause(const struct tlv_parsed *tp);
|
||||
|
||||
extern const struct value_string gsm0808_lcls_config_names[];
|
||||
extern const struct value_string gsm0808_lcls_control_names[];
|
||||
extern const struct value_string gsm0808_lcls_status_names[];
|
||||
|
|
|
@ -155,8 +155,6 @@ static inline bool gsm0808_cause_ext(enum gsm0808_cause cause)
|
|||
return (cause & 0x80) && !(cause & 0x0F);
|
||||
}
|
||||
|
||||
int gsm0808_get_cipher_reject_cause(const struct tlv_parsed *tp);
|
||||
|
||||
/*! \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)
|
||||
{
|
||||
|
|
|
@ -1654,6 +1654,22 @@ const char *gsm0808_cause_name(enum gsm0808_cause cause)
|
|||
return get_value_string(gsm0808_cause_names, cause);
|
||||
}
|
||||
|
||||
enum gsm0808_cause gsm0808_get_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];
|
||||
}
|
||||
|
||||
const struct value_string gsm0808_lcls_config_names[] = {
|
||||
{ GSM0808_LCLS_CFG_BOTH_WAY, "Connect both-way" },
|
||||
{ GSM0808_LCLS_CFG_BOTH_WAY_AND_BICAST_UL,
|
||||
|
|
|
@ -1563,22 +1563,6 @@ int gsm48_mr_cfg_from_gsm0808_sc_cfg(struct gsm48_multi_rate_conf *cfg,
|
|||
return 0;
|
||||
}
|
||||
|
||||
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().
|
||||
|
|
|
@ -157,6 +157,7 @@ gsm0808_bssap_name;
|
|||
gsm0808_bssmap_name;
|
||||
gsm0808_cause_name;
|
||||
gsm0808_cause_class_name;
|
||||
gsm0808_get_cause;
|
||||
gsm0808_create_ass;
|
||||
gsm0808_create_ass2;
|
||||
gsm0808_create_assignment_completed;
|
||||
|
|
|
@ -306,7 +306,7 @@ static inline void parse_cipher_reject(struct msgb *msg, uint8_t exp)
|
|||
if (rc < 0)
|
||||
printf("FIXME: failed (%d) to parse created message %s\n", rc, msgb_hexdump(msg));
|
||||
|
||||
rc = gsm0808_get_cipher_reject_cause(&tp);
|
||||
rc = gsm0808_get_cause(&tp);
|
||||
if (rc < 0)
|
||||
printf("FIXME: failed (%s) to extract Cause from created message %s\n",
|
||||
strerror(-rc), msgb_hexdump(msg));
|
||||
|
|
Loading…
Reference in New Issue