Struct domain::bits::header::Header[][src]

pub struct Header { /* fields omitted */ }

The first part of the header of a DNS message.

This type represents the information contained in the first four bytes of the header: the message ID, opcode, rcode, and the various flags.

The header is layed out like this:

                                1  1  1  1  1  1
  0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|                      ID                       |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|QR|   Opcode  |AA|TC|RD|RA|Z |AD|CD|   RCODE   |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+

Methods are available for each of accessing each of these fields. See Field Access below.

Most of this is defined in RFC 1035, except for the AD and CD flags, which are defined in RFC 4035.

Methods

impl Header
[src]

Creates a new header.

The new header has all fields as either zero or false. Thus, the opcode will be Opcode::Query and the response code will be Rcode::NoError.

Creates a header reference from a bytes slice of a message.

Panics

This function panics if the bytes slice is too short.

Creates a mutable header reference from a bytes slice of a message.

Panics

This function panics if the bytes slice is too short.

Returns a reference to the underlying bytes slice.

impl Header
[src]

Returns the value of the ID field.

The ID field is an identifier chosen by whoever created a query and is copied into a response. It serves to match incoming responses to their request.

Sets the value of the ID field.

Sets the value of the ID field to a randomly chosen number.

Returns whether the QR bit is set.

The QR bit specifies whether this message is a query (false) or a response (true). In other words, this bit is actually stating whether the message is not a query.

Sets the value of the QR bit.

Returns the value of the Opcode field.

This field specifies the kind of query this message contains. See the Opcode type for more information on the possible values and their meaning. Normal queries have the variant Opcode::Query which is also the value set when creating a new header.

Sets the value of the opcode field.

Returns whether the AA bit is set.

Using this bit, a name server generating a response states whether it is authoritative for the requested domain name, ie., whether this response is an authoritative answer. The field has no meaning in a query.

Sets the value of the AA bit.

Returns whether the TC bit is set.

The truncation bit is set if there was more data available then fit into the message. This is typically used when employing datagram transports such as UDP to signal to try again using a stream transport such as TCP.

Sets the value of the TC bit.

Returns whether the RD bit is set.

The recursion desired bit may be set in a query to ask the name server to try and recursively gather a response if it doesn’t have the data available locally. The bit’s value is copied into the response.

Sets the value of the RD bit.

Returns whether the RA bit is set.

In a response, the recursion available bit denotes whether the responding name server supports recursion. It has no meaning in a query.

Sets the value of the RA bit.

Returns whether the reserved bit is set.

This bit must be false in all queries and responses.

Sets the value of the reserved bit.

Returns whether the AD bit is set.

The authentic data bit is used by security-aware recursive name servers to indicate that it considers all RRsets in its response to be authentic.

Sets the value of the AD bit.

Returns whether the CD bit is set.

The checking disabled bit is used by a security-aware resolver to indicate that it does not want upstream name servers to perform verification but rather would like to verify everything itself.

Sets the value of the CD bit.

Returns the value of the RCODE field.

The response code is used in a response to indicate what happened when processing the query. See the Rcode type for information on possible values and their meaning.

Sets the value of the RCODE field.

Trait Implementations

impl Clone for Header
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Debug for Header
[src]

Formats the value using the given formatter. Read more

impl Default for Header
[src]

Returns the "default value" for a type. Read more

impl PartialEq for Header
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

impl Send for Header

impl Sync for Header