aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/libmsc/smpp_openbsc.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@gnumonks.org>2017-08-07 14:01:30 +0100
committerPablo Neira Ayuso <pablo@gnumonks.org>2017-08-09 13:08:53 +0200
commit98849f7ddcbe8b094af5ee5efc30bd841ac12e04 (patch)
tree8b701fa76c372ea74221ed593994bc6e45d4d299 /openbsc/src/libmsc/smpp_openbsc.c
parent52d519220501c4d4c09dfa924e23badac8589614 (diff)
libmsc: add support for SMPP delivery receipts
If the mobile phone requests a status report via SMS, send a DELIVER_SM with esm_class = Delivery Receipt to ESME to indicate that the SMS has been already delivered to its destination. MS GSM 03.40 SMSC SMPP 3.4 ESME | | | | SMS-DELIVER | | |<----------------------------| | | GSM 04.11 RP-ACK | | |---------------------------->| | | | DELIVER-SM | | | esm_class = Delivery Receipt | | |------------------------------->| | | DELIVER-SM-RESP | | |<-------------------------------| | | | This patch implements "Appendix B. Delivery Receipt Format" as specified in the SMPP 3.4 specs. This string is conveyed in the SMS message as data, and it is only meaningful to the ESME, for logging purposes. The "submit date" and "done date" are not yet set, and other fields are just sent with dummy values, so they are left to be finished as future work. The new SMPP TLV tag TLVID_user_message_reference is added to the SMPP messages inconditionally now since this information is required by delivery-reports to associate the status-report with the original SMS. Change-Id: Ic1a9023074bfa938099377980b6aff9b262fab2a
Diffstat (limited to 'openbsc/src/libmsc/smpp_openbsc.c')
-rw-r--r--openbsc/src/libmsc/smpp_openbsc.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/openbsc/src/libmsc/smpp_openbsc.c b/openbsc/src/libmsc/smpp_openbsc.c
index a8037634c..c0aa89bc5 100644
--- a/openbsc/src/libmsc/smpp_openbsc.c
+++ b/openbsc/src/libmsc/smpp_openbsc.c
@@ -200,6 +200,10 @@ static int submit_to_sms(struct gsm_sms **psms, struct gsm_network *net,
sms->user_data_len = sms_msg_len;
}
+ t = find_tlv(submit->tlv, TLVID_user_message_reference);
+ if (t)
+ sms->msg_ref = ntohs(t->value.val16);
+
*psms = sms;
return ESME_ROK;
}
@@ -514,6 +518,9 @@ void smpp_cmd_ack(struct osmo_smpp_cmd *cmd)
struct gsm_subscriber_connection *conn;
struct gsm_trans *trans;
+ if (cmd->is_report)
+ goto out;
+
conn = connection_for_subscr(cmd->subscr);
if (!conn) {
LOGP(DSMPP, LOGL_ERROR, "No connection to subscriber anymore\n");
@@ -538,6 +545,9 @@ void smpp_cmd_err(struct osmo_smpp_cmd *cmd, uint32_t status)
struct gsm_trans *trans;
int gsm411_cause;
+ if (cmd->is_report)
+ goto out;
+
conn = connection_for_subscr(cmd->subscr);
if (!conn) {
LOGP(DSMPP, LOGL_ERROR, "No connection to subscriber anymore\n");
@@ -575,6 +585,7 @@ static int smpp_cmd_enqueue(struct osmo_esme *esme,
return -1;
cmd->sequence_nr = sequence_number;
+ cmd->is_report = sms->is_report;
cmd->gsm411_msg_ref = sms->gsm411.msg_ref;
cmd->gsm411_trans_id = sms->gsm411.transaction_id;
cmd->subscr = subscr_get(subscr);
@@ -639,7 +650,12 @@ static int deliver_to_esme(struct osmo_esme *esme, struct gsm_sms *sms,
memcpy(deliver.destination_addr, sms->dst.addr,
sizeof(deliver.destination_addr));
- deliver.esm_class = 1; /* datagram mode */
+ /* Short message contains a delivery receipt? Sect. 5.2.12. */
+ if (sms->is_report)
+ deliver.esm_class = 0x04;
+ else
+ deliver.esm_class = 1; /* datagram mode */
+
if (sms->ud_hdr_ind)
deliver.esm_class |= 0x40;
if (sms->reply_path_req)
@@ -685,6 +701,9 @@ static int deliver_to_esme(struct osmo_esme *esme, struct gsm_sms *sms,
if (esme->acl && esme->acl->osmocom_ext && conn->lchan)
append_osmo_tlvs(&deliver.tlv, conn->lchan);
+ append_tlv_u16(&deliver.tlv, TLVID_user_message_reference,
+ sms->msg_ref);
+
ret = smpp_tx_deliver(esme, &deliver);
if (ret < 0)
return ret;