pespin has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/38463?usp=email )

Change subject: library/GTPv1C_Templates: Clean up PCO templates
......................................................................

library/GTPv1C_Templates: Clean up PCO templates

* Define a generic ProtoElem template and use it everywhere.
* User superset instead of "*, tr_..., *" construct.

Change-Id: I005a6dea0606bcb677260f85b24396b55a150153
---
M library/GTPv1C_Templates.ttcn
1 file changed, 35 insertions(+), 33 deletions(-)

Approvals:
  pespin: Looks good to me, approved
  Jenkins Builder: Verified
  fixeria: Looks good to me, but someone else must approve
  osmith: Looks good to me, but someone else must approve




diff --git a/library/GTPv1C_Templates.ttcn b/library/GTPv1C_Templates.ttcn
index 12e2f51..8eae7c0 100644
--- a/library/GTPv1C_Templates.ttcn
+++ b/library/GTPv1C_Templates.ttcn
@@ -1186,6 +1186,26 @@
                                                        sgsn_addr_traffic, qos, 
dtf))
 }

+/********
+ * PCO
+ ********/
+
+template (value) ProtocolElement ts_PCO_Proto(template (value) OCT2 protocolID,
+                                             template (value) integer 
lengthProtoID := 0,
+                                             template (value) octetstring 
protoIDContents := ''O) := {
+       protocolID := protocolID,
+       lengthProtoID := lengthProtoID,
+       protoIDContents := protoIDContents
+}
+
+template (present) ProtocolElement tr_PCO_Proto(template (present) OCT2 
protocolID := ?,
+                                               template (present) integer 
lengthProtoID:= ?,
+                                               template (present) octetstring 
protoIDContents:= ?) := {
+       protocolID := protocolID,
+       lengthProtoID := lengthProtoID,
+       protoIDContents := protoIDContents
+}
+
 /* PCO send base template */
 template (value) ProtConfigOptions ts_PCO := {
        type_gtpc := '84'O,
@@ -1206,23 +1226,18 @@
 }

 template (value) ProtConfigOptions ts_PCO_IPv6_DNS modifies ts_PCO := {
-       protocols := {
-               { protocolID := '0003'O, lengthProtoID := 0, protoIDContents := 
''O }
-       }
+       protocols := { ts_PCO_Proto('0003'O) }
 }
 template (present) ProtConfigOptions tr_PCO_IPv6_DNS_resp(template (present) 
OCT16 contents) modifies tr_PCO := {
-       protocols := {
-               *, { protocolID := '0003'O, lengthProtoID := 16, 
protoIDContents := contents }, *
-       }
+       protocols := superset(tr_PCO_Proto('0003'O, 16, contents))
 }

 template (value) ProtConfigOptions ts_PCO_IPv4_DNS_IPCP(template (value) 
uint8_t ipcp_req_id := 0) modifies ts_PCO := {
        protocols := {
                /* dummy PAP entry to check if our parser in the GGSN can 
properly iterate over
                 * the list of protocols, see Change-Id 
Icc2e6716c33d78d3c3e000f529806228d8aa155e */
-               { protocolID := 'C023'O, lengthProtoID := 0, protoIDContents := 
''O },
-               { protocolID := '8021'O, lengthProtoID := 16, protoIDContents :=
-                                                       
enc_IpcpPacket(valueof(ts_IPCP_ReqDNS(ipcp_req_id))) }
+               ts_PCO_Proto('C023'O),
+               ts_PCO_Proto('8021'O, 16, 
enc_IpcpPacket(valueof(ts_IPCP_ReqDNS(ipcp_req_id))))
        }
 }

