Add routines to update nam_ps
Add SQL queries to change nam_ps value and function which uses them.
Change-Id: I24fb79e084b2dfa6a81b52f448b94a86e47014ef
diff --git a/src/db_hlr.c b/src/db_hlr.c
index b7485f0..2c6b243 100644
--- a/src/db_hlr.c
+++ b/src/db_hlr.c
@@ -76,6 +76,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;
+
+ 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)