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+
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 /* Character set for text search. */
38 /* add EBCDIC when it's implemented */
47 * Packet provider for programs using a capture file.
49 struct packet_provider_data {
50 wtap *wth; /* Wiretap session */
51 const frame_data *ref;
54 frame_data_sequence *frames; /* Sequence of frames, if we're keeping that information */
55 GTree *frames_user_comments; /* BST with user comments for frames (key = frame_data) */
58 typedef struct _capture_file {
60 file_state state; /* Current state of capture file */
61 gchar *filename; /* Name of capture file */
62 gchar *source; /* Temp file source, e.g. "Pipe from elsewhere" */
63 gboolean is_tempfile; /* Is capture file a temporary file? */
64 gboolean unsaved_changes; /* Does the capture file have changes that have not been saved? */
65 gboolean stop_flag; /* Stop current processing (loading, searching, etc.) */
67 gint64 f_datalen; /* Size of capture file data (uncompressed) */
68 guint16 cd_t; /* File type of capture file */
69 unsigned int open_type; /* open_routine index+1 used, if selected, or WTAP_TYPE_AUTO */
70 gboolean iscompressed; /* TRUE if the file is compressed */
71 int lnk_t; /* File link-layer type; could be WTAP_ENCAP_PER_PACKET */
72 GArray *linktypes; /* Array of packet link-layer types */
73 guint32 count; /* Total number of frames */
74 guint64 packet_comment_count; /* Number of comments in frames (could be >1 per frame... */
75 guint32 displayed_count; /* Number of displayed frames */
76 guint32 marked_count; /* Number of marked frames */
77 guint32 ignored_count; /* Number of ignored frames */
78 guint32 ref_time_count; /* Number of time referenced frames */
79 gboolean drops_known; /* TRUE if we know how many packets were dropped */
80 guint32 drops; /* Dropped packets */
81 nstime_t elapsed_time; /* Elapsed time */
82 int snap; /* Maximum captured packet length; 0 if unknown */
83 dfilter_t *rfcode; /* Compiled read filter program */
84 dfilter_t *dfcode; /* Compiled display filter program */
85 gchar *dfilter; /* Display filter string */
86 gboolean redissecting; /* TRUE if currently redissecting (cf_redissect_packets) */
88 gchar *sfilter; /* Filter, hex value, or string being searched */
89 gboolean hex; /* TRUE if "Hex value" search was last selected */
90 gboolean string; /* TRUE if "String" search was last selected */
91 gboolean summary_data; /* TRUE if "String" search in "Packet list" (Info column) was last selected */
92 gboolean decode_data; /* TRUE if "String" search in "Packet details" was last selected */
93 gboolean packet_data; /* TRUE if "String" search in "Packet data" was last selected */
94 guint32 search_pos; /* Byte position of last byte found in a hex search */
95 guint32 search_len; /* Length of bytes matching the search */
96 gboolean case_type; /* TRUE if case-insensitive text search */
97 GRegex *regex; /* Set if regular expression search */
98 search_charset_t scs_type; /* Character set for text search */
99 search_direction dir; /* Direction in which to do searches */
100 gboolean search_in_progress; /* TRUE if user just clicked OK in the Find dialog or hit <control>N/B */
102 struct wtap_pkthdr phdr; /* Packet header */
103 Buffer buf; /* Packet data */
104 /* packet provider */
105 struct packet_provider_data provider;
107 guint32 first_displayed; /* Frame number of first frame displayed */
108 guint32 last_displayed; /* Frame number of last frame displayed */
109 column_info cinfo; /* Column formatting information */
110 gboolean columns_changed; /**< Have the columns been changed in the prefs? (GTK+ only) */
111 frame_data *current_frame; /* Frame data for current frame */
112 gint current_row; /* Row number for current frame */
113 epan_dissect_t *edt; /* Protocol dissection for currently selected packet */
114 field_info *finfo_selected; /* Field info for currently selected field */
115 gpointer window; /* Top-level window associated with file */
116 gulong computed_elapsed; /* Elapsed time to load the file (in msec). */
121 extern void cap_file_init(capture_file *cf);
123 const char *cap_file_provider_get_interface_name(struct packet_provider_data *prov, guint32 interface_id);
124 const char *cap_file_provider_get_interface_description(struct packet_provider_data *prov, guint32 interface_id);
125 const char *cap_file_provider_get_user_comment(struct packet_provider_data *prov, const frame_data *fd);
126 void cap_file_provider_set_user_comment(struct packet_provider_data *prov, frame_data *fd, const char *new_comment);
130 #endif /* __cplusplus */
135 * Editor modelines - http://www.wireshark.org/tools/modelines.html
140 * indent-tabs-mode: nil
143 * vi: set shiftwidth=2 tabstop=8 expandtab:
144 * :indentSize=2:tabSize=8:noTabs=true: