Coverage Report

Created: 2026-11-12 07:01

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wireshark/epan/next_tvb.c
Line
Count
Source
1
/* next_tvb.c
2
 * Routines for "next tvb" list
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
#include "config.h"
12
13
#include <glib.h>
14
15
#include <epan/packet.h>
16
17
#include "next_tvb.h"
18
19
1.01k
next_tvb_list_t* next_tvb_list_new(wmem_allocator_t *pool) {
20
1.01k
  next_tvb_list_t *list = wmem_new0(pool, next_tvb_list_t);
21
1.01k
  list->pool = pool;
22
1.01k
  return list;
23
1.01k
}
24
25
0
void next_tvb_add_handle(next_tvb_list_t *list, tvbuff_t *tvb, proto_tree *tree, dissector_handle_t handle) {
26
0
  next_tvb_item_t *item;
27
28
0
  item = wmem_new(list->pool, next_tvb_item_t);
29
30
0
  item->type = NTVB_HANDLE;
31
0
  item->handle = handle;
32
0
  item->tvb = tvb;
33
0
  item->tree = tree;
34
35
0
  if (list->last) {
36
0
    list->last->next = item;
37
0
  } else {
38
0
    list->first = item;
39
0
  }
40
0
  item->next = NULL;
41
0
  item->previous = list->last;
42
0
  list->last = item;
43
0
  list->count++;
44
0
}
45
46
0
void next_tvb_add_uint(next_tvb_list_t *list, tvbuff_t *tvb, proto_tree *tree, dissector_table_t table, uint32_t uint_val) {
47
0
  next_tvb_item_t *item;
48
49
0
  item = wmem_new(list->pool, next_tvb_item_t);
50
51
0
  item->type = NTVB_UINT;
52
0
  item->table = table;
53
0
  item->uint_val = uint_val;
54
0
  item->tvb = tvb;
55
0
  item->tree = tree;
56
57
0
  if (list->last) {
58
0
    list->last->next = item;
59
0
  } else {
60
0
    list->first = item;
61
0
  }
62
0
  item->next = NULL;
63
0
  item->previous = list->last;
64
0
  list->last = item;
65
0
  list->count++;
66
0
}
67
68
0
void next_tvb_add_string(next_tvb_list_t *list, tvbuff_t *tvb, proto_tree *tree, dissector_table_t table, const char *string) {
69
0
  next_tvb_item_t *item;
70
71
0
  item = wmem_new(list->pool, next_tvb_item_t);
72
73
0
  item->type = NTVB_STRING;
74
0
  item->table = table;
75
0
  item->string = string;
76
0
  item->tvb = tvb;
77
0
  item->tree = tree;
78
79
0
  if (list->last) {
80
0
    list->last->next = item;
81
0
  } else {
82
0
    list->first = item;
83
0
  }
84
0
  item->next = NULL;
85
0
  item->previous = list->last;
86
0
  list->last = item;
87
0
  list->count++;
88
0
}
89
90
909
void next_tvb_call(next_tvb_list_t *list, packet_info *pinfo, proto_tree *tree, dissector_handle_t handle, dissector_handle_t data_handle) {
91
909
  next_tvb_item_t *item;
92
93
909
  item = list->first;
94
909
  while (item) {
95
0
    if (item->tvb && tvb_captured_length(item->tvb)) {
96
0
      switch (item->type) {
97
0
        case NTVB_HANDLE:
98
0
          call_dissector((item->handle) ? item->handle : ((handle) ? handle : data_handle), item->tvb, pinfo, (item->tree) ? item->tree : tree);
99
0
          break;
100
0
        case NTVB_UINT:
101
0
          dissector_try_uint(item->table, item->uint_val, item->tvb, pinfo, (item->tree) ? item->tree : tree);
102
0
          break;
103
0
        case NTVB_STRING:
104
0
          dissector_try_string_with_data(item->table, item->string, item->tvb, pinfo, (item->tree) ? item->tree : tree, true, NULL);
105
0
          break;
106
0
      }
107
0
    }
108
0
    item = item->next;
109
0
  }
110
909
}
111
112
113
/*
114
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
115
 *
116
 * Local Variables:
117
 * c-basic-offset: 2
118
 * tab-width: 8
119
 * indent-tabs-mode: nil
120
 * End:
121
 *
122
 * ex: set shiftwidth=2 tabstop=8 expandtab:
123
 * :indentSize=2:tabSize=8:noTabs=true:
124
 */