2using System.Collections.Generic;
14 private readonly
byte[] binary;
15 private readonly ushort id;
16 private readonly
bool response;
17 private readonly
OpCode opCode;
18 private readonly
bool authoritativeAnswer;
19 private readonly
bool truncation;
20 private readonly
bool recursionDesired;
21 private readonly
bool recursionAvailable;
22 private readonly
RCode rCode;
23 private readonly
Question[] questions;
36 using (MemoryStream ms =
new MemoryStream(Data))
40 byte b = (byte)ms.ReadByte();
41 this.response = (b & 0x80) != 0;
42 this.opCode = (
OpCode)((b >> 3) & 15);
43 this.authoritativeAnswer = (b & 4) != 0;
44 this.truncation = (b & 2) != 0;
45 this.recursionDesired = (b & 1) != 0;
47 b = (byte)ms.ReadByte();
48 this.recursionAvailable = (b & 128) != 0;
49 this.rCode = (
RCode)(b & 31);
51 ushort QDCOUNT =
DnsClient.ReadUInt16(ms);
52 ushort ANCOUNT =
DnsClient.ReadUInt16(ms);
53 ushort NSCOUNT =
DnsClient.ReadUInt16(ms);
54 ushort ARCOUNT =
DnsClient.ReadUInt16(ms);
56 this.questions =
new Question[QDCOUNT];
59 for (i = 0; i < QDCOUNT; i++)
68 this.answer =
DnsClient.ReadResourceRecords(ms, ANCOUNT);
69 this.authority =
DnsClient.ReadResourceRecords(ms, NSCOUNT);
70 this.additional =
DnsClient.ReadResourceRecords(ms, ARCOUNT);
82 public ushort
ID => this.id;
Abstract base class for DNS clients.
ResourceRecord[] Additional
Additional section
bool RecursionAvailable
Denotes whether recursive query support is available in the name server
byte[] Binary
Binary response.
bool Response
If a Response (true) or a query (false)
ResourceRecord[] Answer
Answer section
DnsMessage(byte[] Data)
Represents a DNS message
bool RecursionDesired
Directs the name server to pursue the query recursively
ushort ID
Message identifier
OpCode OpCode
Operation code
ResourceRecord[] Authority
Authority section
Question[] Questions
Question section
bool Truncation
Message was truncated due to length greater than that permitted on the transmission channel
bool AuthoritativeAnswer
Responding name server is an authority for the domain name in question section
Contains information about a DNS Question
Abstract base class for a resource record.
OpCode
DNS Operation Codes
QTYPE
QTYPE fields appear in the question part of a query.
QCLASS
QCLASS fields appear in the question section of a query.