From Chris Pane:
[metze/wireshark/wip.git] / capture.h
1 /* capture.h
2  * Definitions for packet capture windows
3  *
4  * $Id$
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  */
24
25 /* This file should only be included if libpcap is present */
26
27 #ifndef __CAPTURE_H__
28 #define __CAPTURE_H__
29
30 /** @file
31  *  Capture related things.
32  */
33
34 #include "capture_opts.h"
35 #include "capture_session.h"
36
37 #ifdef __cplusplus
38 extern "C" {
39 #endif /* __cplusplus */
40
41 typedef enum {
42     capture_cb_capture_prepared,
43     capture_cb_capture_update_started,
44     capture_cb_capture_update_continue,
45     capture_cb_capture_update_finished,
46     capture_cb_capture_fixed_started,
47     capture_cb_capture_fixed_continue,
48     capture_cb_capture_fixed_finished,
49     capture_cb_capture_stopping,
50     capture_cb_capture_failed
51 } capture_cbs;
52
53 typedef void (*capture_callback_t) (gint event, capture_session *cap_session,
54                                     gpointer user_data);
55
56 extern void
57 capture_callback_add(capture_callback_t func, gpointer user_data);
58
59 extern void
60 capture_callback_remove(capture_callback_t func);
61
62 /**
63  * Start a capture session.
64  *
65  * @param capture_opts the numerous capture options
66  * @return TRUE if the capture starts successfully, FALSE otherwise.
67  */
68 extern gboolean
69 capture_start(capture_options *capture_opts, capture_session *cap_session);
70
71 /** Stop a capture session (usually from a menu item). */
72 extern void
73 capture_stop(capture_session *cap_session);
74
75 /** Restart the current captured packets and start again. */
76 extern void
77 capture_restart(capture_session *cap_session);
78
79 /** Terminate the capture child cleanly when exiting. */
80 extern void
81 capture_kill_child(capture_session *cap_session);
82
83 struct if_stat_cache_s;
84 typedef struct if_stat_cache_s if_stat_cache_t;
85
86 /**
87  * Start gathering capture statistics for the interfaces specified.
88  * @param capture_opts A structure containing options for the capture.
89  * @return A pointer to the statistics state data.
90  */
91 extern if_stat_cache_t * capture_stat_start(capture_options *capture_opts);
92
93 /**
94  * Fetch capture statistics, similar to pcap_stats().
95  */
96 struct pcap_stat; /* Stub in case we don't or haven't yet included pcap.h */
97 extern gboolean capture_stats(if_stat_cache_t *sc, char *ifname, struct pcap_stat *ps);
98
99 /**
100  * Stop gathering capture statistics.
101  */
102 void capture_stat_stop(if_stat_cache_t *sc);
103
104 #ifdef __cplusplus
105 }
106 #endif /* __cplusplus */
107
108 #endif /* capture.h */