├── mts-asn1-per ├── src │ ├── test │ │ ├── resources │ │ │ ├── data │ │ │ │ ├── sample │ │ │ │ │ ├── sample.hex │ │ │ │ │ ├── sample.bin │ │ │ │ │ ├── sample.json │ │ │ │ │ └── sample.xml │ │ │ │ └── S1AP │ │ │ │ │ ├── eNodeB_Setup │ │ │ │ │ ├── S1SetupResponse │ │ │ │ │ │ ├── S1SetupResponse.hex │ │ │ │ │ │ ├── S1SetupResponse.bin │ │ │ │ │ │ ├── S1SetupResponse.json │ │ │ │ │ │ └── S1SetupResponse.xml │ │ │ │ │ └── S1SetupRequest │ │ │ │ │ │ ├── S1SetupRequest.hex │ │ │ │ │ │ ├── S1SetupRequest.bin │ │ │ │ │ │ ├── S1SetupRequest.json │ │ │ │ │ │ └── S1SetupRequest.xml │ │ │ │ │ ├── id-E-RABModify │ │ │ │ │ ├── E-RABModifyResponse │ │ │ │ │ │ ├── E-RABModifyResponse.hex │ │ │ │ │ │ ├── E-RABModifyResponse.bin │ │ │ │ │ │ ├── E-RABModifyResponse.json │ │ │ │ │ │ └── E-RABModifyResponse.xml │ │ │ │ │ └── E-RABModifyRequest │ │ │ │ │ │ ├── E-RABModifyRequest.bin │ │ │ │ │ │ ├── E-RABModifyRequest.hex │ │ │ │ │ │ └── E-RABModifyRequest.json │ │ │ │ │ ├── weird_imsi_structure │ │ │ │ │ ├── UEContextReleaseCommand │ │ │ │ │ │ ├── UEContextReleaseCommand.hex │ │ │ │ │ │ ├── UEContextReleaseCommand.bin │ │ │ │ │ │ ├── UEContextReleaseCommand.json │ │ │ │ │ │ └── UEContextReleaseCommand.xml │ │ │ │ │ ├── UEContextReleaseCommand2 │ │ │ │ │ │ ├── UEContextReleaseCommand2.hex │ │ │ │ │ │ ├── UEContextReleaseCommand2.bin │ │ │ │ │ │ ├── UEContextReleaseCommand2.json │ │ │ │ │ │ └── UEContextReleaseCommand2.xml │ │ │ │ │ ├── UEContextReleaseCommand3 │ │ │ │ │ │ ├── UEContextReleaseCommand3.hex │ │ │ │ │ │ ├── UEContextReleaseCommand3.bin │ │ │ │ │ │ ├── UEContextReleaseCommand3.json │ │ │ │ │ │ └── UEContextReleaseCommand3.xml │ │ │ │ │ ├── UEContextReleaseComplete │ │ │ │ │ │ ├── UEContextReleaseComplete.hex │ │ │ │ │ │ ├── UEContextReleaseComplete.bin │ │ │ │ │ │ ├── UEContextReleaseComplete.json │ │ │ │ │ │ └── UEContextReleaseComplete.xml │ │ │ │ │ ├── UEContextReleaseComplete2 │ │ │ │ │ │ ├── UEContextReleaseComplete2.hex │ │ │ │ │ │ ├── UEContextReleaseComplete2.bin │ │ │ │ │ │ ├── UEContextReleaseComplete2.json │ │ │ │ │ │ └── UEContextReleaseComplete2.xml │ │ │ │ │ ├── UEContextReleaseComplete3 │ │ │ │ │ │ ├── UEContextReleaseComplete3.hex │ │ │ │ │ │ ├── UEContextReleaseComplete3.bin │ │ │ │ │ │ ├── UEContextReleaseComplete3.json │ │ │ │ │ │ └── UEContextReleaseComplete3.xml │ │ │ │ │ ├── DownlinkNASTransport │ │ │ │ │ │ ├── DownlinkNASTransport.hex │ │ │ │ │ │ ├── DownlinkNASTransport.bin │ │ │ │ │ │ ├── DownlinkNASTransport.json │ │ │ │ │ │ └── DownlinkNASTransport.xml │ │ │ │ │ ├── DownlinkNASTransport2 │ │ │ │ │ │ ├── DownlinkNASTransport2.hex │ │ │ │ │ │ ├── DownlinkNASTransport2.bin │ │ │ │ │ │ ├── DownlinkNASTransport2.json │ │ │ │ │ │ └── DownlinkNASTransport2.xml │ │ │ │ │ ├── DownlinkNASTransport3 │ │ │ │ │ │ ├── DownlinkNASTransport3.hex │ │ │ │ │ │ ├── DownlinkNASTransport3.bin │ │ │ │ │ │ ├── DownlinkNASTransport3.json │ │ │ │ │ │ └── DownlinkNASTransport3.xml │ │ │ │ │ ├── InitialUEMessage │ │ │ │ │ │ ├── InitialUEMessage.bin │ │ │ │ │ │ ├── InitialUEMessage.hex │ │ │ │ │ │ ├── InitialUEMessage.json │ │ │ │ │ │ └── InitialUEMessage.xml │ │ │ │ │ ├── InitialUEMessage2 │ │ │ │ │ │ ├── InitialUEMessage2.bin │ │ │ │ │ │ ├── InitialUEMessage2.hex │ │ │ │ │ │ ├── InitialUEMessage2.json │ │ │ │ │ │ └── InitialUEMessage2.xml │ │ │ │ │ └── InitialUEMessage3 │ │ │ │ │ │ ├── InitialUEMessage3.bin │ │ │ │ │ │ ├── InitialUEMessage3.hex │ │ │ │ │ │ ├── InitialUEMessage3.json │ │ │ │ │ │ └── InitialUEMessage3.xml │ │ │ │ │ ├── InitialContextSetup │ │ │ │ │ ├── InitialContextSetupResponse │ │ │ │ │ │ ├── S1AP-2.hex │ │ │ │ │ │ ├── S1AP-2.bin │ │ │ │ │ │ ├── S1AP-2.json │ │ │ │ │ │ └── S1AP-2.xml │ │ │ │ │ └── InitialContextSetupRequest │ │ │ │ │ │ ├── S1AP-1.bin │ │ │ │ │ │ ├── S1AP-1.hex │ │ │ │ │ │ └── S1AP-1.json │ │ │ │ │ └── auth_w_sync_failure │ │ │ │ │ ├── UplinkNASTransport2 │ │ │ │ │ ├── UplinkNASTransport2.hex │ │ │ │ │ ├── UplinkNASTransport2.bin │ │ │ │ │ ├── UplinkNASTransport2.json │ │ │ │ │ └── UplinkNASTransport2.xml │ │ │ │ │ ├── DownlinkNASTransport │ │ │ │ │ ├── DownlinkNASTransport.hex │ │ │ │ │ ├── DownlinkNASTransport.bin │ │ │ │ │ ├── DownlinkNASTransport.json │ │ │ │ │ └── DownlinkNASTransport.xml │ │ │ │ │ ├── DownlinkNASTransport2 │ │ │ │ │ ├── DownlinkNASTransport2.hex │ │ │ │ │ ├── DownlinkNASTransport2.bin │ │ │ │ │ ├── DownlinkNASTransport2.json │ │ │ │ │ └── DownlinkNASTransport2.xml │ │ │ │ │ ├── UplinkNASTransport │ │ │ │ │ ├── UplinkNASTransport.hex │ │ │ │ │ ├── UplinkNASTransport.bin │ │ │ │ │ ├── UplinkNASTransport.json │ │ │ │ │ └── UplinkNASTransport.xml │ │ │ │ │ └── InitialUEMessage │ │ │ │ │ ├── InitialUEMessage.bin │ │ │ │ │ ├── InitialUEMessage.hex │ │ │ │ │ ├── InitialUEMessage.json │ │ │ │ │ └── InitialUEMessage.xml │ │ │ ├── wireshark │ │ │ │ └── s1ap │ │ │ │ │ ├── eNodeB_Setup.pcap │ │ │ │ │ ├── id-E-RABModify.pcap │ │ │ │ │ ├── auth_w_sync_failure.pcap │ │ │ │ │ ├── initialContextSetup.pcap │ │ │ │ │ └── weird_imsi_structure.cap │ │ │ ├── grammar │ │ │ │ ├── NGAP │ │ │ │ │ └── NGAP-Common-Definitions.asn │ │ │ │ └── sample │ │ │ │ │ └── examplev2.asn │ │ │ └── simplelogger.properties │ │ └── java │ │ │ └── com │ │ │ └── ericsson │ │ │ └── mts │ │ │ └── asn1 │ │ │ ├── SampleTests.java │ │ │ ├── S1APENodeBSetup.java │ │ │ ├── S1APTests.java │ │ │ └── S1APAuthWSyncFailure.java │ └── main │ │ └── java │ │ └── com │ │ └── ericsson │ │ └── mts │ │ └── asn1 │ │ ├── translator │ │ ├── PERObjectIdentifierTranslator.java │ │ ├── PERRealTranslator.java │ │ ├── PERBooleanTranslator.java │ │ └── PEREnumeratedTranslator.java │ │ ├── CoderUtils.java │ │ └── PERTranslatorFactory.java └── pom.xml ├── .gitignore ├── .m2 └── settings.xml ├── mts-asn1-xml └── pom.xml ├── mts-asn1-json └── pom.xml ├── LICENSE.txt ├── README.md ├── mts-asn1-core ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── ericsson │ └── mts │ └── asn1 │ ├── constant │ ├── IntegerConstant.java │ └── AbstractConstant.java │ ├── exception │ ├── InvalidParameterException.java │ ├── UnknownIdentifierException.java │ ├── EncodingException.java │ ├── ANTLRVisitorException.java │ └── NotHandledCaseException.java │ ├── constraint │ ├── TypeConstraint.java │ ├── AbstractConstraint.java │ ├── ContentsConstraint.java │ ├── ClassFieldConstraint.java │ ├── SizeConstraint.java │ ├── ValueRangeConstraint.java │ ├── SingleValueConstraint.java │ └── AbstractRangeConstraint.java │ ├── TranslatorContext.java │ ├── registry │ └── ParsedRegistry.java │ ├── factory │ ├── FormatReader.java │ ├── FormatWriter.java │ └── AbstractTranslatorFactory.java │ ├── visitor │ └── TopLevelVisitor.java │ ├── translator │ ├── AbstractObjectIdentifierTranslator.java │ ├── NullTranslator.java │ ├── AbstractRealTranslator.java │ ├── AbstractBooleanTranslator.java │ ├── AbstractBitStringTranslator.java │ ├── AbstractOctetStringTranslator.java │ └── AbstractRestrictedCharacterStringTranslator.java │ ├── BitArray.java │ └── ASN1Translator.java ├── .github └── workflows │ ├── maven-publish-snapshot.yml │ └── maven-publish-release.yml ├── mts-asn1-antlr └── pom.xml └── mts-asn1-maven-plugin ├── src └── main │ └── java │ └── com │ └── ericsson │ └── mts │ └── asn1 │ └── plugin │ ├── MtsAsn1Mojo.java │ ├── ConstantsGenerator.java │ └── IdentifierVisitor.java └── pom.xml /mts-asn1-per/src/test/resources/data/sample/sample.hex: -------------------------------------------------------------------------------- 1 | 16 ec -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ### IntelliJ ### 2 | .idea/ 3 | *.iml 4 | 5 | type/ 6 | target 7 | -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/eNodeB_Setup/S1SetupResponse/S1SetupResponse.hex: -------------------------------------------------------------------------------- 1 | 20110022000003003d400702006d6d6538310069000b000000f1100000032b005100574001ff -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/id-E-RABModify/E-RABModifyResponse/E-RABModifyResponse.hex: -------------------------------------------------------------------------------- 1 | 2006001e00000300004005c005c83fd0000840048009dece001f400600002540010a -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/UEContextReleaseCommand/UEContextReleaseCommand.hex: -------------------------------------------------------------------------------- 1 | 00170015000002006300090cdc1be30a801f720f0002400126 -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/UEContextReleaseCommand2/UEContextReleaseCommand2.hex: -------------------------------------------------------------------------------- 1 | 00170015000002006300090cdc1be2cd801f72100002400126 -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/UEContextReleaseCommand3/UEContextReleaseCommand3.hex: -------------------------------------------------------------------------------- 1 | 00170015000002006300090cdc1bedd9801f72110002400126 -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/UEContextReleaseComplete/UEContextReleaseComplete.hex: -------------------------------------------------------------------------------- 1 | 2017001400000200004005c0dc1be30a00084004801f720f -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/UEContextReleaseComplete2/UEContextReleaseComplete2.hex: -------------------------------------------------------------------------------- 1 | 2017001400000200004005c0dc1be2cd00084004801f7210 -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/UEContextReleaseComplete3/UEContextReleaseComplete3.hex: -------------------------------------------------------------------------------- 1 | 2017001400000200004005c0dc1bedd900084004801f7211 -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/sample/sample.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsson-mts/mts-asn1/HEAD/mts-asn1-per/src/test/resources/data/sample/sample.bin -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/DownlinkNASTransport/DownlinkNASTransport.hex: -------------------------------------------------------------------------------- 1 | 000b401c00000300000005c0dc1be30a00080004801f720f001a000403076060 -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/DownlinkNASTransport2/DownlinkNASTransport2.hex: -------------------------------------------------------------------------------- 1 | 000b401c00000300000005c0dc1be2cd00080004801f7210001a000403076060 -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/DownlinkNASTransport3/DownlinkNASTransport3.hex: -------------------------------------------------------------------------------- 1 | 000b401c00000300000005c0dc1bedd900080004801f7211001a000403076060 -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/sample/sample.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": { 3 | "a": true, 4 | "b": 55, 5 | "c": 3, 6 | "d": false, 7 | "e": "on" 8 | } 9 | } -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/wireshark/s1ap/eNodeB_Setup.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsson-mts/mts-asn1/HEAD/mts-asn1-per/src/test/resources/wireshark/s1ap/eNodeB_Setup.pcap -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/wireshark/s1ap/id-E-RABModify.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsson-mts/mts-asn1/HEAD/mts-asn1-per/src/test/resources/wireshark/s1ap/id-E-RABModify.pcap -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/wireshark/s1ap/auth_w_sync_failure.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsson-mts/mts-asn1/HEAD/mts-asn1-per/src/test/resources/wireshark/s1ap/auth_w_sync_failure.pcap -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/wireshark/s1ap/initialContextSetup.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsson-mts/mts-asn1/HEAD/mts-asn1-per/src/test/resources/wireshark/s1ap/initialContextSetup.pcap -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/wireshark/s1ap/weird_imsi_structure.cap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsson-mts/mts-asn1/HEAD/mts-asn1-per/src/test/resources/wireshark/s1ap/weird_imsi_structure.cap -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/InitialContextSetup/InitialContextSetupResponse/S1AP-2.hex: -------------------------------------------------------------------------------- 1 | 200900300000030000400200250008400200240033401d010032400a0a1f0afbfc084b0000000032400a0c1f0afbfc084c000000 -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/auth_w_sync_failure/UplinkNASTransport2/UplinkNASTransport2.hex: -------------------------------------------------------------------------------- 1 | 000d4035000005000000020000000800020001001a000c0b075308deba34fd848a4448006440080055f53100001010004340060055f531b26e -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/eNodeB_Setup/S1SetupRequest/S1SetupRequest.hex: -------------------------------------------------------------------------------- 1 | 0011003f000004003b00080000f11000070800003c400a0380617269632d654e42004000190300030000f1100002c000f11000028000f11000024000f1100089000100 -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/auth_w_sync_failure/DownlinkNASTransport/DownlinkNASTransport.hex: -------------------------------------------------------------------------------- 1 | 000b4038000003000000020000000800020001001a0025240752004711471147114711471147114711471110389046869a1cb9b94d4fc785b83d07dd -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/auth_w_sync_failure/DownlinkNASTransport2/DownlinkNASTransport2.hex: -------------------------------------------------------------------------------- 1 | 000b4038000003000000020000000800020001001a002524075201b8eeb8eeb8eeb8eeb8eeb8eeb8eeb8ee10b14d41f46e52b9b9e10fa67cbfda8011 -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/auth_w_sync_failure/UplinkNASTransport/UplinkNASTransport.hex: -------------------------------------------------------------------------------- 1 | 000d403d000005000000020000000800020001001a001413075c15300e76096683482650040a6fae3f2ce2006440080055f53100001010004340060055f531b26e -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/eNodeB_Setup/S1SetupRequest/S1SetupRequest.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsson-mts/mts-asn1/HEAD/mts-asn1-per/src/test/resources/data/S1AP/eNodeB_Setup/S1SetupRequest/S1SetupRequest.bin -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/eNodeB_Setup/S1SetupResponse/S1SetupResponse.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsson-mts/mts-asn1/HEAD/mts-asn1-per/src/test/resources/data/S1AP/eNodeB_Setup/S1SetupResponse/S1SetupResponse.bin -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/sample/sample.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | true 4 | 55 5 | 3 6 | false 7 | on 8 | 9 | 10 | -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/id-E-RABModify/E-RABModifyRequest/E-RABModifyRequest.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsson-mts/mts-asn1/HEAD/mts-asn1-per/src/test/resources/data/S1AP/id-E-RABModify/E-RABModifyRequest/E-RABModifyRequest.bin -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/InitialContextSetup/InitialContextSetupRequest/S1AP-1.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsson-mts/mts-asn1/HEAD/mts-asn1-per/src/test/resources/data/S1AP/InitialContextSetup/InitialContextSetupRequest/S1AP-1.bin -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/InitialContextSetup/InitialContextSetupResponse/S1AP-2.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsson-mts/mts-asn1/HEAD/mts-asn1-per/src/test/resources/data/S1AP/InitialContextSetup/InitialContextSetupResponse/S1AP-2.bin -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/auth_w_sync_failure/InitialUEMessage/InitialUEMessage.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsson-mts/mts-asn1/HEAD/mts-asn1-per/src/test/resources/data/S1AP/auth_w_sync_failure/InitialUEMessage/InitialUEMessage.bin -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/id-E-RABModify/E-RABModifyResponse/E-RABModifyResponse.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsson-mts/mts-asn1/HEAD/mts-asn1-per/src/test/resources/data/S1AP/id-E-RABModify/E-RABModifyResponse/E-RABModifyResponse.bin -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/InitialUEMessage/InitialUEMessage.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsson-mts/mts-asn1/HEAD/mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/InitialUEMessage/InitialUEMessage.bin -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/auth_w_sync_failure/UplinkNASTransport/UplinkNASTransport.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsson-mts/mts-asn1/HEAD/mts-asn1-per/src/test/resources/data/S1AP/auth_w_sync_failure/UplinkNASTransport/UplinkNASTransport.bin -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/InitialUEMessage2/InitialUEMessage2.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsson-mts/mts-asn1/HEAD/mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/InitialUEMessage2/InitialUEMessage2.bin -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/InitialUEMessage3/InitialUEMessage3.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsson-mts/mts-asn1/HEAD/mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/InitialUEMessage3/InitialUEMessage3.bin -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/auth_w_sync_failure/UplinkNASTransport2/UplinkNASTransport2.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsson-mts/mts-asn1/HEAD/mts-asn1-per/src/test/resources/data/S1AP/auth_w_sync_failure/UplinkNASTransport2/UplinkNASTransport2.bin -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/auth_w_sync_failure/DownlinkNASTransport/DownlinkNASTransport.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsson-mts/mts-asn1/HEAD/mts-asn1-per/src/test/resources/data/S1AP/auth_w_sync_failure/DownlinkNASTransport/DownlinkNASTransport.bin -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/DownlinkNASTransport/DownlinkNASTransport.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsson-mts/mts-asn1/HEAD/mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/DownlinkNASTransport/DownlinkNASTransport.bin -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/auth_w_sync_failure/DownlinkNASTransport2/DownlinkNASTransport2.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsson-mts/mts-asn1/HEAD/mts-asn1-per/src/test/resources/data/S1AP/auth_w_sync_failure/DownlinkNASTransport2/DownlinkNASTransport2.bin -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/DownlinkNASTransport2/DownlinkNASTransport2.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsson-mts/mts-asn1/HEAD/mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/DownlinkNASTransport2/DownlinkNASTransport2.bin -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/DownlinkNASTransport3/DownlinkNASTransport3.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsson-mts/mts-asn1/HEAD/mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/DownlinkNASTransport3/DownlinkNASTransport3.bin -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/id-E-RABModify/E-RABModifyRequest/E-RABModifyRequest.hex: -------------------------------------------------------------------------------- 1 | 0006005700000400000005c005c83fd0000800048009dece0042000a180c350000600c350000001e0031000024002c0a00060527279523c609029f4d7d259da8541d64e92dad3223700fcb756cb03c2b9d5db0a94c7ebcadd22655 -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/InitialUEMessage/InitialUEMessage.hex: -------------------------------------------------------------------------------- 1 | 000c405700000500080004801f720f001a002d2c0748720b29071855102132713a85895805f0f0c040105c1004570200003103e5e0349011035758825d0100c1004300060013210230390064400800132102011004300086400130 -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/InitialUEMessage2/InitialUEMessage2.hex: -------------------------------------------------------------------------------- 1 | 000c405700000500080004801f7210001a002d2c0748720b29071855102132713a85895805f0f0c040105c1004570200003103e5e0349011035758825d0100c1004300060013210230390064400800132102011004300086400130 -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/InitialUEMessage3/InitialUEMessage3.hex: -------------------------------------------------------------------------------- 1 | 000c405700000500080004801f7211001a002d2c0748720b29071855102132713a85895805f0f0c040105c1004570200003103e5e0349011035758825d0100c1004300060013210230390064400800132102011004300086400130 -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/UEContextReleaseCommand/UEContextReleaseCommand.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsson-mts/mts-asn1/HEAD/mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/UEContextReleaseCommand/UEContextReleaseCommand.bin -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/UEContextReleaseCommand2/UEContextReleaseCommand2.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsson-mts/mts-asn1/HEAD/mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/UEContextReleaseCommand2/UEContextReleaseCommand2.bin -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/UEContextReleaseCommand3/UEContextReleaseCommand3.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsson-mts/mts-asn1/HEAD/mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/UEContextReleaseCommand3/UEContextReleaseCommand3.bin -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/UEContextReleaseComplete/UEContextReleaseComplete.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsson-mts/mts-asn1/HEAD/mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/UEContextReleaseComplete/UEContextReleaseComplete.bin -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/UEContextReleaseComplete2/UEContextReleaseComplete2.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsson-mts/mts-asn1/HEAD/mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/UEContextReleaseComplete2/UEContextReleaseComplete2.bin -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/UEContextReleaseComplete3/UEContextReleaseComplete3.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsson-mts/mts-asn1/HEAD/mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/UEContextReleaseComplete3/UEContextReleaseComplete3.bin -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/auth_w_sync_failure/InitialUEMessage/InitialUEMessage.hex: -------------------------------------------------------------------------------- 1 | 000c406b000005000800020001001a0043420741720bf655f531870148e000000102e0e000210201d011d1271a8080211001000010810600000000830600000000000d00000a005255f531b26e9011034f18a6e0004300060055f531b26e006440080055f531000010100086400130 -------------------------------------------------------------------------------- /.m2/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ossrh 5 | ${env.OSSRH_USERNAME} 6 | ${env.OSSRH_TOKEN} 7 | 8 | 9 | gpg.passphrase 10 | ${env.GPG_PASSPHRASE} 11 | 12 | 13 | -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/UEContextReleaseCommand/UEContextReleaseCommand.json: -------------------------------------------------------------------------------- 1 | {"initiatingMessage":{"procedureCode":23,"criticality":"reject","value":{"UEContextReleaseCommand":{"protocolIEs":[{"id":99,"criticality":"reject","value":{"UE-S1AP-IDs":{"uE-S1AP-ID-pair":{"mME-UE-S1AP-ID":3692815114,"eNB-UE-S1AP-ID":2060815}}}},{"id":2,"criticality":"ignore","value":{"Cause":{"nas":"unspecified"}}}]}}}} -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/UEContextReleaseCommand2/UEContextReleaseCommand2.json: -------------------------------------------------------------------------------- 1 | {"initiatingMessage":{"procedureCode":23,"criticality":"reject","value":{"UEContextReleaseCommand":{"protocolIEs":[{"id":99,"criticality":"reject","value":{"UE-S1AP-IDs":{"uE-S1AP-ID-pair":{"mME-UE-S1AP-ID":3692815053,"eNB-UE-S1AP-ID":2060816}}}},{"id":2,"criticality":"ignore","value":{"Cause":{"nas":"unspecified"}}}]}}}} -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/UEContextReleaseCommand3/UEContextReleaseCommand3.json: -------------------------------------------------------------------------------- 1 | {"initiatingMessage":{"procedureCode":23,"criticality":"reject","value":{"UEContextReleaseCommand":{"protocolIEs":[{"id":99,"criticality":"reject","value":{"UE-S1AP-IDs":{"uE-S1AP-ID-pair":{"mME-UE-S1AP-ID":3692817881,"eNB-UE-S1AP-ID":2060817}}}},{"id":2,"criticality":"ignore","value":{"Cause":{"nas":"unspecified"}}}]}}}} -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/UEContextReleaseComplete/UEContextReleaseComplete.json: -------------------------------------------------------------------------------- 1 | { 2 | "successfulOutcome": { 3 | "procedureCode": 23, 4 | "criticality": "reject", 5 | "value": { 6 | "UEContextReleaseComplete": { 7 | "protocolIEs": [ 8 | { 9 | "id": 0, 10 | "criticality": "ignore", 11 | "value": { 12 | "MME-UE-S1AP-ID": 3692815114 13 | } 14 | }, 15 | { 16 | "id": 8, 17 | "criticality": "ignore", 18 | "value": { 19 | "ENB-UE-S1AP-ID": 2060815 20 | } 21 | } 22 | ] 23 | } 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/UEContextReleaseComplete2/UEContextReleaseComplete2.json: -------------------------------------------------------------------------------- 1 | { 2 | "successfulOutcome": { 3 | "procedureCode": 23, 4 | "criticality": "reject", 5 | "value": { 6 | "UEContextReleaseComplete": { 7 | "protocolIEs": [ 8 | { 9 | "id": 0, 10 | "criticality": "ignore", 11 | "value": { 12 | "MME-UE-S1AP-ID": 3692815053 13 | } 14 | }, 15 | { 16 | "id": 8, 17 | "criticality": "ignore", 18 | "value": { 19 | "ENB-UE-S1AP-ID": 2060816 20 | } 21 | } 22 | ] 23 | } 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/UEContextReleaseComplete3/UEContextReleaseComplete3.json: -------------------------------------------------------------------------------- 1 | { 2 | "successfulOutcome": { 3 | "procedureCode": 23, 4 | "criticality": "reject", 5 | "value": { 6 | "UEContextReleaseComplete": { 7 | "protocolIEs": [ 8 | { 9 | "id": 0, 10 | "criticality": "ignore", 11 | "value": { 12 | "MME-UE-S1AP-ID": 3692817881 13 | } 14 | }, 15 | { 16 | "id": 8, 17 | "criticality": "ignore", 18 | "value": { 19 | "ENB-UE-S1AP-ID": 2060817 20 | } 21 | } 22 | ] 23 | } 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /mts-asn1-xml/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | mts-asn1 7 | io.github.ericsson-mts 8 | master-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | mts-asn1-xml 13 | 14 | 15 | 16 | io.github.ericsson-mts 17 | mts-asn1-core 18 | master-SNAPSHOT 19 | 20 | 21 | -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/DownlinkNASTransport/DownlinkNASTransport.json: -------------------------------------------------------------------------------- 1 | { 2 | "initiatingMessage": { 3 | "procedureCode": 11, 4 | "criticality": "ignore", 5 | "value": { 6 | "DownlinkNASTransport": { 7 | "protocolIEs": [ 8 | { 9 | "id": 0, 10 | "criticality": "reject", 11 | "value": { 12 | "MME-UE-S1AP-ID": 3692815114 13 | } 14 | }, 15 | { 16 | "id": 8, 17 | "criticality": "reject", 18 | "value": { 19 | "ENB-UE-S1AP-ID": 2060815 20 | } 21 | }, 22 | { 23 | "id": 26, 24 | "criticality": "reject", 25 | "value": { 26 | "NAS-PDU": "076060" 27 | } 28 | } 29 | ] 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/DownlinkNASTransport2/DownlinkNASTransport2.json: -------------------------------------------------------------------------------- 1 | { 2 | "initiatingMessage": { 3 | "procedureCode": 11, 4 | "criticality": "ignore", 5 | "value": { 6 | "DownlinkNASTransport": { 7 | "protocolIEs": [ 8 | { 9 | "id": 0, 10 | "criticality": "reject", 11 | "value": { 12 | "MME-UE-S1AP-ID": 3692815053 13 | } 14 | }, 15 | { 16 | "id": 8, 17 | "criticality": "reject", 18 | "value": { 19 | "ENB-UE-S1AP-ID": 2060816 20 | } 21 | }, 22 | { 23 | "id": 26, 24 | "criticality": "reject", 25 | "value": { 26 | "NAS-PDU": "076060" 27 | } 28 | } 29 | ] 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/DownlinkNASTransport3/DownlinkNASTransport3.json: -------------------------------------------------------------------------------- 1 | { 2 | "initiatingMessage": { 3 | "procedureCode": 11, 4 | "criticality": "ignore", 5 | "value": { 6 | "DownlinkNASTransport": { 7 | "protocolIEs": [ 8 | { 9 | "id": 0, 10 | "criticality": "reject", 11 | "value": { 12 | "MME-UE-S1AP-ID": 3692817881 13 | } 14 | }, 15 | { 16 | "id": 8, 17 | "criticality": "reject", 18 | "value": { 19 | "ENB-UE-S1AP-ID": 2060817 20 | } 21 | }, 22 | { 23 | "id": 26, 24 | "criticality": "reject", 25 | "value": { 26 | "NAS-PDU": "076060" 27 | } 28 | } 29 | ] 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/auth_w_sync_failure/DownlinkNASTransport/DownlinkNASTransport.json: -------------------------------------------------------------------------------- 1 | { 2 | "initiatingMessage": { 3 | "procedureCode": 11, 4 | "criticality": "ignore", 5 | "value": { 6 | "DownlinkNASTransport": { 7 | "protocolIEs": [ 8 | { 9 | "id": 0, 10 | "criticality": "reject", 11 | "value": { 12 | "MME-UE-S1AP-ID": 0 13 | } 14 | }, 15 | { 16 | "id": 8, 17 | "criticality": "reject", 18 | "value": { 19 | "ENB-UE-S1AP-ID": 1 20 | } 21 | }, 22 | { 23 | "id": 26, 24 | "criticality": "reject", 25 | "value": { 26 | "NAS-PDU": "0752004711471147114711471147114711471110389046869A1CB9B94D4FC785B83D07DD" 27 | } 28 | } 29 | ] 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/auth_w_sync_failure/DownlinkNASTransport2/DownlinkNASTransport2.json: -------------------------------------------------------------------------------- 1 | { 2 | "initiatingMessage": { 3 | "procedureCode": 11, 4 | "criticality": "ignore", 5 | "value": { 6 | "DownlinkNASTransport": { 7 | "protocolIEs": [ 8 | { 9 | "id": 0, 10 | "criticality": "reject", 11 | "value": { 12 | "MME-UE-S1AP-ID": 0 13 | } 14 | }, 15 | { 16 | "id": 8, 17 | "criticality": "reject", 18 | "value": { 19 | "ENB-UE-S1AP-ID": 1 20 | } 21 | }, 22 | { 23 | "id": 26, 24 | "criticality": "reject", 25 | "value": { 26 | "NAS-PDU": "075201B8EEB8EEB8EEB8EEB8EEB8EEB8EEB8EE10B14D41F46E52B9B9E10FA67CBFDA8011" 27 | } 28 | } 29 | ] 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /mts-asn1-json/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | mts-asn1 7 | io.github.ericsson-mts 8 | master-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | mts-asn1-json 13 | 14 | 15 | 16 | io.github.ericsson-mts 17 | mts-asn1-core 18 | master-SNAPSHOT 19 | 20 | 21 | com.fasterxml.jackson.core 22 | jackson-databind 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/grammar/NGAP/NGAP-Common-Definitions.asn: -------------------------------------------------------------------------------- 1 | -- ASN1START 2 | -- ************************************************************** 3 | -- 4 | -- Common definitions 5 | -- 6 | -- ************************************************************** 7 | 8 | NGAP-CommonDataTypes { 9 | itu-t (0) identified-organization (4) etsi (0) mobileDomain (0) 10 | ngran-Access (22) modules (3) ngap (1) version1 (1) ngap-CommonDataTypes (3) } 11 | 12 | DEFINITIONS AUTOMATIC TAGS ::= 13 | 14 | BEGIN 15 | 16 | Criticality ::= ENUMERATED { reject, ignore, notify } 17 | 18 | Presence ::= ENUMERATED { optional, conditional, mandatory } 19 | 20 | PrivateIE-ID ::= CHOICE { 21 | local INTEGER (0..65535), 22 | global OBJECT IDENTIFIER 23 | } 24 | 25 | ProcedureCode ::= INTEGER (0..255) 26 | 27 | ProtocolExtensionID ::= INTEGER (0..65535) 28 | 29 | ProtocolIE-ID ::= INTEGER (0..65535) 30 | 31 | TriggeringMessage ::= ENUMERATED { initiating-message, successful-outcome, unsuccessfull-outcome } 32 | 33 | END 34 | -- ASN1STOP 35 | -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/grammar/sample/examplev2.asn: -------------------------------------------------------------------------------- 1 | --- Second version of the Foo protocol. 2 | 3 | Foo DEFINITIONS AUTOMATIC TAGS ::= 4 | 5 | BEGIN 6 | 7 | State ::= ENUMERATED { 8 | on (0), 9 | off (1) 10 | } 11 | Foo ::= SEQUENCE { 12 | a BOOLEAN, 13 | b INTEGER (0..127), -- Fixed range, encoded in 7 bits. 14 | c INTEGER (0..7), -- Fixed range, encoded in 3 bits. 15 | d BOOLEAN, 16 | e State, 17 | -- Extension in this version, version 2. 18 | v2 SEQUENCE { 19 | a INTEGER (-128..127), -- Fixed range, encoded in 8 bits. 20 | b BOOLEAN, 21 | -- Future extension, more compact encoding than '...'. 22 | extension NULL OPTIONAL 23 | } OPTIONAL 24 | } 25 | 26 | Bar ::= INTEGER (0..31) 27 | 28 | -- Selection encoded in two bits. 29 | Message ::= CHOICE { 30 | foo Foo, 31 | -- Added in version 2. 32 | bar Bar, 33 | -- Future extensions, more compact encoding than '...'. 34 | extension2 NULL, 35 | extension3 NULL 36 | } 37 | 38 | END -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/UEContextReleaseComplete/UEContextReleaseComplete.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 23 4 | reject 5 | 6 | 7 | 8 | 9 | 0 10 | ignore 11 | 12 | 3692815114 13 | 14 | 15 | 16 | 8 17 | ignore 18 | 19 | 2060815 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/UEContextReleaseComplete2/UEContextReleaseComplete2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 23 4 | reject 5 | 6 | 7 | 8 | 9 | 0 10 | ignore 11 | 12 | 3692815053 13 | 14 | 15 | 16 | 8 17 | ignore 18 | 19 | 2060816 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/UEContextReleaseComplete3/UEContextReleaseComplete3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 23 4 | reject 5 | 6 | 7 | 8 | 9 | 0 10 | ignore 11 | 12 | 3692817881 13 | 14 | 15 | 16 | 8 17 | ignore 18 | 19 | 2060817 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 ericsson-mts 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # **mts-asn1** 2 | [![Build Status](https://github.com/ericsson-mts/mts-asn1/actions/workflows/maven-publish-release.yml/badge.svg?event=push)](https://github.com/ericsson-mts/mts-asn1) 3 | [![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/ericsson-mts/mts-asn1/blob/master/LICENSE.txt) 4 | 5 | ## Description 6 | 7 | **mts-asn1** project is designed to encode/decode data to/from binary of ASN.1 protocols. Data can be described in various 8 | dataformat (XML, JSON ...). It use [ANTLR](https://www.antlr.org/) to parse ASN.1 grammar. 9 | 10 | ## Installation 11 | 12 | Clone this repository and use it as a maven project 13 | 14 | (Coming on Maven Central soon) 15 | 16 | ## Usage 17 | 18 | See [here](https://github.com/ericsson-mts/mts-asn1/wiki/User-guide) 19 | 20 | ## DISCLAIMER 21 | 22 | While we do our best to support protocols described in ASN.1 and (U)PER encoding, we cannot guarantee that our project 23 | is error free. mts-asn1 evolve depending of the needs, please consider to [report](https://github.com/ericsson-mts/mts-asn1/wiki/Report) or contributing if you want a new feature or revise an existing one. 24 | -------------------------------------------------------------------------------- /mts-asn1-core/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | mts-asn1-core 7 | 8 | io.github.ericsson-mts 9 | mts-asn1 10 | master-SNAPSHOT 11 | 12 | jar 13 | 14 | 15 | 16 | 17 | org.javatuples 18 | javatuples 19 | 20 | 21 | io.github.ericsson-mts 22 | mts-asn1-antlr 23 | master-SNAPSHOT 24 | 25 | 26 | org.slf4j 27 | slf4j-api 28 | 29 | 30 | -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/InitialContextSetup/InitialContextSetupRequest/S1AP-1.hex: -------------------------------------------------------------------------------- 1 | 00 09 00 81 4f 00 00 06 00 00 00 02 00 25 00 08 2 | 00 02 00 24 00 42 00 0a 18 06 10 00 00 60 06 10 3 | 00 00 00 18 00 81 00 01 00 34 00 80 90 45 00 07 4 | 08 0f 80 0a fc f6 17 4b 00 00 00 80 80 27 2e b7 5 | 53 b3 02 07 42 01 25 06 20 00 f1 10 00 26 00 60 6 | 52 01 c1 01 07 1d 08 69 6e 74 65 72 6e 65 74 06 7 | 6d 6e 63 30 30 31 03 6d 63 63 03 30 30 31 04 67 8 | 70 72 73 05 01 0a ff f6 9a 5d 01 00 30 10 0a 11 9 | 1f 73 96 ff ff 46 29 ff ff 10 00 00 00 00 32 03 10 | 81 34 01 00 5e 04 fe fe 9f 9f 27 14 80 80 21 10 11 | 03 00 00 10 81 06 ac 11 00 01 83 06 00 00 00 00 12 | 50 0b f6 00 f1 10 03 35 52 c0 00 00 24 00 34 00 13 | 66 46 00 07 10 0f 80 0a fc f6 17 4c 00 00 00 57 14 | 27 e8 6e cb dd 03 62 00 c5 05 01 07 19 22 20 80 15 | 09 10 0a 98 9a 81 ff ff ff ff 11 81 09 10 0a 98 16 | 9a 81 ff ff ff ff 5d 01 90 30 10 0a 11 1f 73 96 17 | ff ff 46 29 ff ff 10 00 00 00 00 32 03 81 34 01 18 | 00 27 14 80 80 21 10 03 00 00 10 81 06 ac 11 00 19 | 01 83 06 00 00 00 00 00 6b 00 05 18 00 0c 00 00 20 | 00 49 00 20 1d 8f 4b c0 d0 87 e8 a1 74 f8 b6 df 21 | 29 7f 76 9c 32 0b e2 d2 3a a6 f4 c0 da 24 06 09 22 | 7e 96 ae ba 23 | -------------------------------------------------------------------------------- /.github/workflows/maven-publish-snapshot.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a package using Maven and then publish it to GitHub packages when a release is created 2 | # For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path 3 | 4 | name: Maven Publish Snapshot 5 | 6 | on: 7 | push: 8 | branches: 9 | - master 10 | 11 | jobs: 12 | build: 13 | runs-on: ubuntu-latest 14 | permissions: 15 | contents: read 16 | packages: write 17 | steps: 18 | - uses: actions/checkout@v3 19 | 20 | - name: Set up Apache Maven Central 21 | uses: actions/setup-java@v3 22 | with: # running setup-java again overwrites the settings.xml 23 | java-version: '8' 24 | distribution: 'temurin' 25 | gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} # Value of the GPG private key to import 26 | 27 | - name: Publish to Apache Maven Central 28 | run: mvn -B --settings .m2/settings.xml clean deploy 29 | env: 30 | OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} 31 | OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} 32 | GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/eNodeB_Setup/S1SetupResponse/S1SetupResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "successfulOutcome": { 3 | "procedureCode": 17, 4 | "criticality": "reject", 5 | "value": { 6 | "S1SetupResponse": { 7 | "protocolIEs": [ 8 | { 9 | "id": 61, 10 | "criticality": "ignore", 11 | "value": { 12 | "MMEname": "mme81" 13 | } 14 | }, 15 | { 16 | "id": 105, 17 | "criticality": "reject", 18 | "value": { 19 | "ServedGUMMEIs": [ 20 | { 21 | "servedPLMNs": [ 22 | "00F110" 23 | ], 24 | "servedGroupIDs": [ 25 | "032B" 26 | ], 27 | "servedMMECs": [ 28 | "51" 29 | ] 30 | } 31 | ] 32 | } 33 | }, 34 | { 35 | "id": 87, 36 | "criticality": "ignore", 37 | "value": { 38 | "RelativeMMECapacity": 255 39 | } 40 | } 41 | ] 42 | } 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/id-E-RABModify/E-RABModifyResponse/E-RABModifyResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "successfulOutcome": { 3 | "procedureCode": 6, 4 | "criticality": "reject", 5 | "value": { 6 | "E-RABModifyResponse": { 7 | "protocolIEs": [ 8 | { 9 | "id": 0, 10 | "criticality": "ignore", 11 | "value": { 12 | "MME-UE-S1AP-ID": 97009616 13 | } 14 | }, 15 | { 16 | "id": 8, 17 | "criticality": "ignore", 18 | "value": { 19 | "ENB-UE-S1AP-ID": 646862 20 | } 21 | }, 22 | { 23 | "id": 31, 24 | "criticality": "ignore", 25 | "value": { 26 | "E-RABModifyListBearerModRes": [ 27 | { 28 | "id": 37, 29 | "criticality": "ignore", 30 | "value": { 31 | "E-RABModifyItemBearerModRes": { 32 | "e-RAB-ID": 5 33 | } 34 | } 35 | } 36 | ] 37 | } 38 | } 39 | ] 40 | } 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /mts-asn1-core/src/main/java/com/ericsson/mts/asn1/constant/IntegerConstant.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1.constant; 12 | 13 | 14 | public class IntegerConstant extends AbstractConstant { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /.github/workflows/maven-publish-release.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a package using Maven and then publish it to GitHub packages when a release is created 2 | # For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path 3 | 4 | name: Maven Publish Release 5 | 6 | on: 7 | push: 8 | tags: 9 | - '*' 10 | 11 | jobs: 12 | build: 13 | runs-on: ubuntu-latest 14 | permissions: 15 | contents: read 16 | packages: write 17 | steps: 18 | - uses: actions/checkout@v3 19 | 20 | - name: Set up Apache Maven Central 21 | uses: actions/setup-java@v3 22 | with: # running setup-java again overwrites the settings.xml 23 | java-version: '8' 24 | distribution: 'temurin' 25 | gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} # Value of the GPG private key to import 26 | 27 | - name: Set version from tag 28 | run: | 29 | echo $GITHUB_REF_NAME 30 | mvn versions:set -DnewVersion=$GITHUB_REF_NAME 31 | 32 | - name: Publish to Apache Maven Central 33 | run: mvn -B --settings .m2/settings.xml clean deploy 34 | env: 35 | OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} 36 | OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} 37 | GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/DownlinkNASTransport/DownlinkNASTransport.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 4 | ignore 5 | 6 | 7 | 8 | 9 | 0 10 | reject 11 | 12 | 3692815114 13 | 14 | 15 | 16 | 8 17 | reject 18 | 19 | 2060815 20 | 21 | 22 | 23 | 26 24 | reject 25 | 26 | 076060 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /mts-asn1-core/src/main/java/com/ericsson/mts/asn1/exception/InvalidParameterException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1.exception; 12 | 13 | public class InvalidParameterException extends RuntimeException { 14 | public InvalidParameterException(String message) { 15 | super(message); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /mts-asn1-core/src/main/java/com/ericsson/mts/asn1/exception/UnknownIdentifierException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1.exception; 12 | 13 | public class UnknownIdentifierException extends RuntimeException { 14 | public UnknownIdentifierException(String message) { 15 | super(message); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/DownlinkNASTransport2/DownlinkNASTransport2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 4 | ignore 5 | 6 | 7 | 8 | 9 | 0 10 | reject 11 | 12 | 3692815053 13 | 14 | 15 | 16 | 8 17 | reject 18 | 19 | 2060816 20 | 21 | 22 | 23 | 26 24 | reject 25 | 26 | 076060 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/DownlinkNASTransport3/DownlinkNASTransport3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 4 | ignore 5 | 6 | 7 | 8 | 9 | 0 10 | reject 11 | 12 | 3692817881 13 | 14 | 15 | 16 | 8 17 | reject 18 | 19 | 2060817 20 | 21 | 22 | 23 | 26 24 | reject 25 | 26 | 076060 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /mts-asn1-core/src/main/java/com/ericsson/mts/asn1/constraint/TypeConstraint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1.constraint; 12 | 13 | public enum TypeConstraint { 14 | CONTENT_CONSTRAINT, 15 | SIZE_CONSTRAINT, 16 | CLASS_FIELD_CONSTRAINT, 17 | VALUE_RANGE_CONSTRAINT, 18 | SINGLE_VALUE_CONSTRAINT 19 | } 20 | -------------------------------------------------------------------------------- /mts-asn1-core/src/main/java/com/ericsson/mts/asn1/exception/EncodingException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1.exception; 12 | 13 | public class EncodingException extends RuntimeException { 14 | public EncodingException() { 15 | } 16 | 17 | public EncodingException(String message) { 18 | super(message); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/auth_w_sync_failure/DownlinkNASTransport/DownlinkNASTransport.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 4 | ignore 5 | 6 | 7 | 8 | 9 | 0 10 | reject 11 | 12 | 0 13 | 14 | 15 | 16 | 8 17 | reject 18 | 19 | 1 20 | 21 | 22 | 23 | 26 24 | reject 25 | 26 | 0752004711471147114711471147114711471110389046869A1CB9B94D4FC785B83D07DD 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/auth_w_sync_failure/DownlinkNASTransport2/DownlinkNASTransport2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 4 | ignore 5 | 6 | 7 | 8 | 9 | 0 10 | reject 11 | 12 | 0 13 | 14 | 15 | 16 | 8 17 | reject 18 | 19 | 1 20 | 21 | 22 | 23 | 26 24 | reject 25 | 26 | 075201B8EEB8EEB8EEB8EEB8EEB8EEB8EEB8EE10B14D41F46E52B9B9E10FA67CBFDA8011 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/auth_w_sync_failure/UplinkNASTransport2/UplinkNASTransport2.json: -------------------------------------------------------------------------------- 1 | { 2 | "initiatingMessage": { 3 | "procedureCode": 13, 4 | "criticality": "ignore", 5 | "value": { 6 | "UplinkNASTransport": { 7 | "protocolIEs": [ 8 | { 9 | "id": 0, 10 | "criticality": "reject", 11 | "value": { 12 | "MME-UE-S1AP-ID": 0 13 | } 14 | }, 15 | { 16 | "id": 8, 17 | "criticality": "reject", 18 | "value": { 19 | "ENB-UE-S1AP-ID": 1 20 | } 21 | }, 22 | { 23 | "id": 26, 24 | "criticality": "reject", 25 | "value": { 26 | "NAS-PDU": "075308DEBA34FD848A4448" 27 | } 28 | }, 29 | { 30 | "id": 100, 31 | "criticality": "ignore", 32 | "value": { 33 | "EUTRAN-CGI": { 34 | "pLMNidentity": "55F531", 35 | "cell-ID": "0000000000000000000100000001" 36 | } 37 | } 38 | }, 39 | { 40 | "id": 67, 41 | "criticality": "ignore", 42 | "value": { 43 | "TAI": { 44 | "pLMNidentity": "55F531", 45 | "tAC": "B26E" 46 | } 47 | } 48 | } 49 | ] 50 | } 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/UEContextReleaseCommand/UEContextReleaseCommand.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 23 4 | reject 5 | 6 | 7 | 8 | 9 | 99 10 | reject 11 | 12 | 13 | 14 | 3692815114 15 | 2060815 16 | 17 | 18 | 19 | 20 | 21 | 2 22 | ignore 23 | 24 | 25 | unspecified 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/UEContextReleaseCommand2/UEContextReleaseCommand2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 23 4 | reject 5 | 6 | 7 | 8 | 9 | 99 10 | reject 11 | 12 | 13 | 14 | 3692815053 15 | 2060816 16 | 17 | 18 | 19 | 20 | 21 | 2 22 | ignore 23 | 24 | 25 | unspecified 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/UEContextReleaseCommand3/UEContextReleaseCommand3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 23 4 | reject 5 | 6 | 7 | 8 | 9 | 99 10 | reject 11 | 12 | 13 | 14 | 3692817881 15 | 2060817 16 | 17 | 18 | 19 | 20 | 21 | 2 22 | ignore 23 | 24 | 25 | unspecified 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/auth_w_sync_failure/UplinkNASTransport/UplinkNASTransport.json: -------------------------------------------------------------------------------- 1 | { 2 | "initiatingMessage": { 3 | "procedureCode": 13, 4 | "criticality": "ignore", 5 | "value": { 6 | "UplinkNASTransport": { 7 | "protocolIEs": [ 8 | { 9 | "id": 0, 10 | "criticality": "reject", 11 | "value": { 12 | "MME-UE-S1AP-ID": 0 13 | } 14 | }, 15 | { 16 | "id": 8, 17 | "criticality": "reject", 18 | "value": { 19 | "ENB-UE-S1AP-ID": 1 20 | } 21 | }, 22 | { 23 | "id": 26, 24 | "criticality": "reject", 25 | "value": { 26 | "NAS-PDU": "075C15300E76096683482650040A6FAE3F2CE2" 27 | } 28 | }, 29 | { 30 | "id": 100, 31 | "criticality": "ignore", 32 | "value": { 33 | "EUTRAN-CGI": { 34 | "pLMNidentity": "55F531", 35 | "cell-ID": "0000000000000000000100000001" 36 | } 37 | } 38 | }, 39 | { 40 | "id": 67, 41 | "criticality": "ignore", 42 | "value": { 43 | "TAI": { 44 | "pLMNidentity": "55F531", 45 | "tAC": "B26E" 46 | } 47 | } 48 | } 49 | ] 50 | } 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /mts-asn1-core/src/main/java/com/ericsson/mts/asn1/exception/ANTLRVisitorException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1.exception; 12 | 13 | public class ANTLRVisitorException extends RuntimeException { 14 | public ANTLRVisitorException() { 15 | super(); 16 | } 17 | 18 | public ANTLRVisitorException(String erroMessage) { 19 | super(erroMessage); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /mts-asn1-per/src/main/java/com/ericsson/mts/asn1/translator/PERObjectIdentifierTranslator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1.translator; 12 | 13 | import com.ericsson.mts.asn1.PERTranscoder; 14 | 15 | public class PERObjectIdentifierTranslator extends AbstractObjectIdentifierTranslator { 16 | 17 | public PERObjectIdentifierTranslator(PERTranscoder perTranscoder) { 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /mts-asn1-core/src/main/java/com/ericsson/mts/asn1/exception/NotHandledCaseException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1.exception; 12 | 13 | public class NotHandledCaseException extends RuntimeException { 14 | 15 | public NotHandledCaseException() { 16 | super(); 17 | } 18 | 19 | public NotHandledCaseException(String string) { 20 | super(string); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /mts-asn1-core/src/main/java/com/ericsson/mts/asn1/constant/AbstractConstant.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1.constant; 12 | 13 | public abstract class AbstractConstant { 14 | protected String value; 15 | 16 | public AbstractConstant init(String value) { 17 | this.value = value; 18 | return this; 19 | } 20 | 21 | public String getValue() { 22 | return value; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /mts-asn1-core/src/main/java/com/ericsson/mts/asn1/constraint/AbstractConstraint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1.constraint; 12 | 13 | public abstract class AbstractConstraint { 14 | private boolean isExtensible = false; 15 | 16 | public boolean isExtensible() { 17 | return isExtensible; 18 | } 19 | 20 | public void setExtensible(boolean extensible) { 21 | isExtensible = extensible; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/InitialUEMessage/InitialUEMessage.json: -------------------------------------------------------------------------------- 1 | { 2 | "initiatingMessage": { 3 | "procedureCode": 12, 4 | "criticality": "ignore", 5 | "value": { 6 | "InitialUEMessage": { 7 | "protocolIEs": [ 8 | { 9 | "id": 8, 10 | "criticality": "reject", 11 | "value": { 12 | "ENB-UE-S1AP-ID": 2060815 13 | } 14 | }, 15 | { 16 | "id": 26, 17 | "criticality": "reject", 18 | "value": { 19 | "NAS-PDU": "0748720B29071855102132713A85895805F0F0C040105C1004570200003103E5E0349011035758825D0100C1" 20 | } 21 | }, 22 | { 23 | "id": 67, 24 | "criticality": "reject", 25 | "value": { 26 | "TAI": { 27 | "pLMNidentity": "132102", 28 | "tAC": "3039" 29 | } 30 | } 31 | }, 32 | { 33 | "id": 100, 34 | "criticality": "ignore", 35 | "value": { 36 | "EUTRAN-CGI": { 37 | "pLMNidentity": "132102", 38 | "cell-ID": "0000000100010000000001000011" 39 | } 40 | } 41 | }, 42 | { 43 | "id": 134, 44 | "criticality": "ignore", 45 | "value": { 46 | "RRC-Establishment-Cause": "mo-Signalling" 47 | } 48 | } 49 | ] 50 | } 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/InitialUEMessage2/InitialUEMessage2.json: -------------------------------------------------------------------------------- 1 | { 2 | "initiatingMessage": { 3 | "procedureCode": 12, 4 | "criticality": "ignore", 5 | "value": { 6 | "InitialUEMessage": { 7 | "protocolIEs": [ 8 | { 9 | "id": 8, 10 | "criticality": "reject", 11 | "value": { 12 | "ENB-UE-S1AP-ID": 2060816 13 | } 14 | }, 15 | { 16 | "id": 26, 17 | "criticality": "reject", 18 | "value": { 19 | "NAS-PDU": "0748720B29071855102132713A85895805F0F0C040105C1004570200003103E5E0349011035758825D0100C1" 20 | } 21 | }, 22 | { 23 | "id": 67, 24 | "criticality": "reject", 25 | "value": { 26 | "TAI": { 27 | "pLMNidentity": "132102", 28 | "tAC": "3039" 29 | } 30 | } 31 | }, 32 | { 33 | "id": 100, 34 | "criticality": "ignore", 35 | "value": { 36 | "EUTRAN-CGI": { 37 | "pLMNidentity": "132102", 38 | "cell-ID": "0000000100010000000001000011" 39 | } 40 | } 41 | }, 42 | { 43 | "id": 134, 44 | "criticality": "ignore", 45 | "value": { 46 | "RRC-Establishment-Cause": "mo-Signalling" 47 | } 48 | } 49 | ] 50 | } 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/InitialUEMessage3/InitialUEMessage3.json: -------------------------------------------------------------------------------- 1 | { 2 | "initiatingMessage": { 3 | "procedureCode": 12, 4 | "criticality": "ignore", 5 | "value": { 6 | "InitialUEMessage": { 7 | "protocolIEs": [ 8 | { 9 | "id": 8, 10 | "criticality": "reject", 11 | "value": { 12 | "ENB-UE-S1AP-ID": 2060817 13 | } 14 | }, 15 | { 16 | "id": 26, 17 | "criticality": "reject", 18 | "value": { 19 | "NAS-PDU": "0748720B29071855102132713A85895805F0F0C040105C1004570200003103E5E0349011035758825D0100C1" 20 | } 21 | }, 22 | { 23 | "id": 67, 24 | "criticality": "reject", 25 | "value": { 26 | "TAI": { 27 | "pLMNidentity": "132102", 28 | "tAC": "3039" 29 | } 30 | } 31 | }, 32 | { 33 | "id": 100, 34 | "criticality": "ignore", 35 | "value": { 36 | "EUTRAN-CGI": { 37 | "pLMNidentity": "132102", 38 | "cell-ID": "0000000100010000000001000011" 39 | } 40 | } 41 | }, 42 | { 43 | "id": 134, 44 | "criticality": "ignore", 45 | "value": { 46 | "RRC-Establishment-Cause": "mo-Signalling" 47 | } 48 | } 49 | ] 50 | } 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /mts-asn1-core/src/main/java/com/ericsson/mts/asn1/TranslatorContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1; 12 | 13 | import java.util.HashMap; 14 | 15 | public class TranslatorContext { 16 | private HashMap fields = new HashMap<>(); 17 | 18 | public void put(String key, String value) { 19 | fields.put(key, value); 20 | } 21 | 22 | public String get(String key) { 23 | return fields.get(key); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/auth_w_sync_failure/InitialUEMessage/InitialUEMessage.json: -------------------------------------------------------------------------------- 1 | { 2 | "initiatingMessage": { 3 | "procedureCode": 12, 4 | "criticality": "ignore", 5 | "value": { 6 | "InitialUEMessage": { 7 | "protocolIEs": [ 8 | { 9 | "id": 8, 10 | "criticality": "reject", 11 | "value": { 12 | "ENB-UE-S1AP-ID": 1 13 | } 14 | }, 15 | { 16 | "id": 26, 17 | "criticality": "reject", 18 | "value": { 19 | "NAS-PDU": "0741720BF655F531870148E000000102E0E000210201D011D1271A8080211001000010810600000000830600000000000D00000A005255F531B26E9011034F18A6E0" 20 | } 21 | }, 22 | { 23 | "id": 67, 24 | "criticality": "reject", 25 | "value": { 26 | "TAI": { 27 | "pLMNidentity": "55F531", 28 | "tAC": "B26E" 29 | } 30 | } 31 | }, 32 | { 33 | "id": 100, 34 | "criticality": "ignore", 35 | "value": { 36 | "EUTRAN-CGI": { 37 | "pLMNidentity": "55F531", 38 | "cell-ID": "0000000000000000000100000001" 39 | } 40 | } 41 | }, 42 | { 43 | "id": 134, 44 | "criticality": "ignore", 45 | "value": { 46 | "RRC-Establishment-Cause": "mo-Signalling" 47 | } 48 | } 49 | ] 50 | } 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /mts-asn1-antlr/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | mts-asn1 7 | io.github.ericsson-mts 8 | master-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | mts-asn1-antlr 13 | 14 | 15 | true 16 | false 17 | 18 | 19 | 20 | 21 | 22 | org.antlr 23 | antlr4-runtime 24 | 25 | 26 | org.antlr 27 | antlr4 28 | 29 | 30 | 31 | 32 | 33 | 34 | org.antlr 35 | antlr4-maven-plugin 36 | ${antlr4.version} 37 | 38 | 39 | antlr 40 | 41 | antlr4 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /mts-asn1-core/src/main/java/com/ericsson/mts/asn1/registry/ParsedRegistry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1.registry; 12 | 13 | 14 | import java.util.HashMap; 15 | 16 | public class ParsedRegistry { 17 | private HashMap registry = new HashMap<>(); 18 | 19 | public HashMap getRegistry() { 20 | return registry; 21 | } 22 | 23 | public synchronized void add(String identifier, T abstractTranslator) { 24 | registry.put(identifier, abstractTranslator); 25 | } 26 | 27 | public synchronized T get(String identifier) { 28 | return registry.get(identifier); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /mts-asn1-core/src/main/java/com/ericsson/mts/asn1/constraint/ContentsConstraint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1.constraint; 12 | 13 | import com.ericsson.mts.asn1.translator.AbstractTranslator; 14 | 15 | /** 16 | * Use when CONTAINING keyword appears 17 | */ 18 | public class ContentsConstraint extends AbstractConstraint { 19 | private final AbstractTranslator contentTranslator; 20 | 21 | public ContentsConstraint(AbstractTranslator contentTranslator) { 22 | this.contentTranslator = contentTranslator; 23 | } 24 | 25 | public AbstractTranslator getContentTranslator() { 26 | return contentTranslator; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/simplelogger.properties: -------------------------------------------------------------------------------- 1 | # SLF4J's SimpleLogger configuration file 2 | # Simple implementation of Logger that sends all enabled log messages, for all defined loggers, to System.err. 3 | 4 | # Default logging detail level for all instances of SimpleLogger. 5 | # Must be one of ("trace", "debug", "info", "warn", or "error"). 6 | # If not specified, defaults to "info". 7 | org.slf4j.simpleLogger.defaultLogLevel=trace 8 | 9 | # Logging detail level for a SimpleLogger instance named "xxxxx". 10 | # Must be one of ("trace", "debug", "info", "warn", or "error"). 11 | # If not specified, the default logging detail level is used. 12 | #org.slf4j.simpleLogger.log.xxxxx= 13 | 14 | # Set to true if you want the current date and time to be included in output messages. 15 | # Default is false, and will output the number of milliseconds elapsed since startup. 16 | #org.slf4j.simpleLogger.showDateTime=false 17 | 18 | # The date and time format to be used in the output messages. 19 | # The pattern describing the date and time format is the same that is used in java.text.SimpleDateFormat. 20 | # If the format is not specified or is invalid, the default format is used. 21 | # The default format is yyyy-MM-dd HH:mm:ss:SSS Z. 22 | #org.slf4j.simpleLogger.dateTimeFormat=yyyy-MM-dd HH:mm:ss:SSS Z 23 | 24 | # Set to true if you want to output the current thread name. 25 | # Defaults to true. 26 | #org.slf4j.simpleLogger.showThreadName=true 27 | 28 | # Set to true if you want the Logger instance name to be included in output messages. 29 | # Defaults to true. 30 | #org.slf4j.simpleLogger.showLogName=true 31 | 32 | # Set to true if you want the last component of the name to be included in output messages. 33 | # Defaults to false. 34 | #org.slf4j.simpleLogger.showShortLogName=false -------------------------------------------------------------------------------- /mts-asn1-per/src/main/java/com/ericsson/mts/asn1/translator/PERRealTranslator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1.translator; 12 | 13 | import com.ericsson.mts.asn1.BitInputStream; 14 | import com.ericsson.mts.asn1.PERTranscoder; 15 | import com.ericsson.mts.asn1.exception.NotHandledCaseException; 16 | 17 | import java.math.BigDecimal; 18 | 19 | public class PERRealTranslator extends AbstractRealTranslator { 20 | 21 | public PERRealTranslator(PERTranscoder perTranscoder) { 22 | } 23 | 24 | @Override 25 | public BigDecimal doDecode(BitInputStream s) { 26 | throw new NotHandledCaseException("Real decoding is not implemented yet"); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/InitialContextSetup/InitialContextSetupResponse/S1AP-2.json: -------------------------------------------------------------------------------- 1 | { 2 | "successfulOutcome": { 3 | "procedureCode": 9, 4 | "criticality": "reject", 5 | "value": { 6 | "InitialContextSetupResponse": { 7 | "protocolIEs": [ 8 | { 9 | "id": 0, 10 | "criticality": "ignore", 11 | "value": { 12 | "MME-UE-S1AP-ID": 37 13 | } 14 | }, 15 | { 16 | "id": 8, 17 | "criticality": "ignore", 18 | "value": { 19 | "ENB-UE-S1AP-ID": 36 20 | } 21 | }, 22 | { 23 | "id": 51, 24 | "criticality": "ignore", 25 | "value": { 26 | "E-RABSetupListCtxtSURes": [ 27 | { 28 | "id": 50, 29 | "criticality": "ignore", 30 | "value": { 31 | "E-RABSetupItemCtxtSURes": { 32 | "e-RAB-ID": 5, 33 | "transportLayerAddress": "00001010111110111111110000001000", 34 | "gTP-TEID": "4B000000" 35 | } 36 | } 37 | }, 38 | { 39 | "id": 50, 40 | "criticality": "ignore", 41 | "value": { 42 | "E-RABSetupItemCtxtSURes": { 43 | "e-RAB-ID": 6, 44 | "transportLayerAddress": "00001010111110111111110000001000", 45 | "gTP-TEID": "4C000000" 46 | } 47 | } 48 | } 49 | ] 50 | } 51 | } 52 | ] 53 | } 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /mts-asn1-core/src/main/java/com/ericsson/mts/asn1/factory/FormatReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1.factory; 12 | 13 | import java.math.BigInteger; 14 | import java.util.List; 15 | 16 | public interface FormatReader { 17 | 18 | void enterObject(String name); 19 | 20 | void leaveObject(String name); 21 | 22 | int enterArray(String name); 23 | 24 | void leaveArray(String name); 25 | 26 | boolean booleanValue(String name); 27 | 28 | String bitsValue(String name); 29 | 30 | String bytesValue(String name); 31 | 32 | BigInteger intValue(String name); 33 | 34 | List fieldsValue(); 35 | 36 | String stringValue(String name); 37 | 38 | String printCurrentnode(); 39 | } 40 | -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/eNodeB_Setup/S1SetupRequest/S1SetupRequest.json: -------------------------------------------------------------------------------- 1 | { 2 | "initiatingMessage": { 3 | "procedureCode": 17, 4 | "criticality": "reject", 5 | "value": { 6 | "S1SetupRequest": { 7 | "protocolIEs": [ 8 | { 9 | "id": 59, 10 | "criticality": "reject", 11 | "value": { 12 | "Global-ENB-ID": { 13 | "pLMNidentity": "00F110", 14 | "eNB-ID": { 15 | "macroENB-ID": "00000111000010000000" 16 | } 17 | } 18 | } 19 | }, 20 | { 21 | "id": 60, 22 | "criticality": "ignore", 23 | "value": { 24 | "ENBname": "aric-eNB" 25 | } 26 | }, 27 | { 28 | "id": 64, 29 | "criticality": "reject", 30 | "value": { 31 | "SupportedTAs": [ 32 | { 33 | "tAC": "000C", 34 | "broadcastPLMNs": [ 35 | "00F110" 36 | ] 37 | }, 38 | { 39 | "tAC": "000B", 40 | "broadcastPLMNs": [ 41 | "00F110" 42 | ] 43 | }, 44 | { 45 | "tAC": "000A", 46 | "broadcastPLMNs": [ 47 | "00F110" 48 | ] 49 | }, 50 | { 51 | "tAC": "0009", 52 | "broadcastPLMNs": [ 53 | "00F110" 54 | ] 55 | } 56 | ] 57 | } 58 | }, 59 | { 60 | "id": 137, 61 | "criticality": "reject", 62 | "value": { 63 | "PagingDRX": "v32" 64 | } 65 | } 66 | ] 67 | } 68 | } 69 | } 70 | } -------------------------------------------------------------------------------- /mts-asn1-core/src/main/java/com/ericsson/mts/asn1/visitor/TopLevelVisitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1.visitor; 12 | 13 | import com.ericsson.mts.asn1.ASN1Parser; 14 | import com.ericsson.mts.asn1.ASN1ParserBaseVisitor; 15 | import com.ericsson.mts.asn1.registry.MainRegistry; 16 | import org.slf4j.Logger; 17 | import org.slf4j.LoggerFactory; 18 | 19 | 20 | public class TopLevelVisitor extends ASN1ParserBaseVisitor { 21 | private static Logger logger = LoggerFactory.getLogger(TopLevelVisitor.class.getSimpleName()); 22 | protected MainRegistry mainRegistry; 23 | 24 | public TopLevelVisitor(MainRegistry mainRegistry) { 25 | this.mainRegistry = mainRegistry; 26 | } 27 | 28 | @Override 29 | public Object visitAssignment(ASN1Parser.AssignmentContext ctx) { 30 | mainRegistry.addAssignment(ctx); 31 | return null; 32 | } 33 | } -------------------------------------------------------------------------------- /mts-asn1-per/src/main/java/com/ericsson/mts/asn1/translator/PERBooleanTranslator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1.translator; 12 | 13 | import com.ericsson.mts.asn1.BitArray; 14 | import com.ericsson.mts.asn1.BitInputStream; 15 | 16 | import java.io.IOException; 17 | 18 | public class PERBooleanTranslator extends AbstractBooleanTranslator { 19 | 20 | @Override 21 | public void doEncode(BitArray s, boolean value) throws IOException { 22 | logger.trace("Enter {} encoder, name {}", this.getClass().getSimpleName(), this.name); 23 | if (value) { 24 | s.writeBit(1); 25 | } else { 26 | s.writeBit(0); 27 | } 28 | } 29 | 30 | @Override 31 | public boolean doDecode(BitInputStream s) throws IOException { 32 | logger.trace("Enter {} translator, name {}", this.getClass().getSimpleName(), this.name); 33 | return (1 == s.readBit()); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/id-E-RABModify/E-RABModifyResponse/E-RABModifyResponse.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 4 | reject 5 | 6 | 7 | 8 | 9 | 0 10 | ignore 11 | 12 | 97009616 13 | 14 | 15 | 16 | 8 17 | ignore 18 | 19 | 646862 20 | 21 | 22 | 23 | 31 24 | ignore 25 | 26 | 27 | 28 | 37 29 | ignore 30 | 31 | 32 | 5 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /mts-asn1-per/src/test/java/com/ericsson/mts/asn1/SampleTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1; 12 | 13 | import org.junit.jupiter.api.BeforeAll; 14 | import org.junit.jupiter.api.Test; 15 | 16 | import java.util.Collections; 17 | 18 | class SampleTests extends AbstractTests { 19 | 20 | @BeforeAll 21 | static void init() { 22 | try { 23 | asn1Translator = new ASN1Translator(new PERTranslatorFactory(true), 24 | Collections.singletonList(SampleTests.class.getResourceAsStream("/grammar/sample/examplev2.asn"))); 25 | } catch (Exception e) { 26 | e.printStackTrace(); 27 | } 28 | } 29 | 30 | @Test 31 | void parseSampleGrammar() { 32 | testParsingANTLR(); 33 | } 34 | 35 | @Test 36 | void testSample() throws Exception { 37 | test("Message", "/data/sample/sample.bin", "/data/sample/sample.json", "/data/sample/sample.xml"); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/eNodeB_Setup/S1SetupResponse/S1SetupResponse.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 17 4 | reject 5 | 6 | 7 | 8 | 9 | 61 10 | ignore 11 | 12 | mme81 13 | 14 | 15 | 16 | 105 17 | reject 18 | 19 | 20 | 21 | 22 | 00F110 23 | 24 | 25 | 032B 26 | 27 | 28 | 51 29 | 30 | 31 | 32 | 33 | 34 | 35 | 87 36 | ignore 37 | 38 | 255 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/id-E-RABModify/E-RABModifyRequest/E-RABModifyRequest.json: -------------------------------------------------------------------------------- 1 | { 2 | "initiatingMessage": { 3 | "procedureCode": 6, 4 | "criticality": "reject", 5 | "value": { 6 | "E-RABModifyRequest": { 7 | "protocolIEs": [ 8 | { 9 | "id": 0, 10 | "criticality": "reject", 11 | "value": { 12 | "MME-UE-S1AP-ID": 97009616 13 | } 14 | }, 15 | { 16 | "id": 8, 17 | "criticality": "reject", 18 | "value": { 19 | "ENB-UE-S1AP-ID": 646862 20 | } 21 | }, 22 | { 23 | "id": 66, 24 | "criticality": "reject", 25 | "value": { 26 | "UEAggregateMaximumBitrate": { 27 | "uEaggregateMaximumBitRateDL": 204800000, 28 | "uEaggregateMaximumBitRateUL": 204800000 29 | } 30 | } 31 | }, 32 | { 33 | "id": 30, 34 | "criticality": "reject", 35 | "value": { 36 | "E-RABToBeModifiedListBearerModReq": [ 37 | { 38 | "id": 36, 39 | "criticality": "reject", 40 | "value": { 41 | "E-RABToBeModifiedItemBearerModReq": { 42 | "e-RAB-ID": 5, 43 | "e-RABLevelQoSParameters": { 44 | "qCI": 6, 45 | "allocationRetentionPriority": { 46 | "priorityLevel": 1, 47 | "pre-emptionCapability": "shall-not-trigger-pre-emption", 48 | "pre-emptionVulnerability": "pre-emptable" 49 | } 50 | }, 51 | "nAS-PDU": "279523C609029F4D7D259DA8541D64E92DAD3223700FCB756CB03C2B9D5DB0A94C7EBCADD22655" 52 | } 53 | } 54 | } 55 | ] 56 | } 57 | } 58 | ] 59 | } 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /mts-asn1-core/src/main/java/com/ericsson/mts/asn1/constraint/ClassFieldConstraint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1.constraint; 12 | 13 | /** 14 | * Use within sequence to store target translator of an object set 15 | */ 16 | class ClassFieldConstraint extends AbstractConstraint { 17 | private String objectSetName; 18 | private String targetComponent; 19 | 20 | public ClassFieldConstraint(String objectSetName, String targetComponent) { 21 | this.objectSetName = objectSetName; 22 | this.targetComponent = targetComponent; 23 | } 24 | 25 | public String getObjectSetName() { 26 | return objectSetName; 27 | } 28 | 29 | public String getTargetComponent() { 30 | return targetComponent; 31 | } 32 | 33 | @Override 34 | public String toString() { 35 | return "ClassFieldConstraint{" + 36 | "objectSetName='" + objectSetName + '\'' + 37 | ", targetComponent='" + targetComponent + '\'' + 38 | '}'; 39 | } 40 | } -------------------------------------------------------------------------------- /mts-asn1-core/src/main/java/com/ericsson/mts/asn1/constraint/SizeConstraint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1.constraint; 12 | 13 | import com.ericsson.mts.asn1.registry.MainRegistry; 14 | 15 | import java.math.BigInteger; 16 | 17 | /** 18 | * Use when SIZE keyword appears X.680 51.5 19 | */ 20 | class SizeConstraint extends AbstractRangeConstraint { 21 | 22 | SizeConstraint(MainRegistry mainRegistry) { 23 | super(mainRegistry); 24 | } 25 | 26 | BigInteger getLowerBound() { 27 | if (arelbNumber) { 28 | return new BigInteger(lowerBound); 29 | } else { 30 | return new BigInteger(mainRegistry.getConstantFromName(lowerBound).getValue()); 31 | } 32 | } 33 | 34 | BigInteger getUpperBound() { 35 | if (null == upperBound) { 36 | return null; 37 | } 38 | if (areubNumber) { 39 | return new BigInteger(upperBound); 40 | } else { 41 | return new BigInteger(mainRegistry.getConstantFromName(upperBound).getValue()); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /mts-asn1-core/src/main/java/com/ericsson/mts/asn1/translator/AbstractObjectIdentifierTranslator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1.translator; 12 | 13 | import com.ericsson.mts.asn1.BitArray; 14 | import com.ericsson.mts.asn1.BitInputStream; 15 | import com.ericsson.mts.asn1.TranslatorContext; 16 | import com.ericsson.mts.asn1.exception.NotHandledCaseException; 17 | import com.ericsson.mts.asn1.factory.FormatReader; 18 | import com.ericsson.mts.asn1.factory.FormatWriter; 19 | 20 | import java.util.List; 21 | 22 | public class AbstractObjectIdentifierTranslator extends AbstractTranslator { 23 | 24 | @Override 25 | public final void encode(String name, BitArray s, FormatReader reader, TranslatorContext translatorContext, List parameters) throws Exception { 26 | throw new NotHandledCaseException(); 27 | } 28 | 29 | @Override 30 | public final void decode(String name, BitInputStream s, FormatWriter writer, TranslatorContext translatorContext, List parameters) throws Exception { 31 | throw new NotHandledCaseException(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /mts-asn1-core/src/main/java/com/ericsson/mts/asn1/factory/FormatWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1.factory; 12 | 13 | 14 | import java.math.BigDecimal; 15 | import java.math.BigInteger; 16 | 17 | public interface FormatWriter { 18 | 19 | static String bytesToHex(byte[] bytes) { 20 | StringBuilder sb = new StringBuilder(); 21 | for (byte b : bytes) { 22 | sb.append(String.format("%02X", b)); 23 | } 24 | return sb.toString(); 25 | } 26 | 27 | void enterObject(String name); 28 | 29 | void leaveObject(String name); 30 | 31 | void enterArray(String name); 32 | 33 | void leaveArray(String name); 34 | 35 | void stringValue(String name, String value); 36 | 37 | void booleanValue(String name, boolean value); 38 | 39 | void realValue(String name, BigDecimal value); 40 | 41 | void bytesValue(String name, byte[] value); 42 | 43 | void intValue(String name, BigInteger value, String namedValue); 44 | 45 | void nullValue(String name); 46 | 47 | void bitsValue(String name, String value); 48 | } 49 | -------------------------------------------------------------------------------- /mts-asn1-core/src/main/java/com/ericsson/mts/asn1/constraint/ValueRangeConstraint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1.constraint; 12 | 13 | import com.ericsson.mts.asn1.registry.MainRegistry; 14 | 15 | import java.math.BigInteger; 16 | 17 | /** 18 | * Use when (value1..value2) without SIZE keyword appear X.680 51.4 19 | */ 20 | public class ValueRangeConstraint extends AbstractRangeConstraint { 21 | 22 | ValueRangeConstraint(MainRegistry mainRegistry) { 23 | super(mainRegistry); 24 | } 25 | 26 | BigInteger getLowerRange() { 27 | if (arelbNumber) { 28 | return new BigInteger(lowerBound); 29 | } else { 30 | return new BigInteger(mainRegistry.getConstantFromName(lowerBound).getValue()); 31 | } 32 | } 33 | 34 | BigInteger getUpperRange() { 35 | if (null == upperBound) { 36 | return null; 37 | } 38 | if (areubNumber) { 39 | return new BigInteger(upperBound); 40 | } else { 41 | return new BigInteger(mainRegistry.getConstantFromName(upperBound).getValue()); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /mts-asn1-core/src/main/java/com/ericsson/mts/asn1/translator/NullTranslator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1.translator; 12 | 13 | import com.ericsson.mts.asn1.BitArray; 14 | import com.ericsson.mts.asn1.BitInputStream; 15 | import com.ericsson.mts.asn1.TranslatorContext; 16 | import com.ericsson.mts.asn1.exception.NotHandledCaseException; 17 | import com.ericsson.mts.asn1.factory.FormatReader; 18 | import com.ericsson.mts.asn1.factory.FormatWriter; 19 | 20 | import java.io.IOException; 21 | import java.util.List; 22 | 23 | public class NullTranslator extends AbstractTranslator { 24 | 25 | @Override 26 | public void encode(String name, BitArray s, FormatReader reader, TranslatorContext translatorContext, List parameters) throws Exception { 27 | throw new NotHandledCaseException(); 28 | } 29 | 30 | @Override 31 | public void decode(String name, BitInputStream s, FormatWriter writer, TranslatorContext translatorContext, List parameters) throws NotHandledCaseException, IOException { 32 | writer.nullValue(name); 33 | } 34 | 35 | @Override 36 | public String toString() { 37 | return "NullTranslator{}"; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /mts-asn1-per/src/test/java/com/ericsson/mts/asn1/S1APENodeBSetup.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1; 12 | 13 | import org.junit.jupiter.api.BeforeAll; 14 | import org.junit.jupiter.api.Test; 15 | 16 | import java.util.Collections; 17 | 18 | public class S1APENodeBSetup extends AbstractTests { 19 | 20 | @BeforeAll 21 | static void init() { 22 | try { 23 | asn1Translator = new ASN1Translator(new PERTranslatorFactory(true), Collections.singletonList(S1APENodeBSetup.class.getResourceAsStream("/grammar/S1AP/S1AP.asn"))); 24 | } catch (Exception e) { 25 | e.printStackTrace(); 26 | } 27 | } 28 | 29 | @Test 30 | void testS1SetupRequest() throws Exception { 31 | test("S1AP-PDU", "/data/S1AP/eNodeB_Setup/S1SetupRequest/S1SetupRequest.bin", "/data/S1AP/eNodeB_Setup/S1SetupRequest/S1SetupRequest.json", "/data/S1AP/eNodeB_Setup/S1SetupRequest/S1SetupRequest.xml"); 32 | } 33 | 34 | @Test 35 | void testS1SetupResponse() throws Exception { 36 | test("S1AP-PDU", "/data/S1AP/eNodeB_Setup/S1SetupResponse/S1SetupResponse.bin", "/data/S1AP/eNodeB_Setup/S1SetupResponse/S1SetupResponse.json", "/data/S1AP/eNodeB_Setup/S1SetupResponse/S1SetupResponse.xml"); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/auth_w_sync_failure/UplinkNASTransport2/UplinkNASTransport2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 13 4 | ignore 5 | 6 | 7 | 8 | 9 | 0 10 | reject 11 | 12 | 0 13 | 14 | 15 | 16 | 8 17 | reject 18 | 19 | 1 20 | 21 | 22 | 23 | 26 24 | reject 25 | 26 | 075308DEBA34FD848A4448 27 | 28 | 29 | 30 | 100 31 | ignore 32 | 33 | 34 | 55F531 35 | 0000000000000000000100000001 36 | 37 | 38 | 39 | 40 | 67 41 | ignore 42 | 43 | 44 | 55F531 45 | B26E 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/auth_w_sync_failure/UplinkNASTransport/UplinkNASTransport.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 13 4 | ignore 5 | 6 | 7 | 8 | 9 | 0 10 | reject 11 | 12 | 0 13 | 14 | 15 | 16 | 8 17 | reject 18 | 19 | 1 20 | 21 | 22 | 23 | 26 24 | reject 25 | 26 | 075C15300E76096683482650040A6FAE3F2CE2 27 | 28 | 29 | 30 | 100 31 | ignore 32 | 33 | 34 | 55F531 35 | 0000000000000000000100000001 36 | 37 | 38 | 39 | 40 | 67 41 | ignore 42 | 43 | 44 | 55F531 45 | B26E 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /mts-asn1-core/src/main/java/com/ericsson/mts/asn1/translator/AbstractRealTranslator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1.translator; 12 | 13 | import com.ericsson.mts.asn1.BitArray; 14 | import com.ericsson.mts.asn1.BitInputStream; 15 | import com.ericsson.mts.asn1.TranslatorContext; 16 | import com.ericsson.mts.asn1.exception.NotHandledCaseException; 17 | import com.ericsson.mts.asn1.factory.FormatReader; 18 | import com.ericsson.mts.asn1.factory.FormatWriter; 19 | 20 | import java.io.IOException; 21 | import java.math.BigDecimal; 22 | import java.util.List; 23 | 24 | public abstract class AbstractRealTranslator extends AbstractTranslator { 25 | 26 | @Override 27 | public final void encode(String name, BitArray s, FormatReader reader, TranslatorContext translatorContext, List parameters) throws Exception { 28 | throw new NotHandledCaseException(); 29 | } 30 | 31 | @Override 32 | public final void decode(String name, BitInputStream s, FormatWriter writer, TranslatorContext translatorContext, List parameters) throws NotHandledCaseException, IOException { 33 | writer.realValue(name, doDecode(s)); 34 | } 35 | 36 | public abstract BigDecimal doDecode(BitInputStream s); 37 | 38 | @Override 39 | public String toString() { 40 | return "AbstractRealTranslator{}"; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /mts-asn1-core/src/main/java/com/ericsson/mts/asn1/factory/AbstractTranslatorFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1.factory; 12 | 13 | import com.ericsson.mts.asn1.translator.*; 14 | 15 | public abstract class AbstractTranslatorFactory { 16 | 17 | public abstract AbstractBitStringTranslator bitStringTranslator(); 18 | 19 | public abstract AbstractBooleanTranslator booleanTranslator(); 20 | 21 | public abstract AbstractChoiceTranslator choiceTranslator(); 22 | 23 | public abstract AbstractEnumeratedTranslator enumeratedTranslator(); 24 | 25 | public abstract AbstractIntegerTranslator integerTranslator(); 26 | 27 | public NullTranslator nullTranslator() { 28 | return new NullTranslator(); 29 | } 30 | 31 | public abstract AbstractOctetStringTranslator octetStringTranslator(); 32 | 33 | public abstract AbstractObjectClassFieldTranslator objectClassFieldTypeTranslator(); 34 | 35 | public abstract AbstractRealTranslator realTranslator(); 36 | 37 | public abstract AbstractRestrictedCharacterStringTranslator characterStringTranslator(); 38 | 39 | public abstract AbstractSequenceOfTranslator sequenceOfTranslator(); 40 | 41 | public abstract AbstractSequenceTranslator sequenceTranslator(); 42 | 43 | public abstract AbstractObjectIdentifierTranslator objectIdentifierTranslator(); 44 | } 45 | -------------------------------------------------------------------------------- /mts-asn1-core/src/main/java/com/ericsson/mts/asn1/translator/AbstractBooleanTranslator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1.translator; 12 | 13 | import com.ericsson.mts.asn1.BitArray; 14 | import com.ericsson.mts.asn1.BitInputStream; 15 | import com.ericsson.mts.asn1.TranslatorContext; 16 | import com.ericsson.mts.asn1.exception.NotHandledCaseException; 17 | import com.ericsson.mts.asn1.factory.FormatReader; 18 | import com.ericsson.mts.asn1.factory.FormatWriter; 19 | 20 | import java.io.IOException; 21 | import java.util.List; 22 | 23 | public abstract class AbstractBooleanTranslator extends AbstractTranslator { 24 | 25 | @Override 26 | public final void encode(String name, BitArray s, FormatReader reader, TranslatorContext translatorContext, List parameters) throws Exception { 27 | doEncode(s, reader.booleanValue(name)); 28 | } 29 | 30 | public abstract void doEncode(BitArray s, boolean value) throws IOException; 31 | 32 | @Override 33 | public final void decode(String name, BitInputStream s, FormatWriter writer, TranslatorContext translatorContext, List parameters) throws NotHandledCaseException, IOException { 34 | writer.booleanValue(name, doDecode(s)); 35 | } 36 | 37 | public abstract boolean doDecode(BitInputStream s) throws IOException; 38 | 39 | @Override 40 | public String toString() { 41 | return "AbstractBooleanTranslator{}"; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /mts-asn1-per/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | mts-asn1-per 8 | 9 | io.github.ericsson-mts 10 | mts-asn1 11 | master-SNAPSHOT 12 | 13 | jar 14 | 15 | 16 | 17 | io.github.ericsson-mts 18 | mts-asn1-core 19 | master-SNAPSHOT 20 | 21 | 22 | 23 | commons-io 24 | commons-io 25 | 26 | 27 | org.junit.jupiter 28 | junit-jupiter-engine 29 | 30 | 31 | net.javacrumbs.json-unit 32 | json-unit 33 | 34 | 35 | io.github.ericsson-mts 36 | mts-asn1-json 37 | master-SNAPSHOT 38 | test 39 | 40 | 41 | xmlunit 42 | xmlunit 43 | 44 | 45 | io.github.ericsson-mts 46 | mts-asn1-xml 47 | master-SNAPSHOT 48 | test 49 | 50 | 51 | commons-codec 52 | commons-codec 53 | 54 | 55 | org.slf4j 56 | slf4j-simple 57 | 58 | 59 | 60 | 61 | 62 | org.apache.maven.plugins 63 | maven-surefire-plugin 64 | 3.0.0-M3 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /mts-asn1-maven-plugin/src/main/java/com/ericsson/mts/asn1/plugin/MtsAsn1Mojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1.plugin; 12 | 13 | import org.apache.maven.plugin.AbstractMojo; 14 | import org.apache.maven.plugin.MojoExecutionException; 15 | import org.apache.maven.plugins.annotations.Mojo; 16 | import org.apache.maven.plugins.annotations.Parameter; 17 | import org.slf4j.Logger; 18 | import org.slf4j.LoggerFactory; 19 | 20 | import java.io.File; 21 | import java.io.IOException; 22 | import java.util.List; 23 | 24 | @Mojo(name = "generateJavaFile") 25 | public class MtsAsn1Mojo extends AbstractMojo { 26 | private Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName()); 27 | 28 | @Parameter(defaultValue = "CDRConstants") 29 | private String className; 30 | 31 | @Parameter(defaultValue = "target/generated-sources") 32 | private String outputFile; 33 | 34 | @Parameter 35 | private String outputPackage; 36 | 37 | @Parameter 38 | private List grammarFiles; 39 | 40 | public void execute() throws MojoExecutionException { 41 | if (outputPackage == null) { 42 | outputPackage = ""; 43 | } 44 | 45 | ConstantsGenerator constantsGenerator; 46 | try { 47 | constantsGenerator = new ConstantsGenerator(className, 48 | grammarFiles, 49 | outputPackage); 50 | constantsGenerator.writeFile(new File(outputFile)); 51 | } catch (IOException e) { 52 | logger.error(e.getLocalizedMessage()); 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /mts-asn1-core/src/main/java/com/ericsson/mts/asn1/constraint/SingleValueConstraint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1.constraint; 12 | 13 | import com.ericsson.mts.asn1.registry.MainRegistry; 14 | 15 | import java.math.BigInteger; 16 | import java.util.Map; 17 | 18 | public class SingleValueConstraint extends AbstractConstraint { 19 | private String value; 20 | private boolean isNumber; 21 | private MainRegistry mainRegistry; 22 | 23 | /** 24 | * Use when only a number/identifier appear in a constraint X.680 51.2.1 25 | * 26 | * @param mainRegistry main registry 27 | */ 28 | public SingleValueConstraint(MainRegistry mainRegistry) { 29 | this.mainRegistry = mainRegistry; 30 | } 31 | 32 | public BigInteger getValue() { 33 | if (null == value) { 34 | return null; 35 | } 36 | if (isNumber) { 37 | return new BigInteger(value); 38 | } else { 39 | return new BigInteger(mainRegistry.getConstantFromName(value).getValue()); 40 | } 41 | } 42 | 43 | public void setValue(String value, boolean isNumber) { 44 | if (null != this.value) { 45 | throw new RuntimeException("Multiple value assigned in the same SingleValueConstraint"); 46 | } 47 | this.value = value; 48 | this.isNumber = isNumber; 49 | } 50 | 51 | public void updateValue(Map registry) { 52 | if (isNumber) { 53 | return; 54 | } 55 | for (String key : registry.keySet()) { 56 | if (key.equals(value)) { 57 | value = registry.get(key); 58 | } 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /mts-asn1-maven-plugin/src/main/java/com/ericsson/mts/asn1/plugin/ConstantsGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1.plugin; 12 | 13 | import com.squareup.javapoet.JavaFile; 14 | import com.squareup.javapoet.TypeSpec; 15 | import org.slf4j.Logger; 16 | import org.slf4j.LoggerFactory; 17 | 18 | import javax.lang.model.element.Modifier; 19 | import java.io.File; 20 | import java.io.FileInputStream; 21 | import java.io.IOException; 22 | import java.nio.file.Path; 23 | import java.util.List; 24 | 25 | public class ConstantsGenerator { 26 | private JavaFile javaFile; 27 | private Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName()); 28 | 29 | ConstantsGenerator(String className, List grammarFiles, String generatedPackageName) throws IOException { 30 | TypeSpec.Builder builder = TypeSpec.classBuilder(className) 31 | .addModifiers(Modifier.PUBLIC, Modifier.FINAL); 32 | for (String grammarFile : grammarFiles) { 33 | builder = new IdentifierVisitor(builder).beginVisit(new FileInputStream(new File(grammarFile))); 34 | } 35 | this.javaFile = JavaFile.builder(generatedPackageName, builder.build()) 36 | .build(); 37 | } 38 | 39 | public void writeFile(Path filePath) throws IOException { 40 | javaFile.writeTo(filePath); 41 | } 42 | 43 | void writeFile(File file) throws IOException { 44 | if (file.mkdirs()) { 45 | logger.trace("Create directories for path : {}", file.getAbsolutePath()); 46 | } 47 | javaFile.writeTo(file); 48 | } 49 | 50 | public String getCode() { 51 | return javaFile.toString(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /mts-asn1-maven-plugin/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 15 | 16 | mts-asn1 17 | io.github.ericsson-mts 18 | master-SNAPSHOT 19 | 20 | 4.0.0 21 | 22 | mts-asn1-plugin 23 | maven-plugin 24 | 25 | 26 | 27 | io.github.ericsson-mts 28 | mts-asn1-antlr 29 | master-SNAPSHOT 30 | 31 | 32 | org.slf4j 33 | slf4j-api 34 | 35 | 36 | com.squareup 37 | javapoet 38 | 39 | 40 | org.apache.maven 41 | maven-plugin-api 42 | 43 | 44 | org.apache.maven.plugin-tools 45 | maven-plugin-annotations 46 | 47 | 48 | 49 | 50 | 51 | 52 | org.apache.maven.plugins 53 | maven-plugin-plugin 54 | ${maven-plugin.version} 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /mts-asn1-core/src/main/java/com/ericsson/mts/asn1/constraint/AbstractRangeConstraint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1.constraint; 12 | 13 | import com.ericsson.mts.asn1.registry.MainRegistry; 14 | 15 | import java.util.Map; 16 | 17 | /** 18 | * Abstract class for SizeConstraint and ValueRangeCosntraint 19 | */ 20 | public abstract class AbstractRangeConstraint extends AbstractConstraint { 21 | String lowerBound; 22 | String upperBound; 23 | boolean arelbNumber; 24 | boolean areubNumber; 25 | protected MainRegistry mainRegistry; 26 | 27 | AbstractRangeConstraint(MainRegistry mainRegistry) { 28 | this.mainRegistry = mainRegistry; 29 | } 30 | 31 | 32 | void setLowerBound(String lower_bound, boolean isNumber) { 33 | if (this.lowerBound != null) { 34 | throw new RuntimeException(); 35 | } 36 | this.lowerBound = lower_bound; 37 | this.arelbNumber = isNumber; 38 | } 39 | 40 | void setUpperBound(String upper_bound, boolean isNumber) { 41 | if (this.upperBound != null) { 42 | throw new RuntimeException(); 43 | } 44 | this.upperBound = upper_bound; 45 | this.areubNumber = isNumber; 46 | } 47 | 48 | void updateValue(Map registry) { 49 | if (arelbNumber && areubNumber) { 50 | return; 51 | } 52 | for (String key : registry.keySet()) { 53 | if (key.equals(lowerBound)) { 54 | lowerBound = registry.get(key); 55 | } 56 | if (key.equals(upperBound)) { 57 | upperBound = registry.get(key); 58 | } 59 | } 60 | } 61 | 62 | @Override 63 | public String toString() { 64 | return "SizeConstraint{" + 65 | "lowerBound=" + lowerBound + 66 | ", upperBound=" + upperBound + 67 | '}'; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /mts-asn1-per/src/main/java/com/ericsson/mts/asn1/CoderUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | package com.ericsson.mts.asn1; 11 | 12 | public class CoderUtils { 13 | 14 | public static int getIntegerLength(int value) { 15 | long mask = 0x7f800000L; 16 | int sizeOfInt = 4; 17 | if (value < 0) { 18 | while (((mask & value) == mask) && (sizeOfInt > 1)) { 19 | mask = mask >> 8; 20 | sizeOfInt--; 21 | } 22 | } else { 23 | while (((mask & value) == 0) && (sizeOfInt > 1)) { 24 | mask = mask >> 8; 25 | sizeOfInt--; 26 | } 27 | } 28 | return sizeOfInt; 29 | } 30 | 31 | public static int getIntegerLength(long value) { 32 | long mask = 0x7f80000000000000L; 33 | int sizeOfInt = 8; 34 | if (value < 0) { 35 | while (((mask & value) == mask) && (sizeOfInt > 1)) { 36 | mask = mask >> 8; 37 | sizeOfInt--; 38 | } 39 | } else { 40 | while (((mask & value) == 0) && (sizeOfInt > 1)) { 41 | mask = mask >> 8; 42 | sizeOfInt--; 43 | } 44 | } 45 | return sizeOfInt; 46 | } 47 | 48 | public static int getPositiveIntegerLength(long value) { 49 | if (value < 0) { 50 | long mask = 0x7f80000000000000L; 51 | int sizeOfInt = 8; 52 | while (((mask & ~value) == mask) && (sizeOfInt > 1)) { 53 | mask = mask >> 8; 54 | sizeOfInt--; 55 | } 56 | return sizeOfInt; 57 | } else { 58 | return getIntegerLength(value); 59 | } 60 | } 61 | 62 | public static String bytesToHex(byte[] bytes) { 63 | StringBuilder sb = new StringBuilder(); 64 | for (byte b : bytes) { 65 | sb.append(String.format("%02X", b)); 66 | } 67 | return sb.toString(); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /mts-asn1-per/src/test/java/com/ericsson/mts/asn1/S1APTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1; 12 | 13 | import org.junit.jupiter.api.BeforeAll; 14 | import org.junit.jupiter.api.Test; 15 | 16 | import java.util.Collections; 17 | 18 | class S1APTests extends AbstractTests { 19 | 20 | @BeforeAll 21 | static void init() { 22 | try { 23 | asn1Translator = new ASN1Translator(new PERTranslatorFactory(true), Collections.singletonList(S1APTests.class.getResourceAsStream("/grammar/S1AP/S1AP.asn"))); 24 | } catch (Exception e) { 25 | e.printStackTrace(); 26 | } 27 | } 28 | 29 | @Test 30 | void parseS1APGrammar() { 31 | testParsingANTLR(); 32 | } 33 | 34 | @Test 35 | void testS1AP1() throws Exception { 36 | test("S1AP-PDU", "/data/S1AP/InitialContextSetup/InitialContextSetupRequest/S1AP-1.bin", "/data/S1AP/InitialContextSetup/InitialContextSetupRequest/S1AP-1.json", "/data/S1AP/InitialContextSetup/InitialContextSetupRequest/S1AP-1.xml"); 37 | } 38 | 39 | @Test 40 | void testS1AP2() throws Exception { 41 | test("S1AP-PDU", "/data/S1AP/InitialContextSetup/InitialContextSetupResponse/S1AP-2.bin", "/data/S1AP/InitialContextSetup/InitialContextSetupResponse/S1AP-2.json", "/data/S1AP/InitialContextSetup/InitialContextSetupResponse/S1AP-2.xml"); 42 | } 43 | 44 | @Test 45 | void testS1AP3() throws Exception { 46 | test("S1AP-PDU", "/data/S1AP/id-E-RABModify/E-RABModifyRequest/E-RABModifyRequest.bin", "/data/S1AP/id-E-RABModify/E-RABModifyRequest/E-RABModifyRequest.json", "/data/S1AP/id-E-RABModify/E-RABModifyRequest/E-RABModifyRequest.xml"); 47 | } 48 | 49 | @Test 50 | void testS1AP4() throws Exception { 51 | test("S1AP-PDU", "/data/S1AP/id-E-RABModify/E-RABModifyResponse/E-RABModifyResponse.bin", "/data/S1AP/id-E-RABModify/E-RABModifyResponse/E-RABModifyResponse.json", "/data/S1AP/id-E-RABModify/E-RABModifyResponse/E-RABModifyResponse.xml"); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/eNodeB_Setup/S1SetupRequest/S1SetupRequest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 17 4 | reject 5 | 6 | 7 | 8 | 9 | 59 10 | reject 11 | 12 | 13 | 00F110 14 | 15 | 00000111000010000000 16 | 17 | 18 | 19 | 20 | 21 | 60 22 | ignore 23 | 24 | aric-eNB 25 | 26 | 27 | 28 | 64 29 | reject 30 | 31 | 32 | 33 | 000C 34 | 35 | 00F110 36 | 37 | 38 | 39 | 000B 40 | 41 | 00F110 42 | 43 | 44 | 45 | 000A 46 | 47 | 00F110 48 | 49 | 50 | 51 | 0009 52 | 53 | 00F110 54 | 55 | 56 | 57 | 58 | 59 | 60 | 137 61 | reject 62 | 63 | v32 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /mts-asn1-per/src/test/java/com/ericsson/mts/asn1/S1APAuthWSyncFailure.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1; 12 | 13 | import org.junit.jupiter.api.BeforeAll; 14 | import org.junit.jupiter.api.Test; 15 | 16 | import java.util.Collections; 17 | 18 | public class S1APAuthWSyncFailure extends AbstractTests { 19 | 20 | @BeforeAll 21 | static void init() { 22 | try { 23 | asn1Translator = new ASN1Translator(new PERTranslatorFactory(true), Collections.singletonList(S1APAuthWSyncFailure.class.getResourceAsStream("/grammar/S1AP/S1AP.asn"))); 24 | } catch (Exception e) { 25 | e.printStackTrace(); 26 | } 27 | } 28 | 29 | @Test 30 | void testInitialUEMessage() throws Exception { 31 | test("S1AP-PDU", "/data/S1AP/auth_w_sync_failure/InitialUEMessage/InitialUEMessage.bin", "/data/S1AP/auth_w_sync_failure/InitialUEMessage/InitialUEMessage.json", "/data/S1AP/auth_w_sync_failure/InitialUEMessage/InitialUEMessage.xml"); 32 | } 33 | 34 | @Test 35 | void testDownlinkNASTransport() throws Exception { 36 | test("S1AP-PDU", "/data/S1AP/auth_w_sync_failure/DownlinkNASTransport/DownlinkNASTransport.bin", "/data/S1AP/auth_w_sync_failure/DownlinkNASTransport/DownlinkNASTransport.json", "/data/S1AP/auth_w_sync_failure/DownlinkNASTransport/DownlinkNASTransport.xml"); 37 | } 38 | 39 | @Test 40 | void testUplinkNASTransport() throws Exception { 41 | test("S1AP-PDU", "/data/S1AP/auth_w_sync_failure/UplinkNASTransport/UplinkNASTransport.bin", "/data/S1AP/auth_w_sync_failure/UplinkNASTransport/UplinkNASTransport.json", "/data/S1AP/auth_w_sync_failure/UplinkNASTransport/UplinkNASTransport.xml"); 42 | } 43 | 44 | @Test 45 | void testDownlinkNASTransport2() throws Exception { 46 | test("S1AP-PDU", "/data/S1AP/auth_w_sync_failure/DownlinkNASTransport2/DownlinkNASTransport2.bin", "/data/S1AP/auth_w_sync_failure/DownlinkNASTransport2/DownlinkNASTransport2.json", "/data/S1AP/auth_w_sync_failure/DownlinkNASTransport2/DownlinkNASTransport2.xml"); 47 | } 48 | 49 | @Test 50 | void testUplinkNASTransport2() throws Exception { 51 | test("S1AP-PDU", "/data/S1AP/auth_w_sync_failure/UplinkNASTransport2/UplinkNASTransport2.bin", "/data/S1AP/auth_w_sync_failure/UplinkNASTransport2/UplinkNASTransport2.json", "/data/S1AP/auth_w_sync_failure/UplinkNASTransport2/UplinkNASTransport2.xml"); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /mts-asn1-per/src/main/java/com/ericsson/mts/asn1/translator/PEREnumeratedTranslator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | package com.ericsson.mts.asn1.translator; 11 | 12 | import com.ericsson.mts.asn1.BitArray; 13 | import com.ericsson.mts.asn1.BitInputStream; 14 | import com.ericsson.mts.asn1.PERTranscoder; 15 | import com.ericsson.mts.asn1.exception.NotHandledCaseException; 16 | import com.ericsson.mts.asn1.factory.FormatReader; 17 | import com.ericsson.mts.asn1.factory.FormatWriter; 18 | 19 | import java.io.IOException; 20 | import java.math.BigInteger; 21 | 22 | public class PEREnumeratedTranslator extends AbstractEnumeratedTranslator { 23 | 24 | private PERTranscoder perTranscoder; 25 | 26 | public PEREnumeratedTranslator(PERTranscoder perTranscoder) { 27 | this.perTranscoder = perTranscoder; 28 | } 29 | 30 | @Override 31 | public void doEncode(BitArray s, FormatReader reader, String value) throws IOException { 32 | logger.trace("Encode {}", this); 33 | int additionalIndex = additionalFieldsList.indexOf(value); 34 | if (hasExtensionMarker && additionalIndex != -1) { 35 | s.writeBit(1); 36 | perTranscoder.encodeNormallySmallWholeNumber(s, BigInteger.valueOf(additionalIndex)); 37 | } else { 38 | if (hasExtensionMarker) { 39 | s.writeBit(0); 40 | } 41 | perTranscoder.encodeConstrainedWholeNumber(s, BigInteger.valueOf(fieldList.indexOf(value)), BigInteger.ZERO, BigInteger.valueOf(fieldList.size() - 1L)); 42 | } 43 | } 44 | 45 | @Override 46 | public String doDecode(BitInputStream s, FormatWriter writer) throws IOException { 47 | logger.trace("{} : {}", this.name, this); 48 | // read the extension bit and returns the extension status, if grammar indicates it can be extended 49 | boolean isExtendedValue = hasExtensionMarker && (1 == s.readBit()); 50 | logger.trace("{} is extended : {}", this.name, isExtendedValue); 51 | if (!isExtendedValue) { 52 | return fieldList.get(perTranscoder.decodeConstrainedNumber(BigInteger.ZERO, BigInteger.valueOf(fieldList.size() - 1L), s).intValueExact()); 53 | } else { 54 | int choice = perTranscoder.decodeNormallySmallNumber(s).intValueExact(); 55 | if (additionalFieldsList.size() > choice) { 56 | return additionalFieldsList.get(choice); 57 | } else { 58 | return "UNKNOWN_EXTENDED(" + choice + ")"; 59 | } 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /mts-asn1-core/src/main/java/com/ericsson/mts/asn1/BitArray.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1; 12 | 13 | import com.ericsson.mts.asn1.factory.FormatWriter; 14 | import org.slf4j.Logger; 15 | import org.slf4j.LoggerFactory; 16 | 17 | import java.io.ByteArrayOutputStream; 18 | import java.io.IOException; 19 | import java.math.BigInteger; 20 | 21 | public class BitArray { 22 | private final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); 23 | private Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName()); 24 | private BigInteger length = BigInteger.ZERO; 25 | private int nextBit = 0; 26 | private int currentByte; 27 | 28 | public ByteArrayOutputStream getOutputStream() { 29 | 30 | return outputStream; 31 | } 32 | 33 | public synchronized void write(int b) throws IOException { 34 | if (nextBit == 0) { 35 | outputStream.write(b); 36 | length = length.add(BigInteger.valueOf(8)); 37 | } else { 38 | for (int i = 0; i < 8; i++) { 39 | this.writeBit((b >> (8 - i))); 40 | } 41 | } 42 | } 43 | 44 | public synchronized void writeBit(int bit) throws IOException { 45 | currentByte = currentByte << 1 | (bit & 0x0001); 46 | length = length.add(BigInteger.ONE); 47 | nextBit++; 48 | if (nextBit == 8) { 49 | outputStream.write(currentByte); 50 | nextBit = 0; 51 | currentByte = 0; 52 | } 53 | } 54 | 55 | public synchronized void skipAlignedBits() throws IOException { 56 | while (nextBit != 0) { 57 | writeBit(0); 58 | } 59 | } 60 | 61 | public void concatBitArray(BitArray bitArray) throws IOException { 62 | ByteArrayOutputStream outputStream = bitArray.getOutputStream(); 63 | for (byte octet : outputStream.toByteArray()) { 64 | this.write(octet); 65 | } 66 | } 67 | 68 | public BigInteger getLength() { 69 | return length; 70 | } 71 | 72 | public String getBinaryMessage() throws IOException { 73 | this.skipAlignedBits(); 74 | return FormatWriter.bytesToHex(outputStream.toByteArray()); 75 | } 76 | 77 | public byte[] getBinaryArray() { 78 | return outputStream.toByteArray(); 79 | } 80 | 81 | public String getActualBinaryMessage() { 82 | //Use for debug 83 | return FormatWriter.bytesToHex(outputStream.toByteArray()) + Integer.toString(currentByte, 16); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/InitialUEMessage/InitialUEMessage.xml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 13 | 12 14 | ignore 15 | 16 | 17 | 18 | 19 | 8 20 | reject 21 | 22 | 2060815 23 | 24 | 25 | 26 | 26 27 | reject 28 | 29 | 30 | 0748720B29071855102132713A85895805F0F0C040105C1004570200003103E5E0349011035758825D0100C1 31 | 32 | 33 | 34 | 35 | 67 36 | reject 37 | 38 | 39 | 132102 40 | 3039 41 | 42 | 43 | 44 | 45 | 100 46 | ignore 47 | 48 | 49 | 132102 50 | 0000000100010000000001000011 51 | 52 | 53 | 54 | 55 | 134 56 | ignore 57 | 58 | mo-Signalling 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/InitialUEMessage2/InitialUEMessage2.xml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 13 | 12 14 | ignore 15 | 16 | 17 | 18 | 19 | 8 20 | reject 21 | 22 | 2060816 23 | 24 | 25 | 26 | 26 27 | reject 28 | 29 | 30 | 0748720B29071855102132713A85895805F0F0C040105C1004570200003103E5E0349011035758825D0100C1 31 | 32 | 33 | 34 | 35 | 67 36 | reject 37 | 38 | 39 | 132102 40 | 3039 41 | 42 | 43 | 44 | 45 | 100 46 | ignore 47 | 48 | 49 | 132102 50 | 0000000100010000000001000011 51 | 52 | 53 | 54 | 55 | 134 56 | ignore 57 | 58 | mo-Signalling 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/weird_imsi_structure/InitialUEMessage3/InitialUEMessage3.xml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 13 | 12 14 | ignore 15 | 16 | 17 | 18 | 19 | 8 20 | reject 21 | 22 | 2060817 23 | 24 | 25 | 26 | 26 27 | reject 28 | 29 | 30 | 0748720B29071855102132713A85895805F0F0C040105C1004570200003103E5E0349011035758825D0100C1 31 | 32 | 33 | 34 | 35 | 67 36 | reject 37 | 38 | 39 | 132102 40 | 3039 41 | 42 | 43 | 44 | 45 | 100 46 | ignore 47 | 48 | 49 | 132102 50 | 0000000100010000000001000011 51 | 52 | 53 | 54 | 55 | 134 56 | ignore 57 | 58 | mo-Signalling 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /mts-asn1-core/src/main/java/com/ericsson/mts/asn1/ASN1Translator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1; 12 | 13 | import com.ericsson.mts.asn1.factory.AbstractTranslatorFactory; 14 | import com.ericsson.mts.asn1.factory.FormatReader; 15 | import com.ericsson.mts.asn1.factory.FormatWriter; 16 | import com.ericsson.mts.asn1.registry.MainRegistry; 17 | import com.ericsson.mts.asn1.visitor.TopLevelVisitor; 18 | import org.antlr.v4.runtime.CharStream; 19 | import org.antlr.v4.runtime.CharStreams; 20 | import org.antlr.v4.runtime.CommonTokenStream; 21 | import org.slf4j.Logger; 22 | import org.slf4j.LoggerFactory; 23 | 24 | import java.io.IOException; 25 | import java.io.InputStream; 26 | import java.util.List; 27 | 28 | public class ASN1Translator { 29 | private Logger logger = LoggerFactory.getLogger(ASN1Translator.class.getSimpleName()); 30 | private MainRegistry registry; 31 | 32 | public ASN1Translator(AbstractTranslatorFactory factory, List stream) throws IOException { 33 | registry = new MainRegistry(factory); 34 | for (InputStream inputStream : stream) { 35 | beginVisit(inputStream); 36 | } 37 | } 38 | 39 | public void encode(String string, BitArray bitArray, FormatReader formatReader) throws Exception { 40 | registry.getTranslatorFromName(string).encode(string, bitArray, formatReader, null); 41 | } 42 | 43 | public void decode(String str, InputStream stream, FormatWriter formatWriter) throws Exception { 44 | registry.getTranslatorFromName(str).decode(str, new BitInputStream(stream), formatWriter, null); 45 | } 46 | 47 | private void beginVisit(InputStream stream) throws IOException { 48 | CharStream inputStream = CharStreams.fromStream(stream); 49 | ASN1Lexer asn1Lexer = new ASN1Lexer(inputStream); 50 | CommonTokenStream commonTokenStream = new CommonTokenStream(asn1Lexer); 51 | ASN1Parser asn1Parser = new ASN1Parser(commonTokenStream); 52 | new TopLevelVisitor(registry).visitModuleDefinition(asn1Parser.moduleDefinition()); 53 | } 54 | 55 | public void parseTranslators() { 56 | registry.parseConstants(); 57 | registry.parseTranslators(); 58 | registry.parseClassHandler(); 59 | registry.parseClassObject(); 60 | registry.parseClassObjectSet(); 61 | if (!registry.checkIndexingRegistry()) { 62 | //Use debugger : registry -> indexingRegistry to see what's left 63 | throw new RuntimeException("IndexingRegistry isn't empty !"); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/auth_w_sync_failure/InitialUEMessage/InitialUEMessage.xml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 13 | 12 14 | ignore 15 | 16 | 17 | 18 | 19 | 8 20 | reject 21 | 22 | 1 23 | 24 | 25 | 26 | 26 27 | reject 28 | 29 | 30 | 0741720BF655F531870148E000000102E0E000210201D011D1271A8080211001000010810600000000830600000000000D00000A005255F531B26E9011034F18A6E0 31 | 32 | 33 | 34 | 35 | 67 36 | reject 37 | 38 | 39 | 55F531 40 | B26E 41 | 42 | 43 | 44 | 45 | 100 46 | ignore 47 | 48 | 49 | 55F531 50 | 0000000000000000000100000001 51 | 52 | 53 | 54 | 55 | 134 56 | ignore 57 | 58 | mo-Signalling 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /mts-asn1-core/src/main/java/com/ericsson/mts/asn1/translator/AbstractBitStringTranslator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1.translator; 12 | 13 | import com.ericsson.mts.asn1.ASN1Parser; 14 | import com.ericsson.mts.asn1.BitArray; 15 | import com.ericsson.mts.asn1.BitInputStream; 16 | import com.ericsson.mts.asn1.TranslatorContext; 17 | import com.ericsson.mts.asn1.constraint.Constraints; 18 | import com.ericsson.mts.asn1.exception.NotHandledCaseException; 19 | import com.ericsson.mts.asn1.factory.FormatReader; 20 | import com.ericsson.mts.asn1.factory.FormatWriter; 21 | import com.ericsson.mts.asn1.registry.MainRegistry; 22 | 23 | import java.io.IOException; 24 | import java.util.HashMap; 25 | import java.util.List; 26 | 27 | public abstract class AbstractBitStringTranslator extends AbstractTranslator { 28 | protected Constraints constraints; 29 | protected HashMap namedBitList = new HashMap<>(); 30 | 31 | public AbstractTranslator init(ASN1Parser.BitStringTypeContext bitStringTypeContext, MainRegistry mainRegistry, List constraintContexts) throws NotHandledCaseException { 32 | if (bitStringTypeContext.namedBitList() != null) { 33 | throw new NotHandledCaseException(); 34 | } 35 | 36 | if (constraintContexts.size() != 1) { 37 | throw new NotHandledCaseException(); 38 | } 39 | if (constraintContexts.get(0) != null) { 40 | constraints = new Constraints(mainRegistry); 41 | constraints.addConstraint(constraintContexts.get(0)); 42 | if (!constraints.hasSizeConstraint() && !constraints.hasContentsConstraint() && !constraints.hasSingleValueConstraints()) { 43 | throw new RuntimeException(); 44 | } 45 | } 46 | return this; 47 | } 48 | 49 | @Override 50 | public final void encode(String name, BitArray s, FormatReader reader, TranslatorContext translatorContext, List parameters) throws Exception { 51 | doEncode(s, reader, reader.bitsValue(name)); 52 | } 53 | 54 | public abstract void doEncode(BitArray s, FormatReader reader, String value) throws IOException; 55 | 56 | @Override 57 | public final void decode(String name, BitInputStream s, FormatWriter writer, TranslatorContext translatorContext, List parameters) throws NotHandledCaseException, IOException { 58 | writer.bitsValue(name, doDecode(s, writer)); 59 | } 60 | 61 | public abstract String doDecode(BitInputStream s, FormatWriter writer) throws NotHandledCaseException, IOException; 62 | } 63 | -------------------------------------------------------------------------------- /mts-asn1-per/src/main/java/com/ericsson/mts/asn1/PERTranslatorFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1; 12 | 13 | import com.ericsson.mts.asn1.factory.AbstractTranslatorFactory; 14 | import com.ericsson.mts.asn1.translator.*; 15 | 16 | public class PERTranslatorFactory extends AbstractTranslatorFactory { 17 | 18 | private PERTranscoder perTranscoder; 19 | 20 | public PERTranslatorFactory(boolean aligned) { 21 | perTranscoder = new PERTranscoder(aligned); 22 | } 23 | 24 | public PERTranslatorFactory(PERTranscoder perTranscoder) { 25 | this.perTranscoder = perTranscoder; 26 | } 27 | 28 | @Override 29 | public AbstractBitStringTranslator bitStringTranslator() { 30 | return new PERBitStringTranslator(perTranscoder); 31 | } 32 | 33 | @Override 34 | public AbstractBooleanTranslator booleanTranslator() { 35 | return new PERBooleanTranslator(); 36 | } 37 | 38 | @Override 39 | public AbstractChoiceTranslator choiceTranslator() { 40 | return new PERChoiceTranslator(perTranscoder); 41 | } 42 | 43 | @Override 44 | public AbstractEnumeratedTranslator enumeratedTranslator() { 45 | return new PEREnumeratedTranslator(perTranscoder); 46 | } 47 | 48 | @Override 49 | public AbstractIntegerTranslator integerTranslator() { 50 | return new PERIntegerTranslator(perTranscoder); 51 | } 52 | 53 | @Override 54 | public AbstractOctetStringTranslator octetStringTranslator() { 55 | return new PEROctetStringTranslator(perTranscoder); 56 | } 57 | 58 | @Override 59 | public AbstractRealTranslator realTranslator() { 60 | return new PERRealTranslator(perTranscoder); 61 | } 62 | 63 | @Override 64 | public AbstractRestrictedCharacterStringTranslator characterStringTranslator() { 65 | return new PERRestrictedCharacterStringTranslator(perTranscoder); 66 | } 67 | 68 | @Override 69 | public AbstractSequenceOfTranslator sequenceOfTranslator() { 70 | return new PERSequenceOfTranslator(perTranscoder); 71 | } 72 | 73 | @Override 74 | public AbstractSequenceTranslator sequenceTranslator() { 75 | return new PERSequenceTranslator(perTranscoder); 76 | } 77 | 78 | @Override 79 | public AbstractObjectClassFieldTranslator objectClassFieldTypeTranslator() { 80 | return new PERObjectClassFieldTranslator(perTranscoder); 81 | } 82 | 83 | @Override 84 | public AbstractObjectIdentifierTranslator objectIdentifierTranslator() { 85 | return new PERObjectIdentifierTranslator(perTranscoder); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/InitialContextSetup/InitialContextSetupResponse/S1AP-2.xml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 13 | 9 14 | reject 15 | 16 | 17 | 18 | 19 | 0 20 | ignore 21 | 22 | 37 23 | 24 | 25 | 26 | 8 27 | ignore 28 | 29 | 36 30 | 31 | 32 | 33 | 51 34 | ignore 35 | 36 | 37 | 38 | 50 39 | ignore 40 | 41 | 42 | 5 43 | 00001010111110111111110000001000 44 | 45 | 4B000000 46 | 47 | 48 | 49 | 50 | 50 51 | ignore 52 | 53 | 54 | 6 55 | 00001010111110111111110000001000 56 | 57 | 4C000000 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /mts-asn1-per/src/test/resources/data/S1AP/InitialContextSetup/InitialContextSetupRequest/S1AP-1.json: -------------------------------------------------------------------------------- 1 | { 2 | "initiatingMessage": { 3 | "procedureCode": 9, 4 | "criticality": "reject", 5 | "value": { 6 | "InitialContextSetupRequest": { 7 | "protocolIEs": [ 8 | { 9 | "id": 0, 10 | "criticality": "reject", 11 | "value": { 12 | "MME-UE-S1AP-ID": 37 13 | } 14 | }, 15 | { 16 | "id": 8, 17 | "criticality": "reject", 18 | "value": { 19 | "ENB-UE-S1AP-ID": 36 20 | } 21 | }, 22 | { 23 | "id": 66, 24 | "criticality": "reject", 25 | "value": { 26 | "UEAggregateMaximumBitrate": { 27 | "uEaggregateMaximumBitRateDL": 101711872, 28 | "uEaggregateMaximumBitRateUL": 101711872 29 | } 30 | } 31 | }, 32 | { 33 | "id": 24, 34 | "criticality": "reject", 35 | "value": { 36 | "E-RABToBeSetupListCtxtSUReq": [ 37 | { 38 | "id": 52, 39 | "criticality": "reject", 40 | "value": { 41 | "E-RABToBeSetupItemCtxtSUReq": { 42 | "e-RAB-ID": 5, 43 | "e-RABlevelQoSParameters": { 44 | "qCI": 7, 45 | "allocationRetentionPriority": { 46 | "priorityLevel": 2, 47 | "pre-emptionCapability": "shall-not-trigger-pre-emption", 48 | "pre-emptionVulnerability": "not-pre-emptable" 49 | } 50 | }, 51 | "transportLayerAddress": "00001010111111001111011000010111", 52 | "gTP-TEID": "4B000000", 53 | "nAS-PDU": "272EB753B30207420125062000F110002600605201C101071D08696E7465726E6574066D6E63303031036D636303303031046770727305010AFFF69A5D010030100A111F7396FFFF4629FFFF10000000003203813401005E04FEFE9F9F271480802110030000108106AC110001830600000000500BF600F110033552C0000024" 54 | } 55 | } 56 | }, 57 | { 58 | "id": 52, 59 | "criticality": "reject", 60 | "value": { 61 | "E-RABToBeSetupItemCtxtSUReq": { 62 | "e-RAB-ID": 6, 63 | "e-RABlevelQoSParameters": { 64 | "qCI": 7, 65 | "allocationRetentionPriority": { 66 | "priorityLevel": 4, 67 | "pre-emptionCapability": "shall-not-trigger-pre-emption", 68 | "pre-emptionVulnerability": "not-pre-emptable" 69 | } 70 | }, 71 | "transportLayerAddress": "00001010111111001111011000010111", 72 | "gTP-TEID": "4C000000", 73 | "nAS-PDU": "27E86ECBDD036200C50501071922208009100A989A81FFFFFFFF118109100A989A81FFFFFFFF5D019030100A111F7396FFFF4629FFFF1000000000320381340100271480802110030000108106AC110001830600000000" 74 | } 75 | } 76 | } 77 | ] 78 | } 79 | }, 80 | { 81 | "id": 107, 82 | "criticality": "reject", 83 | "value": { 84 | "UESecurityCapabilities": { 85 | "encryptionAlgorithms": "1100000000000000", 86 | "integrityProtectionAlgorithms": "1100000000000000" 87 | } 88 | } 89 | }, 90 | { 91 | "id": 73, 92 | "criticality": "reject", 93 | "value": { 94 | "SecurityKey": "0001110110001111010010111100000011010000100001111110100010100001011101001111100010110110110111110010100101111111011101101001110000110010000010111110001011010010001110101010011011110100110000001101101000100100000001100000100101111110100101101010111010111010" 95 | } 96 | } 97 | ] 98 | } 99 | } 100 | } 101 | } -------------------------------------------------------------------------------- /mts-asn1-core/src/main/java/com/ericsson/mts/asn1/translator/AbstractOctetStringTranslator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1.translator; 12 | 13 | import com.ericsson.mts.asn1.ASN1Parser; 14 | import com.ericsson.mts.asn1.BitArray; 15 | import com.ericsson.mts.asn1.BitInputStream; 16 | import com.ericsson.mts.asn1.TranslatorContext; 17 | import com.ericsson.mts.asn1.constraint.Constraints; 18 | import com.ericsson.mts.asn1.exception.NotHandledCaseException; 19 | import com.ericsson.mts.asn1.factory.FormatReader; 20 | import com.ericsson.mts.asn1.factory.FormatWriter; 21 | import com.ericsson.mts.asn1.registry.MainRegistry; 22 | 23 | import java.io.ByteArrayInputStream; 24 | import java.io.IOException; 25 | import java.math.BigInteger; 26 | import java.util.List; 27 | 28 | public abstract class AbstractOctetStringTranslator extends AbstractTranslator { 29 | protected Constraints constraints; 30 | 31 | public AbstractTranslator init(MainRegistry mainRegistry, List constraintContexts) throws NotHandledCaseException { 32 | constraints = new Constraints(mainRegistry); 33 | if (constraintContexts.size() == 0) { 34 | return this; 35 | } else if (constraintContexts.size() != 1) { 36 | throw new NotHandledCaseException(); 37 | } 38 | if (constraintContexts.get(0) != null) { 39 | constraints.addConstraint(constraintContexts.get(0)); 40 | if (!constraints.hasSizeConstraint() && !constraints.hasContentsConstraint() && !constraints.hasSingleValueConstraints()) { 41 | throw new NotHandledCaseException(constraintContexts.get(0).getText()); 42 | } 43 | } 44 | return this; 45 | } 46 | 47 | @Override 48 | public final void encode(String name, BitArray s, FormatReader reader, TranslatorContext translatorContext, List parameters) throws Exception { 49 | if (!constraints.hasContentsConstraint()) { 50 | doEncode(s, reader, reader.bytesValue(name)); 51 | } else { 52 | BitArray bitArray = new BitArray(); 53 | constraints.getContentTranslator().encode(name, bitArray, reader, translatorContext); 54 | bitArray.skipAlignedBits(); 55 | doEncode(s, reader, bitArray.getBinaryMessage()); 56 | } 57 | } 58 | 59 | public abstract void doEncode(BitArray s, FormatReader reader, String value) throws IOException; 60 | 61 | @Override 62 | public void decode(String name, BitInputStream s, FormatWriter writer, TranslatorContext translatorContext, List parameters) throws Exception { 63 | if (!constraints.hasContentsConstraint()) { 64 | writer.bytesValue(name, doDecode(s, writer)); 65 | } else { 66 | BitInputStream bitInputStream = new BitInputStream(new ByteArrayInputStream(doDecode(s, writer))); 67 | constraints.getContentTranslator().decode(name, bitInputStream, writer, translatorContext); 68 | } 69 | } 70 | 71 | public abstract byte[] doDecode(BitInputStream s, FormatWriter writer) throws IOException; 72 | 73 | @Override 74 | public String toString() { 75 | return "AbstractOctetStringTranslator{" + 76 | "constraints=" + constraints + 77 | '}'; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /mts-asn1-maven-plugin/src/main/java/com/ericsson/mts/asn1/plugin/IdentifierVisitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1.plugin; 12 | 13 | import com.ericsson.mts.asn1.ASN1Lexer; 14 | import com.ericsson.mts.asn1.ASN1Parser; 15 | import com.ericsson.mts.asn1.ASN1ParserBaseVisitor; 16 | import com.squareup.javapoet.FieldSpec; 17 | import com.squareup.javapoet.TypeSpec; 18 | import org.antlr.v4.runtime.CharStream; 19 | import org.antlr.v4.runtime.CharStreams; 20 | import org.antlr.v4.runtime.CommonTokenStream; 21 | 22 | import javax.lang.model.element.Modifier; 23 | import java.io.IOException; 24 | import java.io.InputStream; 25 | import java.util.HashSet; 26 | 27 | class IdentifierVisitor { 28 | private IdentifierVisitorInner identifierVisitorInner; 29 | private HashSet insertedName = new HashSet<>(); 30 | 31 | IdentifierVisitor(TypeSpec.Builder typeSpec) { 32 | identifierVisitorInner = new IdentifierVisitorInner(typeSpec); 33 | } 34 | 35 | TypeSpec.Builder beginVisit(InputStream stream) throws IOException { 36 | return identifierVisitorInner.beginVisit(stream); 37 | } 38 | 39 | 40 | private class IdentifierVisitorInner extends ASN1ParserBaseVisitor { 41 | private TypeSpec.Builder builder; 42 | 43 | /** 44 | * Constructor 45 | * 46 | * @param builder javapoet builder 47 | */ 48 | IdentifierVisitorInner(TypeSpec.Builder builder) { 49 | this.builder = builder; 50 | } 51 | 52 | /** 53 | * Visit asn file and return completed builder 54 | * @param stream asn file 55 | * @return javapoet builder 56 | * @throws IOException output file error 57 | */ 58 | TypeSpec.Builder beginVisit(InputStream stream) throws IOException { 59 | CharStream inputStream = CharStreams.fromStream(stream); 60 | ASN1Lexer asn1Lexer = new ASN1Lexer(inputStream); 61 | CommonTokenStream commonTokenStream = new CommonTokenStream(asn1Lexer); 62 | ASN1Parser asn1Parser = new ASN1Parser(commonTokenStream); 63 | visitModuleDefinition(asn1Parser.moduleDefinition()); 64 | return builder; 65 | } 66 | 67 | 68 | @Override 69 | public Object visitNamedNumber(ASN1Parser.NamedNumberContext ctx) { 70 | addField(ctx.IDENTIFIER().getText(), ctx.IDENTIFIER().getText()); 71 | return super.visitNamedNumber(ctx); 72 | } 73 | 74 | 75 | @Override 76 | public Object visitNamedType(ASN1Parser.NamedTypeContext ctx) { 77 | addField(ctx.IDENTIFIER().getText(), ctx.IDENTIFIER().getText()); 78 | return super.visitNamedType(ctx); 79 | } 80 | 81 | /** 82 | * add a field to javapoet Builder 83 | * @param fieldName name of the field 84 | * @param fieldValue value of the field 85 | */ 86 | private void addField(String fieldName, String fieldValue) { 87 | String inputName = fieldName.replace("-", "_").toUpperCase(); 88 | if (!insertedName.contains(fieldName)) { 89 | insertedName.add(fieldName); 90 | builder.addField(FieldSpec.builder(String.class, inputName) 91 | .addModifiers(Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL) 92 | .initializer("$S", fieldValue) 93 | .build()); 94 | } 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /mts-asn1-core/src/main/java/com/ericsson/mts/asn1/translator/AbstractRestrictedCharacterStringTranslator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ericsson, https://www.ericsson.com/en 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | * 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | package com.ericsson.mts.asn1.translator; 12 | 13 | import com.ericsson.mts.asn1.ASN1Parser; 14 | import com.ericsson.mts.asn1.BitArray; 15 | import com.ericsson.mts.asn1.BitInputStream; 16 | import com.ericsson.mts.asn1.TranslatorContext; 17 | import com.ericsson.mts.asn1.constraint.Constraints; 18 | import com.ericsson.mts.asn1.exception.NotHandledCaseException; 19 | import com.ericsson.mts.asn1.factory.FormatReader; 20 | import com.ericsson.mts.asn1.factory.FormatWriter; 21 | import com.ericsson.mts.asn1.registry.MainRegistry; 22 | 23 | import java.io.IOException; 24 | import java.util.List; 25 | 26 | public abstract class AbstractRestrictedCharacterStringTranslator extends AbstractTranslator { 27 | protected Constraints constraints; 28 | protected boolean isknownMultiplierCharacterStringType = false; 29 | protected MainRegistry mainRegistry; 30 | protected KnownMultiplierCharacterString knownMultiplierCharacterString; 31 | 32 | public AbstractRestrictedCharacterStringTranslator init(MainRegistry mainRegistry, ASN1Parser.CharacterStringTypeContext characterStringTypeContext, List constraintContexts) { 33 | this.mainRegistry = mainRegistry; 34 | if (characterStringTypeContext.restrictedCharacterStringType() != null && characterStringTypeContext.restrictedCharacterStringType().PRINTABLE_STRING() != null) { 35 | constraints = new Constraints(mainRegistry); 36 | constraints.addConstraint(constraintContexts.get(0)); 37 | if (!constraints.hasSizeConstraint()) { 38 | throw new NotHandledCaseException(); 39 | } 40 | isknownMultiplierCharacterStringType = true; 41 | knownMultiplierCharacterString = KnownMultiplierCharacterString.PrintableString; 42 | } else { 43 | throw new NotHandledCaseException(); 44 | } 45 | return this; 46 | } 47 | 48 | @Override 49 | public final void encode(String name, BitArray s, FormatReader reader, TranslatorContext translatorContext, List parameters) throws Exception { 50 | doEncode(s, reader, reader.stringValue(name)); 51 | } 52 | 53 | public abstract void doEncode(BitArray s, FormatReader reader, String value) throws IOException; 54 | 55 | @Override 56 | public final void decode(String name, BitInputStream s, FormatWriter writer, TranslatorContext translatorContext, List parameters) throws NotHandledCaseException, IOException { 57 | writer.stringValue(name, doDecode(s, writer)); 58 | } 59 | 60 | public abstract String doDecode(BitInputStream s, FormatWriter writer) throws IOException; 61 | 62 | protected enum KnownMultiplierCharacterString { 63 | PrintableString(32, 122, 7, 8); 64 | 65 | private final int lb; 66 | private final int ub; 67 | private final int b; 68 | private final int b2; 69 | 70 | KnownMultiplierCharacterString(int lb, int ub, int b, int b2) { 71 | this.lb = lb; 72 | this.ub = ub; 73 | this.b = b; 74 | this.b2 = b2; 75 | } 76 | 77 | public int getLb() { 78 | return lb; 79 | } 80 | 81 | public int getUb() { 82 | return ub; 83 | } 84 | 85 | public int getB() { 86 | return b; 87 | } 88 | 89 | public int getB2() { 90 | return b2; 91 | } 92 | } 93 | } 94 | --------------------------------------------------------------------------------