/* Read a compressed 32-bit quantity (PDU Type.3). Since the value is variable length, the new offset is returned. The value can also be returned, along with the size, although NULL is allowed for those parameters.  */
static gint read_c4(tvbuff_t *tvb, gint offset, guint32 *v, gint *len)
/* Read a compressed 32-bit quantity (PDU Type.3). Since the value is variable length, the new offset is returned. The value can also be returned, along with the size, although NULL is allowed for those parameters.  */
static gint read_c4(tvbuff_t *tvb, gint offset, guint32 *v, gint *len)
{
    guint32 val = 0;
    guint8 len = 0;
    guint8 b = tvb_get_guint8(tvb, offset++);
    int i;
    if ((b & 0x80) == 0)
    {
        len = 1;
        b = b & 0x7F;
    }
    else if ((b & 0x40) == 0)
    {
        len = 2;
        b = b & 0x3F;
    }
    else
    {
        len = 4;
        b = b & 0x3F;
    }
    val = b;
    for (i = 1; i < len; i++)
        val = (val << 8) | tvb_get_guint8(tvb, offset++);
    if (L)
        *L = len;
    if (v)
        *v = val;
    return offset;
}