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