diff --git a/epan/tvbuff.c b/epan/tvbuff.c index c3d4fb6c58..a14695dcb6 100644 --- a/epan/tvbuff.c +++ b/epan/tvbuff.c @@ -299,6 +299,17 @@ tvb_new_real_data(const guint8* data, guint length, gint reported_length) return tvb; } +tvbuff_t* +tvb_new_child_real_data(tvbuff_t *parent, const guint8* data, guint length, gint reported_length) +{ + tvbuff_t *tvb = tvb_new_real_data(data, length, reported_length); + if (tvb) { + tvb_set_child_real_data_tvbuff (parent, tvb); + } + + return tvb; +} + /* Computes the absolute offset and length based on a possibly-negative offset * and a length that is possible -1 (which means "to the end of the data"). * Returns TRUE/FALSE indicating whether the offset is in bounds or @@ -3046,3 +3057,12 @@ tvb_uncompress(tvbuff_t *tvb _U_, int offset _U_, int comprlen _U_) } #endif +tvbuff_t* tvb_child_uncompress(tvbuff_t *parent _U_, tvbuff_t *tvb, int offset, int comprlen) +{ + tvbuff_t *new_tvb = tvb_uncompress(tvb, offset, comprlen); + if (new_tvb) + tvb_set_child_real_data_tvbuff (parent, new_tvb); + return new_tvb; +} + + diff --git a/epan/tvbuff.h b/epan/tvbuff.h index 84c4c9cbe6..91e704a148 100644 --- a/epan/tvbuff.h +++ b/epan/tvbuff.h @@ -208,6 +208,9 @@ extern void tvb_set_free_cb(tvbuff_t*, tvbuff_free_cb_t); * the tvbuff routines knowledgable of this fact. */ extern void tvb_set_child_real_data_tvbuff(tvbuff_t* parent, tvbuff_t* child); +extern tvbuff_t* tvb_new_child_real_data(tvbuff_t* parent, const guint8* data, guint length, + gint reported_length); + /**Sets parameters for TVBUFF_REAL_DATA. Can throw ReportedBoundsError. */ extern void tvb_set_real_data(tvbuff_t*, const guint8* data, guint length, gint reported_length); @@ -635,6 +638,13 @@ extern gint tvb_find_tvb(tvbuff_t *haystack_tvb, tvbuff_t *needle_tvb, */ extern tvbuff_t* tvb_uncompress(tvbuff_t *tvb, int offset, int comprlen); +/** + * Uncompresses a zlib compressed packet inside a tvbuff at offset with + * length comprlen. Returns an uncompressed tvbuffer attached to tvb if uncompression + * succeeded or NULL if uncompression failed. + */ +extern tvbuff_t* tvb_child_uncompress(tvbuff_t *parent, tvbuff_t *tvb, int offset, int comprlen); + /************** END OF ACCESSORS ****************/ #endif /* __TVBUFF_H__ */