aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/sms
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2017-07-04 23:08:44 +0200
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-07-12 23:17:10 +0000
commit29b9206e804e8e5d5f6ea6f9d8c1f8af35332480 (patch)
tree77eed5bde035b276b63f92c0f23e944049e59897 /contrib/sms
parent9e3c66b1814246f6c06a6f78975f54dfe9e2cf8c (diff)
move openbsc/* to repos root
This is the first step in creating this repository from the legacy openbsc.git. Like all other Osmocom repositories, keep the autoconf and automake files in the repository root. openbsc.git has been the sole exception, which ends now. Change-Id: I9c6f2a448d9cb1cc088cf1cf6918b69d7e69b4e7
Diffstat (limited to 'contrib/sms')
-rw-r--r--contrib/sms/fill-hlr.st66
-rw-r--r--contrib/sms/hlr-query.st10
-rw-r--r--contrib/sms/sqlite-probe.tap.d5
3 files changed, 81 insertions, 0 deletions
diff --git a/contrib/sms/fill-hlr.st b/contrib/sms/fill-hlr.st
new file mode 100644
index 000000000..da0643ecf
--- /dev/null
+++ b/contrib/sms/fill-hlr.st
@@ -0,0 +1,66 @@
+"I create output for some simple SQL statements for the HLR db"
+
+
+Eval [
+
+"Create tables if they don't exist"
+Transcript show: 'CREATE TABLE SMS (
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ created TIMESTAMP NOT NULL,
+ sent TIMESTAMP,
+ sender_id INTEGER NOT NULL,
+ receiver_id INTEGER NOT NULL,
+ deliver_attempts INTEGER NOT NULL DEFAULT 0,
+ valid_until TIMESTAMP,
+ reply_path_req INTEGER NOT NULL,
+ status_rep_req INTEGER NOT NULL,
+ protocol_id INTEGER NOT NULL,
+ data_coding_scheme INTEGER NOT NULL,
+ ud_hdr_ind INTEGER NOT NULL,
+ dest_addr TEXT,
+ user_data BLOB,
+ header BLOB,
+ text TEXT);'; nl;
+ show: 'CREATE TABLE Subscriber (
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ created TIMESTAMP NOT NULL,
+ updated TIMESTAMP NOT NULL,
+ imsi NUMERIC UNIQUE NOT NULL,
+ name TEXT,
+ extension TEXT UNIQUE,
+ authorized INTEGER NOT NULL DEFAULT 0,
+ tmsi TEXT UNIQUE,
+ lac INTEGER NOT NULL DEFAULT 0);'; nl.
+
+"Create some dummy subscribers"
+num_sub := 1000.
+num_sms := 30.
+lac := 1.
+
+Transcript show: 'BEGIN;'; nl.
+
+1 to: num_sub do: [:each |
+ Transcript show: 'INSERT INTO Subscriber
+ (imsi, created, updated, authorized, lac, extension)
+ VALUES
+ (%1, datetime(''now''), datetime(''now''), 1, %2, %3);' %
+ {(274090000000000 + each). lac. each}; nl.
+].
+
+1 to: num_sms do: [:sms |
+ 1 to: num_sub do: [:sub |
+ Transcript show: 'INSERT INTO SMS
+ (created, sender_id, receiver_id, valid_until,
+ reply_path_req, status_rep_req, protocol_id,
+ data_coding_scheme, ud_hdr_ind, dest_addr,
+ text) VALUES
+ (datetime(''now''), 1, %1, ''2222-2-2'',
+ 0, 0, 0,
+ 0, 0, ''123456'',
+ ''abc'');' % {sub}; nl.
+ ]
+].
+
+Transcript show: 'COMMIT;'; nl.
+
+]
diff --git a/contrib/sms/hlr-query.st b/contrib/sms/hlr-query.st
new file mode 100644
index 000000000..bd3f97a4a
--- /dev/null
+++ b/contrib/sms/hlr-query.st
@@ -0,0 +1,10 @@
+"Query for one SMS"
+
+Eval [
+1 to: 100 do: [:each |
+ Transcript show: 'SELECT SMS.* FROM SMS
+ JOIN Subscriber ON SMS.receiver_id = Subscriber.id
+ WHERE SMS.id >= 1 AND SMS.sent IS NULL AND Subscriber.lac > 0
+ ORDER BY SMS.id LIMIT 1;'; nl.
+].
+]
diff --git a/contrib/sms/sqlite-probe.tap.d b/contrib/sms/sqlite-probe.tap.d
new file mode 100644
index 000000000..e75cdfcfa
--- /dev/null
+++ b/contrib/sms/sqlite-probe.tap.d
@@ -0,0 +1,5 @@
+probe process("/usr/lib/libsqlite3.so.0.8.6").function("sqlite3_get_table")
+{
+ a = user_string($zSql);
+ printf("sqlite3_get_table called '%s'\n", a);
+}