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); }
/// <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()); } }
public AdditionalRR(RecordReader rr) : base(rr) { }
public AuthorityRR(RecordReader rr) : base(rr) { }
public AnswerRR(RecordReader rr) : base(rr) { }
public Question(RecordReader rr) { this.QName = rr.ReadDomainName(); this.QType = (QTYPE)rr.ReadUInt16(); this.QClass = (QCLASS)rr.ReadUInt16(); }