From 32633e2b895233892a238095e21b89b12ed94d14 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Fri, 6 Oct 2017 04:26:21 +0200 Subject: db: use int64_t as subscriber id The SQLite db does not support uint64_t, and we are always binding the uint64_t id actually as signed int64_t. Hence be consistent and actually handle it as int64_t in the code as well. This means that if we ever see a negative subscriber ID in the SQL database (however unlikely), we will also see it negative in our log output. The SQN handled in osmo_auth* is actually of unsigned type, and, unless we store the SQN as 64bit hex string, we are forced to feed this unsigned value as signed int64_t to the SQLite API. The upcoming db regression test for SQN in change-id I0d870d405e2e0a830360d9ad19f0a3f9e09d8cf2 verifies that the SQN uint64_t translates to signed int64_t and back as expected. Change-Id: I83a47289a48ac37da0f712845d422e897a5e8171 --- src/db.h | 6 +++--- src/db_auc.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/db.h b/src/db.h index ee2d801..761d88e 100644 --- a/src/db.h +++ b/src/db.h @@ -38,9 +38,9 @@ struct db_context *db_open(void *ctx, const char *fname); 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); + int64_t *subscr_id); -int db_update_sqn(struct db_context *dbc, uint64_t id, +int db_update_sqn(struct db_context *dbc, int64_t id, uint64_t new_sqn); int db_get_auc(struct db_context *dbc, const char *imsi, @@ -57,7 +57,7 @@ int db_get_auc(struct db_context *dbc, const char *imsi, struct hlr_subscriber { struct llist_head list; - uint64_t id; + int64_t id; char imsi[GSM23003_IMSI_MAX_DIGITS+1]; char msisdn[GT_MAX_DIGITS+1]; /* imeisv? */ diff --git a/src/db_auc.c b/src/db_auc.c index 7aad06d..71c7262 100644 --- a/src/db_auc.c +++ b/src/db_auc.c @@ -33,7 +33,7 @@ #define LOGAUC(imsi, level, fmt, args ...) LOGP(DAUC, level, "IMSI='%s': " fmt, imsi, ## args) /* update the SQN for a given subscriber ID */ -int db_update_sqn(struct db_context *dbc, uint64_t id, +int db_update_sqn(struct db_context *dbc, int64_t id, uint64_t new_sqn) { sqlite3_stmt *stmt = dbc->stmt[DB_STMT_AUC_UPD_SQN]; @@ -77,7 +77,7 @@ int db_update_sqn(struct db_context *dbc, uint64_t id, 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 *subscr_id) + int64_t *subscr_id) { sqlite3_stmt *stmt = dbc->stmt[DB_STMT_AUC_BY_IMSI]; int ret = 0; @@ -192,7 +192,7 @@ int db_get_auc(struct db_context *dbc, const char *imsi, const uint8_t *auts) { struct osmo_sub_auth_data aud2g, aud3g; - uint64_t subscr_id; + int64_t subscr_id; int ret = 0; int rc; -- cgit v1.2.3