3 * Proto Tree TVBuff cursor
4 * Gilbert Ramirez <gram@alumni.rice.edu>
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 2000 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 #ifndef __PTVCURSOR_H__
28 #define __PTVCURSOR_H__
31 #include <epan/packet.h>
33 #define SUBTREE_UNDEFINED_LENGTH -1
35 typedef struct ptvcursor ptvcursor_t;
37 /* Allocates an initializes a ptvcursor_t with 3 variables:
38 * proto_tree, tvbuff, and offset. */
40 ptvcursor_new(proto_tree* tree, tvbuff_t* tvb, gint offset);
42 /* Gets data from tvbuff, adds it to proto_tree, increments offset,
43 * and returns proto_item* */
45 ptvcursor_add(ptvcursor_t* ptvc, int hf, gint length, const guint encoding);
48 /* Gets data from tvbuff, adds it to proto_tree, *DOES NOT* increment
49 * offset, and returns proto_item* */
51 ptvcursor_add_no_advance(ptvcursor_t* ptvc, int hf, gint length, const guint encoding);
53 /* Advance the ptvcursor's offset within its tvbuff without
54 * adding anything to the proto_tree. */
56 ptvcursor_advance(ptvcursor_t* ptvc, gint length);
58 /* Frees memory for ptvcursor_t, but nothing deeper than that. */
60 ptvcursor_free(ptvcursor_t* ptvc);
64 ptvcursor_tvbuff(ptvcursor_t* ptvc);
66 /* Returns current offset. */
68 ptvcursor_current_offset(ptvcursor_t* ptvc);
70 /* Returns the proto_tree* */
72 ptvcursor_tree(ptvcursor_t* ptvc);
74 /* Sets a new proto_tree* for the ptvcursor_t */
76 ptvcursor_set_tree(ptvcursor_t* ptvc, proto_tree* tree);
78 /* push a subtree in the tree stack of the cursor */
80 ptvcursor_push_subtree(ptvcursor_t* ptvc, proto_item* it, gint ett_subtree);
82 /* pop a subtree in the tree stack of the cursor */
84 ptvcursor_pop_subtree(ptvcursor_t* ptvc);
86 /* Add an item to the tree and create a subtree
87 * If the length is unknown, length may be defined as SUBTREE_UNDEFINED_LENGTH.
88 * In this case, when the subtree will be closed, the parent item length will
89 * be equal to the advancement of the cursor since the creation of the subtree.
92 ptvcursor_add_with_subtree(ptvcursor_t* ptvc, int hfindex, gint length,
93 const guint encoding, gint ett_subtree);
95 /* Add a text node to the tree and create a subtree
96 * If the length is unknown, length may be defined as SUBTREE_UNDEFINED_LENGTH.
97 * In this case, when the subtree will be closed, the item length will be equal
98 * to the advancement of the cursor since the creation of the subtree.
101 ptvcursor_add_text_with_subtree(ptvcursor_t* ptvc, gint length,
102 gint ett_subtree, const char* format, ...);
104 /* Creates a subtree and adds it to the cursor as the working tree but does not
105 * save the old working tree */
107 ptvcursor_set_subtree(ptvcursor_t* ptvc, proto_item* it, gint ett_subtree);
109 #endif /* __PTVCURSOR_H__ */