2 * Definitions for packet capture windows
6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@ethereal.com>
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.
25 /* This file should only be included if libpcap is present */
31 * Capture related things.
34 /** Name we give to the child process when doing a "-S" capture. */
35 #define CHILD_NAME "ethereal-capture"
37 /** Capture options coming from user interface */
38 typedef struct capture_options_tag {
40 void *cf; /**< handle to cfile (note: untyped handle) */
41 gchar *cfilter; /**< Capture filter string */
42 gchar *iface; /**< the network interface to capture from */
45 int buffer_size; /**< the capture buffer size (MB) */
47 gboolean has_snaplen; /**< TRUE if maximum capture packet length
49 int snaplen; /**< Maximum captured packet length */
50 gboolean promisc_mode; /**< Capture in promiscuous mode */
51 int linktype; /**< Data link type to use, or -1 for
53 gchar *save_file; /**< the capture file name */
56 gboolean real_time_mode; /**< Update list of packets in real time */
57 gboolean show_info; /**< show the info dialog */
58 gboolean quit_after_cap; /** Makes a "capture only mode". Implies -k */
59 gboolean restart; /**< restart after closing is done */
61 /* multiple files (and ringbuffer) */
62 gboolean multi_files_on; /**< TRUE if ring buffer in use */
64 gboolean has_file_duration; /**< TRUE if ring duration specified */
65 gint32 file_duration; /* Switch file after n seconds */
66 gboolean has_ring_num_files;/**< TRUE if ring num_files specified */
67 guint32 ring_num_files; /**< Number of multiple buffer files */
69 /* autostop conditions */
70 gboolean has_autostop_files;/**< TRUE if maximum number of capture files
72 gint32 autostop_files; /**< Maximum number of capture files */
74 gboolean has_autostop_packets; /**< TRUE if maximum packet count is
76 int autostop_packets; /**< Maximum packet count */
77 gboolean has_autostop_filesize; /**< TRUE if maximum capture file size
79 gint32 autostop_filesize; /**< Maximum capture file size */
80 gboolean has_autostop_duration; /**< TRUE if maximum capture duration
82 gint32 autostop_duration; /**< Maximum capture duration */
84 /* internally used (don't touch from outside) */
85 int fork_child; /**< If not -1, in parent, process ID of child */
87 int signal_pipe_fd; /**< the pipe to signal the child */
92 /* initialize the capture_options with some reasonable values */
94 capture_opts_init(capture_options *capture_opts, void *cfile);
97 capture_opts_add_opt(capture_options *capture_opts, const char *appname, int opt, const char *optarg, gboolean *start_capture);
100 * Start a capture session.
102 * @param capture_opts the numerous capture options
103 * @return TRUE if the capture starts successfully, FALSE otherwise.
105 extern gboolean capture_start(capture_options *capture_opts);
107 /** Stop a capture session (usually from a menu item). */
108 extern void capture_stop(capture_options *capture_opts);
110 /** Restart the current captured packets and start again. */
111 extern void capture_restart(capture_options *capture_opts);
113 /** Terminate the capture child cleanly when exiting. */
114 extern void capture_kill_child(capture_options *capture_opts);
117 * Capture child told us, we have a new (or the first) capture file.
119 extern gboolean capture_input_new_file(capture_options *capture_opts, gchar *new_file);
122 * Capture child told us, we have new packets to read.
124 extern void capture_input_new_packets(capture_options *capture_opts, int to_read);
127 * Capture child closed it's side ot the pipe, do the required cleanup.
129 extern void capture_input_closed(capture_options *capture_opts);
133 /** Do the low-level work of a capture (start the capture child).
134 * Returns TRUE if it succeeds, FALSE otherwise. */
135 extern int capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct pcap_stat *stats);
137 /** Stop a low-level capture (stops the capture child). */
138 extern void capture_loop_stop(void);
142 /** Current Capture info. */
145 gpointer callback_data; /**< capture callback handle */
146 gpointer ui; /**< user interfaces own handle */
149 packet_counts *counts; /**< protocol specific counters */
150 time_t running_time; /**< running time since last update */
151 gint new_packets; /**< packets since last update */
155 /** Create the capture info dialog */
156 extern void capture_info_create(
160 /** Update the capture info counters in the dialog */
161 extern void capture_info_update(
162 capture_info *cinfo);
164 /** Destroy the capture info dialog again */
165 extern void capture_info_destroy(
166 capture_info *cinfo);
169 #endif /* capture.h */