summaryrefslogtreecommitdiffstats
path: root/osmo-gsup-hlr/src/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/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/hlr.c')
-rw-r--r--osmo-gsup-hlr/src/hlr.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/osmo-gsup-hlr/src/hlr.c b/osmo-gsup-hlr/src/hlr.c
index 3b17708..0e31a43 100644
--- a/osmo-gsup-hlr/src/hlr.c
+++ b/osmo-gsup-hlr/src/hlr.c
@@ -406,6 +406,43 @@ static int rx_upd_loc_req(struct osmo_gsup_conn *conn,
return 0;
}
+static int rx_purge_ms_req(struct osmo_gsup_conn *conn,
+ const struct osmo_gsup_message *gsup)
+{
+ struct osmo_gsup_message gsup_reply = {0};
+ struct msgb *msg_out;
+ bool is_ps = false;
+ int rc;
+
+ LOGP(DAUC, LOGL_INFO, "%s: Purge MS (%s)\n", gsup->imsi,
+ is_ps ? "PS" : "CS");
+
+ memcpy(gsup_reply.imsi, gsup->imsi, sizeof(gsup_reply.imsi));
+
+ if (gsup->cn_domain == OSMO_GSUP_CN_DOMAIN_PS)
+ is_ps = true;
+
+ /* FIXME: check if the VLR that sends the purge is the same that
+ * we have on record. Only update if yes */
+
+ /* Perform the actual update of the DB */
+ rc = db_subscr_purge(g_dbc, gsup->imsi, is_ps);
+
+ if (rc == 1)
+ gsup_reply.message_type = OSMO_GSUP_MSGT_PURGE_MS_RESULT;
+ else if (rc == 0) {
+ gsup_reply.message_type = OSMO_GSUP_MSGT_PURGE_MS_ERROR;
+ gsup_reply.cause = GMM_CAUSE_IMSI_UNKNOWN;
+ } else {
+ gsup_reply.message_type = OSMO_GSUP_MSGT_PURGE_MS_ERROR;
+ gsup_reply.cause = GMM_CAUSE_NET_FAIL;
+ }
+
+ msg_out = msgb_alloc_headroom(1024+16, 16, "GSUP AUC response");
+ osmo_gsup_encode(msg_out, &gsup_reply);
+ return osmo_gsup_conn_send(conn, msg_out);
+}
+
static int read_cb(struct osmo_gsup_conn *conn, struct msgb *msg)
{
static struct osmo_gsup_message gsup;
@@ -425,6 +462,9 @@ static int read_cb(struct osmo_gsup_conn *conn, struct msgb *msg)
case OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST:
rx_upd_loc_req(conn, &gsup);
break;
+ case OSMO_GSUP_MSGT_PURGE_MS_REQUEST:
+ rx_purge_ms_req(conn, &gsup);
+ break;
/* responses to requests sent by us */
case OSMO_GSUP_MSGT_INSERT_DATA_ERROR:
case OSMO_GSUP_MSGT_INSERT_DATA_RESULT: