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/12491 Change subject: LCLS: add allocator function ...................................................................... LCLS: add allocator function Change-Id: If67cf93ae3dd449e96156485fe1baaf013df3f77 --- M include/osmocom/gsm/gsm0808_utils.h M src/gsm/gsm0808_utils.c M src/gsm/libosmogsm.map M tests/gsm0808/gsm0808_test.c 4 files changed, 32 insertions(+), 11 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/91/12491/1 diff --git a/include/osmocom/gsm/gsm0808_utils.h b/include/osmocom/gsm/gsm0808_utils.h index 4a2233e..2d86a7d 100644 --- a/include/osmocom/gsm/gsm0808_utils.h +++ b/include/osmocom/gsm/gsm0808_utils.h @@ -67,6 +67,8 @@ bool corr_needed; /**< §3.2.2.118 Correlation-Not-Needed */ }; +struct osmo_lcls *osmo_lcls_alloc(void *ctx); + 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 2a458c3..90388fa 100644 --- a/src/gsm/gsm0808_utils.c +++ b/src/gsm/gsm0808_utils.c @@ -575,6 +575,22 @@ return enc; } +/*! Dynamically allocate LCLS parameters struct. + * \param[in] ctx context pointer to hang the result off + * \returns osmo_lcls pointer or NULL on error */ +struct osmo_lcls *osmo_lcls_alloc(void *ctx) +{ + struct osmo_lcls *r = talloc_zero(ctx, struct osmo_lcls); + if (!r) + return NULL; + + r->gcr = talloc_zero(r, struct osmo_gcr_parsed); + if (!r->gcr) + return NULL; + + return r; +} + /*! Decode LCLS parameters to a given msgb, 3GPP TS 48.008 §3.2.2.115 - 3.2.2.120. * \param[out] lcls Caller-provided memory to store LCLS-related data * \param[in] tp IE values to be decoded diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map index bb97878..6b5f0ae 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -38,6 +38,7 @@ abis_nm_get_sw_conf; abis_nm_get_sw_desc_len; +osmo_lcls_alloc; osmo_sitype_strs; osmo_c4; osmo_get_rand_id; diff --git a/tests/gsm0808/gsm0808_test.c b/tests/gsm0808/gsm0808_test.c index 40e2b87..cb0df88 100644 --- a/tests/gsm0808/gsm0808_test.c +++ b/tests/gsm0808/gsm0808_test.c @@ -682,7 +682,7 @@ }; uint8_t len; struct msgb *msg; - struct osmo_gcr_parsed p = { 0 }, g = { + struct osmo_gcr_parsed g = { .net_len = 3, .net = { 0xf1, 0xf2, 0xf3 }, .node = 0xDEAD, @@ -690,7 +690,7 @@ }; int rc; struct tlv_parsed tp; - struct osmo_lcls lcls_out = { .gcr = &p }, lcls_in = { + struct osmo_lcls *lcls_out, lcls_in = { .gcr = &g, .config = GSM0808_LCLS_CFG_NA, .control = GSM0808_LCLS_CSC_NA, @@ -701,6 +701,8 @@ if (!msg) return; + lcls_out = osmo_lcls_alloc(msg); + len = gsm0808_enc_lcls(msg, &lcls_in); printf("Testing Global Call Reference IE encoder...\n\t%d bytes added: %s\n", len, len == ARRAY_SIZE(res) ? "OK" : "FAIL"); @@ -714,29 +716,29 @@ abort(); } - rc = gsm0808_dec_lcls(&lcls_out, &tp); + rc = gsm0808_dec_lcls(lcls_out, &tp); if (rc < 0) { printf("decoding failed: %s [%s]\n", strerror(-rc), msgb_hexdump(msg)); abort(); } - if (lcls_out.gcr->net_len != g.net_len) { - printf("Network ID length parsed wrong: %u != %u\n", lcls_out.gcr->net_len, g.net_len); + if (lcls_out->gcr->net_len != g.net_len) { + printf("Network ID length parsed wrong: %u != %u\n", lcls_out->gcr->net_len, g.net_len); abort(); } - if (lcls_out.gcr->node != g.node) { - printf("Node ID parsed wrong: 0x%X != 0x%X\n", lcls_out.gcr->node, g.node); + if (lcls_out->gcr->node != g.node) { + printf("Node ID parsed wrong: 0x%X != 0x%X\n", lcls_out->gcr->node, g.node); abort(); } - if (memcmp(lcls_out.gcr->net, g.net, g.net_len) != 0) { - printf("Network ID parsed wrong: %s\n", osmo_hexdump(lcls_out.gcr->net, lcls_out.gcr->net_len)); + if (memcmp(lcls_out->gcr->net, g.net, g.net_len) != 0) { + printf("Network ID parsed wrong: %s\n", osmo_hexdump(lcls_out->gcr->net, lcls_out->gcr->net_len)); abort(); } - if (memcmp(lcls_out.gcr->cr, g.cr, 5) != 0) { - printf("Call ref. ID parsed wrong: %s\n", osmo_hexdump(lcls_out.gcr->cr, 5)); + if (memcmp(lcls_out->gcr->cr, g.cr, 5) != 0) { + printf("Call ref. ID parsed wrong: %s\n", osmo_hexdump(lcls_out->gcr->cr, 5)); abort(); } -- To view, visit https://gerrit.osmocom.org/12491 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: If67cf93ae3dd449e96156485fe1baaf013df3f77 Gerrit-Change-Number: 12491 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/bf2dab55/attachment.htm>