Page 1 of 1

Add Basic Encoding Rules (BER) to Data Inspector

Posted: 01 Jun 2016 20:19
by akrutsinger
There are many types of encoding that would be nice to have in the data inspector and it obviously doesn't make sense to add them all within the Data Inspector frame. With that said, perhaps a scripting / plugin capability would enhance this? If not a plugin/scripting capability, the below code would help facilitate the quick decoding of BER.

Code: Select all

static uint64_t get_ber_length(uint8_t *p)
{
    uint64_t size = *p++;
    if (size & 0x80) { /* long form */
        int bytes_num = size & 0x7f;
        /* Different implementations might have different uses for BER. */
        /* KLV data from UAV's for example follow 379M standards */
        /* SMPTE 379M 5.3.4 guarantee that bytes_num must not exceed 8 bytes */
        if (bytes_num > 8)
            return 0xFF;
        size = 0;
        /* should probably include a check that byte_num doesn't put us past the end of the file/data */
        while (bytes_num--)
            size = size << 8 | *p++;
    }
    return size;
}