summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Chemeris <Alexander.Chemeris@gmail.com>2013-10-05 12:55:34 +0200
committerIvan Kluchnikov <kluchnikovi@gmail.com>2014-04-15 16:10:59 +0400
commitc9cdb30df1af4810a24fafe513df650500c7c5c2 (patch)
tree7b6c149fe7fce0ac208ef61fd7b2f1120ff750fc
parenta26e2995c9435447894d5cc159da60e7e7c64e07 (diff)
sms_queue,smpp: Refactor MO SUBMIT code to make further changes easier.fairwaves/external_number
This is required to implement normal prefix/regexp routing in addition to the current "if unroutable" model.
-rw-r--r--openbsc/src/libmsc/gsm_04_11.c66
1 files changed, 40 insertions, 26 deletions
diff --git a/openbsc/src/libmsc/gsm_04_11.c b/openbsc/src/libmsc/gsm_04_11.c
index 5f107599d..16ce65187 100644
--- a/openbsc/src/libmsc/gsm_04_11.c
+++ b/openbsc/src/libmsc/gsm_04_11.c
@@ -280,6 +280,42 @@ static int gsm340_gen_sms_deliver_tpdu(struct msgb *msg, struct gsm_sms *sms)
return msg->len - old_msg_len;
}
+static int sms_queue_try_deliver(struct gsm_subscriber_connection *conn,
+ struct msgb *msg, struct gsm_sms *gsms,
+ uint8_t sms_mti)
+{
+ int rc = 0;
+
+ /* determine gsms->receiver based on dialled number */
+ gsms->receiver = subscr_get_by_extension(conn->bts->network, gsms->dst.addr);
+ if (!gsms->receiver) {
+ rc = GSM411_RP_CAUSE_MO_NUM_UNASSIGNED;
+ goto out;
+ }
+
+ switch (sms_mti) {
+ case GSM340_SMS_SUBMIT_MS2SC:
+ /* MS is submitting a SMS */
+ rc = gsm340_rx_sms_submit(msg, gsms);
+ break;
+ case GSM340_SMS_COMMAND_MS2SC:
+ case GSM340_SMS_DELIVER_REP_MS2SC:
+ LOGP(DLSMS, LOGL_NOTICE, "Unimplemented MTI 0x%02x\n", sms_mti);
+ rc = GSM411_RP_CAUSE_IE_NOTEXIST;
+ break;
+ default:
+ LOGP(DLSMS, LOGL_NOTICE, "Undefined MTI 0x%02x\n", sms_mti);
+ rc = GSM411_RP_CAUSE_IE_NOTEXIST;
+ break;
+ }
+
+ if (!rc && !gsms->receiver)
+ rc = GSM411_RP_CAUSE_MO_NUM_UNASSIGNED;
+
+out:
+ return rc;
+}
+
/* 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_subscriber_connection *conn, struct msgb *msg)
@@ -394,44 +430,22 @@ static int gsm340_rx_tpdu(struct gsm_subscriber_connection *conn, struct msgb *m
/* FIXME: This looks very wrong */
send_signal(0, NULL, gsms, 0);
- /* determine gsms->receiver based on dialled number */
- gsms->receiver = subscr_get_by_extension(conn->bts->network, gsms->dst.addr);
- if (!gsms->receiver) {
+ rc = sms_queue_try_deliver(conn, msg, gsms, sms_mti);
+ if (rc == GSM411_RP_CAUSE_MO_NUM_UNASSIGNED) {
#ifdef BUILD_SMPP
rc = smpp_try_deliver(gsms, conn);
- if (rc == 1) {
- rc = 1; /* cause 1: unknown subscriber */
+ if (rc == GSM411_RP_CAUSE_MO_NUM_UNASSIGNED) {
osmo_counter_inc(conn->bts->network->stats.sms.no_receiver);
} else if (rc < 0) {
- rc = 21; /* cause 21: short message transfer rejected */
+ rc = GSM411_RP_CAUSE_MO_NUM_UNASSIGNED;
/* FIXME: handle the error somehow? */
}
#else
- rc = 1; /* cause 1: unknown subscriber */
osmo_counter_inc(conn->bts->network->stats.sms.no_receiver);
#endif
goto out;
}
- switch (sms_mti) {
- case GSM340_SMS_SUBMIT_MS2SC:
- /* MS is submitting a SMS */
- rc = gsm340_rx_sms_submit(msg, gsms);
- break;
- case GSM340_SMS_COMMAND_MS2SC:
- case GSM340_SMS_DELIVER_REP_MS2SC:
- LOGP(DLSMS, LOGL_NOTICE, "Unimplemented MTI 0x%02x\n", sms_mti);
- rc = GSM411_RP_CAUSE_IE_NOTEXIST;
- break;
- default:
- LOGP(DLSMS, LOGL_NOTICE, "Undefined MTI 0x%02x\n", sms_mti);
- rc = GSM411_RP_CAUSE_IE_NOTEXIST;
- break;
- }
-
- if (!rc && !gsms->receiver)
- rc = GSM411_RP_CAUSE_MO_NUM_UNASSIGNED;
-
out:
sms_free(gsms);