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

laforge gerrit-no-reply at lists.osmocom.org
Wed Apr 7 16:25:35 UTC 2021


laforge has submitted this change. ( 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(-)

Approvals:
  laforge: Looks good to me, approved
  fixeria: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/src/gb/gprs_ns2_vc_fsm.c b/src/gb/gprs_ns2_vc_fsm.c
index 85cd2ad..9a6bfc2 100644
--- a/src/gb/gprs_ns2_vc_fsm.c
+++ b/src/gb/gprs_ns2_vc_fsm.c
@@ -784,6 +784,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);
 }
 
@@ -792,6 +796,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 fc060ae..b678db4 100644
--- a/src/gb/gprs_ns2_vty.c
+++ b/src/gb/gprs_ns2_vty.c
@@ -2044,6 +2044,7 @@
 {
 	struct gprs_ns2_inst *nsi = vty_nsi;
 	struct gprs_ns2_vc *nsvc;
+	int rc;
 
 	uint16_t id = atoi(argv[0]);
 
@@ -2054,11 +2055,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 %05u will be blocked.%s", id, VTY_NEWLINE);
+			return CMD_SUCCESS;
+		case -EALREADY:
+			vty_out(vty, "The NS-VC %05u is already blocked.%s", id, VTY_NEWLINE);
+			return CMD_ERR_NOTHING_TODO;
+		default:
+			vty_out(vty, "An unknown error %d happend on NS-VC %05u.%s", rc, id, 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 %05u will be unblocked.%s", id, VTY_NEWLINE);
+			return CMD_SUCCESS;
+		case -EALREADY:
+			vty_out(vty, "The NS-VC %05u is already unblocked.%s", id, VTY_NEWLINE);
+			return CMD_ERR_NOTHING_TODO;
+		default:
+			vty_out(vty, "An unknown error %d happend on NS-VC %05u.%s", rc, id, VTY_NEWLINE);
+			return CMD_WARNING;
+		}
 	} else {
 		ns2_vc_reset(nsvc);
+		vty_out(vty, "The NS-VC %05u 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: 5
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210407/4730ccc4/attachment.htm>


More information about the gerrit-log mailing list