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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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"
41 /* Current state of capture engine. XXX - differentiate states */
43 CAPTURE_STOPPED, /**< stopped */
44 CAPTURE_PREPARING, /**< preparing, but still no response from capture child */
45 CAPTURE_RUNNING /**< capture child signalled ok, capture is running now */
48 #ifdef HAVE_PCAP_REMOTE
49 /* Type of capture source */
51 CAPTURE_IFLOCAL, /**< Local network interface */
52 CAPTURE_IFREMOTE /**< Remote network interface */
55 /* Type of RPCAPD Authentication */
57 CAPTURE_AUTH_NULL, /**< No authentication */
58 CAPTURE_AUTH_PWD /**< User/password authentication */
61 #ifdef HAVE_PCAP_SETSAMPLING
63 * Method of packet sampling (dropping some captured packets),
64 * may require additional integer parameter, marked here as N
67 CAPTURE_SAMP_NONE, /**< No sampling - capture all packets */
68 CAPTURE_SAMP_BY_COUNT, /**< Counter-based sampling -
69 capture 1 packet from every N */
70 CAPTURE_SAMP_BY_TIMER /**< Timer-based sampling -
71 capture no more than 1 packet
77 /** Capture options coming from user interface */
78 typedef struct capture_options_tag {
80 void *cf; /**< handle to cfile (note: untyped handle) */
81 gboolean has_cfilter; /**< TRUE if capture filter specified on command line */
82 gchar *cfilter; /**< Capture filter string */
83 gchar *iface; /**< the network interface to capture from */
84 gchar *iface_descr; /**< A human readable description of iface.
85 *< NOTE: capture_opts.c is not able to
86 *< set this field because doing so
87 *< requires too many dependencies.
88 *< Readers of this field should use
89 *< get_iface_description() from
90 *< "capture_ui_utils.h" to access it. */
91 #ifdef HAVE_PCAP_REMOTE
92 capture_source src_type; /**< Capturing on remote interface */
93 gchar *remote_host; /**< Host name or network address
94 *< for remote capturing */
95 gchar *remote_port; /**< TCP port of remote RPCAP server */
97 capture_auth auth_type;
99 gchar *auth_password; /**< Remote authentication parameters */
101 gboolean datatx_udp; /**< Whether to use UDP for data transfer */
102 gboolean nocap_rpcap; /**< Whether to capture RPCAP own traffic */
103 gboolean nocap_local; /**< TODO: Whether to capture local traffic */
104 #ifdef HAVE_PCAP_SETSAMPLING
105 capture_sampling sampling_method; /**< PCAP packet sampling method */
106 int sampling_param; /**< PCAP packet sampling parameter */
109 #if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
110 int buffer_size; /**< the capture buffer size (MB) */
112 gboolean has_snaplen; /**< TRUE if maximum capture packet length
114 int snaplen; /**< Maximum captured packet length */
115 gboolean promisc_mode; /**< Capture in promiscuous mode */
116 int linktype; /**< Data link type to use, or -1 for
118 gboolean monitor_mode; /**< Capture in monitor mode, if available */
119 gboolean saving_to_file; /**< TRUE if capture is writing to a file */
120 gchar *save_file; /**< the capture file name */
121 gboolean group_read_access; /**< TRUE is group read permission needs to be set */
122 gboolean use_pcapng; /**< TRUE if file format is pcapng */
125 gboolean real_time_mode; /**< Update list of packets in real time */
126 gboolean show_info; /**< show the info dialog */
127 gboolean quit_after_cap; /**< Makes a "capture only mode". Implies -k */
128 gboolean restart; /**< restart after closing is done */
130 /* multiple files (and ringbuffer) */
131 gboolean multi_files_on; /**< TRUE if ring buffer in use */
133 gboolean has_file_duration; /**< TRUE if ring duration specified */
134 gint32 file_duration; /**< Switch file after n seconds */
135 gboolean has_ring_num_files; /**< TRUE if ring num_files specified */
136 guint32 ring_num_files; /**< Number of multiple buffer files */
138 /* autostop conditions */
139 gboolean has_autostop_files; /**< TRUE if maximum number of capture files
141 gint32 autostop_files; /**< Maximum number of capture files */
143 gboolean has_autostop_packets; /**< TRUE if maximum packet count is
145 int autostop_packets; /**< Maximum packet count */
146 gboolean has_autostop_filesize; /**< TRUE if maximum capture file size
148 gint32 autostop_filesize; /**< Maximum capture file size */
149 gboolean has_autostop_duration; /**< TRUE if maximum capture duration
151 gint32 autostop_duration; /**< Maximum capture duration */
153 /* internally used (don't touch from outside) */
154 int fork_child; /**< If not -1, in parent, process ID of child */
155 int fork_child_status; /**< Child exit status */
157 int signal_pipe_write_fd; /**< the pipe to signal the child */
159 capture_state state; /**< current state of the capture engine */
160 gboolean output_to_pipe; /**< save_file is a pipe (named or stdout) */
162 uid_t owner; /**< owner of the cfile */
163 gid_t group; /**< group of the cfile */
167 /* initialize the capture_options with some reasonable values */
169 capture_opts_init(capture_options *capture_opts, void *cf);
171 /* set a command line option value */
173 capture_opts_add_opt(capture_options *capture_opts, int opt, const char *optarg, gboolean *start_capture);
175 /* log content of capture_opts */
177 capture_opts_log(const char *log_domain, GLogLevelFlags log_level, capture_options *capture_opts);
179 /* print interface capabilities, including link layer types */
181 capture_opts_print_if_capabilities(if_capabilities_t *caps,
182 gboolean monitor_mode);
184 /* print list of interfaces */
186 capture_opts_print_interfaces(GList *if_list);
188 /* trim the snaplen entry */
190 capture_opts_trim_snaplen(capture_options *capture_opts, int snaplen_min);
192 /* trim the ring_num_files entry */
194 capture_opts_trim_ring_num_files(capture_options *capture_opts);
196 /* trim the interface entry */
198 capture_opts_trim_iface(capture_options *capture_opts, const char *capture_device);
200 #endif /* capture_opts.h */