Wireshark 4.7.3
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
capture_session.h
Go to the documentation of this file.
1
11
12#ifndef __CAPCHILD_CAPTURE_SESSION_H__
13#define __CAPCHILD_CAPTURE_SESSION_H__
14
15#ifndef _WIN32
16#include <sys/types.h>
17#include <stdint.h>
18#endif
19
20#include "ui/capture_opts.h"
21
22#include <epan/fifo_string_cache.h>
23#include <wsutil/processes.h>
24
25#include <epan/cfile.h>
26
27#ifdef __cplusplus
28extern "C" {
29#endif /* __cplusplus */
30
31#ifdef HAVE_LIBPCAP
32/* Current state of capture engine. XXX - differentiate states */
33typedef enum {
34 CAPTURE_STOPPED,
35 CAPTURE_PREPARING,
36 CAPTURE_RUNNING
37} capture_state;
38
39struct _info_data;
40
41/*
42 * State of a capture session.
43 */
45
46/*
47 * Types of callbacks.
48 */
49
53typedef bool (*new_file_fn)(capture_session *cap_session, char *new_file);
54
58typedef void (*new_packets_fn)(capture_session *cap_session, int to_read);
59
63typedef void (*drops_fn)(capture_session *cap_session, uint32_t dropped,
64 const char *interface_name);
65
70typedef void (*message_fn)(capture_session *cap_session, char *error_msg,
71 char *secondary_error_msg);
72
77typedef void (*cfilter_error_fn)(capture_session *cap_session, unsigned i,
78 const char *error_message);
79
83typedef void (*toolbar_control_fn)(capture_session *cap_session,
84 const char *interface_name);
85
90typedef void (*closed_fn)(capture_session *cap_session, char *msg);
91
92/*
93 * The structure for the session.
94 */
95struct _capture_session {
96 ws_process_id fork_child;
97 int fork_child_status;
98 int pipe_input_id;
99#ifdef _WIN32
100 int signal_pipe_write_fd;
101#endif
102 capture_state state;
103#ifndef _WIN32
104 uid_t owner;
105 gid_t group;
106#endif
107 bool session_will_restart;
108 uint64_t count;
109 uint32_t count_pending;
110 capture_options *capture_opts;
111 capture_file *cf;
112 wtap_rec rec;
113 struct wtap *wtap;
114 struct _info_data *cap_data_info;
115
116 // If the user wants to ignore duplicate frames, we need these.
117 fifo_string_cache_t frame_dup_cache;
118 GChecksum *frame_cksum;
119
120 // For storing pending toolbar control messages
121 GQueue toolbar_queue;
122 GMutex toolbar_mutex;
123
124 /*
125 * Routines supplied by our caller; we call them back to notify them
126 * of various events.
127 */
128 new_file_fn new_file;
129 new_packets_fn new_packets;
130 drops_fn drops;
131 message_fn error;
132 cfilter_error_fn cfilter_error;
133 message_fn warning;
134 toolbar_control_fn toolbar;
135 closed_fn closed;
136};
137
138extern void
139capture_session_init(capture_session *cap_session, capture_file *cf,
140 new_file_fn new_file, new_packets_fn new_packets,
141 drops_fn drops, message_fn error,
142 cfilter_error_fn cfilter_error,
143 message_fn warning, toolbar_control_fn toolbar,
144 closed_fn closed);
145
146void capture_process_finished(capture_session *cap_session);
147#else
148
159
160#endif /* HAVE_LIBPCAP */
161
162#ifdef __cplusplus
163}
164#endif /* __cplusplus */
165
166#endif /* __CAPCHILD_CAPTURE_SESSION_H__ */
struct capture_options_tag capture_options
struct _capture_session capture_session
Opaque handle representing an active or pending capture session.
struct _capture_file capture_file
Represents a capture file and its associated metadata.
Opaque handle representing an active or pending capture session.
Definition capture_session.h:156
int dummy
Definition capture_session.h:157
Aggregates packet count statistics and UI state for a live capture info display.
Definition capture_info.h:43
struct wtap_rec wtap_rec
Represents a single capture record read from or written to a capture file, regardless of record type.