Skip to content

Commit

Permalink
Add support for interleaved view mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
martinling committed Oct 29, 2024
1 parent 8f47902 commit 34e3bc6
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/capture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ pub enum TrafficItem {
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
pub enum TrafficViewMode {
Hierarchical,
Interleaved,
Transactions,
Packets,
}
Expand All @@ -242,6 +243,7 @@ impl TrafficViewMode {
use TrafficViewMode::*;
match self {
Hierarchical => "Hierarchical",
Interleaved => "Interleaved",
Transactions => "Transactions",
Packets => "Packets",
}
Expand All @@ -252,6 +254,7 @@ impl TrafficViewMode {
use TrafficViewMode::*;
match self {
Hierarchical => "traffic-hierarchical",
Interleaved => "traffic-interleaved",
Transactions => "traffic-transactions",
Packets => "traffic-packets",
}
Expand All @@ -262,6 +265,7 @@ impl TrafficViewMode {
use TrafficViewMode::*;
match log_name {
"traffic-hierarchical" => Hierarchical,
"traffic-interleaved" => Interleaved,
"traffic-transactions" => Transactions,
"traffic-packets" => Packets,
_ => panic!("Unrecognised log name '{log_name}'")
Expand Down Expand Up @@ -1528,7 +1532,7 @@ impl ItemSource<TrafficItem, TrafficViewMode> for CaptureReader {
use TrafficViewMode::*;
match parent {
None => Ok(match view_mode {
Hierarchical => {
Hierarchical | Interleaved => {
let item_id = TrafficItemId::from(index);
let group_id = self.item_index.get(item_id)?;
TransactionGroup(group_id)
Expand Down Expand Up @@ -1580,7 +1584,7 @@ impl ItemSource<TrafficItem, TrafficViewMode> for CaptureReader {
Ok(match parent {
None => {
(self.completion(), match view_mode {
Hierarchical => self.item_index.len(),
Hierarchical | Interleaved => self.item_index.len(),
Transactions => self.transaction_index.len(),
Packets => self.packet_index.len(),
})
Expand All @@ -1592,11 +1596,19 @@ impl ItemSource<TrafficItem, TrafficViewMode> for CaptureReader {
}
let transaction_count = self.group_range(&entry)?.len();
let ep_traf = self.endpoint_traffic(entry.endpoint_id())?;
if entry.group_id().value >= ep_traf.end_index.len() {
(Ongoing, transaction_count)
} else {
(Complete, transaction_count)
}
let ep_group_id = entry.group_id();
let ongoing = ep_group_id.value >= ep_traf.end_index.len();
let status = match (view_mode, ongoing) {
(Hierarchical, true) => Ongoing,
(Hierarchical, false) => Complete,
(Interleaved, true) => InterleavedOngoing,
(Interleaved, false) => {
let end = ep_traf.end_index.get(ep_group_id)?;
InterleavedComplete(end.value)
}
(Transactions | Packets, _) => unreachable!(),
};
(status, transaction_count)
},
Some(Transaction(_, transaction_id)) => {
let packet_count = self.transaction_index.target_range(
Expand Down

0 comments on commit 34e3bc6

Please sign in to comment.