public Query5250Response(InputByteArray InputArray)
        {
            InputByteArray buf = null;

            if (InputArray.RemainingLength < 58)
            {
                this.Errmsg = "Insufficient bytes in byte stream for 5250 query response.";
            }

            if (this.Errmsg == null)
            {
                this.Length = InputArray.PeekBigEndianShort(0);
                if (InputArray.RemainingLength < this.Length)
                {
                    this.Errmsg = "response length exceeds byte stream.";
                }
            }

            if (this.Errmsg == null)
            {
                this.RawBytes = InputArray.PeekBytes(this.Length);
                buf           = new InputByteArray(this.RawBytes);
                buf.AdvanceIndex(2); // the length
                this.cField = buf.GetByte();
                var tField = buf.GetByte();
                this.RequestCode  = tField.ToRequestCode();
                this.ResponseByte = buf.GetByte(); // 0x80 fixed code

                if ((cField != 0xd9) || (this.RequestCode == null) ||
                    (this.ResponseByte != 0x80))
                {
                    this.Errmsg = "invalid c Field, t Field or response byte in 5250 "
                                  + "query response.";
                }
            }

            // isolate other 5250 query response fields.
            if (this.Errmsg == null)
            {
                this.ControlUnitCode = buf.GetBytes(2);
                this.CodeLevel       = buf.GetBytes(3);
                this.Reserve1        = buf.GetBytes(16);

                this.WorkstationByte = buf.GetByte();
                this.MachineType     = buf.GetEbcdicBytes(7);
                this.KeyboardId      = buf.GetByte();
                buf.AdvanceIndex(2);
                this.SerialNumber   = buf.GetBytes(4);
                this.MaxInputFields = buf.GetBigEndianShort();
                this.Reserve2       = buf.GetBytes(3);
                this.Capabilities   = buf.GetBytes(5);
            }

            // is a valid query 5250 response byte stream. Advance index of input bytes.
            if (this.Errmsg == null)
            {
                InputArray.AdvanceIndex(this.Length);
            }
        }
        private void ProcessAndPostBytesReceived(byte[] recvBytes)
        {
            // load bytes received from the server into InputArray.
            var inputArray = new InputByteArray(recvBytes);

            WorkstationCommandList wipCmdList = null;
            bool badDataLogged = false;

            while (inputArray.IsEof() == false)
            {
                var rv = ParseAndPostInputArray(inputArray, wipCmdList);
                wipCmdList = rv.Item1;
                var gotSomething = rv.Item2;

                // nothing parsed. And there is data remaining. This is an error.
                if ((gotSomething == false) && (inputArray.IsEof() == false))
                {
                    if (badDataLogged == false)
                    {
                        LogBadData(inputArray);
                        badDataLogged = true;
                    }
                    inputArray.GetByte(); // advance by 1 byte in byte stream.
                }
            }
        }
Beispiel #3
0
        public ClearUnitAlternateCommand(InputByteArray InputArray)
            : base(InputArray, WorkstationCode.ClearUnitAlternate)
        {
            if (InputArray.RemainingLength < 3)
            {
                this.Errmsg = "too few bytes in input stream";
            }

            if (this.Errmsg == null)
            {
                InputArray.AdvanceIndex(2);

                this.RequestByte = InputArray.GetByte();
            }
        }
 public TelnetCommand(InputByteArray InputArray, CommandCode CmdCode, TelnetSubject Subject)
     : this(InputArray, CmdCode)
 {
     this.Subject = Subject;
     this.RawBytes.Append(InputArray.GetByte());
 }