Class Message
All communications inside of the domain protocol are carried in a single format called a message.
Inherited Members
Namespace: Makaretu.Dns
Assembly: Makaretu.Dns.dll
Syntax
public class Message : DnsObject, IWireSerialiser, ICloneable
Fields
| Improve this Doc View SourceMaxLength
Maximum bytes of a message.
Declaration
public const int MaxLength = 9000
Field Value
Type | Description |
---|---|
Int32 | 9000 bytes. |
Remarks
In reality the max length is dictated by the network MTU. For legacy IPv4 systems, 512 bytes should be used. For DNSSEC, at least 4096 bytes are needed.
9000 bytes (less IP and UPD header lengths) is specified by Multicast DNS.
MinLength
Minimum bytes of a messages
Declaration
public const int MinLength = 12
Field Value
Type | Description |
---|---|
Int32 | 12 bytes. |
Properties
| Improve this Doc View SourceAA
Authoritative Answer - this bit is valid in responses, and specifies that the responding name server is an authority for the domain name in question section.
Note that the contents of the answer section may have multiple owner names because of aliases.The AA bit corresponds to the name which matches the query name, or the first owner name in the answer section.
Declaration
public bool AA { get; set; }
Property Value
Type | Description |
---|---|
Boolean | true for an authoritative answer; otherwise, false. |
AD
Authentic data.
Declaration
public bool AD { get; set; }
Property Value
Type | Description |
---|---|
Boolean | true if the response data is authentic; otherwise, false. |
Remarks
Only used in a response and indicates that all the data included in the Answers and AuthorityRecords sections are authenticated by the server according to its DNSSEC policies.
AdditionalRecords
The list of additional records.
Declaration
public List<ResourceRecord> AdditionalRecords { get; set; }
Property Value
Type | Description |
---|---|
List<ResourceRecord> | A list of additional resource records. |
Answers
The list of answers.
Declaration
public List<ResourceRecord> Answers { get; set; }
Property Value
Type | Description |
---|---|
List<ResourceRecord> | A list of answers. |
AuthorityRecords
The list of authority records.
Declaration
public List<ResourceRecord> AuthorityRecords { get; set; }
Property Value
Type | Description |
---|---|
List<ResourceRecord> | A list of authority resource records. |
CD
Checking disabled.
Declaration
public bool CD { get; set; }
Property Value
Type | Description |
---|---|
Boolean | true if the query does not require AD; otherwise, false. |
Remarks
Only used in a query and indicates that pending (non-authenticated) data is acceptable to the resolver sending the query.
DO
Indicates that DNS Security Extensions (DNSSEC) are supported.
Declaration
public bool DO { get; set; }
Property Value
Type | Description |
---|---|
Boolean | true if DNSSEC is supported; otherwise, false. |
Remarks
The DO bit is actually in the OPTRecord, when setting the record is added to AdditionalRecords if not already present.
See Also
| Improve this Doc View SourceId
A 16 bit identifier assigned by the program that generates any kind of query. This identifier is copied the corresponding reply and can be used by the requester to match up replies to outstanding queries.
Declaration
public ushort Id { get; set; }
Property Value
Type | Description |
---|---|
UInt16 | A unique identifier. |
IsQuery
Determines if the message is query.
Declaration
public bool IsQuery { get; }
Property Value
Type | Description |
---|---|
Boolean | true for a query; otherwise, false for a response. |
IsResponse
Determines if the message is a response to a query.
Declaration
public bool IsResponse { get; }
Property Value
Type | Description |
---|---|
Boolean | false for a query; otherwise, true for a response. |
Opcode
The requested operation.
Declaration
public MessageOperation Opcode { get; set; }
Property Value
Type | Description |
---|---|
MessageOperation | One of the MessageOperation values. Both standard and extended values are supported. |
Remarks
This value is set by the originator of a query and copied into the response.
Extended opcodes (values requiring more than 4 bits) are split between the message header and the OPTRecord in the AdditionalRecords section. When setting an extended opcode, the OPTRecord will be created if it does not already exist.
See Also
| Improve this Doc View SourceQR
A one bit field that specifies whether this message is a query(0), or a response(1).
Declaration
public bool QR { get; set; }
Property Value
Type | Description |
---|---|
Boolean | false for a query; otherwise, true for a response. |
Questions
The list of question.
Declaration
public List<Question> Questions { get; }
Property Value
Type | Description |
---|---|
List<Question> | A list of questions. |
RA
Recursion Available - this be is set or cleared in a response, and denotes whether recursive query support is available in the name server.
Declaration
public bool RA { get; set; }
Property Value
Type | Description |
---|---|
Boolean | true if recursion is available; otherwise, false. |
RD
Recursion Desired - this bit may be set in a query and is copied into the response. If RD is set, it directs the name server to pursue the query recursively.
Recursive query support is optional.
Declaration
public bool RD { get; set; }
Property Value
Type | Description |
---|---|
Boolean | true if recursion is desired; otherwise, false. |
Status
Response code - this 4 bit field is set as part of responses.
Declaration
public MessageStatus Status { get; set; }
Property Value
Type | Description |
---|---|
MessageStatus | One of the MessageStatus values. |
TC
TrunCation - specifies that this message was truncated due to length greater than that permitted on the transmission channel.
Declaration
public bool TC { get; set; }
Property Value
Type | Description |
---|---|
Boolean | true for a truncated message; otherwise, false. |
See Also
| Improve this Doc View SourceZ
Reserved for future use.
Declaration
public int Z { get; set; }
Property Value
Type | Description |
---|---|
Int32 | Must be zero in all queries and responses. |
Methods
| Improve this Doc View SourceCreateResponse()
Create a response for the query message.
Declaration
public Message CreateResponse()
Returns
Type | Description |
---|---|
Message | A new response for the query message. |
Read(WireReader)
Reads the DNS object that is encoded in the wire format.
Declaration
public override IWireSerialiser Read(WireReader reader)
Parameters
Type | Name | Description |
---|---|---|
WireReader | reader | The source of the DNS object. |
Returns
Type | Description |
---|---|
IWireSerialiser | The final DNS object. |
Overrides
Remarks
Reading a ResourceRecord will return a new instance that is type specific unless the GetDataLength() is zero.
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String |
Overrides
| Improve this Doc View SourceTruncate(Int32)
Make the message not exceed the specified length.
Declaration
public void Truncate(int length)
Parameters
Type | Name | Description |
---|---|---|
Int32 | length | The maximum number bytes for the message. |
Remarks
If the message does not fit into length
bytes, then AdditionalRecords
are removed and then AuthorityRecords are removed.
If it is still too big, then the TC bit is set.
UseDnsSecurity()
Enables DNS Security Extensions (DNSSEC) for the message.
Declaration
public Message UseDnsSecurity()
Returns
Type | Description |
---|---|
Message | The Message for a fluent design. |
Remarks
Sets DO to true. Adds an OPTRecord to AdditionalRecords if not already present.
See Also
| Improve this Doc View SourceWrite(WireWriter)
Writes the DNS object encoded in the wire format.
Declaration
public override void Write(WireWriter writer)
Parameters
Type | Name | Description |
---|---|---|
WireWriter | writer | The destination of the DNS object. |