public void decode(AsnInputStream aisA) throws ParseException { // TAG has been decoded already, now, lets get LEN try { AsnInputStream ais = aisA.readSequenceStream(); int tag = ais.readTag(); if (tag != Tag.EXTERNAL) throw new ParseException( PAbortCauseType.IncorrectTxPortion, null, "Error decoding DialogPortion: wrong value of tag, expected EXTERNAL, found: " + tag); ext.decode(ais); if (!isAsn() || !isOid()) { throw new ParseException( PAbortCauseType.IncorrectTxPortion, null, "Error decoding DialogPortion: Oid and Asd parts not found"); } // Check Oid if (Arrays.equals(_DIALG_UNI, this.getOidValue())) this.uniDirectional = true; else if (Arrays.equals(_DIALG_STRUCTURED, this.getOidValue())) this.uniDirectional = false; else throw new ParseException( PAbortCauseType.IncorrectTxPortion, null, "Error decoding DialogPortion: bad Oid value"); AsnInputStream loaclAsnIS = new AsnInputStream(ext.getEncodeType()); // now lets get APDU tag = loaclAsnIS.readTag(); this.dialogAPDU = TcapFactory.createDialogAPDU(loaclAsnIS, tag, isUnidirectional()); } catch (IOException e) { throw new ParseException( PAbortCauseType.BadlyFormattedTxPortion, null, "IOException when decoding DialogPortion: " + e.getMessage(), e); } catch (AsnException e) { throw new ParseException( PAbortCauseType.BadlyFormattedTxPortion, null, "AsnException when decoding DialogPortion: " + e.getMessage(), e); } }
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); }
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(); } } }
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; } } }