Return ByteArray as "value" for FieldInfo's with type FT_NONE (which has data).
[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 <wsutil/nstime.h>
31 #include "ws_symbol_export.h"
32
33 #define PINFO_FD_NUM(pinfo)       ((pinfo)->fd->num)
34 #define PINFO_FD_VISITED(pinfo)   ((pinfo)->fd->flags.visited)
35
36 /** @file
37  * Low-level frame data and metadata.
38  */
39
40 /** @defgroup framedata Frame Data
41  *
42  * @{
43  */
44
45 /** @todo XXX - some of this stuff is used only while a packet is being dissected;
46    should we keep that stuff in the "packet_info" structure, instead, to
47    save memory? */
48
49 /* Types of character encodings */
50 typedef enum {
51         PACKET_CHAR_ENC_CHAR_ASCII       = 0,   /* ASCII */
52         PACKET_CHAR_ENC_CHAR_EBCDIC      = 1    /* EBCDIC */
53 } packet_char_enc;
54
55 /** The frame number is the ordinal number of the frame in the capture, so
56    it's 1-origin.  In various contexts, 0 as a frame number means "frame
57    number unknown". */
58 typedef struct _frame_data {
59   GSList      *pfd;          /**< Per frame proto data */
60   guint32      num;          /**< Frame number */
61   guint32      pkt_len;      /**< Packet length */
62   guint32      cap_len;      /**< Amount actually captured */
63   guint32      cum_bytes;    /**< Cumulative bytes into the capture */
64   gint64       file_off;     /**< File offset */
65   guint16      subnum;       /**< subframe number, for protocols that require this */
66   gint16       lnk_t;        /**< Per-packet encapsulation/data-link type */
67   struct {
68     unsigned int passed_dfilter : 1; /**< 1 = display, 0 = no display */
69     unsigned int dependent_of_displayed : 1; /**< 1 if a displayed frame depends on this frame */
70     unsigned int encoding       : 1; /**< Character encoding (ASCII, EBCDIC...) */
71     unsigned int visited        : 1; /**< Has this packet been visited yet? 1=Yes,0=No*/
72     unsigned int marked         : 1; /**< 1 = marked by user, 0 = normal */
73     unsigned int ref_time       : 1; /**< 1 = marked as a reference time frame, 0 = normal */
74     unsigned int ignored        : 1; /**< 1 = ignore this frame, 0 = normal */
75     unsigned int has_ts         : 1; /**< 1 = has time stamp, 0 = no time stamp */
76     unsigned int has_phdr_comment : 1; /** 1 = there's comment for this packet */
77     unsigned int has_user_comment : 1; /** 1 = user set (also deleted) comment for this packet */
78   } flags;
79
80   const void *color_filter;  /**< Per-packet matching color_filter_t object */
81
82   nstime_t     abs_ts;       /**< Absolute timestamp */
83   nstime_t     shift_offset; /**< How much the abs_tm of the frame is shifted */
84   guint32      frame_ref_num; /**< Previous reference frame (0 if this is one) */
85   guint32      prev_dis_num; /**< Previous displayed frame (0 if first one) */
86 } frame_data;
87
88 #ifdef WANT_PACKET_EDITOR
89 /* XXX, where this struct should go? */
90 typedef struct {
91   struct wtap_pkthdr phdr; /**< Modified packet header */
92   char *pd;                /**< Modified packet data */
93 } modified_frame_data;
94 #endif
95
96 /* Utility routines used by packet*.c */
97
98 WS_DLL_PUBLIC void p_add_proto_data(frame_data *fd, int proto, guint8 key, void *proto_data);
99 WS_DLL_PUBLIC void *p_get_proto_data(frame_data *fd, int proto, guint8 key);
100 void p_remove_proto_data(frame_data *fd, int proto, guint8 key);
101 gchar *p_get_proto_name_and_key(frame_data *fd, guint pfd_index);
102
103 /* no sense to include epan.h + dependencies for opaque epan session type */
104 struct epan_session;
105
106 /** compare two frame_datas */
107 WS_DLL_PUBLIC gint frame_data_compare(const struct epan_session *epan, const frame_data *fdata1, const frame_data *fdata2, int field);
108
109 WS_DLL_PUBLIC void frame_data_reset(frame_data *fdata);
110
111 WS_DLL_PUBLIC void frame_data_destroy(frame_data *fdata);
112
113 WS_DLL_PUBLIC void frame_data_init(frame_data *fdata, guint32 num,
114                 const struct wtap_pkthdr *phdr, gint64 offset,
115                 guint32 cum_bytes);
116
117 extern void frame_delta_abs_time(const struct epan_session *epan, const frame_data *fdata,
118                 guint32 prev_num, nstime_t *delta);
119 /**
120  * Sets the frame data struct values before dissection.
121  */
122 WS_DLL_PUBLIC void frame_data_set_before_dissect(frame_data *fdata,
123                 nstime_t *elapsed_time,
124                 const frame_data **frame_ref,
125                 const frame_data *prev_dis);
126
127 WS_DLL_PUBLIC void frame_data_set_after_dissect(frame_data *fdata,
128                 guint32 *cum_bytes);
129
130 /** @} */
131
132 #endif  /* __FRAME_DATA__ */