internal override IPdu Parse(UnparsedPdu raw) { try { switch (raw.GetType()) { case 1: case 2: case 3: throw new PduException("Unexpected " + raw, new AAbort(AAbort.SERVICE_PROVIDER, AAbort.UNEXPECTED_PDU)); case 4: return m_fsm.FireReceived(PDataTF.Parse(raw)); case 5: IPdu pdu = m_fsm.FireReceived(AReleaseRQ.Parse(raw)); m_fsm.ChangeState(m_fsm.requestor ? m_fsm.STA9 : m_fsm.STA10); return pdu; case 6: m_fsm.FireReceived(pdu = AReleaseRP.Parse(raw)); m_fsm.ChangeState(m_fsm.STA1); return pdu; case 7: m_fsm.FireReceived(m_fsm.aa = AAbort.Parse(raw)); m_fsm.ChangeState(m_fsm.STA1); return m_fsm.aa; default: throw new PduException("Unrecognized " + raw, new AAbort(AAbort.SERVICE_PROVIDER, AAbort.UNRECOGNIZED_PDU)); } } catch (PduException ule) { try { Write(ule.AAbort); } catch (Exception) {} throw ule; } }
internal override IPdu Parse(UnparsedPdu raw) { try { switch (raw.GetType()) { case 1: m_fsm.FireReceived(m_fsm.rq = AAssociateRQ.Parse(raw)); m_fsm.ChangeState(m_fsm.STA3); return m_fsm.rq; case 2: case 3: case 4: case 5: case 6: throw new PduException("Unexpected " + raw, new AAbort(AAbort.SERVICE_PROVIDER, AAbort.UNEXPECTED_PDU)); case 7: m_fsm.FireReceived(m_fsm.aa = AAbort.Parse(raw)); m_fsm.ChangeState(m_fsm.STA1); return m_fsm.aa; default: throw new PduException("Unrecognized " + raw, new AAbort(AAbort.SERVICE_PROVIDER, AAbort.UNRECOGNIZED_PDU)); } } catch (PduException ule) { try { Write(ule.AAbort); } catch (Exception) {} throw ule; } }
public virtual IPdu ReadFrom(Stream ins, byte[] buf) { var raw = new UnparsedPdu(ins, buf); switch (raw.GetType()) { case 1: return AAssociateRQ.Parse(raw); case 2: return AAssociateAC.Parse(raw); case 3: return AAssociateRJ.Parse(raw); case 4: return PDataTF.Parse(raw); case 5: return AReleaseRQ.Parse(raw); case 6: return AReleaseRP.Parse(raw); case 7: return AAbort.Parse(raw); default: throw new PduException("Unrecognized " + raw, new AAbort(AAbort.SERVICE_PROVIDER, AAbort.UNRECOGNIZED_PDU)); } }