The data contained in this repository can be downloaded to your computer using one of several clients.
Please see the documentation of your version control software client for more information.
Please select the desired protocol below to get the URL.
This URL has Read-Only access.
main_repo / epan / next_tvb.c @ df6d8f49
History | View | Annotate | Download (3.33 KB)
1 | a063a87a | Tomas Kukosa | /* next_tvb.c
|
---|---|---|---|
2 | * Routines for "next tvb" list
|
||
3 | *
|
||
4 | * $Id$
|
||
5 | *
|
||
6 | * Wireshark - Network traffic analyzer
|
||
7 | * By Gerald Combs <gerald@wireshark.org>
|
||
8 | * Copyright 1998 Gerald Combs
|
||
9 | *
|
||
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.
|
||
14 | *
|
||
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.
|
||
19 | *
|
||
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.
|
||
23 | */
|
||
24 | |||
25 | #ifdef HAVE_CONFIG_H
|
||
26 | # include "config.h" |
||
27 | #endif
|
||
28 | |||
29 | #include <glib.h> |
||
30 | |||
31 | #include <epan/packet.h> |
||
32 | #include <epan/emem.h> |
||
33 | |||
34 | #include "next_tvb.h" |
||
35 | |||
36 | void next_tvb_init(next_tvb_list_t *list) {
|
||
37 | list->first = NULL;
|
||
38 | list->last = NULL;
|
||
39 | list->count = 0;
|
||
40 | } |
||
41 | |||
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; |
||
44 | |||
45 | item = ep_alloc(sizeof(next_tvb_item_t));
|
||
46 | |||
47 | item->type = NTVB_HANDLE; |
||
48 | item->handle = handle; |
||
49 | item->tvb = tvb; |
||
50 | item->tree = tree; |
||
51 | |||
52 | if (list->last) {
|
||
53 | list->last->next = item; |
||
54 | } else {
|
||
55 | list->first = item; |
||
56 | } |
||
57 | item->next = NULL;
|
||
58 | item->previous = list->last; |
||
59 | list->last = item; |
||
60 | list->count++; |
||
61 | } |
||
62 | |||
63 | a8bc4a0d | Guy Harris | void next_tvb_add_uint(next_tvb_list_t *list, tvbuff_t *tvb, proto_tree *tree, dissector_table_t table, guint32 uint_val) {
|
64 | a063a87a | Tomas Kukosa | next_tvb_item_t *item; |
65 | |||
66 | item = ep_alloc(sizeof(next_tvb_item_t));
|
||
67 | |||
68 | a8bc4a0d | Guy Harris | item->type = NTVB_UINT; |
69 | a063a87a | Tomas Kukosa | item->table = table; |
70 | a8bc4a0d | Guy Harris | item->uint_val = uint_val; |
71 | a063a87a | Tomas Kukosa | item->tvb = tvb; |
72 | item->tree = tree; |
||
73 | |||
74 | if (list->last) {
|
||
75 | list->last->next = item; |
||
76 | } else {
|
||
77 | list->first = item; |
||
78 | } |
||
79 | item->next = NULL;
|
||
80 | item->previous = list->last; |
||
81 | list->last = item; |
||
82 | list->count++; |
||
83 | } |
||
84 | |||
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; |
||
87 | |||
88 | item = ep_alloc(sizeof(next_tvb_item_t));
|
||
89 | |||
90 | item->type = NTVB_STRING; |
||
91 | item->table = table; |
||
92 | item->string = string; |
||
93 | item->tvb = tvb; |
||
94 | item->tree = tree; |
||
95 | |||
96 | if (list->last) {
|
||
97 | list->last->next = item; |
||
98 | } else {
|
||
99 | list->first = item; |
||
100 | } |
||
101 | item->next = NULL;
|
||
102 | item->previous = list->last; |
||
103 | list->last = item; |
||
104 | list->count++; |
||
105 | } |
||
106 | |||
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; |
||
109 | |||
110 | item = list->first; |
||
111 | while (item) {
|
||
112 | if (item->tvb && tvb_length(item->tvb)) {
|
||
113 | switch (item->type) {
|
||
114 | case NTVB_HANDLE:
|
||
115 | call_dissector((item->handle) ? item->handle : ((handle) ? handle : data_handle), item->tvb, pinfo, (item->tree) ? item->tree : tree); |
||
116 | break;
|
||
117 | a8bc4a0d | Guy Harris | case NTVB_UINT:
|
118 | dissector_try_uint(item->table, item->uint_val, item->tvb, pinfo, (item->tree) ? item->tree : tree); |
||
119 | a063a87a | Tomas Kukosa | break;
|
120 | case NTVB_STRING:
|
||
121 | dissector_try_string(item->table, item->string, item->tvb, pinfo, (item->tree) ? item->tree : tree); |
||
122 | break;
|
||
123 | } |
||
124 | } |
||
125 | item = item->next; |
||
126 | } |
||
127 | } |