### Bug Summary

File: | epan/frame_data.c
Warning: | line 50, column 19 Value stored to 'prev_abs_ts' during its initialization is never read

### Annotated Source Code

Press '?' to see keyboard shortcuts

Show analyzer invocation
clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name frame_data.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -fno-delete-null-pointer-checks -mframe-pointer=all -relaxed-aliasing -fmath-errno -ffp-contract=on -fno-rounding-math -ffloat16-excess-precision=fast -fbfloat16-excess-precision=fast -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/builds/wireshark/wireshark/build -fcoverage-compilation-dir=/builds/wireshark/wireshark/build -resource-dir /usr/lib/llvm-21/lib/clang/21 -isystem /usr/include/glib-2.0 -isystem /usr/lib/x86_64-linux-gnu/glib-2.0/include -isystem /builds/wireshark/wireshark/epan -isystem /builds/wireshark/wireshark/build/epan -isystem /usr/include/mit-krb5 -isystem /usr/include/libxml2 -isystem /usr/include/lua5.4 -D G_DISABLE_DEPRECATED -D G_DISABLE_SINGLE_INCLUDES -D WS_BUILD_DLL -D WS_DEBUG -D WS_DEBUG_UTF_8 -D epan_EXPORTS -I /builds/wireshark/wireshark/build -I /builds/wireshark/wireshark -I /builds/wireshark/wireshark/include -I /builds/wireshark/wireshark/wiretap -D _GLIBCXX_ASSERTIONS -internal-isystem /usr/lib/llvm-21/lib/clang/21/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fmacro-prefix-map=/builds/wireshark/wireshark/= -fmacro-prefix-map=/builds/wireshark/wireshark/build/= -fmacro-prefix-map=../= -Wno-format-truncation -Wno-format-nonliteral -Wno-pointer-sign -std=gnu11 -ferror-limit 19 -fvisibility=hidden -fwrapv -fwrapv-pointer -fstrict-flex-arrays=3 -stack-protector 2 -fstack-clash-protection -fcf-protection=full -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fexceptions -fcolor-diagnostics -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /builds/wireshark/wireshark/sbout/2025-10-26-100329-3623-1 -x c /builds/wireshark/wireshark/epan/frame_data.c

Keyboard shortcuts:

- Use 'j/k' keys for keyboard navigation
- Use 'Shift+S' to show/hide relevant lines
- Use '?' to toggle this window

Close
Show only relevant lines Show control flow arrows

