diff options
author | Michael Mann <mmann78@netscape.net> | 2019-08-28 03:37:04 -0400 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2019-09-05 03:25:39 +0000 |
commit | 168ee5003fa2bfba578118b807d6fdf37ec02abc (patch) | |
tree | 7c10842f881b21209e797aac0b14d0c4152aa329 /epan/tvbuff.c | |
parent | 05e39afb3fdbf76452a05c1c2a2c3164af9702ed (diff) |
kafka: Cleanup to use "native" APIs.
Add "native" support for the "zig-zag" version of a varint in proto.[ch] and
tvbuff.[ch]. Convert the use of varint in the KAFKA dissector to use the (new)
"native" API.
Ping-Bug: 15988
Change-Id: Ia83569203877df8c780f4f182916ed6327d0ec6c
Reviewed-on: https://code.wireshark.org/review/34386
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/tvbuff.c')
-rw-r--r-- | epan/tvbuff.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/epan/tvbuff.c b/epan/tvbuff.c index 9b691f3e6f..73cb88ef50 100644 --- a/epan/tvbuff.c +++ b/epan/tvbuff.c @@ -4082,7 +4082,22 @@ tvb_get_varint(tvbuff_t *tvb, guint offset, guint maxlen, guint64 *value, const return i + 1; } } - } else if (encoding & ENC_VARINT_QUIC) { + } else if (encoding & ENC_VARINT_ZIGZAG) { + guint i; + guint64 b; /* current byte */ + + 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 */ + *value = (*value >> 1) ^ ((*value & 1) ? -1 : 0); + return i + 1; + } + } + } + else if (encoding & ENC_VARINT_QUIC) { /* calculate variable length */ *value = tvb_get_guint8(tvb, offset); |