Skip to content

Commit

Permalink
trace packets 4-tuples when they are specified
Browse files Browse the repository at this point in the history
i.e., different from 0.0.0.0 (Ipv4) and :: (Ipv6).
  • Loading branch information
qdeconinck committed May 25, 2022
1 parent e0833f3 commit 6756beb
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions quiche/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,14 @@ impl Default for QlogInfo {
}
}

fn addr_tuple_to_string(from: SocketAddr, to: SocketAddr) -> String {
if from.ip().is_unspecified() || to.ip().is_unspecified() {
"".to_string()
} else {
format!(" ({} -> {})", from, to)
}
}

impl Connection {
fn new(
scid: ConnectionId<'static>, odcid: Option<&ConnectionId>,
Expand Down Expand Up @@ -2361,11 +2369,12 @@ impl Connection {
let pn_len = hdr.pkt_num_len;

trace!(
"{} rx pkt {:?} len={} pn={}",
"{} rx pkt {:?} len={} pn={}{}",
self.trace_id,
hdr,
payload_len,
pn
pn,
addr_tuple_to_string(info.from, info.to)
);

#[cfg(feature = "qlog")]
Expand Down Expand Up @@ -4023,11 +4032,15 @@ impl Connection {
}

trace!(
"{} tx pkt {} len={} pn={}",
"{} tx pkt {} len={} pn={}{}",
self.trace_id,
hdr_trace.unwrap_or_else(|| "".to_string()),
payload_len,
pn
pn,
addr_tuple_to_string(
self.path_mgr.get(send_pid)?.local_addr(),
self.path_mgr.get(send_pid)?.peer_addr()
)
);

#[cfg(feature = "qlog")]
Expand Down

0 comments on commit 6756beb

Please sign in to comment.