2 * Routines for "next tvb" list
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
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.
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.
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.
29 #include <epan/packet.h>
30 #include <epan/emem.h>
34 void next_tvb_init(next_tvb_list_t
*list
) {
40 void next_tvb_add_handle(next_tvb_list_t
*list
, tvbuff_t
*tvb
, proto_tree
*tree
, dissector_handle_t handle
) {
41 next_tvb_item_t
*item
;
43 item
= ep_new(next_tvb_item_t
);
45 item
->type
= NTVB_HANDLE
;
46 item
->handle
= handle
;
51 list
->last
->next
= item
;
56 item
->previous
= list
->last
;
61 void next_tvb_add_uint(next_tvb_list_t
*list
, tvbuff_t
*tvb
, proto_tree
*tree
, dissector_table_t table
, guint32 uint_val
) {
62 next_tvb_item_t
*item
;
64 item
= ep_new(next_tvb_item_t
);
66 item
->type
= NTVB_UINT
;
68 item
->uint_val
= uint_val
;
73 list
->last
->next
= item
;
78 item
->previous
= list
->last
;
83 void next_tvb_add_string(next_tvb_list_t
*list
, tvbuff_t
*tvb
, proto_tree
*tree
, dissector_table_t table
, const gchar
*string
) {
84 next_tvb_item_t
*item
;
86 item
= ep_new(next_tvb_item_t
);
88 item
->type
= NTVB_STRING
;
90 item
->string
= string
;
95 list
->last
->next
= item
;
100 item
->previous
= list
->last
;
105 void next_tvb_call(next_tvb_list_t
*list
, packet_info
*pinfo
, proto_tree
*tree
, dissector_handle_t handle
, dissector_handle_t data_handle
) {
106 next_tvb_item_t
*item
;
110 if (item
->tvb
&& tvb_length(item
->tvb
)) {
111 switch (item
->type
) {
113 call_dissector((item
->handle
) ? item
->handle
: ((handle
) ? handle
: data_handle
), item
->tvb
, pinfo
, (item
->tree
) ? item
->tree
: tree
);
116 dissector_try_uint(item
->table
, item
->uint_val
, item
->tvb
, pinfo
, (item
->tree
) ? item
->tree
: tree
);
119 dissector_try_string(item
->table
, item
->string
, item
->tvb
, pinfo
, (item
->tree
) ? item
->tree
: tree
, NULL
);