packet-smb: register a dissector on top of smb_direct
[metze/wireshark/wip.git] / capture_sync.h
1 /* capture_sync.h
2  * Synchronisation between Wireshark capture parent and child instances
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
26 /** @file
27  *
28  *  Sync mode capture (internal interface).
29  *
30  *  Will start a new Wireshark child instance which will do the actual capture
31  *  work.
32  */
33
34 #ifndef __CAPTURE_SYNC_H__
35 #define __CAPTURE_SYNC_H__
36
37 /**
38  * Start a new capture session.
39  *  Create a capture child which is doing the real capture work.
40  *  The various capture_input_... functions will be called, if something had
41  *  happened.
42  *
43  *  Most of the parameters are passed through the global capture_opts.
44  *
45  *  @param capture_opts the options
46  *  @param cap_session a handle for the capture session
47  *  @param update_cb update screen
48  *  @return             TRUE if a capture could be started, FALSE if not
49  */
50 extern gboolean
51 sync_pipe_start(capture_options *capture_opts, capture_session *cap_session, void(*update_cb)(void));
52
53 /** User wants to stop capturing, gracefully close the capture child */
54 extern void
55 sync_pipe_stop(capture_session *cap_session);
56
57 /** User wants to stop the program, just kill the child as soon as possible */
58 extern void
59 sync_pipe_kill(int fork_child);
60
61 /** Set wireless channel using dumpcap */
62 extern int
63 sync_interface_set_80211_chan(const gchar *iface, const char *freq, const gchar *type,
64                               gchar **data, gchar **primary_msg,
65                               gchar **secondary_msg, void (*update_cb)(void));
66
67 /** Get an interface list using dumpcap */
68 extern int
69 sync_interface_list_open(gchar **data, gchar **primary_msg,
70                          gchar **secondary_msg, void (*update_cb)(void));
71
72 /** Get interface capabilities using dumpcap */
73 extern int
74 sync_if_capabilities_open(const gchar *ifname, gboolean monitor_mode,
75                           gchar **data, gchar **primary_msg,
76                           gchar **secondary_msg, void (*update_cb)(void));
77
78 /** Start getting interface statistics using dumpcap. */
79 extern int
80 sync_interface_stats_open(int *read_fd, int *fork_child, gchar **msg, void (*update_cb)(void));
81
82 /** Stop gathering statistics. */
83 extern int
84 sync_interface_stats_close(int *read_fd, int *fork_child, gchar **msg);
85
86 /** Read a line from a pipe, similar to fgets.  Non-blocking. */
87 extern int
88 sync_pipe_gets_nonblock(int pipe_fd, char *bytes, int max);
89
90 /*
91  * Routines supplied by our caller; we call them back to notify them
92  * of various events.
93  *
94  * XXX - this is *really* ugly.  We should do this better.
95  */
96
97 /**
98  * Capture child told us we have a new (or the first) capture file.
99  */
100 extern gboolean
101 capture_input_new_file(capture_session *cap_session, gchar *new_file);
102
103 /**
104  * Capture child told us we have new packets to read.
105  */
106 extern void
107 capture_input_new_packets(capture_session *cap_session, int to_read);
108
109 /**
110  * Capture child told us how many dropped packets it counted.
111  */
112 extern void
113 capture_input_drops(capture_session *cap_session, guint32 dropped);
114
115 /**
116  * Capture child told us that an error has occurred while starting the capture.
117  */
118 extern void
119 capture_input_error_message(capture_session *cap_session, char *error_message,
120                             char *secondary_error_msg);
121
122 /**
123  * Capture child told us that an error has occurred while parsing a
124  * capture filter when starting/running the capture.
125  */
126 extern void
127 capture_input_cfilter_error_message(capture_session *cap_session, guint i,
128                                     char *error_message);
129
130 /**
131  * Capture child closed its side of the pipe, report any error and
132  * do the required cleanup.
133  */
134 extern void
135 capture_input_closed(capture_session *cap_session, gchar *msg);
136
137 /* set a callback to be called after fork with the pid of the forked child */
138 extern void capture_sync_set_fetch_dumpcap_pid_cb(void(*cb)(int pid));
139
140 #endif /* capture_sync.h */