Пример #1
0
 void Parse(byte[] data)
 {
     header.Parse(data);
     question.Parse(data);
     record = new MyDnsRecord();
     record.Parse(data, question.GetBytes().Length + 12);
 }
Пример #2
0
 void Parse(byte[] data)
 {
     header.Parse(data);
     question.Parse(data);
     record = new MyDnsRecord();
     record.Parse(data, question.GetBytes().Length + 12);
 }
        public void Parse(byte[] data, int offset)
        {
            while (offset < data.Length)
            {
                int         labelLen;
                MyDnsRecord RecordItem = new MyDnsRecord();
                RecordItem.Name = MyDns.GetLabelName(data, offset, out labelLen);
                offset         += labelLen;
                //
                offset++;
                RecordItem.QType = (QueryType)data[++offset];
                //
                offset++;
                RecordItem.QClass = (QueryClass)data[++offset];
                //
                offset++;
                RecordItem.TTL = data[offset++] * 256 * 256 * 256 + data[offset++] * 256 * 256 + data[offset++] * 256 + data[offset++];
                //
                RecordItem.RDLength = data[offset++] * 256 + data[offset++];
                //
                switch (RecordItem.QType)
                {
                case QueryType.A:
                    RecordItem.RDDate = new A_RR(data, offset, RecordItem.RDLength);
                    break;

                case QueryType.CNAME:
                    RecordItem.RDDate = new CNAME_RR(data, offset, RecordItem.RDLength);
                    break;

                case QueryType.MX:
                    RecordItem.RDDate = new MX_RR(data, offset, RecordItem.RDLength);
                    break;

                case QueryType.NS:
                    RecordItem.RDDate = new NS_RR(data, offset, RecordItem.RDLength);
                    break;

                case QueryType.SOA:
                    RecordItem.RDDate = new SOA_RR(data, offset, RecordItem.RDLength);
                    break;

                case QueryType.TXT:
                    RecordItem.RDDate = new TXT_RR(data, offset, RecordItem.RDLength);
                    break;
                }
                Records.Add(RecordItem);
                offset += RecordItem.RDLength;
            }
        }
Пример #4
0
        public void Parse(byte[] data, int offset)
        {
            while (offset < data.Length)
            {
                int labelLen;
                MyDnsRecord RecordItem = new MyDnsRecord();
                RecordItem.Name = MyDns.GetLabelName(data, offset, out labelLen);
                offset += labelLen;
                //
                offset ++;
                RecordItem.QType = (QueryType)data[++offset];
                //
                offset++;
                RecordItem.QClass = (QueryClass)data[++offset];
                //
                offset++;
                RecordItem.TTL = data[offset++] * 256 * 256 * 256 + data[offset++] * 256 * 256 + data[offset++] * 256 + data[offset++];
                //
               RecordItem.RDLength = data[offset++] * 256 + data[offset++];
                //
               switch (RecordItem.QType)
               {
                   case QueryType.A:
                       RecordItem.RDDate = new A_RR(data, offset, RecordItem.RDLength);
                       break;
                   case QueryType.CNAME :
                       RecordItem.RDDate = new CNAME_RR(data, offset, RecordItem.RDLength);
                       break;
                   case QueryType.MX :
                       RecordItem.RDDate = new MX_RR(data, offset, RecordItem.RDLength);
                       break;
                   case QueryType.NS:
                       RecordItem.RDDate = new NS_RR(data, offset, RecordItem.RDLength);
                       break;
                   case QueryType.SOA:
                       RecordItem.RDDate = new SOA_RR(data, offset, RecordItem.RDLength);
                       break;
                   case QueryType.TXT:
                       RecordItem.RDDate =new TXT_RR (data, offset, RecordItem.RDLength);
                       break;
               }
               Records.Add(RecordItem);
               offset += RecordItem.RDLength;

            }
        }