b99ea0bf9b2e8c034f32154d4c9b148dc525524d
[obnox/wireshark/wip.git] / capture.h
1 /* capture.h
2  * Definitions for packet capture windows
3  *
4  * $Id: capture.h,v 1.41 2004/02/28 16:21:10 ulfl Exp $
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 #ifdef HAVE_LIBPCAP
29
30 /* Name we give to the child process when doing a "-S" capture. */
31 #define CHILD_NAME      "ethereal-capture"
32
33 typedef struct {
34         gboolean has_snaplen;           /* TRUE if maximum capture packet
35                                            length is specified */
36         int snaplen;                    /* Maximum captured packet length */
37         int promisc_mode;               /* Capture in promiscuous mode */
38         int sync_mode;                  /* Fork a child to do the capture,
39                                            and sync between them */
40         gboolean has_autostop_count;    /* TRUE if maximum packet count is
41                                            specified */
42         int autostop_count;             /* Maximum packet count */
43         gboolean has_autostop_duration; /* TRUE if maximum capture duration
44                                            is specified */
45         gint32 autostop_duration;       /* Maximum capture duration */
46         gboolean has_autostop_filesize; /* TRUE if maximum capture file size
47                                            is specified */
48         gint32 autostop_filesize;       /* Maximum capture file size */
49         gboolean ringbuffer_on;         /* TRUE if ring buffer in use */
50         guint32 num_files;              /* Number of multiple buffer files */
51         gboolean has_ring_duration;     /* TRUE if ring duration specified */
52         gint32 ringbuffer_duration;     /* Switch file after n seconds */
53         int linktype;                   /* Data link type to use, or -1 for
54                                            "use default" */
55 } capture_options;
56
57 extern capture_options capture_opts;
58
59 extern gboolean quit_after_cap; /* Makes a "capture only mode". Implies -k */
60 extern gboolean capture_child;  /* if this is the child for "-S" */
61
62 /* Open a specified file, or create a temporary file, and start a capture
63    to the file in question.  Returns TRUE if the capture starts
64    successfully, FALSE otherwise. */
65 gboolean do_capture(const char *save_file);
66
67 /* Do the low-level work of a capture. */
68 int    capture(gboolean *stats_known, struct pcap_stat *stats);
69
70 /* Stop a capture from a menu item. */
71 void   capture_stop(void);
72
73 /* Terminate the capture child cleanly when exiting. */
74 void   kill_capture_child(void);
75
76
77 /* XXX: improve this macro (put something like this into epan/packet.h?) */
78 #define CAPTURE_PACKET_COUNTS sizeof(packet_counts) / sizeof (gint)
79
80 typedef struct {
81     /* handles */
82     gpointer        callback_data;  /* capture callback handle */
83     gpointer        ui;             /* user interfaces own handle */
84
85     /* capture info */
86     packet_counts   *counts;        /* protocol specific counters */
87     time_t          running_time;   /* running time since last update */
88     gint            new_packets;    /* packets since last update */
89 } capture_info;
90
91
92 /* create the capture info dialog */
93 extern void capture_info_create(
94 capture_info    *cinfo);
95
96 /* Update the capture info counters in the dialog */
97 extern void capture_info_update(
98 capture_info    *cinfo);
99
100 /* destroy the capture info dialog again */
101 extern void capture_info_destroy(
102 capture_info    *cinfo);
103
104
105 #endif /* HAVE_LIBPCAP */
106
107 #define EMPTY_FILTER ""
108 #endif /* capture.h */