2 * Definitions for file structures and routines
4 * $Id: file.h,v 1.13 1999/05/11 18:51:10 deniel 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>
38 /* Data file formats */
44 #define CD_NA_UNCOMPR 5
46 /* Data file magic info */
47 #define SNOOP_MAGIC_1 0x736e6f6f /* 'snoop' in ASCII */
48 #define SNOOP_MAGIC_2 0x70000000
49 #define PCAP_MAGIC 0xa1b2c3d4
51 /* Data file format versions we can handle */
52 #define SNOOP_MIN_VERSION 2
53 #define SNOOP_MAX_VERSION 2
55 /* Link types (removed in favor of the DLT_* defines from bpf.h */
58 typedef struct bpf_program bpf_prog;
60 typedef struct _capture_file {
61 FILE *fh; /* Capture file */
62 gchar *filename; /* filename */
63 long f_len; /* File length */
65 int swap; /* Swap data bytes? */
67 guint16 cd_t; /* Capture data type */
68 guint32 vers; /* Version. For tcpdump minor is appended to major */
70 guint32 lnk_t; /* Network link type */
72 guint32 count; /* Packet count */
73 guint32 drops; /* Dropped packets */
74 guint32 esec; /* Elapsed seconds */
75 guint32 eusec; /* Elapsed microseconds */
76 guint32 snap; /* Captured packet length */
77 gchar *iface; /* Interface */
78 gchar *save_file; /* File that user saved capture to */
79 gint user_saved;/* Was capture file saved by user yet? */
81 wtap *wth; /* Wiretap session */
83 pcap_t *pfh; /* Pcap session */
85 gchar *dfilter; /* Display filter string */
86 gchar *cfilter; /* Capture filter string */
87 bpf_prog fcode; /* Compiled filter program */
88 /* XXX - I'm cheating for now. I'll hardcode 65536 here until I re-arrange
89 * more header files so that ethereal.h is split up into two files, a
90 * generic header and a gtk+-speficic header (or the gtk+ definitions are
91 * moved to different header files) --gilbert
93 /*guint8 pd[MAX_PACKET_SIZE];*/ /* Packet data */
94 guint8 pd[65536]; /* Packet data */
95 GList *plist_first;/* First packet in list */
96 GList *plist; /* Packet list */
97 frame_data *cur; /* Current list item */
98 column_info cinfo; /* Column formatting information */
101 /* Taken from RFC 1761 */
104 typedef struct _snoop_file_hdr {
111 typedef struct _snoop_frame_hdr {
121 int open_cap_file(char *, capture_file *);
122 void close_cap_file(capture_file *, void *, guint);
123 int load_cap_file(char *, capture_file *);
124 int tail_cap_file(char *, capture_file *);
125 /* size_t read_frame_header(capture_file *); */