tshark: endpoints statistics are not supported for now, do not list them in -z
[metze/wireshark/wip.git] / capchild / capture_sync.h
1 /* capture_sync.h
2  * Synchronisation between Wireshark capture parent and child instances
3  *
4  * Wireshark - Network traffic analyzer
5  * By Gerald Combs <gerald@wireshark.org>
6  * Copyright 1998 Gerald Combs
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22
23
24 /** @file
25  *
26  *  Sync mode capture (internal interface).
27  *
28  *  Will start a new Wireshark child instance which will do the actual capture
29  *  work.
30  */
31
32 #ifndef __CAPTURE_SYNC_H__
33 #define __CAPTURE_SYNC_H__
34
35 /**
36  * Start a new capture session.
37  *  Create a capture child which is doing the real capture work.
38  *  The various capture_input_... functions will be called, if something had
39  *  happened.
40  *
41  *  Most of the parameters are passed through the global capture_opts.
42  *
43  *  @param capture_opts the options
44  *  @param cap_session a handle for the capture session
45  *  @param update_cb update screen
46  *  @return             TRUE if a capture could be started, FALSE if not
47  */
48 extern gboolean
49 sync_pipe_start(capture_options *capture_opts, capture_session *cap_session, void(*update_cb)(void));
50
51 /** User wants to stop capturing, gracefully close the capture child */
52 extern void
53 sync_pipe_stop(capture_session *cap_session);
54
55 /** User wants to stop the program, just kill the child as soon as possible */
56 extern void
57 sync_pipe_kill(int fork_child);
58
59 /** Set wireless channel using dumpcap */
60 extern int
61 sync_interface_set_80211_chan(const gchar *iface, const char *freq, const gchar *type,
62                               gchar **data, gchar **primary_msg,
63                               gchar **secondary_msg, void (*update_cb)(void));
64
65 /** Get an interface list using dumpcap */
66 extern int
67 sync_interface_list_open(gchar **data, gchar **primary_msg,
68                          gchar **secondary_msg, void (*update_cb)(void));
69
70 /** Get interface capabilities using dumpcap */
71 extern int
72 sync_if_capabilities_open(const gchar *ifname, gboolean monitor_mode,
73                           gchar **data, gchar **primary_msg,
74                           gchar **secondary_msg, void (*update_cb)(void));
75
76 /** Start getting interface statistics using dumpcap. */
77 extern int
78 sync_interface_stats_open(int *read_fd, int *fork_child, gchar **msg, void (*update_cb)(void));
79
80 /** Stop gathering statistics. */
81 extern int
82 sync_interface_stats_close(int *read_fd, int *fork_child, gchar **msg);
83
84 /** Read a line from a pipe, similar to fgets.  Non-blocking. */
85 extern int
86 sync_pipe_gets_nonblock(int pipe_fd, char *bytes, int max);
87
88 /*
89  * Routines supplied by our caller; we call them back to notify them
90  * of various events.
91  *
92  * XXX - this is *really* ugly.  We should do this better.
93  */
94
95 /**
96  * Capture child told us we have a new (or the first) capture file.
97  */
98 extern gboolean
99 capture_input_new_file(capture_session *cap_session, gchar *new_file);
100
101 /**
102  * Capture child told us we have new packets to read.
103  */
104 extern void
105 capture_input_new_packets(capture_session *cap_session, int to_read);
106
107 /**
108  * Capture child told us how many dropped packets it counted.
109  */
110 extern void
111 capture_input_drops(capture_session *cap_session, guint32 dropped);
112
113 /**
114  * Capture child told us that an error has occurred while starting the capture.
115  */
116 extern void
117 capture_input_error_message(capture_session *cap_session, char *error_message,
118                             char *secondary_error_msg);
119
120 /**
121  * Capture child told us that an error has occurred while parsing a
122  * capture filter when starting/running the capture.
123  */
124 extern void
125 capture_input_cfilter_error_message(capture_session *cap_session, guint i,
126                                     char *error_message);
127
128 /**
129  * Capture child closed its side of the pipe, report any error and
130  * do the required cleanup.
131  */
132 extern void
133 capture_input_closed(capture_session *cap_session, gchar *msg);
134
135 /* set a callback to be called after fork with the pid of the forked child */
136 extern void capture_sync_set_fetch_dumpcap_pid_cb(void(*cb)(int pid));
137
138 #endif /* capture_sync.h */