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

Max gerrit-no-reply at lists.osmocom.org
Mon Feb 20 16:55:30 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 (#7).

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/gsup_server.c
M src/gsup_server.h
M src/hlr.c
M src/luop.c
M src/luop.h
6 files changed, 72 insertions(+), 7 deletions(-)


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

diff --git a/src/ctrl.c b/src/ctrl.c
index a167171..ec1a85d 100644
--- a/src/ctrl.c
+++ b/src/ctrl.c
@@ -33,6 +33,46 @@
 #include "luop.h"
 #include "ctrl.h"
 
+static int handle_cmd_ps(struct hlr *ctx, struct ctrl_cmd *cmd, bool enable)
+{
+	struct lu_operation *luop = NULL;
+	struct osmo_gsup_conn *co;
+
+	if (db_subscr_get(ctx->dbc, cmd->value, NULL) < 0) {
+		cmd->reply = "Subscriber Unknown in HLR";
+		return CTRL_CMD_ERROR;
+	}
+
+	if (db_subscr_ps(ctx->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, &ctx->gs->clients, list) {
+			luop = lu_op_alloc_conn(co);
+			lu_op_fill_subscr(luop, ctx->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)
 {
@@ -57,6 +97,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/gsup_server.c b/src/gsup_server.c
index ea51f7d..d431637 100644
--- a/src/gsup_server.c
+++ b/src/gsup_server.c
@@ -245,9 +245,9 @@
 }
 
 struct osmo_gsup_server *
-osmo_gsup_server_create(void *ctx, const char *ip_addr,
-			uint16_t tcp_port,
-			osmo_gsup_read_cb_t read_cb)
+osmo_gsup_server_create(void *ctx, const char *ip_addr, uint16_t tcp_port,
+			osmo_gsup_read_cb_t read_cb,
+			struct llist_head *lu_op_lst)
 {
 	struct osmo_gsup_server *gsups;
 	int rc;
@@ -272,6 +272,8 @@
 	if (rc < 0)
 		goto failed;
 
+	gsups->luop = lu_op_lst;
+
 	return gsups;
 
 failed:
diff --git a/src/gsup_server.h b/src/gsup_server.h
index 484a0d7..885fe52 100644
--- a/src/gsup_server.h
+++ b/src/gsup_server.h
@@ -14,6 +14,9 @@
 	/* list of osmo_gsup_conn */
 	struct llist_head clients;
 
+	/* lu_operations list */
+	struct llist_head *luop;
+
 	struct ipa_server_link *link;
 	osmo_gsup_read_cb_t read_cb;
 	struct llist_head routes;
@@ -36,9 +39,10 @@
 			   uint8_t tag);
 
 struct osmo_gsup_server *osmo_gsup_server_create(void *ctx,
-					const char *ip_addr,
-					uint16_t tcp_port,
-					osmo_gsup_read_cb_t read_cb);
+						 const char *ip_addr,
+						 uint16_t tcp_port,
+						 osmo_gsup_read_cb_t read_cb,
+						 struct llist_head *lu_op_lst);
 
 void osmo_gsup_server_destroy(struct osmo_gsup_server *gsups);
 
diff --git a/src/hlr.c b/src/hlr.c
index a22780b..baa69ec 100644
--- a/src/hlr.c
+++ b/src/hlr.c
@@ -259,6 +259,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:
@@ -447,7 +449,8 @@
 		exit(1);
 	}
 
-	g_hlr->gs = osmo_gsup_server_create(hlr_ctx, NULL, 2222, read_cb);
+	g_hlr->gs = osmo_gsup_server_create(hlr_ctx, NULL, 2222, read_cb,
+					    &g_lu_ops);
 	if (!g_hlr->gs) {
 		LOGP(DMAIN, LOGL_FATAL, "Error starting GSUP server\n");
 		exit(1);
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: 7
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