Struct simple_dns::PacketHeader
source · [−]pub struct PacketHeader {Show 14 fields
pub id: u16,
pub query: bool,
pub opcode: OPCODE,
pub authoritative_answer: bool,
pub truncated: bool,
pub recursion_desired: bool,
pub recursion_available: bool,
pub response_code: RCODE,
pub questions_count: u16,
pub answers_count: u16,
pub name_servers_count: u16,
pub additional_records_count: u16,
pub authentic_data: bool,
pub checking_disabled: bool,
}
Expand description
Contains general information about the packet
Fields
id: u16
The identification of the packet, must be defined when querying
query: bool
Indicates if this packet is a query or a response.
opcode: OPCODE
Indicates the type of query in this packet
Authoritative Answer - this bit is valid in responses,
and specifies that the responding name server is an authority for the domain name in question section.
truncated: bool
TrunCation - specifies that this message was truncated due to
length greater than that permitted on the transmission channel.
recursion_desired: bool
Recursion Desired may be set in a query andis copied into the response.
If RD is set, it directs the name server to pursue the query recursively.
Recursive query support is optional.
recursion_available: bool
Recursion Available is set or cleared in a response.
It denotes whether recursive query support is available in the name server.
response_code: RCODE
RCODE indicates the response code for this packet
questions_count: u16
Indicate the number of questions in the packet
answers_count: u16
Indicate the number of answers in the packet
name_servers_count: u16
Indicate the number of name servers resource records in the packet
additional_records_count: u16
Indicate the number of additional records in the packet
authentic_data: bool
checking_disabled: bool
Implementations
sourceimpl PacketHeader
impl PacketHeader
sourcepub fn new_query(id: u16, recursion_desired: bool) -> Self
pub fn new_query(id: u16, recursion_desired: bool) -> Self
Creates a new header for a query packet
sourcepub fn write_questions(buffer: &mut [u8], question_count: u16)
pub fn write_questions(buffer: &mut [u8], question_count: u16)
Writes the questions count in the header buffer
sourcepub fn write_answers(buffer: &mut [u8], answers_count: u16)
pub fn write_answers(buffer: &mut [u8], answers_count: u16)
Writes the answers count in the header buffer
sourcepub fn read_name_servers(buffer: &[u8]) -> u16
pub fn read_name_servers(buffer: &[u8]) -> u16
Returns the name servers count from the header buffer
sourcepub fn write_name_servers(buffer: &mut [u8], name_servers_count: u16)
pub fn write_name_servers(buffer: &mut [u8], name_servers_count: u16)
Writes the name servers count in the header buffer
Trait Implementations
sourceimpl Clone for PacketHeader
impl Clone for PacketHeader
sourcefn clone(&self) -> PacketHeader
fn clone(&self) -> PacketHeader
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl RefUnwindSafe for PacketHeader
impl Send for PacketHeader
impl Sync for PacketHeader
impl Unpin for PacketHeader
impl UnwindSafe for PacketHeader
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more