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]
fn new() -> Header
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
.
fn from_message(s: &[u8]) -> &Header
Creates a header reference from a bytes slice of a message.
Panics
This function panics if the bytes slice is too short.
fn from_message_mut(s: &mut [u8]) -> &mut Header
Creates a mutable header reference from a bytes slice of a message.
Panics
This function panics if the bytes slice is too short.
fn as_bytes(&self) -> &[u8]
Returns a reference to the underlying bytes slice.
impl Header
[src]
fn id(&self) -> u16
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.
fn set_id(&mut self, value: u16)
Sets the value of the ID field.
fn set_random_id(&mut self)
Sets the value of the ID field to a randomly chosen number.
fn qr(&self) -> bool
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.
fn set_qr(&mut self, set: bool)
Sets the value of the QR bit.
fn opcode(&self) -> Opcode
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.
fn set_opcode(&mut self, opcode: Opcode)
Sets the value of the opcode field.
fn aa(&self) -> bool
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.
fn set_aa(&mut self, set: bool)
Sets the value of the AA bit.
fn tc(&self) -> bool
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.
fn set_tc(&mut self, set: bool)
Sets the value of the TC bit.
fn rd(&self) -> bool
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.
fn set_rd(&mut self, set: bool)
Sets the value of the RD bit.
fn ra(&self) -> bool
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.
fn set_ra(&mut self, set: bool)
Sets the value of the RA bit.
fn z(&self) -> bool
Returns whether the reserved bit is set.
This bit must be false
in all queries and responses.
fn set_z(&mut self, set: bool)
Sets the value of the reserved bit.
fn ad(&self) -> bool
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.
fn set_ad(&mut self, set: bool)
Sets the value of the AD bit.
fn cd(&self) -> bool
Returns whether the CD bit is set.
The checking disabled bit is used by security-aware resolvers to indicate that it does not want upstream name servers to perform verification but rather would like to verify everything itself.
fn set_cd(&mut self, set: bool)
Sets the value of the CD bit.
fn rcode(&self) -> Rcode
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.
fn set_rcode(&mut self, rcode: Rcode)
Sets the value of the RCODE field.
Trait Implementations
impl Clone for Header
[src]
fn clone(&self) -> Header
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more