2013-05-22 07:51:15 +00:00
|
|
|
/* capture_session.h
|
|
|
|
* State of a capture session
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
2018-04-30 07:47:58 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2013-05-22 07:51:15 +00:00
|
|
|
|
2014-06-30 05:08:59 +00:00
|
|
|
#ifndef __CAPCHILD_CAPTURE_SESSION_H__
|
|
|
|
#define __CAPCHILD_CAPTURE_SESSION_H__
|
2013-05-22 07:51:15 +00:00
|
|
|
|
2013-05-22 11:53:36 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
2014-06-24 09:36:51 +00:00
|
|
|
#ifndef _WIN32
|
|
|
|
#include <sys/types.h>
|
2015-06-09 08:13:29 +00:00
|
|
|
#include <stdint.h>
|
2014-06-24 09:36:51 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "capture_opts.h"
|
|
|
|
|
2015-06-10 01:54:54 +00:00
|
|
|
#include <wsutil/processes.h>
|
2015-06-10 00:30:15 +00:00
|
|
|
|
2013-10-11 21:26:26 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
2013-05-22 07:51:15 +00:00
|
|
|
/* Current state of capture engine. XXX - differentiate states */
|
|
|
|
typedef enum {
|
|
|
|
CAPTURE_STOPPED, /**< stopped */
|
|
|
|
CAPTURE_PREPARING, /**< preparing, but still no response from capture child */
|
|
|
|
CAPTURE_RUNNING /**< capture child signalled ok, capture is running now */
|
|
|
|
} capture_state;
|
|
|
|
|
2017-12-03 18:53:58 +00:00
|
|
|
#include "cfile.h"
|
2015-12-17 04:15:03 +00:00
|
|
|
struct _info_data;
|
2013-05-22 07:51:15 +00:00
|
|
|
/*
|
|
|
|
* State of a capture session.
|
|
|
|
*/
|
2014-09-09 20:42:58 +00:00
|
|
|
typedef struct _capture_session {
|
2017-02-08 02:21:00 +00:00
|
|
|
ws_process_id fork_child; /**< If not WS_INVALID_PID, in parent, process ID of child */
|
2015-06-09 08:13:29 +00:00
|
|
|
int fork_child_status; /**< Child exit status */
|
2013-05-22 07:51:15 +00:00
|
|
|
#ifdef _WIN32
|
2015-06-09 08:13:29 +00:00
|
|
|
int signal_pipe_write_fd; /**< the pipe to signal the child */
|
2013-05-22 07:51:15 +00:00
|
|
|
#endif
|
2015-06-10 00:30:15 +00:00
|
|
|
capture_state state; /**< current state of the capture engine */
|
2013-05-22 07:51:15 +00:00
|
|
|
#ifndef _WIN32
|
2015-06-10 00:30:15 +00:00
|
|
|
uid_t owner; /**< owner of the cfile */
|
2015-06-09 08:13:29 +00:00
|
|
|
gid_t group; /**< group of the cfile */
|
2013-05-22 07:51:15 +00:00
|
|
|
#endif
|
2015-06-09 08:13:29 +00:00
|
|
|
gboolean session_started;
|
|
|
|
guint32 count; /**< Total number of frames captured */
|
|
|
|
capture_options *capture_opts; /**< options for this capture */
|
2017-12-03 18:53:58 +00:00
|
|
|
capture_file *cf; /**< handle to cfile */
|
2019-04-07 02:42:23 +00:00
|
|
|
wtap_rec rec; /**< record we're reading packet metadata into */
|
|
|
|
Buffer buf; /**< Buffer we're reading packet data into */
|
2019-04-07 01:35:00 +00:00
|
|
|
struct wtap *wtap; /**< current wtap file */
|
2019-01-03 19:39:54 +00:00
|
|
|
struct _info_data *cap_data_info; /**< stats for this capture */
|
2013-05-22 10:21:52 +00:00
|
|
|
} capture_session;
|
2013-05-22 07:51:15 +00:00
|
|
|
|
|
|
|
extern void
|
2017-12-03 18:53:58 +00:00
|
|
|
capture_session_init(capture_session *cap_session, capture_file *cf);
|
2013-10-11 21:26:26 +00:00
|
|
|
#else
|
|
|
|
|
2014-05-28 11:19:50 +00:00
|
|
|
/* dummy is needed because clang throws the error: empty struct has size 0 in C, size 1 in C++ */
|
2014-09-09 20:42:58 +00:00
|
|
|
typedef struct _capture_session {int dummy;} capture_session;
|
2013-10-11 21:26:26 +00:00
|
|
|
|
|
|
|
#endif /* HAVE_LIBPCAP */
|
2013-05-22 07:51:15 +00:00
|
|
|
|
2013-05-22 11:53:36 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
2014-06-30 05:08:59 +00:00
|
|
|
#endif /* __CAPCHILD_CAPTURE_SESSION_H__ */
|