Change in libosmocore[master]: gprs_ns2: add vty command `nsvc <nsvci> reset`

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
Wed Mar 24 15:42:48 UTC 2021


lynxis lazus has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/23454 )

Change subject: gprs_ns2: add vty command `nsvc <nsvci> reset`
......................................................................

gprs_ns2: add vty command `nsvc <nsvci> reset`

Change-Id: I436dd0367e83548acfc8f8e36ae4707496a252d9
---
M src/gb/gprs_ns2_internal.h
M src/gb/gprs_ns2_vc_fsm.c
M src/gb/gprs_ns2_vty.c
3 files changed, 27 insertions(+), 3 deletions(-)

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



diff --git a/src/gb/gprs_ns2_internal.h b/src/gb/gprs_ns2_internal.h
index 6cfef44..8e4ba9e 100644
--- a/src/gb/gprs_ns2_internal.h
+++ b/src/gb/gprs_ns2_internal.h
@@ -395,6 +395,7 @@
 int ns2_vc_is_alive(struct gprs_ns2_vc *nsvc);
 int ns2_vc_is_unblocked(struct gprs_ns2_vc *nsvc);
 int ns2_vc_block(struct gprs_ns2_vc *nsvc);
+int ns2_vc_reset(struct gprs_ns2_vc *nsvc);
 int ns2_vc_unblock(struct gprs_ns2_vc *nsvc);
 void ns2_vty_dump_nsvc(struct vty *vty, struct gprs_ns2_vc *nsvc, bool stats);
 
diff --git a/src/gb/gprs_ns2_vc_fsm.c b/src/gb/gprs_ns2_vc_fsm.c
index c64f60d..ad8d4db 100644
--- a/src/gb/gprs_ns2_vc_fsm.c
+++ b/src/gb/gprs_ns2_vc_fsm.c
@@ -115,6 +115,7 @@
 	GPRS_NS2_EV_RX_UNITDATA,
 
 	GPRS_NS2_EV_REQ_FORCE_UNCONFIGURED,	/* called via vty for tests */
+	GPRS_NS2_EV_REQ_OM_RESET,		/* vty cmd: reset */
 	GPRS_NS2_EV_REQ_OM_BLOCK,		/* vty cmd: block */
 	GPRS_NS2_EV_REQ_OM_UNBLOCK,		/* vty cmd: unblock*/
 };
@@ -132,6 +133,7 @@
 	{ GPRS_NS2_EV_RX_STATUS,		"RX-STATUS" },
 	{ GPRS_NS2_EV_RX_UNITDATA,		"RX-UNITDATA" },
 	{ GPRS_NS2_EV_REQ_FORCE_UNCONFIGURED,	"REQ-FORCE_UNCONFIGURED" },
+	{ GPRS_NS2_EV_REQ_OM_RESET,		"REQ-O&M-RESET"},
 	{ GPRS_NS2_EV_REQ_OM_BLOCK,		"REQ-O&M-BLOCK"},
 	{ GPRS_NS2_EV_REQ_OM_UNBLOCK,		"REQ-O&M-UNBLOCK"},
 	{ 0, NULL }
@@ -611,6 +613,15 @@
 	struct msgb *msg = data;
 
 	switch (event) {
+	case GPRS_NS2_EV_REQ_OM_RESET:
+		if (priv->nsvc->mode != GPRS_NS2_VC_MODE_BLOCKRESET)
+			break;
+		/* move the FSM into reset */
+		if (fi->state != GPRS_NS2_ST_RESET) {
+			priv->initiate_reset = true;
+			osmo_fsm_inst_state_chg(fi, GPRS_NS2_ST_RESET, nsi->timeout[NS_TOUT_TNS_RESET], NS_TOUT_TNS_RESET);
+		}
+		break;
 	case GPRS_NS2_EV_RX_RESET:
 		if (priv->nsvc->mode != GPRS_NS2_VC_MODE_BLOCKRESET)
 			break;
@@ -710,6 +721,7 @@
 			       S(GPRS_NS2_EV_RX_ALIVE) |
 			       S(GPRS_NS2_EV_RX_ALIVE_ACK) |
 			       S(GPRS_NS2_EV_REQ_FORCE_UNCONFIGURED) |
+			       S(GPRS_NS2_EV_REQ_OM_RESET) |
 			       S(GPRS_NS2_EV_REQ_OM_BLOCK) |
 			       S(GPRS_NS2_EV_REQ_OM_UNBLOCK),
 	.allstate_action = ns2_vc_fsm_allstate_action,
@@ -783,6 +795,14 @@
 	return osmo_fsm_inst_dispatch(nsvc->fi, GPRS_NS2_EV_REQ_OM_UNBLOCK, NULL);
 }
 
+/*! Reset a NS-VC.
+ *  \param nsvc the virtual circuit
+ *  \return 0 on success; negative on error */
+int ns2_vc_reset(struct gprs_ns2_vc *nsvc)
+{
+	return osmo_fsm_inst_dispatch(nsvc->fi, GPRS_NS2_EV_REQ_OM_RESET, NULL);
+}
+
 /*! entry point for messages from the driver/VL
  *  \param nsvc virtual circuit on which the message was received
  *  \param msg message that was received
diff --git a/src/gb/gprs_ns2_vty.c b/src/gb/gprs_ns2_vty.c
index 68a14c2..fc060ae 100644
--- a/src/gb/gprs_ns2_vty.c
+++ b/src/gb/gprs_ns2_vty.c
@@ -2035,11 +2035,12 @@
 }
 
 DEFUN(nsvc_block, nsvc_block_cmd,
-      "nsvc <0-65535> (block|unblock)",
+      "nsvc <0-65535> (block|unblock|reset)",
       "NS Virtual Connection\n"
       NSVCI_STR
       "Block a NSVC. As cause code O&M intervention will be used.\n"
-      "Unblock a NSVC. As cause code O&M intervention will be used.\n")
+      "Unblock a NSVC. As cause code O&M intervention will be used.\n"
+      "Reset a NSVC. As cause code O&M intervention will be used.\n")
 {
 	struct gprs_ns2_inst *nsi = vty_nsi;
 	struct gprs_ns2_vc *nsvc;
@@ -2054,8 +2055,10 @@
 
 	if (!strcmp(argv[1], "block")) {
 		ns2_vc_block(nsvc);
-	} else {
+	} else if (!strcmp(argv[1], "unblock")) {
 		ns2_vc_unblock(nsvc);
+	} else {
+		ns2_vc_reset(nsvc);
 	}
 
 	return CMD_SUCCESS;

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I436dd0367e83548acfc8f8e36ae4707496a252d9
Gerrit-Change-Number: 23454
Gerrit-PatchSet: 2
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: lynxis lazus <lynxis at fe80.eu>
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/20210324/55fa15b1/attachment.htm>


More information about the gerrit-log mailing list