diff options
author | Harald Welte <laforge@gnumonks.org> | 2016-05-05 21:03:03 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2016-05-05 21:03:03 +0200 |
commit | b18f0e04f3294821a4ef57a926a3ba07c5e5103c (patch) | |
tree | 04b347ae67c43c6fe1b9a3975903d89f4a248dfc /src/hlr.c | |
parent | 999092790caa2c41803a447389a717ac2b9ef745 (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 'src/hlr.c')
-rw-r--r-- | src/hlr.c | 40 |
1 files changed, 40 insertions, 0 deletions
@@ -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: |