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
This commit is contained in:
Neels Hofmeyr 2017-10-06 04:26:21 +02:00
parent d7d9697d85
commit 32633e2b89
2 changed files with 6 additions and 6 deletions

View File

@ -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? */

View File

@ -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;