dns: add tailing data to split tcp unit test

Add trailing data to the complete payload to test the case
where data is consumed, but still incomplete.
pull/5266/head
Jason Ish 6 years ago
parent cc154ce152
commit 6cff558663

@ -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)
);
}
}

Loading…
Cancel
Save