Get rid of old non-interface specific settings which are now interface
[metze/wireshark/wip.git] / capture_opts.h
1 /* capture_opts.h
2  * Capture options (all parameters needed to do the actual capture)
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23  */
24
25
26 /** @file
27  *
28  *  Capture options (all parameters needed to do the actual capture)
29  *
30  */
31
32 #ifndef __CAPTURE_OPTS_H__
33 #define __CAPTURE_OPTS_H__
34
35 #ifdef HAVE_SYS_TYPES_H
36 # include <sys/types.h>     /* for gid_t */
37 #endif
38
39 #include "capture_ifinfo.h"
40
41 /* Current state of capture engine. XXX - differentiate states */
42 typedef enum {
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 */
46 } capture_state;
47
48 #ifdef HAVE_PCAP_REMOTE
49 /* Type of capture source */
50 typedef enum {
51     CAPTURE_IFLOCAL,        /**< Local network interface */
52     CAPTURE_IFREMOTE        /**< Remote network interface */
53 } capture_source;
54
55 /* Type of RPCAPD Authentication */
56 typedef enum {
57     CAPTURE_AUTH_NULL,      /**< No authentication */
58     CAPTURE_AUTH_PWD        /**< User/password authentication */
59 } capture_auth;
60 #endif
61 #ifdef HAVE_PCAP_SETSAMPLING
62 /**
63  * Method of packet sampling (dropping some captured packets),
64  * may require additional integer parameter, marked here as N
65  */
66 typedef enum {
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
72                                  in N milliseconds */
73 } capture_sampling;
74 #endif
75
76 typedef struct interface_options_tag {
77     gchar *name;
78     gchar *descr;
79     gchar *cfilter;
80     gboolean has_snaplen;
81     int snaplen;
82     int linktype;
83     gboolean promisc_mode;
84 #if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
85     int buffer_size;
86 #endif
87     gboolean monitor_mode;
88 #ifdef HAVE_PCAP_REMOTE
89     capture_source src_type;
90     gchar *remote_host;
91     gchar *remote_port;
92     capture_auth auth_type;
93     gchar *auth_username;
94     gchar *auth_password;
95     gboolean datatx_udp;
96     gboolean nocap_rpcap;
97     gboolean nocap_local;
98 #endif
99 #ifdef HAVE_PCAP_SETSAMPLING
100     capture_sampling sampling_method;
101     int sampling_param;
102 #endif
103 } interface_options;
104
105 /** Capture options coming from user interface */
106 typedef struct capture_options_tag {
107     /* general */
108     void     *cf;                   /**< handle to cfile (note: untyped handle) */
109     GArray   *ifaces;               /**< array of interfaces.
110                                          Currently only used by dumpcap. */
111     interface_options default_options;
112     gboolean saving_to_file;        /**< TRUE if capture is writing to a file */
113     gchar    *save_file;            /**< the capture file name */
114     gboolean group_read_access;     /**< TRUE is group read permission needs to be set */
115     gboolean use_pcapng;            /**< TRUE if file format is pcapng */
116
117     /* GUI related */
118     gboolean real_time_mode;        /**< Update list of packets in real time */
119     gboolean show_info;             /**< show the info dialog */
120     gboolean quit_after_cap;        /**< Makes a "capture only mode". Implies -k */
121     gboolean restart;               /**< restart after closing is done */
122
123     /* multiple files (and ringbuffer) */
124     gboolean multi_files_on;        /**< TRUE if ring buffer in use */
125
126     gboolean has_file_duration;     /**< TRUE if ring duration specified */
127     gint32 file_duration;           /**< Switch file after n seconds */
128     gboolean has_ring_num_files;    /**< TRUE if ring num_files specified */
129     guint32 ring_num_files;         /**< Number of multiple buffer files */
130
131     /* autostop conditions */
132     gboolean has_autostop_files;    /**< TRUE if maximum number of capture files
133                                          are specified */
134     gint32 autostop_files;          /**< Maximum number of capture files */
135
136     gboolean has_autostop_packets;  /**< TRUE if maximum packet count is
137                                          specified */
138     int autostop_packets;           /**< Maximum packet count */
139     gboolean has_autostop_filesize; /**< TRUE if maximum capture file size
140                                          is specified */
141     gint32 autostop_filesize;       /**< Maximum capture file size */
142     gboolean has_autostop_duration; /**< TRUE if maximum capture duration
143                                          is specified */
144     gint32 autostop_duration;       /**< Maximum capture duration */
145
146     /* internally used (don't touch from outside) */
147     int fork_child;                 /**< If not -1, in parent, process ID of child */
148     int fork_child_status;          /**< Child exit status */
149 #ifdef _WIN32
150     int signal_pipe_write_fd;       /**< the pipe to signal the child */
151 #endif
152     capture_state state;            /**< current state of the capture engine */
153     gboolean output_to_pipe;        /**< save_file is a pipe (named or stdout) */
154 #ifndef _WIN32
155     uid_t owner;                    /**< owner of the cfile */
156     gid_t group;                    /**< group of the cfile */
157 #endif
158 } capture_options;
159
160 /* initialize the capture_options with some reasonable values */
161 extern void
162 capture_opts_init(capture_options *capture_opts, void *cf);
163
164 /* set a command line option value */
165 extern int
166 capture_opts_add_opt(capture_options *capture_opts, int opt, const char *optarg, gboolean *start_capture);
167
168 /* log content of capture_opts */
169 extern void
170 capture_opts_log(const char *log_domain, GLogLevelFlags log_level, capture_options *capture_opts);
171
172 /* print interface capabilities, including link layer types */
173 extern void
174 capture_opts_print_if_capabilities(if_capabilities_t *caps, char *name,
175                                    gboolean monitor_mode);
176
177 /* print list of interfaces */
178 extern void
179 capture_opts_print_interfaces(GList *if_list);
180
181 /* trim the snaplen entry */
182 extern void
183 capture_opts_trim_snaplen(capture_options *capture_opts, int snaplen_min);
184
185 /* trim the ring_num_files entry */
186 extern void
187 capture_opts_trim_ring_num_files(capture_options *capture_opts);
188
189 /* trim the interface entry */
190 extern gboolean
191 capture_opts_trim_iface(capture_options *capture_opts, const char *capture_device);
192
193 #endif /* capture_opts.h */