/* Reads a compressed 16-bit quantity (PDU Type.1). 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_c2(tvbuff_t *tvb, gint offset, guint16 *v, gint *len)
/* Reads a compressed 16-bit quantity (PDU Type.1). 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_c2(tvbuff_t *tvb, gint offset, guint16 *v, gint *len)
{
    guint16 val = 0;
    guint8 b = tvb_get_guint8(tvb, offset++);
    if (b & 0x80)
    {
        b = b & 0x7F;
        val = (b << 8) | tvb_get_guint8(tvb, offset++);
        if (L)
            *L = 2;
    }
    else
    {
        val = b;
        if (L)
            *L = 1;
    }
    if (v)
        *v = val;
    return offset;
}