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.orgReview at https://gerrit.osmocom.org/1814 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, 12 insertions(+), 10 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/14/1814/1 diff --git a/src/hlr.c b/src/hlr.c index 2fa27c3..275b99f 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -181,6 +181,15 @@ msg_out); } +static inline void fill_gsup_msg(struct osmo_gsup_message *out, + struct lu_operation *lu, + enum osmo_gsup_message_type mt) +{ + memset(out, 0, sizeof(struct osmo_gsup_message)); + 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 +199,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 +233,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); @@ -281,9 +285,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: newchange Gerrit-Change-Id: Icd6e2479aa111ff820d53711222d46c6522033e6 Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max <msuraev at sysmocom.de>