2 * Definitions for file structures and routines
4 * $Id: file.h,v 1.83 2001/06/05 07:38:33 guy Exp $
6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@ethereal.com>
8 * Copyright 1998 Gerald Combs
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.
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.
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.
28 #ifdef HAVE_SYS_TYPES_H
29 #include <sys/types.h>
32 #include "wiretap/wtap.h"
33 #include "dfilter/dfilter.h"
41 #define file_open gzopen
42 #define filed_open gzdopen
43 #define file_close gzclose
46 #define file_open fopen
47 #define filed_open fdopen
48 #define file_close fclose
49 #endif /* HAVE_LIBZ */
51 /* Current state of file. */
53 FILE_CLOSED, /* No file open */
54 FILE_READ_IN_PROGRESS, /* Reading a file we've opened */
55 FILE_READ_ABORTED, /* Read aborted by user */
56 FILE_READ_DONE /* Read completed */
59 typedef struct _capture_file {
60 file_state state; /* Current state of capture file */
61 int filed; /* File descriptor of capture file */
62 gchar *filename; /* Name of capture file */
63 gboolean is_tempfile; /* Is capture file a temporary file? */
64 gboolean user_saved;/* If capture file is temporary, has it been saved by user yet? */
65 long f_len; /* Length of capture file */
66 guint16 cd_t; /* File type of capture file */
67 int lnk_t; /* Link-layer type with which to save capture */
68 guint32 vers; /* Version. For tcpdump minor is appended to major */
69 int count; /* Packet count */
70 gboolean drops_known; /* TRUE if we know how many packets were dropped */
71 guint32 drops; /* Dropped packets */
72 guint32 esec; /* Elapsed seconds */
73 guint32 eusec; /* Elapsed microseconds */
74 int snap; /* Captured packet length */
75 long progbar_quantum; /* Number of bytes read per progress bar update */
76 long progbar_nextstep; /* Next point at which to update progress bar */
77 gchar *iface; /* Interface */
78 gchar *save_file; /* File that user saved capture to */
79 int save_file_fd; /* File descriptor for saved file */
80 wtap *wth; /* Wiretap session */
81 dfilter_t *rfcode; /* Compiled read filter program */
82 gchar *dfilter; /* Display filter string */
83 struct _colfilter *colors; /* Colors for colorizing packet window */
84 dfilter_t *dfcode; /* Compiled display filter program */
86 gchar *cfilter; /* Capture filter string */
88 gchar *sfilter; /* Search filter string */
89 gboolean sbackward; /* TRUE if search is backward, FALSE if forward */
90 union wtap_pseudo_header pseudo_header; /* Packet pseudo_header */
91 guint8 pd[WTAP_MAX_PACKET_SIZE]; /* Packet data */
92 GMemChunk *plist_chunk; /* Memory chunk for frame_data structures */
93 frame_data *plist; /* Packet list */
94 frame_data *plist_end; /* Last packet in list */
95 frame_data *first_displayed; /* First frame displayed */
96 frame_data *last_displayed; /* Last frame displayed */
97 column_info cinfo; /* Column formatting information */
98 frame_data *current_frame; /* Frame data for current frame */
99 proto_tree *protocol_tree; /* Protocol tree for currently selected packet */
100 epan_dissect_t *edt; /* Protocol dissection fo rcurrently selected packet */
101 FILE *print_fh; /* File we're printing to */
104 /* Return values from "read_cap_file()", "continue_tail_cap_file()",
105 and "finish_tail_cap_file()". */
107 READ_SUCCESS, /* read succeeded */
108 READ_ERROR, /* read got an error */
109 READ_ABORTED /* read aborted by user */
112 int open_cap_file(char *, gboolean, capture_file *);
113 void close_cap_file(capture_file *);
114 read_status_t read_cap_file(capture_file *, int *);
115 int start_tail_cap_file(char *, gboolean, capture_file *);
116 read_status_t continue_tail_cap_file(capture_file *, int, int *);
117 read_status_t finish_tail_cap_file(capture_file *, int *);
118 /* size_t read_frame_header(capture_file *); */
119 int save_cap_file(char *, capture_file *, gboolean, gboolean, guint);
121 int filter_packets(capture_file *cf, gchar *dfilter);
122 void colorize_packets(capture_file *);
123 void redissect_packets(capture_file *cf);
124 int print_packets(capture_file *cf, print_args_t *print_args);
125 void change_time_formats(capture_file *);
126 gboolean find_packet(capture_file *cf, dfilter_t *sfcode);
129 FOUND_FRAME, /* found the frame */
130 NO_SUCH_FRAME, /* no frame with that number */
131 FRAME_NOT_DISPLAYED /* frame with that number isn't displayed */
133 goto_result_t goto_frame(capture_file *cf, guint fnumber);
135 void select_packet(capture_file *, int);
136 void unselect_packet(capture_file *);
138 void unselect_field(void);
140 /* Moves or copies a file. Returns 0 on failure, 1 on success */
141 int file_mv(char *from, char *to);
143 /* Copies a file. Returns 0 on failure, 1 on success */
144 int file_cp(char *from, char *to);
146 char *file_open_error_message(int, gboolean);
147 char *file_read_error_message(int);
148 char *file_write_error_message(int);