| Wireshark 4.7.3 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
/builds/wireshark/wireshark/file.h
Go to the documentation of this file.
1
11
12#ifndef __FILE_H__
13#define __FILE_H__
14
15#include <wiretap/wtap.h>
16#include <epan/epan.h>
17#include <epan/print.h>
18#include <epan/fifo_string_cache.h>
19#include <ui/packet_range.h>
20
21#ifdef __cplusplus
22 extern "C" {
23#endif /* __cplusplus */
24
26 typedef enum {
27 CF_OK,
28 CF_ERROR
29} cf_status_t;
30
32 typedef enum {
33 CF_READ_OK,
34 CF_READ_ERROR,
35 CF_READ_ABORTED
36} cf_read_status_t;
37
39 typedef enum {
40 CF_WRITE_OK,
41 CF_WRITE_ERROR,
42 CF_WRITE_ABORTED
43} cf_write_status_t;
44
46 typedef enum {
47 CF_PRINT_OK,
48 CF_PRINT_OPEN_ERROR,
49 CF_PRINT_WRITE_ERROR
50} cf_print_status_t;
51
55 typedef enum {
56 cf_cb_file_opened,
57 cf_cb_file_closing,
58 cf_cb_file_closed,
59 cf_cb_file_read_started,
60 cf_cb_file_read_finished,
61 cf_cb_file_reload_started,
62 cf_cb_file_reload_finished,
63 cf_cb_file_rescan_started,
64 cf_cb_file_rescan_finished,
65 cf_cb_file_retap_started,
66 cf_cb_file_retap_finished,
67 cf_cb_file_merge_started,
68 cf_cb_file_merge_finished,
69 cf_cb_file_fast_save_finished,
70 cf_cb_file_save_started,
71 cf_cb_file_save_finished,
72 cf_cb_file_save_failed,
73 cf_cb_file_save_stopped
74} cf_cbs;
75
82 typedef void (*cf_callback_t)(int event, void *data, void *user_data);
83
87 typedef struct {
88 const char *string;
89 size_t string_len;
90 capture_file *cf;
91 field_info *finfo;
92 field_info *prev_finfo;
93 bool frame_matched;
94 bool halt;
95} match_data;
96
102 extern void
103 cf_set_max_records(unsigned max_records);
104
115
116 extern void
117 cf_callback_add(cf_callback_t func, void *user_data);
118
125
126 extern void
127 cf_callback_remove(cf_callback_t func, void *user_data);
128
139 cf_status_t cf_open(capture_file *cf, const char *fname, unsigned int type, bool is_tempfile, int *err);
140
146 void cf_close(capture_file *cf);
147
154 cf_status_t cf_reload(capture_file *cf);
155
163 cf_read_status_t cf_read(capture_file *cf, bool reloading);
164
175 bool cf_read_record(capture_file *cf, const frame_data *fdata,
176 wtap_rec *rec);
177
188 bool cf_read_record_no_alert(capture_file *cf, const frame_data *fdata,
189 wtap_rec *rec);
190
191
200 bool cf_read_current_record(capture_file *cf);
201
213 cf_read_status_t cf_continue_tail(capture_file *cf, volatile int to_read,
214 wtap_rec *rec, int *err,
215 fifo_string_cache_t *frame_dup_cache, GChecksum *frame_cksum);
216
222 void cf_fake_continue_tail(capture_file *cf);
223
234 cf_read_status_t cf_finish_tail(capture_file *cf, wtap_rec *rec,
235 int *err,
236 fifo_string_cache_t *frame_dup_cache, GChecksum *frame_cksum);
237
245 bool cf_can_write_with_wiretap(capture_file *cf);
246
254 bool cf_can_save(capture_file *cf);
255
262 bool cf_can_save_as(capture_file *cf);
263
270 bool cf_has_unsaved_data(capture_file *cf);
271
290 cf_write_status_t cf_save_records(capture_file * cf, const char *fname,
291 unsigned save_format,
292 ws_compression_type compression_type,
293 bool discard_comments,
294 bool dont_reopen);
295
310 cf_write_status_t cf_export_specified_packets(capture_file *cf,
311 const char *fname,
312 packet_range_t *range,
313 unsigned save_format,
314 ws_compression_type compression_type);
315
322 char *cf_get_display_name(capture_file *cf);
323
333 char *cf_get_basename(capture_file *cf);
334
342 void cf_set_tempfile_source(capture_file *cf, char *source);
343
350 const char *cf_get_tempfile_source(capture_file *cf);
351
358 int cf_get_packet_count(capture_file *cf);
359
366 bool cf_is_tempfile(capture_file *cf);
367
371 void cf_set_tempfile(capture_file *cf, bool is_tempfile);
372
379 void cf_set_drops_known(capture_file *cf, bool drops_known);
380
387 void cf_set_drops(capture_file *cf, uint32_t drops);
388
395 bool cf_get_drops_known(capture_file *cf);
396
403uint32_t cf_get_drops(capture_file *cf);
404
412 void cf_set_rfcode(capture_file *cf, dfilter_t *rfcode);
413
422 cf_status_t cf_filter_packets(capture_file *cf, char *dfilter, bool force);
423
430 void cf_reftime_packets(capture_file *cf);
431
437 unsigned long cf_get_computed_elapsed(capture_file *cf);
438
444 void cf_redissect_packets(capture_file *cf);
445
452 cf_read_status_t cf_retap_packets(capture_file *cf);
453
460 void cf_retap_aggregation_packets(capture_file* cf, bool enable);
461
465 typedef enum {
466 print_range_selected_only,
467 print_range_marked_only,
468 print_range_all_displayed,
469 print_range_all_captured
470} print_range_e;
471
472
476 typedef struct {
477 print_stream_t *stream;
478 print_format_e format;
479 bool to_file;
480 char *file;
481 char *cmd;
482 packet_range_t range;
483
484 /* --- Packet list and detail options --- */
485 bool print_summary;
486 bool print_col_headings;
487 print_dissections_e print_dissections;
488 bool print_hex;
489 unsigned hexdump_options;
490 bool print_formfeed;
491
492 /* --- JSON output options --- */
493 bool no_duplicate_keys;
494 bool json_compact;
495
496 /* --- CSV output options -- */
497 print_args_csv_t csv_args;
498
499 /* --- C Arrays output options --- */
500 print_args_carrays_t carrays_args;
501} print_args_t;
502
511 cf_print_status_t cf_print_packets(capture_file *cf, print_args_t *print_args,
512 bool show_progress_bar);
513
521 cf_print_status_t cf_write_pdml_packets(capture_file *cf, print_args_t *print_args);
522
530 cf_print_status_t cf_write_psml_packets(capture_file *cf, print_args_t *print_args);
531
539 cf_print_status_t cf_write_csv_packets(capture_file *cf, print_args_t *print_args);
540
548 cf_print_status_t cf_write_carrays_packets(capture_file *cf, print_args_t *print_args);
549
557 cf_print_status_t cf_write_json_packets(capture_file *cf, print_args_t *print_args);
558
569 bool cf_find_packet_protocol_tree(capture_file *cf, const char *string,
570 search_direction dir, bool multiple);
571
580 extern field_info* cf_find_string_protocol_tree(capture_file *cf, proto_tree *tree);
581
590 bool cf_find_packet_summary_line(capture_file *cf, const char *string,
591 search_direction dir);
592
604 bool cf_find_packet_data(capture_file *cf, const uint8_t *string,
605 size_t string_size, search_direction dir,
606 bool multiple);
607
617 bool cf_find_packet_dfilter(capture_file *cf, dfilter_t *sfcode,
618 search_direction dir, bool start_current);
619
628 bool
629 cf_find_packet_dfilter_string(capture_file *cf, const char *filter,
630 search_direction dir);
631
639 bool cf_find_packet_marked(capture_file *cf, search_direction dir);
640
648 bool cf_find_packet_time_reference(capture_file *cf, search_direction dir);
649
659 bool cf_goto_frame(capture_file *cf, unsigned row, bool exact);
660
669 bool cf_goto_framenum(capture_file *cf);
670
677 void cf_select_packet(capture_file *cf, frame_data *frame);
678
684 void cf_unselect_packet(capture_file *cf);
685
692 void cf_mark_frame(capture_file *cf, frame_data *frame);
693
700 void cf_unmark_frame(capture_file *cf, frame_data *frame);
701
708 void cf_ignore_frame(capture_file *cf, frame_data *frame);
709
716 void cf_unignore_frame(capture_file *cf, frame_data *frame);
717
731 cf_status_t
732
745 cf_merge_files_to_tempfile(void *pd_window, const char *temp_dir, char **out_filenamep,
746 int in_file_count, const char *const *in_filenames,
747 int file_type, bool do_append);
748
756 void cf_update_section_comment(capture_file *cf, char *comment);
757
766 void cf_update_section_comments(capture_file *cf, unsigned shb_idx, char **comments);
767
777wtap_block_t cf_get_packet_block(capture_file *cf, const frame_data *fd);
778
790 bool cf_set_modified_block(capture_file *cf, frame_data *fd, const wtap_block_t new_block);
791
798uint32_t cf_comment_types(capture_file *cf);
799
808 bool cf_add_ip_name_from_string(capture_file *cf, const char *addr, const char *name);
809
810#ifdef __cplusplus
811}
812#endif /* __cplusplus */
813
814#endif /* file.h */
capture_file
struct _capture_file capture_file
Represents a capture file and its associated metadata.
search_direction
search_direction
Direction of a packet search through the capture.
Definition cfile.h:63
epan.h
cf_get_basename
char * cf_get_basename(capture_file *cf)
Definition file.c:1129
cf_unmark_frame
void cf_unmark_frame(capture_file *cf, frame_data *frame)
Definition file.c:4995
cf_write_csv_packets
cf_print_status_t cf_write_csv_packets(capture_file *cf, print_args_t *print_args)
Definition file.c:3029
cf_goto_frame
bool cf_goto_frame(capture_file *cf, unsigned row, bool exact)
Definition file.c:4778
cf_read_status_t
cf_read_status_t
Definition file.h:32
CF_READ_ERROR
@ CF_READ_ERROR
Definition file.h:34
CF_READ_OK
@ CF_READ_OK
Definition file.h:33
CF_READ_ABORTED
@ CF_READ_ABORTED
Definition file.h:35
cf_find_packet_marked
bool cf_find_packet_marked(capture_file *cf, search_direction dir)
Definition file.c:4567
cf_update_section_comments
void cf_update_section_comments(capture_file *cf, unsigned shb_idx, char **comments)
Definition file.c:5066
cf_read_record_no_alert
bool cf_read_record_no_alert(capture_file *cf, const frame_data *fdata, wtap_rec *rec)
Reads a record from the capture file without generating alerts.
Definition file.c:1655
cf_comment_types
uint32_t cf_comment_types(capture_file *cf)
Definition file.c:5186
cf_reload
cf_status_t cf_reload(capture_file *cf)
Definition file.c:6070
cf_has_unsaved_data
bool cf_has_unsaved_data(capture_file *cf)
Definition file.c:5405
cf_print_packets
cf_print_status_t cf_print_packets(capture_file *cf, print_args_t *print_args, bool show_progress_bar)
Definition file.c:2667
cf_find_packet_data
bool cf_find_packet_data(capture_file *cf, const uint8_t *string, size_t string_size, search_direction dir, bool multiple)
Definition file.c:3595
cf_close
void cf_close(capture_file *cf)
Definition file.c:358
cf_set_drops_known
void cf_set_drops_known(capture_file *cf, bool drops_known)
Definition file.c:1222
cf_retap_packets
cf_read_status_t cf_retap_packets(capture_file *cf)
Rescan all packets and just run taps - don't reconstruct the display.
Definition file.c:2367
cf_write_psml_packets
cf_print_status_t cf_write_psml_packets(capture_file *cf, print_args_t *print_args)
Definition file.c:2948
cf_callback_t
void(* cf_callback_t)(int event, void *data, void *user_data)
Callback function type invoked when a capture file lifecycle event occurs.
Definition file.h:82
cf_set_tempfile_source
void cf_set_tempfile_source(capture_file *cf, char *source)
Definition file.c:1176
cf_reftime_packets
void cf_reftime_packets(capture_file *cf)
Definition file.c:2126
cf_get_drops_known
bool cf_get_drops_known(capture_file *cf)
Definition file.c:1236
cf_get_drops
uint32_t cf_get_drops(capture_file *cf)
Definition file.c:1243
cf_goto_framenum
bool cf_goto_framenum(capture_file *cf)
Definition file.c:4878
cf_set_modified_block
bool cf_set_modified_block(capture_file *cf, frame_data *fd, const wtap_block_t new_block)
Definition file.c:5146
cf_can_save
bool cf_can_save(capture_file *cf)
Definition file.c:5343
cf_get_packet_count
int cf_get_packet_count(capture_file *cf)
Definition file.c:1201
cf_callback_add
void cf_callback_add(cf_callback_t func, void *user_data)
Definition file.c:189
cf_ignore_frame
void cf_ignore_frame(capture_file *cf, frame_data *frame)
Definition file.c:5008
cf_find_packet_time_reference
bool cf_find_packet_time_reference(capture_file *cf, search_direction dir)
Definition file.c:4580
cf_merge_files_to_tempfile
cf_status_t cf_merge_files_to_tempfile(void *pd_window, const char *temp_dir, char **out_filenamep, int in_file_count, const char *const *in_filenames, int file_type, bool do_append)
Merges multiple files into a temporary file.
Definition file.c:1502
cf_write_pdml_packets
cf_print_status_t cf_write_pdml_packets(capture_file *cf, print_args_t *print_args)
Definition file.c:2872
cf_write_carrays_packets
cf_print_status_t cf_write_carrays_packets(capture_file *cf, print_args_t *print_args)
Definition file.c:3101
cf_add_ip_name_from_string
bool cf_add_ip_name_from_string(capture_file *cf, const char *addr, const char *name)
Definition file.c:5220
cf_set_max_records
void cf_set_max_records(unsigned max_records)
Definition file.c:155
cf_find_string_protocol_tree
field_info * cf_find_string_protocol_tree(capture_file *cf, proto_tree *tree)
Definition file.c:3258
cf_read_record
bool cf_read_record(capture_file *cf, const frame_data *fdata, wtap_rec *rec)
Definition file.c:1642
cf_mark_frame
void cf_mark_frame(capture_file *cf, frame_data *frame)
Definition file.c:4982
cf_unselect_packet
void cf_unselect_packet(capture_file *cf)
Definition file.c:4960
cf_get_computed_elapsed
unsigned long cf_get_computed_elapsed(capture_file *cf)
Return the time it took to load the file (in msec).
Definition file.c:220
cf_can_save_as
bool cf_can_save_as(capture_file *cf)
Definition file.c:5382
cf_read_current_record
bool cf_read_current_record(capture_file *cf)
Definition file.c:1669
cf_get_tempfile_source
const char * cf_get_tempfile_source(capture_file *cf)
Definition file.c:1190
cf_set_rfcode
void cf_set_rfcode(capture_file *cf, dfilter_t *rfcode)
Definition file.c:1249
cf_set_drops
void cf_set_drops(capture_file *cf, uint32_t drops)
Definition file.c:1229
cf_find_packet_summary_line
bool cf_find_packet_summary_line(capture_file *cf, const char *string, search_direction dir)
Definition file.c:3489
cf_fake_continue_tail
void cf_fake_continue_tail(capture_file *cf)
Fake reading packets from the "end" of a capture file.
cf_write_json_packets
cf_print_status_t cf_write_json_packets(capture_file *cf, print_args_t *print_args)
Definition file.c:3175
cf_set_tempfile
void cf_set_tempfile(capture_file *cf, bool is_tempfile)
Definition file.c:1214
cf_read
cf_read_status_t cf_read(capture_file *cf, bool reloading)
Definition file.c:499
cf_finish_tail
cf_read_status_t cf_finish_tail(capture_file *cf, wtap_rec *rec, int *err, fifo_string_cache_t *frame_dup_cache, GChecksum *frame_cksum)
Finish reading from "end" of a capture file.
cf_retap_aggregation_packets
void cf_retap_aggregation_packets(capture_file *cf, bool enable)
Definition file.c:2490
cf_get_display_name
char * cf_get_display_name(capture_file *cf)
Get a displayable name of the capture file.
Definition file.c:1103
cf_is_tempfile
bool cf_is_tempfile(capture_file *cf)
Definition file.c:1208
cf_export_specified_packets
cf_write_status_t cf_export_specified_packets(capture_file *cf, const char *fname, packet_range_t *range, unsigned save_format, ws_compression_type compression_type)
Definition file.c:5941
cf_cbs
cf_cbs
Event identifiers for capture file lifecycle callbacks.
Definition file.h:55
cf_cb_file_retap_finished
@ cf_cb_file_retap_finished
Definition file.h:66
cf_cb_file_save_failed
@ cf_cb_file_save_failed
Definition file.h:72
cf_cb_file_reload_finished
@ cf_cb_file_reload_finished
Definition file.h:62
cf_cb_file_save_started
@ cf_cb_file_save_started
Definition file.h:70
cf_cb_file_retap_started
@ cf_cb_file_retap_started
Definition file.h:65
cf_cb_file_merge_started
@ cf_cb_file_merge_started
Definition file.h:67
cf_cb_file_merge_finished
@ cf_cb_file_merge_finished
Definition file.h:68
cf_cb_file_rescan_finished
@ cf_cb_file_rescan_finished
Definition file.h:64
cf_cb_file_fast_save_finished
@ cf_cb_file_fast_save_finished
Definition file.h:69
cf_cb_file_read_finished
@ cf_cb_file_read_finished
Definition file.h:60
cf_cb_file_opened
@ cf_cb_file_opened
Definition file.h:56
cf_cb_file_reload_started
@ cf_cb_file_reload_started
Definition file.h:61
cf_cb_file_save_finished
@ cf_cb_file_save_finished
Definition file.h:71
cf_cb_file_rescan_started
@ cf_cb_file_rescan_started
Definition file.h:63
cf_cb_file_closed
@ cf_cb_file_closed
Definition file.h:58
cf_cb_file_closing
@ cf_cb_file_closing
Definition file.h:57
cf_cb_file_save_stopped
@ cf_cb_file_save_stopped
Definition file.h:73
cf_cb_file_read_started
@ cf_cb_file_read_started
Definition file.h:59
cf_status_t
cf_status_t
Definition file.h:26
CF_ERROR
@ CF_ERROR
Definition file.h:28
CF_OK
@ CF_OK
Definition file.h:27
cf_open
cf_status_t cf_open(capture_file *cf, const char *fname, unsigned int type, bool is_tempfile, int *err)
Definition file.c:252
cf_filter_packets
cf_status_t cf_filter_packets(capture_file *cf, char *dfilter, bool force)
Definition file.c:1538
cf_continue_tail
cf_read_status_t cf_continue_tail(capture_file *cf, volatile int to_read, wtap_rec *rec, int *err, fifo_string_cache_t *frame_dup_cache, GChecksum *frame_cksum)
Read packets from the "end" of a capture file.
cf_callback_remove
void cf_callback_remove(cf_callback_t func, void *user_data)
Definition file.c:201
cf_unignore_frame
void cf_unignore_frame(capture_file *cf, frame_data *frame)
Definition file.c:5021
cf_find_packet_protocol_tree
bool cf_find_packet_protocol_tree(capture_file *cf, const char *string, search_direction dir, bool multiple)
Definition file.c:3232
cf_can_write_with_wiretap
bool cf_can_write_with_wiretap(capture_file *cf)
Definition file.c:5314
cf_update_section_comment
void cf_update_section_comment(capture_file *cf, char *comment)
Definition file.c:5034
print_range_e
print_range_e
Selects which frames from a capture file should be included in a print or export operation.
Definition file.h:465
print_range_all_displayed
@ print_range_all_displayed
Definition file.h:468
print_range_all_captured
@ print_range_all_captured
Definition file.h:469
print_range_selected_only
@ print_range_selected_only
Definition file.h:466
print_range_marked_only
@ print_range_marked_only
Definition file.h:467
cf_find_packet_dfilter
bool cf_find_packet_dfilter(capture_file *cf, dfilter_t *sfcode, search_direction dir, bool start_current)
Definition file.c:4512
cf_redissect_packets
void cf_redissect_packets(capture_file *cf)
"Something" has changed, rescan all packets.
Definition file.c:1616
cf_print_status_t
cf_print_status_t
Definition file.h:46
CF_PRINT_OPEN_ERROR
@ CF_PRINT_OPEN_ERROR
Definition file.h:48
CF_PRINT_WRITE_ERROR
@ CF_PRINT_WRITE_ERROR
Definition file.h:49
CF_PRINT_OK
@ CF_PRINT_OK
Definition file.h:47
cf_select_packet
void cf_select_packet(capture_file *cf, frame_data *frame)
Definition file.c:4902
cf_get_packet_block
wtap_block_t cf_get_packet_block(capture_file *cf, const frame_data *fd)
Definition file.c:5119
cf_write_status_t
cf_write_status_t
Definition file.h:39
CF_WRITE_OK
@ CF_WRITE_OK
Definition file.h:40
CF_WRITE_ERROR
@ CF_WRITE_ERROR
Definition file.h:41
CF_WRITE_ABORTED
@ CF_WRITE_ABORTED
Definition file.h:42
cf_save_records
cf_write_status_t cf_save_records(capture_file *cf, const char *fname, unsigned save_format, ws_compression_type compression_type, bool discard_comments, bool dont_reopen)
Definition file.c:5586
cf_find_packet_dfilter_string
bool cf_find_packet_dfilter_string(capture_file *cf, const char *filter, search_direction dir)
Definition file.c:4519
frame_data
DIAG_OFF_PEDANTIC struct _frame_data frame_data
Frame data structure.
packet_range.h
packet_range_t
struct packet_range_tag packet_range_t
Fully describes a packet range selection, including UI settings, derived counts, and dependency sets ...
print.h
print_format_e
print_format_e
Output format for printed packet data.
Definition print.h:30
print_dissections_e
print_dissections_e
Controls the level of protocol dissection detail included in printed output.
Definition print.h:39
print_stream_t
struct print_stream print_stream_t
Represents an abstract print stream, pairing a backend operations vtable with instance-specific state...
field_info
Definition proto.h:822
fifo_string_cache_t
Definition fifo_string_cache.h:26
match_data
State and result data for an in-progress packet or field search operation.
Definition file.h:87
match_data::cf
capture_file * cf
Definition file.h:90
match_data::string
const char * string
Definition file.h:88
match_data::finfo
field_info * finfo
Definition file.h:91
match_data::string_len
size_t string_len
Definition file.h:89
match_data::prev_finfo
field_info * prev_finfo
Definition file.h:92
match_data::frame_matched
bool frame_matched
Definition file.h:93
match_data::halt
bool halt
Definition file.h:94
print_args_carrays_t
Definition print.h:72
print_args_csv_t
Definition print.h:66
print_args_t
Aggregates all options controlling a single print or export operation.
Definition file.h:476
print_args_t::stream
print_stream_t * stream
Definition file.h:477
print_args_t::print_col_headings
bool print_col_headings
Definition file.h:486
print_args_t::hexdump_options
unsigned hexdump_options
Definition file.h:489
print_args_t::print_formfeed
bool print_formfeed
Definition file.h:490
print_args_t::file
char * file
Definition file.h:480
print_args_t::print_dissections
print_dissections_e print_dissections
Definition file.h:487
print_args_t::no_duplicate_keys
bool no_duplicate_keys
Definition file.h:493
print_args_t::print_hex
bool print_hex
Definition file.h:488
print_args_t::format
print_format_e format
Definition file.h:478
print_args_t::json_compact
bool json_compact
Definition file.h:494
print_args_t::range
packet_range_t range
Definition file.h:482
print_args_t::to_file
bool to_file
Definition file.h:479
print_args_t::cmd
char * cmd
Definition file.h:481
print_args_t::print_summary
bool print_summary
Definition file.h:485
wtap_rec
Represents a single capture record read from or written to a capture file, regardless of record type.
Definition wtap.h:1600
wtap.h