Review at  https://gerrit.osmocom.org/5098

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
---
M src/host/layer23/include/osmocom/bb/mobile/gsm411_sms.h
M src/host/layer23/src/mobile/gsm411_sms.c
2 files changed, 10 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/98/5098/1

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 0d0578a..a94d1aa 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 @@
        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 f09d7a1..eb09854 100644
--- a/src/host/layer23/src/mobile/gsm411_sms.c
+++ b/src/host/layer23/src/mobile/gsm411_sms.c
@@ -232,6 +232,7 @@
        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 @@
        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 @@
 
 /* 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 @@
 
        /* 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 @@
 
 /* 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 @@
        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 @@
        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);
 }
 
 /*

-- 
To view, visit https://gerrit.osmocom.org/5098
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9b0f90f875de5f072565878861d38b0bb3bfbded
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Holger Freyther <[email protected]>

Reply via email to