private void _decode(AsnInputStream asnIS, int length) throws MAPParsingComponentException, IOException, AsnException { if (asnIS.getTagClass() != Tag.CLASS_CONTEXT_SPECIFIC || !asnIS.isTagPrimitive()) throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ": bad tag class or is not primitive: TagClass=" + asnIS.getTagClass(), MAPParsingComponentExceptionReason.MistypedParameter); switch (asnIS.getTag()) { case _TAG_MSC_NUMBER: this.mSCNumber = new ISDNAddressStringImpl(); ((ISDNAddressStringImpl) this.mSCNumber).decodeData(asnIS, length); break; case _TAG_SGSN_NUMBER: this.sGSNNumber = new ISDNAddressStringImpl(); ((ISDNAddressStringImpl) this.sGSNNumber).decodeData(asnIS, length); break; default: throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ": Expexted msc-Number [0] ISDN-AddressString or sgsn-Number [1] ISDN-AddressString, but found " + asnIS.getTag(), MAPParsingComponentExceptionReason.MistypedParameter); } }
private void _decode(AsnInputStream ansIS, int length) throws MAPParsingComponentException, IOException, AsnException { AsnInputStream ais = ansIS.readSequenceStreamData(length); int tag = ais.readTag(); // ussd-DataCodingScheme USSD-DataCodingScheme if (ais.getTagClass() != Tag.CLASS_UNIVERSAL || !ais.isTagPrimitive()) throw new MAPParsingComponentException( "Error while decoding UnstructuredSSResponseIndication: Parameter ussd-DataCodingScheme bad tag class or not primitive", MAPParsingComponentExceptionReason.MistypedParameter); int length1 = ais.readLength(); this.ussdDataCodingSch = new CBSDataCodingSchemeImpl(ais.readOctetStringData(length1)[0]); tag = ais.readTag(); // ussd-String USSD-String if (ais.getTagClass() != Tag.CLASS_UNIVERSAL || !ais.isTagPrimitive()) throw new MAPParsingComponentException( "Error while decoding UnstructuredSSResponseIndication: Parameter ussd-String bad tag class or not primitive", MAPParsingComponentExceptionReason.MistypedParameter); this.ussdString = new USSDStringImpl(this.ussdDataCodingSch); ((USSDStringImpl) this.ussdString).decodeAll(ais); }
@Test(groups = {"functional.decode", "primitives"}) public void testDecode() throws Exception { byte[] data = this.getData1(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); LocationAreaImpl prim = new LocationAreaImpl(); prim.decodeAll(asn); assertEquals(tag, LocationAreaImpl._TAG_laiFixedLength); assertEquals(asn.getTagClass(), Tag.CLASS_CONTEXT_SPECIFIC); LAIFixedLength lai = prim.getLAIFixedLength(); assertEquals(lai.getMCC(), 249); assertEquals(lai.getMNC(), 1); assertEquals(lai.getLac(), 14010); assertNull(prim.getLAC()); data = this.getData2(); asn = new AsnInputStream(data); tag = asn.readTag(); prim = new LocationAreaImpl(); prim.decodeAll(asn); assertEquals(tag, LocationAreaImpl._TAG_lac); assertEquals(asn.getTagClass(), Tag.CLASS_CONTEXT_SPECIFIC); assertNull(prim.getLAIFixedLength()); LAC lac = prim.getLAC(); assertEquals(lac.getLac(), 14010); }
@Override protected void _decode(AsnInputStream asnIS, int length) throws MAPParsingComponentException, IOException, AsnException { AsnInputStream ais = asnIS.readSequenceStreamData(length); int num = 0; while (true) { if (ais.available() == 0) break; int tag = ais.readTag(); switch (num) { case 0: if (tag != Tag.STRING_OCTET || ais.getTagClass() != Tag.CLASS_UNIVERSAL || !ais.isTagPrimitive()) { throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ".kc: Parameter 0 bad tag or tag class or not primitive", MAPParsingComponentExceptionReason.MistypedParameter); } this.kc = new KcImpl(); ((KcImpl) this.kc).decodeAll(ais); break; case 1: if (tag != Tag.STRING_OCTET || ais.getTagClass() != Tag.CLASS_UNIVERSAL || !ais.isTagPrimitive()) { throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ".cksn: Parameter 1 bad tag or tag class or not primitive", MAPParsingComponentExceptionReason.MistypedParameter); } this.cksn = new CksnImpl(); ((CksnImpl) this.cksn).decodeAll(ais); break; default: ais.advanceElement(); break; } num++; } if (num < 2) throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ": Needs at least 2 mandatory parameters, found " + num, MAPParsingComponentExceptionReason.MistypedParameter); }
@Test(groups = {"functional.decode"}) public void testDecode() throws Exception { byte[] rawData = getEncodedData(); AsnInputStream asn = new AsnInputStream(rawData); int tag = asn.readTag(); EpsAuthenticationSetListImpl asc = new EpsAuthenticationSetListImpl(); asc.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); ArrayList<EpcAv> epcAvs = asc.getEpcAv(); assertEquals(epcAvs.size(), 2); assertTrue(Arrays.equals(epcAvs.get(0).getRand(), EpcAvTest.getRandData())); assertTrue(Arrays.equals(epcAvs.get(0).getXres(), EpcAvTest.getXresData())); assertTrue(Arrays.equals(epcAvs.get(0).getAutn(), EpcAvTest.getAutnData())); assertTrue(Arrays.equals(epcAvs.get(0).getKasme(), EpcAvTest.getKasmeData())); assertTrue(Arrays.equals(epcAvs.get(1).getRand(), EpcAvTest.getRandData())); assertTrue(Arrays.equals(epcAvs.get(1).getXres(), getXresData())); assertTrue(Arrays.equals(epcAvs.get(1).getAutn(), EpcAvTest.getAutnData())); assertTrue(Arrays.equals(epcAvs.get(1).getKasme(), EpcAvTest.getKasmeData())); }
@Test(groups = {"functional.decode", "primitives"}) public void testDecode() throws Exception { byte[] data = this.getData(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); EPSQoSSubscribedImpl prim = new EPSQoSSubscribedImpl(); prim.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); AllocationRetentionPriority allocationRetentionPriority = prim.getAllocationRetentionPriority(); MAPExtensionContainer extensionContainer = prim.getExtensionContainer(); assertEquals(allocationRetentionPriority.getPriorityLevel(), 1); assertTrue(allocationRetentionPriority.getPreEmptionCapability()); assertTrue(allocationRetentionPriority.getPreEmptionVulnerability()); assertNotNull(allocationRetentionPriority.getExtensionContainer()); ; assertTrue( MAPExtensionContainerTest.CheckTestExtensionContainer( allocationRetentionPriority.getExtensionContainer())); assertNotNull(extensionContainer); assertEquals(prim.getQoSClassIdentifier(), QoSClassIdentifier.QCI_1); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(extensionContainer)); }
private void _decode(AsnInputStream ais, int length) throws MAPParsingComponentException, IOException, AsnException { this.forwardingInfo = null; this.callBarringInfo = null; this.cugInfo = null; this.ssData = null; this.emlppInfo = null; if (ais.getTagClass() != Tag.CLASS_CONTEXT_SPECIFIC || ais.isTagPrimitive()) throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ": bad tag class or is primitive: TagClass=" + ais.getTagClass(), MAPParsingComponentExceptionReason.MistypedParameter); switch (ais.getTag()) { case _TAG_forwardingInfo: this.forwardingInfo = new ExtForwInfoImpl(); ((ExtForwInfoImpl) this.forwardingInfo).decodeData(ais, length); break; case _TAG_callBarringInfo: this.callBarringInfo = new ExtCallBarInfoImpl(); ((ExtCallBarInfoImpl) this.callBarringInfo).decodeData(ais, length); break; case _TAG_cugInfo: this.cugInfo = new CUGInfoImpl(); ((CUGInfoImpl) this.cugInfo).decodeData(ais, length); break; case _TAG_ssData: this.ssData = new ExtSSDataImpl(); ((ExtSSDataImpl) this.ssData).decodeData(ais, length); break; case _TAG_emlppInfo: this.emlppInfo = new EMLPPInfoImpl(); ((EMLPPInfoImpl) this.emlppInfo).decodeData(ais, length); break; default: throw new MAPParsingComponentException( "Error while " + _PrimitiveName + ": bad tag: " + ais.getTag(), MAPParsingComponentExceptionReason.MistypedParameter); } }
@Test(groups = {"functional.decode", "circuitSwitchedCall.primitive"}) public void testDecode() throws Exception { byte[] data = this.getData(); AsnInputStream ais = new AsnInputStream(data); TDisconnectSpecificInfoImpl elem = new TDisconnectSpecificInfoImpl(); int tag = ais.readTag(); assertEquals(tag, EventSpecificInformationBCSMImpl._ID_tDisconnectSpecificInfo); assertEquals(ais.getTagClass(), Tag.CLASS_CONTEXT_SPECIFIC); elem.decodeAll(ais); assertTrue(Arrays.equals(elem.getReleaseCause().getData(), this.getIntData())); }
@Test(groups = {"functional.decode", "primitives"}) public void testDecode() throws Exception { byte[] rawData = getData(); AsnInputStream asn = new AsnInputStream(rawData); int tag = asn.readTag(); AccessRestrictionDataImpl imp = new AccessRestrictionDataImpl(); imp.decodeAll(asn); assertEquals(tag, Tag.STRING_BIT); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertTrue(!imp.getUtranNotAllowed()); assertTrue(imp.getGeranNotAllowed()); assertTrue(!imp.getGanNotAllowed()); assertTrue(imp.getIHspaEvolutionNotAllowed()); assertTrue(!imp.getEUtranNotAllowed()); assertTrue(imp.getHoToNon3GPPAccessNotAllowed()); rawData = getData1(); asn = new AsnInputStream(rawData); tag = asn.readTag(); imp = new AccessRestrictionDataImpl(); imp.decodeAll(asn); assertEquals(tag, Tag.STRING_BIT); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertTrue(imp.getUtranNotAllowed()); assertTrue(!imp.getGeranNotAllowed()); assertTrue(imp.getGanNotAllowed()); assertTrue(!imp.getIHspaEvolutionNotAllowed()); assertTrue(imp.getEUtranNotAllowed()); assertTrue(!imp.getHoToNon3GPPAccessNotAllowed()); }
private void _decode(AsnInputStream ansIS, int length) throws CAPParsingComponentException, IOException, AsnException { this.elementaryMessageID = 0; this.variableParts = null; boolean elementaryMessageIDFound = false; AsnInputStream ais = ansIS.readSequenceStreamData(length); while (true) { if (ais.available() == 0) break; int tag = ais.readTag(); if (ais.getTagClass() == Tag.CLASS_CONTEXT_SPECIFIC) { switch (tag) { case _ID_elementaryMessageID: this.elementaryMessageID = (int) ais.readInteger(); elementaryMessageIDFound = true; break; case _ID_variableParts: this.variableParts = new ArrayList<VariablePart>(); AsnInputStream ais2 = ais.readSequenceStream(); while (true) { if (ais2.available() == 0) break; ais2.readTag(); VariablePartImpl val = new VariablePartImpl(); val.decodeAll(ais2); this.variableParts.add(val); } break; default: ais.advanceElement(); break; } } else { ais.advanceElement(); } } if (this.variableParts == null || !elementaryMessageIDFound) throw new CAPParsingComponentException( "Error while decoding " + _PrimitiveName + ": elementaryMessageID and variableParts are mandatory but not found", CAPParsingComponentExceptionReason.MistypedParameter); }
private void _decode(AsnInputStream ansIS, int length) throws MAPParsingComponentException, IOException, AsnException { this.signalInfo = null; this.protocolId = null; this.extensionContainer = null; AsnInputStream ais = ansIS.readSequenceStreamData(length); while (true) { if (ais.available() == 0) break; int tag = ais.readTag(); if (ais.getTagClass() == Tag.CLASS_UNIVERSAL) { switch (tag) { case Tag.ENUMERATED: int code = (int) ais.readInteger(); this.protocolId = ProtocolId.getProtocolId(code); break; case Tag.STRING_OCTET: if (!ais.isTagPrimitive()) throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ".signalInfo: Parameter extensionContainer is not primitive", MAPParsingComponentExceptionReason.MistypedParameter); this.signalInfo = new SignalInfoImpl(); ((SignalInfoImpl) this.signalInfo).decodeAll(ais); break; case Tag.SEQUENCE: if (ais.isTagPrimitive()) throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ".extensionContainer: Parameter extensionContainer is primitive", MAPParsingComponentExceptionReason.MistypedParameter); this.extensionContainer = new MAPExtensionContainerImpl(); ((MAPExtensionContainerImpl) this.extensionContainer).decodeAll(ais); break; default: ais.advanceElement(); break; } } } if (this.protocolId == null || this.signalInfo == null) throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ": protocolId and signalInfo must not be null", MAPParsingComponentExceptionReason.MistypedParameter); }
@Test(groups = {"functional.decode", "service.sms"}) public void testDecode() throws Exception { byte[] rawData = getEncodedData(); AsnInputStream asn = new AsnInputStream(rawData); int tag = asn.readTag(); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); ReadyForSMResponseImpl impl = new ReadyForSMResponseImpl(); impl.decodeAll(asn); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(impl.getExtensionContainer())); }
@Test(groups = {"functional.decode", "service.supplementary"}) public void testDecode() throws Exception { byte[] rawData = getEncodedData(); AsnInputStream asn = new AsnInputStream(rawData); int tag = asn.readTag(); assertEquals(tag, Tag.STRING_NUMERIC); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); GetPasswordResponseImpl impl = new GetPasswordResponseImpl(); impl.decodeAll(asn); assertEquals(impl.getPassword().getData(), "0123"); }
@Override protected void _decode(AsnInputStream asnIS, int length) throws CAPParsingComponentException, IOException, AsnException { this.roVolumeSinceLastTariffSwitch = -1; this.roVolumeTariffSwitchInterval = -1; AsnInputStream ais = asnIS.readSequenceStreamData(length); while (true) { if (ais.available() == 0) break; int tag = ais.readTag(); if (ais.getTagClass() == Tag.CLASS_CONTEXT_SPECIFIC) { switch (tag) { case _ID_roVolumeSinceLastTariffSwitch: if (!ais.isTagPrimitive()) throw new CAPParsingComponentException( "Error while decoding " + _PrimitiveName + ".roVolumeSinceLastTariffSwitch: Parameter is not primitive", CAPParsingComponentExceptionReason.MistypedParameter); this.roVolumeSinceLastTariffSwitch = (int) ais.readInteger(); break; case _ID_roVolumeTariffSwitchInterval: if (!ais.isTagPrimitive()) throw new CAPParsingComponentException( "Error while decoding " + _PrimitiveName + ".roVolumeTariffSwitchInterval: Parameter is not primitive", CAPParsingComponentExceptionReason.MistypedParameter); this.roVolumeTariffSwitchInterval = (int) ais.readInteger(); break; default: ais.advanceElement(); break; } } else { ais.advanceElement(); } } }
private void _decode(AsnInputStream ais, int length) throws CAPParsingComponentException, IOException, AsnException, MAPParsingComponentException { this.volumeIfNoTariffSwitch = null; this.volumeIfTariffSwitch = null; int tag = ais.getTag(); if (ais.getTagClass() == Tag.CLASS_CONTEXT_SPECIFIC) { switch (tag) { case _ID_volumeIfNoTariffSwitch: if (!ais.isTagPrimitive()) throw new CAPParsingComponentException( "Error while decoding " + _PrimitiveName + ".volumeIfNoTariffSwitch: Parameter is not primitive", CAPParsingComponentExceptionReason.MistypedParameter); this.volumeIfNoTariffSwitch = ais.readIntegerData(length); break; case _ID_volumeIfTariffSwitch: if (ais.isTagPrimitive()) throw new CAPParsingComponentException( "Error while decoding " + _PrimitiveName + ".volumeIfTariffSwitch: Parameter is primitive", CAPParsingComponentExceptionReason.MistypedParameter); this.volumeIfTariffSwitch = new VolumeIfTariffSwitchImpl(); ((VolumeIfTariffSwitchImpl) this.volumeIfTariffSwitch).decodeData(ais, length); break; default: throw new CAPParsingComponentException( "Error while decoding " + _PrimitiveName + ": bad choice tag", CAPParsingComponentExceptionReason.MistypedParameter); } } else { throw new CAPParsingComponentException( "Error while decoding " + _PrimitiveName + ": bad choice tagClass", CAPParsingComponentExceptionReason.MistypedParameter); } }
private void _decode(AsnInputStream ais, int length) throws CAPParsingComponentException, IOException, AsnException, MAPParsingComponentException { this.maxTransferredVolume = -1; this.maxElapsedTime = -1; int tag = ais.getTag(); if (ais.getTagClass() == Tag.CLASS_CONTEXT_SPECIFIC) { switch (tag) { case _ID_maxTransferredVolume: if (!ais.isTagPrimitive()) throw new CAPParsingComponentException( "Error while decoding " + _PrimitiveName + ".maxTransferredVolume: Parameter is not primitive", CAPParsingComponentExceptionReason.MistypedParameter); this.maxTransferredVolume = (long) ais.readIntegerData(length); break; case _ID_maxElapsedTime: if (!ais.isTagPrimitive()) throw new CAPParsingComponentException( "Error while decoding " + _PrimitiveName + ".maxElapsedTime: Parameter is not primitive", CAPParsingComponentExceptionReason.MistypedParameter); this.maxElapsedTime = (int) ais.readIntegerData(length); break; default: throw new CAPParsingComponentException( "Error while decoding " + _PrimitiveName + ": bad choice tag", CAPParsingComponentExceptionReason.MistypedParameter); } } else { throw new CAPParsingComponentException( "Error while decoding " + _PrimitiveName + ": bad choice tagClass", CAPParsingComponentExceptionReason.MistypedParameter); } }
@Test(groups = {"functional.decode", "service.oam"}) public void testDecode() throws Exception { byte[] rawData = getEncodedData(); AsnInputStream asn = new AsnInputStream(rawData); int tag = asn.readTag(); PGWInterfaceListImpl asc = new PGWInterfaceListImpl(); asc.decodeAll(asn); assertEquals(tag, Tag.STRING_BIT); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertTrue(asc.getS2a()); assertFalse(asc.getS2b()); assertTrue(asc.getS2c()); assertFalse(asc.getS5()); assertTrue(asc.getS6b()); assertTrue(asc.getGx()); assertFalse(asc.getS8b()); assertTrue(asc.getSgi()); }
private void _decode(AsnInputStream ansIS, int length) throws CAPParsingComponentException, IOException, AsnException { this.aocInitial = null; this.aocSubsequent = null; AsnInputStream ais = ansIS.readSequenceStreamData(length); while (true) { if (ais.available() == 0) break; int tag = ais.readTag(); if (ais.getTagClass() == Tag.CLASS_CONTEXT_SPECIFIC) { switch (tag) { case _ID_cAI_GSM0224: this.aocInitial = new CAI_GSM0224Impl(); ((CAI_GSM0224Impl) this.aocInitial).decodeAll(ais); break; case _ID_aOCSubsequent: this.aocSubsequent = new AOCSubsequentImpl(); ((AOCSubsequentImpl) this.aocSubsequent).decodeAll(ais); break; default: ais.advanceElement(); break; } } else { ais.advanceElement(); } } if (this.aocInitial == null) throw new CAPParsingComponentException( "Error while decoding " + _PrimitiveName + ": aocInitial is mandatory but not found", CAPParsingComponentExceptionReason.MistypedParameter); }
@Test(groups = {"functional.decode", "service.lsm"}) public void testDecode() throws Exception { byte[] rawData = getEncodedData(); AsnInputStream asn = new AsnInputStream(rawData); int tag = asn.readTag(); SupportedGADShapesImpl supportedLCSCapabilityTest = new SupportedGADShapesImpl(); supportedLCSCapabilityTest.decodeAll(asn); assertEquals(tag, Tag.STRING_BIT); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertEquals((boolean) supportedLCSCapabilityTest.getEllipsoidArc(), true); assertEquals((boolean) supportedLCSCapabilityTest.getEllipsoidPoint(), true); assertEquals((boolean) supportedLCSCapabilityTest.getEllipsoidPointWithAltitude(), true); assertEquals( (boolean) supportedLCSCapabilityTest.getEllipsoidPointWithAltitudeAndUncertaintyElipsoid(), true); assertEquals( (boolean) supportedLCSCapabilityTest.getEllipsoidPointWithUncertaintyCircle(), true); assertEquals( (boolean) supportedLCSCapabilityTest.getEllipsoidPointWithUncertaintyEllipse(), true); assertEquals((boolean) supportedLCSCapabilityTest.getPolygon(), true); }
@Test(groups = {"functional.decode"}) public void testDecode() throws Exception { byte[] rawData = getEncodedData(); AsnInputStream asn = new AsnInputStream(rawData); int tag = asn.readTag(); UpdateLocationRequestImpl asc = new UpdateLocationRequestImpl(3); asc.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertEquals(asc.getMapProtocolVersion(), 3); IMSI imsi = asc.getImsi(); assertTrue(imsi.getData().equals("1111122222")); assertNull(asc.getRoamingNumber()); ISDNAddressString mscNumber = asc.getMscNumber(); assertTrue(mscNumber.getAddress().equals("22228")); assertEquals(mscNumber.getAddressNature(), AddressNature.international_number); assertEquals(mscNumber.getNumberingPlan(), NumberingPlan.ISDN); ISDNAddressString vlrNumber = asc.getVlrNumber(); assertTrue(vlrNumber.getAddress().equals("22229")); assertEquals(vlrNumber.getAddressNature(), AddressNature.international_number); assertEquals(vlrNumber.getNumberingPlan(), NumberingPlan.ISDN); VLRCapability vlrCap = asc.getVlrCapability(); assertTrue(vlrCap.getSupportedLCSCapabilitySets().getCapabilitySetRelease98_99()); assertFalse(vlrCap.getSupportedLCSCapabilitySets().getCapabilitySetRelease4()); assertNull(asc.getLmsi()); assertNull(asc.getExtensionContainer()); assertFalse(asc.getInformPreviousNetworkEntity()); assertFalse(asc.getCsLCSNotSupportedByUE()); assertFalse(asc.getSkipSubscriberDataUpdate()); assertFalse(asc.getRestorationIndicator()); rawData = getEncodedData2(); asn = new AsnInputStream(rawData); tag = asn.readTag(); asc = new UpdateLocationRequestImpl(3); asc.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertEquals(asc.getMapProtocolVersion(), 3); imsi = asc.getImsi(); assertTrue(imsi.getData().equals("1111122233")); assertNull(asc.getRoamingNumber()); mscNumber = asc.getMscNumber(); assertTrue(mscNumber.getAddress().equals("22228")); assertEquals(mscNumber.getAddressNature(), AddressNature.international_number); assertEquals(mscNumber.getNumberingPlan(), NumberingPlan.ISDN); vlrNumber = asc.getVlrNumber(); assertTrue(vlrNumber.getAddress().equals("22229")); assertEquals(vlrNumber.getAddressNature(), AddressNature.international_number); assertEquals(vlrNumber.getNumberingPlan(), NumberingPlan.ISDN); vlrCap = asc.getVlrCapability(); assertTrue(vlrCap.getSupportedLCSCapabilitySets().getCapabilitySetRelease98_99()); assertFalse(vlrCap.getSupportedLCSCapabilitySets().getCapabilitySetRelease4()); assertTrue(Arrays.equals(asc.getLmsi().getData(), getLmsiData())); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(asc.getExtensionContainer())); assertTrue(asc.getInformPreviousNetworkEntity()); assertTrue(asc.getCsLCSNotSupportedByUE()); assertTrue(asc.getSkipSubscriberDataUpdate()); assertTrue(asc.getRestorationIndicator()); rawData = getEncodedData3(); asn = new AsnInputStream(rawData); tag = asn.readTag(); asc = new UpdateLocationRequestImpl(3); asc.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertEquals(asc.getMapProtocolVersion(), 3); imsi = asc.getImsi(); assertTrue(imsi.getData().equals("1111122233")); assertNull(asc.getRoamingNumber()); mscNumber = asc.getMscNumber(); assertTrue(mscNumber.getAddress().equals("22228")); assertEquals(mscNumber.getAddressNature(), AddressNature.international_number); assertEquals(mscNumber.getNumberingPlan(), NumberingPlan.ISDN); vlrNumber = asc.getVlrNumber(); assertTrue(vlrNumber.getAddress().equals("22229")); assertEquals(vlrNumber.getAddressNature(), AddressNature.international_number); assertEquals(vlrNumber.getNumberingPlan(), NumberingPlan.ISDN); vlrCap = asc.getVlrCapability(); assertTrue(vlrCap.getSupportedLCSCapabilitySets().getCapabilitySetRelease98_99()); assertFalse(vlrCap.getSupportedLCSCapabilitySets().getCapabilitySetRelease4()); assertTrue(Arrays.equals(asc.getLmsi().getData(), getLmsiData())); assertNull(asc.getExtensionContainer()); assertTrue(asc.getInformPreviousNetworkEntity()); assertTrue(asc.getCsLCSNotSupportedByUE()); assertTrue(asc.getSkipSubscriberDataUpdate()); assertTrue(asc.getRestorationIndicator()); assertTrue(Arrays.equals(asc.getVGmlcAddress().getData(), getGSNAddressData())); assertTrue(asc.getADDInfo().getImeisv().getIMEI().equals("123456789009876")); assertFalse(asc.getADDInfo().getSkipSubscriberDataUpdate()); assertEquals(asc.getPagingArea().getLocationAreas().size(), 1); assertEquals(asc.getPagingArea().getLocationAreas().get(0).getLAC().getLac(), 123); rawData = getEncodedData_V1(); asn = new AsnInputStream(rawData); tag = asn.readTag(); asc = new UpdateLocationRequestImpl(1); asc.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertEquals(asc.getMapProtocolVersion(), 1); imsi = asc.getImsi(); assertTrue(imsi.getData().equals("1111122233")); assertNull(asc.getMscNumber()); ISDNAddressString roamingNumber = asc.getRoamingNumber(); assertTrue(roamingNumber.getAddress().equals("22220")); assertEquals(roamingNumber.getAddressNature(), AddressNature.international_number); assertEquals(roamingNumber.getNumberingPlan(), NumberingPlan.ISDN); vlrNumber = asc.getVlrNumber(); assertTrue(vlrNumber.getAddress().equals("22221")); assertEquals(vlrNumber.getAddressNature(), AddressNature.international_number); assertEquals(vlrNumber.getNumberingPlan(), NumberingPlan.ISDN); assertNull(asc.getVlrCapability()); assertNull(asc.getLmsi()); assertNull(asc.getExtensionContainer()); assertFalse(asc.getInformPreviousNetworkEntity()); assertFalse(asc.getCsLCSNotSupportedByUE()); assertFalse(asc.getSkipSubscriberDataUpdate()); assertFalse(asc.getRestorationIndicator()); }
@Override protected void _decode(AsnInputStream asnIS, int length) throws MAPParsingComponentException, IOException, AsnException { this.groupId = null; this.extensionContainer = null; this.additionalSubscriptions = null; this.additionalInfo = null; this.longGroupId = null; AsnInputStream ais = asnIS.readSequenceStreamData(length); int num = 0; while (true) { if (ais.available() == 0) break; int tag = ais.readTag(); switch (num) { case 0: if (!ais.isTagPrimitive() || tag != Tag.STRING_OCTET || ais.getTagClass() != Tag.CLASS_UNIVERSAL) throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ".groupId: Bad tab or tag class or Parameter not primitive", MAPParsingComponentExceptionReason.MistypedParameter); this.groupId = new GroupIdImpl(); ((GroupIdImpl) this.groupId).decodeAll(ais); break; default: switch (ais.getTagClass()) { case Tag.CLASS_UNIVERSAL: { switch (tag) { case Tag.SEQUENCE: if (ais.isTagPrimitive()) throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ".extensionContainer: Parameter extensionContainer is primitive", MAPParsingComponentExceptionReason.MistypedParameter); this.extensionContainer = new MAPExtensionContainerImpl(); ((MAPExtensionContainerImpl) this.extensionContainer).decodeAll(ais); break; case Tag.STRING_BIT: if (!ais.isTagPrimitive()) throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ".additionalSubscriptions: Parameter is not primitive", MAPParsingComponentExceptionReason.MistypedParameter); this.additionalSubscriptions = new AdditionalSubscriptionsImpl(); ((AdditionalSubscriptionsImpl) this.additionalSubscriptions).decodeAll(ais); break; default: ais.advanceElement(); break; } } break; case Tag.CLASS_CONTEXT_SPECIFIC: { switch (tag) { case _TAG_additionalInfo: if (!ais.isTagPrimitive()) throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ".additionalInfo: Parameter not primitive", MAPParsingComponentExceptionReason.MistypedParameter); this.additionalInfo = new AdditionalInfoImpl(); ((AdditionalInfoImpl) this.additionalInfo).decodeAll(ais); break; case _TAG_longGroupId: if (!ais.isTagPrimitive()) throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ".longGroupId: Parameter not primitive", MAPParsingComponentExceptionReason.MistypedParameter); this.longGroupId = new LongGroupIdImpl(); ((LongGroupIdImpl) this.longGroupId).decodeAll(ais); break; default: ais.advanceElement(); break; } } break; default: ais.advanceElement(); break; } break; } num++; } if (this.groupId == null) { throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ": Parament groupId is mandatory but does not found", MAPParsingComponentExceptionReason.MistypedParameter); } }
protected void _decode(AsnInputStream ansIS, int length) throws MAPParsingComponentException, IOException, AsnException { this.privateExtensionList = null; this.slrArgPcsExtensions = null; AsnInputStream ais = ansIS.readSequenceStreamData(length); while (true) { if (ais.available() == 0) break; int tag = ais.readTag(); if (ais.getTagClass() == Tag.CLASS_CONTEXT_SPECIFIC) { switch (tag) { case _TAG_privateExtensionList: if (ais.isTagPrimitive()) throw new MAPParsingComponentException( "Error while " + _PrimitiveName + " decoding: privateExtensionList is primitive", MAPParsingComponentExceptionReason.MistypedParameter); if (this.privateExtensionList != null) throw new MAPParsingComponentException( "Error while " + _PrimitiveName + " decoding: More than one PrivateExtensionList has found", MAPParsingComponentExceptionReason.MistypedParameter); AsnInputStream localAis2 = ais.readSequenceStream(); this.privateExtensionList = new ArrayList<MAPPrivateExtension>(); while (localAis2.available() > 0) { tag = localAis2.readTag(); if (tag != Tag.SEQUENCE || localAis2.getTagClass() != Tag.CLASS_UNIVERSAL || localAis2.isTagPrimitive()) throw new MAPParsingComponentException( "Error while " + _PrimitiveName + " decoding: Bad tag, tagClass or primitiveFactor of PrivateExtension", MAPParsingComponentExceptionReason.MistypedParameter); if (this.privateExtensionList.size() >= 10) throw new MAPParsingComponentException( "More then 10 " + _PrimitiveName + " found when PrivateExtensionList decoding", MAPParsingComponentExceptionReason.MistypedParameter); MAPPrivateExtensionImpl privateExtension = new MAPPrivateExtensionImpl(); privateExtension.decodeAll(localAis2); this.privateExtensionList.add(privateExtension); } break; case _TAG_slr_Arg_PCS_Extensions: if (ais.isTagPrimitive()) throw new MAPParsingComponentException( "Error while " + _PrimitiveName + " decoding: slrArgPcsExtensions is primitive", MAPParsingComponentExceptionReason.MistypedParameter); if (this.slrArgPcsExtensions != null) throw new MAPParsingComponentException( "Error while " + _PrimitiveName + " decoding: More than one slrArgPcsExtensions has found", MAPParsingComponentExceptionReason.MistypedParameter); this.slrArgPcsExtensions = new SLRArgPCSExtensionsImpl(); ((SLRArgPCSExtensionsImpl) this.slrArgPcsExtensions).decodeAll(ais); break; default: ais.advanceElement(); break; } } else { ais.advanceElement(); } } }
private void _decode(AsnInputStream ansIS, int length) throws MAPParsingComponentException, IOException, AsnException { this.authenticationSetList = null; this.extensionContainer = null; this.epsAuthenticationSetList = null; if (mapProtocolVersion >= 3) { AsnInputStream ais = ansIS.readSequenceStreamData(length); while (true) { if (ais.available() == 0) break; int tag = ais.readTag(); if (ais.getTagClass() == Tag.CLASS_CONTEXT_SPECIFIC) { switch (tag) { case AuthenticationSetListImpl._TAG_tripletList: case AuthenticationSetListImpl._TAG_quintupletList: // authenticationSetList this.authenticationSetList = new AuthenticationSetListImpl(); ((AuthenticationSetListImpl) this.authenticationSetList).decodeAll(ais); break; case _TAG_eps_AuthenticationSetList: // epsAuthenticationSetList if (ais.isTagPrimitive()) throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ".epsAuthenticationSetList: Parameter epsAuthenticationSetList is primitive", MAPParsingComponentExceptionReason.MistypedParameter); this.epsAuthenticationSetList = new EpsAuthenticationSetListImpl(); ((EpsAuthenticationSetListImpl) this.epsAuthenticationSetList).decodeAll(ais); break; default: ais.advanceElement(); break; } } else if (ais.getTagClass() == Tag.CLASS_UNIVERSAL) { switch (tag) { case Tag.SEQUENCE: // extensionContainer if (ais.isTagPrimitive()) throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ".extensionContainer: Parameter extensionContainer is primitive", MAPParsingComponentExceptionReason.MistypedParameter); this.extensionContainer = new MAPExtensionContainerImpl(); ((MAPExtensionContainerImpl) this.extensionContainer).decodeAll(ais); break; default: ais.advanceElement(); break; } } else { ais.advanceElement(); } } } else { this.authenticationSetList = new AuthenticationSetListImpl(); ((AuthenticationSetListImpl) this.authenticationSetList).decodeData(ansIS, length); } }
protected void _decode(AsnInputStream asnIS, int length) throws MAPParsingComponentException, IOException, AsnException { this.networkNodeNumber = null; this.lmsi = null; this.extensionContainer = null; this.gprsNodeIndicator = false; this.additionalNumber = null; this.supportedLCSCapabilitySets = null; this.additionalLCSCapabilitySets = null; this.mmeName = null; this.aaaServerName = null; AsnInputStream ais = asnIS.readSequenceStreamData(length); int tag = ais.readTag(); if (ais.getTagClass() != Tag.CLASS_UNIVERSAL || !ais.isTagPrimitive() || tag != Tag.STRING_OCTET) { throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ": Parameter [networkNode-Number ISDN-AddressString] bad tag class, tag or not primitive", MAPParsingComponentExceptionReason.MistypedParameter); } this.networkNodeNumber = new ISDNAddressStringImpl(); ((ISDNAddressStringImpl) this.networkNodeNumber).decodeAll(ais); while (true) { if (ais.available() == 0) break; tag = ais.readTag(); if (ais.getTagClass() == Tag.CLASS_CONTEXT_SPECIFIC) { switch (tag) { case _TAG_LMSI: // lmsi [0] LMSI OPTIONAL, if (!ais.isTagPrimitive()) { throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ": Parameter [lmsi [0] LMSI ] bad tag class, tag or not primitive", MAPParsingComponentExceptionReason.MistypedParameter); } this.lmsi = new LMSIImpl(); ((LMSIImpl) this.lmsi).decodeAll(ais); break; case _TAG_EXTENSION_CONTAINER: // extensionContainer [1] ExtensionContainer if (ais.isTagPrimitive()) { throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ": Parameter [extensionContainer [1] ExtensionContainer ] is primitive", MAPParsingComponentExceptionReason.MistypedParameter); } this.extensionContainer = new MAPExtensionContainerImpl(); ((MAPExtensionContainerImpl) this.extensionContainer).decodeAll(ais); break; case _TAG_GPRS_NODE_IND: // gprsNodeIndicator [2] NULL if (!ais.isTagPrimitive()) { throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ": Parameter [gprsNodeIndicator [2] NULL ] is not primitive", MAPParsingComponentExceptionReason.MistypedParameter); } ais.readNull(); this.gprsNodeIndicator = true; break; case _TAG_ADDITIONAL_NUMBER: // additional-Number [3] Additional-Number OPTIONAL if (ais.isTagPrimitive()) { throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ": Parameter [additional-Number [3] Additional-Number] is primitive", MAPParsingComponentExceptionReason.MistypedParameter); } this.additionalNumber = new AdditionalNumberImpl(); AsnInputStream ais2 = ais.readSequenceStream(); ais2.readTag(); ((AdditionalNumberImpl) this.additionalNumber).decodeAll(ais2); break; case _TAG_SUPPORTED_LCS_CAPBILITY_SET: // supportedLCS-CapabilitySets [4] // SupportedLCS-CapabilitySets if (!ais.isTagPrimitive()) { throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ": Parameter [supportedLCS-CapabilitySets [4] SupportedLCS-CapabilitySets] is not primitive", MAPParsingComponentExceptionReason.MistypedParameter); } this.supportedLCSCapabilitySets = new SupportedLCSCapabilitySetsImpl(); ((SupportedLCSCapabilitySetsImpl) this.supportedLCSCapabilitySets).decodeAll(ais); break; case _TAG_ADDITIONAL_LCS_CAPBILITY_SET: // additional-LCS-CapabilitySets [5] // SupportedLCS-CapabilitySets OPTIONAL if (!ais.isTagPrimitive()) { throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ": Parameter [additional-LCS-CapabilitySets [5] SupportedLCS-CapabilitySets] is not primitive", MAPParsingComponentExceptionReason.MistypedParameter); } this.additionalLCSCapabilitySets = new SupportedLCSCapabilitySetsImpl(); ((SupportedLCSCapabilitySetsImpl) this.additionalLCSCapabilitySets).decodeAll(ais); break; case _TAG_mme_Name: // mmeName if (!ais.isTagPrimitive()) { throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ": Parameter mmeName is not primitive", MAPParsingComponentExceptionReason.MistypedParameter); } this.mmeName = new DiameterIdentityImpl(); ((DiameterIdentityImpl) this.mmeName).decodeAll(ais); break; case _TAG_aaa_Server_Name: // aaaServerName if (!ais.isTagPrimitive()) { throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ": Parameter aaaServerName is not primitive", MAPParsingComponentExceptionReason.MistypedParameter); } this.aaaServerName = new DiameterIdentityImpl(); ((DiameterIdentityImpl) this.aaaServerName).decodeAll(ais); break; default: ais.advanceElement(); } } else { ais.advanceElement(); } } }
protected void _decode(AsnInputStream ansIS, int length) throws MAPParsingComponentException, IOException, AsnException { ExtBasicServiceCode serviceItem = null; this.ssCode = null; this.ssStatus = null; this.ssSubscriptionOption = null; this.basicServiceGroupList = null; this.extensionContainer = null; AsnInputStream ais = ansIS.readSequenceStreamData(length); int num = 0; while (true) { if (ais.available() == 0) break; int tag = ais.readTag(); switch (num) { case 0: // ssCode if (ais.getTagClass() != Tag.CLASS_UNIVERSAL || tag != Tag.STRING_OCTET || !ais.isTagPrimitive()) throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ".ssCode: bad tag or tag class or not primitive", MAPParsingComponentExceptionReason.MistypedParameter); this.ssCode = new SSCodeImpl(); ((SSCodeImpl) this.ssCode).decodeAll(ais); break; case 1: // ss-Status if (ais.getTagClass() != Tag.CLASS_CONTEXT_SPECIFIC || tag != _TAG_ss_Status || !ais.isTagPrimitive()) throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + "._TAG_ss_Status: bad tag or tag class or not primitive", MAPParsingComponentExceptionReason.MistypedParameter); this.ssStatus = new ExtSSStatusImpl(); ((ExtSSStatusImpl) this.ssStatus).decodeAll(ais); break; default: switch (ais.getTagClass()) { case Tag.CLASS_CONTEXT_SPECIFIC: switch (tag) { case SSSubscriptionOptionImpl._TAG_overrideCategory: case SSSubscriptionOptionImpl._TAG_cliRestrictionOption: this.ssSubscriptionOption = new SSSubscriptionOptionImpl(); ((SSSubscriptionOptionImpl) this.ssSubscriptionOption).decodeAll(ais); break; case _TAG_extensionContainer: if (ais.isTagPrimitive()) throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ".extensionContainer: is primitive", MAPParsingComponentExceptionReason.MistypedParameter); this.extensionContainer = new MAPExtensionContainerImpl(); ((MAPExtensionContainerImpl) this.extensionContainer).decodeAll(ais); break; default: ais.advanceElement(); break; } break; case Tag.CLASS_UNIVERSAL: // basicServiceGroupList switch (tag) { case Tag.SEQUENCE: AsnInputStream ais2 = ais.readSequenceStream(); this.basicServiceGroupList = new ArrayList<ExtBasicServiceCode>(); while (true) { if (ais2.available() == 0) break; ais2.readTag(); serviceItem = new ExtBasicServiceCodeImpl(); ((ExtBasicServiceCodeImpl) serviceItem).decodeAll(ais2); this.basicServiceGroupList.add(serviceItem); } if (this.basicServiceGroupList.size() < 1 && this.basicServiceGroupList.size() > 32) { throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ": Parameter basicServiceGroupList size must be from 1 to 32, found: " + this.basicServiceGroupList.size(), MAPParsingComponentExceptionReason.MistypedParameter); } break; default: ais.advanceElement(); break; } break; default: ais.advanceElement(); break; } break; } num++; } if (this.ssCode == null) throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ": ssCode required.", MAPParsingComponentExceptionReason.MistypedParameter); if (this.ssStatus == null) throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ": ssStatus required.", MAPParsingComponentExceptionReason.MistypedParameter); }
@Override protected void _decode(AsnInputStream asnIS, int length) throws MAPParsingComponentException, IOException, AsnException { this.cgiList = null; this.eUtranCgiList = null; this.routingAreaIdList = null; this.locationAreaIdList = null; this.trackingAreaIdList = null; this.extensionContainer = null; AsnInputStream ais = asnIS.readSequenceStreamData(length); while (true) { if (ais.available() == 0) break; int tag = ais.readTag(); switch (ais.getTagClass()) { case Tag.CLASS_CONTEXT_SPECIFIC: { switch (tag) { case _ID_cgiList: if (ais.isTagPrimitive()) throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ".cgiList: is primitive", MAPParsingComponentExceptionReason.MistypedParameter); AsnInputStream ais2 = ais.readSequenceStream(); GlobalCellId globalCellId = null; this.cgiList = new ArrayList<GlobalCellId>(); while (true) { if (ais2.available() == 0) break; int tag2 = ais2.readTag(); if (tag2 != Tag.STRING_OCTET || ais2.getTagClass() != Tag.CLASS_UNIVERSAL || !ais2.isTagPrimitive()) throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ": bad tag or tagClass or is not primitive when decoding cgiList", MAPParsingComponentExceptionReason.MistypedParameter); globalCellId = new GlobalCellIdImpl(); ((GlobalCellIdImpl) globalCellId).decodeAll(ais2); this.cgiList.add(globalCellId); } if (this.cgiList.size() < 1 && this.cgiList.size() > 32) { throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ": Parameter cgiList size must be from 1 to 32, found: " + this.cgiList.size(), MAPParsingComponentExceptionReason.MistypedParameter); } break; case _ID_eUtranCgiList: if (ais.isTagPrimitive()) throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ".eUtranCgiList: is primitive", MAPParsingComponentExceptionReason.MistypedParameter); ais2 = ais.readSequenceStream(); EUtranCgi eUtranCgi = null; this.eUtranCgiList = new ArrayList<EUtranCgi>(); while (true) { if (ais2.available() == 0) break; int tag2 = ais2.readTag(); if (tag2 != Tag.STRING_OCTET || ais2.getTagClass() != Tag.CLASS_UNIVERSAL || !ais2.isTagPrimitive()) throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ": bad tag or tagClass or is not primitive when decoding eUtranCgiList", MAPParsingComponentExceptionReason.MistypedParameter); eUtranCgi = new EUtranCgiImpl(); ((EUtranCgiImpl) eUtranCgi).decodeAll(ais2); this.eUtranCgiList.add(eUtranCgi); } if (this.eUtranCgiList.size() < 1 && this.eUtranCgiList.size() > 32) { throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ": Parameter eUtranCgiList size must be from 1 to 32, found: " + this.eUtranCgiList.size(), MAPParsingComponentExceptionReason.MistypedParameter); } break; case _ID_routingAreaIdList: if (ais.isTagPrimitive()) throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ".routingAreaIdList: is primitive", MAPParsingComponentExceptionReason.MistypedParameter); ais2 = ais.readSequenceStream(); RAIdentity raIdentity = null; this.routingAreaIdList = new ArrayList<RAIdentity>(); while (true) { if (ais2.available() == 0) break; int tag2 = ais2.readTag(); if (tag2 != Tag.STRING_OCTET || ais2.getTagClass() != Tag.CLASS_UNIVERSAL || !ais2.isTagPrimitive()) throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ": bad tag or tagClass or is not primitive when decoding routingAreaIdList", MAPParsingComponentExceptionReason.MistypedParameter); raIdentity = new RAIdentityImpl(); ((RAIdentityImpl) raIdentity).decodeAll(ais2); this.routingAreaIdList.add(raIdentity); } if (this.routingAreaIdList.size() < 1 && this.routingAreaIdList.size() > 8) { throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ": Parameter routingAreaIdList size must be from 1 to 8, found: " + this.routingAreaIdList.size(), MAPParsingComponentExceptionReason.MistypedParameter); } break; case _ID_locationAreaIdList: if (ais.isTagPrimitive()) throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ".locationAreaIdList: is primitive", MAPParsingComponentExceptionReason.MistypedParameter); ais2 = ais.readSequenceStream(); LAIFixedLength laiFixedLength = null; this.locationAreaIdList = new ArrayList<LAIFixedLength>(); while (true) { if (ais2.available() == 0) break; int tag2 = ais2.readTag(); if (tag2 != Tag.STRING_OCTET || ais2.getTagClass() != Tag.CLASS_UNIVERSAL || !ais2.isTagPrimitive()) throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ": bad tag or tagClass or is not primitive when decoding locationAreaIdList", MAPParsingComponentExceptionReason.MistypedParameter); laiFixedLength = new LAIFixedLengthImpl(); ((LAIFixedLengthImpl) laiFixedLength).decodeAll(ais2); this.locationAreaIdList.add(laiFixedLength); } if (this.locationAreaIdList.size() < 1 && this.locationAreaIdList.size() > 8) { throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ": Parameter locationAreaIdList size must be from 1 to 8, found: " + this.locationAreaIdList.size(), MAPParsingComponentExceptionReason.MistypedParameter); } break; case _ID_trackingAreaIdList: if (ais.isTagPrimitive()) throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ".trackingAreaIdList: is primitive", MAPParsingComponentExceptionReason.MistypedParameter); ais2 = ais.readSequenceStream(); TAId taId = null; this.trackingAreaIdList = new ArrayList<TAId>(); while (true) { if (ais2.available() == 0) break; int tag2 = ais2.readTag(); if (tag2 != Tag.STRING_OCTET || ais2.getTagClass() != Tag.CLASS_UNIVERSAL || !ais2.isTagPrimitive()) throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ": bad tag or tagClass or is not primitive when decoding trackingAreaIdList", MAPParsingComponentExceptionReason.MistypedParameter); taId = new TAIdImpl(); ((TAIdImpl) taId).decodeAll(ais2); this.trackingAreaIdList.add(taId); } if (this.trackingAreaIdList.size() < 1 && this.trackingAreaIdList.size() > 8) { throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ": Parameter trackingAreaIdList size must be from 1 to 8, found: " + this.trackingAreaIdList.size(), MAPParsingComponentExceptionReason.MistypedParameter); } break; case _ID_extensionContainer: if (ais.isTagPrimitive()) throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ".extensionContainer: Parameter extensionContainer is primitive", MAPParsingComponentExceptionReason.MistypedParameter); this.extensionContainer = new MAPExtensionContainerImpl(); ((MAPExtensionContainerImpl) this.extensionContainer).decodeAll(ais); break; default: ais.advanceElement(); break; } } break; default: ais.advanceElement(); break; } } }
@Test(groups = {"functional.decode", "primitives"}) public void testDecode() throws Exception { byte[] data = this.getData(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); ExtForwFeatureImpl prim = new ExtForwFeatureImpl(); prim.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); MAPExtensionContainer extensionContainer = prim.getExtensionContainer(); assertEquals( prim.getBasicService().getExtBearerService().getBearerServiceCodeValue(), BearerServiceCodeValue.padAccessCA_9600bps); assertNull(prim.getBasicService().getExtTeleservice()); assertNotNull(prim.getSsStatus()); assertTrue(prim.getSsStatus().getBitA()); assertTrue(!prim.getSsStatus().getBitP()); assertTrue(!prim.getSsStatus().getBitQ()); assertTrue(prim.getSsStatus().getBitR()); ISDNAddressString forwardedToNumber = prim.getForwardedToNumber(); assertNotNull(forwardedToNumber); assertTrue(forwardedToNumber.getAddress().equals("22228")); assertEquals(forwardedToNumber.getAddressNature(), AddressNature.international_number); assertEquals(forwardedToNumber.getNumberingPlan(), NumberingPlan.ISDN); assertTrue( Arrays.equals( prim.getForwardedToSubaddress().getData(), this.getISDNSubaddressStringData())); assertTrue(prim.getForwardingOptions().getNotificationToCallingParty()); assertTrue(prim.getForwardingOptions().getNotificationToForwardingParty()); assertTrue(!prim.getForwardingOptions().getRedirectingPresentation()); assertEquals( prim.getForwardingOptions().getExtForwOptionsForwardingReason(), ExtForwOptionsForwardingReason.msBusy); assertNotNull(prim.getNoReplyConditionTime()); assertEquals(prim.getNoReplyConditionTime().intValue(), 2); FTNAddressString longForwardedToNumber = prim.getLongForwardedToNumber(); assertNotNull(longForwardedToNumber); assertTrue(longForwardedToNumber.getAddress().equals("22227")); assertEquals(longForwardedToNumber.getAddressNature(), AddressNature.international_number); assertEquals(longForwardedToNumber.getNumberingPlan(), NumberingPlan.ISDN); assertNotNull(extensionContainer); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(extensionContainer)); data = this.getData2(); asn = new AsnInputStream(data); tag = asn.readTag(); prim = new ExtForwFeatureImpl(); prim.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); extensionContainer = prim.getExtensionContainer(); assertEquals( prim.getBasicService().getExtTeleservice().getTeleserviceCodeValue(), TeleserviceCodeValue.allSpeechTransmissionServices); assertNull(prim.getBasicService().getExtBearerService()); assertNotNull(prim.getSsStatus()); assertTrue(prim.getSsStatus().getBitA()); assertTrue(prim.getSsStatus().getBitP()); assertTrue(prim.getSsStatus().getBitQ()); assertTrue(prim.getSsStatus().getBitR()); forwardedToNumber = prim.getForwardedToNumber(); assertNotNull(forwardedToNumber); assertTrue(forwardedToNumber.getAddress().equals("999888777")); assertEquals(forwardedToNumber.getAddressNature(), AddressNature.international_number); assertEquals(forwardedToNumber.getNumberingPlan(), NumberingPlan.ISDN); assertNull(prim.getForwardedToSubaddress()); assertFalse(prim.getForwardingOptions().getNotificationToCallingParty()); assertFalse(prim.getForwardingOptions().getNotificationToForwardingParty()); assertFalse(prim.getForwardingOptions().getRedirectingPresentation()); assertEquals( prim.getForwardingOptions().getExtForwOptionsForwardingReason(), ExtForwOptionsForwardingReason.msNotReachable); assertNull(prim.getNoReplyConditionTime()); longForwardedToNumber = prim.getLongForwardedToNumber(); assertNull(longForwardedToNumber); assertNull(extensionContainer); }
private void _decode(AsnInputStream ansIS, int length) throws MAPParsingComponentException, IOException, AsnException { AsnInputStream ais = ansIS.readSequenceStreamData(length); locationInformation = false; subscriberState = false; extensionContainer = null; currentLocation = false; requestedDomain = null; imei = false; msClassmark = false; mnpRequestedInfo = false; while (true) { if (ais.available() == 0) break; int tag = ais.readTag(); if (ais.getTagClass() == Tag.CLASS_CONTEXT_SPECIFIC) { switch (tag) { case _ID_locationInformation: if (!ais.isTagPrimitive()) throw new MAPParsingComponentException( "Error while decoding RequestedInfo: Parameter is not primitive", MAPParsingComponentExceptionReason.MistypedParameter); ais.readNull(); this.locationInformation = Boolean.TRUE; break; case _ID_subscriberState: if (!ais.isTagPrimitive()) throw new MAPParsingComponentException( "Error while decoding RequestedInfo: Parameter is not primitive", MAPParsingComponentExceptionReason.MistypedParameter); ais.readNull(); this.subscriberState = Boolean.TRUE; break; case _ID_extensionContainer: if (ais.isTagPrimitive()) throw new MAPParsingComponentException( "Error while decoding RequestedInfo: Parameter is primitive", MAPParsingComponentExceptionReason.MistypedParameter); extensionContainer = new MAPExtensionContainerImpl(); ((MAPExtensionContainerImpl) extensionContainer).decodeAll(ais); break; case _ID_currentLocation: if (!ais.isTagPrimitive()) throw new MAPParsingComponentException( "Error while decoding RequestedInfo: Parameter is not primitive", MAPParsingComponentExceptionReason.MistypedParameter); ais.readNull(); this.currentLocation = Boolean.TRUE; break; case _ID_requestedDomain: if (!ais.isTagPrimitive()) throw new MAPParsingComponentException( "Error while decoding RequestedInfo: Parameter is not primitive", MAPParsingComponentExceptionReason.MistypedParameter); int i1 = (int) ais.readInteger(); this.requestedDomain = DomainType.getInstance(i1); break; case _ID_msclassmark: if (!ais.isTagPrimitive()) throw new MAPParsingComponentException( "Error while decoding RequestedInfo: Parameter is not primitive", MAPParsingComponentExceptionReason.MistypedParameter); ais.readNull(); this.msClassmark = Boolean.TRUE; break; case _ID_imei: if (!ais.isTagPrimitive()) throw new MAPParsingComponentException( "Error while decoding RequestedInfo: Parameter is not primitive", MAPParsingComponentExceptionReason.MistypedParameter); ais.readNull(); this.imei = Boolean.TRUE; break; case _ID_mnpRequestedInfo: if (!ais.isTagPrimitive()) throw new MAPParsingComponentException( "Error while decoding RequestedInfo: Parameter is not primitive", MAPParsingComponentExceptionReason.MistypedParameter); ais.readNull(); this.mnpRequestedInfo = Boolean.TRUE; break; default: ais.advanceElement(); break; } } else { ais.advanceElement(); } } }
@Override protected void _decode(AsnInputStream asnIS, int length) throws MAPParsingComponentException, IOException, AsnException { this.ssCode = null; this.basicService = null; this.longFtnSupported = false; AsnInputStream ais = asnIS.readSequenceStreamData(length); int num = 0; while (true) { if (ais.available() == 0) break; int tag = ais.readTag(); switch (num) { case 0: // ssCode if (ais.getTagClass() != Tag.CLASS_UNIVERSAL || !ais.isTagPrimitive() || tag != Tag.STRING_OCTET) throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ".ssCode: Parameter 0 bad tag or tag class or not primitive", MAPParsingComponentExceptionReason.MistypedParameter); this.ssCode = new SSCodeImpl(); ((SSCodeImpl) this.ssCode).decodeAll(ais); break; default: if (ais.getTagClass() == Tag.CLASS_CONTEXT_SPECIFIC) { switch (tag) { case BasicServiceCodeImpl._TAG_bearerService: case BasicServiceCodeImpl._TAG_teleservice: if (!ais.isTagPrimitive()) throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ".basicService: Parameter is not primitive", MAPParsingComponentExceptionReason.MistypedParameter); this.basicService = new BasicServiceCodeImpl(); ((BasicServiceCodeImpl) this.basicService).decodeAll(ais); break; case _ID_longFTNSupported: if (!ais.isTagPrimitive()) throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ".longFtnSupported: Parameter is not primitive", MAPParsingComponentExceptionReason.MistypedParameter); ais.readNull(); this.longFtnSupported = true; break; default: ais.advanceElement(); break; } } else { ais.advanceElement(); } break; } num++; } if (num < 1) throw new MAPParsingComponentException( "Error while decoding " + _PrimitiveName + ": Needs at least 1 mandatory parameter, found " + num, MAPParsingComponentExceptionReason.MistypedParameter); }
@Test(groups = {"functional.decode", "primitives"}) public void testDecode() throws Exception { // Option 0 byte[] data = this.getData(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); ChargingRollOverImpl prim = new ChargingRollOverImpl(); prim.decodeAll(asn); assertEquals(tag, ChargingRollOverImpl._ID_transferredVolumeRollOver); assertEquals(asn.getTagClass(), Tag.CLASS_CONTEXT_SPECIFIC); assertTrue(prim.getIsPrimitive()); assertEquals(prim.getTransferredVolumeRollOver().getROVolumeIfNoTariffSwitch().longValue(), 25); assertNull(prim.getElapsedTimeRollOver()); // Option 1 data = this.getData1(); asn = new AsnInputStream(data); tag = asn.readTag(); prim = new ChargingRollOverImpl(); prim.decodeAll(asn); assertEquals(tag, ChargingRollOverImpl._ID_transferredVolumeRollOver); assertEquals(asn.getTagClass(), Tag.CLASS_CONTEXT_SPECIFIC); assertFalse(prim.getIsPrimitive()); assertNull(prim.getTransferredVolumeRollOver().getROVolumeIfNoTariffSwitch()); assertEquals( prim.getTransferredVolumeRollOver() .getROVolumeIfTariffSwitch() .getROVolumeSinceLastTariffSwitch() .intValue(), 12); assertEquals( prim.getTransferredVolumeRollOver() .getROVolumeIfTariffSwitch() .getROVolumeTariffSwitchInterval() .intValue(), 24); assertNull(prim.getElapsedTimeRollOver()); // Option 2 data = this.getData2(); asn = new AsnInputStream(data); tag = asn.readTag(); prim = new ChargingRollOverImpl(); prim.decodeAll(asn); assertEquals(tag, ChargingRollOverImpl._ID_elapsedTimeRollOver); assertEquals(asn.getTagClass(), Tag.CLASS_CONTEXT_SPECIFIC); assertTrue(prim.getIsPrimitive()); assertEquals(prim.getElapsedTimeRollOver().getROTimeGPRSIfNoTariffSwitch().intValue(), 24); assertNull(prim.getTransferredVolumeRollOver()); // Option 3 data = this.getData3(); asn = new AsnInputStream(data); tag = asn.readTag(); prim = new ChargingRollOverImpl(); prim.decodeAll(asn); assertEquals(tag, ChargingRollOverImpl._ID_elapsedTimeRollOver); assertEquals(asn.getTagClass(), Tag.CLASS_CONTEXT_SPECIFIC); assertFalse(prim.getIsPrimitive()); assertNull(prim.getElapsedTimeRollOver().getROTimeGPRSIfNoTariffSwitch()); assertEquals( prim.getElapsedTimeRollOver() .getROTimeGPRSIfTariffSwitch() .getROTimeGPRSSinceLastTariffSwitch() .intValue(), 12); assertEquals( prim.getElapsedTimeRollOver() .getROTimeGPRSIfTariffSwitch() .getROTimeGPRSTariffSwitchInterval() .intValue(), 24); assertNull(prim.getTransferredVolumeRollOver()); }