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
answers
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
id
Returns the packet id from the header buffer
name_servers
Returns the name servers count from the header buffer
opcode
Get the OPCODE from the buffer
questions
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