diff --git a/lib/src/upper/pdcp_entity.cc b/lib/src/upper/pdcp_entity.cc index 27425a698..a7bf51bcb 100644 --- a/lib/src/upper/pdcp_entity.cc +++ b/lib/src/upper/pdcp_entity.cc @@ -342,40 +342,8 @@ void pdcp_entity::run_thread() log->info_hex(pdu->msg, pdu->N_bytes, "RX %s PDU, do_integrity = %s, do_encryption = %s", get_rb_name(lcid), (do_integrity) ? "true" : "false", (do_encryption) ? "true" : "false"); - // Handle SRB messages - switch(lcid) - { - case RB_ID_SRB0: - // Simply pass on to RRC - rrc->write_pdu(RB_ID_SRB0, pdu); - break; - case RB_ID_SRB1: // Intentional fall-through - case RB_ID_SRB2: - uint32_t sn; - if (do_encryption) { - cipher_decrypt(&(pdu->msg[sn_len_bytes]), - rx_count, - pdu->N_bytes - sn_len_bytes, - &(pdu->msg[sn_len_bytes])); - log->info_hex(pdu->msg, pdu->N_bytes, "RX %s PDU (decrypted)", get_rb_name(lcid)); - } - - if (do_integrity) { - integrity_verify(pdu->msg, - rx_count, - pdu->N_bytes - 4, - &(pdu->msg[pdu->N_bytes - 4])); - } - - pdcp_unpack_control_pdu(pdu, &sn); - log->info_hex(pdu->msg, pdu->N_bytes, "RX %s PDU SN: %d", get_rb_name(lcid), sn); - rrc->write_pdu(lcid, pdu); - break; - } - // Handle DRB messages - if(lcid >= RB_ID_DRB1) - { + if (cfg.is_data) { uint32_t sn; if (do_encryption) { cipher_decrypt(&(pdu->msg[sn_len_bytes]), @@ -392,14 +360,38 @@ void pdcp_entity::run_thread() } log->info_hex(pdu->msg, pdu->N_bytes, "RX %s PDU SN: %d", get_rb_name(lcid), sn); gw->write_pdu(lcid, pdu); + } else { + // Handle SRB messages + if (cfg.is_control) { + uint32_t sn; + if (do_encryption) { + cipher_decrypt(&(pdu->msg[sn_len_bytes]), + rx_count, + pdu->N_bytes - sn_len_bytes, + &(pdu->msg[sn_len_bytes])); + log->info_hex(pdu->msg, pdu->N_bytes, "RX %s PDU (decrypted)", get_rb_name(lcid)); + } + + if (do_integrity) { + integrity_verify(pdu->msg, + rx_count, + pdu->N_bytes - 4, + &(pdu->msg[pdu->N_bytes - 4])); + } + + pdcp_unpack_control_pdu(pdu, &sn); + log->info_hex(pdu->msg, pdu->N_bytes, "RX %s PDU SN: %d", get_rb_name(lcid), sn); + } + // pass to RRC + rrc->write_pdu(lcid, pdu); } - rx_count++; } } uint8_t pdcp_entity::get_bearer_id(uint8_t lcid) { + #define RB_ID_SRB2 2 if(lcid <= RB_ID_SRB2) { return lcid - 1; } else {