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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 #include <epan/packet.h>
32 #include <epan/emem.h>
36 void next_tvb_init(next_tvb_list_t *list) {
42 void next_tvb_add_handle(next_tvb_list_t *list, tvbuff_t *tvb, proto_tree *tree, dissector_handle_t handle) {
43 next_tvb_item_t *item;
45 item = ep_alloc(sizeof(next_tvb_item_t));
47 item->type = NTVB_HANDLE;
48 item->handle = handle;
53 list->last->next = item;
58 item->previous = list->last;
63 void next_tvb_add_port(next_tvb_list_t *list, tvbuff_t *tvb, proto_tree *tree, dissector_table_t table, guint32 port) {
64 next_tvb_item_t *item;
66 item = ep_alloc(sizeof(next_tvb_item_t));
68 item->type = NTVB_PORT;
75 list->last->next = item;
80 item->previous = list->last;
85 void next_tvb_add_string(next_tvb_list_t *list, tvbuff_t *tvb, proto_tree *tree, dissector_table_t table, const gchar *string) {
86 next_tvb_item_t *item;
88 item = ep_alloc(sizeof(next_tvb_item_t));
90 item->type = NTVB_STRING;
92 item->string = string;
97 list->last->next = item;
102 item->previous = list->last;
107 void next_tvb_call(next_tvb_list_t *list, packet_info *pinfo, proto_tree *tree, dissector_handle_t handle, dissector_handle_t data_handle) {
108 next_tvb_item_t *item;
112 if (item->tvb && tvb_length(item->tvb)) {
113 switch (item->type) {
115 call_dissector((item->handle) ? item->handle : ((handle) ? handle : data_handle), item->tvb, pinfo, (item->tree) ? item->tree : tree);
118 dissector_try_port(item->table, item->port, item->tvb, pinfo, (item->tree) ? item->tree : tree);
121 dissector_try_string(item->table, item->string, item->tvb, pinfo, (item->tree) ? item->tree : tree);