pespin has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/27853 )


Change subject: pgw: Initial Gy support
......................................................................

pgw: Initial Gy support

Change-Id: I04cf78cb4bc73de59f803c01208a7ef9056cb14f
---
M pgw/PGW_Tests.ttcn
1 file changed, 79 insertions(+), 4 deletions(-)



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

diff --git a/pgw/PGW_Tests.ttcn b/pgw/PGW_Tests.ttcn
index 16bea57..92cad87 100644
--- a/pgw/PGW_Tests.ttcn
+++ b/pgw/PGW_Tests.ttcn
@@ -3,6 +3,7 @@
 import from General_Types all;
 import from Osmocom_Types all;
 import from Native_Functions all;
+import from Misc_Helpers all;

 import from GTPv2_Types all;
 import from GTPv2_Templates all;
@@ -29,6 +30,9 @@

        charstring mp_pcrf_local_ip := "127.0.0.9";
        integer mp_pcrf_local_port := 3868;
+
+       charstring mp_ocs_local_ip := "127.0.0.9";
+       integer mp_ocs_local_port := 3869;
 }

 /* main component, we typically have one per testcase */
@@ -40,6 +44,10 @@
        var DIAMETER_Emulation_CT vc_Gx;
        port DIAMETER_PT Gx_UNIT;
        port DIAMETEREM_PROC_PT Gx_PROC;
+       /* emulated OCS */
+       var DIAMETER_Emulation_CT vc_Gy;
+       port DIAMETER_PT Gy_UNIT;
+       port DIAMETEREM_PROC_PT Gy_PROC;
        /* global test case guard timer (actual timeout value is set in 
f_init()) */
        timer T_guard;
 }
@@ -81,6 +89,7 @@
        var SessionPars g_pars;

        port DIAMETER_Conn_PT Gx;
+       port DIAMETER_Conn_PT Gy;

        /* TEI (Data) local side */
        var OCT4        g_teid;
@@ -98,6 +107,9 @@
        var OCT4        g_ip4_addr;
        var OCT16       g_ip6_addr;
        var integer     g_ip6_plen;
+
+       /* In seconds. 0 => disabled, !0 => grant over CC-Time period */
+       var integer g_gy_validity_time := 0;
 }

 /* configuration data for a given Session */
@@ -155,7 +167,10 @@
                unitdata_cb := refers(DiameterForwardUnitdataCallback),
                raw := false /* handler mode (IMSI based routing) */
        };
