DNS.Message (DNS v0.4.1)

View Source

DNS Message

All communications inside of the domain protocol are carried in a single format called a message. The top level format of message is divided into 5 sections (some of which are empty in certain cases) shown below:

+---------------------+
|        Header       |
+---------------------+
|       Question      | the question for the name server
+---------------------+
|        Answer       | RRs answering the question
+---------------------+
|      Authority      | RRs pointing toward an authority
+---------------------+
|      Additional     | RRs holding additional information
+---------------------+

The header section is always present. The header includes fields that specify which of the remaining sections are present, and also specify whether the message is a query or a response, a standard query or some other opcode, etc.

The names of the sections after the header are derived from their use in standard queries. The question section contains fields that describe a question to a name server. These fields are a query type (QTYPE), a query class (QCLASS), and a query domain name (QNAME). The last three sections have the same format: a possibly empty list of concatenated resource records (RRs). The answer section contains RRs that answer the question; the authority section contains RRs that point toward an authoritative name server; the additional records section contains RRs which relate to the query, but are not strictly answers for the question.

Summary

Types

t()

@type t() :: %DNS.Message{
  anlist: [
    %DNS.Message.Record{
      class: term(),
      data: term(),
      name: term(),
      rdlength: term(),
      ttl: term(),
      type: term()
    }
  ],
  arlist: [
    %DNS.Message.Record{
      class: term(),
      data: term(),
      name: term(),
      rdlength: term(),
      ttl: term(),
      type: term()
    }
  ],
  header: %DNS.Message.Header{
    aa: term(),
    ad: term(),
    ancount: term(),
    arcount: term(),
    cd: term(),
    id: term(),
    nscount: term(),
    opcode: term(),
    qdcount: term(),
    qr: term(),
    ra: term(),
    rcode: term(),
    rd: term(),
    tc: term(),
    z: term()
  },
  nslist: [
    %DNS.Message.Record{
      class: term(),
      data: term(),
      name: term(),
      rdlength: term(),
      ttl: term(),
      type: term()
    }
  ],
  options: Keyword.t(),
  qdlist: [%DNS.Message.Question{class: term(), name: term(), type: term()}]
}

Functions

add_question(message, question)

from_iodata(message)

get_option(message, key, default_value \\ nil)

new()

put_option(message, key, value)

update_header_attr(message, key, value)