diff options
author | Alexander Chemeris <Alexander.Chemeris@gmail.com> | 2020-05-13 00:44:04 +0300 |
---|---|---|
committer | laforge <laforge@osmocom.org> | 2020-05-17 07:32:32 +0000 |
commit | 22630e68279525fd9684c8016f7443a8aba1f2a5 (patch) | |
tree | 649151c3e1e0af09c6514d2509fea03c1dc1c7e5 /src | |
parent | bfeeb1c86ce473ff3811513f02a307c969531c5f (diff) |
gsm0808: Implement helper functions for CONFUSION BSSMAP message decoding.
Also add a test for an actual CONFUSION message parsing.
Change-Id: If8afd2d096fb66c6c2f255a08fc1129de3d09cec
Diffstat (limited to 'src')
-rw-r--r-- | src/gsm/gsm0808.c | 38 | ||||
-rw-r--r-- | src/gsm/libosmogsm.map | 2 |
2 files changed, 40 insertions, 0 deletions
diff --git a/src/gsm/gsm0808.c b/src/gsm/gsm0808.c index 788f6c3c..23468c3e 100644 --- a/src/gsm/gsm0808.c +++ b/src/gsm/gsm0808.c @@ -21,6 +21,8 @@ * */ +#include <string.h> + #include <osmocom/core/byteswap.h> #include <osmocom/gsm/gsm0808.h> #include <osmocom/gsm/gsm0808_utils.h> @@ -34,6 +36,9 @@ * message generation/encoding. */ +/*! Char buffer to return strings from functions */ +static __thread char str_buff[512]; + /*! Create "Complete L3 Info" for AoIP, legacy implementation. * Instead use gsm0808_create_layer3_aoip2(), which is capable of three-digit MNC with leading zeros. * \param[in] msg_l3 msgb containing Layer 3 Message @@ -1670,6 +1675,39 @@ enum gsm0808_cause gsm0808_get_cause(const struct tlv_parsed *tp) return buf[0]; } +const char *gsm0808_diagnostics_octet_location_str(uint8_t pointer) +{ + switch (pointer) { + case 0: + return "Error location not determined"; + case 1: + return "The first octet of the message received (i.e. the message type) was found erroneous (unknown)"; + case 0xfd: + return "The first octet of the BSSAP header (Discrimination) was found erroneous"; + case 0xfe: + return "(DTAP only) The DLCI (second) octet of the BSSAP header was found erroneous"; + case 0xff: + return "The last octet of the BSSAP header (length indicator) was found erroneous"; + default: + snprintf(str_buff, sizeof(str_buff), "The %d octet of the message received was found erroneous", pointer); + return str_buff; + } +} + +const char *gsm0808_diagnostics_bit_location_str(uint8_t bit_pointer) +{ + if (bit_pointer == 0) { + return "No particular part of the octet is indicated"; + } else if (bit_pointer > 8) { + return "Reserved value"; + } + + snprintf(str_buff, sizeof(str_buff), + "An error was provoked by the field whose most significant bit is in bit position %d", + bit_pointer); + return str_buff; +} + const struct value_string gsm0808_lcls_config_names[] = { { GSM0808_LCLS_CFG_BOTH_WAY, "Connect both-way" }, { GSM0808_LCLS_CFG_BOTH_WAY_AND_BICAST_UL, diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map index ce557465..70b39163 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -159,6 +159,8 @@ gsm0808_bssmap_name; gsm0808_cause_name; gsm0808_cause_class_name; gsm0808_get_cause; +gsm0808_diagnostics_octet_location_str; +gsm0808_diagnostics_bit_location_str; gsm0808_create_ass; gsm0808_create_ass2; gsm0808_create_assignment_completed; |