pespin has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/43299?usp=email )


Change subject: hnbgw: Move generic PFCP ConnHdlr helpers to 
library/PFCP_Emulation.ttcn
......................................................................

hnbgw: Move generic PFCP ConnHdlr helpers to library/PFCP_Emulation.ttcn

Change-Id: Ic40bea51934ad465a68e0d5690de066cbe1dc57d
---
M hnbgw/HNBGW_Tests.ttcn
M library/PFCP_Emulation.ttcn
2 files changed, 96 insertions(+), 94 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks 
refs/changes/99/43299/1

diff --git a/hnbgw/HNBGW_Tests.ttcn b/hnbgw/HNBGW_Tests.ttcn
index f43a738..da4a64d 100644
--- a/hnbgw/HNBGW_Tests.ttcn
+++ b/hnbgw/HNBGW_Tests.ttcn
@@ -260,100 +260,6 @@
        return pfcp_associated;
 }

-private function f_pfcp_wait_assoc_setup_req(boolean fail_timeout := true, 
boolean fail_rx_others := true, float wait_timeout := 16.0) runs on 
PFCP_ConnHdlr {
-       var PDU_PFCP m;
-       timer T := wait_timeout;
-       var integer rts := f_PFCPEM_get_recovery_timestamp();
-       /* ask PFCPEM to route all PDUs to us */
-       f_PFCPEM_subscribe_bcast();
-
-       T.start;
-       alt {
-       [] PFCP.receive(tr_PFCP_Assoc_Setup_Req()) -> value m {
-                       PFCP.send(ts_PFCP_Assoc_Setup_Resp(m.sequence_number, 
ts_PFCP_Node_ID_fqdn(mp_pfcp_upf_node_id),
-                                          ts_PFCP_Cause(REQUEST_ACCEPTED), 
rts));
-                       setverdict(pass);
-               }
-       [fail_rx_others] PFCP.receive(PDU_PFCP:?) -> value m {
-                       Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
-                                               log2str("Got an unexpected PFCP 
message ", m, " vs exp ", tr_PFCP_Assoc_Setup_Req()));
-               }
-       [fail_timeout] T.timeout {
-                       Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
-                                               log2str("Timeout waiting for 
PFCP ", tr_PFCP_Assoc_Setup_Req()));
-               }
-       [not fail_timeout] T.timeout {
-                       log("Timeout waiting for PFCP ", 
tr_PFCP_Assoc_Setup_Req());
-               }
-       }
-       T.stop;
-       /* ask PFCPEM to *not* route all PDUs to us anymore */
-       f_PFCPEM_unsubscribe_bcast();
-}
-
-altstep as_pfcp_handle_heartbeat_req(integer tx_recovery_timestamp)
-runs on PFCP_ConnHdlr {
-       var PDU_PFCP m;
-
-       [] PFCP.receive(tr_PFCP_Heartbeat_Req) -> value m {
-               var PDU_PFCP tx_pfcp;
-               tx_pfcp := 
valueof(ts_PFCP_Heartbeat_Resp(tx_recovery_timestamp));
-               tx_pfcp.sequence_number := m.sequence_number;
-               PFCP.send(tx_pfcp);
-               }
-}
-
-/* Notify peer that we restarted, it will then try to associate again. */
-private function f_pfcp_force_assoc_setup_req(boolean fail_timeout := true,
-                                              boolean fail_rx_others := true,
-                                              float wait_timeout := 16.0)
-runs on PFCP_ConnHdlr {
-       var boolean rx_hb_resp := false;
-       var boolean rx_assoc_setup_req := false;
-       var integer rts := f_PFCPEM_get_recovery_timestamp();
-       var PDU_PFCP m;
-       timer T := wait_timeout;
-
-       /* ask PFCPEM to route all PDUs to us */
-       f_PFCPEM_subscribe_bcast();
-
-       T.start;
-       PFCP.send(ts_PFCP_Heartbeat_Req(rts));
-       alt {
-       [not rx_hb_resp] PFCP.receive(tr_PFCP_Heartbeat_Resp) {
-               rx_hb_resp := true;
-               if (not rx_assoc_setup_req) {
-                       repeat;
-               }
-               }
-       [not rx_assoc_setup_req] PFCP.receive(tr_PFCP_Assoc_Setup_Req()) -> 
value m {
-               rx_assoc_setup_req := true;
-               PFCP.send(ts_PFCP_Assoc_Setup_Resp(m.sequence_number, 
ts_PFCP_Node_ID_fqdn(mp_pfcp_upf_node_id),
-                                                  
ts_PFCP_Cause(REQUEST_ACCEPTED), rts));
-               if (not rx_hb_resp) {
-                       repeat;
-               }
-       }
-       [] as_pfcp_handle_heartbeat_req(rts) { repeat; }
-       [fail_rx_others] PFCP.receive(PDU_PFCP:?) -> value m {
-                       Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
-                                               log2str("Got an unexpected PFCP 
message ", m, " vs exp ", tr_PFCP_Assoc_Setup_Req()));
-               }
-       [fail_timeout] T.timeout {
-                       Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
-                                               log2str("Timeout waiting for 
PFCP ", tr_PFCP_Assoc_Setup_Req()));
-               }
-       [not fail_timeout] T.timeout {
-                       log("Timeout waiting for PFCP ", 
tr_PFCP_Assoc_Setup_Req());
-               }
-       }
-       T.stop;
-       setverdict(pass);
-
-       /* ask PFCPEM to *not* route all PDUs to us anymore */
-       f_PFCPEM_unsubscribe_bcast();
-}
-
 function f_init_pfcp(charstring id) runs on test_CT {
        id := id & "-PFCP";

diff --git a/library/PFCP_Emulation.ttcn b/library/PFCP_Emulation.ttcn
index a5ec818..ec6777c 100644
--- a/library/PFCP_Emulation.ttcn
+++ b/library/PFCP_Emulation.ttcn
@@ -401,4 +401,100 @@
        }
 }

+/* Wait for peer to send a PFCP HEARTBEAT REQ to us, answer it */
+altstep as_pfcp_handle_heartbeat_req(integer tx_recovery_timestamp)
+runs on PFCP_ConnHdlr {
+       var PDU_PFCP m;
+
+       [] PFCP.receive(tr_PFCP_Heartbeat_Req) -> value m {
+               var PDU_PFCP tx_pfcp;
+               tx_pfcp := 
valueof(ts_PFCP_Heartbeat_Resp(tx_recovery_timestamp));
+               tx_pfcp.sequence_number := m.sequence_number;
+               PFCP.send(tx_pfcp);
+               }
+}
+
+/* Wait for peer to send a PFCP ASSOC SETUP REQ to us, answer it */
+function f_pfcp_wait_assoc_setup_req(boolean fail_timeout := true, boolean 
fail_rx_others := true, float wait_timeout := 16.0) runs on PFCP_ConnHdlr {
+       var PDU_PFCP m;
+       timer T := wait_timeout;
+       var integer rts := f_PFCPEM_get_recovery_timestamp();
+       /* ask PFCPEM to route all PDUs to us */
+       f_PFCPEM_subscribe_bcast();
+
+       T.start;
+       alt {
+       [] PFCP.receive(tr_PFCP_Assoc_Setup_Req()) -> value m {
+                       PFCP.send(ts_PFCP_Assoc_Setup_Resp(m.sequence_number, 
ts_PFCP_Node_ID_fqdn(mp_pfcp_upf_node_id),
+                                          ts_PFCP_Cause(REQUEST_ACCEPTED), 
rts));
+                       setverdict(pass);
+               }
+       [fail_rx_others] PFCP.receive(PDU_PFCP:?) -> value m {
+                       Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
+                                               log2str("Got an unexpected PFCP 
message ", m, " vs exp ", tr_PFCP_Assoc_Setup_Req()));
+               }
+       [fail_timeout] T.timeout {
+                       Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
+                                               log2str("Timeout waiting for 
PFCP ", tr_PFCP_Assoc_Setup_Req()));
+               }
+       [not fail_timeout] T.timeout {
+                       log("Timeout waiting for PFCP ", 
tr_PFCP_Assoc_Setup_Req());
+               }
+       }
+       T.stop;
+       /* ask PFCPEM to *not* route all PDUs to us anymore */
+       f_PFCPEM_unsubscribe_bcast();
+}
+
+/* Notify peer that we restarted, it will then try to associate again. */
+function f_pfcp_force_assoc_setup_req(boolean fail_timeout := true,
+                                              boolean fail_rx_others := true,
+                                              float wait_timeout := 16.0)
+runs on PFCP_ConnHdlr {
+       var boolean rx_hb_resp := false;
+       var boolean rx_assoc_setup_req := false;
+       var integer rts := f_PFCPEM_get_recovery_timestamp();
+       var PDU_PFCP m;
+       timer T := wait_timeout;
+
+       /* ask PFCPEM to route all PDUs to us */
+       f_PFCPEM_subscribe_bcast();
+
+       T.start;
+       PFCP.send(ts_PFCP_Heartbeat_Req(rts));
+       alt {
+       [not rx_hb_resp] PFCP.receive(tr_PFCP_Heartbeat_Resp) {
+               rx_hb_resp := true;
+               if (not rx_assoc_setup_req) {
+                       repeat;
+               }
+               }
+       [not rx_assoc_setup_req] PFCP.receive(tr_PFCP_Assoc_Setup_Req()) -> 
value m {
+               rx_assoc_setup_req := true;
+               PFCP.send(ts_PFCP_Assoc_Setup_Resp(m.sequence_number, 
ts_PFCP_Node_ID_fqdn(mp_pfcp_upf_node_id),
+                               ts_PFCP_Cause(REQUEST_ACCEPTED), rts));
+               if (not rx_hb_resp) {
+                       repeat;
+               }
+       }
+       [] as_pfcp_handle_heartbeat_req(rts) { repeat; }
+       [fail_rx_others] PFCP.receive(PDU_PFCP:?) -> value m {
+                       Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
+                                               log2str("Got an unexpected PFCP 
message ", m, " vs exp ", tr_PFCP_Assoc_Setup_Req()));
+               }
+       [fail_timeout] T.timeout {
+                       Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
+                                               log2str("Timeout waiting for 
PFCP ", tr_PFCP_Assoc_Setup_Req()));
+               }
+       [not fail_timeout] T.timeout {
+                       log("Timeout waiting for PFCP ", 
tr_PFCP_Assoc_Setup_Req());
+               }
+       }
+       T.stop;
+       setverdict(pass);
+
+       /* ask PFCPEM to *not* route all PDUs to us anymore */
+       f_PFCPEM_unsubscribe_bcast();
+}
+
 }

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

Gerrit-MessageType: newchange
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: Ic40bea51934ad465a68e0d5690de066cbe1dc57d
Gerrit-Change-Number: 43299
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <[email protected]>

Reply via email to