From Thomas Anders:
[obnox/wireshark/wip.git] / capture.h
1 /* capture.h
2  * Definitions for packet capture windows
3  *
4  * $Id$
5  *
6  * Ethereal - Network traffic analyzer
7  * By Gerald Combs <gerald@ethereal.com>
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 #ifndef __CAPTURE_H__
26 #define __CAPTURE_H__
27
28 /** @file
29  *  Capture related things.
30  */
31
32 /** Name we give to the child process when doing a "-S" capture. */
33 #define CHILD_NAME      "ethereal-capture"
34
35 #ifdef HAVE_LIBPCAP
36
37 /** Capture options coming from user interface */
38 typedef struct {
39 #ifdef _WIN32
40     int buffer_size;        /**< the capture buffer size (MB) */
41 #endif
42         gboolean has_snaplen;           /**< TRUE if maximum capture packet
43                                            length is specified */
44         int snaplen;                    /**< Maximum captured packet length */
45         int promisc_mode;               /**< Capture in promiscuous mode */
46         int linktype;                   /**< Data link type to use, or -1 for
47                                            "use default" */
48         int sync_mode;                  /**< Fork a child to do the capture,
49                                            and sync between them */
50     gboolean show_info;     /**< show the info dialog */
51
52     gboolean multi_files_on;    /**< TRUE if ring buffer in use */
53
54         gboolean has_file_duration;     /**< TRUE if ring duration specified */
55         gint32 file_duration;     /* Switch file after n seconds */
56         gboolean has_ring_num_files;/**< TRUE if ring num_files specified */
57         guint32 ring_num_files;         /**< Number of multiple buffer files */
58     gboolean has_autostop_files;/**< TRUE if maximum number of capture files
59                                            are specified */
60     gint32 autostop_files;      /**< Maximum number of capture files */
61
62     gboolean has_autostop_packets;      /**< TRUE if maximum packet count is
63                                            specified */
64         int autostop_packets;           /**< Maximum packet count */
65         gboolean has_autostop_filesize; /**< TRUE if maximum capture file size
66                                            is specified */
67         gint32 autostop_filesize;       /**< Maximum capture file size */
68         gboolean has_autostop_duration; /**< TRUE if maximum capture duration
69                                            is specified */
70         gint32 autostop_duration;       /**< Maximum capture duration */
71 } capture_options;
72
73 /** Global capture options. */
74 extern capture_options capture_opts;
75
76 /** Makes a "capture only mode". Implies -k */
77 extern gboolean quit_after_cap; 
78
79 /** If this is the child for "-S" */
80 extern gboolean capture_child;  
81
82 /** Open a specified file, or create a temporary file, and start a capture
83    to the file in question.  Returns TRUE if the capture starts
84    successfully, FALSE otherwise. */
85 gboolean do_capture(const char *save_file);
86
87 /** Do the low-level work of a capture. */
88 int    capture(gboolean *stats_known, struct pcap_stat *stats);
89
90 /** Stop a capture from a menu item. */
91 void   capture_stop(void);
92
93 /** Terminate the capture child cleanly when exiting. */
94 void   kill_capture_child(void);
95
96 /** Number of packet counts.
97  * @todo improve this macro (put something like this into epan/packet.h?) */
98 #define CAPTURE_PACKET_COUNTS sizeof(packet_counts) / sizeof (gint)
99
100 /** Current Capture info. */
101 typedef struct {
102     /* handles */
103     gpointer        callback_data;  /**< capture callback handle */
104     gpointer        ui;             /**< user interfaces own handle */
105
106     /* capture info */
107     packet_counts   *counts;        /**< protocol specific counters */
108     time_t          running_time;   /**< running time since last update */
109     gint            new_packets;    /**< packets since last update */
110 } capture_info;
111
112
113 /** Create the capture info dialog */
114 extern void capture_info_create(
115 capture_info    *cinfo,
116 gchar           *iface);
117
118 /** Update the capture info counters in the dialog */
119 extern void capture_info_update(
120 capture_info    *cinfo);
121
122 /** Destroy the capture info dialog again */
123 extern void capture_info_destroy(
124 capture_info    *cinfo);
125
126
127 #endif /* HAVE_LIBPCAP */
128
129 #endif /* capture.h */