Skip to main content

Module header_buffer

Module header_buffer 

Source
Expand description

Helper functions to assert a buffer for the header flags of a DNS Packet. Useful for checking the header without parsing the whole packet. WARNING: Flags and RCODE information may be incomplete if the packet contains EDNS (OPT) or DNSSEC Resource Records

use simple_dns::{header_buffer, PacketFlag};

let buffer = b"\xff\xff\x03\x00\x00\x02\x00\x02\x00\x02\x00\x02";
assert_eq!(u16::MAX, header_buffer::id(&buffer[..]).unwrap());
assert!(!header_buffer::has_flags(&buffer[..], PacketFlag::RESPONSE).unwrap());

Functionsยง

additional_records
Returns the additional records from the header buffer
additional_records_unchecked
Returns the additional records from the header buffer
answers
Returns the answers count from the header buffer
answers_unchecked
Returns the answers count from the header buffer
has_flags
Verify if buffer has the flags set. WARNING: This information may be wrong if there is an OPT record in packet
has_flags_unchecked
Verify if buffer has the flags set. WARNING: This information may be wrong if there is an OPT record in packet
id
Returns the packet id from the header buffer
id_unchecked
Returns the packet id from the header buffer
name_servers
Returns the name servers count from the header buffer
name_servers_unchecked
Returns the name servers count from the header buffer
opcode
Get the OPCODE from the buffer
opcode_unchecked
Get the OPCODE from the buffer
questions
Returns the questions count from the header buffer
questions_unchecked
Returns the questions count from the header buffer
rcode
Get the RCODE from the buffer. WARNING: This information may be wrong if there is an OPT record in packet
rcode_unchecked
Get the RCODE from the buffer. WARNING: This information may be wrong if there is an OPT record in packet