gboolean is_gquic_unencrypt(tvbuff_t *tvb, packet_info *pinfo, guint offset, guint16 len_pkn, gquic_info_data_t *gquic_info){
    guint8 frame_type;
    guint8 num_ranges, num_revived, num_blocks = 0, num_timestamp;
    guint32 len_stream = 0, len_offset = 0, len_data = 0, len_largest_observed = 1, len_missing_packet = 1;
    guint32 message_tag;


    if(tvb_captured_length_remaining(tvb, offset) <= 13){
        return FALSE;
    }
    /* Message Authentication Hash */
    offset += 12;

    if(gquic_info->version_valid && gquic_info->version < 34){ /* No longer Private Flags after Q034 */
        /* Private Flags */
        offset += 1;
    }

    while(tvb_reported_length_remaining(tvb, offset) > 0){

        if (tvb_captured_length_remaining(tvb, offset) <= 1){
            return FALSE;
        }
        /* Frame type */
        frame_type = tvb_get_guint8(tvb, offset);
        if((frame_type & FTFLAGS_SPECIAL) == 0){
            offset += 1;
            switch(frame_type){
                case FT_PADDING:
                    return FALSE; /* Pad on rest of packet.. */
                break;
                case FT_RST_STREAM:
                    /* Stream ID */
                    offset += 4;
                    /* Byte Offset */
                    offset += 8;
                    /* Error Code */
                    offset += 4;
                break;
                case FT_CONNECTION_CLOSE:{
                    guint16 len_reason;

                    /* Error Code */
                    offset += 4;
                    /* Reason Phrase Length */
                    if (tvb_captured_length_remaining(tvb, offset) <= 2){
                        return FALSE;
                    }
                    len_reason = tvb_get_guint16(tvb, offset, gquic_info->encoding);
                    offset += 2;
                    /* Reason Phrase */
                    /* If length remaining == len_reason, it is Connection Close */
                    if (tvb_captured_length_remaining(tvb, offset) == len_reason){
                        return TRUE;
                    }
                    }
                break;
                case FT_GOAWAY:{
                    guint16 len_reason;

                    /* Error Code */
                    offset += 4;
                    /* Last Good Stream ID */
                    offset += 4;
                    /* Reason Phrase Length */
                    if (tvb_captured_length_remaining(tvb, offset) <= 2){
                        return FALSE;
                    }
                    len_reason = tvb_get_guint16(tvb, offset, gquic_info->encoding);
                    offset += 2;
                    /* Reason Phrase */
                    offset += len_reason;
                    }
                break;
                case FT_WINDOW_UPDATE:
                    /* Stream ID */
                    offset += 4;
                    /* Byte Offset */
                    offset += 8;
                break;
                case FT_BLOCKED:
                    /* Stream ID */
                    offset += 4;
                break;
                case FT_STOP_WAITING:
                    if(gquic_info->version_valid && gquic_info->version < 34){ /* No longer Entropy after Q034 */
                        /* Send Entropy */
                        offset += 1;
                    }
                    /* Least Unacked Delta */
                    offset += len_pkn;
                break;
                case FT_PING: /* No Payload */
                default: /* No default */
                break;
            }
        } else {
            /* Special Frame Type */
            if(frame_type & FTFLAGS_STREAM){ /* Stream */

                if(frame_type & FTFLAGS_STREAM_D){
                    len_data = 2;
                }
                len_offset = get_len_offset(frame_type);
                len_stream = get_len_stream(frame_type);

                /* Frame Type */
                offset += 1;

                /* Stream */
                offset += len_stream;

                /* Offset */
                offset += len_offset;

                /* Data length */
                offset += len_data;

                if (tvb_captured_length_remaining(tvb, offset) <= 4){
                    return FALSE;
                }

                /* Check if the Message Tag is CHLO (Client Hello) or SHLO (Server Hello) or REJ (Rejection) */
                message_tag = tvb_get_ntohl(tvb, offset);
                if (message_tag == MTAG_CHLO|| message_tag == MTAG_SHLO || message_tag == MTAG_REJ) {
                    if(message_tag == MTAG_CHLO && pinfo->srcport != 443) { /* Found */
                        gquic_info->server_port = pinfo->destport;
                    }
                    return TRUE;
                }


            } else if (frame_type & FTFLAGS_ACK) {
            /* ACK Flags */

                len_largest_observed = get_len_largest_observed(frame_type);
                len_missing_packet = get_len_missing_packet(frame_type);

                /* Frame Type */
                offset += 1;

                if(gquic_info->version_valid && gquic_info->version < 34){ /* No longer Entropy after Q034 */
                    /* Received Entropy */
                    offset += 1;

                    /* Largest Observed */
                    offset += len_largest_observed;

                    /* Ack Delay Time */
                    offset += 2;

                    /* Num Timestamp */
                    if (tvb_captured_length_remaining(tvb, offset) <= 1){
                        return FALSE;
                    }
                    num_timestamp = tvb_get_guint8(tvb, offset);
                    offset += 1;

                    if(num_timestamp > 0){
                        /* Delta Largest Observed */
                        offset += 1;

                        /* First Timestamp */
                        offset += 4;

                        /* Num Timestamp (-1)x (Delta Largest Observed + Time Since Previous Timestamp) */
                        offset += (num_timestamp - 1)*(1+2);
                    }

                    if(frame_type & FTFLAGS_ACK_N){
                        /* Num Ranges */
                        if (tvb_captured_length_remaining(tvb, offset) <= 1){
                            return FALSE;
                        }
                        num_ranges = tvb_get_guint8(tvb, offset);
                        offset += 1;

                        /* Num Range x (Missing Packet + Range Length) */
                        offset += num_ranges*(len_missing_packet+1);

                        /* Num Revived */
                        if (tvb_captured_length_remaining(tvb, offset) <= 1){
                            return FALSE;
                        }
                        num_revived = tvb_get_guint8(tvb, offset);
                        offset += 1;

                        /* Num Revived x Length Largest Observed */
                        offset += num_revived*len_largest_observed;

                    }
                } else {

                    /* Largest Acked */
                    offset += len_largest_observed;

                    /* Largest Acked Delta Time*/
                    offset += 2;

                    /* Ack Block */
                    if(frame_type & FTFLAGS_ACK_N){
                        if (tvb_captured_length_remaining(tvb, offset) <= 1){
                            return FALSE;
                        }
                        num_blocks = tvb_get_guint8(tvb, offset);
                        offset += 1;
                    }

                    /* First Ack Block Length */
                    offset += len_missing_packet;
                    if(num_blocks){
                        offset += (num_blocks)*(1 + len_missing_packet);
                    }

                    /* Timestamp */
                    if (tvb_captured_length_remaining(tvb, offset) <= 1){
                        return FALSE;
                    }
                    num_timestamp = tvb_get_guint8(tvb, offset);
                    offset += 1;

                    if(num_timestamp > 0){

                        /* Delta Largest Acked */
                        offset += 1;

                        /* Time Since Largest Acked */
                        offset += 4;

                        /* Num Timestamp x (Delta Largest Acked + Time Since Previous Timestamp) */
                        offset += (num_timestamp - 1)*(1+2);
                    }

                }
            } else { /* Other Special Frame type */
                offset += 1;
            }
        }
    }

    return FALSE;

}
gboolean is_gquic_unencrypt(tvbuff_t *tvb, packet_info *pinfo, guint offset, guint16 len_pkn, gquic_info_data_t *gquic_info){
    guint8 frame_type;
    guint8 num_ranges, num_revived, num_blocks = 0, num_timestamp;
    guint32 len_stream = 0, len_offset = 0, len_data = 0, len_largest_observed = 1, len_missing_packet = 1;
    guint32 message_tag;


    if(tvb_captured_length_remaining(tvb, offset) <= 13){
        return FALSE;
    }
     
    offset += 12;

    if(gquic_info->version_valid && gquic_info->version < 34){  
         
        offset += 1;
    }

    while(tvb_reported_length_remaining(tvb, offset) > 0){

        if (tvb_captured_length_remaining(tvb, offset) <= 1){
            return FALSE;
        }
         
        frame_type = tvb_get_guint8(tvb, offset);
        if((frame_type & FTFLAGS_SPECIAL) == 0){
            offset += 1;
            switch(frame_type){
                case FT_PADDING:
                    return FALSE;  
                break;
                case FT_RST_STREAM:
                     
                    offset += 4;
                     
                    offset += 8;
                     
                    offset += 4;
                break;
                case FT_CONNECTION_CLOSE:{
                    guint16 len_reason;

                     
                    offset += 4;
                     
                    if (tvb_captured_length_remaining(tvb, offset) <= 2){
                        return FALSE;
                    }
                    len_reason = tvb_get_guint16(tvb, offset, gquic_info->encoding);
                    offset += 2;
                     
                     
                    if (tvb_captured_length_remaining(tvb, offset) == len_reason){
                        return TRUE;
                    }
                    }
                break;
                case FT_GOAWAY:{
                    guint16 len_reason;

                     
                    offset += 4;
                     
                    offset += 4;
                     
                    if (tvb_captured_length_remaining(tvb, offset) <= 2){
                        return FALSE;
                    }
                    len_reason = tvb_get_guint16(tvb, offset, gquic_info->encoding);
                    offset += 2;
                     
                    offset += len_reason;
                    }
                break;
                case FT_WINDOW_UPDATE:
                     
                    offset += 4;
                     
                    offset += 8;
                break;
                case FT_BLOCKED:
                     
                    offset += 4;
                break;
                case FT_STOP_WAITING:
                    if(gquic_info->version_valid && gquic_info->version < 34){  
                         
                        offset += 1;
                    }
                     
                    offset += len_pkn;
                break;
                case FT_PING:  
                default:  
                break;
            }
        } else {
             
            if(frame_type & FTFLAGS_STREAM){  

                if(frame_type & FTFLAGS_STREAM_D){
                    len_data = 2;
                }
                len_offset = get_len_offset(frame_type);
                len_stream = get_len_stream(frame_type);

                 
                offset += 1;

                 
                offset += len_stream;

                 
                offset += len_offset;

                 
                offset += len_data;

                if (tvb_captured_length_remaining(tvb, offset) <= 4){
                    return FALSE;
                }

                 
                message_tag = tvb_get_ntohl(tvb, offset);
                if (message_tag == MTAG_CHLO|| message_tag == MTAG_SHLO || message_tag == MTAG_REJ) {
                    if(message_tag == MTAG_CHLO && pinfo->srcport != 443) {  
                        gquic_info->server_port = pinfo->destport;
                    }
                    return TRUE;
                }


            } else if (frame_type & FTFLAGS_ACK) {
             

                len_largest_observed = get_len_largest_observed(frame_type);
                len_missing_packet = get_len_missing_packet(frame_type);

                 
                offset += 1;

                if(gquic_info->version_valid && gquic_info->version < 34){  
                     
                    offset += 1;

                     
                    offset += len_largest_observed;

                     
                    offset += 2;

                     
                    if (tvb_captured_length_remaining(tvb, offset) <= 1){
                        return FALSE;
                    }
                    num_timestamp = tvb_get_guint8(tvb, offset);
                    offset += 1;

                    if(num_timestamp > 0){
                         
                        offset += 1;

                         
                        offset += 4;

                         
                        offset += (num_timestamp - 1)*(1+2);
                    }

                    if(frame_type & FTFLAGS_ACK_N){
                         
                        if (tvb_captured_length_remaining(tvb, offset) <= 1){
                            return FALSE;
                        }
                        num_ranges = tvb_get_guint8(tvb, offset);
                        offset += 1;

                         
                        offset += num_ranges*(len_missing_packet+1);

                         
                        if (tvb_captured_length_remaining(tvb, offset) <= 1){
                            return FALSE;
                        }
                        num_revived = tvb_get_guint8(tvb, offset);
                        offset += 1;

                         
                        offset += num_revived*len_largest_observed;

                    }
                } else {

                     
                    offset += len_largest_observed;

                     
                    offset += 2;

                     
                    if(frame_type & FTFLAGS_ACK_N){
                        if (tvb_captured_length_remaining(tvb, offset) <= 1){
                            return FALSE;
                        }
                        num_blocks = tvb_get_guint8(tvb, offset);
                        offset += 1;
                    }

                     
                    offset += len_missing_packet;
                    if(num_blocks){
                        offset += (num_blocks)*(1 + len_missing_packet);
                    }

                     
                    if (tvb_captured_length_remaining(tvb, offset) <= 1){
                        return FALSE;
                    }
                    num_timestamp = tvb_get_guint8(tvb, offset);
                    offset += 1;

                    if(num_timestamp > 0){

                         
                        offset += 1;

                         
                        offset += 4;

                         
                        offset += (num_timestamp - 1)*(1+2);
                    }

                }
            } else {  
                offset += 1;
            }
        }
    }

    return FALSE;

}