1 | /* frame_data.c
2 | * Routines for packet disassembly
3 | *
4 | * Wireshark - Network traffic analyzer
5 | * By Gerald Combs <gerald@wireshark.org>
6 | * Copyright 1998 Gerald Combs
7 | *
8 | *
9 | * SPDX-License-Identifier: GPL-2.0-or-later
10 | */
11 |
12 | #include "config.h"
13 |
14 | #include <glib.h>
15 |
16 | #include <epan/epan.h>
17 | #include <epan/frame_data.h>
18 | #include <epan/column-utils.h>
19 | #include <epan/timestamp.h>
20 | #include <wiretap/wtap.h>
21 | #include <wsutil/ws_assert.h>
22 |
23 | #define COMPARE_FRAME_NUM()((fdata1->num < fdata2->num) ? -1 : (fdata1->num > fdata2->num) ? 1 : 0) ((fdata1->num < fdata2->num) ? -1 : \
24 | (fdata1->num > fdata2->num) ? 1 : \
25 | 0)
26 |
27 | #define COMPARE_NUM(f)((fdata1->f < fdata2->f) ? -1 : (fdata1->f > fdata2 ->f) ? 1 : ((fdata1->num < fdata2->num) ? -1 : (fdata1 ->num > fdata2->num) ? 1 : 0)) ((fdata1->f < fdata2->f) ? -1 : \
28 | (fdata1->f > fdata2->f) ? 1 : \
29 | COMPARE_FRAME_NUM()((fdata1->num < fdata2->num) ? -1 : (fdata1->num > fdata2->num) ? 1 : 0))
30 |
31 | /* Compare time stamps.
32 | A packet whose time is a reference time is considered to have
33 | a lower time stamp than any frame with a non-reference time;
34 | if both packets' times are reference times, we compare the
35 | times of the packets. */
36 | #define COMPARE_TS_REAL(time1, time2)((fdata1->ref_time && !fdata2->ref_time) ? -1 : (!fdata1->ref_time && fdata2->ref_time) ? 1 : ( (time1).secs < (time2).secs) ? -1 : ((time1).secs > (time2 ).secs) ? 1 : ((time1).nsecs < (time2).nsecs) ? -1 : ((time1 ).nsecs > (time2).nsecs) ? 1 : ((fdata1->num < fdata2 ->num) ? -1 : (fdata1->num > fdata2->num) ? 1 : 0 )) \
37 | ((fdata1->ref_time && !fdata2->ref_time) ? -1 : \
38 | (!fdata1->ref_time && fdata2->ref_time) ? 1 : \
39 | ((time1).secs < (time2).secs) ? -1 : \
40 | ((time1).secs > (time2).secs) ? 1 : \
41 | ((time1).nsecs < (time2).nsecs) ? -1 :\
42 | ((time1).nsecs > (time2).nsecs) ? 1 : \
43 | COMPARE_FRAME_NUM()((fdata1->num < fdata2->num) ? -1 : (fdata1->num > fdata2->num) ? 1 : 0))
44 |
45 | #define COMPARE_TS(ts)((fdata1->ref_time && !fdata2->ref_time) ? -1 : (!fdata1->ref_time && fdata2->ref_time) ? 1 : ( (fdata1->ts).secs < (fdata2->ts).secs) ? -1 : ((fdata1 ->ts).secs > (fdata2->ts).secs) ? 1 : ((fdata1->ts ).nsecs < (fdata2->ts).nsecs) ? -1 : ((fdata1->ts).nsecs > (fdata2->ts).nsecs) ? 1 : ((fdata1->num < fdata2 ->num) ? -1 : (fdata1->num > fdata2->num) ? 1 : 0 )) COMPARE_TS_REAL(fdata1->ts, fdata2->ts)((fdata1->ref_time && !fdata2->ref_time) ? -1 : (!fdata1->ref_time && fdata2->ref_time) ? 1 : ( (fdata1->ts).secs < (fdata2->ts).secs) ? -1 : ((fdata1 ->ts).secs > (fdata2->ts).secs) ? 1 : ((fdata1->ts ).nsecs < (fdata2->ts).nsecs) ? -1 : ((fdata1->ts).nsecs > (fdata2->ts).nsecs) ? 1 : ((fdata1->num < fdata2 ->num) ? -1 : (fdata1->num > fdata2->num) ? 1 : 0 ))
46 |
47 | static bool_Bool
48 | frame_delta_abs_time(const struct epan_session *epan, const frame_data *fdata, uint32_t prev_num, nstime_t *delta)
49 | {
50 | const nstime_t *prev_abs_ts = (prev_num) ? epan_get_frame_ts(epan, prev_num) : NULL((void*)0);
| Value stored to 'prev_abs_ts' during its initialization is never read
51 |
52 | if (!fdata->has_ts) {
53 | /* We don't have a time stamp for this packet. Set the delta time
54 | to zero, and return false. */
55 | nstime_set_zero(delta);
56 | return false0;
57 | }
58 |
59 | if (prev_num == 0) {
60 | /* The previous frame doesn't exist. Set the delta time to zero,
61 | and return false. */
62 | nstime_set_zero(delta);
63 | return false0;
64 | }
65 |
66 | /* Ge the previous frame's time stamp, if it has one. */
67 | prev_abs_ts = epan_get_frame_ts(epan, prev_num);
68 | if (prev_abs_ts == NULL((void*)0)) {
69 | /* The previous frame doesn't have a time stamp. Set the delta
70 | time to zero, and return false. */
71 | nstime_set_zero(delta);
72 | return false0;
73 | }
74 |
75 | /* This frame has a time stamp, the previous frame exists and has a
76 | time stamp; compute the delta between this frame's time stamp and
77 | the previous frame's time stamp, and return true. */
78 | nstime_delta(delta, &fdata->abs_ts, prev_abs_ts);
79 | return true1;
80 | }
81 |
82 | static int
83 | frame_compare_time_deltas(const frame_data *fdata1, bool_Bool have_ts1, const nstime_t *ts1,
84 | const frame_data *fdata2, bool_Bool have_ts2, const nstime_t *ts2)
85 | {
86 | if (!have_ts1) {
87 | if (!have_ts2) {
88 | /* We don't have either delta time; sort them the same. */
89 | return 0;
90 | }
91 |
92 | /*
93 | * We don't have ts1 but do have ts2; treat the first
94 | * as sorting lower than the second.
95 | */
96 | return -1;
97 | }
98 | if (!have_ts2) {
99 | /*
100 | * We have ts1 but don't have ts2; treat the first as
101 | * sorting greater than the second.
102 | */
103 | return 1;
104 | }
105 |
106 | /*
107 | * We have ts1 and ts2; compare them.
108 | */
109 | return COMPARE_TS_REAL(*ts1, *ts2)((fdata1->ref_time && !fdata2->ref_time) ? -1 : (!fdata1->ref_time && fdata2->ref_time) ? 1 : ( (*ts1).secs < (*ts2).secs) ? -1 : ((*ts1).secs > (*ts2) .secs) ? 1 : ((*ts1).nsecs < (*ts2).nsecs) ? -1 : ((*ts1). nsecs > (*ts2).nsecs) ? 1 : ((fdata1->num < fdata2-> num) ? -1 : (fdata1->num > fdata2->num) ? 1 : 0));
110 | }
111 |
112 | bool_Bool
113 | frame_rel_first_frame_time(const struct epan_session *epan,
114 | const frame_data *fdata, nstime_t *delta)
115 | {
116 | /*
117 | * Time relative to the first frame in the capture.
118 | */
119 | return frame_delta_abs_time(epan, fdata, 1, delta);
120 | }
121 |
122 | bool_Bool
123 | frame_rel_time(const struct epan_session *epan, const frame_data *fdata,
124 | nstime_t *delta)
125 | {
126 | /*
127 | * Time relative to the previous reference frame or, if there is no
128 | * previous reference frame, the first frame in the capture.
129 | */
130 | return frame_delta_abs_time(epan, fdata,
131 | fdata->frame_ref_num == 0 ? 1 : fdata->frame_ref_num,
132 | delta);
133 | }
134 |
135 | bool_Bool
136 | frame_rel_start_time(const struct epan_session *epan, const frame_data *fdata,
137 | nstime_t *delta)
138 | {
139 | if (!fdata->has_ts) {
140 | /* We don't have a time stamp for this packet. Set the delta time
141 | to zero, and return false. */
142 | /* XXX - Would it make more sense to set the delta time to "unset"
143 | * rather than zero here and in similar functions when returning
144 | * false? */
145 | nstime_set_zero(delta);
146 | return false0;
147 | }
148 |
149 | const nstime_t *start_ts = epan_get_start_ts(epan);
150 |
151 | if (start_ts == NULL((void*)0) || nstime_is_unset(start_ts)) {
152 | /* There isn't an explicit start time. Set the delta
153 | time to zero, and return false. */
154 | nstime_set_zero(delta);
155 | return false0;
156 | }
157 |
158 | /* This frame has a time stamp and the start time stamp exists;
159 | compute the delta between this frame's time stamp and
160 | the start time stamp, and return true. */
161 | nstime_delta(delta, &fdata->abs_ts, start_ts);
162 | return true1;
163 | }
164 |
165 | static int
166 | frame_compare_rel_times(const struct epan_session *epan,
167 | const frame_data *fdata1, const frame_data *fdata2)
168 | {
169 | nstime_t del_rel_ts1, del_rel_ts2;
170 | bool_Bool have_del_rel_ts1, have_del_rel_ts2;
171 |
172 | have_del_rel_ts1 = frame_rel_time(epan, fdata1, &del_rel_ts1);
173 | have_del_rel_ts2 = frame_rel_time(epan, fdata2, &del_rel_ts2);
174 |
175 | return frame_compare_time_deltas(fdata1, have_del_rel_ts1, &del_rel_ts1,
176 | fdata2, have_del_rel_ts2, &del_rel_ts2);
177 | }
178 |
179 | static int
180 | frame_compare_rel_start_times(const struct epan_session *epan,
181 | const frame_data *fdata1, const frame_data *fdata2)
182 | {
183 | nstime_t del_rel_start_ts1, del_rel_start_ts2;
184 | bool_Bool have_del_rel_start_ts1, have_del_rel_start_ts2;
185 |
186 | have_del_rel_start_ts1 = frame_rel_start_time(epan, fdata1, &del_rel_start_ts1);
187 | have_del_rel_start_ts2 = frame_rel_start_time(epan, fdata2, &del_rel_start_ts2);
188 |
189 | return frame_compare_time_deltas(fdata1, have_del_rel_start_ts1, &del_rel_start_ts1,
190 | fdata2, have_del_rel_start_ts2, &del_rel_start_ts2);
191 | }
192 |
193 | bool_Bool
194 | frame_delta_time_prev_captured(const struct epan_session *epan,
195 | const frame_data *fdata, nstime_t *delta)
196 | {
197 | return frame_delta_abs_time(epan, fdata, fdata->num - 1, delta);
198 | }
199 |
200 | static int
201 | frame_compare_delta_times_prev_captured(const struct epan_session *epan,
202 | const frame_data *fdata1,
203 | const frame_data *fdata2)
204 | {
205 | nstime_t del_cap_ts1, del_cap_ts2;
206 | bool_Bool have_del_cap_ts1, have_del_cap_ts2;
207 |
208 | have_del_cap_ts1 = frame_delta_time_prev_captured(epan, fdata1, &del_cap_ts1);
209 | have_del_cap_ts2 = frame_delta_time_prev_captured(epan, fdata2, &del_cap_ts2);
210 |
211 | return frame_compare_time_deltas(fdata1, have_del_cap_ts1, &del_cap_ts1,
212 | fdata2, have_del_cap_ts2, &del_cap_ts2);
213 | }
214 |
215 | bool_Bool
216 | frame_delta_time_prev_displayed(const struct epan_session *epan,
217 | const frame_data *fdata, nstime_t *delta)
218 | {
219 | return frame_delta_abs_time(epan, fdata, fdata->prev_dis_num, delta);
220 | }
221 |
222 | static int
223 | frame_compare_delta_times_prev_displayed(const struct epan_session *epan, const frame_data *fdata1, const frame_data *fdata2)
224 | {
225 | nstime_t del_dis_ts1, del_dis_ts2;
226 | bool_Bool have_del_dis_ts1, have_del_dis_ts2;
227 |
228 | have_del_dis_ts1 = frame_delta_time_prev_displayed(epan, fdata1, &del_dis_ts1);
229 | have_del_dis_ts2 = frame_delta_time_prev_displayed(epan, fdata2, &del_dis_ts2);
230 |
231 | return frame_compare_time_deltas(fdata1, have_del_dis_ts1, &del_dis_ts1,
232 | fdata2, have_del_dis_ts2, &del_dis_ts2);
233 | }
234 |
235 | static int
236 | frame_data_aggregation_values_compare(GSList* list1, GSList* list2) {
237 | GHashTable* set = g_hash_table_new(g_str_hash, g_str_equal);
238 | for (GSList* node = list1; node; node = node->next)
239 | g_hash_table_add(set, node->data);
240 |
241 | for (GSList* node = list2; node; node = node->next) {
242 | if (g_hash_table_contains(set, node->data)) {
243 | g_hash_table_destroy(set);
244 | return 0;
245 | }
246 | }
247 | g_hash_table_destroy(set);
248 | return 1;
249 | }
250 |
251 | void
252 | free_aggregation_key(gpointer data) {
253 | aggregation_key* key = (aggregation_key*)data;
254 | if (!key) return;
255 |
256 | if (key->field) {
257 | g_free(key->field);
258 | key->field = NULL((void*)0);
259 | }
260 |
261 | if (key->values) {
262 | g_slist_free_full(key->values, g_free);
263 | key->values = NULL((void*)0);
264 | }
265 |
266 | g_free(key);
267 | }
268 |
269 | int
270 | frame_data_compare(const struct epan_session *epan, const frame_data *fdata1, const frame_data *fdata2, int field)
271 | {
272 | switch (field) {
273 | case COL_NUMBER:
274 | return COMPARE_FRAME_NUM()((fdata1->num < fdata2->num) ? -1 : (fdata1->num > fdata2->num) ? 1 : 0);
275 |
276 | case COL_NUMBER_DIS:
277 | return COMPARE_NUM(dis_num)((fdata1->dis_num < fdata2->dis_num) ? -1 : (fdata1-> dis_num > fdata2->dis_num) ? 1 : ((fdata1->num < fdata2 ->num) ? -1 : (fdata1->num > fdata2->num) ? 1 : 0 ));
278 |
279 | case COL_CLS_TIME:
280 | switch (timestamp_get_type()) {
281 | case TS_ABSOLUTE:
282 | case TS_ABSOLUTE_WITH_YMD:
283 | case TS_ABSOLUTE_WITH_YDOY:
284 | case TS_UTC:
285 | case TS_UTC_WITH_YMD:
286 | case TS_UTC_WITH_YDOY:
287 | case TS_EPOCH:
288 | return COMPARE_TS(abs_ts)((fdata1->ref_time && !fdata2->ref_time) ? -1 : (!fdata1->ref_time && fdata2->ref_time) ? 1 : ( (fdata1->abs_ts).secs < (fdata2->abs_ts).secs) ? -1 : ((fdata1->abs_ts).secs > (fdata2->abs_ts).secs) ? 1 : ((fdata1->abs_ts).nsecs < (fdata2->abs_ts).nsecs) ? -1 : ((fdata1->abs_ts).nsecs > (fdata2->abs_ts).nsecs ) ? 1 : ((fdata1->num < fdata2->num) ? -1 : (fdata1-> num > fdata2->num) ? 1 : 0));
289 |
290 | case TS_RELATIVE:
291 | return frame_compare_rel_times(epan, fdata1, fdata2);
292 |
293 | case TS_RELATIVE_CAP:
294 | return frame_compare_rel_start_times(epan, fdata1, fdata2);
295 |
296 | case TS_DELTA:
297 | return frame_compare_delta_times_prev_captured(epan, fdata1, fdata2);
298 |
299 | case TS_DELTA_DIS:
300 | return frame_compare_delta_times_prev_displayed(epan, fdata1, fdata2);
301 |
302 | case TS_NOT_SET:
303 | return 0;
304 | }
305 | return 0;
306 |
307 | case COL_ABS_TIME:
308 | case COL_ABS_YMD_TIME:
309 | case COL_ABS_YDOY_TIME:
310 | case COL_UTC_TIME:
311 | case COL_UTC_YMD_TIME:
312 | case COL_UTC_YDOY_TIME:
313 | return COMPARE_TS(abs_ts)((fdata1->ref_time && !fdata2->ref_time) ? -1 : (!fdata1->ref_time && fdata2->ref_time) ? 1 : ( (fdata1->abs_ts).secs < (fdata2->abs_ts).secs) ? -1 : ((fdata1->abs_ts).secs > (fdata2->abs_ts).secs) ? 1 : ((fdata1->abs_ts).nsecs < (fdata2->abs_ts).nsecs) ? -1 : ((fdata1->abs_ts).nsecs > (fdata2->abs_ts).nsecs ) ? 1 : ((fdata1->num < fdata2->num) ? -1 : (fdata1-> num > fdata2->num) ? 1 : 0));
314 |
315 | case COL_REL_TIME:
316 | return frame_compare_rel_times(epan, fdata1, fdata2);
317 |
318 | case COL_DELTA_TIME:
319 | return frame_compare_delta_times_prev_captured(epan, fdata1, fdata2);
320 |
321 | case COL_DELTA_TIME_DIS:
322 | return frame_compare_delta_times_prev_displayed(epan, fdata1, fdata2);
323 |
324 | case COL_PACKET_LENGTH:
325 | return COMPARE_NUM(pkt_len)((fdata1->pkt_len < fdata2->pkt_len) ? -1 : (fdata1-> pkt_len > fdata2->pkt_len) ? 1 : ((fdata1->num < fdata2 ->num) ? -1 : (fdata1->num > fdata2->num) ? 1 : 0 ));
326 |
327 | case COL_CUMULATIVE_BYTES:
328 | return COMPARE_NUM(cum_bytes)((fdata1->cum_bytes < fdata2->cum_bytes) ? -1 : (fdata1 ->cum_bytes > fdata2->cum_bytes) ? 1 : ((fdata1-> num < fdata2->num) ? -1 : (fdata1->num > fdata2-> num) ? 1 : 0));
329 |
330 | }
331 | g_return_val_if_reached(0)do { g_log (((gchar*) 0), G_LOG_LEVEL_CRITICAL, "file %s: line %d (%s): should not be reached" , "epan/frame_data.c", 331, ((const char*) (__func__))); return (0); } while (0);
332 | }
333 |
334 | int
335 | frame_data_aggregation_compare(const frame_data* fdata1, const frame_data* fdata2)
336 | {
337 | unsigned length = g_slist_length(fdata1->aggregation_keys);
338 | if (length != g_slist_length(fdata2->aggregation_keys)) {
339 | return 1;
340 | }
341 | unsigned i = 0;
342 | while (i < length) {
343 | const aggregation_key* key1 = (aggregation_key*)g_slist_nth_data(fdata1->aggregation_keys, i);
344 | const aggregation_key* key2 = (aggregation_key*)g_slist_nth_data(fdata2->aggregation_keys, i);
345 | if (g_strcmp0(key1->field, key2->field) != 0 ||
346 | frame_data_aggregation_values_compare(key1->values, key2->values) == 1) {
347 | return 1;
348 | }
349 | i++;
350 | }
351 | return 0;
352 | }
353 |
354 | void
355 | frame_data_init(frame_data *fdata, uint32_t num, const wtap_rec *rec,
356 | int64_t offset, uint32_t cum_bytes)
357 | {
358 | fdata->pfd = NULL((void*)0);
359 | fdata->num = num;
360 | fdata->dis_num = num;
361 | fdata->file_off = offset;
362 | fdata->passed_dfilter = 1;
363 | fdata->dependent_of_displayed = 0;
364 | fdata->dependent_frames = NULL((void*)0);
365 | fdata->encoding = PACKET_CHAR_ENC_CHAR_ASCII;
366 | fdata->visited = 0;
367 | fdata->marked = 0;
368 | fdata->ref_time = 0;
369 | fdata->ignored = 0;
370 | fdata->has_ts = (rec->presence_flags & WTAP_HAS_TS0x00000001) ? 1 : 0;
371 | fdata->tcp_snd_manual_analysis = 0;
372 | switch (rec->rec_type) {
373 |
374 | case REC_TYPE_PACKET0:
375 | fdata->pkt_len = rec->rec_header.packet_header.len;
376 | fdata->cum_bytes = cum_bytes + rec->rec_header.packet_header.len;
377 | fdata->cap_len = rec->rec_header.packet_header.caplen;
378 | break;
379 |
380 | case REC_TYPE_FT_SPECIFIC_EVENT1:
381 | case REC_TYPE_FT_SPECIFIC_REPORT2:
382 | /*
383 | * XXX
384 | */
385 | fdata->pkt_len = rec->rec_header.ft_specific_header.record_len;
386 | fdata->cum_bytes = cum_bytes + rec->rec_header.ft_specific_header.record_len;
387 | fdata->cap_len = rec->rec_header.ft_specific_header.record_len;
388 | break;
389 |
390 | case REC_TYPE_SYSCALL3:
391 | /*
392 | * XXX - is cum_bytes supposed to count non-packet bytes?
393 | */
394 | fdata->pkt_len = rec->rec_header.syscall_header.event_data_len;
395 | fdata->cum_bytes = cum_bytes + rec->rec_header.syscall_header.event_data_len;
396 | fdata->cap_len = rec->rec_header.syscall_header.event_data_len;
397 | break;
398 |
399 | case REC_TYPE_SYSTEMD_JOURNAL_EXPORT4:
400 | /*
401 | * XXX - is cum_bytes supposed to count non-packet bytes?
402 | */
403 | fdata->pkt_len = rec->rec_header.systemd_journal_export_header.record_len;
404 | fdata->cum_bytes = cum_bytes + rec->rec_header.systemd_journal_export_header.record_len;
405 | fdata->cap_len = rec->rec_header.systemd_journal_export_header.record_len;
406 | break;
407 |
408 | case REC_TYPE_CUSTOM_BLOCK5:
409 | /*
410 | * XXX - is cum_bytes supposed to count non-packet bytes?
411 | */
412 | fdata->pkt_len = rec->rec_header.custom_block_header.length;
413 | fdata->cum_bytes = cum_bytes + rec->rec_header.custom_block_header.length;
414 | fdata->cap_len = rec->rec_header.custom_block_header.length;
415 | break;
416 |
417 | }
418 |
419 | /* To save some memory, we coerce it into 4 bits */
420 | ws_assert(rec->tsprec <= 0xF)do { if ((1) && !(rec->tsprec <= 0xF)) ws_log_fatal_full ("", LOG_LEVEL_ERROR, "epan/frame_data.c", 420, __func__, "assertion failed: %s" , "rec->tsprec <= 0xF"); } while (0);
421 | fdata->tsprec = (unsigned int)rec->tsprec;
422 | fdata->abs_ts = rec->ts;
423 | fdata->has_modified_block = 0;
424 | fdata->need_colorize = 0;
425 | fdata->color_filter = NULL((void*)0);
426 | fdata->shift_offset.secs = 0;
427 | fdata->shift_offset.nsecs = 0;
428 | fdata->frame_ref_num = 0;
429 | fdata->prev_dis_num = 0;
430 | fdata->aggregation_keys = NULL((void*)0);
431 | }
432 |
433 | void
434 | frame_data_set_before_dissect(frame_data *fdata,
435 | nstime_t *elapsed_time,
436 | const frame_data **frame_ref,
437 | const frame_data *prev_dis)
438 | {
439 | nstime_t rel_ts;
440 |
441 | /* If this frame doesn't have a time stamp, don't set it as the
442 | * reference frame used for calculating time deltas, set elapsed
443 | * time, etc. We also won't need to calculate the delta of this
444 | * frame's timestamp to any other frame.
445 | */
446 | if (!fdata->has_ts) {
447 | /* If it was marked as a reference time frame anyway (should we
448 | * allow that?), clear the existing reference frame so that the
449 | * next frame with a time stamp will become the reference frame.
450 | */
451 | if(fdata->ref_time) {
452 | *frame_ref = NULL((void*)0);
453 | }
454 | return;
455 | }
456 |
457 | /* Don't have the reference frame, set to current */
458 | if (*frame_ref == NULL((void*)0))
459 | *frame_ref = fdata;
460 |
461 | /* if this frames is marked as a reference time frame,
462 | set reference frame this frame */
463 | if(fdata->ref_time)
464 | *frame_ref = fdata;
465 |
466 | /* Get the time elapsed between the first packet and this packet. */
467 | nstime_delta(&rel_ts, &fdata->abs_ts, &(*frame_ref)->abs_ts);
468 |
469 | /* If it's greater than the current elapsed time, set the elapsed time
470 | to it (we check for "greater than" so as not to be confused by
471 | time moving backwards). */
472 | if (nstime_cmp(elapsed_time, &rel_ts) < 0) {
473 | *elapsed_time = rel_ts;
474 | }
475 |
476 | fdata->frame_ref_num = (*frame_ref)->num;
477 | fdata->prev_dis_num = (prev_dis) ? prev_dis->num : 0;
478 | }
479 |
480 | void
481 | frame_data_set_after_dissect(frame_data *fdata,
482 | uint32_t *cum_bytes)
483 | {
484 | /* This frame either passed the display filter list or is marked as
485 | a time reference frame. All time reference frames are displayed
486 | even if they don't pass the display filter */
487 | if(fdata->ref_time){
488 | /* if this was a TIME REF frame we should reset the cul bytes field */
489 | *cum_bytes = fdata->pkt_len;
490 | fdata->cum_bytes = *cum_bytes;
491 | } else {
492 | /* increase cum_bytes with this packets length */
493 | *cum_bytes += fdata->pkt_len;
494 | fdata->cum_bytes = *cum_bytes;
495 | }
496 | }
497 |
498 | void
499 | frame_data_reset(frame_data *fdata)
500 | {
501 | fdata->visited = 0;
502 |
503 | frame_data_destroy(fdata);
504 | }
505 |
506 | void
507 | frame_data_destroy(frame_data *fdata)
508 | {
509 | if (fdata->pfd) {
510 | g_slist_free(fdata->pfd);
511 | fdata->pfd = NULL((void*)0);
512 | }
513 |
514 | if (fdata->dependent_frames) {
515 | g_hash_table_destroy(fdata->dependent_frames);
516 | fdata->dependent_frames = NULL((void*)0);
517 | }
518 |
519 | frame_data_aggregation_free(fdata);
520 | }
521 |
522 | void frame_data_aggregation_free(frame_data* fdata)
523 | {
524 | if (fdata->aggregation_keys) {
525 | g_slist_free_full(fdata->aggregation_keys, free_aggregation_key);
526 | fdata->aggregation_keys = NULL((void*)0);
527 | }
528 | }
529 |
530 | /*
531 | * Editor modelines - https://www.wireshark.org/tools/modelines.html
532 | *
533 | * Local variables:
534 | * c-basic-offset: 2
535 | * tab-width: 8
536 | * indent-tabs-mode: nil
537 | * End:
538 | *
539 | * vi: set shiftwidth=2 tabstop=8 expandtab:
540 | * :indentSize=2:tabSize=8:noTabs=true:
541 | */