summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/db.c18
-rw-r--r--src/db.h22
-rw-r--r--src/db_auc.c4
-rw-r--r--src/db_hlr.c16
4 files changed, 30 insertions, 30 deletions
diff --git a/src/db.c b/src/db.c
index aaf6fe2..6566527 100644
--- a/src/db.c
+++ b/src/db.c
@@ -26,15 +26,15 @@
#include "db.h"
static const char *stmt_sql[] = {
- [SEL_BY_IMSI] = "SELECT id,imsi,msisdn,vlr_number,sgsn_number,sgsn_address,periodic_lu_tmr,periodic_rau_tau_tmr,nam_cs,nam_ps,lmsi,ms_purged_cs,ms_purged_ps FROM subscriber WHERE imsi = ?",
- [UPD_VLR_BY_ID] = "UPDATE subscriber SET vlr_number = ? WHERE id = ?",
- [UPD_SGSN_BY_ID] = "UPDATE subscriber SET sgsn_number = ? WHERE id = ?",
- [AUC_BY_IMSI] = "SELECT id, algo_id_2g, ki, algo_id_3g, k, op, opc, sqn, ind_bitlen FROM subscriber LEFT JOIN auc_2g ON auc_2g.subscriber_id = subscriber.id LEFT JOIN auc_3g ON auc_3g.subscriber_id = subscriber.id WHERE imsi = ?",
- [AUC_UPD_SQN] = "UPDATE auc_3g SET sqn = ? WHERE subscriber_id = ?",
- [UPD_PURGE_CS_BY_IMSI] = "UPDATE subscriber SET ms_purged_cs=1 WHERE imsi = ?",
- [UPD_PURGE_PS_BY_IMSI] = "UPDATE subscriber SET ms_purged_ps=1 WHERE imsi = ?",
- [SET_NAM_PS_BY_IMSI] = "UPDATE subscriber SET nam_ps=1 WHERE imsi = ?",
- [UNSET_NAM_PS_BY_IMSI] = "UPDATE subscriber SET nam_ps=0 WHERE imsi = ?",
+ [DB_STMT_SEL_BY_IMSI] = "SELECT id,imsi,msisdn,vlr_number,sgsn_number,sgsn_address,periodic_lu_tmr,periodic_rau_tau_tmr,nam_cs,nam_ps,lmsi,ms_purged_cs,ms_purged_ps FROM subscriber WHERE imsi = ?",
+ [DB_STMT_UPD_VLR_BY_ID] = "UPDATE subscriber SET vlr_number = ? WHERE id = ?",
+ [DB_STMT_UPD_SGSN_BY_ID] = "UPDATE subscriber SET sgsn_number = ? WHERE id = ?",
+ [DB_STMT_AUC_BY_IMSI] = "SELECT id, algo_id_2g, ki, algo_id_3g, k, op, opc, sqn, ind_bitlen FROM subscriber LEFT JOIN auc_2g ON auc_2g.subscriber_id = subscriber.id LEFT JOIN auc_3g ON auc_3g.subscriber_id = subscriber.id WHERE imsi = ?",
+ [DB_STMT_AUC_UPD_SQN] = "UPDATE auc_3g SET sqn = ? WHERE subscriber_id = ?",
+ [DB_STMT_UPD_PURGE_CS_BY_IMSI] = "UPDATE subscriber SET ms_purged_cs=1 WHERE imsi = ?",
+ [DB_STMT_UPD_PURGE_PS_BY_IMSI] = "UPDATE subscriber SET ms_purged_ps=1 WHERE imsi = ?",
+ [DB_STMT_SET_NAM_PS_BY_IMSI] = "UPDATE subscriber SET nam_ps=1 WHERE imsi = ?",
+ [DB_STMT_UNSET_NAM_PS_BY_IMSI] = "UPDATE subscriber SET nam_ps=0 WHERE imsi = ?",
};
static void sql3_error_log_cb(void *arg, int err_code, const char *msg)
diff --git a/src/db.h b/src/db.h
index a60cf62..d424b38 100644
--- a/src/db.h
+++ b/src/db.h
@@ -4,22 +4,22 @@
#include <sqlite3.h>
enum stmt_idx {
- SEL_BY_IMSI = 0,
- UPD_VLR_BY_ID = 1,
- UPD_SGSN_BY_ID = 2,
- AUC_BY_IMSI = 3,
- AUC_UPD_SQN = 4,
- UPD_PURGE_CS_BY_IMSI = 5,
- UPD_PURGE_PS_BY_IMSI = 6,
- SET_NAM_PS_BY_IMSI = 7,
- UNSET_NAM_PS_BY_IMSI = 8,
- _NUM_STMT
+ DB_STMT_SEL_BY_IMSI,
+ DB_STMT_UPD_VLR_BY_ID,
+ DB_STMT_UPD_SGSN_BY_ID,
+ DB_STMT_AUC_BY_IMSI,
+ DB_STMT_AUC_UPD_SQN,
+ DB_STMT_UPD_PURGE_CS_BY_IMSI,
+ DB_STMT_UPD_PURGE_PS_BY_IMSI,
+ DB_STMT_SET_NAM_PS_BY_IMSI,
+ DB_STMT_UNSET_NAM_PS_BY_IMSI,
+ _NUM_DB_STMT
};
struct db_context {
char *fname;
sqlite3 *db;
- sqlite3_stmt *stmt[_NUM_STMT];
+ sqlite3_stmt *stmt[_NUM_DB_STMT];
};
bool db_remove_reset(sqlite3_stmt *stmt);
diff --git a/src/db_auc.c b/src/db_auc.c
index f532b83..07039d4 100644
--- a/src/db_auc.c
+++ b/src/db_auc.c
@@ -36,7 +36,7 @@
int db_update_sqn(struct db_context *dbc, uint64_t id,
uint64_t new_sqn)
{
- sqlite3_stmt *stmt = dbc->stmt[AUC_UPD_SQN];
+ sqlite3_stmt *stmt = dbc->stmt[DB_STMT_AUC_UPD_SQN];
int rc;
/* bind new SQN and subscriber ID */
@@ -79,7 +79,7 @@ int db_get_auth_data(struct db_context *dbc, const char *imsi,
struct osmo_sub_auth_data *aud3g,
uint64_t *subscr_id)
{
- sqlite3_stmt *stmt = dbc->stmt[AUC_BY_IMSI];
+ sqlite3_stmt *stmt = dbc->stmt[DB_STMT_AUC_BY_IMSI];
int ret = 0;
int rc;
diff --git a/src/db_hlr.c b/src/db_hlr.c
index f6ae18f..9c74a24 100644
--- a/src/db_hlr.c
+++ b/src/db_hlr.c
@@ -40,7 +40,7 @@
int db_subscr_get(struct db_context *dbc, const char *imsi,
struct hlr_subscriber *subscr)
{
- sqlite3_stmt *stmt = dbc->stmt[SEL_BY_IMSI];
+ sqlite3_stmt *stmt = dbc->stmt[DB_STMT_SEL_BY_IMSI];
int rc;
if (!db_bind_imsi(stmt, imsi))
@@ -83,7 +83,7 @@ int db_subscr_get(struct db_context *dbc, const char *imsi,
int db_subscr_ps(struct db_context *dbc, const char *imsi, bool enable)
{
sqlite3_stmt *stmt =
- dbc->stmt[enable ? SET_NAM_PS_BY_IMSI : UNSET_NAM_PS_BY_IMSI];
+ dbc->stmt[enable ? DB_STMT_SET_NAM_PS_BY_IMSI : DB_STMT_UNSET_NAM_PS_BY_IMSI];
int rc;
if (!db_bind_imsi(stmt, imsi))
@@ -111,15 +111,15 @@ int db_subscr_lu(struct db_context *dbc,
const struct hlr_subscriber *subscr,
const char *vlr_or_sgsn_number, bool lu_is_ps)
{
- sqlite3_stmt *stmt = dbc->stmt[UPD_VLR_BY_ID];
+ sqlite3_stmt *stmt = dbc->stmt[DB_STMT_UPD_VLR_BY_ID];
const char *txt;
int rc, ret = 0;
if (lu_is_ps) {
- stmt = dbc->stmt[UPD_SGSN_BY_ID];
+ stmt = dbc->stmt[DB_STMT_UPD_SGSN_BY_ID];
txt = subscr->sgsn_number;
} else {
- stmt = dbc->stmt[UPD_VLR_BY_ID];
+ stmt = dbc->stmt[DB_STMT_UPD_VLR_BY_ID];
txt = subscr->vlr_number;
}
@@ -150,13 +150,13 @@ out:
int db_subscr_purge(struct db_context *dbc, const char *imsi, bool is_ps)
{
- sqlite3_stmt *stmt = dbc->stmt[UPD_VLR_BY_ID];
+ sqlite3_stmt *stmt = dbc->stmt[DB_STMT_UPD_VLR_BY_ID];
int rc, ret = 1;
if (is_ps)
- stmt = dbc->stmt[UPD_PURGE_PS_BY_IMSI];
+ stmt = dbc->stmt[DB_STMT_UPD_PURGE_PS_BY_IMSI];
else
- stmt = dbc->stmt[UPD_PURGE_CS_BY_IMSI];
+ stmt = dbc->stmt[DB_STMT_UPD_PURGE_CS_BY_IMSI];
if (!db_bind_imsi(stmt, imsi))
return -EINVAL;