Don't preserve the read filter from file to file - you won't necessarily
[obnox/wireshark/wip.git] / file.h
1 /* file.h
2  * Definitions for file structures and routines
3  *
4  * $Id: file.h,v 1.36 1999/08/15 19:18:46 guy Exp $
5  *
6  * Ethereal - Network traffic analyzer
7  * By Gerald Combs <gerald@zing.org>
8  * Copyright 1998 Gerald Combs
9  *
10  * 
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  * 
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  * 
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
24  */
25
26 #ifndef __FILE_H__
27 #define __FILE_H__
28
29 #ifdef HAVE_SYS_TYPES_H
30 #include <sys/types.h>
31 #endif
32
33 #ifdef HAVE_SYS_TIME_H
34 #include <sys/time.h>
35 #endif
36
37 #ifndef __WTAP_H__
38 #include "wiretap/wtap.h"
39 #endif
40
41 #ifdef HAVE_LIBPCAP
42 #ifndef lib_pcap_h
43 #include <pcap.h>
44 #endif
45 #endif
46
47 #ifndef __DFILTER_H__
48 #include "dfilter.h"
49 #endif
50
51 typedef struct bpf_program bpf_prog;
52
53 typedef struct _capture_file {
54   FILE        *fh;        /* Capture file */
55   gchar       *filename;  /* filename */
56   long         f_len;     /* File length */
57   guint16      cd_t;      /* Capture data type */
58   const gchar *cd_t_desc;/* Description of that data type */
59   guint32      vers;      /* Version.  For tcpdump minor is appended to major */
60   guint32      count;     /* Packet count */
61   gfloat       unfiltered_count; /* used for dfilter progress bar */
62   guint32      drops;     /* Dropped packets */
63   guint32      esec;      /* Elapsed seconds */
64   guint32      eusec;     /* Elapsed microseconds */
65   guint32      snap;      /* Captured packet length */
66   gchar       *iface;     /* Interface */
67   gchar       *save_file; /* File that user saved capture to */
68   gint         user_saved;/* Was capture file saved by user yet? */
69   wtap        *wth;       /* Wiretap session */
70   dfilter     *rfcode;    /* Compiled read filter program */ 
71   gchar       *dfilter;   /* Display filter string */
72   dfilter     *dfcode;    /* Compiled display filter program */ 
73 #ifdef HAVE_LIBPCAP
74   gchar       *cfilter;   /* Capture filter string */
75   bpf_prog     fcode;     /* Compiled capture filter program */
76 #endif
77   /* XXX - I'm cheating for now. I'll hardcode 65536 here until I re-arrange
78    * more header files so that ethereal.h is split up into two files, a
79    * generic header and a gtk+-specific header (or the gtk+ definitions are
80    * moved to different header files) --gilbert
81    */
82   /*guint8       pd[MAX_PACKET_SIZE];*/  /* Packet data */
83   guint8       pd[65536];  /* Packet data */
84   frame_data  *plist;     /* Packet list */
85   frame_data  *plist_end; /* Last packet in list */
86   column_info  cinfo;    /* Column formatting information */
87   int          selected_packet;   /* Index in packet list of currently selected packet, if any */
88   int          selected_row;   /* Row in packet display of currently selected packet, if any */
89   frame_data  *fd;        /* Frame data for currently selected packet */
90   proto_tree  *protocol_tree; /* Protocol tree for currently selected packet */
91   FILE        *print_fh;  /* File we're printing to */
92 } capture_file;
93
94 int  open_cap_file(char *, capture_file *);
95 void close_cap_file(capture_file *, void *, guint);
96 int  read_cap_file(capture_file *);
97 int  tail_cap_file(char *, capture_file *);
98 /* size_t read_frame_header(capture_file *); */
99
100 int print_packets(capture_file *cf, int to_file, const char *dest);
101 void filter_packets(capture_file *);
102 void change_time_formats(capture_file *);
103 void select_packet(capture_file *, int);
104 void unselect_packet(capture_file *);
105
106 /* Moves or copies a file. Returns 0 on failure, 1 on success */
107 int file_mv(char *from, char *to);
108
109 /* Copies a file. Returns 0 on failure, 1 on success */
110 int file_cp(char *from, char *to);
111
112 char *file_open_error_message(int, int);
113 char *file_read_error_message(int);
114 char *file_write_error_message(int);
115
116 #endif /* file.h */
117
118
119