aboutsummaryrefslogtreecommitdiffstats
path: root/epan/tvbuff.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2017-09-23 09:05:21 -0400
committerMichael Mann <mmann78@netscape.net>2017-10-09 11:31:19 +0000
commitd8d60b4980882e37b73df3bfead8c2b09daba091 (patch)
treec41c195ce3971a71e8afea965740a7e87bf54609 /epan/tvbuff.c
parentc6a0e2a7916a689dfb642b004d07f6fc76fd04f3 (diff)
Add ENC_VARINT_PROTOBUF
Encoding of integer datatypes of Protocol buffers https://developers.google.cn/protocol-buffers/docs/encoding Change-Id: I9f6d65ddca099c15c0634984e9394131f98d35a9 Reviewed-on: https://code.wireshark.org/review/23813 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
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
*