HACK: pinfo->private_data points to smb_info again
[wireshark-wip.git] / epan / tpg.h
blobf71feef35f9ff6f58543e30e39a3ff5668558210
1 /* tpg.h
2 * Definitions of helper functions for TPG
4 * (c) 2005, Luis E. Garcia Ontanon <luis@ontanon.org>
5 *
6 * $Id$
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 #ifndef _TPG_H_
28 #define _TPG_H_
30 #include <glib.h>
31 #include <epan/packet.h>
32 #include <epan/proto.h>
33 #include <epan/tvbuff.h>
34 #include <epan/tvbparse.h>
35 #include "ws_symbol_export.h"
37 typedef struct _tpg_parser_data_t {
38 ep_stack_t stack;
39 tvbparse_t* tt;
40 void* private_data;
41 } tpg_parser_data_t;
43 extern tpg_parser_data_t* tpg_start(proto_tree* root_tree,
44 tvbuff_t* tvb,
45 int offset,
46 int len,
47 tvbparse_wanted_t* ignore,
48 void* private_data);
50 #define TPG_START(tree,tvb,offset,len,data) tpg_start((tree),(tvb),(offset),(len),(data))
52 #define TPG_GET(tpg, wanted) tvbparse_get((tpg)->tt,(wanted))
53 #define TPG_FIND(tpg, wanted) tvbparse_find((tpg)->tt,(wanted))
55 #define TPG_TREE(vp) (((tpg_parser_data_t*)(vp))->tree)
56 #define TPG_DATA(vp,type) (((type*)(((tpg_parser_data_t*)(vp))->private_data)))
58 #define TPG_STRING(i) tvb_get_string(wmem_packet_scope(), (i)->tvb,(i)->offset,(i)->len)
59 #define TPG_INT(i) strtol(tvb_get_string(wmem_packet_scope(), (i)->tvb,(i)->offset,(i)->len),NULL,10)
60 #define TPG_UINT(i) strtoul(tvb_get_string(wmem_packet_scope(), (i)->tvb,(i)->offset,(i)->len),NULL,10)
61 #define TPG_UINT_HEX(i) strtoul(tvb_get_string(wmem_packet_scope(), (i)->tvb,(i)->offset,(i)->len),NULL,16)
62 #define TPG_TVB(i) tvb_new_subset((i)->tvb,(i)->offset,(i)->len,(i)->len)
64 WS_DLL_PUBLIC guint32 tpg_ipv4(tvbparse_elem_t*);
65 #define TPG_IPV4(i) tpg_ipv4((i))
67 WS_DLL_PUBLIC guint8* tpg_ipv6(tvbparse_elem_t*);
68 #define TPG_IPV6(i) tpg_ipv6((i))
70 #define TPG_PUSH(tpg,pi,ett) ep_stack_push(((tpg_parser_data_t*)(tpg))->stack,proto_item_add_subtree((pi),(ett)))
71 #define TPG_POP(tpg) ep_stack_pop(((tpg_parser_data_t*)(tpg))->stack) ;
73 #define TPG_ADD_STRING(tpg, hfid, elem) proto_tree_add_item(ep_stack_peek(((tpg_parser_data_t*)tpg)->stack), hfid, (elem)->tvb, (elem)->offset, (elem)->len, FALSE)
74 #define TPG_ADD_BOOLEAN(tpg, hfid, elem) proto_tree_add_boolean(ep_stack_peek(((tpg_parser_data_t*)tpg)->stack), hfid, (elem)->tvb, (elem)->offset, (elem)->len, TRUE)
75 #define TPG_ADD_INT(tpg, hfid, elem, value) proto_tree_add_int(ep_stack_peek(((tpg_parser_data_t*)tpg)->stack), hfid, (elem)->tvb, (elem)->offset, (elem)->len, value)
76 #define TPG_ADD_UINT(tpg, hfid, elem, value) proto_tree_add_uint(ep_stack_peek(((tpg_parser_data_t*)tpg)->stack), hfid, (elem)->tvb, (elem)->offset, (elem)->len, value)
77 #define TPG_ADD_IPV4(tpg, hfid, elem, value) proto_tree_add_ipv4(ep_stack_peek(((tpg_parser_data_t*)tpg)->stack), hfid, (elem)->tvb, (elem)->offset, (elem)->len, value)
78 #define TPG_ADD_IPV6(tpg, hfid, elem, value) proto_tree_add_ipv6(ep_stack_peek(((tpg_parser_data_t*)tpg)->stack), hfid, (elem)->tvb, (elem)->offset, (elem)->len, value)
79 #define TPG_ADD_TEXT(tpg, elem) proto_tree_add_text(ep_stack_peek(((tpg_parser_data_t*)tpg)->stack), (elem)->tvb, (elem)->offset, (elem)->len, \
80 "%s",tvb_format_text((elem)->tvb, (elem)->offset, (elem)->len))
82 #define TPG_SET_TEXT(pi, elem) proto_item_set_text((pi), "%s",tvb_format_text((elem)->tvb, (elem)->offset, (elem)->len))
84 #endif /* _TPG_H_ */