summaryrefslogtreecommitdiffstats
path: root/osmo-gsup-hlr/src/db_hlr.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2016-05-05 21:03:03 +0200
committerHarald Welte <laforge@gnumonks.org>2016-05-05 21:03:03 +0200
commit82a583b6ba3f7d02d9c65eb735b8e57c22426fec (patch)
tree50eb74b06805bb4ca8e2774fbbb179b681a9ec7c /osmo-gsup-hlr/src/db_hlr.c
parent17cbcb733be91335692277de0f6b323927ae89d7 (diff)
implement PURGE-MS from VLR/SGSN to HLR
Using this procedure, the VLR/SGSN can set the cs/ps purged flag for the subscriber. We might not even need to store this persistent in the database according to spec, but let's do it anyway, at least until it turns out to be a performance issue.
Diffstat (limited to 'osmo-gsup-hlr/src/db_hlr.c')
-rw-r--r--osmo-gsup-hlr/src/db_hlr.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/osmo-gsup-hlr/src/db_hlr.c b/osmo-gsup-hlr/src/db_hlr.c
index baa0456..ca44e8e 100644
--- a/osmo-gsup-hlr/src/db_hlr.c
+++ b/osmo-gsup-hlr/src/db_hlr.c
@@ -135,3 +135,48 @@ out:
return ret;
}
+
+int db_subscr_purge(struct db_context *dbc, const char *imsi, bool is_ps)
+{
+ sqlite3_stmt *stmt = dbc->stmt[UPD_VLR_BY_ID];
+ int rc, ret = 1;
+
+ if (is_ps)
+ stmt = dbc->stmt[UPD_PURGE_PS_BY_IMSI];
+ else
+ stmt = dbc->stmt[UPD_PURGE_CS_BY_IMSI];
+
+ rc = sqlite3_bind_int(stmt, 1, 1);
+ if (rc != SQLITE_OK) {
+ LOGP(DAUC, LOGL_ERROR, "Error binding Purged: %d\n", rc);
+ return -1;
+ }
+
+ rc = sqlite3_bind_text(stmt, 2, imsi, -1, SQLITE_STATIC);
+ if (rc != SQLITE_OK) {
+ LOGP(DAUC, LOGL_ERROR, "Error binding IMSI: %d\n", rc);
+ ret = -1;
+ goto out;
+ }
+
+ /* execute the statement */
+ rc = sqlite3_step(stmt);
+ if (rc != SQLITE_DONE) {
+ LOGP(DAUC, LOGL_ERROR, "Error setting Purged: %d\n", rc);
+ ret = -2;
+ goto out;
+ }
+ /* FIXME: return 0 in case IMSI not known */
+out:
+ /* remove bindings and reset statement to be re-executed */
+ rc = sqlite3_clear_bindings(stmt);
+ if (rc != SQLITE_OK) {
+ LOGP(DAUC, LOGL_ERROR, "Error clearing bindings: %d\n", rc);
+ }
+ rc = sqlite3_reset(stmt);
+ if (rc != SQLITE_OK) {
+ LOGP(DAUC, LOGL_ERROR, "Error in sqlite3_reset: %d\n", rc);
+ }
+
+ return ret;
+}