(tests) Implement tests for DNS header parsing
* implemented 3 tests * valid opcodes * invalid opcodes * header too short * fixed byteorder and bit shifting for flags * added hexdump for main function for testing purposes
This commit is contained in:
@ -32,10 +32,18 @@ fn listen() -> (
|
||||
)
|
||||
}
|
||||
|
||||
fn print_hex(bytes: &[u8]) {
|
||||
let stdout = std::io::stdout();
|
||||
let mut stdout = stdout.lock();
|
||||
let mut hxp = hexyl::Printer::new(&mut stdout, true, hexyl::BorderStyle::None, false);
|
||||
let _ = hxp.print_all(bytes);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let (thread_udp, _thread_udp_tx, thread_udp_rx) = listen();
|
||||
|
||||
for msg in thread_udp_rx.iter() {
|
||||
print_hex(&msg);
|
||||
let hdr_struct = DNSHeader::from_udp_datagram(&msg).unwrap();
|
||||
dbg!(hdr_struct);
|
||||
}
|
||||
|
Reference in New Issue
Block a user