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