summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/osmocom/gsm/gsm0808_utils.h3
-rw-r--r--src/gsm/gsm0808_utils.c40
-rw-r--r--src/gsm/gsm29205.c3
-rw-r--r--src/gsm/libosmogsm.map2
-rw-r--r--tests/gsm0808/gsm0808_test.c5
-rw-r--r--tests/gsm0808/gsm0808_test.ok4
6 files changed, 54 insertions, 3 deletions
diff --git a/include/osmocom/gsm/gsm0808_utils.h b/include/osmocom/gsm/gsm0808_utils.h
index e1e345d6..2b48be76 100644
--- a/include/osmocom/gsm/gsm0808_utils.h
+++ b/include/osmocom/gsm/gsm0808_utils.h
@@ -68,6 +68,9 @@ struct osmo_lcls {
bool corr_needed; /**< ยง3.2.2.118 Correlation-Not-Needed */
};
+char *osmo_lcls_dump(const struct osmo_lcls *lcls);
+char *osmo_gcr_dump(const struct osmo_lcls *lcls);
+
extern const struct value_string gsm0808_cell_id_discr_names[];
static inline const char *gsm0808_cell_id_discr_name(enum CELL_IDENT id_discr)
{ return get_value_string(gsm0808_cell_id_discr_names, id_discr); }
diff --git a/src/gsm/gsm0808_utils.c b/src/gsm/gsm0808_utils.c
index 54ec19c2..606899e8 100644
--- a/src/gsm/gsm0808_utils.c
+++ b/src/gsm/gsm0808_utils.c
@@ -28,6 +28,7 @@
#include <errno.h>
#include <osmocom/gsm/protocol/gsm_08_08.h>
#include <osmocom/gsm/gsm48.h>
+#include <osmocom/gsm/gsm0808.h>
#include <osmocom/gsm/gsm0808_utils.h>
#define IP_V4_ADDR_LEN 4
@@ -591,6 +592,45 @@ int gsm0808_dec_lcls(struct osmo_lcls *lcls, const struct tlv_parsed *tp)
return ret;
}
+static char dbuf[256];
+
+/*! Dump LCLS parameters (GCR excluded) into string for printing.
+ * \param[in] lcls pointer to the struct to print.
+ * \returns string representation of LCLS or NULL on error. */
+char *osmo_lcls_dump(const struct osmo_lcls *lcls)
+{
+ struct osmo_strbuf s = { .buf = dbuf, .len = 256 };
+
+ if (!lcls)
+ return NULL;
+
+ OSMO_STRBUF_PRINTF(s, "LCLS Config: %s, Control: %s, Correlation-Needed: %u",
+ gsm0808_lcls_config_name(lcls->config),
+ gsm0808_lcls_control_name(lcls->control),
+ lcls->corr_needed);
+
+ return dbuf;
+}
+
+/*! Dump GCR struct into string for printing.
+ * \param[in] lcls pointer to the struct to print.
+ * \returns string representation of GCR or NULL on error. */
+char *osmo_gcr_dump(const struct osmo_lcls *lcls)
+{
+ struct osmo_strbuf s = { .buf = dbuf, .len = 256 };
+
+ if (!lcls)
+ return NULL;
+
+ if (lcls->gcr_available) {
+ OSMO_STRBUF_PRINTF(s, "GCR NetID 0x%s, ", osmo_hexdump_nospc(lcls->gcr.net, lcls->gcr.net_len));
+ /* osmo_hexdump() uses static buffers so we can't call it twice withing the same parameter list */
+ OSMO_STRBUF_PRINTF(s, "Node 0x%x, CallRefID 0x%s", lcls->gcr.node, osmo_hexdump_nospc(lcls->gcr.cr, 5));
+ }
+
+ return dbuf;
+}
+
/*! Encode TS 08.08 Encryption Information IE
* \param[out] msg Message Buffer to which IE is to be appended
* \param[in] ei Encryption Information to be encoded
diff --git a/src/gsm/gsm29205.c b/src/gsm/gsm29205.c
index 0d344688..6ceb8ee4 100644
--- a/src/gsm/gsm29205.c
+++ b/src/gsm/gsm29205.c
@@ -20,9 +20,12 @@
*
*/
+#include "config.h"
+
#include <osmocom/gsm/protocol/gsm_08_08.h>
#include <osmocom/gsm/gsm29205.h>
#include <osmocom/gsm/gsm0808.h>
+#include <osmocom/core/utils.h>
#include <osmocom/core/msgb.h>
#include <osmocom/gsm/tlv.h>
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index 48757a7b..2d47d7a7 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -247,6 +247,8 @@ gsm29118_create_service_abort_req;
osmo_enc_gcr;
osmo_dec_gcr;
osmo_gcr_eq;
+osmo_gcr_dump;
+osmo_lcls_dump;
gsm0858_rsl_ul_meas_enc;
diff --git a/tests/gsm0808/gsm0808_test.c b/tests/gsm0808/gsm0808_test.c
index 65fef53a..af90d00c 100644
--- a/tests/gsm0808/gsm0808_test.c
+++ b/tests/gsm0808/gsm0808_test.c
@@ -760,11 +760,12 @@ static void test_enc_dec_lcls()
}
if (!osmo_gcr_eq(&lcls_out->gcr, &lcls_in.gcr)) {
- printf("GCR parsed wrong.\n");
+ printf("GCR parsed wrong:\n\t%s\n\t%s\n", osmo_gcr_dump(lcls_out), osmo_gcr_dump(&lcls_in));
abort();
}
- printf("\tdecoded %d bytes: %s\n", rc, rc == len ? "OK" : "FAIL");
+ printf("\tdecoded %d bytes: %s:\n%s\n", rc, rc == len ? "OK" : "FAIL", osmo_lcls_dump(lcls_out));
+ printf("\t%s\n", osmo_gcr_dump(lcls_out));
msgb_free(msg);
}
diff --git a/tests/gsm0808/gsm0808_test.ok b/tests/gsm0808/gsm0808_test.ok
index 7819e7a6..e7df007a 100644
--- a/tests/gsm0808/gsm0808_test.ok
+++ b/tests/gsm0808/gsm0808_test.ok
@@ -27,7 +27,9 @@ Testing creating DTAP
Testing prepend DTAP
Testing Global Call Reference IE encoder...
15 bytes added: OK
- decoded 15 bytes: OK
+ decoded 15 bytes: OK:
+LCLS Config: Not available, Control: Not available, Correlation-Needed: 1
+ GCR NetID 0xf1f2f3, Node 0xdead, CallRefID 0x4142434445
test_gsm0808_enc_dec_cell_id_list_lac: encoded: 1a 07 05 01 24 ab cd 56 78 (rc = 9)
------- test_cell_id_list_add
cell_id_list == CGI[0]:{}