| Wireshark 4.7.0 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
/builds/wireshark/wireshark/file.h
Go to the documentation of this file.
1
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
52 typedef enum {
53 cf_cb_file_opened,
54 cf_cb_file_closing,
55 cf_cb_file_closed,
56 cf_cb_file_read_started,
57 cf_cb_file_read_finished,
58 cf_cb_file_reload_started,
59 cf_cb_file_reload_finished,
60 cf_cb_file_rescan_started,
61 cf_cb_file_rescan_finished,
62 cf_cb_file_retap_started,
63 cf_cb_file_retap_finished,
64 cf_cb_file_merge_started, /* Qt only */
65 cf_cb_file_merge_finished, /* Qt only */
66 cf_cb_file_fast_save_finished,
67 cf_cb_file_save_started,
68 cf_cb_file_save_finished,
69 cf_cb_file_save_failed,
70 cf_cb_file_save_stopped
71} cf_cbs;
72
73 typedef void (*cf_callback_t) (int event, void *data, void *user_data);
74
75 typedef struct {
76 const char *string;
77 size_t string_len;
78 capture_file *cf;
79 field_info *finfo;
80 field_info *prev_finfo;
81 bool frame_matched;
82 bool halt;
83} match_data;
84
90 extern void
91 cf_set_max_records(unsigned max_records);
92
104 extern void
105 cf_callback_add(cf_callback_t func, void *user_data);
106
114 extern void
115 cf_callback_remove(cf_callback_t func, void *user_data);
116
127 cf_status_t cf_open(capture_file *cf, const char *fname, unsigned int type, bool is_tempfile, int *err);
128
134 void cf_close(capture_file *cf);
135
142 cf_status_t cf_reload(capture_file *cf);
143
151 cf_read_status_t cf_read(capture_file *cf, bool reloading);
152
163 bool cf_read_record(capture_file *cf, const frame_data *fdata,
164 wtap_rec *rec);
165
167 bool cf_read_record_no_alert(capture_file *cf, const frame_data *fdata,
168 wtap_rec *rec);
169
170
179 bool cf_read_current_record(capture_file *cf);
180
190 cf_read_status_t cf_continue_tail(capture_file *cf, volatile int to_read,
191 wtap_rec *rec, int *err,
192 fifo_string_cache_t *frame_dup_cache, GChecksum *frame_cksum);
193
199 void cf_fake_continue_tail(capture_file *cf);
200
209 cf_read_status_t cf_finish_tail(capture_file *cf, wtap_rec *rec,
210 int *err,
211 fifo_string_cache_t *frame_dup_cache, GChecksum *frame_cksum);
212
220 bool cf_can_write_with_wiretap(capture_file *cf);
221
229 bool cf_can_save(capture_file *cf);
230
237 bool cf_can_save_as(capture_file *cf);
238
245 bool cf_has_unsaved_data(capture_file *cf);
246
265 cf_write_status_t cf_save_records(capture_file * cf, const char *fname,
266 unsigned save_format,
267 ws_compression_type compression_type,
268 bool discard_comments,
269 bool dont_reopen);
270
285 cf_write_status_t cf_export_specified_packets(capture_file *cf,
286 const char *fname,
287 packet_range_t *range,
288 unsigned save_format,
289 ws_compression_type compression_type);
290
297 char *cf_get_display_name(capture_file *cf);
298
308 char *cf_get_basename(capture_file *cf);
309
317 void cf_set_tempfile_source(capture_file *cf, char *source);
318
325 const char *cf_get_tempfile_source(capture_file *cf);
326
333 int cf_get_packet_count(capture_file *cf);
334
341 bool cf_is_tempfile(capture_file *cf);
342
346 void cf_set_tempfile(capture_file *cf, bool is_tempfile);
347
354 void cf_set_drops_known(capture_file *cf, bool drops_known);
355
362 void cf_set_drops(capture_file *cf, uint32_t drops);
363
370 bool cf_get_drops_known(capture_file *cf);
371
378uint32_t cf_get_drops(capture_file *cf);
379
387 void cf_set_rfcode(capture_file *cf, dfilter_t *rfcode);
388
397 cf_status_t cf_filter_packets(capture_file *cf, char *dfilter, bool force);
398
405 void cf_reftime_packets(capture_file *cf);
406
410 unsigned long cf_get_computed_elapsed(capture_file *cf);
411
417 void cf_redissect_packets(capture_file *cf);
418
425 cf_read_status_t cf_retap_packets(capture_file *cf);
426
433 void cf_retap_aggregation_packets(capture_file* cf, bool enable);
434
435/* print_range, enum which frames should be printed */
436 typedef enum {
437 print_range_selected_only, /* selected frame(s) only (currently only one) */
438 print_range_marked_only, /* marked frames only */
439 print_range_all_displayed, /* all frames currently displayed */
440 print_range_all_captured /* all frames in capture */
441} print_range_e;
442
443 typedef struct {
444 print_stream_t *stream; /* the stream to which we're printing */
445 print_format_e format; /* plain text or PostScript */
446 bool to_file; /* true if we're printing to a file */
447 char *file; /* file output pathname */
448 char *cmd; /* print command string (not win32) */
449 packet_range_t range;
450
451 bool print_summary; /* true if we should print summary line. */
452 bool print_col_headings; /* true if we should print column headings */
453 print_dissections_e print_dissections;
454 bool print_hex; /* true if we should print hex data;
455 * false if we should print only if not dissected. */
456 unsigned hexdump_options; /* Hexdump options if print_hex is true. */
457 bool print_formfeed; /* true if a formfeed should be printed before
458 * each new packet */
459
460 /* JSON related option */
461 bool no_duplicate_keys;
462} print_args_t;
463
472 cf_print_status_t cf_print_packets(capture_file *cf, print_args_t *print_args,
473 bool show_progress_bar);
474
482 cf_print_status_t cf_write_pdml_packets(capture_file *cf, print_args_t *print_args);
483
491 cf_print_status_t cf_write_psml_packets(capture_file *cf, print_args_t *print_args);
492
500 cf_print_status_t cf_write_csv_packets(capture_file *cf, print_args_t *print_args);
501
509 cf_print_status_t cf_write_carrays_packets(capture_file *cf, print_args_t *print_args);
510
518 cf_print_status_t cf_write_json_packets(capture_file *cf, print_args_t *print_args);
519
530 bool cf_find_packet_protocol_tree(capture_file *cf, const char *string,
531 search_direction dir, bool multiple);
532
541 extern field_info* cf_find_string_protocol_tree(capture_file *cf, proto_tree *tree);
542
551 bool cf_find_packet_summary_line(capture_file *cf, const char *string,
552 search_direction dir);
553
565 bool cf_find_packet_data(capture_file *cf, const uint8_t *string,
566 size_t string_size, search_direction dir,
567 bool multiple);
568
578 bool cf_find_packet_dfilter(capture_file *cf, dfilter_t *sfcode,
579 search_direction dir, bool start_current);
580
589 bool
590 cf_find_packet_dfilter_string(capture_file *cf, const char *filter,
591 search_direction dir);
592
600 bool cf_find_packet_marked(capture_file *cf, search_direction dir);
601
609 bool cf_find_packet_time_reference(capture_file *cf, search_direction dir);
610
620 bool cf_goto_frame(capture_file *cf, unsigned row, bool exact);
621
630 bool cf_goto_framenum(capture_file *cf);
631
638 void cf_select_packet(capture_file *cf, frame_data *frame);
639
645 void cf_unselect_packet(capture_file *cf);
646
653 void cf_mark_frame(capture_file *cf, frame_data *frame);
654
661 void cf_unmark_frame(capture_file *cf, frame_data *frame);
662
669 void cf_ignore_frame(capture_file *cf, frame_data *frame);
670
677 void cf_unignore_frame(capture_file *cf, frame_data *frame);
678
692 cf_status_t
693 cf_merge_files_to_tempfile(void *pd_window, const char *temp_dir, char **out_filenamep,
694 int in_file_count, const char *const *in_filenames,
695 int file_type, bool do_append);
696
704 void cf_update_section_comment(capture_file *cf, char *comment);
705
714 void cf_update_section_comments(capture_file *cf, unsigned shb_idx, char **comments);
715
716/*
717 * Get the packet block for a packet (record).
718 * If the block has been edited, it returns the result of the edit,
719 * otherwise it returns the block from the file.
720 *
721 * @param cf the capture file
722 * @param fd the frame_data structure for the frame
723 * @returns A block (use wtap_block_unref to free) or NULL if there is none.
724 */
725 wtap_block_t cf_get_packet_block(capture_file *cf, const frame_data *fd);
726
738 bool cf_set_modified_block(capture_file *cf, frame_data *fd, const wtap_block_t new_block);
739
746uint32_t cf_comment_types(capture_file *cf);
747
756 bool cf_add_ip_name_from_string(capture_file *cf, const char *addr, const char *name);
757
758#ifdef __cplusplus
759}
760#endif /* __cplusplus */
761
762#endif /* file.h */
epan.h
cf_get_basename
char * cf_get_basename(capture_file *cf)
Definition file.c:1081
cf_unmark_frame
void cf_unmark_frame(capture_file *cf, frame_data *frame)
Definition file.c:4955
cf_write_csv_packets
cf_print_status_t cf_write_csv_packets(capture_file *cf, print_args_t *print_args)
Definition file.c:2997
cf_goto_frame
bool cf_goto_frame(capture_file *cf, unsigned row, bool exact)
Definition file.c:4738
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:4527
cf_update_section_comments
void cf_update_section_comments(capture_file *cf, unsigned shb_idx, char **comments)
Definition file.c:5026
cf_read_record_no_alert
bool cf_read_record_no_alert(capture_file *cf, const frame_data *fdata, wtap_rec *rec)
Definition file.c:1617
cf_comment_types
uint32_t cf_comment_types(capture_file *cf)
Definition file.c:5146
cf_reload
cf_status_t cf_reload(capture_file *cf)
Definition file.c:6036
cf_has_unsaved_data
bool cf_has_unsaved_data(capture_file *cf)
Definition file.c:5365
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:2636
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:3555
cf_close
void cf_close(capture_file *cf)
Definition file.c:356
cf_set_drops_known
void cf_set_drops_known(capture_file *cf, bool drops_known)
Definition file.c:1174
cf_retap_packets
cf_read_status_t cf_retap_packets(capture_file *cf)
Definition file.c:2335
cf_write_psml_packets
cf_print_status_t cf_write_psml_packets(capture_file *cf, print_args_t *print_args)
Definition file.c:2916
cf_set_tempfile_source
void cf_set_tempfile_source(capture_file *cf, char *source)
Definition file.c:1128
cf_reftime_packets
void cf_reftime_packets(capture_file *cf)
Definition file.c:2088
cf_get_drops_known
bool cf_get_drops_known(capture_file *cf)
Definition file.c:1188
cf_get_drops
uint32_t cf_get_drops(capture_file *cf)
Definition file.c:1195
cf_goto_framenum
bool cf_goto_framenum(capture_file *cf)
Definition file.c:4838
cf_set_modified_block
bool cf_set_modified_block(capture_file *cf, frame_data *fd, const wtap_block_t new_block)
Definition file.c:5106
cf_can_save
bool cf_can_save(capture_file *cf)
Definition file.c:5303
cf_get_packet_count
int cf_get_packet_count(capture_file *cf)
Definition file.c:1153
cf_callback_add
void cf_callback_add(cf_callback_t func, void *user_data)
Definition file.c:188
cf_ignore_frame
void cf_ignore_frame(capture_file *cf, frame_data *frame)
Definition file.c:4968
cf_find_packet_time_reference
bool cf_find_packet_time_reference(capture_file *cf, search_direction dir)
Definition file.c:4540
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)
Definition file.c:1464
cf_write_pdml_packets
cf_print_status_t cf_write_pdml_packets(capture_file *cf, print_args_t *print_args)
Definition file.c:2840
cf_write_carrays_packets
cf_print_status_t cf_write_carrays_packets(capture_file *cf, print_args_t *print_args)
Definition file.c:3065
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:5180
cf_set_max_records
void cf_set_max_records(unsigned max_records)
Definition file.c:154
cf_find_string_protocol_tree
field_info * cf_find_string_protocol_tree(capture_file *cf, proto_tree *tree)
Definition file.c:3218
cf_read_record
bool cf_read_record(capture_file *cf, const frame_data *fdata, wtap_rec *rec)
Definition file.c:1604
cf_mark_frame
void cf_mark_frame(capture_file *cf, frame_data *frame)
Definition file.c:4942
cf_unselect_packet
void cf_unselect_packet(capture_file *cf)
Definition file.c:4920
cf_get_computed_elapsed
unsigned long cf_get_computed_elapsed(capture_file *cf)
Definition file.c:219
cf_can_save_as
bool cf_can_save_as(capture_file *cf)
Definition file.c:5342
cf_read_current_record
bool cf_read_current_record(capture_file *cf)
Definition file.c:1631
cf_get_tempfile_source
const char * cf_get_tempfile_source(capture_file *cf)
Definition file.c:1142
cf_set_rfcode
void cf_set_rfcode(capture_file *cf, dfilter_t *rfcode)
Definition file.c:1201
cf_set_drops
void cf_set_drops(capture_file *cf, uint32_t drops)
Definition file.c:1181
cf_find_packet_summary_line
bool cf_find_packet_summary_line(capture_file *cf, const char *string, search_direction dir)
Definition file.c:3449
cf_fake_continue_tail
void cf_fake_continue_tail(capture_file *cf)
cf_write_json_packets
cf_print_status_t cf_write_json_packets(capture_file *cf, print_args_t *print_args)
Definition file.c:3135
cf_set_tempfile
void cf_set_tempfile(capture_file *cf, bool is_tempfile)
Definition file.c:1166
cf_read
cf_read_status_t cf_read(capture_file *cf, bool reloading)
Definition file.c:490
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)
cf_retap_aggregation_packets
void cf_retap_aggregation_packets(capture_file *cf, bool enable)
Definition file.c:2459
cf_get_display_name
char * cf_get_display_name(capture_file *cf)
Definition file.c:1055
cf_is_tempfile
bool cf_is_tempfile(capture_file *cf)
Definition file.c:1160
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:5901
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:251
cf_filter_packets
cf_status_t cf_filter_packets(capture_file *cf, char *dfilter, bool force)
Definition file.c:1500
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)
cf_callback_remove
void cf_callback_remove(cf_callback_t func, void *user_data)
Definition file.c:200
cf_unignore_frame
void cf_unignore_frame(capture_file *cf, frame_data *frame)
Definition file.c:4981
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:3192
cf_can_write_with_wiretap
bool cf_can_write_with_wiretap(capture_file *cf)
Definition file.c:5274
cf_update_section_comment
void cf_update_section_comment(capture_file *cf, char *comment)
Definition file.c:4994
cf_find_packet_dfilter
bool cf_find_packet_dfilter(capture_file *cf, dfilter_t *sfcode, search_direction dir, bool start_current)
Definition file.c:4472
cf_redissect_packets
void cf_redissect_packets(capture_file *cf)
Definition file.c:1578
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:4862
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:5546
cf_find_packet_dfilter_string
bool cf_find_packet_dfilter_string(capture_file *cf, const char *filter, search_direction dir)
Definition file.c:4479
packet_range.h
print.h
_capture_file
Definition cfile.h:71
_proto_node
Definition proto.h:905
epan_dfilter
Definition dfilter-int.h:35
field_info
Definition proto.h:814
fifo_string_cache_t
Definition fifo_string_cache.h:24
match_data
Definition file.h:75
packet_range_tag
Definition packet_range.h:39
print_args_t
Definition file.h:443
print_stream
Definition print_stream.h:43
stream
Definition stream.c:41
wtap_block
Definition wtap_opttypes.h:272
wtap_rec
Definition wtap.h:1512
wtap.h