Update documentation about iptrace version support.
[metze/wireshark/wip.git] / file.h
1 /* file.h
2  * Definitions for file structures and routines
3  *
4  * $Id: file.h,v 1.54 1999/11/25 18:02:07 gerald 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 #ifndef __WTAP_H__
34 #include "wiretap/wtap.h"
35 #endif
36
37 #ifdef HAVE_LIBPCAP
38 #ifndef lib_pcap_h
39 #include <pcap.h>
40 #endif
41 #endif
42
43 #ifndef __DFILTER_H__
44 #include "dfilter.h"
45 #endif
46
47 #ifndef __COLORS_H__
48 #include "colors.h"
49 #endif
50
51 #include <errno.h>
52
53 #ifdef HAVE_LIBZ
54 #include "zlib.h"
55
56 #define FILE_T gzFile
57 #define file_open gzopen
58 #define filed_open gzdopen
59 #define file_seek gzseek
60 #define file_read(buf, bsize, count, file) gzread((file),(buf),((count)*(bsize)))
61 #define file_write(buf, bsize, count, file) gzwrite((file),(buf),((count)*(bsize)))
62 #define file_close gzclose
63
64 #else /* No zLib */
65 #define FILE_T FILE *
66 #define file_open fopen
67 #define filed_open fdopen
68 #define file_seek fseek
69 #define file_read fread
70 #define file_write fwrite
71 #define file_close fclose
72 #endif /* HAVE_LIBZ */
73
74 typedef struct bpf_program bpf_prog;
75
76 typedef struct _capture_file {
77   FILE_T       fh;        /* Capture file */
78   int          filed;     /* Filedes of capture file */
79   gchar       *filename;  /* filename */
80   long         f_len;     /* File length */
81   guint16      cd_t;      /* Capture data type */
82   const gchar *cd_t_desc; /* Description of that data type */
83   guint32      vers;      /* Version.  For tcpdump minor is appended to major */
84   guint32      count;     /* Packet count */
85   gfloat       unfiltered_count; /* used for dfilter progress bar */
86   guint32      drops;     /* Dropped packets */
87   guint32      esec;      /* Elapsed seconds */
88   guint32      eusec;     /* Elapsed microseconds */
89   guint32      snap;      /* Captured packet length */
90   gboolean     update_progbar; /* TRUE if we should update the progress bar */
91   long         progbar_quantum; /* Number of bytes read per progress bar update */
92   long         progbar_nextstep; /* Next point at which to update progress bar */
93   gchar       *iface;     /* Interface */
94   gchar       *save_file; /* File that user saved capture to */
95   int          save_file_fd; /* File descriptor for saved file */
96   gint         user_saved;/* Was capture file saved by user yet? */
97   wtap        *wth;       /* Wiretap session */
98   dfilter     *rfcode;    /* Compiled read filter program */ 
99   gchar       *dfilter;   /* Display filter string */
100   colfilter   *colors;    /* Colors for colorizing packet window */
101   dfilter     *dfcode;    /* Compiled display filter program */ 
102 #ifdef HAVE_LIBPCAP
103   gchar       *cfilter;   /* Capture filter string */
104   bpf_prog     fcode;     /* Compiled capture filter program */
105 #endif
106   gchar       *sfilter;   /* Search filter string */
107   gboolean     sbackward;  /* TRUE if search is backward, FALSE if forward */
108   guint8       pd[WTAP_MAX_PACKET_SIZE];  /* Packet data */
109   frame_data  *plist;     /* Packet list */
110   frame_data  *plist_end; /* Last packet in list */
111   frame_data  *first_displayed; /* First frame displayed */
112   frame_data  *last_displayed;  /* Last frame displayed */
113   column_info  cinfo;    /* Column formatting information */
114   frame_data  *current_frame;  /* Frame data for current frame */
115   int          current_row;    /* Row in packet display of current frame */
116   gboolean     current_frame_is_selected; /* TRUE if that frame is selected */
117   proto_tree  *protocol_tree; /* Protocol tree for currently selected packet */
118   FILE        *print_fh;  /* File we're printing to */
119 } capture_file;
120
121 int  open_cap_file(char *, capture_file *);
122 void close_cap_file(capture_file *, void *, guint);
123 int  read_cap_file(capture_file *);
124 int  tail_cap_file(char *, capture_file *);
125 /* size_t read_frame_header(capture_file *); */
126
127 int filter_packets(capture_file *cf, gchar *dfilter);
128 void colorize_packets(capture_file *);
129 int print_packets(capture_file *cf, print_args_t *print_args);
130 void change_time_formats(capture_file *);
131 gboolean find_packet(capture_file *cf, dfilter *sfcode);
132 gboolean goto_frame(capture_file *cf, guint fnumber);
133 void select_packet(capture_file *, int);
134 void unselect_packet(capture_file *);
135
136 /* Moves or copies a file. Returns 0 on failure, 1 on success */
137 int file_mv(char *from, char *to);
138
139 /* Copies a file. Returns 0 on failure, 1 on success */
140 int file_cp(char *from, char *to);
141
142 char *file_open_error_message(int, int);
143 char *file_read_error_message(int);
144 char *file_write_error_message(int);
145
146 #endif /* file.h */