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

libmsc: remove 'deferred' parameter in sms_route_mt_sms()

No need to cache the sms object, just cache what we need into the
smpp_cmd structure. This simplifies what that I introduced in
93ffbd0029d1 ("libmsc: send RP-ACK to MS after ESME sends SMPP
DELIVER-SM-RESP").

Change-Id: Iba5f864f9bb963baff95969e306b1b7cff00c1e3
---
M openbsc/src/libmsc/gsm_04_11.c
M openbsc/src/libmsc/smpp_openbsc.c
M openbsc/src/libmsc/smpp_smsc.h
3 files changed, 24 insertions(+), 30 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/26/3426/1

diff --git a/openbsc/src/libmsc/gsm_04_11.c b/openbsc/src/libmsc/gsm_04_11.c
index 7df5e64..d60de08 100644
--- a/openbsc/src/libmsc/gsm_04_11.c
+++ b/openbsc/src/libmsc/gsm_04_11.c
@@ -278,8 +278,7 @@
 }
 
 static int sms_route_mt_sms(struct gsm_subscriber_connection *conn,
-                           struct gsm_sms *gsms, uint8_t sms_mti,
-                           bool *deferred)
+                           struct gsm_sms *gsms, uint8_t sms_mti)
 {
        int rc;
 
@@ -293,7 +292,7 @@
         * delivery of the SMS.
         */
        if (smpp_first) {
-               rc = smpp_try_deliver(gsms, conn, deferred);
+               rc = smpp_try_deliver(gsms, conn);
                if (rc == GSM411_RP_CAUSE_MO_NUM_UNASSIGNED)
                        /* unknown subscriber, try local */
                        goto try_local;
@@ -322,7 +321,7 @@
                        return GSM411_RP_CAUSE_MO_NUM_UNASSIGNED;
                }
 
-               rc = smpp_try_deliver(gsms, conn, deferred);
+               rc = smpp_try_deliver(gsms, conn);
                if (rc == GSM411_RP_CAUSE_MO_NUM_UNASSIGNED) {
                        
rate_ctr_inc(&conn->network->msc_ctrs->ctr[MSC_CTR_SMS_NO_RECEIVER]);
                } else if (rc < 0) {
@@ -363,7 +362,7 @@
 /* process an incoming TPDU (called from RP-DATA)
  * return value > 0: RP CAUSE for ERROR; < 0: silent error; 0 = success */
 static int gsm340_rx_tpdu(struct gsm_trans *trans, struct msgb *msg,
-                         uint32_t gsm411_msg_ref, bool *deferred)
+                         uint32_t gsm411_msg_ref)
 {
        struct gsm_subscriber_connection *conn = trans->conn;
        uint8_t *smsp = msgb_sms(msg);
@@ -485,10 +484,9 @@
        /* FIXME: This looks very wrong */
        send_signal(0, NULL, gsms, 0);
 
-       rc = sms_route_mt_sms(conn, gsms, sms_mti, deferred);
+       rc = sms_route_mt_sms(conn, gsms, sms_mti);
 out:
-       if (!deferred)
-               sms_free(gsms);
+       sms_free(gsms);
 
        return rc;
 }
@@ -541,7 +539,6 @@
                          uint8_t dst_len, uint8_t *dst,
                          uint8_t tpdu_len, uint8_t *tpdu)
 {
-       bool deferred = false;
        int rc = 0;
 
        if (src_len && src)
@@ -558,8 +555,8 @@
 
        DEBUGP(DLSMS, "DST(%u,%s)\n", dst_len, osmo_hexdump(dst, dst_len));
 
-       rc = gsm340_rx_tpdu(trans, msg, rph->msg_ref, &deferred);
-       if (rc == 0 && !deferred)
+       rc = gsm340_rx_tpdu(trans, msg, rph->msg_ref);
+       if (rc == 0)
                return gsm411_send_rp_ack(trans, rph->msg_ref);
        else if (rc > 0)
                return gsm411_send_rp_error(trans, rph->msg_ref, rc);
diff --git a/openbsc/src/libmsc/smpp_openbsc.c 
b/openbsc/src/libmsc/smpp_openbsc.c
index c9379ec..6b89df2 100644
--- a/openbsc/src/libmsc/smpp_openbsc.c
+++ b/openbsc/src/libmsc/smpp_openbsc.c
@@ -497,7 +497,6 @@
        osmo_timer_del(&cmd->response_timer);
        llist_del(&cmd->list);
        subscr_put(cmd->subscr);
-       sms_free(cmd->sms);
        talloc_free(cmd);
 }
 
@@ -520,15 +519,14 @@
                goto out;
        }
 
-       trans = trans_find_by_id(conn, GSM48_PDISC_SMS,
-                                cmd->sms->gsm411.transaction_id);
+       trans = trans_find_by_id(conn, GSM48_PDISC_SMS, cmd->gsm411_trans_id);
        if (!trans) {
                LOGP(DSMPP, LOGL_ERROR, "GSM transaction %u is gone\n",
-                    cmd->sms->gsm411.transaction_id);
+                    cmd->gsm411_trans_id);
                goto out;
        }
 
