From 2c7cea8fb6e3a876d05a30c5db99111c920d1958 Mon Sep 17 00:00:00 2001 From: mark Date: Mon, 28 Mar 2022 10:35:38 +0100 Subject: [PATCH 1/9] Bringing into line with SA3LI --- temp.asn | 735 +++++++++++++++++++++++++++++++ testing/asn_compile_targets.json | 33 ++ testing/asn_ignore.txt | 2 + testing/asn_ignore_lint.txt | 1 + testing/asn_process.py | 206 +++++++++ testing/check_asn1.py | 31 -- testing/check_xsd.py | 194 -------- testing/compile_asn.py | 140 ------ testing/dockerfile_asn | 11 + testing/dockerfile_xsd | 10 + testing/merge_test.py | 68 +++ testing/mod1.asn | 22 + testing/mod2.asn | 14 + testing/xsd_compile_targets.json | 7 + testing/xsd_ignore.txt | 3 + testing/xsd_process.py | 152 +++++++ 16 files changed, 1264 insertions(+), 365 deletions(-) create mode 100644 temp.asn create mode 100644 testing/asn_compile_targets.json create mode 100644 testing/asn_ignore.txt create mode 100644 testing/asn_ignore_lint.txt create mode 100644 testing/asn_process.py delete mode 100644 testing/check_asn1.py delete mode 100644 testing/check_xsd.py delete mode 100644 testing/compile_asn.py create mode 100644 testing/dockerfile_asn create mode 100644 testing/dockerfile_xsd create mode 100644 testing/merge_test.py create mode 100644 testing/mod1.asn create mode 100644 testing/mod2.asn create mode 100644 testing/xsd_compile_targets.json create mode 100644 testing/xsd_ignore.txt create mode 100644 testing/xsd_process.py diff --git a/temp.asn b/temp.asn new file mode 100644 index 0000000..6bcd0ce --- /dev/null +++ b/temp.asn @@ -0,0 +1,735 @@ +LI-PS-PDU +{itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulIntercept(2) li-ps(5) genHeader(1) version32(32)} + +DEFINITIONS IMPLICIT TAGS ::= + +BEGIN + +IMPORTS + -- Any of the IMPORTs may be commented out if they are not used (see clause A.3) + + -- from ETSI TS 103 280 [44] + LIID + FROM Common-Parameters + {itu-t(0) identified-organization(4) etsi(0) common-parameters(3280) version231(231)} + + + -- from ETSI TS 101 671 [4] + IRI-Parameters, + IRIsContent, + Location, + Network-Element-Identifier + FROM HI2Operations + {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulIntercept(2) hi2(1) version18(18)} + + -- from ETSI TS 101 671 [4] + HI1-Operation + FROM HI1NotificationOperations + {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulIntercept(2) hi1(0) notificationOperations(1) version7(7)} + + -- from ETSI TS 102 232-2 [5] + EmailCC, + EmailIRI, + MessagingCC, + MessagingMMCC, + MessagingIRI + FROM EmailPDU + {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulIntercept(2) li-ps(5) email(2) version18(18)} + + -- from ETSI TS 102 232-3 [6] + IPCC, + IPIRI, + IPIRIOnly + FROM IPAccessPDU + {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulIntercept(2) li-ps(5) iPAccess(3) version14(14)} + + -- from ETSI TS 102 232-4 [32] + L2CC, + L2IRI, + L2IRIOnly + FROM L2AccessPDU + {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulIntercept(2) li-ps(5) l2Access(4) version7(7)} + + -- from ETSI TS 102 232-5 [37] + IPMMCC, + IPMMIRI + FROM IPMultimediaPDU + {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulIntercept(2) li-ps(5) iPMultimedia(5) version13(13)} + + -- from ETSI TS 102 232-6 [36] + PstnIsdnCC, + PstnIsdnIRI + FROM PstnIsdnPDU + {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulIntercept(2) li-ps(5) pstnIsdn(6) version5(5)} + + -- from 3GPP TS 33.108 [9] + IRI-Parameters, + UmtsIRIsContent, + CorrelationValues, + Location + FROM UmtsHI2Operations + {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulIntercept(2) threeGPP(4) hi2(1)} + -- The relevant module (including the 3GPP release and version number) needs + -- to be chosen when compiling the application. + + -- from 3GPP TS 33.108 [9] + IRI-Parameters, + UmtsCS-IRIsContent + FROM UmtsCS-HI2Operations + {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulIntercept(2) threeGPP(4) hi2CS(3)} + -- The relevant module (including the 3GPP release and version number) needs + -- to be chosen when compiling the application. + + -- from 3GPP TS 33.108 [9] + IRI-Parameters, + EpsIRIsContent, + EPSLocation + FROM EpsHI2Operations + {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulIntercept(2) threeGPP(4) hi2eps(8)} + -- The relevant module (including the 3GPP release and version number) needs + -- to be chosen when compiling the application. + + -- from 3GPP TS 33.108 [9] + IRI-Parameters, + ConfIRIsContent + FROM CONFHI2Operations + {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulIntercept(2) threeGPP(4) hi2conf(10)} + -- The relevant module (including the 3GPP release and version number) needs + -- to be chosen when compiling the application. + + -- from 3GPP TS 33.108 [9] + IRI-Parameters, + ProSeIRIsContent + FROM ProSeHI2Operations + {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulIntercept(2) threeGPP(4) hi2prose (15)} + -- The relevant module (including the 3GPP release and version number) needs + -- to be chosen when compiling the application. + + -- from 3GPP TS 33.108 [9] + IRI-Parameters, + GcseIRIsContent + FROM GCSEHI2Operations + {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulIntercept(2) threeGPP(4) hi2gcse(13)} + -- The relevant module (including the 3GPP release and version number) needs + -- to be chosen when compiling the application. + + -- from 3GPP TS 33.108 [9] + CC-PDU + FROM Umts-HI3-PS + {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulintercept(2) threeGPP(4) hi3(2)} + -- The relevant module (including the 3GPP release and version number) + -- needs to be chosen when compiling the application. + + -- from 3GPP TS 33.108 [9] + CC-PDU + FROM Eps-HI3-PS + {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulintercept(2) threeGPP(4) hi3eps(9)} + -- The relevant module (including the 3GPP release and version number) + -- needs to be chosen when compiling the application. + + -- from 3GPP TS 33.108 [9] + Conf-CC-PDU + FROM CONF-HI3-IMS + {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulintercept(2) threeGPP(4) hi3conf(11)} + -- The relevant module (including the 3GPP release and version number) + -- needs to be chosen when compiling the application. + + -- from 3GPP TS 33.108 [9] + Voip-CC-PDU + FROM VoIP-HI3-IMS + {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulintercept(2) threeGPP(4) hi3voip(12)} + -- The relevant module (including the 3GPP release and version number) + -- needs to be chosen when compiling the application. + + -- from 3GPP TS 33.108 [9] + Gcse-CC-PDU + FROM GCSE-HI3 + {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulintercept(2) threeGPP(4) hi3gcse(14)} + -- The relevant module (including the 3GPP release and version number) + -- needs to be chosen when compiling the application. + + -- from 3GPP TS 33.108 [9] + ThreeGPP-HI1-Operation + FROM ThreeGPP-HI1NotificationOperations + {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulIntercept(2) threeGPP(4) hi1(0) notificationOperations(1)} + -- The relevant module (including the 3GPP release and version number) + -- needs to be chosen when compiling the application. + -- TS 101 671 HI1 and 3GPP HI1 are related to the same functionality but are + -- corresponding to different implementations and exclusive usage each other. + -- The implementation depends of national regulations or LEA/CSP negotiations. + -- 3GPP HI1 may be used with other services/networks than 3GPP's one. + + -- from 3GPP TS 33.108 [9] + CSvoice-CC-PDU + FROM CSvoice-HI3-IP + {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulIntercept(2) threeGPP(4) hi3CSvoice(18)} + -- The relevant module (including the 3GPP release and version number) + -- needs to be chosen when compiling the application. + -- The implementation of the CS domain delivery in IP have to be based on 3GPP TS 33.108 [9]. + + -- from ETSI TS 101 909-20-1 [33] + TARGETACTIVITYMONITOR-1, + TTRAFFIC, + CTTRAFFIC + FROM TS101909201 + {itu-t(0) identified-organization(4) etsi(0) ts101909(1909) part20(20) subpart1(1) interceptVersion(0)} + + -- from ETSI TS 101 909-20-2 [34] + TARGETACTIVITYMONITOR, + TTRAFFIC, + CTTRAFFIC + FROM TS101909202 + {itu-t(0) identified-organization(4) etsi(0) ts101909(1909) part20(20) subpart2(2) interceptVersion(0)} + + -- from ETSI TS 103 462 [45] + ILHIPayload + FROM ILHIPDU + {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) informationHandover(4) ilhi(0) ilhiPdu(0) version2(2)} + -- This import is only used for the handover between LEMFs. + + -- from 3GPP TS 33.128 [46] + LINotificationPayload, + IRIPayload, + CCPayload + FROM TS33128Payloads + {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulIntercept(2) threeGPP(4) ts33128(19)}; + -- The relevant module (including the 3GPP release and version number) + -- needs to be chosen when compiling the application. + +-- end of IMPORTS + +-- ============================= +-- Object Identifier Definitions +-- ============================= + +lawfulInterceptDomainId OBJECT IDENTIFIER ::= {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulIntercept(2)} + +li-psDomainId OBJECT IDENTIFIER ::= {lawfulInterceptDomainId li-ps(5) genHeader(1) version32(32)} + +-- ==================== +-- Top-level definition +-- ==================== + +PS-PDU ::= SEQUENCE +{ + pSHeader [1] PSHeader, + payload [2] Payload +} + +PSHeader ::= SEQUENCE +{ + li-psDomainId [0] OBJECT IDENTIFIER, + lawfulInterceptionIdentifier [1] LawfulInterceptionIdentifier, + -- As of ASN.1 version 26 this parameter is included from ETSI TS 103 280 [44] + authorizationCountryCode [2] PrintableString (SIZE (2)) OPTIONAL, + -- see clause 5.2.3 + communicationIdentifier [3] CommunicationIdentifier, + sequenceNumber [4] INTEGER (0..4294967295), + timeStamp [5] GeneralizedTime OPTIONAL, + -- see clause 5.2.6 + ..., + interceptionPointID [6] PrintableString (SIZE (1..8)) OPTIONAL, + -- see clause 5.2.11 + microSecondTimeStamp [7] MicroSecondTimeStamp OPTIONAL, + timeStampQualifier [8] TimeStampQualifier OPTIONAL, + extendedInterceptionPointID [9] OCTET STRING (SIZE (1..65535)) OPTIONAL, + -- see clause 5.2.13 + networkFunctionIdentifier [10] OCTET STRING (SIZE (1..65535)) OPTIONAL + -- see clause 5.2.14 +} + +Payload ::= CHOICE +{ + iRIPayloadSequence [0] SEQUENCE OF NativeIRIPayload, + cCPayloadSequence [1] SEQUENCE OF NativeCCPayload, + -- Clause 6.2.3 explains how to include more than one payload in the same PDU + tRIPayload [2] TRIPayload, + ..., + hI1-Operation [3] HI1-Operation, + encryptionContainer [4] EncryptionContainer, + threeGPP-HI1-Operation [5] ThreeGPP-HI1-Operation, + -- This structure may be functionally redundant with hI1-Operation from ETSI TS 101 671 [4] + iLHIPayload [6] SEQUENCE OF ILHIPayload, + -- For typical use cases see ETSI TS 103 462 [45] + hI4Payload [7] SEQUENCE OF HI4Payload +} + +TimeStampQualifier ::= ENUMERATED +{ + unknown(0), + timeOfInterception(1), + timeOfMediation(2), + ..., + timeOfAggregation(3) +} + +HI4Payload ::= CHOICE +{ + threeGPP-LI-Notification [1] TS33128Payloads.LINotificationPayload, + ... +} + +-- ==================================== +-- Items contained within the PS-Header +-- ==================================== + +CommunicationIdentifier ::= SEQUENCE +{ + networkIdentifier [0] NetworkIdentifier, + communicationIdentityNumber [1] INTEGER (0..4294967295) OPTIONAL, + -- in case of transport of HI1 messages not required + -- Mandatory for CC and IRI, with certain exceptions (see clause 5.2.4) + deliveryCountryCode [2] PrintableString (SIZE (2)) OPTIONAL, + -- see clause 5.2.4 + ..., + cINExtension [3] CorrelationValues OPTIONAL + -- To be used when a single INTEGER is not sufficient to identify + -- a particular session (see clause 5.2.4) +} + +NetworkIdentifier ::= SEQUENCE +{ + operatorIdentifier [0] OCTET STRING (SIZE(1..16)), + networkElementIdentifier [1] OCTET STRING (SIZE(1..16)) OPTIONAL, + ..., + eTSI671NEID [2] Network-Element-Identifier OPTIONAL + -- For network element identifier, use either networkElementIdentifier or eTSI671NEID +} + +-- ========================== +-- Definitions for CC Payload +-- ========================== + +NativeCCPayload ::= SEQUENCE +{ + payloadDirection [0] PayloadDirection OPTIONAL, + timeStamp [1] GeneralizedTime OPTIONAL, + -- For aggregated payloads (see clause 6.2.3) + cCContents [2] CCContents, + ..., + microSecondTimeStamp [3] MicroSecondTimeStamp OPTIONAL, + -- For aggregated payloads (see clause 6.2.3) + timeStampQualifier [4] TimeStampQualifier OPTIONAL +} + +PayloadDirection ::= ENUMERATED +{ + fromTarget(0), + toTarget(1), + ..., + indeterminate(2), + -- Indication that the direction was indeterminate + combined(3), + -- Indication applicable to some services that the traffic is actually a combination + -- of To and From + notapplicable(4) + -- Indication that direction of interceptable service does not make sense +} + +CCContents ::= CHOICE + -- Any of these choices may be commented out if they are not being used, see clause A.3 +{ + -- tag [0] deprecated in version15, ETSI TS 102 232-1 V3.3.1 (2013-02) + emailCC [1] EmailCC, + iPCC [2] IPCC, + -- tag [3] not used + uMTSCC [4] OCTET STRING, + ..., + -- tag [5] deprecated in version15, ETSI TS 102 232-1 V3.3.1 (2013-02) + l2CC [6] L2CC, + tTRAFFIC-1 [7] TS101909201.TTRAFFIC, + cTTRAFFIC-1 [8] TS101909201.CTTRAFFIC, + tTRAFFIC-2 [9] TS101909202.TTRAFFIC, + cTTRAFFIC-2 [10] TS101909202.CTTRAFFIC, + pstnIsdnCC [11] PstnIsdnCC, + iPMMCC [12] IPMMCC, + -- tag [13] deprecated in version32, ETSI TS 102 232-1 V3.24.1 (2021-07) + messagingCC [14] MessagingCC, + ePSCC [15] OCTET STRING, + uMTSCC-CC-PDU [16] Umts-HI3-PS.CC-PDU, + ePSCC-CC-PDU [17] Eps-HI3-PS.CC-PDU, + messagingMMCC [18] MessagingMMCC, + confCC-CC-PDU [19] CONF-HI3-IMS.Conf-CC-PDU, + voipCC-CC-PDU [20] VoIP-HI3-IMS.Voip-CC-PDU, + gcseCC-CC-PDU [21] GCSE-HI3.Gcse-CC-PDU, + cSvoice-CC-PDU [22] CSvoice-HI3-IP.CSvoice-CC-PDU, + threeGPP33128DefinedCC [23] OCTET STRING (CONTAINING TS33128Payloads.CCPayload) +} + +MicroSecondTimeStamp ::= SEQUENCE +{ + seconds [0] INTEGER (0..18446744073709551615), + -- number of seconds since 1970-1-1 00:00Z also known as unix time epoch + microSeconds [1] INTEGER (0..999999), + ... +} + +-- =========================== +-- Definitions for IRI Payload +-- =========================== + +NativeIRIPayload ::= SEQUENCE +{ + iRIType [0] IRIType OPTIONAL, + -- See clause 5.2.10 + timeStamp [1] GeneralizedTime OPTIONAL, + -- For aggregated payloads (see clause 6.2.3) + iRIContents [2] IRIContents, + ..., + microSecondTimeStamp [3] MicroSecondTimeStamp OPTIONAL, + -- For aggregated payloads (see clause 6.2.3) + timeStampQualifier [4] TimeStampQualifier OPTIONAL, + sessionDirection [5] PayloadDirection OPTIONAL, + -- If the sessionDirection field is to be used for a given service then + -- the exact meaning and use of the field will be described in the + -- relevant service-specific details + payloadDirection [6] PayloadDirection OPTIONAL + -- If the payloadDirection field is to be used for a given service then + -- the exact meaning and use of the field will be described in the + -- relevant service-specific details +} + +IRIType ::= ENUMERATED +{ + iRI-Begin(1), + iRI-End(2), + iRI-Continue(3), + iRI-Report(4) +} + +IRIContents ::= CHOICE + -- Any of these choices may be commented out if they are not being used (see clause A.3) +{ + -- tag [0] deprecated in version15, ETSI TS 102 232-1 V3.3.1 (2013-02) + emailIRI [1] EmailIRI, + iPIRI [2] IPIRI, + iPIRIOnly [3] IPIRIOnly, + uMTSIRI [4] UMTSIRI, + eTSI671IRI [5] ETSI671IRI, + ..., + l2IRI [6] L2IRI, + l2IRIOnly [7] L2IRIOnly, + tARGETACTIVITYMONITOR-1 [8] TS101909201.TARGETACTIVITYMONITOR-1, + tARGETACTIVITYMONITOR-2 [9] TS101909202.TARGETACTIVITYMONITOR, + pstnIsdnIRI [10] PstnIsdnIRI, + iPMMIRI [11] IPMMIRI, + -- tag [12] deprecated in version32, ETSI TS 102 232-1 V3.24.1 (2021-07) + -- tag [13] deprecated in version32, ETSI TS 102 232-1 V3.24.1 (2021-07) + messagingIRI [14] MessagingIRI, + ePSIRI [15] EPSIRI, + confIRI [16] ConfIRI, + proseIRI [17] ProSeIRI, + gcseIRI [18] GcseIRI, + threeGPP33128DefinedIRI [19] OCTET STRING (CONTAINING TS33128Payloads.IRIPayload) +} + +UMTSIRI ::= CHOICE + -- This structure may be commented out if not used +{ + iRI-Parameters [0] UmtsHI2Operations.IRI-Parameters, + umtsIRIsContent [1] UmtsIRIsContent, + ..., + iRI-CS-Parameters [2] UmtsCS-HI2Operations.IRI-Parameters, + umtsCS-IRIsContent [3] UmtsCS-IRIsContent +} + +ETSI671IRI ::= CHOICE + -- This structure may be commented out if not used +{ + iRI-Parameters [0] HI2Operations.IRI-Parameters, + iRIsContent [1] IRIsContent, + ... +} + +EPSIRI ::= CHOICE + -- This structure may be commented out if not used +{ + iRI-EPS-Parameters [0] EpsHI2Operations.IRI-Parameters, + epsIRIsContent [1] EpsIRIsContent, + ... +} + +ConfIRI ::= CHOICE + -- This structure may be commented out if not used +{ + iRI-Conf-Parameters [0] CONFHI2Operations.IRI-Parameters, + confIRIsContent [1] ConfIRIsContent, + ... +} + + +ProSeIRI ::= CHOICE + -- This structure may be commented out if not used +{ + iRI-ProSe-Parameters [0] ProSeHI2Operations.IRI-Parameters, + proseIRIsContent [1] ProSeIRIsContent, + ... +} + + +GcseIRI ::= CHOICE + -- This structure may be commented out if not used +{ + iRI-Gcse-Parameters [0] GCSEHI2Operations.IRI-Parameters, + gcseIRIsContent [1] GcseIRIsContent, + ... +} + + +-- =========================== +-- Definitions for TRI Payload +-- =========================== + +TRIPayload ::= CHOICE +{ + integrityCheck [0] IntegrityCheck, + testPDU [1] NULL, + paddingPDU [2] OCTET STRING, + -- Undefined contents (will be discarded) + keep-alive [3] NULL, + keep-aliveResponse [4] NULL, + firstSegmentFlag [5] NULL, + lastSegmentFlag [6] NULL, + ..., + cINReset [7] NULL, + operatorLeaMessage [8] OperatorLeaMessage, + optionRequest [9] OptionRequest, + optionResponse [10] OptionResponse, + optionComplete [11] NULL, + pDUAcknowledgementRequest [12] NULL, + pDUAcknowledgementResponse [13] NULL +} + +IntegrityCheck ::= SEQUENCE +{ + includedSequenceNumbers [0] SEQUENCE OF INTEGER (0..4294967295), + -- gives the order the PDUs were processed + checkType [1] CheckType, + dataType [2] DataType OPTIONAL, + -- From version5(5) the dataType is mandatory for hashes and for signatures + -- (see clause 7.2.3) + checkValue [3] OCTET STRING, + -- Network byte order + -- If checkValue contains a signature, the octet string field space may be + -- used to insert the appropriate ASN.1 DER or BER encoded structure for the + -- DSS/DSA signature as described in IETF RFC 3279 [43], clause 2.2.2. + ..., + hashAlgorithm [4] HashAlgorithm OPTIONAL + -- Clarifies the hash function if checkType is hash(1). + -- If used, it shall be present for each checkType hash(1). +} + +CheckType ::= ENUMERATED +{ + hash(1), + -- hash value + signature(2), + -- DSS/DSA signature + ... +} + +DataType ::= ENUMERATED +{ + iRI(1), + cC(2), + ..., + iLHI(3) +} + +HashAlgorithm ::= ENUMERATED +{ + sHA-1(1), + -- Included for legacy/migration purposes only, not to be used for new implementations + sHA-256(2), + sHA-384(3), + sHA-512(4), + ... +} + +Option ::= CHOICE +{ + pDUAcknowledgement [0] NULL, + ... +} + +OptionRequest ::= SEQUENCE +{ + requestedOptions [0] SEQUENCE OF Option, + ... +} + +OptionResponse ::= SEQUENCE +{ + acceptedOptions [0] SEQUENCE OF Option, + declinedOptions [1] SEQUENCE OF Option, + ... +} + +-- ================================== +-- Definitions for OperatorLeaMessage +-- ================================== + +OperatorLeaMessage ::= SEQUENCE +{ + messagePriority [0] OperatorLeaMessagePriority, + message [1] OCTET STRING (SIZE(1..255)), + ... +} + +OperatorLeaMessagePriority ::= ENUMERATED +{ + error(1), + -- reporting of error conditions that have impact on the quality of the + -- intercepted data + informational(2), + -- reporting of conditions that will not have direct impact on the quality of + -- the intercepted data + ... +} + +-- =================================== +-- Definitions for EncryptionContainer +-- =================================== + +EncryptionContainer ::= SEQUENCE +{ + encryptionType [0] EncryptionType, + encryptedPayload [1] OCTET STRING, + -- once decrypted, it can be interpreted as EncryptedPayload + ..., + encryptedPayloadType [2] EncryptedPayloadType OPTIONAL +} + +EncryptionType ::= ENUMERATED +{ + none(1), + -- No encryption is applied. + national-option(2), + -- Use this option when an encryption scheme is negotiated on a national level + aES-192-CBC(3), + -- The Advanced Encryption Standard using a 192 bit key in CBC mode + aES-256-CBC(4), + -- The Advanced Encryption Standard using a 256 bit key in CBC mode + blowfish-192-CBC(5), + -- Blowfish (www.schneier.com/blowfish.html) using a 192 bit key in CBC mode + blowfish-256-CBC(6), + -- Blowfish using a 256 bit key in CBC mode + threedes-cbc(7), + -- Triple-DES using a 192 bit key in CBC mode + ... +} + +EncryptedPayload ::= SEQUENCE +{ + byteCounter [0] INTEGER (0..18446744073709551615), + -- The sum of the sizes of all PDUs before this PDU. + -- It is initialized with the unixTime (number of seconds since 01-01-1970) + -- multiplied by 2^32 at first use. + -- Where N is sequencenumber of the n-th PDU in transfer, and size(PDU(N)) + -- as defined in annex G: + -- IF N > 0 THEN + -- PDU[N].byteCounter = PDU[N-1].byteCounter + size(PDU[N-1]) + -- ELSE + -- PDU[N].byteCounter = ( unixTime(now) << 32 ) + -- ENDIF + payload [1] Payload, + ... +} + +EncryptedPayloadType ::= ENUMERATED +{ + unknown(1), + part2(2), + -- encrypted payload is ETSI TS 102 232-2 [5] + part3(3), + -- encrypted payload is ETSI TS 102 232-3 [6] + part4(4), + -- encrypted payload is ETSI TS 102 232-4 [32] + part5(5), + -- encrypted payload is ETSI TS 102 232-5 [37] + part6(6), + -- encrypted payload is ETSI TS 102 232-6 [36] + part7(7), + -- encrypted payload is ETSI TS 102 232-7 [38] + ..., + part1(8) + -- encrypted payload is ETSI TS 102 232-1 (the present document) +} + +-- =================================== +-- Common Parameters +-- =================================== + +NativeLocation ::= SEQUENCE + -- This is a common parameter, the use of this parameter is described in clause 4.5 +{ + umtsHI2Location [0] UmtsHI2Operations.Location OPTIONAL, + epsLocation [1] EpsHI2Operations.EPSLocation OPTIONAL, + ..., + wlanLocationAttributes [2] WlanLocationAttributes OPTIONAL, + eTSI671HI2Location [3] HI2Operations.Location OPTIONAL +} + +WlanLocationAttributes ::= SEQUENCE +{ + wlanAPMACAddress [0] OCTET STRING (SIZE(6)) OPTIONAL, + -- 48-bit (6 octet) MAC address of the WLAN access point derived from the BSSID + ... +} + +IPAddress ::= SEQUENCE + -- This parameter was previously imported from ETSI TS 101 671 [4] but has been copied + -- to ETSI TS 102 232-1 (the present document). It is not recommended to use this parameter in + -- future change requests. Suggested approach is to use a parameter from ETSI TS 103 280 [44] + -- instead. +{ + iP-type [1] ENUMERATED + { + iPV4(0), + iPV6(1), + ... + }, + iP-value [2] IP-value, + iP-assignment [3] ENUMERATED + { + static(1), + -- The static coding shall be used to report a static address. + dynamic(2), + -- The dynamic coding shall be used to report a dynamically allocated address. + notKnown(3), + -- The notKnown coding shall be used to report other than static or dynamically + -- allocated IP addresses. + ... + } OPTIONAL, + ..., + iPv6PrefixLength [4] INTEGER (1..128) OPTIONAL, + -- Indicates the length of the prefix delegated by the CSP to the subscriber + -- example: 60 if IP address is "2001:db8:0:85a3::ac1f:8001/60" + -- Mandatory in case where the iP-value contains an IPv6 binary value + iPv4SubnetMask [5] OCTET STRING (SIZE(4)) OPTIONAL + -- For IPv4 addresses, this indicates the subnet mask to be applied to the iP-value field. + -- The subnet mask is intended to be presented as a binary value, e.g. "ff ff ff f8" to + -- represent the dotted-decimal subnet mask of "255.255.255.248" corresponding to + -- a /29 CIDR-format subnet mask +} + +IP-value ::= CHOICE +{ + iPBinaryAddress [1] OCTET STRING (SIZE(4..16)), + -- In case of IPv6, the Prefix Length is provided by the "iPv6PrefixLength" + -- In case of IPv4, the netmask is provided by the "iPv4SubnetMask" + iPTextAddress [2] IA5String (SIZE(7..45)), + -- In case of IPv6, the delivered iPTextAddress field could include a complete + -- single IPv6-Address or an IPv6-Prefix for a subnetwork on the target side. + -- In case of IPv4, the delivered iPTextAddress field could include a single + -- IPv4 address or an IPv4address/netmask, for example "192.168.1.1" or "192.168.1.1/24" + ... +} + +LawfulInterceptionIdentifier ::= LIID + -- LIID is a common parameter imported from ETSI TS 103 280 [44]. + -- It is redefined as LawfulInterceptionIdentifier in this + -- module to preserve the original type name during the + -- removal of imports from ETSI TS 101 671 [4]. + +END --end of LI-PS-PDU \ No newline at end of file diff --git a/testing/asn_compile_targets.json b/testing/asn_compile_targets.json new file mode 100644 index 0000000..e186add --- /dev/null +++ b/testing/asn_compile_targets.json @@ -0,0 +1,33 @@ +[ + [ + "./102232-1/LI-PS-PDU.asn", + "./103280/TS_103_280.asn1", + "./testing/deps/33128/TS33128Payloads.asn", + "./testing/deps/33108/Three3gppHI1Notifications.asn", + "./testing/deps/33108/UMTSHI2Operations.asn", + "./testing/deps/33108/UMTSHI3PS.asn", + "./testing/deps/33108/EpsHI3PS.asn", + "./testing/deps/33108/ConfHI3IMS.asn", + "./testing/deps/33108/VoipHI3IMS.asn", + "./testing/deps/33108/GCSEHI3.asn", + "./testing/deps/33108/CSVoiceHI3IP.asn", + "./testing/deps/33108/UMTSCSHI2Operations.asn", + "./testing/deps/33108/EpsHI2Operations.asn", + "./testing/deps/33108/ConfHI2Operations.asn", + "./testing/deps/33108/ProSeHI2Operations.asn", + "./testing/deps/33108/GCSEHI2Operations.asn", + "./testing/deps/101671/HI1NotificationOperations,ver7.asn", + "./testing/deps/101671/HI2Operations,ver18.asn", + "./testing/deps/101909/TS101909201.asn", + "./testing/deps/101909/TS101909202.asn", + "./testing/deps/101909/PCESP.asn", + "./testing/deps/301040/06132v203_C01.asn", + "./103462/ILHIPDU.asn", + "./102232-2/EmailPDU.asn", + "./102232-3/IPAccessPDU.asn", + "./102232-4/L2AccessPDU.asn", + "./102232-5/IPMultimediaPDU.asn", + "./102232-6/PstnIsdnPDU.asn" + ], + ["./102657/RDMessage.asn"] +] \ No newline at end of file diff --git a/testing/asn_ignore.txt b/testing/asn_ignore.txt new file mode 100644 index 0000000..2d81d20 --- /dev/null +++ b/testing/asn_ignore.txt @@ -0,0 +1,2 @@ +deps +temp \ No newline at end of file diff --git a/testing/asn_ignore_lint.txt b/testing/asn_ignore_lint.txt new file mode 100644 index 0000000..03e7f54 --- /dev/null +++ b/testing/asn_ignore_lint.txt @@ -0,0 +1 @@ +dependencies \ No newline at end of file diff --git a/testing/asn_process.py b/testing/asn_process.py new file mode 100644 index 0000000..aa0a0a6 --- /dev/null +++ b/testing/asn_process.py @@ -0,0 +1,206 @@ +import logging +import json +from pathlib import Path +from subprocess import run +from re import sub + +from pycrate_asn1c.asnproc import * + +def reconstrainInteger (filename): + Path('temp.asn').write_text(Path(filename).read_text().replace("18446744073709551615", "65536")) + return 'temp.asn' + +filesWithBigInts = [ + '102232-1/LI-PS-PDU.asn', + '102232-3/IPAccessPDU.asn', + '102232-4/L2AccessPDU.asn' +] + +def syntaxCheckASN (fileList): + """ + Performs ASN syntax checking on a list of filenames (or pathlib Paths) + + :param fileList: List of filenames (str or Pathlib Path) + :returns: Dict with result, return code and message for each filename + + Calls the open-source asn1c compiler with the "syntax only" option. + As a result, asn1c must be available to run. + """ + results = {} + for file in fileList: + try: + if file.as_posix() in filesWithBigInts: + newFile = reconstrainInteger(str(file)) + p = run(['asn1c', '-E', newFile], capture_output=True) + Path(newFile).unlink() + else: + p = run(['asn1c', '-E', str(file)], capture_output=True) + if (p.returncode != 0): + errorMessage = p.stderr.decode().splitlines()[0] + if errorMessage.startswith(' Value "18446744073709551615" at line'): + results[str(file)] = { 'ok' : True} + continue + results[str(file)] = { + 'ok' : False, + 'code' : p.returncode, + 'message' : p.stderr.decode().splitlines()[0] + } + else: + results[str(file)] = { + 'ok' : True + } + except Exception as ex: + results[str(file)] = { + 'ok' : False, + 'code' : -1, + 'message' : f"{ex!r}" + } + return results + + +duplicateObjects = { + '102232-1/LI-PS-PDU.asn' : [ + 'CCPayload', + 'IRIPayload', + 'Location' + ], + 'testing/mod1.asn' : [ + 'ClashField' + ] +} +def fixDuplicateObjects(filename): + stringContent = filename.read_text() + for object in duplicateObjects[filename.as_posix()]: + stringContent = stringContent.replace(f'{object} ::=', f'Native{object} ::=') + stringContent = stringContent.replace(f'SEQUENCE OF {object}', f'SEQUENCE OF Native{object}') + #stringContent = sub(f"]\\w{object}", f"] Native{object}", stringContent) + + Path('temp.asn').write_text(stringContent) + return 'temp.asn' + + +def compileAllTargets (compileTargets): + """ + Attempts to compile a set of compile targets using the pycrate ASN1 tools + + :param compileTargets: list of compile targets, each of which is a list of filenames + :returns: A dict of outcome against the first filename of each compile target. Return code and message are included for failures. + + For each compile target (list of filenames) the first filename is assumed + to be the "primary" file. This doesn't have any relavance to the compilation, + but will be used as the identifier when reporting any compile errors. + The compilation is performed by the pycrate ASN compile functions; errors + are caught as exceptions and rendered into a list. + + Unfortunately, the pycrate compiler doesn't report line numbers. + The asn1c compiler does, but doesn't properly handle identifiers with the + same name in different modules; as this occurs multiple times in TS 33.108, + we can't use it. + """ + results = {} + for target in compileTargets: + firstTarget = target[0] + logging.debug(f"Compiling {firstTarget}") + try: + fileTexts = [] + fileNames = [] + GLOBAL.clear() + for filename in target: + pFile = Path(filename) + if pFile.as_posix() in duplicateObjects: + tmpFile = Path(fixDuplicateObjects(pFile)) + fileTexts.append(tmpFile.read_text()) + #tmpFile.unlink() + else: + fileTexts.append(pFile.read_text()) + fileNames.append(filename) + logging.debug (f" Loading {filename}") + compile_text(fileTexts, filenames = fileNames) + results[str(firstTarget)] = { + 'ok' : True, + } + except Exception as ex: + results[str(firstTarget)] = { + 'ok' : False, + 'code' : -1, + 'message' : f"{ex!r}" + } + continue + return results + + + +def processResults (results, stageName): + """ + Counts the number of errors and writes out the output per filename + + :param results: List of filenames (str or Pathlib Path) + :param stageName: Name to decorate the output with + :returns: The number of files which had errors + """ + print("") + errorCount = sum([1 for r in results.values() if not r['ok']]) + logging.info(f"{errorCount} {stageName} errors encountered") + + print(f"{'-':-<60}") + print(f"{stageName} results:") + print(f"{'-':-<60}") + for filename, result in results.items(): + print(f" {filename:.<55}{'..OK' if result['ok'] else 'FAIL'}") + if not result['ok']: + if isinstance(result['message'], list): + for thing in result['message']: + print(f" {thing['message']}") + else: + print(f" {result['message']}") + + print(f"{'-':-<60}") + print(f"{stageName} errors: {errorCount}") + print(f"{'-':-<60}") + + return errorCount + + +if __name__ == '__main__': + logging.info('Searching for ASN.1 files') + fileList = list(Path(".").rglob("*.asn1")) + list(Path(".").rglob("*.asn")) + logging.info(f'{len(fileList)} ASN.1 files found') + for file in fileList: + logging.debug(f' {file}') + + ignoreList = Path('testing/asn_ignore.txt').read_text().splitlines() + ignoredFiles = [] + for ignore in ignoreList: + logging.debug(f'Ignoring pattern {ignore}') + for file in fileList: + if ignore in str(file): + ignoredFiles.append(file) + logging.debug(f" Ignoring {str(file)} as contains {ignore}") + ignoredFiles = list(set(ignoredFiles)) + logging.info(f'{len(ignoredFiles)} files ignored') + for file in ignoredFiles: + logging.debug(f' {file}') + + fileList = [file for file in fileList if file not in ignoredFiles] + logging.info(f'{len(fileList)} files to process') + for file in fileList: + logging.debug(f' {file}') + + if len(fileList) == 0: + logging.warning ("No files specified") + exit(0) + + logging.info("Parsing ASN1 files") + parseResults = syntaxCheckASN(fileList) + if processResults(parseResults, "Parsing") > 0: + exit(-1) + + logging.info ("Getting compile targets") + compileTargets = json.loads(Path('testing/asn_compile_targets.json').read_text()) + logging.info (f"{len(compileTargets)} compile targets found") + + compileResults = compileAllTargets(compileTargets) + if processResults(compileResults, "Compiling") > 0: + exit(-1) + + exit(0) diff --git a/testing/check_asn1.py b/testing/check_asn1.py deleted file mode 100644 index c87a226..0000000 --- a/testing/check_asn1.py +++ /dev/null @@ -1,31 +0,0 @@ -import logging -from compile_asn import * - - -if __name__ == '__main__': - log = logging.getLogger() - log.setLevel(logging.INFO) - parseErrors, compileErrors, parser = validateAllASN1FilesInPath("./") - parseErrorCount = 0 - print ("ASN.1 Parser checks:") - print ("-----------------------------") - for filename, errors in parseErrors.items(): - if len(errors) > 0: - parseErrorCount += len(errors) - print (f"{filename}: {len(errors)} errors") - for error in errors: - print (" " + str(error)) - else: - print (f"{filename}: OK") - print ("-----------------------------") - print ("ASN.1 Compilation:") - print ("-----------------------------") - if len(compileErrors) > 0: - for error in compileErrors: - print (" " + str(error)) - else: - print ("Compilation OK") - print ("-----------------------------") - print (f"{parseErrorCount} parse errors, {len(compileErrors)} compile errors") - exit (parseErrorCount + len(compileErrors)) - diff --git a/testing/check_xsd.py b/testing/check_xsd.py deleted file mode 100644 index 816e389..0000000 --- a/testing/check_xsd.py +++ /dev/null @@ -1,194 +0,0 @@ -import logging - -import glob -import sys -import argparse -from pathlib import Path -from pprint import pprint -import os - -from lxml import etree -from xml.etree.ElementTree import ParseError -from xmlschema import XMLSchema, XMLSchemaParseError - -def BuildSchemaDictonary (fileList): - if len(fileList) == 0: - logging.info("No schema files provided") - return [] - - logging.info("Schema locations:") - schemaLocations = [] - for schemaFile in fileList: - try: - xs = XMLSchema(schemaFile, validation='skip') - schemaLocations.append((xs.target_namespace, str(Path(schemaFile).resolve()))) - logging.info(" [ {0} -> {1} ]".format(xs.default_namespace, schemaFile)) - except ParseError as ex: - logging.warning (" [ {0} failed to parse: {1} ]".format(schemaFile, ex)) - return schemaLocations - - -def BuildSchema (coreFile, fileList = None): - schemaLocations = [] - if fileList and len(fileList) > 0: - schemaLocations = BuildSchemaDictonary(fileList) - - coreSchema = XMLSchema(str(Path(coreFile)), locations=schemaLocations) - return coreSchema - -def ValidateSingleFile (schemaFile): - try: - xs = XMLSchema(schemaFile, validation='skip') - except ParseError as ex: - logging.warning (" [ {0} failed to parse: {1} ]".format(schemaFile, ex)) - return ex - return None - - -def ValidateXSDFiles (fileList): - if len(fileList) == 0: - logging.info("No schema files provided") - return {} - - schemaLocations = BuildSchemaDictonary(fileList) - errors = {} - schemaDictionary = {} - - logging.info("Schema validation:") - for schemaFile in fileList: - try: - schema = XMLSchema(schemaFile, locations = schemaLocations) - logging.info(schemaFile + ": OK") - errors[schemaFile] = [] - schemaDictionary[schema.target_namespace] = schema - except XMLSchemaParseError as ex: - if (ex.schema_url) and (ex.schema_url != ex.origin_url): - logging.info(" Error {1} comes from {0}, suppressing".format(ex.schema_url, ex.message)) - errors[schemaFile] = [] - else: - logging.warning(schemaFile + ": Failed validation ({0})".format(ex)) - errors[schemaFile] = [ex.message] - return errors, schemaDictionary - - -def ValidateInstanceDocuments (coreFile, supportingSchemas, instanceDocs): - if (instanceDocs is None) or len(instanceDocs) == 0: - logging.warning ("No instance documents provided") - return [] - - schema = BuildSchema(coreFile, supportingSchemas) - errors = [] - for instanceDoc in instanceDocs: - try: - schema.validate(instanceDoc) - logging.info ("{0} passed validation".format(instanceDoc)) - except Exception as ex: - logging.error ("{0} failed validation: {1}".format(instanceDoc, ex)) - return errors - - - -if __name__ == '__main__': - parser = argparse.ArgumentParser() - parser.add_argument("-v", "--verbosity", help="verbosity level", action="count", default=0) - parser.add_argument("input", help="include a directory or file", action="append", nargs="+") - parser.add_argument("-p", "--primaryNamespace", help="Primary schema namespace for instance doc validation") - args = parser.parse_args() - - logging.getLogger().setLevel(logging.WARNING) - if (args.verbosity >= 1): - logging.getLogger().setLevel(logging.INFO) - if (args.verbosity >= 2): - logging.getLogger().setLevel(logging.DEBUG) - logging.debug("Very verbose selected") - - - logging.debug(f"Path: {args.input}") - includeFileList = [] - includeInstanceDocList = [] - for path in args.input[0]: - p = Path(path) - if not p.exists(): - logging.error(f"Include path {path} not found") - exit(1) - if p.is_dir(): - logging.debug(f"Expanding directory") - for g in glob.glob(os.path.join(str(p), "*.xsd")): - logging.info(f">Including {g}") - includeFileList.append(g) - for g in glob.glob(os.path.join(str(p), "*.xml")): - logging.info(f">Including instance doc {g}") - includeInstanceDocList.append(g) - else: - logging.info(f">Including {p.absolute()}") - if str(p.absolute()).endswith('.xml'): - includeInstanceDocList.append(str(p.absolute())) - elif str(p.absolute()).endswith('.xsd'): - includeFileList.append(str(p.absolute())) - else: - logging.warning(f'Ignoring file {p.absolute()}') - - if len(includeInstanceDocList) and (args.primaryNamespace is None): - print("Cannot validate instance documents without specifying a primary namespace (use -h for usage guidelines)") - exit(-1) - - syntaxErrors = 0 - - print ("=============================") - print ("XSD syntax checks:") - print ("-----------------------------") - for file in includeFileList: - error = ValidateSingleFile(file) - if (error): - print (f" {file} : Syntax error [{error}]") - syntaxErrors += 1 - else: - print (f" {file} : OK") - - print ("-----------------------------") - if (syntaxErrors > 0): - print (f"{syntaxErrors} syntax errors detected") - exit(syntaxErrors) - else: - print ("0 syntax errors detected") - - results, schemaDict = ValidateXSDFiles(includeFileList) - - print ("=============================") - print ("XSD build checks:") - print ("-----------------------------") - errorCount = 0 - for fileName, errors in results.items(): - if len(errors) > 0: - errorCount += len(errors) - print (f" {fileName}: {len(errors)} errors") - for error in errors: - if isinstance(error, XMLSchemaParseError): - print (error.msg) - else: - print (f" {str(error.strip())}") - else: - print (f" {fileName}: OK") - - print ("-----------------------------") - print (f"{errorCount} build errors detected") - if (errorCount > 0): - exit(errorCount) - - print ("=============================") - print ("Instance document checks") - print ("-----------------------------") - errorCount = 0 - - primarySchema = schemaDict[args.primaryNamespace] - for instanceDoc in includeInstanceDocList: - try: - results = primarySchema.validate(instanceDoc) - print (f" {instanceDoc} : OK") - except Exception as ex: - errorCount += 1 - print (f" {instanceDoc} : {str(ex)}") - print ("-----------------------------") - print (f"{errorCount} instance doc errors detected") - print ("=============================") - exit(errorCount) diff --git a/testing/compile_asn.py b/testing/compile_asn.py deleted file mode 100644 index e291e42..0000000 --- a/testing/compile_asn.py +++ /dev/null @@ -1,140 +0,0 @@ -import logging -import copy -from asn1tools import parse_files, compile_dict, ParseError, CompileError -from glob import glob -from pathlib import Path -from pprint import pprint - -def parseASN1File (asnFile): - try: - parse_files(asnFile) - except ParseError as ex: - return [ex] - return [] - - -def parseASN1Files (fileList): - if len(fileList) == 0: - logging.warning ("No files specified") - return {} - errors = {} - logging.info("Parsing files...") - for f in fileList: - ex = parseASN1File(f) - if ex: - logging.info (f" {f}: Failed - {ex!r}") - else: - logging.info (f" {f}: OK") - errors[f] = ex - return errors - -def fixDottedReference (dict, importingModule, importingType, importingMember, importedModule, importedType): - newName = importedModule + "_" + importedType - dict[importedModule]['types'][newName] = copy.deepcopy(dict[importedModule]['types'][importedType]) - dict[importingModule]['imports'][importedModule].append(newName) - member = [x for x in dict[importingModule]['types'][importingType]['members'] if x is not None and x['name'] == importingMember][0] - member['type'] = newName - -def compileASN1Files (fileList): - logging.info("Compiling files...") - errors = [] - imports = {} - - #p = re.compile(r"]\s+\S+\.\S+") - #for f in fileList: - # with open(f) as fh: - # s = fh.read() - # for match in p.findall(s): - # print (f"In {f}: {match}") - #exit() - - try: - dr = parse_files(fileList) - for modulename, module in dr.items(): - # Weird fix because the compiler doesn't like RELATIVE-OID as a type - # Not sure if the on-the-wire encoding would be affected or not - # but for most checking purposes this doesn't matter - module['types']["RELATIVE-OID"] = {'type' : 'OBJECT IDENTIFIER'} - for k,v in module['imports'].items(): - if not k in imports: - imports[k] = [] - imports[k].append({ - "in" : modulename, - "types" : v - }) - for k,v in imports.items(): - if not k in dr.keys(): - importers = [i['in'] for i in v] - errors.append(f"Unsatisfied import [{k}] for {importers}") - - fixDottedReference(dr, 'LI-PS-PDU', 'Location', 'umtsHI2Location', 'UmtsHI2Operations', 'Location') - fixDottedReference(dr, 'LI-PS-PDU', 'Location', 'epsLocation', 'EpsHI2Operations', 'Location') - fixDottedReference(dr, 'LI-PS-PDU', 'Location', 'eTSI671HI2Location', 'HI2Operations', 'Location') - - fixDottedReference(dr, 'LI-PS-PDU', 'UMTSIRI', 'iRI-Parameters', 'UmtsHI2Operations', 'IRI-Parameters') - fixDottedReference(dr, 'LI-PS-PDU', 'UMTSIRI', 'iRI-CS-Parameters', 'UmtsCS-HI2Operations', 'IRI-Parameters') - fixDottedReference(dr, 'LI-PS-PDU', 'ETSI671IRI', 'iRI-Parameters', 'HI2Operations', 'IRI-Parameters') - fixDottedReference(dr, 'LI-PS-PDU', 'EPSIRI', 'iRI-EPS-Parameters', 'EpsHI2Operations', 'IRI-Parameters') - fixDottedReference(dr, 'LI-PS-PDU', 'ConfIRI', 'iRI-Conf-Parameters', 'CONFHI2Operations', 'IRI-Parameters') - fixDottedReference(dr, 'LI-PS-PDU', 'ProSeIRI', 'iRI-ProSe-Parameters', 'ProSeHI2Operations', 'IRI-Parameters') - fixDottedReference(dr, 'LI-PS-PDU', 'GcseIRI', 'iRI-Gcse-Parameters', 'GCSEHI2Operations', 'IRI-Parameters') - - fixDottedReference(dr, 'LI-PS-PDU', 'CCContents', 'tTRAFFIC-1', 'TS101909201', 'TTRAFFIC') - fixDottedReference(dr, 'LI-PS-PDU', 'CCContents', 'cTTRAFFIC-1', 'TS101909201', 'CTTRAFFIC') - fixDottedReference(dr, 'LI-PS-PDU', 'CCContents', 'tTRAFFIC-2', 'TS101909202', 'TTRAFFIC') - fixDottedReference(dr, 'LI-PS-PDU', 'CCContents', 'cTTRAFFIC-2', 'TS101909202', 'CTTRAFFIC') - #fixDottedReference(dr, 'LI-PS-PDU', 'CCContents', 'cCIPPacketHeader', 'CDMA2000CCModule', 'CCIPPacketHeader') - fixDottedReference(dr, 'LI-PS-PDU', 'CCContents', 'uMTSCC-CC-PDU', 'Umts-HI3-PS', 'CC-PDU') - fixDottedReference(dr, 'LI-PS-PDU', 'CCContents', 'ePSCC-CC-PDU', 'Eps-HI3-PS', 'CC-PDU') - fixDottedReference(dr, 'LI-PS-PDU', 'CCContents', 'confCC-CC-PDU', 'CONF-HI3-IMS', 'Conf-CC-PDU') - fixDottedReference(dr, 'LI-PS-PDU', 'CCContents', 'voipCC-CC-PDU', 'VoIP-HI3-IMS', 'Voip-CC-PDU') - fixDottedReference(dr, 'LI-PS-PDU', 'CCContents', 'gcseCC-CC-PDU', 'GCSE-HI3', 'Gcse-CC-PDU') - fixDottedReference(dr, 'LI-PS-PDU', 'CCContents', 'cSvoice-CC-PDU', 'CSvoice-HI3-IP', 'CSvoice-CC-PDU') - - fixDottedReference(dr, 'LI-PS-PDU', 'IRIContents', 'tARGETACTIVITYMONITOR-1', 'TS101909201', 'TARGETACTIVITYMONITOR-1') - fixDottedReference(dr, 'LI-PS-PDU', 'IRIContents', 'tARGETACTIVITYMONITOR-2', 'TS101909202', 'TARGETACTIVITYMONITOR') - #fixDottedReference(dr, 'LI-PS-PDU', 'IRIContents', 'lAESProtocol', 'Laesp-j-std-025-b', 'LAESProtocol') - #fixDottedReference(dr, 'LI-PS-PDU', 'IRIContents', 'cDMA2000LAESMessage', 'CDMA2000CIIModule', 'CDMA2000LAESMessage') - - fixDottedReference(dr, 'LI-PS-PDU', 'HI4Payload', 'threeGPP-LI-Notification', 'TS33128Payloads', 'LINotificationPayload') - - fixDottedReference(dr, 'ILHIPDU', 'TimestampMapping', 'timeStampQualifier', 'LI-PS-PDU', 'TimeStampQualifier') - - fixDottedReference(dr, 'ILHIPDU', 'ILHITimestamp', 'qualifiedDateTime', 'Common-Parameters', 'QualifiedDateTime') - fixDottedReference(dr, 'ILHIPDU', 'ILHITimestamp', 'qualifiedMicrosecondDateTime', 'Common-Parameters', 'QualifiedMicrosecondDateTime') - - fixDottedReference(dr, 'ILHIPDU', 'OriginalTimestamp', 'microSecondTimeStamp', 'LI-PS-PDU', 'MicroSecondTimeStamp') - - fixDottedReference(dr, 'ILHIPDU', 'LocationMapping', 'originalLocation', 'LI-PS-PDU', 'Location') - - fixDottedReference(dr, 'ILHIPDU', 'GeocodedLocationData', 'wGS84CoordinateDecimal', 'Common-Parameters', 'WGS84CoordinateDecimal') - fixDottedReference(dr, 'ILHIPDU', 'GeocodedLocationData', 'wGS84CoordinateAngular', 'Common-Parameters', 'WGS84CoordinateAngular') - - c = compile_dict(dr) - except CompileError as ex: - logging.info (f"Compiler error: {ex}") - errors.append(ex) - return errors, None - except ParseError as ex: - logging.info (f"Parse error: {ex}") - errors.append(ex) - return errors, None - logging.info ("Compiled OK") - return errors, c - - -def validateASN1Files (fileList): - parseErrors = parseASN1Files(fileList) - errorCount = sum([len(v) for k,v in parseErrors.items()]) - if errorCount > 0: - logging.info ("Abandoning compile due to parse errors") - return parseErrors, [], None - compileErrors, parser = compileASN1Files(fileList) - return parseErrors, compileErrors, parser - - -def validateAllASN1FilesInPath (path): - p = Path(path) - fileGlob = [str(f) for f in p.rglob('*.asn')] - fileGlob += [str(f) for f in p.rglob('*.asn1')] - return validateASN1Files(fileGlob) \ No newline at end of file diff --git a/testing/dockerfile_asn b/testing/dockerfile_asn new file mode 100644 index 0000000..2a4198b --- /dev/null +++ b/testing/dockerfile_asn @@ -0,0 +1,11 @@ +# docker build -t mcanterb/asn1test +# docker push mcanterb/asn1test + +FROM python:3.9-slim-bullseye +RUN apt-get update -y && \ + apt-get install -y asn1c && \ + rm -rf /var/lib/apt/lists/* && \ + pip install --no-cache-dir asn1tools pycrate + + + diff --git a/testing/dockerfile_xsd b/testing/dockerfile_xsd new file mode 100644 index 0000000..9ceeee3 --- /dev/null +++ b/testing/dockerfile_xsd @@ -0,0 +1,10 @@ +# docker build -t mcanterb/xsdtest +# docker push mcanterb/xsdtest + +FROM python:3.9-slim-bullseye +RUN apt-get update -y && \ + rm -rf /var/lib/apt/lists/* && \ + pip install --no-cache-dir lxml xmlschema + + + diff --git a/testing/merge_test.py b/testing/merge_test.py new file mode 100644 index 0000000..b7a82b3 --- /dev/null +++ b/testing/merge_test.py @@ -0,0 +1,68 @@ +import os +import pprint +import requests +import json +import subprocess + +crCommitBranch = os.environ.get("CI_COMMIT_REF_NAME", "NOTFOUND") +apiUrl = os.environ.get("CI_API_V4_URL", "https://forge.3gpp.org/rep/api/v4") +projectId = os.environ.get("CI_PROJECT_ID", "13") + +def gapi (query): + url = f"{apiUrl}/projects/{projectId}/{query}" + r = requests.get(url) + return json.loads(r.text) + +def do (commandline): + #print (" Attempting: " + commandline) + completedProc = subprocess.run(commandline, capture_output=True, shell=True) + #print (" STDOUT > " + ("empty" if completedProc.stdout is None else completedProc.stdout.decode('utf-8'))) + #print (" STDERR > " + ("empty" if completedProc.stderr is None else completedProc.stderr.decode('utf-8'))) + #print (f" Completed with code {completedProc.returncode}") + return (completedProc.returncode == 0, completedProc.stdout.decode('utf-8')) + +print ("Searching for corresponding MR...") + +mrs = gapi(f"merge_requests?source_branch={crCommitBranch}&state=opened") +if len(mrs) == 0: + print ("No MR found... aborting") + exit() + +if len(mrs) > 1: + print (f"{len(mrs)} MRs found, 1 expected - aborting") + for m in mrs: + pprint.pprint(m) + exit(-1) + +mr = mrs[0] + +print (f"Found MR {mr['reference']} ({mr['title']})") +print (f"Target branch is {mr['target_branch']}") +print ("Searching for open MRs targeting same branch...") + +mrs = gapi(f"merge_requests?target_branch={mr['target_branch']}&state=opened") +mrs = [m for m in mrs if m['reference'] != mr['reference']] +print (f"{len(mrs)} MRs found") + +mergeConflicts = {} + +for mr in mrs: + source_branch = mr['source_branch'] + print (source_branch) + + try: + do(f"git fetch origin {source_branch}:{source_branch}") + success, errStr = do(f"git merge --no-commit {source_branch}") + if not success: + print ("Merge NOT OK") + mergeConflicts[source_branch] = errStr + else: + print ("Merge OK") + except Exception as ex: + mergeConflicts[source_branch] = str(ex) + raise + finally: + do("git merge --abort") + +print (f"Merge conflicts with following branches: {mergeConflicts}") +exit(len(mergeConflicts.keys())) \ No newline at end of file diff --git a/testing/mod1.asn b/testing/mod1.asn new file mode 100644 index 0000000..5d4853e --- /dev/null +++ b/testing/mod1.asn @@ -0,0 +1,22 @@ +Mod1 {itu-t(0) identified-organization(4) etsi(0)} + +DEFINITIONS ::= + +BEGIN + +IMPORTS + + ImportedField, + ClashField + FROM Mod2 {itu-t(0) identified-organization(4) etsi(1)}; + +TestPDU ::= SEQUENCE +{ + field1 [1] ClashField +} + +ClashField ::= BOOLEAN + +END + + diff --git a/testing/mod2.asn b/testing/mod2.asn new file mode 100644 index 0000000..cec89b0 --- /dev/null +++ b/testing/mod2.asn @@ -0,0 +1,14 @@ +Mod2 {itu-t(0) identified-organization(4) etsi(1)} + +DEFINITIONS ::= + +BEGIN + +ImportedField ::= SEQUENCE +{ + field2 [0] BOOLEAN +} + +ClashField ::= INTEGER + +END diff --git a/testing/xsd_compile_targets.json b/testing/xsd_compile_targets.json new file mode 100644 index 0000000..fc6e235 --- /dev/null +++ b/testing/xsd_compile_targets.json @@ -0,0 +1,7 @@ +[ + { + "coreSchema" : "RDMessage.xsd", + "supportingSchemas" : [], + "exampleFiles" : [] + } +] \ No newline at end of file diff --git a/testing/xsd_ignore.txt b/testing/xsd_ignore.txt new file mode 100644 index 0000000..90bfe5d --- /dev/null +++ b/testing/xsd_ignore.txt @@ -0,0 +1,3 @@ +deps +portal +temp \ No newline at end of file diff --git a/testing/xsd_process.py b/testing/xsd_process.py new file mode 100644 index 0000000..864b70b --- /dev/null +++ b/testing/xsd_process.py @@ -0,0 +1,152 @@ +import logging +from pathlib import Path + +from xmlschema.etree import etree_tostring +from xmlschema import XMLSchema, XMLSchemaParseError + + +def BuildSchemaDictonary (fileList): + if len(fileList) == 0: + logging.info("No schema files provided") + return [] + + logging.info("Schema locations:") + schemaLocations = [] + for schemaFile in fileList: + try: + xs = XMLSchema(schemaFile, validation='skip') + schemaLocations.append((xs.default_namespace, str(Path(schemaFile).resolve()))) + logging.info(" [ {0} -> {1} ]".format(xs.default_namespace, schemaFile)) + except XMLSchemaParseError as ex: + logging.warning (" [ {0} failed to parse: {1} ]".format(schemaFile, ex)) + return schemaLocations + + +def BuildSchema (coreFile, fileList = None): + schemaLocations = [] + if fileList and len(fileList) > 0: + schemaLocations = BuildSchemaDictonary(fileList) + + coreSchema = XMLSchema(str(Path(coreFile)), locations=schemaLocations) + return coreSchema + + +def ValidateXSDFiles (fileList): + if len(fileList) == 0: + logging.info("No schema files provided") + return {} + + schemaLocations = BuildSchemaDictonary(fileList) + errors = {} + + logging.info("Schema validation:") + for schemaFile in fileList: + try: + schema = XMLSchema(schemaFile, locations = schemaLocations, validation="lax") + logging.info(schemaFile + ": OK") + errors[schemaFile] = [f"{etree_tostring(e.elem, e.namespaces, ' ', 20)} - {e.message}" for e in schema.all_errors] + except XMLSchemaParseError as ex: + logging.warning(schemaFile + ": Failed validation ({0})".format(ex.message)) + if (ex.schema_url) and (ex.schema_url != ex.origin_url): + logging.warning(" Error comes from {0}, suppressing".format(ex.schema_url)) + errors[schemaFile] = [] + else: + errors[schemaFile] = [ex] + return errors + + +def ValidateAllXSDFilesInPath (path): + schemaGlob = [str(f) for f in Path(path).rglob("*.xsd")] + return ValidateXSDFiles(schemaGlob) + + +def ValidateInstanceDocuments (coreFile, supportingSchemas, instanceDocs): + if (instanceDocs is None) or len(instanceDocs) == 0: + logging.warning ("No instance documents provided") + return [] + + schema = BuildSchema(coreFile, supportingSchemas) + errors = [] + for instanceDoc in instanceDocs: + try: + schema.validate(instanceDoc) + logging.info ("{0} passed validation".format(instanceDoc)) + except Exception as ex: + logging.error ("{0} failed validation: {1}".format(instanceDoc, ex)) + return errors + + +def processResults (results, stageName): + """ + Counts the number of errors and writes out the output per filename + + :param results: List of filenames (str or Pathlib Path) + :param stageName: Name to decorate the output with + :returns: The number of files which had errors + """ + print("") + errorCount = sum([1 for r in results.values() if not r['ok']]) + logging.info(f"{errorCount} {stageName} errors encountered") + + print(f"{'-':-<60}") + print(f"{stageName} results:") + print(f"{'-':-<60}") + for filename, result in results.items(): + print(f" {filename:.<55}{'..OK' if result['ok'] else 'FAIL'}") + if not result['ok']: + if isinstance(result['message'], list): + for thing in result['message']: + print(f" {thing['message']}") + else: + print(f" {result['message']}") + + print(f"{'-':-<60}") + print(f"{stageName} errors: {errorCount}") + print(f"{'-':-<60}") + + return errorCount + + +if __name__ == '__main__': + logging.basicConfig(level=logging.DEBUG) + + logging.info('Searching for XSD files') + fileList = list(Path(".").rglob("*.xsd")) + list(Path(".").rglob("*.xsd")) + logging.info(f'{len(fileList)} XSD files found') + for file in fileList: + logging.debug(f' {file}') + + ignoreList = Path('testing/xsd_ignore.txt').read_text().splitlines() + ignoredFiles = [] + for ignore in ignoreList: + logging.debug(f'Ignoring pattern {ignore}') + for file in fileList: + if ignore in str(file): + ignoredFiles.append(file) + logging.debug(f" Ignoring {str(file)} as contains {ignore}") + ignoredFiles = list(set(ignoredFiles)) + logging.info(f'{len(ignoredFiles)} files ignored') + for file in ignoredFiles: + logging.debug(f' {file}') + + fileList = [file for file in fileList if file not in ignoredFiles] + logging.info(f'{len(fileList)} files to process') + for file in fileList: + logging.debug(f' {file}') + + if len(fileList) == 0: + logging.warning ("No files specified") + exit(0) + + logging.info("Parsing ASN1 files") + parseResults = syntaxCheckXSD(fileList) + if processResults(parseResults, "Parsing") > 0: + exit(-1) + + logging.info ("Getting compile targets") + compileTargets = json.loads(Path('testing/asn_compile_targets.json').read_text()) + logging.info (f"{len(compileTargets)} compile targets found") + + compileResults = compileAllTargets(compileTargets) + if processResults(compileResults, "Compiling") > 0: + exit(-1) -- GitLab From 3d10ba4ac2b41298ff47c0333798590c0f73acaf Mon Sep 17 00:00:00 2001 From: mark Date: Mon, 28 Mar 2022 10:49:47 +0100 Subject: [PATCH 2/9] Updating cd/cid yml tyo match SA3LI --- .gitlab-ci.yml | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1b43a20..b4e3df3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,13 +1,17 @@ -image: "python:3.7" - -before_script: - - python3 --version - - pip3 install -q asn1tools lxml xmlschema - stages: - - Check Schemas + - check -checkASN1: - stage: Check Schemas +process_asn: + image: "mcanterb/asn1test:latest" + stage: check + interruptible: true script: - - python3 testing/check_asn1.py \ No newline at end of file + - python3 testing/asn_process.py + +process_xsd: + image: "mcanterb/xsdtest:latest" + stage: check + interruptible: true + script: + - python3 testing/xsd_process.py + -- GitLab From a9edda0e74817bf94cce877556b7773d4ae60f33 Mon Sep 17 00:00:00 2001 From: mark Date: Mon, 28 Mar 2022 11:57:51 +0100 Subject: [PATCH 3/9] Restructing XSD compilation --- .../GetTaskDetailsResponse_example.xml | 2 +- 103221-1/examples/desktop.ini | Bin 246 -> 0 bytes testing/xsd_compile_targets.json | 19 ++- testing/xsd_process.py | 141 +++++++++++++----- 4 files changed, 122 insertions(+), 40 deletions(-) delete mode 100644 103221-1/examples/desktop.ini diff --git a/103221-1/examples/GetTaskDetailsResponse_example.xml b/103221-1/examples/GetTaskDetailsResponse_example.xml index 63a66f5..0442556 100644 --- a/103221-1/examples/GetTaskDetailsResponse_example.xml +++ b/103221-1/examples/GetTaskDetailsResponse_example.xml @@ -16,7 +16,7 @@ X2andX3 - 1eb4406a-8b28-41fd-8f0f-e1a0a3eb5ff9 + 1eb4406a-8b28-41fd-8f0f-e1a0a3eb5ff9foooo diff --git a/103221-1/examples/desktop.ini b/103221-1/examples/desktop.ini deleted file mode 100644 index 8b699c692d358fa29d7ac0976e524fe25c5da053..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 246 zcmY+9%?iRW5QM+8;5+mIB=`d!gr1a2Pl_Imhf<;jsu82&<2%X0BEyE+-I+;pz_90n zqZ5{@hA7nBI1xB9WT1J-z30J|3NM{w!<~|GR@Agvv(r3^y`*f#OL-Sqw(0|CosANT zUq;k!txejcOv_3d&s)4#6?)@SbC=zgnP7CYVZuDK|CBzXlGDidQH_{NpZ@a&#q=qQ diff --git a/testing/xsd_compile_targets.json b/testing/xsd_compile_targets.json index fc6e235..f890299 100644 --- a/testing/xsd_compile_targets.json +++ b/testing/xsd_compile_targets.json @@ -1,7 +1,24 @@ [ { - "coreSchema" : "RDMessage.xsd", + "coreSchema" : "102657/RDMessage.xsd", "supportingSchemas" : [], "exampleFiles" : [] + }, + { + "coreSchema" : "103280/TS_103_280.xsd", + "supportingSchemas" : [], + "exampleFiles" : [] + }, + { + "coreSchema" : "103221-1/TS_103_221_01.xsd", + "supportingSchemas" : [ + "103221-1/TS_103_221_01.xsd", + "103221-1/TS_103_221_01_HashedID.xsd", + "103280/TS_103_280.xsd", + "103221-1/examples/ExampleGenericObjects.xsd" + ], + "exampleFiles" : [ + "103221-1/examples" + ] } ] \ No newline at end of file diff --git a/testing/xsd_process.py b/testing/xsd_process.py index 864b70b..20b54d3 100644 --- a/testing/xsd_process.py +++ b/testing/xsd_process.py @@ -1,3 +1,4 @@ +import json import logging from pathlib import Path @@ -107,46 +108,110 @@ def processResults (results, stageName): return errorCount -if __name__ == '__main__': - logging.basicConfig(level=logging.DEBUG) - - logging.info('Searching for XSD files') - fileList = list(Path(".").rglob("*.xsd")) + list(Path(".").rglob("*.xsd")) - logging.info(f'{len(fileList)} XSD files found') +def syntaxCheckXSD (fileList): + results = {} for file in fileList: - logging.debug(f' {file}') - - ignoreList = Path('testing/xsd_ignore.txt').read_text().splitlines() - ignoredFiles = [] - for ignore in ignoreList: - logging.debug(f'Ignoring pattern {ignore}') - for file in fileList: - if ignore in str(file): - ignoredFiles.append(file) - logging.debug(f" Ignoring {str(file)} as contains {ignore}") - ignoredFiles = list(set(ignoredFiles)) - logging.info(f'{len(ignoredFiles)} files ignored') - for file in ignoredFiles: - logging.debug(f' {file}') - - fileList = [file for file in fileList if file not in ignoredFiles] - logging.info(f'{len(fileList)} files to process') - for file in fileList: - logging.debug(f' {file}') + try: + logging.info(f"Syntax checking {str(file)}") - if len(fileList) == 0: - logging.warning ("No files specified") - exit(0) - - logging.info("Parsing ASN1 files") - parseResults = syntaxCheckXSD(fileList) - if processResults(parseResults, "Parsing") > 0: - exit(-1) + schema = XMLSchema(str(file), validation="skip") + results[str(file)] = { + 'ok' : len(schema.all_errors) == 0, + 'message' : None if len(schema.all_errors) == 0 else [{'message' : f"{etree_tostring(e.elem, e.namespaces, ' ', 20)} - {e.message}"} for e in schema.all_errors] + } + except XMLSchemaParseError as ex: + logging.warning(str(file) + ": Failed validation ({0})".format(ex.message)) + results[str(file)] = { + 'ok' : False, + 'message' : f"{ex!r}" + } + return results - logging.info ("Getting compile targets") - compileTargets = json.loads(Path('testing/asn_compile_targets.json').read_text()) - logging.info (f"{len(compileTargets)} compile targets found") - compileResults = compileAllTargets(compileTargets) - if processResults(compileResults, "Compiling") > 0: +if __name__ == '__main__': + #logging.basicConfig(level=logging.DEBUG) + + compileTargets = json.loads(Path('testing/xsd_compile_targets.json').read_text()) + results = {} + for target in compileTargets: + coreFile = target['coreSchema'] + logging.info(f"Attempting to compile {coreFile}") + schemaLocations = [] + for supportSchema in target['supportingSchemas']: + logging.debug(f"Adding supporting schema {supportSchema}") + try: + xs = XMLSchema(supportSchema, validation='skip') + schemaLocations.append((xs.default_namespace, str(Path(supportSchema).resolve()))) + logging.info(" [ {0} -> {1} ]".format(xs.default_namespace, supportSchema)) + except Exception as ex: + logging.warning (" [ {0} exception parsing: {1} ]".format(supportSchema, ex)) + results[coreFile] = { + 'ok' : False, + 'message' : f"{ex!r}" + } + break + try: + schema = XMLSchema(coreFile, locations = schemaLocations, validation="strict") + results[coreFile] = { + 'ok' : len(schema.all_errors) == 0, + 'message' : None if len(schema.all_errors) == 0 else [{'message' : f"{etree_tostring(e.elem, e.namespaces, ' ', 20)} - {e.message}"} for e in schema.all_errors] + } + target["schemaInstance"] = schema + except Exception as ex: + results[coreFile] = { + 'ok' : False, + 'message' : f"{ex!r}" + } + continue + + if (processResults(results, "Compile") > 0): exit(-1) + + results = {} + + for target in compileTargets: + schema = target["schemaInstance"] + testResults = {} + failureCount = 0 + logging.info (f"Validating example {len(target['exampleFiles'])} entries for {target['coreSchema']}") + for example in target["exampleFiles"]: + examplePath = Path(example) + if examplePath.is_dir: + logging.debug (f"Expanding {str(examplePath)}") + testFiles = list(examplePath.rglob("./*.xml")) + else: + testFiles = [examplePath] + logging.debug(f"Found {len(testFiles)} test files") + for test in testFiles: + logging.debug(f"Validating {str(test)} against schema") + try: + errors = list(schema.iter_errors(str(test))) + testResults[test] = [f"{etree_tostring(e.elem, e.namespaces, ' ', 20)} - {e.message}" for e in errors] + failureCount += len(errors) + except Exception as ex: + testResults[test] = [f"{ex!r}"] + failureCount += 1 + results[target['coreSchema']] = { + 'ok' : failureCount == 0, + 'testResults' : testResults, + 'failureCount' : failureCount + } + + print(f"{'-':-<75}") + print(f"Validation results:") + print(f"{'-':-<75}") + + totalErrors = 0 + for filename, result in results.items(): + print (f"{filename:.<70}{'..OK' if result['ok'] else 'FAIL'}") + totalErrors += result['failureCount'] + for testFile, testResult in result['testResults'].items(): + print(f" {str(testFile):.<65}{'..OK' if len(testResult) == 0 else 'FAIL'}") + for tr in testResult: + print(f" {tr}") + + print(f"{'-':-<75}") + print(f"Validation errors: {totalErrors}") + print(f"{'-':-<75}") + + exit(totalErrors > 0) -- GitLab From 3adbf765be8561bd4cd86e92131b9844a4763e2b Mon Sep 17 00:00:00 2001 From: mark Date: Mon, 28 Mar 2022 12:12:26 +0100 Subject: [PATCH 4/9] Correcting validation --- .../GetTaskDetailsResponse_example.xml | 2 +- testing/mod1.asn | 22 ----------------- testing/mod2.asn | 14 ----------- testing/xsd_compile_targets.json | 24 +++++++++++++++++++ testing/xsd_process.py | 21 +++++++++------- 5 files changed, 38 insertions(+), 45 deletions(-) delete mode 100644 testing/mod1.asn delete mode 100644 testing/mod2.asn diff --git a/103221-1/examples/GetTaskDetailsResponse_example.xml b/103221-1/examples/GetTaskDetailsResponse_example.xml index 0442556..63a66f5 100644 --- a/103221-1/examples/GetTaskDetailsResponse_example.xml +++ b/103221-1/examples/GetTaskDetailsResponse_example.xml @@ -16,7 +16,7 @@ X2andX3 - 1eb4406a-8b28-41fd-8f0f-e1a0a3eb5ff9foooo + 1eb4406a-8b28-41fd-8f0f-e1a0a3eb5ff9 diff --git a/testing/mod1.asn b/testing/mod1.asn deleted file mode 100644 index 5d4853e..0000000 --- a/testing/mod1.asn +++ /dev/null @@ -1,22 +0,0 @@ -Mod1 {itu-t(0) identified-organization(4) etsi(0)} - -DEFINITIONS ::= - -BEGIN - -IMPORTS - - ImportedField, - ClashField - FROM Mod2 {itu-t(0) identified-organization(4) etsi(1)}; - -TestPDU ::= SEQUENCE -{ - field1 [1] ClashField -} - -ClashField ::= BOOLEAN - -END - - diff --git a/testing/mod2.asn b/testing/mod2.asn deleted file mode 100644 index cec89b0..0000000 --- a/testing/mod2.asn +++ /dev/null @@ -1,14 +0,0 @@ -Mod2 {itu-t(0) identified-organization(4) etsi(1)} - -DEFINITIONS ::= - -BEGIN - -ImportedField ::= SEQUENCE -{ - field2 [0] BOOLEAN -} - -ClashField ::= INTEGER - -END diff --git a/testing/xsd_compile_targets.json b/testing/xsd_compile_targets.json index f890299..6fe2c68 100644 --- a/testing/xsd_compile_targets.json +++ b/testing/xsd_compile_targets.json @@ -20,5 +20,29 @@ "exampleFiles" : [ "103221-1/examples" ] + }, + { + "coreSchema" : "103120/dictionaries/ts_103120_Dictionaries.xsd", + "supportingSchemas" : [], + "exampleFiles" : [ + "103120/dictionaries/ts_103120_ETSIDictionaryDefinitions.xml" + ] + }, + { + "coreSchema" : "103120/schema/ts_103120_Core.xsd", + "supportingSchemas" : [ + "103120/schema/ts_103120_Authorisation.xsd", + "103120/schema/ts_103120_Common.xsd", + "103120/schema/ts_103120_Delivery.xsd", + "103120/schema/ts_103120_Document.xsd", + "103120/schema/ts_103120_Notification.xsd", + "103120/schema/ts_103120_Task.xsd", + "103280/TS_103_280.xsd", + "testing/deps/xmldsig/xmldsig-core-schema.xsd", + "103120/examples/FooServiceSchema.xsd" + ], + "exampleFiles" : [ + "103120/examples" + ] } ] \ No newline at end of file diff --git a/testing/xsd_process.py b/testing/xsd_process.py index 20b54d3..a0efd07 100644 --- a/testing/xsd_process.py +++ b/testing/xsd_process.py @@ -141,7 +141,7 @@ if __name__ == '__main__': logging.debug(f"Adding supporting schema {supportSchema}") try: xs = XMLSchema(supportSchema, validation='skip') - schemaLocations.append((xs.default_namespace, str(Path(supportSchema).resolve()))) + schemaLocations.append((xs.target_namespace, str(Path(supportSchema).resolve()))) logging.info(" [ {0} -> {1} ]".format(xs.default_namespace, supportSchema)) except Exception as ex: logging.warning (" [ {0} exception parsing: {1} ]".format(supportSchema, ex)) @@ -176,7 +176,7 @@ if __name__ == '__main__': logging.info (f"Validating example {len(target['exampleFiles'])} entries for {target['coreSchema']}") for example in target["exampleFiles"]: examplePath = Path(example) - if examplePath.is_dir: + if examplePath.is_dir(): logging.debug (f"Expanding {str(examplePath)}") testFiles = list(examplePath.rglob("./*.xml")) else: @@ -203,12 +203,17 @@ if __name__ == '__main__': totalErrors = 0 for filename, result in results.items(): - print (f"{filename:.<70}{'..OK' if result['ok'] else 'FAIL'}") - totalErrors += result['failureCount'] - for testFile, testResult in result['testResults'].items(): - print(f" {str(testFile):.<65}{'..OK' if len(testResult) == 0 else 'FAIL'}") - for tr in testResult: - print(f" {tr}") + if len(result['testResults']) == 0: + print (f"{filename:.<70}SKIP (0)") + continue + else: + print (f"{filename:.<70}{'..OK' if result['ok'] else 'FAIL'} ({len(result['testResults'])})") + totalErrors += result['failureCount'] + if result['failureCount'] > 0: + for testFile, testResult in result['testResults'].items(): + print(f" {str(testFile):.<65}{'..OK' if len(testResult) == 0 else 'FAIL'}") + for tr in testResult: + print(f" {tr}") print(f"{'-':-<75}") print(f"Validation errors: {totalErrors}") -- GitLab From f0319f0c30e8751c9c647d81650bfb14354a8ca3 Mon Sep 17 00:00:00 2001 From: mark Date: Mon, 28 Mar 2022 12:13:11 +0100 Subject: [PATCH 5/9] Updating ASN --- 102232-4/L2AccessPDU.asn | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/102232-4/L2AccessPDU.asn b/102232-4/L2AccessPDU.asn index df562af..f62d60d 100644 --- a/102232-4/L2AccessPDU.asn +++ b/102232-4/L2AccessPDU.asn @@ -38,7 +38,7 @@ L2CC ::= SEQUENCE l2ATM2684 [6] OCTET STRING, -- The protocol RFC 2684, method "LLC Encapsulation for Bridged Protocols` [16] is used l2FR2427 [7] OCTET STRING - -- The protocol RFC 2427 “Multiprotocol Interconnect over Frame Relay” [18] is used + -- The protocol RFC 2427 �Multiprotocol Interconnect over Frame Relay� [18] is used } } @@ -194,7 +194,7 @@ L2ProtocolInformation ::= ENUMERATED l2ProtocolATM2684(7), -- The protocol RFC 2684, method "LLC Encapsulation for Bridged Protocols" [16] is used l2ProtocolFR2427(8) - -- The protocol RFC2427 “Multiprotocol Interconnect over Frame Relay” [18] is used + -- The protocol RFC2427 �Multiprotocol Interconnect over Frame Relay� [18] is used } END -- end of L2AccessPDU -- GitLab From 7841313edb5ce4fb7ceb9ecec26f370bcb5693a3 Mon Sep 17 00:00:00 2001 From: mark Date: Mon, 28 Mar 2022 12:14:38 +0100 Subject: [PATCH 6/9] Strange Unicode bug --- testing/deps/301040/06132v203_C01.asn | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/testing/deps/301040/06132v203_C01.asn b/testing/deps/301040/06132v203_C01.asn index 56305a2..c507812 100644 --- a/testing/deps/301040/06132v203_C01.asn +++ b/testing/deps/301040/06132v203_C01.asn @@ -56,9 +56,9 @@ LISTATUSind ::= SEQUENCE TARGETACTIVITYMONITORind ::= SEQUENCE { - tLIInstanceid TLIIdType, -- header, who – - timestamp UTCTime, -- header, when – - targetLocation LocationType, -- header, where – + tLIInstanceid TLIIdType, -- header, who � + timestamp UTCTime, -- header, when � + targetLocation LocationType, -- header, where � targetAction ActivityType, supplementaryTargetaddress AddressType OPTIONAL, cotargetaddress SEQUENCE OF AddressType OPTIONAL, @@ -178,16 +178,16 @@ TETRAAddressType ::= CHOICE { tETRAaddress TSIType, pISNaddress NumericString (SIZE (20)), - iP4address BIT STRING (SIZE (32)), -- 32 bits – - iP6address BIT STRING (SIZE (128)), -- 128 bits – + iP4address BIT STRING (SIZE (32)), -- 32 bits � + iP6address BIT STRING (SIZE (128)), -- 128 bits � e164address NumericString (SIZE (20)), tEI TEIType } -CellIdType ::= BIT STRING (SIZE (16)) -- 16 bits – +CellIdType ::= BIT STRING (SIZE (16)) -- 16 bits � -LocationAreaType ::= BIT STRING (SIZE (14)) -- 14 bits, as defined in ETS 300 392-2 – +LocationAreaType ::= BIT STRING (SIZE (14)) -- 14 bits, as defined in ETS 300 392-2 � LocationType ::= CHOICE { @@ -196,11 +196,11 @@ LocationType ::= CHOICE } -MCCType ::= BIT STRING (SIZE (10)) -- 10 bits, as defined in ETS 300 392-1 – +MCCType ::= BIT STRING (SIZE (10)) -- 10 bits, as defined in ETS 300 392-1 � -MNCType ::= BIT STRING (SIZE (14)) -- 14 bits, as defined in ETS 300 392-1 – +MNCType ::= BIT STRING (SIZE (14)) -- 14 bits, as defined in ETS 300 392-1 � -SSIType ::= BIT STRING (SIZE (24)) -- 24 bits, as defined in ETS 300 392-1 – +SSIType ::= BIT STRING (SIZE (24)) -- 24 bits, as defined in ETS 300 392-1 � CircuitIdType ::= NumericString (SIZE (20)) @@ -255,7 +255,7 @@ TETRACGIType ::= SEQUENCE cI CellIdType OPTIONAL } -TLIIdType ::= BIT STRING (SIZE (16)) -- 16 bits – +TLIIdType ::= BIT STRING (SIZE (16)) -- 16 bits � TSIType ::= SEQUENCE { @@ -264,6 +264,6 @@ TSIType ::= SEQUENCE ssi SSIType } -TEIType ::= BIT STRING (SIZE (60)) -- 60 bits, as defined in ETS 300 392-1 – +TEIType ::= BIT STRING (SIZE (60)) -- 60 bits, as defined in ETS 300 392-1 � END -- GitLab From 16a7c383cc3f5839929e18d006b64cb21e202e9e Mon Sep 17 00:00:00 2001 From: mark Date: Mon, 28 Mar 2022 12:19:29 +0100 Subject: [PATCH 7/9] Removing odd unicode characters --- 102232-4/L2AccessPDU.asn | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/102232-4/L2AccessPDU.asn b/102232-4/L2AccessPDU.asn index f62d60d..7f18d89 100644 --- a/102232-4/L2AccessPDU.asn +++ b/102232-4/L2AccessPDU.asn @@ -36,9 +36,9 @@ L2CC ::= SEQUENCE -- The ethernet protocol is used ..., l2ATM2684 [6] OCTET STRING, - -- The protocol RFC 2684, method "LLC Encapsulation for Bridged Protocols` [16] is used + -- The protocol RFC 2684, method "LLC Encapsulation for Bridged Protocols" [16] is used l2FR2427 [7] OCTET STRING - -- The protocol RFC 2427 �Multiprotocol Interconnect over Frame Relay� [18] is used + -- The protocol RFC 2427 "Multiprotocol Interconnect over Frame Relay" [18] is used } } @@ -194,7 +194,7 @@ L2ProtocolInformation ::= ENUMERATED l2ProtocolATM2684(7), -- The protocol RFC 2684, method "LLC Encapsulation for Bridged Protocols" [16] is used l2ProtocolFR2427(8) - -- The protocol RFC2427 �Multiprotocol Interconnect over Frame Relay� [18] is used + -- The protocol RFC2427 "Multiprotocol Interconnect over Frame Relay" [18] is used } END -- end of L2AccessPDU -- GitLab From 6ed61b944524d85aa447b44728cbe5ffada78cb8 Mon Sep 17 00:00:00 2001 From: mark Date: Mon, 28 Mar 2022 12:20:24 +0100 Subject: [PATCH 8/9] Removing odd unicode characters --- testing/deps/301040/06132v203_C01.asn | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/testing/deps/301040/06132v203_C01.asn b/testing/deps/301040/06132v203_C01.asn index c507812..30c3212 100644 --- a/testing/deps/301040/06132v203_C01.asn +++ b/testing/deps/301040/06132v203_C01.asn @@ -56,9 +56,9 @@ LISTATUSind ::= SEQUENCE TARGETACTIVITYMONITORind ::= SEQUENCE { - tLIInstanceid TLIIdType, -- header, who � - timestamp UTCTime, -- header, when � - targetLocation LocationType, -- header, where � + tLIInstanceid TLIIdType, -- header, who + timestamp UTCTime, -- header, when + targetLocation LocationType, -- header, where targetAction ActivityType, supplementaryTargetaddress AddressType OPTIONAL, cotargetaddress SEQUENCE OF AddressType OPTIONAL, @@ -178,16 +178,16 @@ TETRAAddressType ::= CHOICE { tETRAaddress TSIType, pISNaddress NumericString (SIZE (20)), - iP4address BIT STRING (SIZE (32)), -- 32 bits � - iP6address BIT STRING (SIZE (128)), -- 128 bits � + iP4address BIT STRING (SIZE (32)), -- 32 bits + iP6address BIT STRING (SIZE (128)), -- 128 bits e164address NumericString (SIZE (20)), tEI TEIType } -CellIdType ::= BIT STRING (SIZE (16)) -- 16 bits � +CellIdType ::= BIT STRING (SIZE (16)) -- 16 bits -LocationAreaType ::= BIT STRING (SIZE (14)) -- 14 bits, as defined in ETS 300 392-2 � +LocationAreaType ::= BIT STRING (SIZE (14)) -- 14 bits, as defined in ETS 300 392-2 LocationType ::= CHOICE { @@ -196,11 +196,11 @@ LocationType ::= CHOICE } -MCCType ::= BIT STRING (SIZE (10)) -- 10 bits, as defined in ETS 300 392-1 � +MCCType ::= BIT STRING (SIZE (10)) -- 10 bits, as defined in ETS 300 392-1 -MNCType ::= BIT STRING (SIZE (14)) -- 14 bits, as defined in ETS 300 392-1 � +MNCType ::= BIT STRING (SIZE (14)) -- 14 bits, as defined in ETS 300 392-1 -SSIType ::= BIT STRING (SIZE (24)) -- 24 bits, as defined in ETS 300 392-1 � +SSIType ::= BIT STRING (SIZE (24)) -- 24 bits, as defined in ETS 300 392-1 CircuitIdType ::= NumericString (SIZE (20)) @@ -255,7 +255,7 @@ TETRACGIType ::= SEQUENCE cI CellIdType OPTIONAL } -TLIIdType ::= BIT STRING (SIZE (16)) -- 16 bits � +TLIIdType ::= BIT STRING (SIZE (16)) -- 16 bits TSIType ::= SEQUENCE { @@ -264,6 +264,6 @@ TSIType ::= SEQUENCE ssi SSIType } -TEIType ::= BIT STRING (SIZE (60)) -- 60 bits, as defined in ETS 300 392-1 � +TEIType ::= BIT STRING (SIZE (60)) -- 60 bits, as defined in ETS 300 392-1 END -- GitLab From a8ad8121bd8cef6b61f1a0be3efa54b5ade09ee4 Mon Sep 17 00:00:00 2001 From: mark Date: Mon, 28 Mar 2022 12:21:23 +0100 Subject: [PATCH 9/9] Removing temporary ASN file --- temp.asn | 735 ------------------------------------------------------- 1 file changed, 735 deletions(-) delete mode 100644 temp.asn diff --git a/temp.asn b/temp.asn deleted file mode 100644 index 6bcd0ce..0000000 --- a/temp.asn +++ /dev/null @@ -1,735 +0,0 @@ -LI-PS-PDU -{itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulIntercept(2) li-ps(5) genHeader(1) version32(32)} - -DEFINITIONS IMPLICIT TAGS ::= - -BEGIN - -IMPORTS - -- Any of the IMPORTs may be commented out if they are not used (see clause A.3) - - -- from ETSI TS 103 280 [44] - LIID - FROM Common-Parameters - {itu-t(0) identified-organization(4) etsi(0) common-parameters(3280) version231(231)} - - - -- from ETSI TS 101 671 [4] - IRI-Parameters, - IRIsContent, - Location, - Network-Element-Identifier - FROM HI2Operations - {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulIntercept(2) hi2(1) version18(18)} - - -- from ETSI TS 101 671 [4] - HI1-Operation - FROM HI1NotificationOperations - {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulIntercept(2) hi1(0) notificationOperations(1) version7(7)} - - -- from ETSI TS 102 232-2 [5] - EmailCC, - EmailIRI, - MessagingCC, - MessagingMMCC, - MessagingIRI - FROM EmailPDU - {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulIntercept(2) li-ps(5) email(2) version18(18)} - - -- from ETSI TS 102 232-3 [6] - IPCC, - IPIRI, - IPIRIOnly - FROM IPAccessPDU - {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulIntercept(2) li-ps(5) iPAccess(3) version14(14)} - - -- from ETSI TS 102 232-4 [32] - L2CC, - L2IRI, - L2IRIOnly - FROM L2AccessPDU - {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulIntercept(2) li-ps(5) l2Access(4) version7(7)} - - -- from ETSI TS 102 232-5 [37] - IPMMCC, - IPMMIRI - FROM IPMultimediaPDU - {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulIntercept(2) li-ps(5) iPMultimedia(5) version13(13)} - - -- from ETSI TS 102 232-6 [36] - PstnIsdnCC, - PstnIsdnIRI - FROM PstnIsdnPDU - {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulIntercept(2) li-ps(5) pstnIsdn(6) version5(5)} - - -- from 3GPP TS 33.108 [9] - IRI-Parameters, - UmtsIRIsContent, - CorrelationValues, - Location - FROM UmtsHI2Operations - {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulIntercept(2) threeGPP(4) hi2(1)} - -- The relevant module (including the 3GPP release and version number) needs - -- to be chosen when compiling the application. - - -- from 3GPP TS 33.108 [9] - IRI-Parameters, - UmtsCS-IRIsContent - FROM UmtsCS-HI2Operations - {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulIntercept(2) threeGPP(4) hi2CS(3)} - -- The relevant module (including the 3GPP release and version number) needs - -- to be chosen when compiling the application. - - -- from 3GPP TS 33.108 [9] - IRI-Parameters, - EpsIRIsContent, - EPSLocation - FROM EpsHI2Operations - {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulIntercept(2) threeGPP(4) hi2eps(8)} - -- The relevant module (including the 3GPP release and version number) needs - -- to be chosen when compiling the application. - - -- from 3GPP TS 33.108 [9] - IRI-Parameters, - ConfIRIsContent - FROM CONFHI2Operations - {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulIntercept(2) threeGPP(4) hi2conf(10)} - -- The relevant module (including the 3GPP release and version number) needs - -- to be chosen when compiling the application. - - -- from 3GPP TS 33.108 [9] - IRI-Parameters, - ProSeIRIsContent - FROM ProSeHI2Operations - {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulIntercept(2) threeGPP(4) hi2prose (15)} - -- The relevant module (including the 3GPP release and version number) needs - -- to be chosen when compiling the application. - - -- from 3GPP TS 33.108 [9] - IRI-Parameters, - GcseIRIsContent - FROM GCSEHI2Operations - {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulIntercept(2) threeGPP(4) hi2gcse(13)} - -- The relevant module (including the 3GPP release and version number) needs - -- to be chosen when compiling the application. - - -- from 3GPP TS 33.108 [9] - CC-PDU - FROM Umts-HI3-PS - {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulintercept(2) threeGPP(4) hi3(2)} - -- The relevant module (including the 3GPP release and version number) - -- needs to be chosen when compiling the application. - - -- from 3GPP TS 33.108 [9] - CC-PDU - FROM Eps-HI3-PS - {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulintercept(2) threeGPP(4) hi3eps(9)} - -- The relevant module (including the 3GPP release and version number) - -- needs to be chosen when compiling the application. - - -- from 3GPP TS 33.108 [9] - Conf-CC-PDU - FROM CONF-HI3-IMS - {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulintercept(2) threeGPP(4) hi3conf(11)} - -- The relevant module (including the 3GPP release and version number) - -- needs to be chosen when compiling the application. - - -- from 3GPP TS 33.108 [9] - Voip-CC-PDU - FROM VoIP-HI3-IMS - {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulintercept(2) threeGPP(4) hi3voip(12)} - -- The relevant module (including the 3GPP release and version number) - -- needs to be chosen when compiling the application. - - -- from 3GPP TS 33.108 [9] - Gcse-CC-PDU - FROM GCSE-HI3 - {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulintercept(2) threeGPP(4) hi3gcse(14)} - -- The relevant module (including the 3GPP release and version number) - -- needs to be chosen when compiling the application. - - -- from 3GPP TS 33.108 [9] - ThreeGPP-HI1-Operation - FROM ThreeGPP-HI1NotificationOperations - {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulIntercept(2) threeGPP(4) hi1(0) notificationOperations(1)} - -- The relevant module (including the 3GPP release and version number) - -- needs to be chosen when compiling the application. - -- TS 101 671 HI1 and 3GPP HI1 are related to the same functionality but are - -- corresponding to different implementations and exclusive usage each other. - -- The implementation depends of national regulations or LEA/CSP negotiations. - -- 3GPP HI1 may be used with other services/networks than 3GPP's one. - - -- from 3GPP TS 33.108 [9] - CSvoice-CC-PDU - FROM CSvoice-HI3-IP - {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulIntercept(2) threeGPP(4) hi3CSvoice(18)} - -- The relevant module (including the 3GPP release and version number) - -- needs to be chosen when compiling the application. - -- The implementation of the CS domain delivery in IP have to be based on 3GPP TS 33.108 [9]. - - -- from ETSI TS 101 909-20-1 [33] - TARGETACTIVITYMONITOR-1, - TTRAFFIC, - CTTRAFFIC - FROM TS101909201 - {itu-t(0) identified-organization(4) etsi(0) ts101909(1909) part20(20) subpart1(1) interceptVersion(0)} - - -- from ETSI TS 101 909-20-2 [34] - TARGETACTIVITYMONITOR, - TTRAFFIC, - CTTRAFFIC - FROM TS101909202 - {itu-t(0) identified-organization(4) etsi(0) ts101909(1909) part20(20) subpart2(2) interceptVersion(0)} - - -- from ETSI TS 103 462 [45] - ILHIPayload - FROM ILHIPDU - {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) informationHandover(4) ilhi(0) ilhiPdu(0) version2(2)} - -- This import is only used for the handover between LEMFs. - - -- from 3GPP TS 33.128 [46] - LINotificationPayload, - IRIPayload, - CCPayload - FROM TS33128Payloads - {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulIntercept(2) threeGPP(4) ts33128(19)}; - -- The relevant module (including the 3GPP release and version number) - -- needs to be chosen when compiling the application. - --- end of IMPORTS - --- ============================= --- Object Identifier Definitions --- ============================= - -lawfulInterceptDomainId OBJECT IDENTIFIER ::= {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulIntercept(2)} - -li-psDomainId OBJECT IDENTIFIER ::= {lawfulInterceptDomainId li-ps(5) genHeader(1) version32(32)} - --- ==================== --- Top-level definition --- ==================== - -PS-PDU ::= SEQUENCE -{ - pSHeader [1] PSHeader, - payload [2] Payload -} - -PSHeader ::= SEQUENCE -{ - li-psDomainId [0] OBJECT IDENTIFIER, - lawfulInterceptionIdentifier [1] LawfulInterceptionIdentifier, - -- As of ASN.1 version 26 this parameter is included from ETSI TS 103 280 [44] - authorizationCountryCode [2] PrintableString (SIZE (2)) OPTIONAL, - -- see clause 5.2.3 - communicationIdentifier [3] CommunicationIdentifier, - sequenceNumber [4] INTEGER (0..4294967295), - timeStamp [5] GeneralizedTime OPTIONAL, - -- see clause 5.2.6 - ..., - interceptionPointID [6] PrintableString (SIZE (1..8)) OPTIONAL, - -- see clause 5.2.11 - microSecondTimeStamp [7] MicroSecondTimeStamp OPTIONAL, - timeStampQualifier [8] TimeStampQualifier OPTIONAL, - extendedInterceptionPointID [9] OCTET STRING (SIZE (1..65535)) OPTIONAL, - -- see clause 5.2.13 - networkFunctionIdentifier [10] OCTET STRING (SIZE (1..65535)) OPTIONAL - -- see clause 5.2.14 -} - -Payload ::= CHOICE -{ - iRIPayloadSequence [0] SEQUENCE OF NativeIRIPayload, - cCPayloadSequence [1] SEQUENCE OF NativeCCPayload, - -- Clause 6.2.3 explains how to include more than one payload in the same PDU - tRIPayload [2] TRIPayload, - ..., - hI1-Operation [3] HI1-Operation, - encryptionContainer [4] EncryptionContainer, - threeGPP-HI1-Operation [5] ThreeGPP-HI1-Operation, - -- This structure may be functionally redundant with hI1-Operation from ETSI TS 101 671 [4] - iLHIPayload [6] SEQUENCE OF ILHIPayload, - -- For typical use cases see ETSI TS 103 462 [45] - hI4Payload [7] SEQUENCE OF HI4Payload -} - -TimeStampQualifier ::= ENUMERATED -{ - unknown(0), - timeOfInterception(1), - timeOfMediation(2), - ..., - timeOfAggregation(3) -} - -HI4Payload ::= CHOICE -{ - threeGPP-LI-Notification [1] TS33128Payloads.LINotificationPayload, - ... -} - --- ==================================== --- Items contained within the PS-Header --- ==================================== - -CommunicationIdentifier ::= SEQUENCE -{ - networkIdentifier [0] NetworkIdentifier, - communicationIdentityNumber [1] INTEGER (0..4294967295) OPTIONAL, - -- in case of transport of HI1 messages not required - -- Mandatory for CC and IRI, with certain exceptions (see clause 5.2.4) - deliveryCountryCode [2] PrintableString (SIZE (2)) OPTIONAL, - -- see clause 5.2.4 - ..., - cINExtension [3] CorrelationValues OPTIONAL - -- To be used when a single INTEGER is not sufficient to identify - -- a particular session (see clause 5.2.4) -} - -NetworkIdentifier ::= SEQUENCE -{ - operatorIdentifier [0] OCTET STRING (SIZE(1..16)), - networkElementIdentifier [1] OCTET STRING (SIZE(1..16)) OPTIONAL, - ..., - eTSI671NEID [2] Network-Element-Identifier OPTIONAL - -- For network element identifier, use either networkElementIdentifier or eTSI671NEID -} - --- ========================== --- Definitions for CC Payload --- ========================== - -NativeCCPayload ::= SEQUENCE -{ - payloadDirection [0] PayloadDirection OPTIONAL, - timeStamp [1] GeneralizedTime OPTIONAL, - -- For aggregated payloads (see clause 6.2.3) - cCContents [2] CCContents, - ..., - microSecondTimeStamp [3] MicroSecondTimeStamp OPTIONAL, - -- For aggregated payloads (see clause 6.2.3) - timeStampQualifier [4] TimeStampQualifier OPTIONAL -} - -PayloadDirection ::= ENUMERATED -{ - fromTarget(0), - toTarget(1), - ..., - indeterminate(2), - -- Indication that the direction was indeterminate - combined(3), - -- Indication applicable to some services that the traffic is actually a combination - -- of To and From - notapplicable(4) - -- Indication that direction of interceptable service does not make sense -} - -CCContents ::= CHOICE - -- Any of these choices may be commented out if they are not being used, see clause A.3 -{ - -- tag [0] deprecated in version15, ETSI TS 102 232-1 V3.3.1 (2013-02) - emailCC [1] EmailCC, - iPCC [2] IPCC, - -- tag [3] not used - uMTSCC [4] OCTET STRING, - ..., - -- tag [5] deprecated in version15, ETSI TS 102 232-1 V3.3.1 (2013-02) - l2CC [6] L2CC, - tTRAFFIC-1 [7] TS101909201.TTRAFFIC, - cTTRAFFIC-1 [8] TS101909201.CTTRAFFIC, - tTRAFFIC-2 [9] TS101909202.TTRAFFIC, - cTTRAFFIC-2 [10] TS101909202.CTTRAFFIC, - pstnIsdnCC [11] PstnIsdnCC, - iPMMCC [12] IPMMCC, - -- tag [13] deprecated in version32, ETSI TS 102 232-1 V3.24.1 (2021-07) - messagingCC [14] MessagingCC, - ePSCC [15] OCTET STRING, - uMTSCC-CC-PDU [16] Umts-HI3-PS.CC-PDU, - ePSCC-CC-PDU [17] Eps-HI3-PS.CC-PDU, - messagingMMCC [18] MessagingMMCC, - confCC-CC-PDU [19] CONF-HI3-IMS.Conf-CC-PDU, - voipCC-CC-PDU [20] VoIP-HI3-IMS.Voip-CC-PDU, - gcseCC-CC-PDU [21] GCSE-HI3.Gcse-CC-PDU, - cSvoice-CC-PDU [22] CSvoice-HI3-IP.CSvoice-CC-PDU, - threeGPP33128DefinedCC [23] OCTET STRING (CONTAINING TS33128Payloads.CCPayload) -} - -MicroSecondTimeStamp ::= SEQUENCE -{ - seconds [0] INTEGER (0..18446744073709551615), - -- number of seconds since 1970-1-1 00:00Z also known as unix time epoch - microSeconds [1] INTEGER (0..999999), - ... -} - --- =========================== --- Definitions for IRI Payload --- =========================== - -NativeIRIPayload ::= SEQUENCE -{ - iRIType [0] IRIType OPTIONAL, - -- See clause 5.2.10 - timeStamp [1] GeneralizedTime OPTIONAL, - -- For aggregated payloads (see clause 6.2.3) - iRIContents [2] IRIContents, - ..., - microSecondTimeStamp [3] MicroSecondTimeStamp OPTIONAL, - -- For aggregated payloads (see clause 6.2.3) - timeStampQualifier [4] TimeStampQualifier OPTIONAL, - sessionDirection [5] PayloadDirection OPTIONAL, - -- If the sessionDirection field is to be used for a given service then - -- the exact meaning and use of the field will be described in the - -- relevant service-specific details - payloadDirection [6] PayloadDirection OPTIONAL - -- If the payloadDirection field is to be used for a given service then - -- the exact meaning and use of the field will be described in the - -- relevant service-specific details -} - -IRIType ::= ENUMERATED -{ - iRI-Begin(1), - iRI-End(2), - iRI-Continue(3), - iRI-Report(4) -} - -IRIContents ::= CHOICE - -- Any of these choices may be commented out if they are not being used (see clause A.3) -{ - -- tag [0] deprecated in version15, ETSI TS 102 232-1 V3.3.1 (2013-02) - emailIRI [1] EmailIRI, - iPIRI [2] IPIRI, - iPIRIOnly [3] IPIRIOnly, - uMTSIRI [4] UMTSIRI, - eTSI671IRI [5] ETSI671IRI, - ..., - l2IRI [6] L2IRI, - l2IRIOnly [7] L2IRIOnly, - tARGETACTIVITYMONITOR-1 [8] TS101909201.TARGETACTIVITYMONITOR-1, - tARGETACTIVITYMONITOR-2 [9] TS101909202.TARGETACTIVITYMONITOR, - pstnIsdnIRI [10] PstnIsdnIRI, - iPMMIRI [11] IPMMIRI, - -- tag [12] deprecated in version32, ETSI TS 102 232-1 V3.24.1 (2021-07) - -- tag [13] deprecated in version32, ETSI TS 102 232-1 V3.24.1 (2021-07) - messagingIRI [14] MessagingIRI, - ePSIRI [15] EPSIRI, - confIRI [16] ConfIRI, - proseIRI [17] ProSeIRI, - gcseIRI [18] GcseIRI, - threeGPP33128DefinedIRI [19] OCTET STRING (CONTAINING TS33128Payloads.IRIPayload) -} - -UMTSIRI ::= CHOICE - -- This structure may be commented out if not used -{ - iRI-Parameters [0] UmtsHI2Operations.IRI-Parameters, - umtsIRIsContent [1] UmtsIRIsContent, - ..., - iRI-CS-Parameters [2] UmtsCS-HI2Operations.IRI-Parameters, - umtsCS-IRIsContent [3] UmtsCS-IRIsContent -} - -ETSI671IRI ::= CHOICE - -- This structure may be commented out if not used -{ - iRI-Parameters [0] HI2Operations.IRI-Parameters, - iRIsContent [1] IRIsContent, - ... -} - -EPSIRI ::= CHOICE - -- This structure may be commented out if not used -{ - iRI-EPS-Parameters [0] EpsHI2Operations.IRI-Parameters, - epsIRIsContent [1] EpsIRIsContent, - ... -} - -ConfIRI ::= CHOICE - -- This structure may be commented out if not used -{ - iRI-Conf-Parameters [0] CONFHI2Operations.IRI-Parameters, - confIRIsContent [1] ConfIRIsContent, - ... -} - - -ProSeIRI ::= CHOICE - -- This structure may be commented out if not used -{ - iRI-ProSe-Parameters [0] ProSeHI2Operations.IRI-Parameters, - proseIRIsContent [1] ProSeIRIsContent, - ... -} - - -GcseIRI ::= CHOICE - -- This structure may be commented out if not used -{ - iRI-Gcse-Parameters [0] GCSEHI2Operations.IRI-Parameters, - gcseIRIsContent [1] GcseIRIsContent, - ... -} - - --- =========================== --- Definitions for TRI Payload --- =========================== - -TRIPayload ::= CHOICE -{ - integrityCheck [0] IntegrityCheck, - testPDU [1] NULL, - paddingPDU [2] OCTET STRING, - -- Undefined contents (will be discarded) - keep-alive [3] NULL, - keep-aliveResponse [4] NULL, - firstSegmentFlag [5] NULL, - lastSegmentFlag [6] NULL, - ..., - cINReset [7] NULL, - operatorLeaMessage [8] OperatorLeaMessage, - optionRequest [9] OptionRequest, - optionResponse [10] OptionResponse, - optionComplete [11] NULL, - pDUAcknowledgementRequest [12] NULL, - pDUAcknowledgementResponse [13] NULL -} - -IntegrityCheck ::= SEQUENCE -{ - includedSequenceNumbers [0] SEQUENCE OF INTEGER (0..4294967295), - -- gives the order the PDUs were processed - checkType [1] CheckType, - dataType [2] DataType OPTIONAL, - -- From version5(5) the dataType is mandatory for hashes and for signatures - -- (see clause 7.2.3) - checkValue [3] OCTET STRING, - -- Network byte order - -- If checkValue contains a signature, the octet string field space may be - -- used to insert the appropriate ASN.1 DER or BER encoded structure for the - -- DSS/DSA signature as described in IETF RFC 3279 [43], clause 2.2.2. - ..., - hashAlgorithm [4] HashAlgorithm OPTIONAL - -- Clarifies the hash function if checkType is hash(1). - -- If used, it shall be present for each checkType hash(1). -} - -CheckType ::= ENUMERATED -{ - hash(1), - -- hash value - signature(2), - -- DSS/DSA signature - ... -} - -DataType ::= ENUMERATED -{ - iRI(1), - cC(2), - ..., - iLHI(3) -} - -HashAlgorithm ::= ENUMERATED -{ - sHA-1(1), - -- Included for legacy/migration purposes only, not to be used for new implementations - sHA-256(2), - sHA-384(3), - sHA-512(4), - ... -} - -Option ::= CHOICE -{ - pDUAcknowledgement [0] NULL, - ... -} - -OptionRequest ::= SEQUENCE -{ - requestedOptions [0] SEQUENCE OF Option, - ... -} - -OptionResponse ::= SEQUENCE -{ - acceptedOptions [0] SEQUENCE OF Option, - declinedOptions [1] SEQUENCE OF Option, - ... -} - --- ================================== --- Definitions for OperatorLeaMessage --- ================================== - -OperatorLeaMessage ::= SEQUENCE -{ - messagePriority [0] OperatorLeaMessagePriority, - message [1] OCTET STRING (SIZE(1..255)), - ... -} - -OperatorLeaMessagePriority ::= ENUMERATED -{ - error(1), - -- reporting of error conditions that have impact on the quality of the - -- intercepted data - informational(2), - -- reporting of conditions that will not have direct impact on the quality of - -- the intercepted data - ... -} - --- =================================== --- Definitions for EncryptionContainer --- =================================== - -EncryptionContainer ::= SEQUENCE -{ - encryptionType [0] EncryptionType, - encryptedPayload [1] OCTET STRING, - -- once decrypted, it can be interpreted as EncryptedPayload - ..., - encryptedPayloadType [2] EncryptedPayloadType OPTIONAL -} - -EncryptionType ::= ENUMERATED -{ - none(1), - -- No encryption is applied. - national-option(2), - -- Use this option when an encryption scheme is negotiated on a national level - aES-192-CBC(3), - -- The Advanced Encryption Standard using a 192 bit key in CBC mode - aES-256-CBC(4), - -- The Advanced Encryption Standard using a 256 bit key in CBC mode - blowfish-192-CBC(5), - -- Blowfish (www.schneier.com/blowfish.html) using a 192 bit key in CBC mode - blowfish-256-CBC(6), - -- Blowfish using a 256 bit key in CBC mode - threedes-cbc(7), - -- Triple-DES using a 192 bit key in CBC mode - ... -} - -EncryptedPayload ::= SEQUENCE -{ - byteCounter [0] INTEGER (0..18446744073709551615), - -- The sum of the sizes of all PDUs before this PDU. - -- It is initialized with the unixTime (number of seconds since 01-01-1970) - -- multiplied by 2^32 at first use. - -- Where N is sequencenumber of the n-th PDU in transfer, and size(PDU(N)) - -- as defined in annex G: - -- IF N > 0 THEN - -- PDU[N].byteCounter = PDU[N-1].byteCounter + size(PDU[N-1]) - -- ELSE - -- PDU[N].byteCounter = ( unixTime(now) << 32 ) - -- ENDIF - payload [1] Payload, - ... -} - -EncryptedPayloadType ::= ENUMERATED -{ - unknown(1), - part2(2), - -- encrypted payload is ETSI TS 102 232-2 [5] - part3(3), - -- encrypted payload is ETSI TS 102 232-3 [6] - part4(4), - -- encrypted payload is ETSI TS 102 232-4 [32] - part5(5), - -- encrypted payload is ETSI TS 102 232-5 [37] - part6(6), - -- encrypted payload is ETSI TS 102 232-6 [36] - part7(7), - -- encrypted payload is ETSI TS 102 232-7 [38] - ..., - part1(8) - -- encrypted payload is ETSI TS 102 232-1 (the present document) -} - --- =================================== --- Common Parameters --- =================================== - -NativeLocation ::= SEQUENCE - -- This is a common parameter, the use of this parameter is described in clause 4.5 -{ - umtsHI2Location [0] UmtsHI2Operations.Location OPTIONAL, - epsLocation [1] EpsHI2Operations.EPSLocation OPTIONAL, - ..., - wlanLocationAttributes [2] WlanLocationAttributes OPTIONAL, - eTSI671HI2Location [3] HI2Operations.Location OPTIONAL -} - -WlanLocationAttributes ::= SEQUENCE -{ - wlanAPMACAddress [0] OCTET STRING (SIZE(6)) OPTIONAL, - -- 48-bit (6 octet) MAC address of the WLAN access point derived from the BSSID - ... -} - -IPAddress ::= SEQUENCE - -- This parameter was previously imported from ETSI TS 101 671 [4] but has been copied - -- to ETSI TS 102 232-1 (the present document). It is not recommended to use this parameter in - -- future change requests. Suggested approach is to use a parameter from ETSI TS 103 280 [44] - -- instead. -{ - iP-type [1] ENUMERATED - { - iPV4(0), - iPV6(1), - ... - }, - iP-value [2] IP-value, - iP-assignment [3] ENUMERATED - { - static(1), - -- The static coding shall be used to report a static address. - dynamic(2), - -- The dynamic coding shall be used to report a dynamically allocated address. - notKnown(3), - -- The notKnown coding shall be used to report other than static or dynamically - -- allocated IP addresses. - ... - } OPTIONAL, - ..., - iPv6PrefixLength [4] INTEGER (1..128) OPTIONAL, - -- Indicates the length of the prefix delegated by the CSP to the subscriber - -- example: 60 if IP address is "2001:db8:0:85a3::ac1f:8001/60" - -- Mandatory in case where the iP-value contains an IPv6 binary value - iPv4SubnetMask [5] OCTET STRING (SIZE(4)) OPTIONAL - -- For IPv4 addresses, this indicates the subnet mask to be applied to the iP-value field. - -- The subnet mask is intended to be presented as a binary value, e.g. "ff ff ff f8" to - -- represent the dotted-decimal subnet mask of "255.255.255.248" corresponding to - -- a /29 CIDR-format subnet mask -} - -IP-value ::= CHOICE -{ - iPBinaryAddress [1] OCTET STRING (SIZE(4..16)), - -- In case of IPv6, the Prefix Length is provided by the "iPv6PrefixLength" - -- In case of IPv4, the netmask is provided by the "iPv4SubnetMask" - iPTextAddress [2] IA5String (SIZE(7..45)), - -- In case of IPv6, the delivered iPTextAddress field could include a complete - -- single IPv6-Address or an IPv6-Prefix for a subnetwork on the target side. - -- In case of IPv4, the delivered iPTextAddress field could include a single - -- IPv4 address or an IPv4address/netmask, for example "192.168.1.1" or "192.168.1.1/24" - ... -} - -LawfulInterceptionIdentifier ::= LIID - -- LIID is a common parameter imported from ETSI TS 103 280 [44]. - -- It is redefined as LawfulInterceptionIdentifier in this - -- module to preserve the original type name during the - -- removal of imports from ETSI TS 101 671 [4]. - -END --end of LI-PS-PDU \ No newline at end of file -- GitLab