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]
pub fn new() -> 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
.
pub fn from_message(s: &[u8]) -> &Header
[src]
Creates a header reference from a bytes slice of a message.
Panics
This function panics if the bytes slice is too short.
pub fn from_message_mut(s: &mut [u8]) -> &mut Header
[src]
Creates a mutable header reference from a bytes slice of a message.
Panics
This function panics if the bytes slice is too short.
pub fn as_bytes(&self) -> &[u8]
[src]
Returns a reference to the underlying bytes slice.
impl Header
[src]
pub fn id(&self) -> u16
[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.
pub fn set_id(&mut self, value: u16)
[src]
Sets the value of the ID field.
pub fn set_random_id(&mut self)
[src]
Sets the value of the ID field to a randomly chosen number.
pub fn qr(&self) -> bool
[src]
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.
pub fn set_qr(&mut self, set: bool)
[src]
Sets the value of the QR bit.
pub fn opcode(&self) -> Opcode
[src]
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.
pub fn set_opcode(&mut self, opcode: Opcode)
[src]
Sets the value of the opcode field.
pub fn aa(&self) -> bool
[src]
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.
pub fn set_aa(&mut self, set: bool)
[src]
Sets the value of the AA bit.
pub fn tc(&self) -> bool
[src]
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.
pub fn set_tc(&mut self, set: bool)
[src]
Sets the value of the TC bit.
pub fn rd(&self) -> bool
[src]
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.
pub fn set_rd(&mut self, set: bool)
[src]
Sets the value of the RD bit.
pub fn ra(&self) -> bool
[src]
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.
pub fn set_ra(&mut self, set: bool)
[src]
Sets the value of the RA bit.
pub fn z(&self) -> bool
[src]
Returns whether the reserved bit is set.
This bit must be false
in all queries and responses.
pub fn set_z(&mut self, set: bool)
[src]
Sets the value of the reserved bit.
pub fn ad(&self) -> bool
[src]
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.
pub fn set_ad(&mut self, set: bool)
[src]
Sets the value of the AD bit.
pub fn cd(&self) -> bool
[src]
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.
pub fn set_cd(&mut self, set: bool)
[src]
Sets the value of the CD bit.
pub fn rcode(&self) -> Rcode
[src]
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.
pub fn set_rcode(&mut self, rcode: Rcode)
[src]
Sets the value of the RCODE field.
Trait Implementations
impl Clone for Header
[src]
fn clone(&self) -> Header
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for Header
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more