[PATCH] osmo-hlr[master]: db: use int64_t as subscriber id

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Wed Oct 11 20:32:29 UTC 2017


Hello Harald Welte, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/4180

to look at the new patch set (#3).

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
---
M src/db.h
M src/db_auc.c
2 files changed, 6 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/80/4180/3

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 @@
 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 @@
 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_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 @@
 	       const uint8_t *auts)
 {
 	struct osmo_sub_auth_data aud2g, aud3g;
-	uint64_t subscr_id;
+	int64_t subscr_id;
 	int ret = 0;
 	int rc;
 

-- 
To view, visit https://gerrit.osmocom.org/4180
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I83a47289a48ac37da0f712845d422e897a5e8171
Gerrit-PatchSet: 3
Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list