Change in osmo-ttcn3-hacks[master]: NS_Emulation: Add CTRL port to administratively disable a NS-VC

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/.

laforge gerrit-no-reply at lists.osmocom.org
Mon Jan 25 12:48:38 UTC 2021


laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/22315 )

Change subject: NS_Emulation: Add CTRL port to administratively disable a NS-VC
......................................................................

NS_Emulation: Add CTRL port to administratively disable a NS-VC

This feature is useful in simulating intermittent or permanent transport network
outage by simply halting processing of all rx+tx in the specified NS-VC
until it is administratively re-enabled.

Change-Id: I742ecf01de15e3edbf0719371f0217a5739b7c8e
RelateD: OS#4521
---
M library/NS_Emulation.ttcnpp
1 file changed, 66 insertions(+), 2 deletions(-)

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



diff --git a/library/NS_Emulation.ttcnpp b/library/NS_Emulation.ttcnpp
index 61ebe95..dc8e0ec 100644
--- a/library/NS_Emulation.ttcnpp
+++ b/library/NS_Emulation.ttcnpp
@@ -107,6 +107,7 @@
 	}
 
 	type enumerated NsvcState {
+		NSVC_S_DISABLED,		/* administratively disabled */
 		NSVC_S_DEAD_BLOCKED,
 		NSVC_S_WAIT_RESET,
 		NSVC_S_ALIVE_BLOCKED,
@@ -128,6 +129,25 @@
 		out	NsUnitdataRequest;
 	} with { extension "internal" };
 
+	/* port from our (internal) point of view */
+	type port NS_CTRL_SP_PT message {
+		in	NsDisableVcRequest,
+			NsEnableVcRequest;
+	} with { extension "internal" };
+
+	/* port from the user point of view */
+	type port NS_CTRL_PT message {
+		out	NsEnableVcRequest,
+			NsDisableVcRequest;
+	} with { extension "internal" };
+
+	type record NsDisableVcRequest {
+		Nsvci nsvci
+	};
+	type record NsEnableVcRequest {
+		Nsvci nsvci
+	};
+
 	type component NS_Provider_CT {
 		/* upper port, facing to NS_Emulation:NSCP */
 		port NS_PROVIDER_PT NSE;
@@ -187,6 +207,9 @@
 		/* port towards the per-NSVC components */
 		port NSint_PT NSVC;
 
+		/* control port, used to manipulate at runtime */
+		port NS_CTRL_SP_PT NS_CTRL;
+
 		/* all of the NS configuration a user passes to us */
 		var NSConfiguration g_config;
 		var charstring g_id;
@@ -239,7 +262,9 @@
 	};
 
 	type enumerated NsCtrlRequest {
-		StartAliveProcedure	(0)
+		StartAliveProcedure	(0),
+		DisableReq		(1),	/* administratively disable NS-VC */
+		EnableReq		(2)	/* administratively enable NS-VC */
 	};
 
 	/* add one NSVC (component and table entry */
@@ -346,6 +371,8 @@
 		var NsStatusIndication rx_nssi;
 		var NsUnitdataIndication rx_nsudi;
 		var NsUnitdataRequest rx_nsudr;
+		var NsDisableVcRequest rx_disar;
+		var NsEnableVcRequest rx_enar;
 		/* pass from NS-VCs up to user */
 		[] NSVC.receive(tr_NsStsInd(g_config.nsei, ?, ?, NSVC_S_ALIVE_UNBLOCKED)) -> value rx_nssi {
 			/* check if this one is the first to be unblocked */
@@ -384,6 +411,14 @@
 					log2str("Received UnitDataInd for invalid NSEI: ", rx_nsudi));
 			}
 		/* from user down to NS-VC */
+		[] NS_CTRL.receive(NsDisableVcRequest:?) -> value rx_disar {
+			var integer nsvc_idx := f_nsvc_find_idx(rx_disar.nsvci);
+			NSVC.send(NsCtrlRequest:DisableReq) to g_nsvcs[nsvc_idx].vc_conn;
+			}
+		[] NS_CTRL.receive(NsEnableVcRequest:?) -> value rx_enar {
+			var integer nsvc_idx := f_nsvc_find_idx(rx_enar.nsvci);
+			NSVC.send(NsCtrlRequest:EnableReq) to g_nsvcs[nsvc_idx].vc_conn;
+			}
 		[] NS_SP.receive(tr_NsUdReq(g_config.nsei, 0, ?, ?, *)) -> value rx_nsudr {
 			/* load distribution function */
 			var integer nsvc_idx := g_unblocked_nsvcs_sig[rx_nsudr.lsp mod lengthof(g_unblocked_nsvcs_sig)];
@@ -577,6 +612,15 @@
 		var PDU_NS rf;
 		var ASP_Event evt;
 
+		[] NS_SP.receive(NsCtrlRequest:DisableReq) {
+			/* To make NS-VCG remove us from list of active NS-VC */
+			f_change_state(NSVC_S_DEAD_BLOCKED);
+			log("Disabling NSVC on user request");
+			f_change_state(NSVC_S_DISABLED);
+			Tns_test.stop;
+			Tns_alive.stop;
+		}
+
 		/* transition to DEAD if t_alive times out */
 		[] Tns_alive.timeout {
 			log("Tns-alive expired: changing to DEAD_BLOCKED + starting Tns-test");
@@ -618,6 +662,25 @@
 		}
 	}
 
+	private altstep as_disabled() runs on NSVC_CT {
+		[g_config.handle_sns == true] NS_SP.receive(NsCtrlRequest:EnableReq) {
+			f_change_state(NSVC_S_ALIVE_UNBLOCKED);
+			f_sendAlive();
+			Tns_test.start;
+		}
+		[g_config.handle_sns == false] NS_SP.receive(NsCtrlRequest:EnableReq) {
+			f_change_state(NSVC_S_DEAD_BLOCKED);
+			Tns_test.start;
+		}
+		/* drop any received messages while in this state */
+		[] NSCP.receive {
+			log("Dropping inbound NS mesage as NS-VC is disabled");
+		}
+		[] NS_SP.receive {
+			log("Dropping user primitive as NS-VC is disabled");
+		}
+	}
+
 	private altstep as_handle_reset() runs on NSVC_CT {
 		var PDU_NS rf;
 
@@ -808,7 +871,8 @@
 			[vc_state == NSVC_S_WAIT_RESET] as_wait_reset();
 			[vc_state == NSVC_S_ALIVE_BLOCKED] as_alive_blocked();
 			[vc_state == NSVC_S_ALIVE_UNBLOCKED] as_alive_unblocked();
-			[] as_allstate();
+			[vc_state == NSVC_S_DISABLED] as_disabled();
+			[vc_state != NSVC_S_DISABLED] as_allstate();
 			}
 		}
 	}

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/22315
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I742ecf01de15e3edbf0719371f0217a5739b7c8e
Gerrit-Change-Number: 22315
Gerrit-PatchSet: 3
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210125/26c65c35/attachment.htm>


More information about the gerrit-log mailing list