@@ -1230,37 +1245,28 @@
        protocols := {
                /* dummy PAP entry to check if our parser can cope with a 
single primary DNS entry
                 * see Change-Id Icffde89f9bc5d8fcadf6e2dd6c0b4de03440edd5 and 
OS#3288 */
-               { protocolID := 'C023'O, lengthProtoID := 0, protoIDContents := 
''O },
-               { protocolID := '8021'O, lengthProtoID := 16, protoIDContents :=
-                                                       
enc_IpcpPacket(valueof(ts_IPCP_ReqDNS_Primary)) }
+               ts_PCO_Proto('C023'O),
+               ts_PCO_Proto('8021'O, 16, 
enc_IpcpPacket(valueof(ts_IPCP_ReqDNS_Primary)))
        }
 }
 template (value) ProtConfigOptions ts_PCO_IPv4_SEC_DNS_IPCP modifies ts_PCO := 
{
        protocols := {
                /* dummy PAP entry to check if our parser can cope with a 
single secondary DNS entry
                 * see Change-Id Icffde89f9bc5d8fcadf6e2dd6c0b4de03440edd5 and 
OS#3288 */
-               { protocolID := 'C023'O, lengthProtoID := 0, protoIDContents := 
''O },
-               { protocolID := '8021'O, lengthProtoID := 16, protoIDContents :=
-                                                       
enc_IpcpPacket(valueof(ts_IPCP_ReqDNS_Secondary)) }
+               ts_PCO_Proto('C023'O),
+               ts_PCO_Proto('8021'O, 16, 
enc_IpcpPacket(valueof(ts_IPCP_ReqDNS_Secondary)))
        }
 }
 template (value) ProtConfigOptions ts_PCO_IPv4_SEPARATE_DNS_IPCP modifies 
ts_PCO := {
        protocols := {
                /* dummy PAP entry to check if our parser can cope with a 
primary and secondary DNS
                 * in separate IPCP containers OS#3381 */
-               { protocolID := 'C023'O, lengthProtoID := 0, protoIDContents := 
''O },
-               { protocolID := '8021'O, lengthProtoID := 16, protoIDContents :=
-                                                       
enc_IpcpPacket(valueof(ts_IPCP_ReqDNS_Primary)) },
-               { protocolID := '8021'O, lengthProtoID := 16, protoIDContents :=
-                                                       
enc_IpcpPacket(valueof(ts_IPCP_ReqDNS_Secondary)) }
+               ts_PCO_Proto('C023'O),
+               ts_PCO_Proto('8021'O, 16, 
enc_IpcpPacket(valueof(ts_IPCP_ReqDNS_Primary))),
+               ts_PCO_Proto('8021'O, 16, 
enc_IpcpPacket(valueof(ts_IPCP_ReqDNS_Secondary)))
        }
 }

-template (present) ProtocolElement tr_PCO_Proto(template (present) OCT2 
prot_id := ?) := {
-       protocolID := prot_id,
-       lengthProtoID := ?,
-       protoIDContents := ?
-}
 template (value) ProtocolElement ts_PCOelem_PAP_broken := {
        protocolID := 'C023'O,
        lengthProtoID := 60,
@@ -1270,22 +1276,18 @@
 template (value) ProtConfigOptions ts_PCO_PAP_IPv4_DNS modifies ts_PCO := {
        protocols := {
                ts_PCOelem_PAP_broken,
-               { protocolID := '8021'O, lengthProtoID := 16, protoIDContents 
:= enc_IpcpPacket(valueof(ts_IPCP_ReqDNS)) }
+               ts_PCO_Proto('8021'O, 16, 
enc_IpcpPacket(valueof(ts_IPCP_ReqDNS)))
        }
 }
 template (present) ProtConfigOptions tr_PCO_Contains(template (present) OCT2 
prot_id) modifies tr_PCO := {
-       protocols := { *, tr_PCO_Proto(prot_id), * }
+       protocols := superset(tr_PCO_Proto(prot_id))
 }

 template (value) ProtConfigOptions ts_PCO_IPv4_DNS_CONT modifies ts_PCO := {
-       protocols := {
-               { protocolID := '000d'O, lengthProtoID := 0, protoIDContents := 
''O }
-       }
+       protocols := { ts_PCO_Proto('000d'O) }
 }
 template (present) ProtConfigOptions tr_PCO_IPv4_DNS_CONT_resp(template 
(present) OCT4 contents) modifies tr_PCO := {
-       protocols := {
-               *, { protocolID := '000d'O, lengthProtoID := 4, protoIDContents 
:= contents }, *
-       }
+       protocols := superset(tr_PCO_Proto('000d'O, 4, contents))
 }

 /* extract a given protocol payload from PCO */

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

Gerrit-MessageType: merged
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I005a6dea0606bcb677260f85b24396b55a150153
Gerrit-Change-Number: 38463
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: osmith <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>

Reply via email to