From ff43e1a1b306ea63f7b375bf0ab2773df7d144ba Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Wed, 29 Nov 2017 16:29:08 +0800 Subject: 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 --- src/host/layer23/include/osmocom/bb/mobile/gsm411_sms.h | 1 + src/host/layer23/src/mobile/gsm411_sms.c | 16 +++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/host/layer23/include/osmocom/bb/mobile/gsm411_sms.h b/src/host/layer23/include/osmocom/bb/mobile/gsm411_sms.h index 0d0578a3..a94d1aa7 100644 --- a/src/host/layer23/include/osmocom/bb/mobile/gsm411_sms.h +++ b/src/host/layer23/include/osmocom/bb/mobile/gsm411_sms.h @@ -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; diff --git a/src/host/layer23/src/mobile/gsm411_sms.c b/src/host/layer23/src/mobile/gsm411_sms.c index f09d7a13..eb09854b 100644 --- a/src/host/layer23/src/mobile/gsm411_sms.c +++ b/src/host/layer23/src/mobile/gsm411_sms.c @@ -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); } /* -- cgit v1.2.3