@@ -71,6 +71,7 @@ static struct
71
71
ch_bool allow_duplicates ;
72
72
ch_bool hpt_trailer ;
73
73
char * steer_type ;
74
+ ch_bool verbose ;
74
75
} options ;
75
76
76
77
enum out_format_type {
@@ -351,6 +352,7 @@ int main (int argc, char** argv)
351
352
ch_opt_addbi (CH_OPTION_FLAG , 'D' , "allow-duplicates" , "Allow duplicate filenames to be used" , & options .allow_duplicates , false);
352
353
ch_opt_addbi (CH_OPTION_FLAG , 't' , "hpt-trailer" , "Extract timestamps from Fusion HPT trailers" , & options .hpt_trailer , false);
353
354
ch_opt_addsi (CH_OPTION_OPTIONAL , 's' , "steer" , "Steer packets to different files depending on packet contents. Valid values are [hpt, vlan, expcap]" , & options .steer_type , NULL );
355
+ ch_opt_addbi (CH_OPTION_FLAG , 'v' , "verbose" , "Printout verbose output." , & options .verbose , false);
354
356
355
357
ch_opt_parse (argc , argv );
356
358
@@ -488,6 +490,9 @@ int main (int argc, char** argv)
488
490
}
489
491
490
492
pkt_info = pcap_buff_next_packet (& rd_buffs [buff_idx ]);
493
+ const char * cur_filename = pcap_buff_get_filename (& rd_buffs [buff_idx ]);
494
+ const uint64_t pkt_idx = rd_buffs [buff_idx ].idx ;
495
+
491
496
switch (pkt_info ){
492
497
case PKT_PADDING :
493
498
ch_log_debug1 ("Skipping over packet %i (buffer %i) because len=0\n" , pkt_idx , buff_idx );
@@ -504,14 +509,22 @@ int main (int argc, char** argv)
504
509
break ;
505
510
case PKT_ERROR :
506
511
ch_log_debug1 ("Skipping over damaged packet %i (buffer %i) because flags = 0x%02x\n" ,
507
- pkt_idx , buff_idx , pkt_ftr -> flags );
512
+ pkt_idx , buff_idx , rd_buffs [ buff_idx ]. ftr -> flags );
508
513
dropped_errors ++ ;
509
514
buff_idx -- ;
510
515
continue ;
511
516
case PKT_EOF :
512
- ch_log_debug1 ("End of file \"%s\"\n" , pcap_buff_get_filename ( & rd_buffs [ buff_idx ]) );
517
+ ch_log_debug1 ("End of file \"%s\"\n" , cur_filename );
513
518
goto begin_loop ;
514
519
break ;
520
+ case PKT_OVER_SNAPLEN :
521
+ ch_log_fatal ("Packet with index %d (%s) does not comply with snaplen: %d (data len is %d)\n" ,
522
+ pkt_idx , cur_filename , rd_buffs [buff_idx ].snaplen , rd_buffs [buff_idx ].hdr -> len );
523
+ case PKT_SNAPPED :
524
+ if (options .verbose ){
525
+ ch_log_warn ("Packet has been snapped shorter (%d) than it's wire length (%d) [%s].\n" ,
526
+ rd_buffs [buff_idx ].hdr -> caplen , rd_buffs [buff_idx ].hdr -> len , cur_filename );
527
+ }
515
528
case PKT_OK :
516
529
break ;
517
530
}
0 commit comments