MSWSP: add two more Property Sets
[wireshark-wip.git] / epan / next_tvb.c
blob8b9eaad1c3c7f2c5fd58093d675a82abab8c3bca
1 /* next_tvb.c
2 * Routines for "next tvb" list
4 * $Id$
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.
25 #include "config.h"
27 #include <glib.h>
29 #include <epan/packet.h>
30 #include <epan/emem.h>
32 #include "next_tvb.h"
34 void next_tvb_init(next_tvb_list_t *list) {
35 list->first = NULL;
36 list->last = NULL;
37 list->count = 0;
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;
47 item->tvb = tvb;
48 item->tree = tree;
50 if (list->last) {
51 list->last->next = item;
52 } else {
53 list->first = item;
55 item->next = NULL;
56 item->previous = list->last;
57 list->last = item;
58 list->count++;
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;
67 item->table = table;
68 item->uint_val = uint_val;
69 item->tvb = tvb;
70 item->tree = tree;
72 if (list->last) {
73 list->last->next = item;
74 } else {
75 list->first = item;
77 item->next = NULL;
78 item->previous = list->last;
79 list->last = item;
80 list->count++;
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;
89 item->table = table;
90 item->string = string;
91 item->tvb = tvb;
92 item->tree = tree;
94 if (list->last) {
95 list->last->next = item;
96 } else {
97 list->first = item;
99 item->next = NULL;
100 item->previous = list->last;
101 list->last = item;
102 list->count++;
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;
108 item = list->first;
109 while (item) {
110 if (item->tvb && tvb_length(item->tvb)) {
111 switch (item->type) {
112 case NTVB_HANDLE:
113 call_dissector((item->handle) ? item->handle : ((handle) ? handle : data_handle), item->tvb, pinfo, (item->tree) ? item->tree : tree);
114 break;
115 case NTVB_UINT:
116 dissector_try_uint(item->table, item->uint_val, item->tvb, pinfo, (item->tree) ? item->tree : tree);
117 break;
118 case NTVB_STRING:
119 dissector_try_string(item->table, item->string, item->tvb, pinfo, (item->tree) ? item->tree : tree, NULL);
120 break;
123 item = item->next;