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


Change subject: GTPv2: Declare GTP2C_Cause as enum
......................................................................

GTPv2: Declare GTP2C_Cause as enum

Change-Id: Id26f59274d7a8813b64b9b4b7c5c39cc12d5a0ac
---
M library/GTPv2_Templates.ttcn
M pgw/PGW_Tests.ttcn
2 files changed, 56 insertions(+), 26 deletions(-)



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

diff --git a/library/GTPv2_Templates.ttcn b/library/GTPv2_Templates.ttcn
index 753774d..6bd3ba6 100644
--- a/library/GTPv2_Templates.ttcn
+++ b/library/GTPv2_Templates.ttcn
@@ -147,28 +147,37 @@


 /* 8.4-1 */
-/*
 type enumerated GTP2C_Cause {
        Local_Detach                            (2),
        Complete_Detach                         (3),
        RAT_changed_from_3GPP_to_Non_3GPP       (4),
        ISR_deactivation                        (5),
-       Error_Ind_from_RNC_eNB_SGSN_MME         (5),
+       Error_Ind_from_RNC_eNB_SGSN_MME         (6),
        IMSI_Detach_Only                        (7),
        Reactivation_Required                   (8),
-}
-*/
-
-const integer c_GTP2C_Cause_LocalDetach := 1;
+       PDN_reconnection_to_APN_disallowed      (9),
+       Access_changed_from_Non_3GPP_to_3GPP    (10),
+       PDN_connection_inactivity_timer_expires (11),
+       PGW_not_responding                      (12),
+       Network_Failure                         (13),
+       QoS_parameter_mismatch                  (14),
+       EPS_to_5GS_Mobility                     (15),
+       Request_accepted                        (16),
+       Request_accepted_partially              (17),
+       New_PDN_type_due_to_network_preference  (18),
+       New_PDN_type_due_to_single_address_bearer_only (19),
+       /* ... */
+       Context_Not_Found                       (64)
+} with { variant "FIELDLENGTH(8)" encode "RAW" };

 /* 8.4 */
