checkAPIs.pl: support for new-style dissectors in check_hf_entries
[metze/wireshark/wip.git] / ui / capture.h
1 /* capture.h
2  * Definitions for packet capture windows
3  *
4  * Wireshark - Network traffic analyzer
5  * By Gerald Combs <gerald@wireshark.org>
6  * Copyright 1998 Gerald Combs
7  *
8  * SPDX-License-Identifier: GPL-2.0-or-later
9  */
10
11 /* This file should only be included if libpcap is present */
12
13 #ifndef __CAPTURE_H__
14 #define __CAPTURE_H__
15
16 /** @file
17  *  Capture related things.
18  */
19
20 #include "capture_opts.h"
21 #include "capture_info.h"
22 #include "capchild/capture_session.h"
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif /* __cplusplus */
27
28 typedef enum {
29     capture_cb_capture_prepared,
30     capture_cb_capture_update_started,
31     capture_cb_capture_update_continue,
32     capture_cb_capture_update_finished,
33     capture_cb_capture_fixed_started,
34     capture_cb_capture_fixed_continue,
35     capture_cb_capture_fixed_finished,
36     capture_cb_capture_stopping,
37     capture_cb_capture_failed
38 } capture_cbs;
39
40 typedef void (*capture_callback_t) (gint event, capture_session *cap_session,
41                                     gpointer user_data);
42
43 extern void
44 capture_callback_add(capture_callback_t func, gpointer user_data);
45
46 extern void
47 capture_callback_remove(capture_callback_t func, gpointer user_data);
48
49 /**
50  * Start a capture session.
51  *
52  * @param capture_opts the numerous capture options
53  * @param cap_session a handle for the capture session
54  * @param cap_data a struct with capture info data
55  * @param update_cb update screen
56  * @return TRUE if the capture starts successfully, FALSE otherwise.
57  */
58 extern gboolean
59 capture_start(capture_options *capture_opts, capture_session *cap_session, info_data_t* cap_data, void(*update_cb)(void));
60
61 /** Stop a capture session (usually from a menu item). */
62 extern void
63 capture_stop(capture_session *cap_session);
64
65 /** Restart the current captured packets and start again. */
66 extern void
67 capture_restart(capture_session *cap_session);
68
69 /** Terminate the capture child cleanly when exiting. */
70 extern void
71 capture_kill_child(capture_session *cap_session);
72
73 struct if_stat_cache_s;
74 typedef struct if_stat_cache_s if_stat_cache_t;
75
76 /**
77  * Start gathering capture statistics for the interfaces specified.
78  * @param capture_opts A structure containing options for the capture.
79  * @return A pointer to the statistics state data.
80  */
81 extern if_stat_cache_t * capture_stat_start(capture_options *capture_opts);
82
83 /**
84  * Fetch capture statistics, similar to pcap_stats().
85  */
86 struct pcap_stat; /* Stub in case we don't or haven't yet included pcap.h */
87 extern gboolean capture_stats(if_stat_cache_t *sc, char *ifname, struct pcap_stat *ps);
88
89 /**
90  * Stop gathering capture statistics.
91  */
92 void capture_stat_stop(if_stat_cache_t *sc);
93
94 #ifdef __cplusplus
95 }
96 #endif /* __cplusplus */
97
98 #endif /* capture.h */
99
100 /*
101  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
102  *
103  * Local Variables:
104  * c-basic-offset: 4
105  * tab-width: 8
106  * indent-tabs-mode: nil
107  * End:
108  *
109  * vi: set shiftwidth=4 tabstop=8 expandtab:
110  * :indentSize=4:tabSize=8:noTabs=true:
111  */