aboutsummaryrefslogtreecommitdiffstats
path: root/src/db.h
diff options
context:
space:
mode:
authorStefan Sperling <ssperling@sysmocom.de>2018-12-07 12:30:21 +0100
committerStefan Sperling <stsp@stsp.name>2018-12-10 16:12:06 +0000
commit5c14c9ccca83563d07670eb8e9ed5867ca957112 (patch)
treeb36b740fa2a3f8b49cf42baa49eee7c6911e1a08 /src/db.h
parent705b61bcb795490e265027d0b45499b87dd65e12 (diff)
display last location update timestamp in vty
Read the subscriber's last location update timestamp from the database and display it in the output of 'show subscriber'. For example: OsmoHLR> show subscriber id 1 ID: 1 IMSI: 123456789000000 MSISDN: 543210123456789 VLR number: 712 SGSN number: 5952 last LU seen: Fri Dec 7 11:30:51 2018 UTC While the database stores the timestamp as a string, we convert the timestamp into time_t for internal use. This allows for flexible potential use of the timestamp in contexts other than the VTY in the future. The timestamp displayed in the VTY is created with ctime_r(3). It does not match the format of the raw string in the database: sqlite> select id,last_lu_seen from subscriber; 1|2018-12-07 11:30:51 Related: OS#2838 Change-Id: Ie180c434f02ffec0d4b2f651a73258a8126b2e1a
Diffstat (limited to 'src/db.h')
-rw-r--r--src/db.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/db.h b/src/db.h
index 5129b8d..ae592fb 100644
--- a/src/db.h
+++ b/src/db.h
@@ -84,8 +84,14 @@ struct hlr_subscriber {
uint32_t lmsi;
bool ms_purged_cs;
bool ms_purged_ps;
+ time_t last_lu_seen;
};
+/* A format string for use with strptime(3). This format string is
+ * used to parse the last_lu_seen column stored in the HLR database.
+ * See https://sqlite.org/lang_datefunc.html, function datetime(). */
+#define DB_LAST_LU_SEEN_FMT "%Y-%m-%d %H:%M:%S"
+
/* Like struct osmo_sub_auth_data, but the keys are in hexdump representation.
* This is useful because SQLite requires them in hexdump format, and callers
* like the VTY and CTRL interface also have them available as hexdump to begin