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/.
Max gerrit-no-reply at lists.osmocom.orgHello Neels Hofmeyr, Harald Welte, Jenkins Builder,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/1840
to look at the new patch set (#7).
Add routines to update nam_ps
Add SQL queries to change nam_ps value and function which uses them.
Change-Id: I24fb79e084b2dfa6a81b52f448b94a86e47014ef
---
M src/db.c
M src/db.h
M src/db_hlr.c
3 files changed, 38 insertions(+), 8 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/40/1840/7
diff --git a/src/db.c b/src/db.c
index d20b8b6..aa4726c 100644
--- a/src/db.c
+++ b/src/db.c
@@ -33,6 +33,8 @@
[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 = ?",
};
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 0fb76a0..0b3df88 100644
--- a/src/db.h
+++ b/src/db.h
@@ -4,13 +4,15 @@
#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,
- UPD_PURGE_PS_BY_IMSI,
+ 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
};
@@ -70,7 +72,7 @@
int db_subscr_get(struct db_context *dbc, const char *imsi,
struct hlr_subscriber *subscr);
-
+int db_subscr_ps(struct db_context *dbc, const char *imsi, bool enable);
int db_subscr_lu(struct db_context *dbc,
const struct hlr_subscriber *subscr,
const char *vlr_or_sgsn_number,
diff --git a/src/db_hlr.c b/src/db_hlr.c
index 09ab6fc..a862e8f 100644
--- a/src/db_hlr.c
+++ b/src/db_hlr.c
@@ -77,6 +77,32 @@
return ret;
}
+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];
+ int rc = 0;
+
+ if (!db_bind_imsi(stmt, imsi))
+ return -EINVAL;
+
+ rc = sqlite3_step(stmt); /* execute the statement */
+ if (rc != SQLITE_DONE) {
+ LOGHLR(imsi, LOGL_ERROR, "Error executing SQL: %d\n", rc);
+ rc = -ENOEXEC;
+ }
+
+ rc = sqlite3_changes(dbc->db); /* verify execution result */
+ if (rc != 1) {
+ LOGHLR(imsi, LOGL_ERROR, "SQL modified %d rows (expected 1)\n",
+ rc);
+ rc = -EINVAL;
+ }
+
+ db_remove_reset(stmt);
+ return rc;
+}
+
int db_subscr_lu(struct db_context *dbc,
const struct hlr_subscriber *subscr,
const char *vlr_or_sgsn_number, bool lu_is_ps)
--
To view, visit https://gerrit.osmocom.org/1840
To unsubscribe, visit https://gerrit.osmocom.org/settings
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I24fb79e084b2dfa6a81b52f448b94a86e47014ef
Gerrit-PatchSet: 7
Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>