pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/39984?usp=email )
Change subject: Add function helper hnbgw_decode_ranap_ran_co() ...................................................................... Add function helper hnbgw_decode_ranap_ran_co() Similar to already existing counterpart hnbgw_decode_ranap_cn_co(). This helps simplifying logic into smaller chunks, and will make both UL and DL look more similar. Change-Id: Ifbb058d5340a6cb3a1703415e49c0de04fa6aec1 --- M src/osmo-hnbgw/context_map_sccp.c 1 file changed, 22 insertions(+), 5 deletions(-) Approvals: pespin: Looks good to me, approved Jenkins Builder: Verified laforge: Looks good to me, but someone else must approve osmith: Looks good to me, but someone else must approve diff --git a/src/osmo-hnbgw/context_map_sccp.c b/src/osmo-hnbgw/context_map_sccp.c index c933e8d..fc82426 100644 --- a/src/osmo-hnbgw/context_map_sccp.c +++ b/src/osmo-hnbgw/context_map_sccp.c @@ -193,10 +193,29 @@ return 0; } +/* Decode DL RANAP message with convenient memory freeing: just talloc_free() the returned pointer.. + * Allocate a ranap_message from OTC_SELECT, decode RANAP msgb into it, attach a talloc destructor that calls + * ranap_cn_rx_co_free() upon talloc_free(), and return the decoded ranap_message. */ +static ranap_message *hnbgw_decode_ranap_ran_co(struct msgb *ranap_msg) +{ + int rc; + ranap_message *message; + + if (!msg_has_l2_data(ranap_msg)) + return NULL; + message = talloc_zero(OTC_SELECT, ranap_message); + rc = ranap_ran_rx_co_decode(NULL, message, msgb_l2(ranap_msg), msgb_l2len(ranap_msg)); + if (rc != 0) { + talloc_free(message); + return NULL; + } + talloc_set_destructor(message, destruct_ranap_ran_rx_co_ies); + return message; +} + static int handle_rx_sccp(struct osmo_fsm_inst *fi, struct msgb *ranap_msg) { struct hnbgw_context_map *map = fi->priv; - int rc; /* If the FSM instance has already terminated, don't dispatch anything. */ if (fi->proc.terminating) @@ -208,10 +227,8 @@ /* See if it is a RAB Assignment Request message from SCCP to RUA, where we need to change the user plane * information, for RTP mapping via MGW, or GTP mapping via UPF. */ - ranap_message *message; - message = talloc_zero(OTC_SELECT, ranap_message); - rc = ranap_ran_rx_co_decode(message, message, msgb_l2(ranap_msg), msgb_l2len(ranap_msg)); - if (rc == 0) { + ranap_message *message = hnbgw_decode_ranap_ran_co(ranap_msg); + if (message) { talloc_set_destructor(message, destruct_ranap_ran_rx_co_ies); LOGPFSML(fi, LOGL_DEBUG, "rx from SCCP: RANAP %s\n", -- To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/39984?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: osmo-hnbgw Gerrit-Branch: master Gerrit-Change-Id: Ifbb058d5340a6cb3a1703415e49c0de04fa6aec1 Gerrit-Change-Number: 39984 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pes...@sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <lafo...@osmocom.org> Gerrit-Reviewer: osmith <osm...@sysmocom.de> Gerrit-Reviewer: pespin <pes...@sysmocom.de>