summaryrefslogtreecommitdiffstats
path: root/osmo-gsup-hlr/src/db.h
diff options
context:
space:
mode:
Diffstat (limited to 'osmo-gsup-hlr/src/db.h')
-rw-r--r--osmo-gsup-hlr/src/db.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/osmo-gsup-hlr/src/db.h b/osmo-gsup-hlr/src/db.h
new file mode 100644
index 0000000..f0545a4
--- /dev/null
+++ b/osmo-gsup-hlr/src/db.h
@@ -0,0 +1,35 @@
+#pragma once
+
+#include <sqlite3.h>
+
+enum stmt_idx {
+ SEL_BY_IMSI = 0,
+ UPD_BY_IMSI = 1,
+ AUC_BY_IMSI = 2,
+ AUC_UPD_SQN = 3,
+ _NUM_STMT
+};
+
+struct db_context {
+ char *fname;
+ sqlite3 *db;
+ sqlite3_stmt *stmt[_NUM_STMT];
+};
+
+void db_close(struct db_context *dbc);
+struct db_context *db_open(void *ctx, const char *fname);
+
+#include <osmocom/crypt/auth.h>
+
+/* obtain the authentication data for a given imsi */
+int db_get_auth_data(struct db_context *dbc, const char *imsi,
+ struct osmo_sub_auth_data *aud2g,
+ struct osmo_sub_auth_data *aud3g,
+ uint64_t *suscr_id);
+
+int db_update_sqn(struct db_context *dbc, uint64_t id,
+ uint64_t new_sqn);
+
+int db_get_auc(struct db_context *dbc, const char *imsi,
+ struct osmo_auth_vector *vec, unsigned int num_vec,
+ const uint8_t *rand_auts, const uint8_t *auts);