Beispiel #1
0
 internal static AAssociateRJ Parse(UnparsedPdu raw)
 {
     if (raw.length() != 4)
     {
         throw new PduException("Illegal A-ASSOCIATE-RJ " + raw, new AAbort(AAbort.SERVICE_PROVIDER, AAbort.INVALID_PDU_PARAMETER_VALUE));
     }
     return new AAssociateRJ(raw.buffer());
 }
        protected virtual AAssociateRQAC Init(UnparsedPdu raw)
        {
            if (raw.buffer() == null)
            {
                throw new PduException("Pdu length exceeds supported maximum " + raw, new AAbort(AAbort.SERVICE_PROVIDER, AAbort.REASON_NOT_SPECIFIED));
            }
            ByteBuffer bb = ByteBuffer.Wrap( raw.buffer(), 6, raw.length(), ByteOrder.BIG_ENDIAN );
            try
            {
                version = bb.ReadInt16();		// Protocol version
                bb.Skip(2);						// Skip 2 bytes
                calledAET = bb.ReadString(16);	// Called AET
                callingAET = bb.ReadString(16);	// Calling AET
                if( bb.Skip(32) != 32)
                {
                    throw new EndOfStreamException();
                }

                while( bb.Position < bb.Length )
                {
                    int itemType = bb.ReadByte();	// Item type
                    bb.Skip();						// Skip one byte
                    int itemLen = bb.ReadInt16();	// Item length

                    switch (itemType)
                    {
                        case 0x10:
                            appCtxUID = bb.ReadString(itemLen);
                            break;

                        case 0x20:
                        case 0x21:
                            if (itemType != pctype())
                            {
                                throw new PduException("unexpected item type " + System.Convert.ToString(itemType, 16) + 'H', new AAbort(AAbort.SERVICE_PROVIDER, AAbort.UNEXPECTED_PDU_PARAMETER));
                            }
                            AddPresContext(new PresContext(itemType, bb, itemLen));
                            break;

                        case 0x50:
                            ReadUserInfo(bb, itemLen);
                            break;

                        default:
                            throw new PduException("unrecognized item type " + System.Convert.ToString(itemType, 16) + 'H', new AAbort(AAbort.SERVICE_PROVIDER, AAbort.UNRECOGNIZED_PDU_PARAMETER));
                    }
                }
            }
            catch (PduException e)
            {
                throw e;
            }
            catch (System.Exception e)
            {
                throw new PduException("Failed to parse " + raw, e, new AAbort(AAbort.SERVICE_PROVIDER, AAbort.REASON_NOT_SPECIFIED));
            }
            return this;
        }
Beispiel #3
0
 public static PDataTF Parse(UnparsedPdu raw)
 {
     if (raw.buffer() == null)
     {
         throw new PduException("Pdu length exceeds supported maximum " + raw, new AAbort(AAbort.SERVICE_PROVIDER, AAbort.REASON_NOT_SPECIFIED));
     }
     return new PDataTF(raw.length(), raw.buffer());
 }
Beispiel #4
0
 internal static AAbort Parse(UnparsedPdu raw)
 {
     if (raw.length() != 4)
     {
         throw new PduException("Illegal A-ABORT " + raw, new AAbort(SERVICE_PROVIDER, INVALID_PDU_PARAMETER_VALUE));
     }
     return new AAbort(raw.buffer());
 }