|
|
|
|
@ -1460,21 +1460,38 @@ mod tests {
|
|
|
|
|
0x00, 0x1c, 0x10, 0x32, 0x01, 0x00, 0x00, 0x01,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
|
|
|
|
];
|
|
|
|
|
/* complete payload */
|
|
|
|
|
/* complete payload plus the start of a new payload */
|
|
|
|
|
let buf2: &[u8] = &[
|
|
|
|
|
0x00, 0x1c, 0x10, 0x32, 0x01, 0x00, 0x00, 0x01,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0x06, 0x67, 0x6F, 0x6F, 0x67, 0x6C, 0x65, 0x03,
|
|
|
|
|
0x63, 0x6F, 0x6D, 0x00, 0x00, 0x10, 0x00, 0x01
|
|
|
|
|
0x63, 0x6F, 0x6D, 0x00, 0x00, 0x10, 0x00, 0x01,
|
|
|
|
|
|
|
|
|
|
// next.
|
|
|
|
|
0x00, 0x1c, 0x10, 0x32, 0x01, 0x00, 0x00, 0x01,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
/* and the complete payload again with no trailing data. */
|
|
|
|
|
let buf3: &[u8] = &[
|
|
|
|
|
0x00, 0x1c, 0x10, 0x32, 0x01, 0x00, 0x00, 0x01,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0x06, 0x67, 0x6F, 0x6F, 0x67, 0x6C, 0x65, 0x03,
|
|
|
|
|
0x63, 0x6F, 0x6D, 0x00, 0x00, 0x10, 0x00, 0x01,
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
let mut state = DNSState::new();
|
|
|
|
|
assert_eq!(
|
|
|
|
|
AppLayerResult::incomplete(0, 30),
|
|
|
|
|
state.parse_request_tcp(buf1)
|
|
|
|
|
);
|
|
|
|
|
assert_eq!(
|
|
|
|
|
AppLayerResult::ok(),
|
|
|
|
|
AppLayerResult::incomplete(30, 30),
|
|
|
|
|
state.parse_request_tcp(buf2)
|
|
|
|
|
);
|
|
|
|
|
assert_eq!(
|
|
|
|
|
AppLayerResult::ok(),
|
|
|
|
|
state.parse_request_tcp(buf3)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|