Show VarBind OIDs and trap enterprise OID in info column.
[obnox/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
36 /* Current state of capture engine. XXX - differentiate states */
37 typedef enum {
38     CAPTURE_STOPPED,        /**< stopped */
39     CAPTURE_PREPARING,      /**< preparing, but still no response from capture child */
40     CAPTURE_RUNNING         /**< capture child signalled ok, capture is running now */
41 } capture_state;
42
43 #ifdef HAVE_PCAP_REMOTE
44 /* Type of capture source */
45 typedef enum {
46     CAPTURE_IFLOCAL,        /**< Local network interface */
47     CAPTURE_IFREMOTE        /**< Remote network interface */
48 } capture_source;
49
50 /* Type of RPCAPD Authentication */
51 typedef enum {
52     CAPTURE_AUTH_NULL,      /**< No authentication */
53     CAPTURE_AUTH_PWD        /**< User/password authentication */
54 } capture_auth;
55
56 #ifdef HAVE_PCAP_SETSAMPLING
57 /**
58  * Method of packet sampling (dropping some captured packets),
59  * may require additional integer parameter, marked here as N
60  */
61 typedef enum {
62     CAPTURE_SAMP_NONE,      /**< No sampling - capture all packets */
63     CAPTURE_SAMP_BY_COUNT,  /**< Counter-based sampling -
64                                  capture 1 packet from every N */
65     CAPTURE_SAMP_BY_TIMER   /**< Timer-based sampling -
66                                  capture no more than 1 packet
67                                  in N milliseconds */
68 } capture_sampling;
69 #endif
70 #endif
71
72 /** Capture options coming from user interface */
73 typedef struct capture_options_tag {
74     /* general */
75     void     *cf;                   /**< handle to cfile (note: untyped handle) */
76     gboolean has_cfilter;           /**< TRUE if capture filter specified on command line */
77     gchar    *cfilter;              /**< Capture filter string */
78     gchar    *iface;                /**< the network interface to capture from */
79     gchar    *iface_descr;          /**< A human readable description of iface.
80                                       *< NOTE: capture_opts.c is not able to
81                                       *< set this field because doing so
82                                       *< requires too many dependencies.
83                                       *< Readers of this field should use
84                                       *< get_iface_description() from
85                                       *< "capture_ui_utils.h" to access it. */
86 #ifdef HAVE_PCAP_REMOTE
87     capture_source src_type;        /**< Capturing on remote interface */
88     gchar    *remote_host;          /**< Host name or network address
89                                       *< for remote capturing */
90     gchar    *remote_port;          /**< TCP port of remote RPCAP server */
91
92     capture_auth  auth_type;
93     gchar    *auth_username;
94     gchar    *auth_password;        /**< Remote authentication parameters */
95
96     gboolean datatx_udp;            /**< Whether to use UDP for data transfer */
97     gboolean nocap_rpcap;           /**< Whether to capture RPCAP own traffic */
98     gboolean nocap_local;           /**< TODO: Whether to capture local traffic */
99 #ifdef HAVE_PCAP_SETSAMPLING
100     capture_sampling sampling_method; /**< PCAP packet sampling method */
101     int sampling_param;             /**< PCAP packet sampling parameter */
102 #endif
103 #endif
104 #ifdef _WIN32
105     int      buffer_size;           /**< the capture buffer size (MB) */
106 #endif
107     gboolean has_snaplen;           /**< TRUE if maximum capture packet length
108                                          is specified */
109     int      snaplen;               /**< Maximum captured packet length */
110     gboolean promisc_mode;          /**< Capture in promiscuous mode */
111     int      linktype;              /**< Data link type to use, or -1 for
112                                          "use default" */
113     gboolean saving_to_file;        /**< TRUE if capture is writing to a file */
114     gchar    *save_file;            /**< the capture file name */
115
116     /* GUI related */
117     gboolean real_time_mode;        /**< Update list of packets in real time */
118     gboolean show_info;             /**< show the info dialog */
119     gboolean quit_after_cap;        /**< Makes a "capture only mode". Implies -k */
120     gboolean restart;               /**< restart after closing is done */
121
122     /* multiple files (and ringbuffer) */
123     gboolean multi_files_on;        /**< TRUE if ring buffer in use */
124
125     gboolean has_file_duration;     /**< TRUE if ring duration specified */
126     gint32 file_duration;           /**< Switch file after n seconds */
127     gboolean has_ring_num_files;    /**< TRUE if ring num_files specified */
128     guint32 ring_num_files;         /**< Number of multiple buffer files */
129
130     /* autostop conditions */
131     gboolean has_autostop_files;    /**< TRUE if maximum number of capture files
132                                          are specified */
133     gint32 autostop_files;          /**< Maximum number of capture files */
134
135     gboolean has_autostop_packets;  /**< TRUE if maximum packet count is
136                                          specified */
137     int autostop_packets;           /**< Maximum packet count */
138     gboolean has_autostop_filesize; /**< TRUE if maximum capture file size
139                                          is specified */
140     gint32 autostop_filesize;       /**< Maximum capture file size */
141     gboolean has_autostop_duration; /**< TRUE if maximum capture duration
142                                          is specified */
143     gint32 autostop_duration;       /**< Maximum capture duration */
144
145     /* internally used (don't touch from outside) */
146     int fork_child;                 /**< If not -1, in parent, process ID of child */
147 #ifdef _WIN32
148     int signal_pipe_write_fd;       /**< the pipe to signal the child */
149 #endif
150     capture_state state;            /**< current state of the capture engine */
151     gboolean output_to_pipe;        /**< save_file is a pipe (named or stdout) */
152 #ifndef _WIN32
153     uid_t owner;                    /**< owner of the cfile */
154     gid_t group;                    /**< group of the cfile */
155 #endif
156 } capture_options;
157
158 /* initialize the capture_options with some reasonable values */
159 extern void
160 capture_opts_init(capture_options *capture_opts, void *cfile);
161
162 /* set a command line option value */
163 extern int
164 capture_opts_add_opt(capture_options *capture_opts, int opt, const char *optarg, gboolean *start_capture);
165
166 /* log content of capture_opts */
167 extern void
168 capture_opts_log(const char *log_domain, GLogLevelFlags log_level, capture_options *capture_opts);
169
170 /* list link layer types */
171 extern int
172 capture_opts_list_link_layer_types(capture_options *capture_opts, gboolean machine_readable);
173
174 /* list interfaces */
175 extern int
176 capture_opts_list_interfaces(gboolean machine_readable);
177
178 /* print interface statistics */
179 extern int
180 capture_opts_print_statistics(gboolean machine_readable);
181
182 /* trim the snaplen entry */
183 extern void
184 capture_opts_trim_snaplen(capture_options *capture_opts, int snaplen_min);
185
186 /* trim the ring_num_files entry */
187 extern void
188 capture_opts_trim_ring_num_files(capture_options *capture_opts);
189
190 /* trim the interface entry */
191 extern gboolean
192 capture_opts_trim_iface(capture_options *capture_opts, const char *capture_device);
193
194 #endif /* capture_opts.h */