aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/db.c
diff options
context:
space:
mode:
authorHarald Welte (local) <laflocal@hanuman.gnumonks.org>2009-08-16 10:40:10 +0200
committerHarald Welte (local) <laflocal@hanuman.gnumonks.org>2009-08-16 10:40:10 +0200
commit026531ec924f954cfb2dc9df1082e60f861a2d11 (patch)
tree1f6eed0da450fe75205e9789b1e19498f6bca6f9 /openbsc/src/db.c
parent6eef564e2dc44048685105331382039267e90bed (diff)
store all APDU's received from the MS in the database
This helps us to analyze data such as RRLP location information for later analysis.
Diffstat (limited to 'openbsc/src/db.c')
-rw-r--r--openbsc/src/db.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/openbsc/src/db.c b/openbsc/src/db.c
index d5e924db7..16a7f6ad7 100644
--- a/openbsc/src/db.c
+++ b/openbsc/src/db.c
@@ -109,6 +109,13 @@ static char *create_stmts[] = {
"subscriber_id NUMERIC UNIQUE NOT NULL, "
"last_bts NUMERIC NOT NULL "
")",
+ "CREATE TABLE IF NOT EXISTS ApduBlobs ("
+ "id INTEGER PRIMARY KEY AUTOINCREMENT, "
+ "created TIMESTAMP NOT NULL, "
+ "apdu_id_flags INTEGER NOT NULL, "
+ "subscriber_id INTEGER NOT NULL, "
+ "apdu BLOB "
+ ")",
};
void db_error_func(dbi_conn conn, void* data) {
@@ -771,3 +778,27 @@ int db_sms_inc_deliver_attempts(struct gsm_sms *sms)
dbi_result_free(result);
return 0;
}
+
+int db_apdu_blob_store(struct gsm_subscriber *subscr,
+ u_int8_t apdu_id_flags, u_int8_t len,
+ u_int8_t *apdu)
+{
+ dbi_result result;
+ char *q_apdu;
+
+ dbi_conn_quote_binary_copy(conn, apdu, len, &q_apdu);
+
+ result = dbi_conn_queryf(conn,
+ "INSERT INTO ApduBlobs "
+ "(created,subscriber_id,apdu_id_flags,apdu) VALUES "
+ "(datetime('now'),%llu,%u,%s)",
+ subscr->id, apdu_id_flags, q_apdu);
+
+ free(q_apdu);
+
+ if (!result)
+ return -EIO;
+
+ dbi_result_free(result);
+ return 0;
+}