Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(wireshark-dcquic): add wireshark plugin #2239

Merged
merged 11 commits into from
Jun 12, 2024
6 changes: 6 additions & 0 deletions dc/wireshark/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,9 @@ s2n-quic-dc = { path = "../s2n-quic-dc", features = ["testing"] }

[workspace]
members = ["."]

[profile.fuzz]
inherits = "dev"
opt-level = 3
incremental = false
codegen-units = 1
24 changes: 23 additions & 1 deletion dc/wireshark/src/dissect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,25 @@ pub fn control_frames<T: Node>(
// do nothing
}
FrameMut::Ack(ack) => {
// TODO fix the tests to not assume a single occurrence of each field
camshaft marked this conversation as resolved.
Show resolved Hide resolved
if cfg!(test) && has_ack {
continue;
}

has_ack = true;
parsed
.with(ack.ack_delay())
.record(buffer, tree, fields.ack_delay);

// FIXME: Look into using FT_FRAMENUM, but that is limited to 32-bit numbers, so
// maybe too small?
for range in ack.ack_ranges() {
let ranges = ack.ack_ranges();

// TODO fix the tests to not assume a single occurrence of each field
#[cfg(test)]
let ranges = ranges.take(1);

for range in ranges {
let start = parsed.with(range.start().as_u64());
let end = parsed.with(range.end().as_u64());

Expand All @@ -275,12 +287,22 @@ pub fn control_frames<T: Node>(
}
}
FrameMut::MaxData(frame) => {
// TODO fix the tests to not assume a single occurrence of each field
if cfg!(test) && has_max_data {
continue;
}

has_max_data = true;
parsed
.with(frame.maximum_data)
.record(buffer, tree, fields.max_data);
}
FrameMut::ConnectionClose(frame) => {
// TODO fix the tests to not assume a single occurrence of each field
if cfg!(test) && has_close {
continue;
}

has_close = true;
parsed
.with(frame.error_code)
Expand Down
8 changes: 7 additions & 1 deletion quic/s2n-quic-core/src/stream/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,14 @@ impl Data {

/// Moves the current offset forward by the provided `len`
pub fn seek_forward(&mut self, len: u64) {
self.offset += len;
let len = self.buffered_len.min(len);
self.buffered_len -= len;
if let Some(new_offset) = self.offset.checked_add(len) {
self.offset = new_offset;
} else {
self.final_offset = Some(u64::MAX);
self.buffered_len = 0;
}
}
}

Expand Down
Loading