Пример #1
0
 public RR(RecordReader rr)
 {
     this.NAME     = rr.ReadDomainName();
     this.TYPE     = (TYPE)rr.ReadUInt16();
     this.CLASS    = (CLASS)rr.ReadUInt16();
     this.TTL      = rr.ReadUInt32();
     this.RDLENGTH = rr.ReadUInt16();
     //begin to read a RDATA
     this.RECORD = rr.ReadRecord(TYPE, RDLENGTH);
 }
Пример #2
0
        /// <summary>
        /// Read a Domain name.
        /// </summary>
        /// <returns></returns>
        public string ReadDomainName()
        {
            var name   = new StringBuilder();
            int length = 0;

            // get  the length of the first label
            while ((length = this.ReadByte()) != 0)
            {
                // top 2 bits set denotes domain name compression and to reference elsewhere
                //0xc0 -> Name is a pointer.
                if ((length & 0xc0) == 0xc0)
                {
                    // work out the existing domain name, copy this pointer
                    var newRecordReader = new RecordReader(_buffer, (length & 0x3f) << 8 | this.ReadByte());

                    name.Append(newRecordReader.ReadDomainName());
                    return(name.ToString());
                }

                // if not using compression, copy a char at a time to the domain name
                while (length > 0)
                {
                    name.Append(this.ReadChar());
                    length--;
                }
                name.Append('.');
            }
            if (name.Length == 0)
            {
                return(".");
            }
            else
            {
                return(name.ToString());
            }
        }
Пример #3
0
 public AdditionalRR(RecordReader rr) : base(rr)
 {
 }
Пример #4
0
 public AuthorityRR(RecordReader rr) : base(rr)
 {
 }
Пример #5
0
 public AnswerRR(RecordReader rr) : base(rr)
 {
 }
Пример #6
0
 public Question(RecordReader rr)
 {
     this.QName  = rr.ReadDomainName();
     this.QType  = (QTYPE)rr.ReadUInt16();
     this.QClass = (QCLASS)rr.ReadUInt16();
 }