-       var DIAMETER_conn_parameters pars := {
+       var DIAMETER_conn_parameters pars;
+
+       /* Gx setup: */
+       pars := {
                remote_ip := mp_pgw_hostname,
                remote_sctp_port := -1,
                local_ip := mp_pcrf_local_ip,
@@ -171,7 +186,25 @@
        connect(vc_Gx:DIAMETER_PROC, self:Gx_PROC);
        vc_Gx.start(DIAMETER_Emulation.main(ops, pars, id));

+       /* Gy setup: */
+       pars := {
+               remote_ip := mp_pgw_hostname,
+               remote_sctp_port := -1,
+               local_ip := mp_ocs_local_ip,
+               local_sctp_port := mp_ocs_local_port,
+               origin_host := "ocs.localdomain",
+               origin_realm := "localdomain",
+               auth_app_id := c_DIAMETER_CREDIT_CONTROL_AID,
+               vendor_app_id := omit
+       };
+       vc_Gy := DIAMETER_Emulation_CT.create(id);
+       map(vc_Gy:DIAMETER, system:DIAMETER_CODEC_PT);
+       connect(vc_Gy:DIAMETER_UNIT, self:Gy_UNIT);
+       connect(vc_Gy:DIAMETER_PROC, self:Gy_PROC);
+       vc_Gy.start(DIAMETER_Emulation.main(ops, pars, id));
+
        f_diameter_wait_capability(Gx_UNIT);
+       f_diameter_wait_capability(Gy_UNIT);
        /* Give some time for our emulation to get out of SUSPECT list of SUT 
(3 watchdong ping-pongs):
         * RFC6733 sec 5.1
         * RFC3539 sec 3.4.1 [5]
@@ -206,7 +239,7 @@
 function f_start_handler(void_fn fn, template (omit) SessionPars pars_tmpl := 
omit)
 runs on PGW_Test_CT return PGW_Session_CT {
        var charstring id := testcasename();
-       var DIAMETER_ConnHdlr_CT vc_conn_gx;
+       var DIAMETER_ConnHdlr_CT vc_conn_gx, vc_conn_gy;
        var PGW_Session_CT vc_conn;
        var SessionPars pars;

@@ -228,6 +261,14 @@
                vc_conn_gx.start(f_diam_connhldr_ct_main(pars.imsi));
        }

+       if (isbound(vc_Gy)) {
+               vc_conn_gy := DIAMETER_ConnHdlr_CT.create(id);
+               connect(vc_conn_gy:DIAMETER, vc_Gy:DIAMETER_CLIENT);
+               connect(vc_conn_gy:DIAMETER_PROC, vc_Gy:DIAMETER_PROC);
+               connect(vc_conn:Gy, vc_conn_gy:DIAMETER_CLIENT);
+               vc_conn_gy.start(f_diam_connhldr_ct_main(pars.imsi));
+       }
+
        vc_conn.start(f_handler_init(fn, pars));
        return vc_conn;
 }
@@ -275,8 +316,36 @@
                                         req_type, req_num));
        }
        [] Gx.receive(PDU_DIAMETER:?) -> value rx_dia {
-               setverdict(fail, "Received unexpected DIAMETER ", rx_dia);
-               self.stop;
+               Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
+                                       log2str("Received unexpected DIAMETER 
", rx_dia));
+       }
+}
+
+private altstep as_DIA_Gy_CCR(DCC_NONE_CC_Request_Type req_type) runs on 
PGW_Session_CT {
+       var PDU_DIAMETER rx_dia;
+       [] Gy.receive(tr_DIA_Gy_CCR(req_type := req_type)) -> value rx_dia {
+               var template (value) PDU_DIAMETER tx_dia;
+               var template (omit) AVP avp;
+               var octetstring sess_id;
+               var AVP_Unsigned32 req_num;
+
+               avp := f_DIAMETER_get_avp(rx_dia, 
c_AVP_Code_BASE_NONE_Session_Id);
+               sess_id := valueof(avp.avp_data.avp_BASE_NONE_Session_Id);
+
+               avp := f_DIAMETER_get_avp(rx_dia, 
c_AVP_Code_DCC_NONE_CC_Request_Number);
+               req_num := valueof(avp.avp_data.avp_DCC_NONE_CC_Request_Number);
+               if (g_gy_validity_time > 0) {
+                       tx_dia := 
ts_DIA_Gy_CCA_ValidityTime(rx_dia.hop_by_hop_id, rx_dia.end_to_end_id, sess_id,
+                                                req_type, req_num, 
g_gy_validity_time);
+               } else {
+                       tx_dia := ts_DIA_Gy_CCA(rx_dia.hop_by_hop_id, 
rx_dia.end_to_end_id, sess_id,
+                                                req_type, req_num);
+               }
+               Gy.send(tx_dia);
+       }
+       [] Gy.receive(PDU_DIAMETER:?) -> value rx_dia {
+               Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
+                                       log2str("Received unexpected DIAMETER 
Gy", rx_dia));
        }
 }

@@ -366,6 +435,9 @@
        if (Gx.checkstate("Connected")) {
                as_DIA_Gx_CCR(INITIAL_REQUEST);
        }
+       if (Gy.checkstate("Connected")) {
+               as_DIA_Gy_CCR(INITIAL_REQUEST);
+       }
        alt {
        [] GTP2.receive(tr_GTP2C_CreateSessionResp(d_teid:=g_teic, 
cause:='10'O)) -> value rx {
                /* extract TEIDs */
@@ -425,6 +497,9 @@
        if (Gx.checkstate("Connected") and expect_diameter) {
                as_DIA_Gx_CCR(TERMINATION_REQUEST);
        }
+       if (Gy.checkstate("Connected") and expect_diameter) {
+               as_DIA_Gy_CCR(TERMINATION_REQUEST);
+       }
        alt {
        [] GTP2.receive(tr_GTP2C_DeleteSessionResp(d_teid := exp_teid, cause := 
exp_cause)) {
                setverdict(pass);

--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/27853
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: I04cf78cb4bc73de59f803c01208a7ef9056cb14f
Gerrit-Change-Number: 27853
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <[email protected]>
Gerrit-MessageType: newchange

Reply via email to