From Harald Welte:
[obnox/wireshark/wip.git] / cfile.h
1 /* cfile.h
2  * capture_file definition & GUI-independent manipulation
3  *
4  * $Id$
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
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 __CFILE_H__
26 #define __CFILE_H__
27
28 #include "frame_data_sequence.h"
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif /* __cplusplus */
33
34 /* Current state of file. */
35 typedef enum {
36   FILE_CLOSED,                  /* No file open */
37   FILE_READ_IN_PROGRESS,        /* Reading a file we've opened */
38   FILE_READ_ABORTED,            /* Read aborted by user */
39   FILE_READ_DONE                /* Read completed */
40 } file_state;
41
42 /* Character set for text search. */
43 typedef enum {
44   SCS_ASCII_AND_UNICODE,
45   SCS_ASCII,
46   SCS_UNICODE
47   /* add EBCDIC when it's implemented */
48 } search_charset_t;
49
50 typedef enum {
51   SD_FORWARD,
52   SD_BACKWARD
53 } search_direction;
54
55 /*
56  * We store the frame_data structures in a radix tree, with 1024
57  * elements per level.  The leaf nodes are arrays of 1024 frame_data
58  * structures; the nodes above them are arrays of 1024 pointers to
59  * the nodes below them.  The capture_file structure has a pointer
60  * to the root node.
61  *
62  * As frame numbers are 32 bits, and as 1024 is 2^10, that gives us
63  * up to 4 levels of tree.
64  */
65 #define LOG2_NODES_PER_LEVEL    10
66 #define NODES_PER_LEVEL         (1<<LOG2_NODES_PER_LEVEL)
67
68 typedef struct _capture_file {
69   file_state   state;           /* Current state of capture file */
70   gchar       *filename;        /* Name of capture file */
71   gchar       *source;          /* Temp file source, e.g. "Pipe from elsewhere" */
72   gboolean     is_tempfile;     /* Is capture file a temporary file? */
73   gboolean     user_saved;      /* If capture file is temporary, has it been saved by user yet? */
74   gint64       f_datalen;       /* Size of capture file data (uncompressed) */
75   guint16      cd_t;            /* File type of capture file */
76   int          lnk_t;           /* Link-layer type with which to save capture */
77   guint32      count;           /* Total number of frames */
78   guint32      displayed_count; /* Number of displayed frames */
79   guint32      marked_count;    /* Number of marked frames */
80   guint32      ignored_count;   /* Number of ignored frames */
81   guint32      ref_time_count;  /* Number of time referenced frames */
82   gboolean     drops_known;     /* TRUE if we know how many packets were dropped */
83   guint32      drops;           /* Dropped packets */
84   nstime_t     elapsed_time;    /* Elapsed time */
85   gboolean     has_snap;        /* TRUE if maximum capture packet length is known */
86   int          snap;            /* Maximum captured packet length */
87   wtap        *wth;             /* Wiretap session */
88   dfilter_t   *rfcode;          /* Compiled read (display) filter program */
89   gchar       *dfilter;         /* Display filter string */
90   gboolean     redissecting;    /* TRUE if currently redissecting (cf_redissect_packets) */
91   /* search */
92   gchar       *sfilter;         /* Filter, hex value, or string being searched */
93   gboolean     hex;             /* TRUE if "Hex value" search was last selected */
94   gboolean     string;          /* TRUE if "String" search was last selected */
95   gboolean     summary_data;    /* TRUE if "String" search in "Packet list" (Info column) was last selected */
96   gboolean     decode_data;     /* TRUE if "String" search in "Packet details" was last selected */
97   gboolean     packet_data;     /* TRUE if "String" search in "Packet data" was last selected */
98   guint32      search_pos;      /* Byte position of last byte found in a hex search */
99   gboolean     case_type;       /* TRUE if case-insensitive text search */
100   search_charset_t scs_type;    /* Character set for text search */
101   search_direction dir;         /* Direction in which to do searches */
102   gboolean     search_in_progress; /* TRUE if user just clicked OK in the Find dialog or hit <control>N/B */
103   /* packet data */
104   union wtap_pseudo_header pseudo_header; /* Packet pseudo_header */
105   guint8       pd[WTAP_MAX_PACKET_SIZE];  /* Packet data */
106   /* frames */
107   frame_data_sequence *frames;  /* Sequence of frames, if we're keeping that information */
108   guint32      first_displayed; /* Frame number of first frame displayed */
109   guint32      last_displayed;  /* Frame number of last frame displayed */
110   column_info  cinfo;           /* Column formatting information */
111   frame_data  *current_frame;   /* Frame data for current frame */
112   gint         current_row;     /* Row number for current frame */
113   epan_dissect_t *edt;          /* Protocol dissection for currently selected packet */
114   field_info  *finfo_selected;  /* Field info for currently selected field */
115 #ifdef WANT_PACKET_EDITOR
116   GTree       *edited_frames;   /* BST with modified frames */
117 #endif
118 } capture_file;
119
120 extern void cap_file_init(capture_file *cf);
121
122 #ifdef __cplusplus
123 }
124 #endif /* __cplusplus */
125
126 #endif /* cfile.h */