private void ReadDNSResponseNAPTR(DnsResponseNAPTR response) { response.Order = this._reader.ReadUInt16(); response.Preference = this._reader.ReadUInt16(); var countFlags = this._reader.ReadByte(); response.Flags = this._reader.ReadChars(countFlags); countFlags = this._reader.ReadByte(); response.Services = string.Concat(this._reader.ReadChars(countFlags)); countFlags = this._reader.ReadByte(); response.Regexp = string.Concat(this._reader.ReadChars(countFlags)); response.Replacement = ToStringDomainName(this.ReadDomainName()); }
private void ReadResponse(ushort countMessages, DNSResponseType responseType) { for (ushort i = 0; i < countMessages; i++) { var name = this.ReadDomainName(); Int32 tmpNumber = this._reader.ReadUInt16(); var qType = Enum.IsDefined(typeof(DNSBase.DNSQType), tmpNumber) ? (DNSBase.DNSQType)tmpNumber : DNSBase.DNSQType.UNASSIGNED; DnsResponse response; switch (qType) { case DNSBase.DNSQType.A: case DNSBase.DNSQType.AAAA: response = new DnsResponseA(); break; case DNSBase.DNSQType.CNAME: case DNSBase.DNSQType.NS: case DNSBase.DNSQType.PTR: case DNSBase.DNSQType.TXT: response = new DnsResponseName(); break; case DNSBase.DNSQType.MX: response = new DnsResponseMX(); break; case DNSBase.DNSQType.SOA: response = new DnsResponseSOA(); break; case DNSBase.DNSQType.SRV: response = new DnsResponseSRV(); break; case DNSBase.DNSQType.NAPTR: response = new DnsResponseNAPTR(); break; default: response = new DnsResponseOther(); break; } response.QType = qType; tmpNumber = this._reader.ReadUInt16(); response.QClass = Enum.IsDefined(typeof(DNSBase.DNSQClass), tmpNumber) ? (DNSBase.DNSQClass)tmpNumber : DNSBase.DNSQClass.UNASSIGNED; response.TTL = this._reader.ReadUInt32(); this.ReadResponseRData(response, name); switch (responseType) { case DNSResponseType.ANSWER: this.Answer.Add(response); break; case DNSResponseType.AUTHORITY: this.Authority.Add(response); break; case DNSResponseType.ADDITIONAL: this.Additional.Add(response); break; } } }