Get rid of the check for NetBSD in the Wiretap "configure.in"; we
[obnox/wireshark/wip.git] / file.h
1 /* file.h
2  * Definitions for file structures and routines
3  *
4  * $Id: file.h,v 1.64 2000/02/12 08:15:20 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 #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 "gtk/colors.h"         /* XXX */
49 #endif
50
51 #ifndef __PRINT_H__
52 #include "print.h"
53 #endif
54
55 #include <errno.h>
56
57 #ifdef HAVE_LIBZ
58 #include "zlib.h"
59 #define FILE_T gzFile
60 #define file_open gzopen
61 #define filed_open gzdopen
62 #define file_close gzclose
63 #else /* No zLib */
64 #define FILE_T FILE *
65 #define file_open fopen
66 #define filed_open fdopen
67 #define file_close fclose
68 #endif /* HAVE_LIBZ */
69
70 typedef struct bpf_program bpf_prog;
71
72 typedef struct _capture_file {
73   FILE_T       fh;        /* File handle for capture file */
74   int          filed;     /* File descriptor of capture file */
75   gchar       *filename;  /* Name of capture file */
76   gboolean     is_tempfile; /* Is capture file a temporary file? */
77   gboolean     user_saved;/* If capture file is temporary, has it been saved by user yet? */
78   long         f_len;     /* Length of capture file */
79   guint16      cd_t;      /* File type of capture file */
80   int          lnk_t;     /* Link-layer type with which to save capture */
81   guint32      vers;      /* Version.  For tcpdump minor is appended to major */
82   guint32      count;     /* Packet count */
83   guint32      drops;     /* Dropped packets */
84   guint32      esec;      /* Elapsed seconds */
85   guint32      eusec;     /* Elapsed microseconds */
86   guint32      snap;      /* Captured packet length */
87   gboolean     update_progbar; /* TRUE if we should update the progress bar */
88   long         progbar_quantum; /* Number of bytes read per progress bar update */
89   long         progbar_nextstep; /* Next point at which to update progress bar */
90   gchar       *iface;     /* Interface */
91   gchar       *save_file; /* File that user saved capture to */
92   int          save_file_fd; /* File descriptor for saved file */
93   wtap        *wth;       /* Wiretap session */
94   dfilter     *rfcode;    /* Compiled read filter program */ 
95   gchar       *dfilter;   /* Display filter string */
96   colfilter   *colors;    /* Colors for colorizing packet window */
97   dfilter     *dfcode;    /* Compiled display filter program */ 
98 #ifdef HAVE_LIBPCAP
99   gchar       *cfilter;   /* Capture filter string */
100   bpf_prog     fcode;     /* Compiled capture filter program */
101 #endif
102   gchar       *sfilter;   /* Search filter string */
103   gboolean     sbackward;  /* TRUE if search is backward, FALSE if forward */
104   guint8       pd[WTAP_MAX_PACKET_SIZE];  /* Packet data */
105   frame_data  *plist;     /* Packet list */
106   frame_data  *plist_end; /* Last packet in list */
107   frame_data  *first_displayed; /* First frame displayed */
108   frame_data  *last_displayed;  /* Last frame displayed */
109   column_info  cinfo;    /* Column formatting information */
110   frame_data  *current_frame;  /* Frame data for current frame */
111   int          current_row;    /* Row in packet display of current frame */
112   gboolean     current_frame_is_selected; /* TRUE if that frame is selected */
113   proto_tree  *protocol_tree; /* Protocol tree for currently selected packet */
114   FILE        *print_fh;  /* File we're printing to */
115 } capture_file;
116
117 int  open_cap_file(char *, gboolean, capture_file *);
118 void close_cap_file(capture_file *, void *);
119 int  read_cap_file(capture_file *);
120 int  start_tail_cap_file(char *, gboolean, capture_file *);
121 int  continue_tail_cap_file(capture_file *, int);
122 int  finish_tail_cap_file(capture_file *);
123 /* size_t read_frame_header(capture_file *); */
124 int  save_cap_file(char *, capture_file *, gboolean, guint);
125
126 int filter_packets(capture_file *cf, gchar *dfilter);
127 void colorize_packets(capture_file *);
128 int print_packets(capture_file *cf, print_args_t *print_args);
129 void change_time_formats(capture_file *);
130 gboolean find_packet(capture_file *cf, dfilter *sfcode);
131
132 typedef enum {
133   FOUND_FRAME,          /* found the frame */
134   NO_SUCH_FRAME,        /* no frame with that number */
135   FRAME_NOT_DISPLAYED   /* frame with that number isn't displayed */
136 } goto_result_t;
137 goto_result_t goto_frame(capture_file *cf, guint fnumber);
138
139 void select_packet(capture_file *, int);
140 void unselect_packet(capture_file *);
141
142 /* Moves or copies a file. Returns 0 on failure, 1 on success */
143 int file_mv(char *from, char *to);
144
145 /* Copies a file. Returns 0 on failure, 1 on success */
146 int file_cp(char *from, char *to);
147
148 char *file_open_error_message(int, int);
149 char *file_read_error_message(int);
150 char *file_write_error_message(int);
151
152 #endif /* file.h */