pub fn peek_long_header_dcid(packet: &[u8]) -> Option<&[u8]>Expand description
Extract the Destination Connection ID from a QUIC Long Header packet without performing a full parse.
Returns None when the buffer is too short or the CID length field is
zero or exceeds 20.
Examples found in repository?
examples/parse_header.rs (line 28)
8fn main() {
9 // A minimal QUIC v1 Initial packet (truncated payload).
10 // In practice this would come from a UDP socket.
11 let packet: Vec<u8> = build_sample_initial();
12
13 match quic_parser::parse_initial(&packet) {
14 Ok(header) => {
15 println!("QUIC Initial packet parsed successfully");
16 println!(" version: {:#010x}", header.version);
17 println!(" dcid: {}", hex(header.dcid));
18 println!(" scid: {}", hex(header.scid));
19 println!(" token length: {}", header.token.len());
20 println!(" payload size: {} bytes", header.payload.len());
21 }
22 Err(e) => {
23 eprintln!("parse error: {e}");
24 }
25 }
26
27 // Peek at the DCID without a full parse.
28 if let Some(dcid) = quic_parser::peek_long_header_dcid(&packet) {
29 println!(" peeked dcid: {}", hex(dcid));
30 }
31}