Starting to add separate functions for PDCP handling for UM DRBs and AM DRBs

master
Pedro Alvarez 6 years ago committed by Andre Puschmann
parent 6578cf1d01
commit f4fd6034ba

@ -109,12 +109,18 @@ private:
uint32_t rx_hfn;
uint32_t next_pdcp_rx_sn;
uint32_t reordering_window;
CIPHERING_ALGORITHM_ID_ENUM cipher_algo;
INTEGRITY_ALGORITHM_ID_ENUM integ_algo;
uint32_t maximum_pdcp_sn;
pthread_mutex_t mutex;
void handle_um_drb_pdu(srslte::byte_buffer_t *pdu);
void handle_am_drb_pdu(srslte::byte_buffer_t *pdu);
void integrity_generate(uint8_t *msg,
uint32_t msg_len,
uint8_t *mac);
@ -148,6 +154,4 @@ void pdcp_pack_data_pdu_long_sn(uint32_t sn, byte_buffer_t *sdu);
void pdcp_unpack_data_pdu_long_sn(byte_buffer_t *sdu, uint32_t *sn);
} // namespace srslte
#endif // SRSLTE_PDCP_ENTITY_H

@ -74,6 +74,15 @@ void pdcp_entity::init(srsue::rlc_interface_pdcp *rlc_,
// set length of SN field in bytes
sn_len_bytes = (cfg.sn_len == 5) ? 1 : 2;
if (cfg.is_control) {
reordering_window = 0;
} else if (cfg.is_data) {
reordering_window = 2048;
}
maximum_pdcp_sn = (1 << cfg.sn_len) - 1;
log->info("Init %s with bearer ID: %d\n", rrc->get_rb_name(lcid).c_str(), cfg.bearer_id);
}
// Reestablishment procedure: 36.323 5.2
@ -196,29 +205,12 @@ void pdcp_entity::write_pdu(unique_byte_buffer_t pdu)
if (cfg.is_data) {
// Handle DRB messages
uint32_t sn;
if (12 == cfg.sn_len) {
pdcp_unpack_data_pdu_long_sn(pdu.get(), &sn);
if (rlc->rb_is_um(lcid)) {
handle_um_drb_pdu(pdu);
} else {
pdcp_unpack_data_pdu_short_sn(pdu.get(), &sn);
handle_am_drb_pdu(pdu);
}
if (sn < next_pdcp_rx_sn) {
rx_hfn++;
}
uint32_t count = (rx_hfn << cfg.sn_len) | sn;
if (do_encryption) {
cipher_decrypt(pdu->msg,
count,
pdu->N_bytes,
pdu->msg);
log->debug_hex(pdu->msg, pdu->N_bytes, "RX %s PDU (decrypted)", rrc->get_rb_name(lcid).c_str());
}
next_pdcp_rx_sn = sn + 1;
log->info_hex(pdu->msg, pdu->N_bytes, "RX %s PDU SN: %d", rrc->get_rb_name(lcid).c_str(), sn);
gw->write_pdu(lcid, std::move(pdu));
gw->write_pdu(lcid, pdu);
} else {
// Handle SRB messages
if (cfg.is_control) {
@ -252,6 +244,50 @@ exit:
pthread_mutex_unlock(&mutex);
}
/****************************************************************************
* Rx data/control handler functions
* Ref: 3GPP TS 36.323 v10.1.0 Section 5.1.2
***************************************************************************/
// DRBs mapped on RLC UM (5.1.2.1.3)
void pdcp_entity::handle_um_drb_pdu(srslte::byte_buffer_t* pdu)
{
uint32_t sn;
if (12 == cfg.sn_len) {
pdcp_unpack_data_pdu_long_sn(pdu, &sn);
} else {
pdcp_unpack_data_pdu_short_sn(pdu, &sn);
}
if (sn < next_pdcp_rx_sn) {
rx_hfn++;
}
uint32_t count = (rx_hfn << cfg.sn_len) | sn;
if (do_encryption) {
cipher_decrypt(pdu->msg, count, pdu->N_bytes, pdu->msg);
log->debug_hex(pdu->msg, pdu->N_bytes, "RX %s PDU (decrypted)", rrc->get_rb_name(lcid).c_str());
}
next_pdcp_rx_sn = sn + 1;
if (next_pdcp_rx_sn > maximum_pdcp_sn) {
next_pdcp_rx_sn = 0;
rx_hfn++;
}
log->info_hex(pdu->msg, pdu->N_bytes, "RX %s PDU SN: %d", rrc->get_rb_name(lcid).c_str(), sn);
return;
}
// DRBs mapped on RLC AM, without re-ordering (5.1.2.1.2)
void pdcp_entity::handle_am_drb_pdu(srslte::byte_buffer_t* pdu)
{
handle_um_drb_pdu(pdu); //FIXME!!!
return;
}
/****************************************************************************
* Security functions
***************************************************************************/
void pdcp_entity::integrity_generate( uint8_t *msg,
uint32_t msg_len,
uint8_t *mac)

Loading…
Cancel
Save