This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Stefan Sperling gerrit-no-reply at lists.osmocom.org
Review at https://gerrit.osmocom.org/5875
Store/retrieve SMS validity time in the SMS datebase
Compute a validity timestamp based on SMS validity time.
Store the computed value in the database and recompute the validity
time when an SMS is read from the database.
Change-Id: Id27c250d3a64cd109416450e8ca155b18a8b9568
---
M src/libmsc/db.c
1 file changed, 11 insertions(+), 8 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/75/5875/1
diff --git a/src/libmsc/db.c b/src/libmsc/db.c
index 28004f7..5c9f724 100644
--- a/src/libmsc/db.c
+++ b/src/libmsc/db.c
@@ -27,6 +27,7 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
+#include <time.h>
#include <dbi/dbi.h>
#include <osmocom/msc/gsm_data.h>
@@ -689,9 +690,7 @@
dbi_result result;
char *q_text, *q_daddr, *q_saddr;
unsigned char *q_udata;
- char *validity_timestamp = "2222-2-2";
-
- /* FIXME: generate validity timestamp based on validity_minutes */
+ time_t now, validity_timestamp;
dbi_conn_quote_string_copy(conn, (char *)sms->text, &q_text);
dbi_conn_quote_string_copy(conn, (char *)sms->dst.addr, &q_daddr);
@@ -699,7 +698,9 @@
dbi_conn_quote_binary_copy(conn, sms->user_data, sms->user_data_len,
&q_udata);
- /* FIXME: correct validity period */
+ now = time(NULL);
+ validity_timestamp = now + sms->validity_minutes * 60;
+
result = dbi_conn_queryf(conn,
"INSERT INTO SMS "
"(created, valid_until, "
@@ -709,14 +710,14 @@
"user_data, text, "
"dest_addr, dest_ton, dest_npi, "
"src_addr, src_ton, src_npi) VALUES "
- "(datetime('now'), %u, "
+ "(datetime('%lld', 'unixepoch'), datetime(%lld, 'unixepoch'), "
"%u, %u, %u, "
"%u, %u, %u, "
"%u, "
"%s, %s, "
"%s, %u, %u, "
"%s, %u, %u)",
- validity_timestamp,
+ (int64_t)now, (int64_t)validity_timestamp,
sms->reply_path_req, sms->status_rep_req, sms->is_report,
sms->msg_ref, sms->protocol_id, sms->data_coding_scheme,
sms->ud_hdr_ind,
@@ -740,15 +741,17 @@
struct gsm_sms *sms = sms_alloc();
const char *text, *daddr, *saddr;
const unsigned char *user_data;
+ time_t validity_timestamp;
if (!sms)
return NULL;
sms->id = dbi_result_get_ulonglong(result, "id");
- /* FIXME: validity */
- /* FIXME: those should all be get_uchar, but sqlite3 is braindead */
sms->created = dbi_result_get_datetime(result, "created");
+ validity_timestamp = dbi_result_get_datetime(result, "valid_until");
+ sms->validity_minutes = (validity_timestamp - sms->created) / 60;
+ /* FIXME: those should all be get_uchar, but sqlite3 is braindead */
sms->reply_path_req = dbi_result_get_ulonglong(result, "reply_path_req");
sms->status_rep_req = dbi_result_get_ulonglong(result, "status_rep_req");
sms->is_report = dbi_result_get_ulonglong(result, "is_report");
--
To view, visit https://gerrit.osmocom.org/5875
To unsubscribe, visit https://gerrit.osmocom.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id27c250d3a64cd109416450e8ca155b18a8b9568
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Stefan Sperling <ssperling at sysmocom.de>