| Wireshark 4.7.0 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
capture_session.h
Go to the documentation of this file.
1
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 "cfile.h"
26
27#ifdef __cplusplus
28 extern "C" {
29#endif /* __cplusplus */
30
31#ifdef HAVE_LIBPCAP
32/* Current state of capture engine. XXX - differentiate states */
33 typedef enum {
34 CAPTURE_STOPPED,
35 CAPTURE_PREPARING,
36 CAPTURE_RUNNING
37} capture_state;
38
39 struct _info_data;
40
41/*
42 * State of a capture session.
43 */
44 typedef struct _capture_session capture_session;
45
46/*
47 * Types of callbacks.
48 */
49
53 typedef bool (*new_file_fn)(capture_session *cap_session, char *new_file);
54
58 typedef void (*new_packets_fn)(capture_session *cap_session, int to_read);
59
63 typedef void (*drops_fn)(capture_session *cap_session, uint32_t dropped,
64 const char *interface_name);
65
70 typedef void (*error_fn)(capture_session *cap_session, char *error_msg,
71 char *secondary_error_msg);
72
77 typedef void (*cfilter_error_fn)(capture_session *cap_session, unsigned i,
78 const char *error_message);
79
84 typedef void (*closed_fn)(capture_session *cap_session, char *msg);
85
86/*
87 * The structure for the session.
88 */
89 struct _capture_session {
90 ws_process_id fork_child;
91 int fork_child_status;
92 int pipe_input_id;
93#ifdef _WIN32
94 int signal_pipe_write_fd;
95#endif
96 capture_state state;
97#ifndef _WIN32
98 uid_t owner;
99 gid_t group;
100#endif
101 bool session_will_restart;
102 uint64_t count;
103 uint32_t count_pending;
104 capture_options *capture_opts;
105 capture_file *cf;
106 wtap_rec rec;
107 struct wtap *wtap;
108 struct _info_data *cap_data_info;
110 // If the user wants to ignore duplicate frames, we need these.
111 fifo_string_cache_t frame_dup_cache;
112 GChecksum *frame_cksum;
113
114 /*
115 * Routines supplied by our caller; we call them back to notify them
116 * of various events.
117 */
118 new_file_fn new_file;
119 new_packets_fn new_packets;
120 drops_fn drops;
121 error_fn error;
122 cfilter_error_fn cfilter_error;
123 closed_fn closed;
124};
125
126 extern void
127capture_session_init(capture_session *cap_session, capture_file *cf,
128 new_file_fn new_file, new_packets_fn new_packets,
129 drops_fn drops, error_fn error,
130 cfilter_error_fn cfilter_error, closed_fn closed);
131
132 void capture_process_finished(capture_session *cap_session);
133#else
134
135/* dummy is needed because clang throws the error: empty struct has size 0 in C, size 1 in C++ */
136 typedef struct _capture_session {int dummy;} capture_session;
137
138#endif /* HAVE_LIBPCAP */
139
140#ifdef __cplusplus
141}
142#endif /* __cplusplus */
143
144#endif /* __CAPCHILD_CAPTURE_SESSION_H__ */
capture_opts.h
cfile.h
processes.h
_capture_file
Definition cfile.h:67
_capture_session
Definition capture_session.h:136
_info_data
Definition capture_info.h:40
capture_options_tag
Definition capture_opts.h:236
fifo_string_cache_t
Definition fifo_string_cache.h:24
wtap_rec
Definition wtap.h:1512
wtap
Definition wtap_module.h:58