This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Max gerrit-no-reply at lists.osmocom.orgMax has uploaded this change for review. ( https://gerrit.osmocom.org/12492 Change subject: LCLS: add string dump helper ...................................................................... LCLS: add string dump helper Change-Id: Ic3609224c8f3282d667e75f68bc20327e36eb9e6 --- M include/osmocom/gsm/gsm0808_utils.h M include/osmocom/gsm/gsm29205.h M src/gsm/gsm0808_utils.c M src/gsm/gsm29205.c M src/gsm/libosmogsm.map M tests/gsm0808/gsm0808_test.c M tests/gsm0808/gsm0808_test.ok 7 files changed, 37 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/92/12492/1 diff --git a/include/osmocom/gsm/gsm0808_utils.h b/include/osmocom/gsm/gsm0808_utils.h index 4a2233e..c8924f2 100644 --- a/include/osmocom/gsm/gsm0808_utils.h +++ b/include/osmocom/gsm/gsm0808_utils.h @@ -241,5 +241,6 @@ } const char *gsm0808_channel_type_name(const struct gsm0808_channel_type *ct); +char *osmo_lcls_dump(const struct osmo_lcls *lcls, bool print_gcr); /*! @} */ diff --git a/include/osmocom/gsm/gsm29205.h b/include/osmocom/gsm/gsm29205.h index 0c3c153..3c47edf 100644 --- a/include/osmocom/gsm/gsm29205.h +++ b/include/osmocom/gsm/gsm29205.h @@ -39,3 +39,4 @@ uint8_t osmo_enc_gcr(struct msgb *msg, const struct osmo_gcr_parsed *g); int osmo_dec_gcr(struct osmo_gcr_parsed *gcr, const uint8_t *elem, uint8_t len); +char *osmo_gcr_dump(const struct osmo_gcr_parsed *gcr); diff --git a/src/gsm/gsm0808_utils.c b/src/gsm/gsm0808_utils.c index 2a458c3..272695c 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 @@ -592,6 +593,21 @@ return ret; } +/*! Dump LCLS parameters struct 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, bool print_gcr) +{ + char *s = talloc_asprintf(lcls, "LCLS Config: %s, Control: %s, Correlation-Needed: %u", + gsm0808_lcls_config_name(lcls->config), + gsm0808_lcls_control_name(lcls->control), + lcls->corr_needed); + if (s && print_gcr) + return talloc_asprintf_append(s, ", %s", osmo_gcr_dump(lcls->gcr)); + + return s; +} + /*! 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 0ef29b7..c764c93 100644 --- a/src/gsm/gsm29205.c +++ b/src/gsm/gsm29205.c @@ -91,3 +91,15 @@ return parsed + 5; } + +/*! Dump GCR struct into string for printing. + * \param[in] gcr pointer to the struct to print + * \returns string representation of GCR or NULL on error */ +char *osmo_gcr_dump(const struct osmo_gcr_parsed *gcr) +{ + char *s = talloc_asprintf(gcr, "GCR NetID 0x%s, ", osmo_hexdump_nospc(gcr->net, gcr->net_len)); + if (!s) + return NULL; + /* osmo_hexdump() uses static buffers so we can't call it twice withing the same parameter list */ + return talloc_asprintf_append(s, "Node 0x%x, CallRefID 0x%s", gcr->node, osmo_hexdump_nospc(gcr->cr, 5)); +} diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map index bb97878..fd21f30 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -240,6 +240,8 @@ osmo_enc_gcr; osmo_dec_gcr; +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 40e2b87..72b501c 100644 --- a/tests/gsm0808/gsm0808_test.c +++ b/tests/gsm0808/gsm0808_test.c @@ -740,7 +740,8 @@ 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, false)); + printf("\t%s\n", osmo_gcr_dump(lcls_out->gcr)); msgb_free(msg); } diff --git a/tests/gsm0808/gsm0808_test.ok b/tests/gsm0808/gsm0808_test.ok index 8e6d262..806e625 100644 --- a/tests/gsm0808/gsm0808_test.ok +++ b/tests/gsm0808/gsm0808_test.ok @@ -25,7 +25,9 @@ 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]:{} -- To view, visit https://gerrit.osmocom.org/12492 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-MessageType: newchange Gerrit-Change-Id: Ic3609224c8f3282d667e75f68bc20327e36eb9e6 Gerrit-Change-Number: 12492 Gerrit-PatchSet: 1 Gerrit-Owner: Max <msuraev at sysmocom.de> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190109/9c5354a6/attachment.htm>