|
|
@ -35,47 +35,69 @@ pdcp::pdcp()
|
|
|
|
rrc = NULL;
|
|
|
|
rrc = NULL;
|
|
|
|
gw = NULL;
|
|
|
|
gw = NULL;
|
|
|
|
pdcp_log = NULL;
|
|
|
|
pdcp_log = NULL;
|
|
|
|
lcid = 0;
|
|
|
|
default_lcid = 0;
|
|
|
|
direction = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pdcp::~pdcp()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// destroy all remaining entities
|
|
|
|
|
|
|
|
for (pdcp_map_t::iterator it = pdcp_array.begin(); it != pdcp_array.end(); ++it) {
|
|
|
|
|
|
|
|
delete(it->second);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
pdcp_array.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void pdcp::init(srsue::rlc_interface_pdcp *rlc_, srsue::rrc_interface_pdcp *rrc_, srsue::gw_interface_pdcp *gw_, log *pdcp_log_, uint32_t lcid_, uint8_t direction_)
|
|
|
|
void pdcp::init(srsue::rlc_interface_pdcp *rlc_, srsue::rrc_interface_pdcp *rrc_, srsue::gw_interface_pdcp *gw_, log *pdcp_log_, uint32_t lcid_, uint8_t direction_)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
rlc = rlc_;
|
|
|
|
rlc = rlc_;
|
|
|
|
rrc = rrc_;
|
|
|
|
rrc = rrc_;
|
|
|
|
gw = gw_;
|
|
|
|
gw = gw_;
|
|
|
|
pdcp_log = pdcp_log_;
|
|
|
|
pdcp_log = pdcp_log_;
|
|
|
|
lcid = lcid_;
|
|
|
|
default_lcid = lcid_;
|
|
|
|
direction = direction_;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Default config
|
|
|
|
// Default config
|
|
|
|
srslte_pdcp_config_t cnfg;
|
|
|
|
default_cnfg.is_control = false;
|
|
|
|
cnfg.is_control = false;
|
|
|
|
default_cnfg.is_data = false;
|
|
|
|
cnfg.is_data = false;
|
|
|
|
default_cnfg.direction = direction_;
|
|
|
|
cnfg.direction = direction_;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pdcp_array[0].init(rlc, rrc, gw, pdcp_log, lcid, cnfg);
|
|
|
|
// create default PDCP entity for SRB0
|
|
|
|
|
|
|
|
if (not pdcp_array.insert(pdcp_map_pair_t(0, new pdcp_entity())).second) {
|
|
|
|
|
|
|
|
pdcp_log->error("Error inserting PDCP entity in to array\n.");
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
pdcp_array.at(0)->init(rlc, rrc, gw, pdcp_log, default_lcid, default_cnfg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void pdcp::stop()
|
|
|
|
void pdcp::stop()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
// destroy default entity
|
|
|
|
|
|
|
|
if (valid_lcid(0)) {
|
|
|
|
|
|
|
|
pdcp_map_t::iterator it;
|
|
|
|
|
|
|
|
it = pdcp_array.find(0);
|
|
|
|
|
|
|
|
delete(it->second);
|
|
|
|
|
|
|
|
pdcp_array.erase(it);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void pdcp::reestablish() {
|
|
|
|
void pdcp::reestablish() {
|
|
|
|
for(uint32_t i=0;i<SRSLTE_N_RADIO_BEARERS;i++) {
|
|
|
|
for (uint32_t i = 0; i < SRSLTE_N_RADIO_BEARERS; i++) {
|
|
|
|
if (pdcp_array[i].is_active()) {
|
|
|
|
if (valid_lcid(i)) {
|
|
|
|
pdcp_array[i].reestablish();
|
|
|
|
pdcp_array.at(i)->reestablish();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void pdcp::reset()
|
|
|
|
void pdcp::reset()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for(uint32_t i=0;i<SRSLTE_N_RADIO_BEARERS;i++) {
|
|
|
|
for (uint32_t i = 0; i < SRSLTE_N_RADIO_BEARERS; i++) {
|
|
|
|
pdcp_array[i].reset();
|
|
|
|
if (valid_lcid(i)) {
|
|
|
|
|
|
|
|
pdcp_array.at(i)->reset();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pdcp_array[0].init(rlc, rrc, gw, pdcp_log, lcid, direction);
|
|
|
|
if (valid_lcid(0)) {
|
|
|
|
|
|
|
|
pdcp_array.at(0)->init(rlc, rrc, gw, pdcp_log, default_lcid, default_cnfg);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
/*******************************************************************************
|
|
|
@ -83,17 +105,20 @@ void pdcp::reset()
|
|
|
|
*******************************************************************************/
|
|
|
|
*******************************************************************************/
|
|
|
|
bool pdcp::is_drb_enabled(uint32_t lcid)
|
|
|
|
bool pdcp::is_drb_enabled(uint32_t lcid)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(lcid >= SRSLTE_N_RADIO_BEARERS) {
|
|
|
|
if (lcid >= SRSLTE_N_RADIO_BEARERS) {
|
|
|
|
pdcp_log->error("Radio bearer id must be in [0:%d] - %d\n", SRSLTE_N_RADIO_BEARERS, lcid);
|
|
|
|
pdcp_log->error("Radio bearer id must be in [0:%d] - %d\n", SRSLTE_N_RADIO_BEARERS, lcid);
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return pdcp_array[lcid].is_active();
|
|
|
|
if (pdcp_array.find(lcid) == pdcp_array.end()) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return pdcp_array.at(lcid)->is_active();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void pdcp::write_sdu(uint32_t lcid, byte_buffer_t *sdu)
|
|
|
|
void pdcp::write_sdu(uint32_t lcid, byte_buffer_t *sdu)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(valid_lcid(lcid)) {
|
|
|
|
if (valid_lcid(lcid)) {
|
|
|
|
pdcp_array[lcid].write_sdu(sdu);
|
|
|
|
pdcp_array.at(lcid)->write_sdu(sdu);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
pdcp_log->warning("Writing sdu: lcid=%d. Deallocating sdu\n", lcid);
|
|
|
|
pdcp_log->warning("Writing sdu: lcid=%d. Deallocating sdu\n", lcid);
|
|
|
|
byte_buffer_pool::get_instance()->deallocate(sdu);
|
|
|
|
byte_buffer_pool::get_instance()->deallocate(sdu);
|
|
|
@ -102,18 +127,23 @@ void pdcp::write_sdu(uint32_t lcid, byte_buffer_t *sdu)
|
|
|
|
|
|
|
|
|
|
|
|
void pdcp::write_sdu_mch(uint32_t lcid, byte_buffer_t *sdu)
|
|
|
|
void pdcp::write_sdu_mch(uint32_t lcid, byte_buffer_t *sdu)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(valid_mch_lcid(lcid)){
|
|
|
|
if (valid_mch_lcid(lcid)){
|
|
|
|
pdcp_array_mrb[lcid].write_sdu(sdu);
|
|
|
|
pdcp_array_mrb.at(lcid)->write_sdu(sdu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void pdcp::add_bearer(uint32_t lcid, srslte_pdcp_config_t cfg)
|
|
|
|
void pdcp::add_bearer(uint32_t lcid, srslte_pdcp_config_t cfg)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(lcid >= SRSLTE_N_RADIO_BEARERS) {
|
|
|
|
if (lcid >= SRSLTE_N_RADIO_BEARERS) {
|
|
|
|
pdcp_log->error("Radio bearer id must be in [0:%d] - %d\n", SRSLTE_N_RADIO_BEARERS, lcid);
|
|
|
|
pdcp_log->error("Radio bearer id must be in [0:%d] - %d\n", SRSLTE_N_RADIO_BEARERS, lcid);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!pdcp_array[lcid].is_active()) {
|
|
|
|
|
|
|
|
pdcp_array[lcid].init(rlc, rrc, gw, pdcp_log, lcid, cfg);
|
|
|
|
if (not valid_lcid(lcid)) {
|
|
|
|
|
|
|
|
if (not pdcp_array.insert(pdcp_map_pair_t(lcid, new pdcp_entity())).second) {
|
|
|
|
|
|
|
|
pdcp_log->error("Error inserting PDCP entity in to array\n.");
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
pdcp_array.at(lcid)->init(rlc, rrc, gw, pdcp_log, lcid, cfg);
|
|
|
|
pdcp_log->info("Added bearer %s\n", rrc->get_rb_name(lcid).c_str());
|
|
|
|
pdcp_log->info("Added bearer %s\n", rrc->get_rb_name(lcid).c_str());
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
pdcp_log->warning("Bearer %s already configured. Reconfiguration not supported\n", rrc->get_rb_name(lcid).c_str());
|
|
|
|
pdcp_log->warning("Bearer %s already configured. Reconfiguration not supported\n", rrc->get_rb_name(lcid).c_str());
|
|
|
@ -123,12 +153,16 @@ void pdcp::add_bearer(uint32_t lcid, srslte_pdcp_config_t cfg)
|
|
|
|
|
|
|
|
|
|
|
|
void pdcp::add_bearer_mrb(uint32_t lcid, srslte_pdcp_config_t cfg)
|
|
|
|
void pdcp::add_bearer_mrb(uint32_t lcid, srslte_pdcp_config_t cfg)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(lcid >= SRSLTE_N_RADIO_BEARERS) {
|
|
|
|
if (lcid >= SRSLTE_N_RADIO_BEARERS) {
|
|
|
|
pdcp_log->error("Radio bearer id must be in [0:%d] - %d\n", SRSLTE_N_RADIO_BEARERS, lcid);
|
|
|
|
pdcp_log->error("Radio bearer id must be in [0:%d] - %d\n", SRSLTE_N_RADIO_BEARERS, lcid);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!pdcp_array_mrb[lcid].is_active()) {
|
|
|
|
if (not valid_mch_lcid(lcid)) {
|
|
|
|
pdcp_array_mrb[lcid].init(rlc, rrc, gw, pdcp_log, lcid, cfg);
|
|
|
|
if (pdcp_array_mrb.insert(pdcp_map_pair_t(lcid, new pdcp_entity())).second) {
|
|
|
|
|
|
|
|
pdcp_log->error("Error inserting PDCP entity in to array\n.");
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
pdcp_array_mrb.at(lcid)->init(rlc, rrc, gw, pdcp_log, lcid, cfg);
|
|
|
|
pdcp_log->info("Added bearer %s\n", rrc->get_rb_name(lcid).c_str());
|
|
|
|
pdcp_log->info("Added bearer %s\n", rrc->get_rb_name(lcid).c_str());
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
pdcp_log->warning("Bearer %s already configured. Reconfiguration not supported\n", rrc->get_rb_name(lcid).c_str());
|
|
|
|
pdcp_log->warning("Bearer %s already configured. Reconfiguration not supported\n", rrc->get_rb_name(lcid).c_str());
|
|
|
@ -141,8 +175,9 @@ void pdcp::config_security(uint32_t lcid,
|
|
|
|
CIPHERING_ALGORITHM_ID_ENUM cipher_algo,
|
|
|
|
CIPHERING_ALGORITHM_ID_ENUM cipher_algo,
|
|
|
|
INTEGRITY_ALGORITHM_ID_ENUM integ_algo)
|
|
|
|
INTEGRITY_ALGORITHM_ID_ENUM integ_algo)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(valid_lcid(lcid))
|
|
|
|
if (valid_lcid(lcid)) {
|
|
|
|
pdcp_array[lcid].config_security(k_enc, k_int, cipher_algo, integ_algo);
|
|
|
|
pdcp_array.at(lcid)->config_security(k_enc, k_int, cipher_algo, integ_algo);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void pdcp::config_security_all(uint8_t *k_enc,
|
|
|
|
void pdcp::config_security_all(uint8_t *k_enc,
|
|
|
@ -151,22 +186,24 @@ void pdcp::config_security_all(uint8_t *k_enc,
|
|
|
|
INTEGRITY_ALGORITHM_ID_ENUM integ_algo)
|
|
|
|
INTEGRITY_ALGORITHM_ID_ENUM integ_algo)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for(uint32_t i=0;i<SRSLTE_N_RADIO_BEARERS;i++) {
|
|
|
|
for(uint32_t i=0;i<SRSLTE_N_RADIO_BEARERS;i++) {
|
|
|
|
if (pdcp_array[i].is_active()) {
|
|
|
|
if (pdcp_array.at(i)->is_active()) {
|
|
|
|
pdcp_array[i].config_security(k_enc, k_int, cipher_algo, integ_algo);
|
|
|
|
pdcp_array.at(i)->config_security(k_enc, k_int, cipher_algo, integ_algo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void pdcp::enable_integrity(uint32_t lcid)
|
|
|
|
void pdcp::enable_integrity(uint32_t lcid)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(valid_lcid(lcid))
|
|
|
|
if (valid_lcid(lcid)) {
|
|
|
|
pdcp_array[lcid].enable_integrity();
|
|
|
|
pdcp_array.at(lcid)->enable_integrity();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void pdcp::enable_encryption(uint32_t lcid)
|
|
|
|
void pdcp::enable_encryption(uint32_t lcid)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(valid_lcid(lcid))
|
|
|
|
if (valid_lcid(lcid)) {
|
|
|
|
pdcp_array[lcid].enable_encryption();
|
|
|
|
pdcp_array.at(lcid)->enable_encryption();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
/*******************************************************************************
|
|
|
@ -174,8 +211,8 @@ void pdcp::enable_encryption(uint32_t lcid)
|
|
|
|
*******************************************************************************/
|
|
|
|
*******************************************************************************/
|
|
|
|
void pdcp::write_pdu(uint32_t lcid, byte_buffer_t *pdu)
|
|
|
|
void pdcp::write_pdu(uint32_t lcid, byte_buffer_t *pdu)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(valid_lcid(lcid)) {
|
|
|
|
if (valid_lcid(lcid)) {
|
|
|
|
pdcp_array[lcid].write_pdu(pdu);
|
|
|
|
pdcp_array.at(lcid)->write_pdu(pdu);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
pdcp_log->warning("Writing pdu: lcid=%d. Deallocating pdu\n", lcid);
|
|
|
|
pdcp_log->warning("Writing pdu: lcid=%d. Deallocating pdu\n", lcid);
|
|
|
|
byte_buffer_pool::get_instance()->deallocate(pdu);
|
|
|
|
byte_buffer_pool::get_instance()->deallocate(pdu);
|
|
|
@ -198,7 +235,7 @@ void pdcp::write_pdu_pcch(byte_buffer_t *sdu)
|
|
|
|
|
|
|
|
|
|
|
|
void pdcp::write_pdu_mch(uint32_t lcid, byte_buffer_t *sdu)
|
|
|
|
void pdcp::write_pdu_mch(uint32_t lcid, byte_buffer_t *sdu)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(0 == lcid) {
|
|
|
|
if (0 == lcid) {
|
|
|
|
rrc->write_pdu_mch(lcid, sdu);
|
|
|
|
rrc->write_pdu_mch(lcid, sdu);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
gw->write_pdu_mch(lcid, sdu);
|
|
|
|
gw->write_pdu_mch(lcid, sdu);
|
|
|
@ -210,27 +247,31 @@ void pdcp::write_pdu_mch(uint32_t lcid, byte_buffer_t *sdu)
|
|
|
|
*******************************************************************************/
|
|
|
|
*******************************************************************************/
|
|
|
|
bool pdcp::valid_lcid(uint32_t lcid)
|
|
|
|
bool pdcp::valid_lcid(uint32_t lcid)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(lcid >= SRSLTE_N_RADIO_BEARERS) {
|
|
|
|
if (lcid >= SRSLTE_N_RADIO_BEARERS) {
|
|
|
|
pdcp_log->error("Radio bearer id must be in [0:%d] - %d", SRSLTE_N_RADIO_BEARERS, lcid);
|
|
|
|
pdcp_log->error("Radio bearer id must be in [0:%d] - %d", SRSLTE_N_RADIO_BEARERS, lcid);
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!pdcp_array[lcid].is_active()) {
|
|
|
|
|
|
|
|
|
|
|
|
if (pdcp_array.find(lcid) == pdcp_array.end()) {
|
|
|
|
pdcp_log->error("PDCP entity for logical channel %d has not been activated\n", lcid);
|
|
|
|
pdcp_log->error("PDCP entity for logical channel %d has not been activated\n", lcid);
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool pdcp::valid_mch_lcid(uint32_t lcid)
|
|
|
|
bool pdcp::valid_mch_lcid(uint32_t lcid)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(lcid >= SRSLTE_N_MCH_LCIDS) {
|
|
|
|
if (lcid >= SRSLTE_N_MCH_LCIDS) {
|
|
|
|
pdcp_log->error("Radio bearer id must be in [0:%d] - %d", SRSLTE_N_RADIO_BEARERS, lcid);
|
|
|
|
pdcp_log->error("Radio bearer id must be in [0:%d] - %d", SRSLTE_N_RADIO_BEARERS, lcid);
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!pdcp_array_mrb[lcid].is_active()) {
|
|
|
|
|
|
|
|
|
|
|
|
if (pdcp_array_mrb.find(lcid) == pdcp_array_mrb.end()) {
|
|
|
|
pdcp_log->error("PDCP entity for logical channel %d has not been activated\n", lcid);
|
|
|
|
pdcp_log->error("PDCP entity for logical channel %d has not been activated\n", lcid);
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|