2 * capture_file definition & GUI-independent manipulation
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
8 * SPDX-License-Identifier: GPL-2.0-or-later
14 #include <epan/epan.h>
15 #include <epan/column-info.h>
16 #include <epan/dfilter/dfilter.h>
17 #include <epan/frame_data.h>
18 #include <epan/frame_data_sequence.h>
19 #include <wiretap/wtap.h>
23 #endif /* __cplusplus */
25 /* Current state of file. */
27 FILE_CLOSED, /* No file open */
28 FILE_READ_IN_PROGRESS, /* Reading a file we've opened */
29 FILE_READ_ABORTED, /* Read aborted by user */
30 FILE_READ_DONE /* Read completed */
33 /* Requested packets rescan action. */
35 RESCAN_NONE = 0, /* No rescan requested */
36 RESCAN_SCAN, /* Request rescan without full redissection. */
37 RESCAN_REDISSECT /* Request full redissection. */
40 /* Character set for text search. */
45 /* add EBCDIC when it's implemented */
54 * Packet provider for programs using a capture file.
56 struct packet_provider_data {
57 wtap *wth; /* Wiretap session */
58 const frame_data *ref;
61 frame_data_sequence *frames; /* Sequence of frames, if we're keeping that information */
62 GTree *frames_user_comments; /* BST with user comments for frames (key = frame_data) */
65 typedef struct _capture_file {
67 file_state state; /* Current state of capture file */
68 gchar *filename; /* Name of capture file */
69 gchar *source; /* Temp file source, e.g. "Pipe from elsewhere" */
70 gboolean is_tempfile; /* Is capture file a temporary file? */
71 gboolean unsaved_changes; /* Does the capture file have changes that have not been saved? */
72 gboolean stop_flag; /* Stop current processing (loading, searching, etc.) */
74 gint64 f_datalen; /* Size of capture file data (uncompressed) */
75 guint16 cd_t; /* File type of capture file */
76 unsigned int open_type; /* open_routine index+1 used, if selected, or WTAP_TYPE_AUTO */
77 gboolean iscompressed; /* TRUE if the file is compressed */
78 int lnk_t; /* File link-layer type; could be WTAP_ENCAP_PER_PACKET */
79 GArray *linktypes; /* Array of packet link-layer types */
80 guint32 count; /* Total number of frames */
81 guint64 packet_comment_count; /* Number of comments in frames (could be >1 per frame... */
82 guint32 displayed_count; /* Number of displayed frames */
83 guint32 marked_count; /* Number of marked frames */
84 guint32 ignored_count; /* Number of ignored frames */
85 guint32 ref_time_count; /* Number of time referenced frames */
86 gboolean drops_known; /* TRUE if we know how many packets were dropped */
87 guint32 drops; /* Dropped packets */
88 nstime_t elapsed_time; /* Elapsed time */
89 int snap; /* Maximum captured packet length; 0 if unknown */
90 dfilter_t *rfcode; /* Compiled read filter program */
91 dfilter_t *dfcode; /* Compiled display filter program */
92 gchar *dfilter; /* Display filter string */
93 gboolean redissecting; /* TRUE if currently redissecting (cf_redissect_packets) */
94 gboolean read_lock; /* TRUE if currently processing a file (cf_read) */
95 rescan_type redissection_queued; /* Queued redissection type. */
97 gchar *sfilter; /* Filter, hex value, or string being searched */
98 gboolean hex; /* TRUE if "Hex value" search was last selected */
99 gboolean string; /* TRUE if "String" search was last selected */
100 gboolean summary_data; /* TRUE if "String" search in "Packet list" (Info column) was last selected */
101 gboolean decode_data; /* TRUE if "String" search in "Packet details" was last selected */
102 gboolean packet_data; /* TRUE if "String" search in "Packet data" was last selected */
103 guint32 search_pos; /* Byte position of last byte found in a hex search */
104 guint32 search_len; /* Length of bytes matching the search */
105 gboolean case_type; /* TRUE if case-insensitive text search */
106 GRegex *regex; /* Set if regular expression search */
107 search_charset_t scs_type; /* Character set for text search */
108 search_direction dir; /* Direction in which to do searches */
109 gboolean search_in_progress; /* TRUE if user just clicked OK in the Find dialog or hit <control>N/B */
111 wtap_rec rec; /* Record header */
112 Buffer buf; /* Record data */
113 /* packet provider */
114 struct packet_provider_data provider;
116 guint32 first_displayed; /* Frame number of first frame displayed */
117 guint32 last_displayed; /* Frame number of last frame displayed */
118 column_info cinfo; /* Column formatting information */
119 frame_data *current_frame; /* Frame data for current frame */
120 gint current_row; /* Row number for current frame */
121 epan_dissect_t *edt; /* Protocol dissection for currently selected packet */
122 field_info *finfo_selected; /* Field info for currently selected field */
123 gpointer window; /* Top-level window associated with file */
124 gulong computed_elapsed; /* Elapsed time to load the file (in msec). */
129 extern void cap_file_init(capture_file *cf);
131 const char *cap_file_provider_get_interface_name(struct packet_provider_data *prov, guint32 interface_id);
132 const char *cap_file_provider_get_interface_description(struct packet_provider_data *prov, guint32 interface_id);
133 const char *cap_file_provider_get_user_comment(struct packet_provider_data *prov, const frame_data *fd);
134 void cap_file_provider_set_user_comment(struct packet_provider_data *prov, frame_data *fd, const char *new_comment);
138 #endif /* __cplusplus */
143 * Editor modelines - http://www.wireshark.org/tools/modelines.html
148 * indent-tabs-mode: nil
151 * vi: set shiftwidth=2 tabstop=8 expandtab:
152 * :indentSize=2:tabSize=8:noTabs=true: