Make the bytes-written information from Wiretap a long, as we allow
[metze/wireshark/wip.git] / file.h
1 /* file.h
2  * Definitions for file structures and routines
3  *
4  * $Id: file.h,v 1.86 2001/12/04 08:25:55 guy Exp $
5  *
6  * Ethereal - Network traffic analyzer
7  * By Gerald Combs <gerald@ethereal.com>
8  * Copyright 1998 Gerald Combs
9  * 
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  * 
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  * 
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23  */
24
25 #ifndef __FILE_H__
26 #define __FILE_H__
27
28 #ifdef HAVE_SYS_TYPES_H
29 #include <sys/types.h>
30 #endif
31
32 #include "wiretap/wtap.h"
33 #include "dfilter/dfilter.h"
34 #include "print.h"
35 #include <errno.h>
36 #include <epan.h>
37
38 /* Current state of file. */
39 typedef enum {
40         FILE_CLOSED,            /* No file open */
41         FILE_READ_IN_PROGRESS,  /* Reading a file we've opened */
42         FILE_READ_ABORTED,      /* Read aborted by user */
43         FILE_READ_DONE          /* Read completed */
44 } file_state;
45
46 typedef struct _capture_file {
47   file_state   state;     /* Current state of capture file */
48   int          filed;     /* File descriptor of capture file */
49   gchar       *filename;  /* Name of capture file */
50   gboolean     is_tempfile; /* Is capture file a temporary file? */
51   gboolean     user_saved;/* If capture file is temporary, has it been saved by user yet? */
52   long         f_len;     /* Length of capture file */
53   guint16      cd_t;      /* File type of capture file */
54   int          lnk_t;     /* Link-layer type with which to save capture */
55   guint32      vers;      /* Version.  For tcpdump minor is appended to major */
56   int          count;     /* Packet count */
57   gboolean     drops_known; /* TRUE if we know how many packets were dropped */
58   guint32      drops;     /* Dropped packets */
59   guint32      esec;      /* Elapsed seconds */
60   guint32      eusec;     /* Elapsed microseconds */
61   int          snap;      /* Captured packet length */
62   long         progbar_quantum; /* Number of bytes read per progress bar update */
63   long         progbar_nextstep; /* Next point at which to update progress bar */
64   gchar       *iface;     /* Interface */
65   gchar       *save_file; /* File that user saved capture to */
66   int          save_file_fd; /* File descriptor for saved file */
67   wtap        *wth;       /* Wiretap session */
68   dfilter_t   *rfcode;    /* Compiled read filter program */ 
69   gchar       *dfilter;   /* Display filter string */
70   struct _colfilter   *colors;    /* Colors for colorizing packet window */
71   dfilter_t   *dfcode;    /* Compiled display filter program */ 
72 #ifdef HAVE_LIBPCAP
73   gchar       *cfilter;   /* Capture filter string */
74 #endif
75   gchar       *sfilter;   /* Search filter string */
76   gboolean     sbackward;  /* TRUE if search is backward, FALSE if forward */
77   union wtap_pseudo_header pseudo_header;      /* Packet pseudo_header */
78   guint8       pd[WTAP_MAX_PACKET_SIZE];  /* Packet data */
79   GMemChunk   *plist_chunk; /* Memory chunk for frame_data structures */
80   frame_data  *plist;     /* Packet list */
81   frame_data  *plist_end; /* Last packet in list */
82   frame_data  *first_displayed; /* First frame displayed */
83   frame_data  *last_displayed;  /* Last frame displayed */
84   column_info  cinfo;    /* Column formatting information */
85   frame_data  *current_frame;  /* Frame data for current frame */
86   proto_tree  *protocol_tree; /* Protocol tree for currently selected packet */
87   epan_dissect_t *edt; /* Protocol dissection fo rcurrently selected packet */
88   FILE        *print_fh;  /* File we're printing to */
89 #ifdef HAVE_LIBPCAP
90   gint32       autostop_filesize; /* Maximum capture file size */
91   gint32       autostop_duration; /* Maximum capture duration */
92   gboolean     ringbuffer_on; /* Ringbuffer option */
93   guint32      ringbuffer_num_files; /* Number of ringbuffer files */
94 #endif
95 } capture_file;
96
97 /* Return values from "read_cap_file()", "continue_tail_cap_file()",
98    and "finish_tail_cap_file()". */
99 typedef enum {
100         READ_SUCCESS,   /* read succeeded */
101         READ_ERROR,     /* read got an error */
102         READ_ABORTED    /* read aborted by user */
103 } read_status_t;
104
105 int  open_cap_file(char *, gboolean, capture_file *);
106 void close_cap_file(capture_file *);
107 read_status_t read_cap_file(capture_file *, int *);
108 int  start_tail_cap_file(char *, gboolean, capture_file *);
109 read_status_t continue_tail_cap_file(capture_file *, int, int *);
110 read_status_t finish_tail_cap_file(capture_file *, int *);
111 /* size_t read_frame_header(capture_file *); */
112 int  save_cap_file(char *, capture_file *, gboolean, gboolean, guint);
113
114 int filter_packets(capture_file *cf, gchar *dfilter);
115 void colorize_packets(capture_file *);
116 void redissect_packets(capture_file *cf);
117 int print_packets(capture_file *cf, print_args_t *print_args);
118 void change_time_formats(capture_file *);
119 gboolean find_packet(capture_file *cf, dfilter_t *sfcode);
120
121 typedef enum {
122   FOUND_FRAME,          /* found the frame */
123   NO_SUCH_FRAME,        /* no frame with that number */
124   FRAME_NOT_DISPLAYED   /* frame with that number isn't displayed */
125 } goto_result_t;
126 goto_result_t goto_frame(capture_file *cf, guint fnumber);
127
128 void select_packet(capture_file *, int);
129 void unselect_packet(capture_file *);
130
131 void unselect_field(void);
132
133 /* Moves or copies a file. Returns 0 on failure, 1 on success */
134 int file_mv(char *from, char *to);
135
136 /* Copies a file. Returns 0 on failure, 1 on success */
137 int file_cp(char *from, char *to);
138
139 char *file_open_error_message(int, gboolean);
140 char *file_read_error_message(int);
141 char *file_write_error_message(int);
142
143 #endif /* file.h */