mirror of
https://gitea.osmocom.org/cellular-infrastructure/osmo-hlr.git
synced 2025-10-23 08:22:12 +00:00
Timestamps are stored in the HLR DB in the new 'last_lu_seen' column of the 'subscriber' table, in UTC and in granularity of seconds. At present, osmo-hlr only records these timestamps but otherwise makes no use of them. Because the timestamps are stored in a human-readable form, they may already provide value to external processes which need this information. For example: sqlite> select imsi,last_lu_seen from subscriber; 901990000000001|2018-12-04 14:17:12 I didn't bother adding additional tests because the code added with this commit is already being exercised by several calls to db_subscr_lu() in db_test.c. This change requires a HLR DB schema update. Existing databases won't be upgraded automatically. However, osmo-hlr will refuse to operate with databases which are not upgraded. Change-Id: Ibeb49d45aec18451a260a6654b8c51b8fc3bec50 Related: OS#2838
78 lines
2.3 KiB
SQL
78 lines
2.3 KiB
SQL
CREATE TABLE subscriber (
|
|
-- OsmoHLR's DB scheme is modelled roughly after TS 23.008 version 13.3.0
|
|
id INTEGER PRIMARY KEY,
|
|
-- Chapter 2.1.1.1
|
|
imsi VARCHAR(15) UNIQUE NOT NULL,
|
|
-- Chapter 2.1.2
|
|
msisdn VARCHAR(15) UNIQUE,
|
|
-- Chapter 2.2.3: Most recent / current IMEI
|
|
imeisv VARCHAR,
|
|
-- Chapter 2.4.5
|
|
vlr_number VARCHAR(15),
|
|
-- Chapter 2.4.6
|
|
hlr_number VARCHAR(15),
|
|
-- Chapter 2.4.8.1
|
|
sgsn_number VARCHAR(15),
|
|
-- Chapter 2.13.10
|
|
sgsn_address VARCHAR,
|
|
-- Chapter 2.4.8.2
|
|
ggsn_number VARCHAR(15),
|
|
-- Chapter 2.4.9.2
|
|
gmlc_number VARCHAR(15),
|
|
-- Chapter 2.4.23
|
|
smsc_number VARCHAR(15),
|
|
-- Chapter 2.4.24
|
|
periodic_lu_tmr INTEGER,
|
|
-- Chapter 2.13.115
|
|
periodic_rau_tau_tmr INTEGER,
|
|
-- Chapter 2.1.1.2: network access mode
|
|
nam_cs BOOLEAN NOT NULL DEFAULT 1,
|
|
nam_ps BOOLEAN NOT NULL DEFAULT 1,
|
|
-- Chapter 2.1.8
|
|
lmsi INTEGER,
|
|
|
|
-- The below purged flags might not even be stored non-volatile,
|
|
-- refer to TS 23.012 Chapter 3.6.1.4
|
|
-- Chapter 2.7.5
|
|
ms_purged_cs BOOLEAN NOT NULL DEFAULT 0,
|
|
-- Chapter 2.7.6
|
|
ms_purged_ps BOOLEAN NOT NULL DEFAULT 0,
|
|
|
|
-- Timestamp of last location update seen from subscriber
|
|
-- The value is a string which encodes a UTC timestamp in granularity of seconds.
|
|
last_lu_seen TIMESTAMP default NULL
|
|
);
|
|
|
|
CREATE TABLE subscriber_apn (
|
|
subscriber_id INTEGER, -- subscriber.id
|
|
apn VARCHAR(256) NOT NULL
|
|
);
|
|
|
|
CREATE TABLE subscriber_multi_msisdn (
|
|
-- Chapter 2.1.3
|
|
subscriber_id INTEGER, -- subscriber.id
|
|
msisdn VARCHAR(15) NOT NULL
|
|
);
|
|
|
|
CREATE TABLE auc_2g (
|
|
subscriber_id INTEGER PRIMARY KEY, -- subscriber.id
|
|
algo_id_2g INTEGER NOT NULL, -- enum osmo_auth_algo value
|
|
ki VARCHAR(32) NOT NULL -- hex string: subscriber's secret key (128bit)
|
|
);
|
|
|
|
CREATE TABLE auc_3g (
|
|
subscriber_id INTEGER PRIMARY KEY, -- subscriber.id
|
|
algo_id_3g INTEGER NOT NULL, -- enum osmo_auth_algo value
|
|
k VARCHAR(32) NOT NULL, -- hex string: subscriber's secret key (128bit)
|
|
op VARCHAR(32), -- hex string: operator's secret key (128bit)
|
|
opc VARCHAR(32), -- hex string: derived from OP and K (128bit)
|
|
sqn INTEGER NOT NULL DEFAULT 0, -- sequence number of key usage
|
|
ind_bitlen INTEGER NOT NULL DEFAULT 5 -- nr of index bits at lower SQN end
|
|
);
|
|
|
|
CREATE UNIQUE INDEX idx_subscr_imsi ON subscriber (imsi);
|
|
|
|
-- Set HLR database schema version number
|
|
-- Note: This constant is currently duplicated in src/db.c and must be kept in sync!
|
|
PRAGMA user_version = 1;
|