@@ -9,7 +9,7 @@ use ratatui::{
99use crate :: {
1010 app:: { ActiveView , App , SortColumn , TreeNode } ,
1111 ptp:: { PtpHost , PtpHostState } ,
12- types:: { format_timestamp, ProcessedPacket , PtpClockAccuracy , PtpClockClass } ,
12+ types:: { format_timestamp, ParsedPacket , PtpClockAccuracy , PtpClockClass } ,
1313 version,
1414} ;
1515
@@ -1027,8 +1027,9 @@ fn render_scrollbar(
10271027 }
10281028}
10291029
1030- fn format_instant ( instant : std:: time:: Instant ) -> String {
1031- let elapsed = instant. elapsed ( ) ;
1030+ fn format_instant ( system_time : std:: time:: SystemTime ) -> String {
1031+ let now = std:: time:: SystemTime :: now ( ) ;
1032+ let elapsed = now. duration_since ( system_time) . unwrap_or_default ( ) ;
10321033
10331034 let elapsed_str = if elapsed. as_secs ( ) < 1 {
10341035 format ! ( "{}ms" , elapsed. as_millis( ) )
@@ -1180,8 +1181,8 @@ fn render_packet_history(f: &mut Frame, area: Rect, app: &mut App) {
11801181 . iter ( )
11811182 . enumerate ( )
11821183 . map ( |( i, packet) | {
1183- let time_str = format_instant ( packet. timestamp ) ;
1184- let header = packet. ptp_message . header ( ) ;
1184+ let time_str = format_instant ( packet. raw . timestamp ) ;
1185+ let header = packet. ptp . header ( ) ;
11851186
11861187 let row_style =
11871188 if matches ! ( app. active_view, ActiveView :: PacketHistory ) && i == selected_in_view {
@@ -1194,19 +1195,19 @@ fn render_packet_history(f: &mut Frame, area: Rect, app: &mut App) {
11941195
11951196 Row :: new ( vec ! [
11961197 Cell :: from( time_str) ,
1197- Cell :: from( match packet. vlan_id {
1198+ Cell :: from( match packet. raw . vlan_id {
11981199 Some ( id) => id. to_string( ) ,
11991200 None => "-" . to_string( ) ,
12001201 } ) ,
1201- Cell :: from( match packet. source_addr {
1202+ Cell :: from( match packet. raw . source_addr {
12021203 std:: net:: SocketAddr :: V4 ( a) => a. ip( ) . to_string( ) ,
12031204 _ => "-" . to_string( ) ,
12041205 } ) ,
1205- Cell :: from( match packet. source_addr {
1206+ Cell :: from( match packet. raw . source_addr {
12061207 std:: net:: SocketAddr :: V4 ( a) => a. port( ) . to_string( ) ,
12071208 _ => "-" . to_string( ) ,
12081209 } ) ,
1209- Cell :: from( packet. interface . clone( ) ) ,
1210+ Cell :: from( packet. raw . interface_name . clone( ) ) ,
12101211 Cell :: from( header. version. to_string( ) ) ,
12111212 Cell :: from( Span :: styled(
12121213 header. message_type. to_string( ) ,
@@ -1218,7 +1219,7 @@ fn render_packet_history(f: &mut Frame, area: Rect, app: &mut App) {
12181219 Cell :: from( header. flags. short( ) ) ,
12191220 Cell :: from( header. correction_field. to_string( ) ) ,
12201221 Cell :: from( header. log_message_interval. to_string( ) ) ,
1221- Cell :: from( packet. ptp_message . to_string( ) ) ,
1222+ Cell :: from( packet. ptp . to_string( ) ) ,
12221223 ] )
12231224 . style ( row_style)
12241225 } )
@@ -1290,7 +1291,7 @@ fn render_packet_modal(f: &mut Frame, area: Rect, app: &mut App) {
12901291 // Modal title
12911292 let title = format ! (
12921293 "Packet Details - Seq {} (ESC to close)" ,
1293- packet. ptp_message . header( ) . sequence_id
1294+ packet. ptp . header( ) . sequence_id
12941295 ) ;
12951296
12961297 // Get theme reference before mutable operations
@@ -1314,12 +1315,12 @@ fn render_packet_modal(f: &mut Frame, area: Rect, app: &mut App) {
13141315fn render_packet_details_with_hexdump (
13151316 f : & mut Frame ,
13161317 area : Rect ,
1317- packet : & ProcessedPacket ,
1318+ packet : & ParsedPacket ,
13181319 theme : & crate :: themes:: Theme ,
13191320 app : & mut App ,
13201321) {
1321- let header = packet. ptp_message . header ( ) ;
1322- let time_str = format_instant ( packet. timestamp ) ;
1322+ let header = packet. ptp . header ( ) ;
1323+ let time_str = format_instant ( packet. raw . timestamp ) ;
13231324
13241325 // Define the width for label alignment (same as host details)
13251326 const LABEL_WIDTH : usize = 30 ;
@@ -1336,48 +1337,56 @@ fn render_packet_details_with_hexdump(
13361337 ) ] ) ,
13371338 create_aligned_field(
13381339 "Source Address:" ,
1339- packet. source_addr. to_string( ) ,
1340+ packet. raw . source_addr. to_string( ) ,
13401341 LABEL_WIDTH ,
13411342 theme,
13421343 ) ,
13431344 create_aligned_field(
13441345 "Source MAC:" ,
13451346 format!(
13461347 "{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}" ,
1347- packet. source_mac[ 0 ] ,
1348- packet. source_mac[ 1 ] ,
1349- packet. source_mac[ 2 ] ,
1350- packet. source_mac[ 3 ] ,
1351- packet. source_mac[ 4 ] ,
1352- packet. source_mac[ 5 ]
1348+ packet. raw . source_mac[ 0 ] ,
1349+ packet. raw . source_mac[ 1 ] ,
1350+ packet. raw . source_mac[ 2 ] ,
1351+ packet. raw . source_mac[ 3 ] ,
1352+ packet. raw . source_mac[ 4 ] ,
1353+ packet. raw . source_mac[ 5 ]
13531354 ) ,
13541355 LABEL_WIDTH ,
13551356 theme,
13561357 ) ,
13571358 create_aligned_field(
13581359 "Dest Address:" ,
1359- packet. dest_addr. to_string( ) ,
1360+ packet. raw . dest_addr. to_string( ) ,
13601361 LABEL_WIDTH ,
13611362 theme,
13621363 ) ,
13631364 create_aligned_field(
13641365 "Dest MAC:" ,
13651366 format!(
13661367 "{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}" ,
1367- packet. dest_mac[ 0 ] ,
1368- packet. dest_mac[ 1 ] ,
1369- packet. dest_mac[ 2 ] ,
1370- packet. dest_mac[ 3 ] ,
1371- packet. dest_mac[ 4 ] ,
1372- packet. dest_mac[ 5 ]
1368+ packet. raw . dest_mac[ 0 ] ,
1369+ packet. raw . dest_mac[ 1 ] ,
1370+ packet. raw . dest_mac[ 2 ] ,
1371+ packet. raw . dest_mac[ 3 ] ,
1372+ packet. raw . dest_mac[ 4 ] ,
1373+ packet. raw . dest_mac[ 5 ]
13731374 ) ,
13741375 LABEL_WIDTH ,
13751376 theme,
13761377 ) ,
1377- create_aligned_field( "Interface:" , packet. interface. clone( ) , LABEL_WIDTH , theme) ,
1378+ create_aligned_field(
1379+ "Interface:" ,
1380+ packet. raw. interface_name. clone( ) ,
1381+ LABEL_WIDTH ,
1382+ theme,
1383+ ) ,
13781384 create_aligned_field(
13791385 "VLAN ID:" ,
1380- packet. vlan_id. map_or( "-" . to_string( ) , |id| id. to_string( ) ) ,
1386+ packet
1387+ . raw
1388+ . vlan_id
1389+ . map_or( "-" . to_string( ) , |id| id. to_string( ) ) ,
13811390 LABEL_WIDTH ,
13821391 theme,
13831392 ) ,
@@ -1443,7 +1452,7 @@ fn render_packet_details_with_hexdump(
14431452 ] ;
14441453
14451454 // Add detailed message fields
1446- let message_details = packet. ptp_message . details ( ) ;
1455+ let message_details = packet. ptp . details ( ) ;
14471456 if !message_details. is_empty ( ) {
14481457 for ( field_name, field_value) in message_details. iter ( ) {
14491458 all_lines. push ( Line :: from ( vec ! [
@@ -1485,7 +1494,7 @@ fn render_packet_details_with_hexdump(
14851494 }
14861495
14871496 // Add hexdump section at the end
1488- let raw_data = & packet. raw_packet_data ;
1497+ let raw_data = & packet. raw . data ;
14891498 all_lines. extend ( vec ! [
14901499 Line :: from( "" ) ,
14911500 Line :: from( vec![
0 commit comments