Skip to content

Request

Request is the caller-facing message builder for a DNS query. It logically consists of one or more Question objects plus header-level flags (Opcode, RecursionDesired), and serializes itself into an RFC1035 wire-format byte array via GetMessage().

Purpose

  • Accumulate one or more Question instances to be sent to a DNS server.
  • Serialize the accumulated questions and header flags into a wire-format byte array ready for UDP transmission.

Context

  • Namespace: SAIF.Framework.DNS
  • Assembly/package: SAIF.BOF.Framework.DNS

Public members

Member Signature Purpose
RecursionDesired public bool RecursionDesired { get; set; } Whether the "recursion desired" flag is set in the request header; defaults to true.
Opcode public Opcode Opcode { get; set; } The query opcode (RFC1035 4.1.1); defaults to Opcode.StandardQuery.
Request() public Request() Constructs a request with default flags (RecursionDesired = true, Opcode = StandardQuery) and an empty question list.
AddQuestion public void AddQuestion(Question question) Adds a Question to the request; throws ArgumentNullException if question is null.
GetMessage public byte[] GetMessage() Serializes the header and all added questions into an RFC1035 wire-format byte array.

Behavioral notes

  • The first two bytes of the serialized message (the transaction id) are left as zero; Resolver.UdpTransfer stamps them with a unique id immediately before sending*.
  • GetMessage() always writes zero counts for answer, name-server, and additional-record sections, since a request never carries those sections.
  • Domain names are encoded label-by-label (length-prefixed) without using the message-compression scheme implemented by Pointer for decoding.

Constraints and usage notes

  • Many DNS servers do not support more than one question per request; callers are advised to add only one Question per Request and to check Response.ReturnCode if they do not*.

Note: Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts.

Sources

  • SAIF.Framework.DNS\Request.cs