mobile: Re-introduce msg_ref in struct gsm_sms

In I4bac5f06921b5fd85a98d97770d42d4858ca1c42 I have removed the
msg_ref field. But in case we delete a transaction with a pending
SMS we need to get the msg_ref from somewhere. This is a partial
revert but for RX SMS it makes sure that msg_ref will be set (it
wasn't set before).

Change-Id: I9b0f90f875de5f072565878861d38b0bb3bfbded
This commit is contained in:
Holger Hans Peter Freyther 2017-11-29 16:29:08 +08:00
parent d27d4354c3
commit ff43e1a1b3
2 changed files with 10 additions and 7 deletions

View File

@ -11,6 +11,7 @@ struct gsm_sms {
uint8_t ud_hdr_ind;
uint8_t protocol_id;
uint8_t data_coding_scheme;
uint8_t msg_ref;
char address[20+1]; /* DA LV is 12 bytes max, i.e. 10 bytes
* BCD == 20 bytes string */
time_t time;

View File

@ -232,6 +232,7 @@ static int gsm340_rx_tpdu(struct gsm_trans *trans, struct msgb *msg, uint8_t msg
int rc = 0;
gsms = sms_alloc();
gsms->msg_ref = msg_ref;
/* invert those fields where 0 means active/present */
sms_mti = *smsp & 0x03;
@ -296,7 +297,7 @@ static int gsm340_rx_tpdu(struct gsm_trans *trans, struct msgb *msg, uint8_t msg
LOGP(DLSMS, LOGL_INFO, "RX SMS: MTI: 0x%02x, "
"MR: 0x%02x PID: 0x%02x, DCS: 0x%02x, OA: %s, "
"UserDataLength: 0x%02x, UserData: \"%s\"\n",
sms_mti, msg_ref,
sms_mti, gsms->msg_ref,
gsms->protocol_id, gsms->data_coding_scheme, gsms->address,
gsms->user_data_len,
sms_alphabet == DCS_7BIT_DEFAULT ? gsms->text :
@ -528,7 +529,7 @@ static int gsm411_rx_rl_report(struct msgb *msg, struct gsm48_hdr *gh,
/* generate a msgb containing a TPDU derived from struct gsm_sms,
* returns total size of TPDU */
static int gsm340_gen_tpdu(struct msgb *msg, struct gsm_sms *sms, uint8_t msg_ref)
static int gsm340_gen_tpdu(struct msgb *msg, struct gsm_sms *sms)
{
uint8_t *smsp;
uint8_t da[12]; /* max len per 03.40 */
@ -559,7 +560,7 @@ static int gsm340_gen_tpdu(struct msgb *msg, struct gsm_sms *sms, uint8_t msg_re
/* generate message ref */
smsp = msgb_put(msg, 1);
*smsp = msg_ref;
*smsp = sms->msg_ref;
/* generate destination address */
if (sms->address[0] == '+')
@ -620,7 +621,7 @@ static int gsm340_gen_tpdu(struct msgb *msg, struct gsm_sms *sms, uint8_t msg_re
/* Take a SMS in gsm_sms structure and send it. */
static int gsm411_tx_sms_submit(struct osmocom_ms *ms, const char *sms_sca,
struct gsm_sms *sms, uint8_t msg_ref)
struct gsm_sms *sms)
{
struct msgb *msg;
struct gsm_trans *trans;
@ -688,14 +689,14 @@ error:
rp_ud_len = (uint8_t *)msgb_put(msg, 1);
/* generate the 03.40 TPDU */
rc = gsm340_gen_tpdu(msg, sms, msg_ref);
rc = gsm340_gen_tpdu(msg, sms);
if (rc < 0)
goto error;
*rp_ud_len = rc;
LOGP(DLSMS, LOGL_INFO, "TX: SMS DELIVER\n");
gsm411_push_rp_header(msg, GSM411_MT_RP_DATA_MO, msg_ref);
gsm411_push_rp_header(msg, GSM411_MT_RP_DATA_MO, sms->msg_ref);
return gsm411_smr_send(&trans->sms.smr_inst, GSM411_SM_RL_DATA_REQ,
msg);
}
@ -709,7 +710,8 @@ int sms_send(struct osmocom_ms *ms, const char *sms_sca, const char *number,
if (!sms)
return -ENOMEM;
return gsm411_tx_sms_submit(ms, sms_sca, sms, msg_ref);
sms->msg_ref = msg_ref;
return gsm411_tx_sms_submit(ms, sms_sca, sms);
}
/*