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

Change subject: NS_Emulation: Introduce status events from provider -> emulation
......................................................................

NS_Emulation: Introduce status events from provider -> emulation

This allows NS_Emulation to react to changes of the underlying
transport layer (e.g. Frame Relay Link/DLCI up).

Change-Id: If00e9c50dc664ce62b6c0cbde99d741e8173169b
---
M library/NS_Emulation.ttcnpp
M library/NS_Provider_FR.ttcn
M library/NS_Provider_IPL4.ttcn
3 files changed, 40 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/library/NS_Emulation.ttcnpp b/library/NS_Emulation.ttcnpp
index 32746b4..5872b00 100644
--- a/library/NS_Emulation.ttcnpp
+++ b/library/NS_Emulation.ttcnpp
@@ -120,9 +120,17 @@
                /* lower layer ports (UDP/IP, Frame Relay) are added in derived 
components */
        };

+       type enumerated NS_Provider_LinkStatus {
+               NS_PROV_LINK_STATUS_UP,
+               NS_PROV_LINK_STATUS_DOWN
+       };
+       type union NS_Provider_Evt {
+               NS_Provider_LinkStatus link_status
+       };
+
        /* port between NS_Provider and NS_CT */
        type port NS_PROVIDER_PT message {
-               inout PDU_NS;
+               inout PDU_NS, NS_Provider_Evt;
        } with { extension "internal" };

        type component NS_CT {
@@ -211,6 +219,12 @@
                        f_sendAlive();
                }

+               [] 
NSCP.receive(NS_Provider_Evt:{link_status:=NS_PROV_LINK_STATUS_UP}) {
+                       log("Provider Link came up: sending NS-ALIVE");
+                       f_sendAlive();
+                       Tns_test.start;
+                       }
+
                /* Stop t_alive when receiving ALIVE-ACK */
                [Tns_alive.running] NSCP.receive(t_NS_ALIVE_ACK) {
                        log("NS-ALIVE-ACK received: stopping Tns-alive; 
starting Tns-test");
diff --git a/library/NS_Provider_FR.ttcn b/library/NS_Provider_FR.ttcn
index 851e6c4..afa27d9 100644
--- a/library/NS_Provider_FR.ttcn
+++ b/library/NS_Provider_FR.ttcn
@@ -22,6 +22,9 @@
 type component NS_Provider_FR_CT extends NS_Provider_CT, FR_Client_CT {
        /* component reference to Frame Relay emulation */
        var FR_Emulation_CT vc_FREMU;
+
+       var boolean link_available := false;
+       var boolean pvc_active := false;
 };

 function main(NSConfiguration config) runs on NS_Provider_FR_CT system 
af_packet {
@@ -50,8 +53,28 @@
                        NSE.send(dec_PDU_NS(rx_fr.payload));
                        }

+               [] FR.receive(FRemu_Event:{link_status:=FR_LINK_STS_AVAILABLE}) 
-> value rx_frevt {
+                       if (link_available == false and pvc_active == true) {
+                               NSE.send(NS_Provider_Evt:{link_status := 
NS_PROV_LINK_STATUS_UP});
+                       }
+                       link_available := true;
+                       }
+               [] 
FR.receive(FRemu_Event:{link_status:=FR_LINK_STS_UNAVAILABLE}) -> value 
rx_frevt {
+                       link_available := false;
+                       NSE.send(NS_Provider_Evt:{link_status := 
NS_PROV_LINK_STATUS_DOWN});
+                       }
+               [] FR.receive(tr_FRemu_PvcStatusAct(config.provider.fr.dlci, 
true)) -> value rx_frevt {
+                       if (pvc_active == false and link_available == true) {
+                               NSE.send(NS_Provider_Evt:{link_status := 
NS_PROV_LINK_STATUS_UP});
+                       }
+                       pvc_active := true;
+                       }
+               [] FR.receive(tr_FRemu_PvcStatusAct(config.provider.fr.dlci, 
false)) -> value rx_frevt {
+                       pvc_active := false;
+                       NSE.send(NS_Provider_Evt:{link_status := 
NS_PROV_LINK_STATUS_DOWN});
+                       }
                [] FR.receive(FRemu_Event:?) -> value rx_frevt {
-                       /* TODO: dispatch to user */
+                       log("Unhandled FRemu_event: ", rx_frevt);
                        }
                [] NSE.receive(PDU_NS:?) -> value rx_pdu {
                        FR.send(ts_FR(config.provider.fr.dlci, 
enc_PDU_NS(rx_pdu), true));
diff --git a/library/NS_Provider_IPL4.ttcn b/library/NS_Provider_IPL4.ttcn
index 1414935..f1fda6c 100644
--- a/library/NS_Provider_IPL4.ttcn
+++ b/library/NS_Provider_IPL4.ttcn
@@ -36,6 +36,7 @@
                mtc.stop;
        }
        g_conn_id := res.connId;
+       NSE.send(NS_Provider_Evt:{link_status := NS_PROV_LINK_STATUS_UP});

        /* transceive beteween user-facing port and UDP socket */
        while (true) {

--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/20122
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: If00e9c50dc664ce62b6c0cbde99d741e8173169b
Gerrit-Change-Number: 20122
Gerrit-PatchSet: 11
Gerrit-Owner: laforge <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: lynxis lazus <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>
Gerrit-MessageType: merged

Reply via email to