diff options
author | Gilbert Ramirez <gram@alumni.rice.edu> | 2002-01-10 04:44:34 +0000 |
---|---|---|
committer | Gilbert Ramirez <gram@alumni.rice.edu> | 2002-01-10 04:44:34 +0000 |
commit | f7265ba975b079f97d3837ba91cb371f63059c5b (patch) | |
tree | 6d7240e50e195c75db9872b444c714926525e264 /ptvcursor.c | |
parent | aa36cec9df2e30710deaebc50f10ea3c033dedd5 (diff) |
Allow NCP types to define bitfields. In order to implement
sub-trees, I added new functions to ptvcursor:
ptvcursor_add_no_advance()
ptvcursor_tvbuff()
ptvcursor_current_offset()
Note that no NCP type that actually uses bitfields has been
checked in yet.
svn path=/trunk/; revision=4509
Diffstat (limited to 'ptvcursor.c')
-rw-r--r-- | ptvcursor.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/ptvcursor.c b/ptvcursor.c index 6159e6085c..bce7f80dd3 100644 --- a/ptvcursor.c +++ b/ptvcursor.c @@ -3,7 +3,7 @@ * Proto Tree TVBuff cursor * Gilbert Ramirez <gram@alumni.rice.edu> * - * $Id: ptvcursor.c,v 1.4 2001/11/13 23:55:30 gram Exp $ + * $Id: ptvcursor.c,v 1.5 2002/01/10 04:44:34 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -56,10 +56,22 @@ ptvcursor_add(ptvcursor_t *ptvc, int hf, gint length, gboolean endianness) { proto_item *item; + item = ptvcursor_add_no_advance(ptvc, hf, length, endianness); + ptvc->offset += proto_item_get_len(item); + return item; +} + +/* Gets data from tvbuff, adds it to proto_tree, *DOES NOT* increment + * offset, and returns proto_item* */ +proto_item* +ptvcursor_add_no_advance(ptvcursor_t* ptvc, int hf, gint length, + gboolean endianness) +{ + proto_item *item; + item = proto_tree_add_item(ptvc->tree, hf, ptvc->tvb, ptvc->offset, length, endianness); - ptvc->offset += proto_item_get_len(item); return item; } @@ -69,3 +81,16 @@ ptvcursor_free(ptvcursor_t *ptvc) { g_free(ptvc); } +/* Returns tvbuff. */ +tvbuff_t* +ptvcursor_tvbuff(ptvcursor_t* ptvc) +{ + return ptvc->tvb; +} + +/* Returns current offset. */ +gint +ptvcursor_current_offset(ptvcursor_t* ptvc) +{ + return ptvc->offset; +} |