From af9683a3730ef7396adebf2dbd56d4ec8ca6b906 Mon Sep 17 00:00:00 2001 From: Alexander Chemeris Date: Sat, 8 Mar 2014 21:57:07 +0100 Subject: sms,db: Update DB scheme to support more features in our SMSC. Do not store delivered messages in the DB. In a production system we should not store messages longer than needed, as it will quickly bloat our DB. In case one wants to store messages for debug purposes, we could add one of the following capabilities later: - hexdump to a log file - send to an SMPP entry on delivery - send to Wireshark sms,db: Store SMS Message Reference in the DB, since we need it to generate SMS-STATUS-REPORT. 03.40 9.2.3.6TP-Message-Reference (TP-MR) The SMS-STATUS-REPORT also contains a TP-Message-Reference field. The value sent to the MS will be the sameas the TP-Message-Reference value generated by the MS in the earlier SMS-SUBMIT or SMS-COMMAND to whichthe status report relates. sms,db: Add a 'type' filed to gsm_sms structure to be able diffrentiate normal DELIVER/SUBMIT messages from STATUS-REP messages. --- openbsc/tests/db/db_test.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'openbsc/tests') diff --git a/openbsc/tests/db/db_test.c b/openbsc/tests/db/db_test.c index be327aa99..c8b916096 100644 --- a/openbsc/tests/db/db_test.c +++ b/openbsc/tests/db/db_test.c @@ -73,10 +73,13 @@ static void test_sms(void) subscr->net = &dummy_net; sms = sms_alloc(); + sms->type = GSM_SMS_DELIVER; sms->receiver = subscr_get(subscr); sms->received_time = 12345; sms->valid_until = 67890; + sms->delivered_time = 98765; + sms->msg_ref = 123; sms->src.ton = 0x23; sms->src.npi = 0x24; @@ -104,9 +107,12 @@ static void test_sms(void) /* now query */ sms = db_sms_get_unsent_for_subscr(subscr); OSMO_ASSERT(sms); + OSMO_ASSERT(sms->type == GSM_SMS_DELIVER); OSMO_ASSERT(sms->receiver == subscr); OSMO_ASSERT(sms->received_time == 12345); OSMO_ASSERT(sms->valid_until == 67890); + OSMO_ASSERT(sms->delivered_time == 98765); + OSMO_ASSERT(sms->msg_ref == 123); OSMO_ASSERT(sms->reply_path_req == 1); OSMO_ASSERT(sms->status_rep_req == 2); OSMO_ASSERT(sms->ud_hdr_ind == 3); @@ -120,6 +126,14 @@ static void test_sms(void) OSMO_ASSERT(sms->user_data_len == strlen("UserData123")); OSMO_ASSERT(strcmp((char *) sms->user_data, "UserData123") == 0); + /* mark SMS as delivered in the DB */ + db_sms_mark_delivered(sms); + sms_free(sms); + + /* now query - we should not get anything */ + sms = db_sms_get_unsent_for_subscr(subscr); + OSMO_ASSERT(!sms); + subscr_put(subscr); } -- cgit v1.2.3