Fixed problem where filename of capture file would not be displayed in
[obnox/wireshark/wip.git] / file.h
1 /* file.h
2  * Definitions for file structures and routines
3  *
4  * $Id: file.h,v 1.13 1999/05/11 18:51:10 deniel 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 #include <sys/types.h>
30 #include <sys/time.h>
31
32 #ifdef WITH_WIRETAP
33  #include <wtap.h>
34  #include <pcap.h>
35 #else
36  #include <pcap.h>
37
38   /* Data file formats */
39   #define CD_UNKNOWN    0
40   #define CD_WIRE       1
41   #define CD_SNOOP      2
42   #define CD_PCAP_BE    3
43   #define CD_PCAP_LE    4
44   #define CD_NA_UNCOMPR 5
45
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
50
51   /* Data file format versions we can handle */
52   #define SNOOP_MIN_VERSION 2
53   #define SNOOP_MAX_VERSION 2
54
55   /* Link types (removed in favor of the DLT_* defines from bpf.h */
56 #endif
57
58 typedef struct bpf_program bpf_prog;
59
60 typedef struct _capture_file {
61   FILE       *fh;        /* Capture file */
62   gchar      *filename;  /* filename */
63   long        f_len;     /* File length */
64 #ifndef WITH_WIRETAP
65   int         swap;      /* Swap data bytes? */
66 #endif
67   guint16     cd_t;      /* Capture data type */
68   guint32     vers;      /* Version.  For tcpdump minor is appended to major */
69 #ifndef WITH_WIRETAP
70   guint32     lnk_t;     /* Network link type */
71 #endif
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? */
80 #ifdef WITH_WIRETAP
81   wtap     *wth;         /* Wiretap session */
82 #else
83   pcap_t     *pfh;       /* Pcap session */
84 #endif
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
92    */
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 */
99 } capture_file;
100
101 /* Taken from RFC 1761 */
102
103 #ifndef WITH_WIRETAP
104 typedef struct _snoop_file_hdr {
105   guint32 magic1;
106   guint32 magic2;
107   guint32 vers;
108   guint32 s_lnk_t;
109 } snoop_file_hdr;
110
111 typedef struct _snoop_frame_hdr {
112   guint32 orig_len;
113   guint32 inc_len;
114   guint32 pr_len;
115   guint32 drops;
116   guint32 secs;
117   guint32 usecs;
118 } snoop_frame_hdr;
119 #endif
120
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 *); */
126
127 #endif /* file.h */