Пример #1
0
 public SOA(NetBinaryReader nbr)
 {
     PrimaryNS = nbr.ReadLblOrPntString();
     AdminMB = nbr.ReadLblOrPntString();
     SerialNbr = nbr.ReadUInt32();
     RefreshInterval = nbr.ReadUInt32();
     RetryInterval = nbr.ReadUInt32();
     ExpirationLimit = nbr.ReadUInt32();
     MaxTTL = nbr.ReadUInt32();
 }
Пример #2
0
        public TcpHeader(byte[] byIpData, int start)
        {
            NetBinaryReader nbr = new NetBinaryReader(byIpData, start);

            SourcePort = nbr.ReadUInt16();
            DestinationPort = nbr.ReadUInt16();

            SequenceNumber = nbr.ReadUInt32();
            AcknowledgmentNumber = nbr.ReadUInt32();

            DataOffset = nbr.ReadNible();
            nbr.SkipPadBits();

            nbr.ReadCustomAmount(2);
            URG = nbr.ReadBit();
            ACK = nbr.ReadBit();
            PSH = nbr.ReadBit();
            RST = nbr.ReadBit();
            SYN = nbr.ReadBit();
            FIN = nbr.ReadBit();

            Window = nbr.ReadUInt16();
            Checksum = nbr.ReadUInt16();
            UrgentPointer = nbr.ReadUInt16();

            //TODO: test
            byte option;
            long optionsStart = nbr.BaseStream.Position;
            Options = new byte[0][];

            while ((option = nbr.ReadByte()) != 0 || nbr.BaseStream.Position > start + DataOffset)    // 0 = End list
            {
                if (option == 1) continue;  // 1 = No Option
                if (option == 2)            // Max Segm size
                {
                    byte length = nbr.ReadByte();

                    byte[] cur = new byte[length];
                    for (byte i = 0; i < length; i++)
                    {
                        cur[i] = nbr.ReadByte();
                    }

                    Array.Resize(ref Options, Options.Length + 1);
                    Options[Options.Length - 1] = cur;
                }
            }

            long dataLength = DataOffset - optionsStart;
            Data = new byte[dataLength];
            for (int i = 0; i < dataLength; i++)
            {
                Data[i] = nbr.ReadByte();
            }
        }
Пример #3
0
        public DnsAnswer(NetBinaryReader nbr)
        {
            Name = nbr.ReadLblOrPntString();
            Type = (QType)nbr.ReadUInt16();

            ushort rawClass = nbr.ReadUInt16();
            if (rawClass > 65279) rawClass = 0;
            else if (rawClass > 4 && rawClass < 252) rawClass = 2;
            else if (rawClass > 255 && rawClass < 65280) rawClass = 2;
            Class = (DnsClass)rawClass;

            TTL = nbr.ReadUInt32();
            ByteCount = nbr.ReadUInt16();
            HandleRData(nbr);
        }