Add wtap_pseudo_header union to wtap_pkthdr structure.
[metze/wireshark/wip.git] / epan / frame_data.h
1 /* frame_data.h
2  * Definitions for frame_data structures and routines
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  */
24
25 #ifndef __FRAME_DATA_H__
26 #define __FRAME_DATA_H__
27
28 #include <epan/column_info.h>
29 #include <epan/tvbuff.h>
30 #include <epan/nstime.h>
31
32 #define PINFO_FD_NUM(pinfo)       ((pinfo)->fd->num)
33 #define PINFO_FD_VISITED(pinfo)   ((pinfo)->fd->flags.visited)
34
35 /** @todo XXX - some of this stuff is used only while a packet is being dissected;
36    should we keep that stuff in the "packet_info" structure, instead, to
37    save memory? */
38
39 /** The frame number is the ordinal number of the frame in the capture, so
40    it's 1-origin.  In various contexts, 0 as a frame number means "frame
41    number unknown". */
42 typedef struct _frame_data {
43   GSList      *pfd;          /**< Per frame proto data */
44   guint32      num;          /**< Frame number */
45   guint32      interface_id; /**< identifier of the interface. */
46   guint32      pkt_len;      /**< Packet length */
47   guint32      cap_len;      /**< Amount actually captured */
48   guint32      cum_bytes;    /**< Cumulative bytes into the capture */
49   gint64       file_off;     /**< File offset */
50   guint16      subnum;       /**< subframe number, for protocols that require this */
51   gint16       lnk_t;        /**< Per-packet encapsulation/data-link type */
52   struct {
53     unsigned int passed_dfilter : 1; /**< 1 = display, 0 = no display */
54     unsigned int dependent_of_displayed : 1; /**< 1 if a displayed frame depends on this frame */
55     unsigned int encoding       : 2; /**< Character encoding (ASCII, EBCDIC...) */
56     unsigned int visited        : 1; /**< Has this packet been visited yet? 1=Yes,0=No*/
57     unsigned int marked         : 1; /**< 1 = marked by user, 0 = normal */
58     unsigned int ref_time       : 1; /**< 1 = marked as a reference time frame, 0 = normal */
59     unsigned int ignored        : 1; /**< 1 = ignore this frame, 0 = normal */
60     unsigned int has_ts         : 1; /**< 1 = has time stamp, 0 = no time stamp */
61     unsigned int has_if_id      : 1; /**< 1 = has interface ID, 0 = no interface ID */
62   } flags;
63
64   const void *color_filter;  /**< Per-packet matching color_filter_t object */
65
66   nstime_t     abs_ts;       /**< Absolute timestamp */
67   nstime_t     shift_offset; /**< How much the abs_tm of the frame is shifted */
68   nstime_t     rel_ts;       /**< Relative timestamp (yes, it can be negative) */
69   const struct _frame_data *prev_dis;   /**< Previous displayed frame */
70   const struct _frame_data *prev_cap;   /**< Previous captured frame */
71   gchar        *opt_comment; /**< NULL if not available */
72 } frame_data;
73
74 #ifdef WANT_PACKET_EDITOR
75 /* XXX, where this struct should go? */
76 typedef struct {
77   struct wtap_pkthdr phdr; /**< Modified packet header */
78   char *pd;                /**< Modified packet data */
79 } modified_frame_data;
80 #endif
81
82 /**
83  * A data source.
84  * Has a tvbuff and a name.
85  */
86 typedef struct {
87   tvbuff_t *tvb;
88   gboolean name_initialized;
89   const char *name;
90 } data_source;
91
92 /* Utility routines used by packet*.c */
93
94 extern void p_add_proto_data(frame_data *fd, int proto, void *proto_data);
95 extern void *p_get_proto_data(frame_data *fd, int proto);
96 extern void p_remove_proto_data(frame_data *fd, int proto);
97
98 /** compare two frame_datas */
99 extern gint frame_data_compare(const frame_data *fdata1, const frame_data *fdata2, int field);
100
101 extern void frame_data_cleanup(frame_data *fdata);
102
103 extern void frame_data_init(frame_data *fdata, guint32 num,
104                 const struct wtap_pkthdr *phdr, gint64 offset,
105                 guint32 cum_bytes);
106
107 extern void frame_delta_abs_time(const frame_data *fdata, 
108                 const frame_data *prev, nstime_t *delta);
109 /**
110  * Sets the frame data struct values before dissection.
111  */
112 extern void frame_data_set_before_dissect(frame_data *fdata,
113                 nstime_t *elapsed_time,
114                 nstime_t *first_ts,
115                 const frame_data *prev_dis,
116                 const frame_data *prev_cap);
117
118 extern void frame_data_set_after_dissect(frame_data *fdata,
119                 guint32 *cum_bytes);
120
121 #endif  /* __FRAME_DATA__ */
122