Example #1
0
 public APdu(int sendSeqNum, int receiveSeqNum, ApciType apciType, ASdu aSdu)
 {
     this.sendSeqNum    = sendSeqNum;
     this.receiveSeqNum = receiveSeqNum;
     this.apciType      = apciType;
     this.aSdu          = aSdu;
 }
Example #2
0
 public APdu(int sendSeqNum, int receiveSeqNum, ApciType apciType, ASdu aSdu)
 {
     this.sendSeqNum = sendSeqNum;
     this.receiveSeqNum = receiveSeqNum;
     this.apciType = apciType;
     this.aSdu = aSdu;
 }
Example #3
0
        public APdu(BinaryReader reader, ConnectionSettings settings)
        {
            var length = reader.ReadByte() & 0xff;

            if (length < 4 || length > 253)
            {
                throw new IOException("APDU contain invalid length: " + length);
            }

            var aPduHeader = reader.ReadBytes(4);

            if ((aPduHeader[0] & 0x01) == 0)
            {
                apciType      = ApciType.I_FORMAT;
                sendSeqNum    = ((aPduHeader[0] & 0xfe) >> 1) + ((aPduHeader[1] & 0xff) << 7);
                receiveSeqNum = ((aPduHeader[2] & 0xfe) >> 1) + ((aPduHeader[3] & 0xff) << 7);

                aSdu = new ASdu(reader, settings, length - 4);
            }
            else if ((aPduHeader[0] & 0x02) == 0)
            {
                apciType      = ApciType.S_FORMAT;
                receiveSeqNum = ((aPduHeader[2] & 0xfe) >> 1) + ((aPduHeader[3] & 0xff) << 7);
            }
            else
            {
                switch (aPduHeader[0])
                {
                case 0x83:
                    apciType = ApciType.TESTFR_CON;
                    break;

                case 0x43:
                    apciType = ApciType.TESTFR_ACT;
                    break;

                case 0x23:
                    apciType = ApciType.STOPDT_CON;
                    break;

                case 0x13:
                    apciType = ApciType.STOPDT_ACT;
                    break;

                case 0x0B:
                    apciType = ApciType.STARTDT_CON;
                    break;

                default:
                    apciType = ApciType.STARTDT_ACT;
                    break;
                }
            }
        }
Example #4
0
        public APdu(BinaryReader reader, ConnectionSettings settings)
        {
            var length = reader.ReadByte() & 0xff;

            if (length < 4 || length > 253)
            {
                throw new IOException("APDU contain invalid length: " + length);
            }

            var aPduHeader = reader.ReadBytes(4);

            if ((aPduHeader[0] & 0x01) == 0)
            {
                apciType = ApciType.FORMAT;
                sendSeqNum = ((aPduHeader[0] & 0xfe) >> 1) + ((aPduHeader[1] & 0xff) << 7);
                receiveSeqNum = ((aPduHeader[2] & 0xfe) >> 1) + ((aPduHeader[3] & 0xff) << 7);

                aSdu = new ASdu(reader, settings, length - 4);
            }
            else if ((aPduHeader[0] & 0x02) == 0)
            {
                apciType = ApciType.S_FORMAT;
                receiveSeqNum = ((aPduHeader[2] & 0xfe) >> 1) + ((aPduHeader[3] & 0xff) << 7);
            }
            else
            {
                if (aPduHeader[0] == 0x83)
                {
                    apciType = ApciType.TESTFR_CON;
                }
                else if (aPduHeader[0] == 0x43)
                {
                    apciType = ApciType.TESTFR_ACT;
                }
                else if (aPduHeader[0] == 0x23)
                {
                    apciType = ApciType.STOPDT_CON;
                }
                else if (aPduHeader[0] == 0x13)
                {
                    apciType = ApciType.STOPDT_ACT;
                }
                else if (aPduHeader[0] == 0x0B)
                {
                    apciType = ApciType.STARTDT_CON;
                }
                else
                {
                    apciType = ApciType.STARTDT_ACT;
                }
            }
        }