summaryrefslogtreecommitdiffstats
path: root/openbsc/src/libmsc
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@gnumonks.org>2017-08-07 14:01:10 +0100
committerPablo Neira Ayuso <pablo@gnumonks.org>2017-08-08 10:20:20 +0200
commit4e5b90a594f987266a7e9492f30780eb92b9639c (patch)
treef404b3a9006965b7929b65c5760869362d03848d /openbsc/src/libmsc
parent31655d84faa7f7fe823111856ae2035d44aca0eb (diff)
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
Diffstat (limited to 'openbsc/src/libmsc')
-rw-r--r--openbsc/src/libmsc/gsm_04_11.c19
-rw-r--r--openbsc/src/libmsc/smpp_openbsc.c30
-rw-r--r--openbsc/src/libmsc/smpp_smsc.h5
3 files changed, 24 insertions, 30 deletions
diff --git a/openbsc/src/libmsc/gsm_04_11.c b/openbsc/src/libmsc/gsm_04_11.c
index 7df5e649d..d60de08d9 100644
--- a/openbsc/src/libmsc/gsm_04_11.c
+++ b/openbsc/src/libmsc/gsm_04_11.c
@@ -278,8 +278,7 @@ static int gsm340_gen_sms_deliver_tpdu(struct msgb *msg, struct gsm_sms *sms)
}
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 @@ static int sms_route_mt_sms(struct gsm_subscriber_connection *conn,
* 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 @@ try_local:
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 @@ try_local:
/* 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 @@ static int gsm340_rx_tpdu(struct gsm_trans *trans, struct msgb *msg,
/* 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 @@ static int gsm411_rx_rp_ud(struct msgb *msg, struct gsm_trans *trans,
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 @@ static int gsm411_rx_rp_ud(struct msgb *msg, struct gsm_trans *trans,
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 c9379ec07..6b89df26f 100644
--- a/openbsc/src/libmsc/smpp_openbsc.c
+++ b/openbsc/src/libmsc/smpp_openbsc.c
@@ -497,7 +497,6 @@ static void smpp_cmd_free(struct osmo_smpp_cmd *cmd)
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 @@ void smpp_cmd_ack(struct osmo_smpp_cmd *cmd)
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 @@ void smpp_cmd_err(struct osmo_smpp_cmd *cmd, uint32_t status)
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 void smpp_deliver_sm_cb(void *data)
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 @@ static int smpp_cmd_enqueue(struct osmo_esme *esme,
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 @@ static int smpp_cmd_enqueue(struct osmo_esme *esme,
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 @@ struct osmo_smpp_cmd *smpp_cmd_find_by_seqnum(struct osmo_esme *esme,
}
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 @@ static int deliver_to_esme(struct osmo_esme *esme, struct gsm_sms *sms,
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_route_smpp_first(struct gsm_sms *sms, struct gsm_subscriber_connection
}
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 @@ int smpp_try_deliver(struct gsm_sms *sms,
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 c9209ef8b..468d3b477 100644
--- a/openbsc/src/libmsc/smpp_smsc.h
+++ b/openbsc/src/libmsc/smpp_smsc.h
@@ -89,8 +89,9 @@ struct osmo_smpp_route {
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 @@ struct gsm_subscriber_connection;
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