-       gsm411_send_rp_ack(trans, cmd->sms->gsm411.msg_ref);
+       gsm411_send_rp_ack(trans, cmd->gsm411_msg_ref);
 out:
        smpp_cmd_free(cmd);
 }
@@ -545,18 +543,17 @@
                goto out;
        }
 
-       trans = trans_find_by_id(conn, GSM48_PDISC_SMS,
-                                cmd->sms->gsm411.transaction_id);
+       trans = trans_find_by_id(conn, GSM48_PDISC_SMS, cmd->gsm411_trans_id);
        if (!trans) {
                LOGP(DSMPP, LOGL_ERROR, "GSM transaction %u is gone\n",
-                    cmd->sms->gsm411.transaction_id);
+                    cmd->gsm411_trans_id);
                goto out;
        }
 
        if (smpp_to_gsm411_err(status, &gsm411_cause) < 0)
                gsm411_cause = GSM411_RP_CAUSE_MO_NET_OUT_OF_ORDER;
 
-       gsm411_send_rp_error(trans, cmd->sms->gsm411.msg_ref, gsm411_cause);
+       gsm411_send_rp_error(trans, cmd->gsm411_msg_ref, gsm411_cause);
 out:
        smpp_cmd_free(cmd);
 }
@@ -568,7 +565,7 @@
 
 static int smpp_cmd_enqueue(struct osmo_esme *esme,
                            struct gsm_subscriber *subscr, struct gsm_sms *sms,
-                           uint32_t sequence_number, bool *deferred)
+                           uint32_t sequence_number)
 {
        struct osmo_smpp_cmd *cmd;
 
@@ -577,7 +574,8 @@
                return -1;
 
        cmd->sequence_nr        = sequence_number;
-       cmd->sms                = sms;
+       cmd->gsm411_msg_ref     = sms->gsm411.msg_ref;
+       cmd->gsm411_trans_id    = sms->gsm411.transaction_id;
        cmd->subscr             = subscr_get(subscr);
 
        /* FIXME: No predefined value for this response_timer as specified by
@@ -588,7 +586,6 @@
        osmo_timer_setup(&cmd->response_timer, smpp_deliver_sm_cb, cmd);
        osmo_timer_schedule(&cmd->response_timer, 5, 0);
        llist_add_tail(&cmd->list, &esme->smpp_cmd_list);
-       *deferred = true;
 
        return 0;
 }
@@ -606,8 +603,7 @@
 }
 
 static int deliver_to_esme(struct osmo_esme *esme, struct gsm_sms *sms,
-                          struct gsm_subscriber_connection *conn,
-                          bool *deferred)
+                          struct gsm_subscriber_connection *conn)
 {
        struct deliver_sm_t deliver;
        int mode, ret;
@@ -686,7 +682,7 @@
                return ret;
 
        return smpp_cmd_enqueue(esme, conn->subscr, sms,
-                               deliver.sequence_number, deferred);
+                               deliver.sequence_number);
 }
 
 static struct smsc *g_smsc;
@@ -697,7 +693,7 @@
 }
 
 int smpp_try_deliver(struct gsm_sms *sms,
-                    struct gsm_subscriber_connection *conn, bool *deferred)
+                    struct gsm_subscriber_connection *conn)
 {
        struct osmo_esme *esme;
        struct osmo_smpp_addr dst;
@@ -710,7 +706,7 @@
 
        rc = smpp_route(g_smsc, &dst, &esme);
        if (!rc)
-               rc = deliver_to_esme(esme, sms, conn, deferred);
+               rc = deliver_to_esme(esme, sms, conn);
 
        return rc;
 }
diff --git a/openbsc/src/libmsc/smpp_smsc.h b/openbsc/src/libmsc/smpp_smsc.h
index c9209ef..468d3b4 100644
--- a/openbsc/src/libmsc/smpp_smsc.h
+++ b/openbsc/src/libmsc/smpp_smsc.h
@@ -89,8 +89,9 @@
 struct osmo_smpp_cmd {
        struct llist_head       list;
        struct gsm_subscriber   *subscr;
-       struct gsm_sms          *sms;
        uint32_t                sequence_nr;
+       uint32_t                gsm411_msg_ref;
+       uint8_t                 gsm411_trans_id;
        struct osmo_timer_list  response_timer;
 };
 
@@ -161,5 +162,5 @@
 int smpp_route_smpp_first(struct gsm_sms *sms,
                            struct gsm_subscriber_connection *conn);
 int smpp_try_deliver(struct gsm_sms *sms,
-                    struct gsm_subscriber_connection *conn, bool *deferred);
+                    struct gsm_subscriber_connection *conn);
 #endif

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iba5f864f9bb963baff95969e306b1b7cff00c1e3
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Pablo Neira Ayuso <pa...@gnumonks.org>

Reply via email to