Change in libosmocore[master]: gprs_ns2_vty: print a response to vty `nsvc <nsvci> (block|unblock|re...

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

lynxis lazus gerrit-no-reply at lists.osmocom.org
Mon Mar 22 12:21:19 UTC 2021


lynxis lazus has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/23455 )


Change subject: gprs_ns2_vty: print a response to vty `nsvc <nsvci> (block|unblock|reset)
......................................................................

gprs_ns2_vty: print a response to vty `nsvc <nsvci> (block|unblock|reset)

The vty wasn't printing anything to the user if it was a success or not

Change-Id: Idbb83ea319bbdc94177febdd66e79c49fce7fdd2
---
M src/gb/gprs_ns2_vc_fsm.c
M src/gb/gprs_ns2_vty.c
2 files changed, 34 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/55/23455/1

diff --git a/src/gb/gprs_ns2_vc_fsm.c b/src/gb/gprs_ns2_vc_fsm.c
index 3cc97cb..4f0bfa4 100644
--- a/src/gb/gprs_ns2_vc_fsm.c
+++ b/src/gb/gprs_ns2_vc_fsm.c
@@ -756,6 +756,10 @@
  *  \return 0 on success; negative on error */
 int ns2_vc_block(struct gprs_ns2_vc *nsvc)
 {
+	struct gprs_ns2_vc_priv *priv = nsvc->fi->priv;
+	if (priv->initiate_block)
+		return -EALREADY;
+
 	return osmo_fsm_inst_dispatch(nsvc->fi, GPRS_NS2_EV_REQ_OM_BLOCK, NULL);
 }
 
@@ -764,6 +768,10 @@
  *  \return 0 on success; negative on error */
 int ns2_vc_unblock(struct gprs_ns2_vc *nsvc)
 {
+	struct gprs_ns2_vc_priv *priv = nsvc->fi->priv;
+	if (!priv->initiate_block)
+		return -EALREADY;
+
 	return osmo_fsm_inst_dispatch(nsvc->fi, GPRS_NS2_EV_REQ_OM_UNBLOCK, NULL);
 }
 
diff --git a/src/gb/gprs_ns2_vty.c b/src/gb/gprs_ns2_vty.c
index 32639c2..5861d9c 100644
--- a/src/gb/gprs_ns2_vty.c
+++ b/src/gb/gprs_ns2_vty.c
@@ -1895,6 +1895,7 @@
 {
 	struct gprs_ns2_inst *nsi = vty_nsi;
 	struct gprs_ns2_vc *nsvc;
+	int rc;
 
 	uint16_t id = atoi(argv[0]);
 
@@ -1905,11 +1906,34 @@
 	}
 
 	if (!strcmp(argv[1], "block")) {
-		ns2_vc_block(nsvc);
+		rc = ns2_vc_block(nsvc);
+		switch (rc) {
+		case 0:
+			vty_out(vty, "The NS-VC %d will be blocked.%s", id, VTY_NEWLINE);
+			return CMD_SUCCESS;
+		case -EALREADY:
+			vty_out(vty, "The NS-VC %d is already blocked.%s", id, VTY_NEWLINE);
+			return CMD_ERR_NOTHING_TODO;
+		default:
+			vty_out(vty, "An unknown error happend%s", VTY_NEWLINE);
+			return CMD_WARNING;
+		}
 	} else if (!strcmp(argv[1], "unblock")) {
-		ns2_vc_unblock(nsvc);
+		rc = ns2_vc_unblock(nsvc);
+		switch (rc) {
+		case 0:
+			vty_out(vty, "The NS-VC %d will be unblocked.%s", id, VTY_NEWLINE);
+			return CMD_SUCCESS;
+		case -EALREADY:
+			vty_out(vty, "The NS-VC %d is already unblocked.%s", id, VTY_NEWLINE);
+			return CMD_ERR_NOTHING_TODO;
+		default:
+			vty_out(vty, "An unknown error happend%s", VTY_NEWLINE);
+			return CMD_WARNING;
+		}
 	} else {
 		ns2_vc_reset(nsvc);
+		vty_out(vty, "The NS-VC %d has been resetted.%s", id, VTY_NEWLINE);
 	}
 
 	return CMD_SUCCESS;

-- 
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/23455
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Idbb83ea319bbdc94177febdd66e79c49fce7fdd2
Gerrit-Change-Number: 23455
Gerrit-PatchSet: 1
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210322/b7bb4dd7/attachment.htm>


More information about the gerrit-log mailing list