diff --git a/lib/include/srslte/common/interfaces_common.h b/lib/include/srslte/common/interfaces_common.h index 254d6306e..bc458af74 100644 --- a/lib/include/srslte/common/interfaces_common.h +++ b/lib/include/srslte/common/interfaces_common.h @@ -70,12 +70,14 @@ public: class srslte_pdcp_config_t { public: - srslte_pdcp_config_t(bool is_control_ = false, bool is_data_ = false, uint8_t direction_ = SECURITY_DIRECTION_UPLINK) - :direction(direction_) + srslte_pdcp_config_t(uint8_t bearer_id_ = 0, bool is_control_ = false, bool is_data_ = false, uint8_t direction_ = SECURITY_DIRECTION_UPLINK) + :bearer_id(bearer_id_) + ,direction(direction_) ,is_control(is_control_) ,is_data(is_data_) ,sn_len(12) {} + uint32_t bearer_id; uint8_t direction; bool is_control; bool is_data; diff --git a/lib/include/srslte/upper/pdcp_entity.h b/lib/include/srslte/upper/pdcp_entity.h index aea49462c..4413f8027 100644 --- a/lib/include/srslte/upper/pdcp_entity.h +++ b/lib/include/srslte/upper/pdcp_entity.h @@ -129,8 +129,6 @@ private: uint32_t count, uint32_t ct_len, uint8_t *msg); - - uint8_t get_bearer_id(uint8_t lcid); }; /**************************************************************************** diff --git a/lib/src/upper/pdcp_entity.cc b/lib/src/upper/pdcp_entity.cc index 0e0877414..b52f8738d 100644 --- a/lib/src/upper/pdcp_entity.cc +++ b/lib/src/upper/pdcp_entity.cc @@ -244,7 +244,7 @@ void pdcp_entity::integrity_generate( uint8_t *msg, case INTEGRITY_ALGORITHM_ID_128_EIA1: security_128_eia1(&k_int[16], tx_count, - get_bearer_id(lcid), + cfg.bearer_id - 1, cfg.direction, msg, msg_len, @@ -253,7 +253,7 @@ void pdcp_entity::integrity_generate( uint8_t *msg, case INTEGRITY_ALGORITHM_ID_128_EIA2: security_128_eia2(&k_int[16], tx_count, - get_bearer_id(lcid), + cfg.bearer_id - 1, cfg.direction, msg, msg_len, @@ -266,7 +266,7 @@ void pdcp_entity::integrity_generate( uint8_t *msg, log->debug("Integrity gen input:\n"); log->debug_hex(&k_int[16], 16, " K_int"); log->debug(" Local count: %d\n", tx_count); - log->debug(" Bearer ID: %d\n", get_bearer_id(lcid)); + log->debug(" Bearer ID: %d\n", cfg.bearer_id); log->debug(" Direction: %s\n", (cfg.direction == SECURITY_DIRECTION_DOWNLINK) ? "Downlink" : "Uplink"); log->debug_hex(msg, msg_len, " Message"); log->debug_hex(mac, 4, "MAC (generated)"); @@ -288,7 +288,7 @@ bool pdcp_entity::integrity_verify(uint8_t *msg, case INTEGRITY_ALGORITHM_ID_128_EIA1: security_128_eia1(&k_int[16], count, - get_bearer_id(lcid), + cfg.bearer_id - 1, (cfg.direction == SECURITY_DIRECTION_DOWNLINK) ? (SECURITY_DIRECTION_UPLINK) : (SECURITY_DIRECTION_DOWNLINK), msg, msg_len, @@ -297,7 +297,7 @@ bool pdcp_entity::integrity_verify(uint8_t *msg, case INTEGRITY_ALGORITHM_ID_128_EIA2: security_128_eia2(&k_int[16], count, - get_bearer_id(lcid), + cfg.bearer_id - 1, (cfg.direction == SECURITY_DIRECTION_DOWNLINK) ? (SECURITY_DIRECTION_UPLINK) : (SECURITY_DIRECTION_DOWNLINK), msg, msg_len, @@ -310,7 +310,7 @@ bool pdcp_entity::integrity_verify(uint8_t *msg, log->debug("Integrity check input:\n"); log->debug_hex(&k_int[16], 16, " K_int"); log->debug(" Local count: %d\n", count); - log->debug(" Bearer ID: %d\n", get_bearer_id(lcid)); + log->debug(" Bearer ID: %d\n", cfg.bearer_id); log->debug(" Direction: %s\n", (cfg.direction == SECURITY_DIRECTION_DOWNLINK) ? "Uplink" : "Downlink"); log->debug_hex(msg, msg_len, " Message"); @@ -351,7 +351,7 @@ void pdcp_entity::cipher_encrypt(uint8_t *msg, case CIPHERING_ALGORITHM_ID_128_EEA1: security_128_eea1(&(k_enc[16]), tx_count, - get_bearer_id(lcid), + cfg.bearer_id - 1, cfg.direction, msg, msg_len, @@ -361,7 +361,7 @@ void pdcp_entity::cipher_encrypt(uint8_t *msg, case CIPHERING_ALGORITHM_ID_128_EEA2: security_128_eea2(&(k_enc[16]), tx_count, - get_bearer_id(lcid), + cfg.bearer_id - 1, cfg.direction, msg, msg_len, @@ -386,7 +386,7 @@ void pdcp_entity::cipher_decrypt(uint8_t *ct, case CIPHERING_ALGORITHM_ID_128_EEA1: security_128_eea1(&(k_enc[16]), count, - get_bearer_id(lcid), + cfg.bearer_id - 1, (cfg.direction == SECURITY_DIRECTION_DOWNLINK) ? (SECURITY_DIRECTION_UPLINK) : (SECURITY_DIRECTION_DOWNLINK), ct, ct_len, @@ -396,7 +396,7 @@ void pdcp_entity::cipher_decrypt(uint8_t *ct, case CIPHERING_ALGORITHM_ID_128_EEA2: security_128_eea2(&(k_enc[16]), count, - get_bearer_id(lcid), + cfg.bearer_id - 1, (cfg.direction == SECURITY_DIRECTION_DOWNLINK) ? (SECURITY_DIRECTION_UPLINK) : (SECURITY_DIRECTION_DOWNLINK), ct, ct_len, @@ -409,17 +409,6 @@ void pdcp_entity::cipher_decrypt(uint8_t *ct, } -uint8_t pdcp_entity::get_bearer_id(uint8_t lcid) -{ - #define RB_ID_SRB2 2 - if(lcid <= RB_ID_SRB2) { - return lcid - 1; - } else { - return lcid - RB_ID_SRB2 - 1; - } -} - - uint32_t pdcp_entity::get_dl_count() { return rx_count; diff --git a/srsenb/src/upper/rrc.cc b/srsenb/src/upper/rrc.cc index 9c1ef0f18..5c00e94f8 100644 --- a/srsenb/src/upper/rrc.cc +++ b/srsenb/src/upper/rrc.cc @@ -1450,6 +1450,7 @@ void rrc::ue::send_connection_setup(bool is_setup) // Configure SRB1 in PDCP srslte::srslte_pdcp_config_t pdcp_cnfg; + pdcp_cnfg.bearer_id = 1; pdcp_cnfg.is_control = true; pdcp_cnfg.direction = SECURITY_DIRECTION_DOWNLINK; parent->pdcp->add_bearer(rnti, 1, pdcp_cnfg); @@ -1670,6 +1671,7 @@ void rrc::ue::send_connection_reconf(srslte::byte_buffer_t *pdu) // Configure SRB2 in PDCP srslte::srslte_pdcp_config_t pdcp_cnfg; + pdcp_cnfg.bearer_id = 2; pdcp_cnfg.direction = SECURITY_DIRECTION_DOWNLINK; pdcp_cnfg.is_control = true; pdcp_cnfg.is_data = false; @@ -1753,7 +1755,11 @@ void rrc::ue::send_connection_reconf_new_bearer(LIBLTE_S1AP_E_RABTOBESETUPLISTBE // Configure DRB in RLC parent->rlc->add_bearer(rnti, lcid, &conn_reconf->rr_cnfg_ded.drb_to_add_mod_list[i].rlc_cnfg); // Configure DRB in PDCP - parent->pdcp->add_bearer(rnti, lcid, &conn_reconf->rr_cnfg_ded.drb_to_add_mod_list[i].pdcp_cnfg); + srslte::srslte_pdcp_config_t pdcp_config; + pdcp_config.bearer_id = conn_reconf->rr_cnfg_ded.drb_to_add_mod_list[i].drb_id; + pdcp_config.is_data = true; + pdcp_config.direction = SECURITY_DIRECTION_DOWNLINK; + parent->pdcp->add_bearer(rnti, lcid, pdcp_config); // DRB has already been configured in GTPU through bearer setup // Add NAS message diff --git a/srsue/src/upper/rrc.cc b/srsue/src/upper/rrc.cc index 18fea62e2..808ef8213 100644 --- a/srsue/src/upper/rrc.cc +++ b/srsue/src/upper/rrc.cc @@ -2610,7 +2610,10 @@ void rrc::handle_con_reest(LIBLTE_RRC_CONNECTION_REESTABLISHMENT_STRUCT *setup) void rrc::add_srb(LIBLTE_RRC_SRB_TO_ADD_MOD_STRUCT *srb_cnfg) { // Setup PDCP - pdcp->add_bearer(srb_cnfg->srb_id, srslte_pdcp_config_t(true)); // Set PDCP config control flag + srslte_pdcp_config_t pdcp_cfg; + pdcp_cfg.is_control = true; + pdcp_cfg.bearer_id = srb_cnfg->srb_id; + pdcp->add_bearer(srb_cnfg->srb_id, pdcp_cfg); if(RB_ID_SRB2 == srb_cnfg->srb_id) { pdcp->config_security(srb_cnfg->srb_id, k_rrc_enc, k_rrc_int, cipher_algo, integ_algo); pdcp->enable_integrity(srb_cnfg->srb_id); @@ -2675,6 +2678,7 @@ void rrc::add_drb(LIBLTE_RRC_DRB_TO_ADD_MOD_STRUCT *drb_cnfg) { // Setup PDCP srslte_pdcp_config_t pdcp_cfg; pdcp_cfg.is_data = true; + pdcp_cfg.bearer_id = drb_cnfg->drb_id; if (drb_cnfg->pdcp_cnfg.rlc_um_pdcp_sn_size_present) { if (LIBLTE_RRC_PDCP_SN_SIZE_7_BITS == drb_cnfg->pdcp_cnfg.rlc_um_pdcp_sn_size) { pdcp_cfg.sn_len = 7;