2 * Capture options (all parameters needed to do the actual capture)
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
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.
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.
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.
28 * Capture options (all parameters needed to do the actual capture)
32 #ifndef __CAPTURE_OPTS_H__
33 #define __CAPTURE_OPTS_H__
35 #ifdef HAVE_SYS_TYPES_H
36 # include <sys/types.h> /* for gid_t */
39 #include "capture_ifinfo.h"
43 #endif /* __cplusplus */
45 /* Current state of capture engine. XXX - differentiate states */
47 CAPTURE_STOPPED, /**< stopped */
48 CAPTURE_PREPARING, /**< preparing, but still no response from capture child */
49 CAPTURE_RUNNING /**< capture child signalled ok, capture is running now */
52 #ifdef HAVE_PCAP_REMOTE
53 /* Type of capture source */
55 CAPTURE_IFLOCAL, /**< Local network interface */
56 CAPTURE_IFREMOTE /**< Remote network interface */
59 /* Type of RPCAPD Authentication */
61 CAPTURE_AUTH_NULL, /**< No authentication */
62 CAPTURE_AUTH_PWD /**< User/password authentication */
65 #ifdef HAVE_PCAP_SETSAMPLING
67 * Method of packet sampling (dropping some captured packets),
68 * may require additional integer parameter, marked here as N
71 CAPTURE_SAMP_NONE, /**< No sampling - capture all packets */
72 CAPTURE_SAMP_BY_COUNT, /**< Counter-based sampling -
73 capture 1 packet from every N */
74 CAPTURE_SAMP_BY_TIMER /**< Timer-based sampling -
75 capture no more than 1 packet
80 #ifdef HAVE_PCAP_REMOTE
81 struct remote_host_info {
82 gchar *remote_host; /**< Host name or network address for remote capturing */
83 gchar *remote_port; /**< TCP port of remote RPCAP server */
84 gint auth_type; /**< Authentication type */
85 gchar *auth_username; /**< Remote authentication parameters */
86 gchar *auth_password; /**< Remote authentication parameters */
92 typedef struct remote_options_tag {
93 capture_source src_type;
94 struct remote_host_info remote_host_opts;
95 #ifdef HAVE_PCAP_SETSAMPLING
96 capture_sampling sampling_method;
100 #endif /* HAVE_PCAP_REMOTE */
102 typedef struct interface_tag {
105 gchar *friendly_name;
113 gboolean has_snaplen;
116 #if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
119 #ifdef HAVE_PCAP_CREATE
120 gboolean monitor_mode_enabled;
121 gboolean monitor_mode_supported;
123 #ifdef HAVE_PCAP_REMOTE
124 remote_options remote_opts;
126 guint32 last_packets;
133 typedef struct link_row_tag {
138 typedef struct interface_options_tag {
139 gchar *name; /* the name of the interface provided to winpcap/libpcap to specify the interface */
141 gchar *console_display_name; /* the name displayed in the console, also the basis for autonamed pcap filenames */
143 gboolean has_snaplen;
146 gboolean promisc_mode;
147 #if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
150 gboolean monitor_mode;
151 #ifdef HAVE_PCAP_REMOTE
152 capture_source src_type;
155 capture_auth auth_type;
156 gchar *auth_username;
157 gchar *auth_password;
159 gboolean nocap_rpcap;
160 gboolean nocap_local;
162 #ifdef HAVE_PCAP_SETSAMPLING
163 capture_sampling sampling_method;
168 /** Capture options coming from user interface */
169 typedef struct capture_options_tag {
171 void *cf; /**< handle to cfile (note: untyped handle) */
172 GArray *ifaces; /**< array of interfaces.
173 Currently only used by dumpcap. */
176 interface_options default_options;
177 gboolean saving_to_file; /**< TRUE if capture is writing to a file */
178 gchar *save_file; /**< the capture file name */
179 gboolean group_read_access; /**< TRUE is group read permission needs to be set */
180 gboolean use_pcapng; /**< TRUE if file format is pcapng */
183 gboolean real_time_mode; /**< Update list of packets in real time */
184 gboolean show_info; /**< show the info dialog */
185 gboolean quit_after_cap; /**< Makes a "capture only mode". Implies -k */
186 gboolean restart; /**< restart after closing is done */
188 /* multiple files (and ringbuffer) */
189 gboolean multi_files_on; /**< TRUE if ring buffer in use */
191 gboolean has_file_duration; /**< TRUE if ring duration specified */
192 gint32 file_duration; /**< Switch file after n seconds */
193 gboolean has_ring_num_files; /**< TRUE if ring num_files specified */
194 guint32 ring_num_files; /**< Number of multiple buffer files */
196 /* autostop conditions */
197 gboolean has_autostop_files; /**< TRUE if maximum number of capture files
199 gint32 autostop_files; /**< Maximum number of capture files */
201 gboolean has_autostop_packets; /**< TRUE if maximum packet count is
203 int autostop_packets; /**< Maximum packet count */
204 gboolean has_autostop_filesize; /**< TRUE if maximum capture file size
206 gint32 autostop_filesize; /**< Maximum capture file size */
207 gboolean has_autostop_duration; /**< TRUE if maximum capture duration
209 gint32 autostop_duration; /**< Maximum capture duration */
211 /* internally used (don't touch from outside) */
212 int fork_child; /**< If not -1, in parent, process ID of child */
213 int fork_child_status; /**< Child exit status */
215 int signal_pipe_write_fd; /**< the pipe to signal the child */
217 capture_state state; /**< current state of the capture engine */
218 gboolean output_to_pipe; /**< save_file is a pipe (named or stdout) */
220 uid_t owner; /**< owner of the cfile */
221 gid_t group; /**< group of the cfile */
223 gboolean session_started;
226 /* initialize the capture_options with some reasonable values */
228 capture_opts_init(capture_options *capture_opts, void *cf);
230 /* set a command line option value */
232 capture_opts_add_opt(capture_options *capture_opts, int opt, const char *optarg, gboolean *start_capture);
234 /* log content of capture_opts */
236 capture_opts_log(const char *log_domain, GLogLevelFlags log_level, capture_options *capture_opts);
238 /* print interface capabilities, including link layer types */
240 capture_opts_print_if_capabilities(if_capabilities_t *caps, char *name,
241 gboolean monitor_mode);
243 /* print list of interfaces */
245 capture_opts_print_interfaces(GList *if_list);
247 /* trim the snaplen entry */
249 capture_opts_trim_snaplen(capture_options *capture_opts, int snaplen_min);
251 /* trim the ring_num_files entry */
253 capture_opts_trim_ring_num_files(capture_options *capture_opts);
255 /* pick default interface if none was specified */
257 capture_opts_default_iface_if_necessary(capture_options *capture_opts,
258 const char *capture_device);
261 collect_ifaces(capture_options *capture_opts);
263 /* Default capture buffer size in Mbytes. */
264 #define DEFAULT_CAPTURE_BUFFER_SIZE 2
268 #endif /* __cplusplus */
270 #endif /* capture_opts.h */