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.orgHello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1814 to look at the new patch set (#2). Move GSUP msg init into separate function * move common copy-pasted code to initialize GSUP message into static function * use osmo_strlcpy() to copy imsi for added safety Change-Id: Icd6e2479aa111ff820d53711222d46c6522033e6 --- M src/hlr.c 1 file changed, 15 insertions(+), 12 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/14/1814/2 diff --git a/src/hlr.c b/src/hlr.c index 2fa27c3..206ddc1 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -181,6 +181,17 @@ msg_out); } +static inline void fill_gsup_msg(struct osmo_gsup_message *out, + const struct lu_operation *lu, + enum osmo_gsup_message_type mt) +{ + memset(out, 0, sizeof(struct osmo_gsup_message)); + if (lu) + osmo_strlcpy(out->imsi, lu->subscr.imsi, + GSM23003_IMSI_MAX_DIGITS + 1); + out->message_type = mt; +} + /*! Transmit UPD_LOC_ERROR and destroy lu_operation */ void lu_op_tx_error(struct lu_operation *luop, enum gsm48_gmm_cause cause) { @@ -190,10 +201,7 @@ luop->subscr.imsi, get_value_string(gsm48_gmm_cause_names, cause)); - memset(&gsup, 0, sizeof(gsup)); - gsup.message_type = OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR; - strncpy((char*)&gsup.imsi, luop->subscr.imsi, sizeof(gsup.imsi)); - gsup.imsi[sizeof(gsup.imsi)-1] = '\0'; + fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR); gsup.cause = cause; _luop_tx_gsup(luop, &gsup); @@ -227,9 +235,7 @@ { struct osmo_gsup_message gsup; - memset(&gsup, 0, sizeof(gsup)); - gsup.message_type = OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT; - strncpy(gsup.imsi, luop->subscr.imsi, sizeof(gsup.imsi)-1); + fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT); //FIXME gsup.hlr_enc; _luop_tx_gsup(luop, &gsup); @@ -245,8 +251,7 @@ OSMO_ASSERT(luop->state == LU_S_LU_RECEIVED); - memset(&gsup, 0, sizeof(gsup)); - gsup.message_type = OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST; + fill_gsup_msg(&gsup, NULL, OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST); //gsup.cause = FIXME; //gsup.cancel_type = FIXME; @@ -281,9 +286,7 @@ OSMO_ASSERT(luop->state == LU_S_LU_RECEIVED || luop->state == LU_S_CANCEL_ACK_RECEIVED); - memset(&gsup, 0, sizeof(gsup)); - gsup.message_type = OSMO_GSUP_MSGT_INSERT_DATA_REQUEST; - strncpy(gsup.imsi, luop->subscr.imsi, sizeof(gsup.imsi)-1); + fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_INSERT_DATA_REQUEST); l = gsm48_encode_bcd_number(msisdn_enc, sizeof(msisdn_enc), 0, luop->subscr.msisdn); -- To view, visit https://gerrit.osmocom.org/1814 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Icd6e2479aa111ff820d53711222d46c6522033e6 Gerrit-PatchSet: 2 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max <msuraev at sysmocom.de> Gerrit-Reviewer: Jenkins Builder