fix issue in PDCP when bearer ID for DRBs was not starting with 1

master
Andre Puschmann 6 years ago
parent 4867b16e38
commit df40259c26

@ -70,12 +70,14 @@ public:
class srslte_pdcp_config_t class srslte_pdcp_config_t
{ {
public: public:
srslte_pdcp_config_t(bool is_control_ = false, bool is_data_ = false, uint8_t direction_ = SECURITY_DIRECTION_UPLINK) srslte_pdcp_config_t(uint8_t bearer_id_ = 0, bool is_control_ = false, bool is_data_ = false, uint8_t direction_ = SECURITY_DIRECTION_UPLINK)
:direction(direction_) :bearer_id(bearer_id_)
,direction(direction_)
,is_control(is_control_) ,is_control(is_control_)
,is_data(is_data_) ,is_data(is_data_)
,sn_len(12) {} ,sn_len(12) {}
uint32_t bearer_id;
uint8_t direction; uint8_t direction;
bool is_control; bool is_control;
bool is_data; bool is_data;

@ -129,8 +129,6 @@ private:
uint32_t count, uint32_t count,
uint32_t ct_len, uint32_t ct_len,
uint8_t *msg); uint8_t *msg);
uint8_t get_bearer_id(uint8_t lcid);
}; };
/**************************************************************************** /****************************************************************************

@ -244,7 +244,7 @@ void pdcp_entity::integrity_generate( uint8_t *msg,
case INTEGRITY_ALGORITHM_ID_128_EIA1: case INTEGRITY_ALGORITHM_ID_128_EIA1:
security_128_eia1(&k_int[16], security_128_eia1(&k_int[16],
tx_count, tx_count,
get_bearer_id(lcid), cfg.bearer_id - 1,
cfg.direction, cfg.direction,
msg, msg,
msg_len, msg_len,
@ -253,7 +253,7 @@ void pdcp_entity::integrity_generate( uint8_t *msg,
case INTEGRITY_ALGORITHM_ID_128_EIA2: case INTEGRITY_ALGORITHM_ID_128_EIA2:
security_128_eia2(&k_int[16], security_128_eia2(&k_int[16],
tx_count, tx_count,
get_bearer_id(lcid), cfg.bearer_id - 1,
cfg.direction, cfg.direction,
msg, msg,
msg_len, msg_len,
@ -266,7 +266,7 @@ void pdcp_entity::integrity_generate( uint8_t *msg,
log->debug("Integrity gen input:\n"); log->debug("Integrity gen input:\n");
log->debug_hex(&k_int[16], 16, " K_int"); log->debug_hex(&k_int[16], 16, " K_int");
log->debug(" Local count: %d\n", tx_count); 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(" Direction: %s\n", (cfg.direction == SECURITY_DIRECTION_DOWNLINK) ? "Downlink" : "Uplink");
log->debug_hex(msg, msg_len, " Message"); log->debug_hex(msg, msg_len, " Message");
log->debug_hex(mac, 4, "MAC (generated)"); 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: case INTEGRITY_ALGORITHM_ID_128_EIA1:
security_128_eia1(&k_int[16], security_128_eia1(&k_int[16],
count, count,
get_bearer_id(lcid), cfg.bearer_id - 1,
(cfg.direction == SECURITY_DIRECTION_DOWNLINK) ? (SECURITY_DIRECTION_UPLINK) : (SECURITY_DIRECTION_DOWNLINK), (cfg.direction == SECURITY_DIRECTION_DOWNLINK) ? (SECURITY_DIRECTION_UPLINK) : (SECURITY_DIRECTION_DOWNLINK),
msg, msg,
msg_len, msg_len,
@ -297,7 +297,7 @@ bool pdcp_entity::integrity_verify(uint8_t *msg,
case INTEGRITY_ALGORITHM_ID_128_EIA2: case INTEGRITY_ALGORITHM_ID_128_EIA2:
security_128_eia2(&k_int[16], security_128_eia2(&k_int[16],
count, count,
get_bearer_id(lcid), cfg.bearer_id - 1,
(cfg.direction == SECURITY_DIRECTION_DOWNLINK) ? (SECURITY_DIRECTION_UPLINK) : (SECURITY_DIRECTION_DOWNLINK), (cfg.direction == SECURITY_DIRECTION_DOWNLINK) ? (SECURITY_DIRECTION_UPLINK) : (SECURITY_DIRECTION_DOWNLINK),
msg, msg,
msg_len, msg_len,
@ -310,7 +310,7 @@ bool pdcp_entity::integrity_verify(uint8_t *msg,
log->debug("Integrity check input:\n"); log->debug("Integrity check input:\n");
log->debug_hex(&k_int[16], 16, " K_int"); log->debug_hex(&k_int[16], 16, " K_int");
log->debug(" Local count: %d\n", count); 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(" Direction: %s\n", (cfg.direction == SECURITY_DIRECTION_DOWNLINK) ? "Uplink" : "Downlink");
log->debug_hex(msg, msg_len, " Message"); 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: case CIPHERING_ALGORITHM_ID_128_EEA1:
security_128_eea1(&(k_enc[16]), security_128_eea1(&(k_enc[16]),
tx_count, tx_count,
get_bearer_id(lcid), cfg.bearer_id - 1,
cfg.direction, cfg.direction,
msg, msg,
msg_len, msg_len,
@ -361,7 +361,7 @@ void pdcp_entity::cipher_encrypt(uint8_t *msg,
case CIPHERING_ALGORITHM_ID_128_EEA2: case CIPHERING_ALGORITHM_ID_128_EEA2:
security_128_eea2(&(k_enc[16]), security_128_eea2(&(k_enc[16]),
tx_count, tx_count,
get_bearer_id(lcid), cfg.bearer_id - 1,
cfg.direction, cfg.direction,
msg, msg,
msg_len, msg_len,
@ -386,7 +386,7 @@ void pdcp_entity::cipher_decrypt(uint8_t *ct,
case CIPHERING_ALGORITHM_ID_128_EEA1: case CIPHERING_ALGORITHM_ID_128_EEA1:
security_128_eea1(&(k_enc[16]), security_128_eea1(&(k_enc[16]),
count, count,
get_bearer_id(lcid), cfg.bearer_id - 1,
(cfg.direction == SECURITY_DIRECTION_DOWNLINK) ? (SECURITY_DIRECTION_UPLINK) : (SECURITY_DIRECTION_DOWNLINK), (cfg.direction == SECURITY_DIRECTION_DOWNLINK) ? (SECURITY_DIRECTION_UPLINK) : (SECURITY_DIRECTION_DOWNLINK),
ct, ct,
ct_len, ct_len,
@ -396,7 +396,7 @@ void pdcp_entity::cipher_decrypt(uint8_t *ct,
case CIPHERING_ALGORITHM_ID_128_EEA2: case CIPHERING_ALGORITHM_ID_128_EEA2:
security_128_eea2(&(k_enc[16]), security_128_eea2(&(k_enc[16]),
count, count,
get_bearer_id(lcid), cfg.bearer_id - 1,
(cfg.direction == SECURITY_DIRECTION_DOWNLINK) ? (SECURITY_DIRECTION_UPLINK) : (SECURITY_DIRECTION_DOWNLINK), (cfg.direction == SECURITY_DIRECTION_DOWNLINK) ? (SECURITY_DIRECTION_UPLINK) : (SECURITY_DIRECTION_DOWNLINK),
ct, ct,
ct_len, 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() uint32_t pdcp_entity::get_dl_count()
{ {
return rx_count; return rx_count;

@ -1450,6 +1450,7 @@ void rrc::ue::send_connection_setup(bool is_setup)
// Configure SRB1 in PDCP // Configure SRB1 in PDCP
srslte::srslte_pdcp_config_t pdcp_cnfg; srslte::srslte_pdcp_config_t pdcp_cnfg;
pdcp_cnfg.bearer_id = 1;
pdcp_cnfg.is_control = true; pdcp_cnfg.is_control = true;
pdcp_cnfg.direction = SECURITY_DIRECTION_DOWNLINK; pdcp_cnfg.direction = SECURITY_DIRECTION_DOWNLINK;
parent->pdcp->add_bearer(rnti, 1, pdcp_cnfg); 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 // Configure SRB2 in PDCP
srslte::srslte_pdcp_config_t pdcp_cnfg; srslte::srslte_pdcp_config_t pdcp_cnfg;
pdcp_cnfg.bearer_id = 2;
pdcp_cnfg.direction = SECURITY_DIRECTION_DOWNLINK; pdcp_cnfg.direction = SECURITY_DIRECTION_DOWNLINK;
pdcp_cnfg.is_control = true; pdcp_cnfg.is_control = true;
pdcp_cnfg.is_data = false; 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 // Configure DRB in RLC
parent->rlc->add_bearer(rnti, lcid, &conn_reconf->rr_cnfg_ded.drb_to_add_mod_list[i].rlc_cnfg); parent->rlc->add_bearer(rnti, lcid, &conn_reconf->rr_cnfg_ded.drb_to_add_mod_list[i].rlc_cnfg);
// Configure DRB in PDCP // 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 // DRB has already been configured in GTPU through bearer setup
// Add NAS message // Add NAS message

@ -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) { void rrc::add_srb(LIBLTE_RRC_SRB_TO_ADD_MOD_STRUCT *srb_cnfg) {
// Setup PDCP // 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) { 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->config_security(srb_cnfg->srb_id, k_rrc_enc, k_rrc_int, cipher_algo, integ_algo);
pdcp->enable_integrity(srb_cnfg->srb_id); 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 // Setup PDCP
srslte_pdcp_config_t pdcp_cfg; srslte_pdcp_config_t pdcp_cfg;
pdcp_cfg.is_data = true; 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 (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) { if (LIBLTE_RRC_PDCP_SN_SIZE_7_BITS == drb_cnfg->pdcp_cnfg.rlc_um_pdcp_sn_size) {
pdcp_cfg.sn_len = 7; pdcp_cfg.sn_len = 7;

Loading…
Cancel
Save