[PATCH] osmo-hlr[master]: CTRL: add enable/disable packet service cmds

Max gerrit-no-reply at lists.osmocom.org
Mon Feb 20 12:40:37 UTC 2017


Hello Neels Hofmeyr, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/1841

to look at the new patch set (#6).

CTRL: add enable/disable packet service cmds

Add commands to enable/disable Packet Service for a given IMSI. Changes
are synced to DB and propagated at runtime to SGSN (in case of disable
command).

Change-Id: I23163ce8667292443ed61cb15c928357dba4b4be
Related: OS#1645
---
M src/ctrl.c
M src/hlr.c
M src/luop.c
M src/luop.h
4 files changed, 59 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/41/1841/6

diff --git a/src/ctrl.c b/src/ctrl.c
index b7514c5..8165926 100644
--- a/src/ctrl.c
+++ b/src/ctrl.c
@@ -32,6 +32,47 @@
 #include "luop.h"
 #include "ctrl.h"
 
+static int handle_cmd_ps(struct osmo_gsup_server *gs, struct ctrl_cmd *cmd,
+			 bool enable)
+{
+	struct lu_operation *luop = NULL;
+	struct osmo_gsup_conn *co;
+
+	if (db_subscr_get(gs->dbc, cmd->value, NULL) < 0) {
+		cmd->reply = "Subscriber Unknown in HLR";
+		return CTRL_CMD_ERROR;
+	}
+
+	if (db_subscr_ps(gs->dbc, cmd->value, enable) < 0) {
+		cmd->reply = "Error updating DB";
+		return CTRL_CMD_ERROR;
+	}
+
+	if (!enable){ /* FIXME: only send to single SGSN where latest update for IMSI came from */
+		llist_for_each_entry(co, &gs->clients, list) {
+			luop = lu_op_alloc_conn(co);
+			lu_op_fill_subscr(luop, gs->dbc, cmd->value);
+			lu_op_tx_del_subscr_data(luop);
+		}
+	}
+
+	cmd->reply = "OK";
+
+	return CTRL_CMD_REPLY;
+}
+
+CTRL_CMD_DEFINE_WO_NOVRF(enable_ps, "enable-ps");
+static int set_enable_ps(struct ctrl_cmd *cmd, void *data)
+{
+	return handle_cmd_ps(data, cmd, true);
+}
+
+CTRL_CMD_DEFINE_WO_NOVRF(disable_ps, "disable-ps");
+static int set_disable_ps(struct ctrl_cmd *cmd, void *data)
+{
+	return handle_cmd_ps(data, cmd, false);
+}
+
 CTRL_CMD_DEFINE_WO_NOVRF(status_ps, "status-ps");
 static int set_status_ps(struct ctrl_cmd *cmd, void *data)
 {
@@ -55,6 +96,8 @@
 {
 	int rc = 0;
 
+	rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_enable_ps);
+	rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_disable_ps);
 	rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_status_ps);
 
 	return rc;
diff --git a/src/hlr.c b/src/hlr.c
index 5ae5ff3..0a3642c 100644
--- a/src/hlr.c
+++ b/src/hlr.c
@@ -257,6 +257,8 @@
 		rx_purge_ms_req(conn, &gsup);
 		break;
 	/* responses to requests sent by us */
+	case OSMO_GSUP_MSGT_DELETE_DATA_ERROR:
+	case OSMO_GSUP_MSGT_DELETE_DATA_RESULT:
 	case OSMO_GSUP_MSGT_INSERT_DATA_ERROR:
 	case OSMO_GSUP_MSGT_INSERT_DATA_RESULT:
 	case OSMO_GSUP_MSGT_LOCATION_CANCEL_ERROR:
diff --git a/src/luop.c b/src/luop.c
index ecf31b4..937c02c 100644
--- a/src/luop.c
+++ b/src/luop.c
@@ -266,3 +266,16 @@
 	lu_op_statechg(luop, LU_S_ISD_SENT);
 	osmo_timer_schedule(&luop->timer, ISD_TIMEOUT_SECS, 0);
 }
+
+/*! Transmit Delete Subscriber Data to new VLR/SGSN */
+void lu_op_tx_del_subscr_data(struct lu_operation *luop)
+{
+	struct osmo_gsup_message gsup;
+
+	fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_DELETE_DATA_REQUEST);
+
+	gsup.cn_domain = OSMO_GSUP_CN_DOMAIN_PS;
+
+	/* Send ISD to new VLR/SGSN */
+	_luop_tx_gsup(luop, &gsup);
+}
diff --git a/src/luop.h b/src/luop.h
index 7e2fbb0..ab1bc24 100644
--- a/src/luop.h
+++ b/src/luop.h
@@ -78,3 +78,4 @@
 void lu_op_tx_ack(struct lu_operation *luop);
 void lu_op_tx_cancel_old(struct lu_operation *luop);
 void lu_op_tx_insert_subscr_data(struct lu_operation *luop);
+void lu_op_tx_del_subscr_data(struct lu_operation *luop);

-- 
To view, visit https://gerrit.osmocom.org/1841
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I23163ce8667292443ed61cb15c928357dba4b4be
Gerrit-PatchSet: 6
Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>


More information about the gerrit-log mailing list