Commit f548e21e authored by canterburym's avatar canterburym
Browse files

Merge branch 'master' into 'updating_asn_testing'

# Conflicts:
#   102232-1/LI-PS-PDU.asn
parent 8ed38ba8
import logging
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 compileASN1Files (fileList):
logging.info("Compiling files...")
errors = []
try:
d = parse_files(fileList)
for modulename, module in d.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'}
c = compile_dict(d)
except CompileError as ex:
logging.info (f"Compiler error: {ex}")
errors.append(ex)
except ParseError as ex:
logging.info (f"Parse error: {ex}")
errors.append(ex)
logging.info ("Compiled OK")
return errors
def validateASN1Files (fileList):
parseErrors = parseASN1Files(fileList)
# if len(parseErrors > 0):
# logging.info ("Abandonding compile due to parse errors")
# compileErrors = compileASN1Files(fileList)
# leave this for now - TBD
compileErrors = []
return parseErrors, compileErrors
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)
from compile_asn import *
if __name__ == '__main__':
parseErrors, compileErrors = validateAllASN1FilesInPath("./")
parseErrors, compileErrors, parser = validateAllASN1FilesInPath("./")
parseErrorCount = 0
print ("ASN.1 Parser checks:")
print ("-----------------------------")
......
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)
except ParseError as ex:
logging.info (f"Parse error: {ex}")
errors.append(ex)
logging.info ("Compiled OK")
return errors, c
def validateASN1Files (fileList):
parseErrors = parseASN1Files(fileList)
if len(parseErrors) > 0:
logging.info ("Abandonding compile due to parse errors")
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
HI1NotificationOperations
{itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulIntercept(2) hi1(0) notificationOperations(1) version7(7)}
DEFINITIONS IMPLICIT TAGS ::=
BEGIN
IMPORTS
-- from clause�D.5
CommunicationIdentifier,
TimeStamp,
LawfulInterceptionIdentifier
FROM HI2Operations
{itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulIntercept(2) hi2(1) version10(10)};
-- =============================
-- Object Identifier Definitions
-- =============================
-- LawfulIntercept DomainId
lawfulInterceptDomainId OBJECT IDENTIFIER ::= {itu-t(0) identified-organization(4) etsi(0) securityDomain(2) lawfulIntercept(2)}
-- hi1 Domain
hi1NotificationOperationsId OBJECT IDENTIFIER ::= {lawfulInterceptDomainId hi1(0) notificationOperations(1)}
hi1OperationId OBJECT IDENTIFIER ::= {hi1NotificationOperationsId version6(6)}
-- Class 2 operation. The timer shall be set to a value between 3s and 240s.
-- The timer default value is 60s.
-- NOTE: The value for this timer is to be set on the equipment waiting for the returned message;
-- its value shall be agreed between the NWO/AP/SvP and the LEA, depending on their equipment
-- properties.
HI1-Operation ::= CHOICE
{
liActivated [1] Notification,
liDeactivated [2] Notification,
liModified [3] Notification,
alarms-indicator [4] Alarm-Indicator,
...,
national-HI1-ASN1parameters [5] National-HI1-ASN1parameters
}
-- ==================
-- PARAMETERS FORMATS
-- ==================
Notification ::= SEQUENCE
{
domainID [0] OBJECT IDENTIFIER (hi1OperationId) OPTIONAL,
-- Once using FTP delivery mechanism
lawfulInterceptionIdentifier [1] LawfulInterceptionIdentifier,
-- This identifier is the LIID identity provided with the lawful authorization
-- for each target.
communicationIdentifier [2] CommunicationIdentifier OPTIONAL,
-- Only the NWO/PA/SvPIdentifier is provided (the one provided with the Lawful
-- authorization).
-- Called "callIdentifier" in V1.1.1 of ES 201 671
timeStamp [3] TimeStamp,
-- date and time of the report.
...,
national-HI1-ASN1parameters [5] National-HI1-ASN1parameters OPTIONAL,
target-Information [6] OCTET STRING (SIZE (1..256)) OPTIONAL
-- provides information about the number or the characteristic of the target
-- (e.g. E-mail address, E.164 number), ASCII format
}
Alarm-Indicator ::= SEQUENCE
{
domainID [0] OBJECT IDENTIFIER (hi1OperationId) OPTIONAL,
-- Once using FTP delivery mechanism
communicationIdentifier [1] CommunicationIdentifier OPTIONAL,
-- Only the NWO/PA/SvPIdentifier is provided (the one provided with the
-- Lawful authorization)
timeStamp [2] TimeStamp,
-- date and time of the report.
alarm-information [3] OCTET STRING (SIZE (1..256)),
-- Provides information about alarms (free format).
-- Until ASN.1 version 6 (document version v3.12.1) the octet string
-- was limited to a size of 25
...,
lawfulInterceptionIdentifier [4] LawfulInterceptionIdentifier OPTIONAL,
-- This identifier is the LIID identity provided with the lawful authorization
-- for each target in according to national law.
national-HI1-ASN1parameters [5] National-HI1-ASN1parameters OPTIONAL
}
National-HI1-ASN1parameters ::= SEQUENCE
{
domainID [0] OBJECT IDENTIFIER (hi1OperationId) OPTIONAL,
-- Once using FTP delivery mechanism.
countryCode [1] PrintableString (SIZE (2)),
-- Country Code according to ISO 3166-1 [67],
-- the country to which the parameters inserted after the extension marker apply.
...
-- In case a given country wants to use additional national parameters according to its law,
-- these national parameters should be defined using the ASN.1 syntax and added after the
-- extension marker (...).
-- It is recommended that "version parameter" and "vendor identification parameter" are
-- included in the national parameters definition. Vendor identifications can be
-- retrieved from IANA web site (see�annex�K). Besides, it is recommended to avoid
-- using tags from 240 to 255 in a formal type definition.
}
END -- end of HI1NotificationOperations
This diff is collapsed.
PCESP {iso(1) identified-organization(3) dod(6) internet(1) private(4)
enterprise(1) cable-Television-Laboratories-Inc(4491) clabProject(2)
clabProjPacketCable(2) pktcLawfulIntercept(5) pcesp(1) version-4(4)}
DEFINITIONS IMPLICIT TAGS ::=
BEGIN
ProtocolVersion ::= ENUMERATED
{
-- Versions IO1 and IO2 do not support protocol versioning.
v3(3), -- Version supporting PacketCable Electronic Surveillance
-- Specification I03
v4(4), -- Version supporting PacketCable Electronic Surveillance
-- Specification I04
...
}
CdcPdu ::= SEQUENCE
{
protocolVersion [0] ProtocolVersion,
message [1] Message,
...
}
Message ::= CHOICE
{
answer [1] Answer,
ccclose [2] CCClose,
ccopen [3] CCOpen,
reserved0 [4] NULL, -- Reserved
origination [5] Origination,
reserved1 [6] NULL, -- Reserved
redirection [7] Redirection,
release [8] Release,
reserved2 [9] NULL, -- Reserved
terminationattempt [10] TerminationAttempt,
reserved [11] NULL, -- Reserved
ccchange [12] CCChange,
reserved3 [13] NULL, -- Reserved
reserved4 [14] NULL, -- Reserved
dialeddigitextraction [15] DialedDigitExtraction,
networksignal [16] NetworkSignal,
subjectsignal [17] SubjectSignal,
mediareport [18] MediaReport,
serviceinstance [19] ServiceInstance,
confpartychange [20] ConferencePartyChange,
...
}
Answer ::= SEQUENCE
{
caseId [0] CaseId,
accessingElementId [1] AccessingElementId,
eventTime [2] EventTime,
callId [3] CallId,
answering [4] PartyId OPTIONAL,
...
}
CCChange ::= SEQUENCE
{
caseId [0] CaseId,
accessingElementId [1] AccessingElementId,
eventTime [2] EventTime,
callId [3] CallId,
cCCId [4] EXPLICIT CCCId,
subject [5] SDP OPTIONAL,
associate [6] SDP OPTIONAL,
flowDirection [7] FlowDirection,
resourceState [8] ResourceState OPTIONAL,
...
}
CCClose ::= SEQUENCE
{
caseId [0] CaseId,
accessingElementId [1] AccessingElementId,
eventTime [2] EventTime,
cCCId [3] EXPLICIT CCCId,
flowDirection [4] FlowDirection,
...
}
CCOpen ::= SEQUENCE
{
caseId [0] CaseId,
accessingElementId [1] AccessingElementId,
eventTime [2] EventTime,
ccOpenOption CHOICE
{
ccOpenTime [3] SEQUENCE OF CallId,
reserved0 [4] NULL, -- Reserved
...
},
cCCId [5] EXPLICIT CCCId,
subject [6] SDP OPTIONAL,
associate [7] SDP OPTIONAL,
flowDirection [8] FlowDirection,
...
}
ConferencePartyChange ::= SEQUENCE
{
caseId [0] CaseId,
accessingElementId [1] AccessingElementId,
eventTime [2] EventTime,
callId [3] CallId,
communicating [4] SEQUENCE OF SEQUENCE
{
-- include to identify parties participating in the
-- communication.
partyId [0] SEQUENCE OF PartyId OPTIONAL,
-- identifies communicating party identities.
cCCId [1] EXPLICIT CCCId OPTIONAL,
-- included when the content of the resulting call is
-- delivered to identify the associated CCC(s).
...
} OPTIONAL,
removed [5] SEQUENCE OF SEQUENCE
{
-- include to identify parties removed (e.g., hold
-- service) from the communication.
partyId [0] SEQUENCE OF PartyId OPTIONAL,
-- identifies removed party identity(ies).
cCCId [1] EXPLICIT CCCId OPTIONAL,
-- included when the content of the resulting call is
-- delivered to identify the associated CCC(s).
...
} OPTIONAL,
joined [6] SEQUENCE OF SEQUENCE
{
-- include to identify parties newly added to the
-- communication.
partyId [0] SEQUENCE OF PartyId OPTIONAL,
-- identifies newly added party identity(ies) to an existing
-- communication.
cCCId [1] EXPLICIT CCCId OPTIONAL,
-- included when the content of the resulting call is
-- delivered to identify the associated CCC(s).
...
} OPTIONAL,
...
}
DialedDigitExtraction ::= SEQUENCE
{
caseId [0] CaseId,
accessingElementId [1] AccessingElementId,
eventTime [2] EventTime,
callId [3] CallId,
digits [4] VisibleString (SIZE (1..32, ...)),
-- string consisting of digits representing
-- Dual Tone Multi Frequency (DTMF) tones
-- having values from the following numbers,
-- letters, and symbols:
-- '0", '1", '2", '3", '4", '5", '6", '7",
-- '8", '9", '#", '*", 'A", 'B", 'C", 'D".
-- Example: '123AB" or '*66" or '345#"
...
}
MediaReport ::= SEQUENCE
{
caseId [0] CaseId,
accessingElementId [1] AccessingElementId,
eventTime [2] EventTime,
callId [3] CallId,
subject [4] SDP OPTIONAL,
associate [5] SDP OPTIONAL,
...
}
NetworkSignal ::= SEQUENCE
{
caseId [0] CaseId,
accessingElementId [1] AccessingElementId,
eventTime [2] EventTime,
callId [3] CallId,
-- Signal
-- The following four parameters are used to report
-- information regarding network-generated signals.
-- Include at least one of the following four
-- parameters to identify the network-generated signal
-- being reported.
alertingSignal [4] AlertingSignal OPTIONAL,
subjectAudibleSignal [5] AudibleSignal OPTIONAL,
terminalDisplayInfo [6] TerminalDisplayInfo OPTIONAL,
other [7] VisibleString (SIZE (1..128, ...)) OPTIONAL,
-- Can be used to report undefined network signals
signaledToPartyId [8] PartyId,
...
}
Origination ::= SEQUENCE
{
caseId [0] CaseId,
accessingElementId [1] AccessingElementId,
eventTime [2] EventTime,
callId [3] CallId,
calling [4] PartyId,
called [5] PartyId OPTIONAL,
input CHOICE {
userinput [6] VisibleString (SIZE (1..32, ...)),
translationinput [7] VisibleString (SIZE (1..32, ...)),
...
},
reserved0 [8] NULL, -- Reserved
transitCarrierId [9] TransitCarrierId OPTIONAL,
...
}
Redirection ::= SEQUENCE
{
caseId [0] CaseId,
accessingElementId [1] AccessingElementId,
eventTime [2] EventTime,
old [3] CallId,
redirectedto [4] PartyId,
transitCarrierId [5] TransitCarrierId OPTIONAL,
reserved0 [6] NULL, -- Reserved
reserved1 [7] NULL, -- Reserved
new [8] CallId OPTIONAL,
redirectedfrom [9] PartyId OPTIONAL,
...
}
Release ::= SEQUENCE
{
caseId [0] CaseId,
accessingElementId [1] AccessingElementId,
eventTime [2] EventTime,
callId [3] CallId,
...
}
ServiceInstance ::= SEQUENCE
{
caseId [0] CaseId,
accessingElementId [1] AccessingElementId,
eventTime [2] EventTime,
callId [3] CallId,
relatedCallId [4] CallId OPTIONAL,
serviceName [5] VisibleString (SIZE (1..128, ...)),
firstCallCalling [6] PartyId OPTIONAL,
secondCallCalling [7] PartyId OPTIONAL,
called [8] PartyId OPTIONAL,
calling [9] PartyId OPTIONAL,
...
}
SubjectSignal ::= SEQUENCE
{
caseId [0] CaseId,
accessingElementId [1] AccessingElementId,
eventTime [2] EventTime,
callId [3] CallId OPTIONAL,
signal [4] SEQUENCE {
-- The following four parameters are used to report
-- information regarding subject-initiated dialing and
-- signaling. Include at least one of the following four
-- parameters to identify the subject- initiated dialing
-- and signaling information being reported.
switchhookFlash [0] VisibleString (SIZE (1..128, ...)) OPTIONAL,
dialedDigits [1] VisibleString (SIZE (1..128, ...)) OPTIONAL,
featureKey [2] VisibleString (SIZE (1..128, ...)) OPTIONAL,
otherSignalingInformation [3] VisibleString (SIZE (1..128, ...)) OPTIONAL,
-- Can be used to report undefined subject signals
...
},
signaledFromPartyId [5] PartyId,
...
}
TerminationAttempt ::= SEQUENCE
{
caseId [0] CaseId,
accessingElementId [1] AccessingElementId,
eventTime [2] EventTime,
callId [3] CallId,
calling [4] PartyId OPTIONAL,
called [5] PartyId OPTIONAL,
reserved0 [6] NULL, -- Reserved
redirectedFromInfo [7] RedirectedFromInfo OPTIONAL,
...
}
AccessingElementId ::= VisibleString (SIZE(1..15, ...))
-- Statically configured element number
AlertingSignal ::= ENUMERATED
{
notUsed (0), -- Reserved
alertingPattern0 (1), -- normal ringing
alertingPattern1 (2), -- distinctive ringing: intergroup
alertingPattern2 (3), -- distinctive ringing: special/priority
alertingPattern3 (4), -- distinctive ringing: electronic key
-- telephone srvc
alertingPattern4 (5), -- ringsplash, reminder ring
callWaitingPattern1 (6), -- normal call waiting tone
callWaitingPattern2 (7), -- incoming additional call waiting tone
callWaitingPattern3 (8), -- priority additional call waiting tone
callWaitingPattern4 (9), -- distinctive call waiting tone
bargeInTone (10), -- barge-in tone (e.g. for operator barge-in)
alertingPattern5 (11), -- distinctive ringing: solution specific
alertingPattern6 (12), -- distinctive ringing: solution specific
alertingPattern7 (13), -- distinctive ringing: solution specific
alertingPattern8 (14), -- distinctive ringing: solution specific
alertingPattern9 (15),