Add a script as a front-end for Flex, to work around various problems,
[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
44 /** Capture options coming from user interface */
45 typedef struct capture_options_tag {
46     /* general */
47     void     *cf;                   /**< handle to cfile (note: untyped handle) */
48     gboolean has_cfilter;           /**< TRUE if capture filter specified on command line */
49     gchar    *cfilter;              /**< Capture filter string */
50     gchar    *iface;                /**< the network interface to capture from */
51
52 #ifdef _WIN32
53     int      buffer_size;           /**< the capture buffer size (MB) */
54 #endif
55     gboolean has_snaplen;           /**< TRUE if maximum capture packet length
56                                          is specified */
57     int      snaplen;               /**< Maximum captured packet length */
58     gboolean promisc_mode;          /**< Capture in promiscuous mode */
59     int      linktype;              /**< Data link type to use, or -1 for
60                                          "use default" */
61     gboolean saving_to_file;        /**< TRUE if capture is writing to a file */
62     gchar    *save_file;            /**< the capture file name */
63
64     /* GUI related */
65     gboolean real_time_mode;        /**< Update list of packets in real time */
66     gboolean show_info;             /**< show the info dialog */
67     gboolean quit_after_cap;        /**< Makes a "capture only mode". Implies -k */
68     gboolean restart;               /**< restart after closing is done */
69
70     /* multiple files (and ringbuffer) */
71     gboolean multi_files_on;        /**< TRUE if ring buffer in use */
72
73     gboolean has_file_duration;     /**< TRUE if ring duration specified */
74     gint32 file_duration;           /**< Switch file after n seconds */
75     gboolean has_ring_num_files;    /**< TRUE if ring num_files specified */
76     guint32 ring_num_files;         /**< Number of multiple buffer files */
77
78     /* autostop conditions */
79     gboolean has_autostop_files;    /**< TRUE if maximum number of capture files
80                                          are specified */
81     gint32 autostop_files;          /**< Maximum number of capture files */
82
83     gboolean has_autostop_packets;  /**< TRUE if maximum packet count is
84                                          specified */
85     int autostop_packets;           /**< Maximum packet count */
86     gboolean has_autostop_filesize; /**< TRUE if maximum capture file size
87                                          is specified */
88     gint32 autostop_filesize;       /**< Maximum capture file size */
89     gboolean has_autostop_duration; /**< TRUE if maximum capture duration
90                                          is specified */
91     gint32 autostop_duration;       /**< Maximum capture duration */
92
93     /* internally used (don't touch from outside) */
94     int fork_child;                 /**< If not -1, in parent, process ID of child */
95 #ifdef _WIN32
96     int signal_pipe_write_fd;       /**< the pipe to signal the child */
97 #endif
98     capture_state state;            /**< current state of the capture engine */
99     gboolean output_to_pipe;        /**< save_file is a pipe (named or stdout) */
100 } capture_options;
101
102
103 /* initialize the capture_options with some reasonable values */
104 extern void
105 capture_opts_init(capture_options *capture_opts, void *cfile);
106
107 /* set a command line option value */
108 extern int
109 capture_opts_add_opt(capture_options *capture_opts, int opt, const char *optarg, gboolean *start_capture);
110
111 /* log content of capture_opts */
112 extern void
113 capture_opts_log(const char *log_domain, GLogLevelFlags log_level, capture_options *capture_opts);
114
115 /* list link layer types */
116 extern int
117 capture_opts_list_link_layer_types(capture_options *capture_opts, gboolean machine_readable);
118
119 /* list interfaces */
120 extern int
121 capture_opts_list_interfaces(gboolean machine_readable);
122
123 /* print interface statistics */
124 extern int
125 capture_opts_print_statistics(gboolean machine_readable);
126
127 /* trim the snaplen entry */
128 extern void
129 capture_opts_trim_snaplen(capture_options *capture_opts, int snaplen_min);
130
131 /* trim the ring_num_files entry */
132 extern void
133 capture_opts_trim_ring_num_files(capture_options *capture_opts);
134
135 /* trim the interface entry */
136 extern gboolean
137 capture_opts_trim_iface(capture_options *capture_opts, const char *capture_device);
138
139 #endif /* capture_opts.h */