aboutsummaryrefslogtreecommitdiffstats
path: root/epan/tvbuff.c
diff options
context:
space:
mode:
Diffstat (limited to 'epan/tvbuff.c')
-rw-r--r--epan/tvbuff.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/epan/tvbuff.c b/epan/tvbuff.c
index af7a6e7bf0..6693a88fef 100644
--- a/epan/tvbuff.c
+++ b/epan/tvbuff.c
@@ -3648,6 +3648,26 @@ tvb_get_ds_tvb(tvbuff_t *tvb)
return(tvb->ds_tvb);
}
+guint
+tvb_get_varint(tvbuff_t *tvb, guint offset, guint maxlen, guint64 *value)
+{
+ guint i;
+ guint64 b; /* current byte */
+ *value = 0;
+
+ for (i = 0; ((i < FT_VARINT_MAX_LEN) && (i < maxlen)); ++i) {
+ b = tvb_get_guint8(tvb, offset++);
+ *value |= ((b & 0x7F) << (i * 7)); /* add lower 7 bits to val */
+
+ if (b < 0x80) {
+ /* end successfully becauseof last byte's msb(most significant bit) is zero */
+ return i + 1;
+ }
+ }
+
+ return 0; /* 10 bytes scanned, but no bytes' msb is zero */
+}
+
/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html
*