2 * Definitions for file structures and routines
4 * $Id: file.h,v 1.19 1999/07/09 04:18:35 gram 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 #include <sys/types.h>
42 typedef struct bpf_program bpf_prog;
44 typedef struct _capture_file {
45 FILE *fh; /* Capture file */
46 gchar *filename; /* filename */
47 long f_len; /* File length */
48 guint16 cd_t; /* Capture data type */
49 guint32 vers; /* Version. For tcpdump minor is appended to major */
50 guint32 count; /* Packet count */
51 guint32 drops; /* Dropped packets */
52 guint32 esec; /* Elapsed seconds */
53 guint32 eusec; /* Elapsed microseconds */
54 guint32 snap; /* Captured packet length */
55 gchar *iface; /* Interface */
56 gchar *save_file; /* File that user saved capture to */
57 gint user_saved;/* Was capture file saved by user yet? */
58 wtap *wth; /* Wiretap session */
59 gchar *dfilter; /* Display filter string */
60 GNode *dfcode; /* Compiled display filter program */
62 gchar *cfilter; /* Capture filter string */
63 bpf_prog fcode; /* Compiled capture filter program */
65 /* XXX - I'm cheating for now. I'll hardcode 65536 here until I re-arrange
66 * more header files so that ethereal.h is split up into two files, a
67 * generic header and a gtk+-speficic header (or the gtk+ definitions are
68 * moved to different header files) --gilbert
70 /*guint8 pd[MAX_PACKET_SIZE];*/ /* Packet data */
71 guint8 pd[65536]; /* Packet data */
72 GList *plist; /* Packet list */
73 frame_data *cur; /* Frame data for current list item */
74 column_info cinfo; /* Column formatting information */
79 * "open_cap_file()" can return:
83 * a positive "errno" value on an open failure;
85 * a negative number, indicating the type of error, on other failures.
87 #define OPEN_CAP_FILE_NOT_REGULAR -1 /* not a plain file */
88 #define OPEN_CAP_FILE_UNKNOWN_FORMAT -2 /* not a capture file in a known format */
90 int open_cap_file(char *, capture_file *);
91 void close_cap_file(capture_file *, void *, guint);
92 int load_cap_file(char *, capture_file *);
93 int tail_cap_file(char *, capture_file *);
94 /* size_t read_frame_header(capture_file *); */
96 void filter_packets(capture_file *);
97 void change_time_formats(capture_file *);
99 /* Moves or copies a file. Returns 0 on failure, 1 on success */
100 int file_mv(char *from, char *to);
102 /* Copies a file. Returns 0 on failure, 1 on success */
103 int file_cp(char *from, char *to);
105 char *file_open_error_message(int, int);
106 char *file_read_error_message(int);
107 char *file_write_error_message(int);