-template (value) Cause ts_GTP2C_Cause(template (value) OCT1 cause,
+template (value) Cause ts_GTP2C_Cause(template (value) GTP2C_Cause cause,
                                      template (value) BIT1 cs) := {
        elementIdentifier := '02'O,
        lengthIndicator := 0, /* overwritten */
        instance := '0000'B,
        spare := '0000'B,
-       causeValue := cause,
+       causeValue := int2oct(enum2int(valueof(cause)), 1),
        cS := cs,
        bCE := '0'B,
        pCE := '0'B,
@@ -178,12 +187,24 @@
        instanceOfOffendingIE := omit,
        spare3 := omit
 }
-template (present) Cause tr_GTP2C_Cause(template (present) OCT1 cause) := {
+private function enum2int_GTP2C_Cause_tmpl(template GTP2C_Cause inp) return 
template integer
+{
+       if (istemplatekind(inp, "omit")) {
+               return omit;
+       } else if (istemplatekind(inp, "*")) {
+               return *;
+       } else if (istemplatekind(inp, "?")) {
+               return ?;
+       } else {
+               return enum2int(valueof(inp));
+       }
+}
+template (present) Cause tr_GTP2C_Cause(template (present) GTP2C_Cause cause) 
:= {
        elementIdentifier := '02'O,
        lengthIndicator := ?,
        instance := ?,
        spare := '0000'B,
-       causeValue := cause,
+       causeValue := int2oct_tmpl(enum2int_GTP2C_Cause_tmpl(cause), 1),
        cS := ?,
        bCE := ?,
        pCE := ?,
@@ -193,7 +214,7 @@
        instanceOfOffendingIE := *,
        spare3 := *
 }
-private function fs_GTP2C_Cause(template (omit) OCT1 cause, template (value) 
BIT1 cs) return
+private function fs_GTP2C_Cause(template (omit) GTP2C_Cause cause, template 
(value) BIT1 cs) return
 template (omit) Cause {
        if (istemplatekind(cause, "omit")) {
                return omit;
@@ -201,7 +222,7 @@
                return ts_GTP2C_Cause(cause, cs);
        }
 }
-private function fr_GTP2C_Cause(template OCT1 cause) return
+private function fr_GTP2C_Cause(template GTP2C_Cause cause) return
 template Cause {
        if (istemplatekind(cause, "omit")) {
                return omit;
@@ -793,7 +814,7 @@
                           template (value) PDN_AddressAllocation addr) :=
 ts_PDU_GTP2C('00000000'O, '000000'O, '21'O, {
        createSessionResponse := {
-               cause := ts_GTP2C_Cause(int2oct(16, 1), '0'B),
+               cause := ts_GTP2C_Cause(Request_accepted, '0'B),
                changeReportingAction := omit,
                cSG_InformationReportingAction := omit,
                heNBInformationReporting := omit,
@@ -824,7 +845,7 @@
 template (present) PDU_GTPCv2
 tr_GTP2C_CreateSessionResp(template (present) OCT4 d_teid := ?,
                           template (present) OCT3 seq := ?,
-                          template (present) OCT1 cause := ?,
+                          template (present) GTP2C_Cause cause := ?,
                           template FullyQualifiedTEID_List fteids := *,
                           template PDN_AddressAllocation addr := *,
                           template BearerContextGrouped_List bctxg := *) :=
@@ -862,7 +883,7 @@

 template (value) PDU_GTPCv2
 ts_GTP2C_DeleteSessionReq(template (value) OCT4 d_teid,
-                         template (omit) OCT1 cause := omit,
+                         template (omit) GTP2C_Cause cause := omit,
                          template (value) FullyQualifiedTEID sender_fteid,
                          template (omit) FullyQualifiedTEID_List teid_list := 
omit,
                          template (value) uint4_t bearer_id) :=
@@ -889,7 +910,7 @@
 template (present) PDU_GTPCv2
 tr_GTP2C_DeleteSessionReq(template (present) OCT4 d_teid,
                          template (present) OCT3 seq := ?,
-                         template (omit) OCT1 cause,
+                         template (omit) GTP2C_Cause cause,
                          template (present) FullyQualifiedTEID sender_fteid,
                          template FullyQualifiedTEID_List teid_list,
                          template (present) uint4_t bearer_id) :=
@@ -918,7 +939,7 @@
 template (value) PDU_GTPCv2
 ts_GTP2C_DeleteSessionResp(template (value) OCT4 d_teid,
                           template (value) OCT3 seq,
-                          template (value) OCT1 cause) :=
+                          template (value) GTP2C_Cause cause) :=
 ts_PDU_GTP2C(d_teid, '000000'O, '25'O, {
        deleteSessionResponse := {
                cause := ts_GTP2C_Cause(cause, '0'B),
@@ -934,7 +955,7 @@
 template (present) PDU_GTPCv2
 tr_GTP2C_DeleteSessionResp(template (present) OCT4 d_teid,
                           template (present) OCT3 seq := ?,
-                          template (present) OCT1 cause := ?
+                          template (present) GTP2C_Cause cause := ?
                        ) :=
 tr_PDU_GTP2C(d_teid, seq, {
        deleteSessionResponse := {
@@ -993,7 +1014,7 @@
 ts_GTP2C_DeleteBearerReq(template (value) OCT4 d_teid,
                         template (value) integer proc_trans_id,
                         template (value) uint4_t bearer_id,
-                        template (value) OCT1 cause) :=
+                        template (value) GTP2C_Cause cause) :=
 ts_PDU_GTP2C(d_teid, '000000'O, '63'O, {
        deleteBearerRequest := {
                epsBearerIdentity := { ts_GTP2C_EpsBearerId(bearer_id) },
@@ -1014,7 +1035,7 @@
 template (present) PDU_GTPCv2
 tr_GTP2C_DeleteBearerResp(template (present) OCT4 d_teid,
                          template (present) OCT3 seq := ?,
-                         template (present) OCT1 cause := ?) :=
+                         template (present) GTP2C_Cause cause := ?) :=
 tr_PDU_GTP2C(d_teid, seq, {
        deleteBearerResponse := {
                cause := tr_GTP2C_Cause(cause),
diff --git a/pgw/PGW_Tests.ttcn b/pgw/PGW_Tests.ttcn
index 4730040..182147d 100644
--- a/pgw/PGW_Tests.ttcn
+++ b/pgw/PGW_Tests.ttcn
@@ -610,7 +610,7 @@
                as_DIA_Gy_CCR(INITIAL_REQUEST);
        }
        alt {
-       [] GTP2.receive(tr_GTP2C_CreateSessionResp(d_teid:=g_teic, 
cause:='10'O)) -> value rx {
+       [] GTP2.receive(tr_GTP2C_CreateSessionResp(d_teid:=g_teic, 
cause:=Request_accepted)) -> value rx {
                /* extract TEIDs */
                var CreateSessionResponse resp := 
rx.gtpcv2_pdu.createSessionResponse;
                g_teic_remote := resp.fullyQualifiedTEID[0].tEID_GRE_Key;
@@ -655,9 +655,9 @@
 }

 /* delete the session from the PGW */
-private function f_delete_session(template (omit) OCT1 tx_cause := omit,
+private function f_delete_session(template (omit) GTP2C_Cause tx_cause := omit,
                                  template (present) OCT4 exp_teid,
-                                 template (present) OCT1 exp_cause,
+                                 template (present) GTP2C_Cause exp_cause,
                                  boolean expect_diameter := true) runs on 
PGW_Session_CT {
        var template (value) FullyQualifiedTEID fteid_c_ie
        fteid_c_ie := ts_GTP2C_FTEID(FTEID_IF_S5S8_SGW_GTPC, g_teic, 0,
@@ -844,7 +844,7 @@
 /* create a session, then delete it again */
 private function f_TC_createSession_deleteSession() runs on PGW_Session_CT {
        f_create_session();
-       f_delete_session(omit, g_teic, '10'O);
+       f_delete_session(omit, g_teic, Request_accepted);
        setverdict(pass);
 }
 testcase TC_createSession_deleteSession() runs on PGW_Test_CT {
@@ -859,7 +859,7 @@
 private function f_TC_deleteSession_unknown() runs on PGW_Session_CT {
        g_teic := f_gtp2_allocate_teid();
        g_teic_remote := f_rnd_octstring(4);
-       f_delete_session(omit, '00000000'O, '40'O /* Context Unknown */, false);
+       f_delete_session(omit, '00000000'O, Context_Not_Found, false);
        setverdict(pass);
 }
 testcase TC_deleteSession_unknown() runs on PGW_Test_CT {
@@ -890,7 +890,7 @@
        as_DIA_Gy_CCR(UPDATE_REQUEST);
        f_validate_gy_cc_report(g_rx_gy, VALIDITY_TIME, (3..4), ?, ?);

-       f_delete_session(omit, g_teic, '10'O);
+       f_delete_session(omit, g_teic, Request_accepted);
        f_validate_gy_cc_report(g_rx_gy, FINAL, (0..1), 0, 0);
        setverdict(pass);
 }

--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/34877?usp=email
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: Id26f59274d7a8813b64b9b4b7c5c39cc12d5a0ac
Gerrit-Change-Number: 34877
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pes...@sysmocom.de>
Gerrit-MessageType: newchange

Reply via email to