2 * Routines for "next tvb" list
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
8 * SPDX-License-Identifier: GPL-2.0-or-later
15 #include <epan/packet.h>
19 next_tvb_list_t
* next_tvb_list_new(wmem_allocator_t
*pool
) {
20 next_tvb_list_t
*list
= wmem_new0(pool
, next_tvb_list_t
);
25 void next_tvb_add_handle(next_tvb_list_t
*list
, tvbuff_t
*tvb
, proto_tree
*tree
, dissector_handle_t handle
) {
26 next_tvb_item_t
*item
;
28 item
= wmem_new(list
->pool
, next_tvb_item_t
);
30 item
->type
= NTVB_HANDLE
;
31 item
->handle
= handle
;
36 list
->last
->next
= item
;
41 item
->previous
= list
->last
;
46 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 next_tvb_item_t
*item
;
49 item
= wmem_new(list
->pool
, next_tvb_item_t
);
51 item
->type
= NTVB_UINT
;
53 item
->uint_val
= uint_val
;
58 list
->last
->next
= item
;
63 item
->previous
= list
->last
;
68 void next_tvb_add_string(next_tvb_list_t
*list
, tvbuff_t
*tvb
, proto_tree
*tree
, dissector_table_t table
, const char *string
) {
69 next_tvb_item_t
*item
;
71 item
= wmem_new(list
->pool
, next_tvb_item_t
);
73 item
->type
= NTVB_STRING
;
75 item
->string
= string
;
80 list
->last
->next
= item
;
85 item
->previous
= list
->last
;
90 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 next_tvb_item_t
*item
;
95 if (item
->tvb
&& tvb_captured_length(item
->tvb
)) {
98 call_dissector((item
->handle
) ? item
->handle
: ((handle
) ? handle
: data_handle
), item
->tvb
, pinfo
, (item
->tree
) ? item
->tree
: tree
);
101 dissector_try_uint(item
->table
, item
->uint_val
, item
->tvb
, pinfo
, (item
->tree
) ? item
->tree
: tree
);
104 dissector_try_string(item
->table
, item
->string
, item
->tvb
, pinfo
, (item
->tree
) ? item
->tree
: tree
, NULL
);
114 * Editor modelines - https://www.wireshark.org/tools/modelines.html
119 * indent-tabs-mode: nil
122 * ex: set shiftwidth=2 tabstop=8 expandtab:
123 * :indentSize=2:tabSize=8:noTabs=true: