From 80adb368d4dc0a84bb4688502853719d1a0614f0 Mon Sep 17 00:00:00 2001 From: Nils Andreas Svee Date: Thu, 23 Apr 2026 00:16:13 +0700 Subject: [PATCH] feat(pinger): Implement new craft_packet signature for ICMP types --- src/pinger_icmp.rs | 7 +++++-- src/pinger_icmp_ts.rs | 8 ++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/pinger_icmp.rs b/src/pinger_icmp.rs index f201fb0..1910204 100644 --- a/src/pinger_icmp.rs +++ b/src/pinger_icmp.rs @@ -77,11 +77,14 @@ impl PingListener for PingerICMPEchoListener { } impl PingSender for PingerICMPEchoSender { - fn craft_packet(&self, id: u16, seq: u16) -> Icmpv4Packet { + fn craft_packet(&self, id: u16, seq: u16) -> (Icmpv4Packet, i64) { let clock = Time::new(ClockId::Monotonic); let time_ms = clock.to_milliseconds(); let payload = time_ms.to_be_bytes().to_vec(); - Icmpv4Packet::with_echo_request(id, seq, payload).unwrap() + ( + Icmpv4Packet::with_echo_request(id, seq, payload).unwrap(), + time_ms as i64, + ) } } diff --git a/src/pinger_icmp_ts.rs b/src/pinger_icmp_ts.rs index c3bf5ca..6a0fc4c 100644 --- a/src/pinger_icmp_ts.rs +++ b/src/pinger_icmp_ts.rs @@ -72,8 +72,12 @@ impl PingListener for PingerICMPTimestampListener { } impl PingSender for PingerICMPTimestampSender { - fn craft_packet(&self, id: u16, seq: u16) -> Icmpv4Packet { + fn craft_packet(&self, id: u16, seq: u16) -> (Icmpv4Packet, i64) { let time_since_midnight = Time::new(ClockId::Realtime).get_time_since_midnight(); - Icmpv4Packet::with_timestamp_request(id, seq, time_since_midnight as u32, 0, 0).unwrap() + ( + Icmpv4Packet::with_timestamp_request(id, seq, time_since_midnight as u32, 0, 0) + .unwrap(), + time_since_midnight as i64, + ) } }