/* ZigBee helper function. extracts an integer and displays it to the tree. */
guint zbee_parse_uint(proto_tree *tree, int hfindex, tvbuff_t *tvb, guint *offset, guint length, proto_item **ti)
/* ZigBee helper function. extracts an integer and displays it to the tree. */
guint zbee_parse_uint(proto_tree *tree, int hfindex, tvbuff_t *tvb, guint *offset, guint length, proto_item **ti)
{
    proto_item          *item = NULL;
    guint               value = 0;
    if (length == 0) {
        return 0;
    }
    else if (length == 1) {
        value = tvb_get_guint8(tvb, *offset);
    }
    else if (length == 2) {
        value = tvb_get_letohs(tvb, *offset);
    }
    else if (length == 3) {
        value = tvb_get_letohs(tvb, *offset);
        value += ((guint32)tvb_get_guint8(tvb, *offset + 2) << 16);
    }
    else {
        value = tvb_get_letohl(tvb, *offset);
    }
    item = proto_tree_add_uint(tree, hfindex, tvb, *offset, length, value);
    *offset += length;
    if (ti) *ti = item;
    return value;
}