1 /* frame_data.h 2 * Definitions for frame_data structures and routines 3 * 4 * Wireshark - Network traffic analyzer 5 * By Gerald Combs <gerald@wireshark.org> 6 * Copyright 1998 Gerald Combs 7 * 8 * SPDX-License-Identifier: GPL-2.0-or-later 9 */ 10 11 #ifndef __FRAME_DATA_H__ 12 #define __FRAME_DATA_H__ 13 14 #include <ws_diag_control.h> 15 #include <ws_symbol_export.h> 16 #include <wsutil/nstime.h> 17 18 #include <wiretap/wtap.h> 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif /* __cplusplus */ 23 24 struct _packet_info; 25 struct epan_session; 26 27 #define PINFO_FD_VISITED(pinfo) ((pinfo)->fd->visited) 28 29 /** @file 30 * Low-level frame data and metadata. 31 */ 32 33 /** @defgroup framedata Frame Data 34 * 35 * @{ 36 */ 37 38 /** @todo XXX - some of this stuff is used only while a packet is being dissected; 39 should we keep that stuff in the "packet_info" structure, instead, to 40 save memory? */ 41 42 /* Types of character encodings */ 43 typedef enum { 44 PACKET_CHAR_ENC_CHAR_ASCII = 0, /* ASCII */ 45 PACKET_CHAR_ENC_CHAR_EBCDIC = 1 /* EBCDIC */ 46 } packet_char_enc; 47 48 /** The frame number is the ordinal number of the frame in the capture, so 49 it's 1-origin. In various contexts, 0 as a frame number means "frame 50 number unknown". 51 52 There is one of these structures for every frame in the capture. 53 That means a lot of memory if we have a lot of frames. 54 They are packed into power-of-2 chunks, so their size is effectively 55 rounded up to a power of 2. 56 Try to keep it close to, and less than or equal to, a power of 2. 57 "Smaller than a power of 2" is OK for ILP32 platforms. 58 59 XXX - shuffle the fields to try to keep the most commonly-accessed 60 fields within the first 16 or 32 bytes, so they all fit in a cache 61 line? */ 62 struct _color_filter; /* Forward */ 63 DIAG_OFF_PEDANTIC 64 typedef struct _frame_data { 65 guint32 num; /**< Frame number */ 66 guint32 pkt_len; /**< Packet length */ 67 guint32 cap_len; /**< Amount actually captured */ 68 guint32 cum_bytes; /**< Cumulative bytes into the capture */ 69 gint64 file_off; /**< File offset */ 70 /* These two are pointers, meaning 64-bit on LP64 (64-bit UN*X) and 71 LLP64 (64-bit Windows) platforms. Put them here, one after the 72 other, so they don't require padding between them. */ 73 GSList *pfd; /**< Per frame proto data */ 74 const struct _color_filter *color_filter; /**< Per-packet matching color_filter_t object */ 75 guint16 subnum; /**< subframe number, for protocols that require this */ 76 /* Keep the bitfields below to 16 bits, so this plus the previous field 77 are 32 bits. */ 78 unsigned int passed_dfilter : 1; /**< 1 = display, 0 = no display */ 79 unsigned int dependent_of_displayed : 1; /**< 1 if a displayed frame depends on this frame */ 80 /* Do NOT use packet_char_enc enum here: MSVC compiler does not handle an enum in a bit field properly */ 81 unsigned int encoding : 1; /**< Character encoding (ASCII, EBCDIC...) */ 82 unsigned int visited : 1; /**< Has this packet been visited yet? 1=Yes,0=No*/ 83 unsigned int marked : 1; /**< 1 = marked by user, 0 = normal */ 84 unsigned int ref_time : 1; /**< 1 = marked as a reference time frame, 0 = normal */ 85 unsigned int ignored : 1; /**< 1 = ignore this frame, 0 = normal */ 86 unsigned int has_ts : 1; /**< 1 = has time stamp, 0 = no time stamp */ 87 unsigned int has_modified_block : 1; /** 1 = block for this packet has been modified */ 88 unsigned int need_colorize : 1; /**< 1 = need to (re-)calculate packet color */ 89 unsigned int tsprec : 4; /**< Time stamp precision -2^tsprec gives up to femtoseconds */ 90 nstime_t abs_ts; /**< Absolute timestamp */ 91 nstime_t shift_offset; /**< How much the abs_tm of the frame is shifted */ 92 guint32 frame_ref_num; /**< Previous reference frame (0 if this is one) */ 93 guint32 prev_dis_num; /**< Previous displayed frame (0 if first one) */ 94 } frame_data; 95 DIAG_ON_PEDANTIC 96 97 /** compare two frame_datas */ 98 WS_DLL_PUBLIC gint frame_data_compare(const struct epan_session *epan, const frame_data *fdata1, const frame_data *fdata2, int field); 99 100 WS_DLL_PUBLIC void frame_data_reset(frame_data *fdata); 101 102 WS_DLL_PUBLIC void frame_data_destroy(frame_data *fdata); 103 104 WS_DLL_PUBLIC void frame_data_init(frame_data *fdata, guint32 num, 105 const wtap_rec *rec, gint64 offset, 106 guint32 cum_bytes); 107 108 extern void frame_delta_abs_time(const struct epan_session *epan, const frame_data *fdata, 109 guint32 prev_num, nstime_t *delta); 110 /** 111 * Sets the frame data struct values before dissection. 112 */ 113 WS_DLL_PUBLIC void frame_data_set_before_dissect(frame_data *fdata, 114 nstime_t *elapsed_time, 115 const frame_data **frame_ref, 116 const frame_data *prev_dis); 117 118 WS_DLL_PUBLIC void frame_data_set_after_dissect(frame_data *fdata, 119 guint32 *cum_bytes); 120 121 /** @} */ 122 123 #ifdef __cplusplus 124 } 125 #endif /* __cplusplus */ 126 127 #endif /* __FRAME_DATA__ */ 128 129 /* 130 * Editor modelines - https://www.wireshark.org/tools/modelines.html 131 * 132 * Local variables: 133 * c-basic-offset: 2 134 * tab-width: 8 135 * indent-tabs-mode: nil 136 * End: 137 * 138 * vi: set shiftwidth=2 tabstop=8 expandtab: 139 * :indentSize=2:tabSize=8:noTabs=true: 140 */ 141