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