2004-10-30 11:44:06 +00:00
|
|
|
/* capture_sync.h
|
2006-05-28 20:28:20 +00:00
|
|
|
* Synchronisation between Wireshark capture parent and child instances
|
2004-10-30 11:44:06 +00:00
|
|
|
*
|
2006-05-21 05:12:17 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2004-10-30 11:44:06 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2012-06-28 22:56:06 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2004-10-30 11:44:06 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/** @file
|
2007-06-11 03:58:58 +00:00
|
|
|
*
|
2004-10-30 11:44:06 +00:00
|
|
|
* Sync mode capture (internal interface).
|
|
|
|
*
|
2007-06-11 03:58:58 +00:00
|
|
|
* Will start a new Wireshark child instance which will do the actual capture
|
2005-04-11 18:57:19 +00:00
|
|
|
* work.
|
2004-10-30 11:44:06 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __CAPTURE_SYNC_H__
|
|
|
|
#define __CAPTURE_SYNC_H__
|
|
|
|
|
2015-06-11 22:05:44 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
2015-12-17 04:15:03 +00:00
|
|
|
struct _info_data;
|
|
|
|
|
2007-06-11 03:58:58 +00:00
|
|
|
/**
|
2005-03-28 18:04:09 +00:00
|
|
|
* Start a new capture session.
|
2004-10-30 11:44:06 +00:00
|
|
|
* Create a capture child which is doing the real capture work.
|
2007-06-11 03:58:58 +00:00
|
|
|
* The various capture_input_... functions will be called, if something had
|
2005-04-11 18:57:19 +00:00
|
|
|
* happened.
|
2004-10-30 11:44:06 +00:00
|
|
|
*
|
|
|
|
* Most of the parameters are passed through the global capture_opts.
|
|
|
|
*
|
2005-03-28 18:04:09 +00:00
|
|
|
* @param capture_opts the options
|
2013-05-22 07:44:28 +00:00
|
|
|
* @param cap_session a handle for the capture session
|
2016-01-26 08:24:30 +00:00
|
|
|
* @param cap_data a struct with capture info data
|
2013-12-15 19:07:26 +00:00
|
|
|
* @param update_cb update screen
|
2004-10-30 11:44:06 +00:00
|
|
|
* @return TRUE if a capture could be started, FALSE if not
|
|
|
|
*/
|
2007-06-11 03:58:58 +00:00
|
|
|
extern gboolean
|
2015-12-17 04:15:03 +00:00
|
|
|
sync_pipe_start(capture_options *capture_opts, capture_session *cap_session, struct _info_data* cap_data, void(*update_cb)(void));
|
2004-10-30 11:44:06 +00:00
|
|
|
|
|
|
|
/** User wants to stop capturing, gracefully close the capture child */
|
|
|
|
extern void
|
2013-05-22 07:44:28 +00:00
|
|
|
sync_pipe_stop(capture_session *cap_session);
|
2004-10-30 11:44:06 +00:00
|
|
|
|
2005-03-28 18:04:09 +00:00
|
|
|
/** User wants to stop the program, just kill the child as soon as possible */
|
2004-10-30 11:44:06 +00:00
|
|
|
extern void
|
2015-06-10 00:30:15 +00:00
|
|
|
sync_pipe_kill(ws_process_id fork_child);
|
2004-10-30 11:44:06 +00:00
|
|
|
|
2016-09-14 12:13:20 +00:00
|
|
|
/**
|
|
|
|
* Set wireless channel using dumpcap
|
|
|
|
* On success, *data points to a buffer containing the dumpcap output,
|
|
|
|
* *primary_msg and *secondary_msg are NULL, and 0 is returned. *data
|
|
|
|
* must be freed with g_free().
|
|
|
|
*
|
|
|
|
* On failure, *data is NULL, *primary_msg points to an error message,
|
|
|
|
* *secondary_msg either points to an additional error message or is
|
|
|
|
* NULL, and -1 or errno value is returned; *primary_msg, and
|
|
|
|
* *secondary_msg if not NULL must be freed with g_free().
|
|
|
|
*
|
|
|
|
* @param iface (monitor) network interface name
|
|
|
|
* @param freq channel control frequency string (in MHz)
|
|
|
|
* @param type channel type string (or NULL if not used)
|
|
|
|
* @param center_freq1 VHT channel center frequency (or NULL if not used)
|
|
|
|
* @param center_freq2 VHT channel center frequency 2 (or NULL if not used)
|
|
|
|
* @return 0 on success
|
|
|
|
*/
|
2012-06-20 18:42:45 +00:00
|
|
|
extern int
|
2012-12-29 20:56:11 +00:00
|
|
|
sync_interface_set_80211_chan(const gchar *iface, const char *freq, const gchar *type,
|
2016-02-06 23:40:51 +00:00
|
|
|
const gchar *center_freq1, const gchar *center_freq2,
|
2012-06-20 18:42:45 +00:00
|
|
|
gchar **data, gchar **primary_msg,
|
2013-06-27 17:10:50 +00:00
|
|
|
gchar **secondary_msg, void (*update_cb)(void));
|
2012-06-20 18:42:45 +00:00
|
|
|
|
2007-06-11 03:58:58 +00:00
|
|
|
/** Get an interface list using dumpcap */
|
|
|
|
extern int
|
2010-05-17 18:40:23 +00:00
|
|
|
sync_interface_list_open(gchar **data, gchar **primary_msg,
|
2013-06-27 17:10:50 +00:00
|
|
|
gchar **secondary_msg, void (*update_cb)(void));
|
2007-06-11 03:58:58 +00:00
|
|
|
|
2010-05-13 17:37:39 +00:00
|
|
|
/** Get interface capabilities using dumpcap */
|
2007-07-20 21:43:07 +00:00
|
|
|
extern int
|
2015-07-17 15:01:27 +00:00
|
|
|
sync_if_capabilities_open(const gchar *ifname, gboolean monitor_mode, const gchar* auth,
|
2010-05-17 18:40:23 +00:00
|
|
|
gchar **data, gchar **primary_msg,
|
2013-06-27 17:10:50 +00:00
|
|
|
gchar **secondary_msg, void (*update_cb)(void));
|
2007-06-11 03:58:58 +00:00
|
|
|
|
2007-08-02 21:45:27 +00:00
|
|
|
/** Start getting interface statistics using dumpcap. */
|
|
|
|
extern int
|
2015-06-10 00:30:15 +00:00
|
|
|
sync_interface_stats_open(int *read_fd, ws_process_id *fork_child, gchar **msg, void (*update_cb)(void));
|
2007-08-02 21:45:27 +00:00
|
|
|
|
|
|
|
/** Stop gathering statistics. */
|
|
|
|
extern int
|
2015-06-10 00:30:15 +00:00
|
|
|
sync_interface_stats_close(int *read_fd, ws_process_id *fork_child, gchar **msg);
|
2007-08-02 21:45:27 +00:00
|
|
|
|
|
|
|
/** Read a line from a pipe, similar to fgets. Non-blocking. */
|
|
|
|
extern int
|
2008-06-23 21:27:37 +00:00
|
|
|
sync_pipe_gets_nonblock(int pipe_fd, char *bytes, int max);
|
2007-08-02 21:45:27 +00:00
|
|
|
|
2013-05-22 19:14:52 +00:00
|
|
|
/*
|
|
|
|
* Routines supplied by our caller; we call them back to notify them
|
|
|
|
* of various events.
|
|
|
|
*
|
|
|
|
* XXX - this is *really* ugly. We should do this better.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Capture child told us we have a new (or the first) capture file.
|
|
|
|
*/
|
|
|
|
extern gboolean
|
|
|
|
capture_input_new_file(capture_session *cap_session, gchar *new_file);
|
|
|
|
|
|
|
|
/**
|
2014-05-23 10:50:02 +00:00
|
|
|
* Capture child told us we have new packets to read.
|
2013-05-22 19:14:52 +00:00
|
|
|
*/
|
|
|
|
extern void
|
2014-05-23 10:50:02 +00:00
|
|
|
capture_input_new_packets(capture_session *cap_session, int to_read);
|
2013-05-22 19:14:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Capture child told us how many dropped packets it counted.
|
|
|
|
*/
|
|
|
|
extern void
|
|
|
|
capture_input_drops(capture_session *cap_session, guint32 dropped);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Capture child told us that an error has occurred while starting the capture.
|
|
|
|
*/
|
|
|
|
extern void
|
|
|
|
capture_input_error_message(capture_session *cap_session, char *error_message,
|
|
|
|
char *secondary_error_msg);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Capture child told us that an error has occurred while parsing a
|
|
|
|
* capture filter when starting/running the capture.
|
|
|
|
*/
|
|
|
|
extern void
|
|
|
|
capture_input_cfilter_error_message(capture_session *cap_session, guint i,
|
|
|
|
char *error_message);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Capture child closed its side of the pipe, report any error and
|
|
|
|
* do the required cleanup.
|
|
|
|
*/
|
|
|
|
extern void
|
|
|
|
capture_input_closed(capture_session *cap_session, gchar *msg);
|
2007-08-02 21:45:27 +00:00
|
|
|
|
2013-06-27 19:00:01 +00:00
|
|
|
/* set a callback to be called after fork with the pid of the forked child */
|
2015-06-10 00:55:03 +00:00
|
|
|
extern void capture_sync_set_fetch_dumpcap_pid_cb(void(*cb)(ws_process_id pid));
|
2013-06-27 19:00:01 +00:00
|
|
|
|
2015-06-11 22:05:44 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
|
|
#endif /* __CAPTURE_SYNC_H__ */
|