|
|
@ -36,15 +36,20 @@ pdcp::pdcp()
|
|
|
|
gw = NULL;
|
|
|
|
gw = NULL;
|
|
|
|
pdcp_log = NULL;
|
|
|
|
pdcp_log = NULL;
|
|
|
|
default_lcid = 0;
|
|
|
|
default_lcid = 0;
|
|
|
|
|
|
|
|
pthread_rwlock_init(&rwlock, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pdcp::~pdcp()
|
|
|
|
pdcp::~pdcp()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// destroy all remaining entities
|
|
|
|
// destroy all remaining entities
|
|
|
|
|
|
|
|
pthread_rwlock_wrlock(&rwlock);
|
|
|
|
for (pdcp_map_t::iterator it = pdcp_array.begin(); it != pdcp_array.end(); ++it) {
|
|
|
|
for (pdcp_map_t::iterator it = pdcp_array.begin(); it != pdcp_array.end(); ++it) {
|
|
|
|
delete(it->second);
|
|
|
|
delete(it->second);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pdcp_array.clear();
|
|
|
|
pdcp_array.clear();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pthread_rwlock_unlock(&rwlock);
|
|
|
|
|
|
|
|
pthread_rwlock_destroy(&rwlock);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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_)
|
|
|
@ -61,34 +66,34 @@ void pdcp::init(srsue::rlc_interface_pdcp *rlc_, srsue::rrc_interface_pdcp *rrc_
|
|
|
|
default_cnfg.direction = direction_;
|
|
|
|
default_cnfg.direction = direction_;
|
|
|
|
|
|
|
|
|
|
|
|
// create default PDCP entity for SRB0
|
|
|
|
// create default PDCP entity for SRB0
|
|
|
|
if (not pdcp_array.insert(pdcp_map_pair_t(0, new pdcp_entity())).second) {
|
|
|
|
add_bearer(0, default_cnfg);
|
|
|
|
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
|
|
|
|
// destroy default entity
|
|
|
|
|
|
|
|
pthread_rwlock_wrlock(&rwlock);
|
|
|
|
if (valid_lcid(0)) {
|
|
|
|
if (valid_lcid(0)) {
|
|
|
|
pdcp_map_t::iterator it;
|
|
|
|
pdcp_map_t::iterator it = pdcp_array.find(0);
|
|
|
|
it = pdcp_array.find(0);
|
|
|
|
|
|
|
|
delete(it->second);
|
|
|
|
delete(it->second);
|
|
|
|
pdcp_array.erase(it);
|
|
|
|
pdcp_array.erase(it);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pthread_rwlock_unlock(&rwlock);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void pdcp::reestablish() {
|
|
|
|
void pdcp::reestablish() {
|
|
|
|
|
|
|
|
pthread_rwlock_rdlock(&rwlock);
|
|
|
|
for (uint32_t i = 0; i < SRSLTE_N_RADIO_BEARERS; i++) {
|
|
|
|
for (uint32_t i = 0; i < SRSLTE_N_RADIO_BEARERS; i++) {
|
|
|
|
if (valid_lcid(i)) {
|
|
|
|
if (valid_lcid(i)) {
|
|
|
|
pdcp_array.at(i)->reestablish();
|
|
|
|
pdcp_array.at(i)->reestablish();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pthread_rwlock_unlock(&rwlock);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void pdcp::reset()
|
|
|
|
void pdcp::reset()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
pthread_rwlock_rdlock(&rwlock);
|
|
|
|
for (uint32_t i = 0; i < SRSLTE_N_RADIO_BEARERS; i++) {
|
|
|
|
for (uint32_t i = 0; i < SRSLTE_N_RADIO_BEARERS; i++) {
|
|
|
|
if (valid_lcid(i)) {
|
|
|
|
if (valid_lcid(i)) {
|
|
|
|
pdcp_array.at(i)->reset();
|
|
|
|
pdcp_array.at(i)->reset();
|
|
|
@ -98,6 +103,7 @@ void pdcp::reset()
|
|
|
|
if (valid_lcid(0)) {
|
|
|
|
if (valid_lcid(0)) {
|
|
|
|
pdcp_array.at(0)->init(rlc, rrc, gw, pdcp_log, default_lcid, default_cnfg);
|
|
|
|
pdcp_array.at(0)->init(rlc, rrc, gw, pdcp_log, default_lcid, default_cnfg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pthread_rwlock_unlock(&rwlock);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
/*******************************************************************************
|
|
|
@ -105,39 +111,46 @@ void pdcp::reset()
|
|
|
|
*******************************************************************************/
|
|
|
|
*******************************************************************************/
|
|
|
|
bool pdcp::is_drb_enabled(uint32_t lcid)
|
|
|
|
bool pdcp::is_drb_enabled(uint32_t lcid)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
pthread_rwlock_rdlock(&rwlock);
|
|
|
|
|
|
|
|
bool ret = false;
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
goto unlock_and_exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (pdcp_array.find(lcid) == pdcp_array.end()) {
|
|
|
|
if (pdcp_array.find(lcid) == pdcp_array.end()) {
|
|
|
|
return false;
|
|
|
|
goto unlock_and_exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return pdcp_array.at(lcid)->is_active();
|
|
|
|
ret = pdcp_array.at(lcid)->is_active();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unlock_and_exit:
|
|
|
|
|
|
|
|
pthread_rwlock_unlock(&rwlock);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void pdcp::write_sdu(uint32_t lcid, byte_buffer_t *sdu)
|
|
|
|
void pdcp::write_sdu(uint32_t lcid, byte_buffer_t *sdu)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
pthread_rwlock_rdlock(&rwlock);
|
|
|
|
if (valid_lcid(lcid)) {
|
|
|
|
if (valid_lcid(lcid)) {
|
|
|
|
pdcp_array.at(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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pthread_rwlock_unlock(&rwlock);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void pdcp::write_sdu_mch(uint32_t lcid, byte_buffer_t *sdu)
|
|
|
|
void pdcp::write_sdu_mch(uint32_t lcid, byte_buffer_t *sdu)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
pthread_rwlock_rdlock(&rwlock);
|
|
|
|
if (valid_mch_lcid(lcid)){
|
|
|
|
if (valid_mch_lcid(lcid)){
|
|
|
|
pdcp_array_mrb.at(lcid)->write_sdu(sdu);
|
|
|
|
pdcp_array_mrb.at(lcid)->write_sdu(sdu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pthread_rwlock_unlock(&rwlock);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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) {
|
|
|
|
pthread_rwlock_rdlock(&rwlock);
|
|
|
|
pdcp_log->error("Radio bearer id must be in [0:%d] - %d\n", SRSLTE_N_RADIO_BEARERS, lcid);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (not valid_lcid(lcid)) {
|
|
|
|
if (not valid_lcid(lcid)) {
|
|
|
|
if (not pdcp_array.insert(pdcp_map_pair_t(lcid, new pdcp_entity())).second) {
|
|
|
|
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.");
|
|
|
|
pdcp_log->error("Error inserting PDCP entity in to array\n.");
|
|
|
@ -148,17 +161,15 @@ void pdcp::add_bearer(uint32_t lcid, srslte_pdcp_config_t cfg)
|
|
|
|
} 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());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pthread_rwlock_unlock(&rwlock);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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) {
|
|
|
|
pthread_rwlock_rdlock(&rwlock);
|
|
|
|
pdcp_log->error("Radio bearer id must be in [0:%d] - %d\n", SRSLTE_N_RADIO_BEARERS, lcid);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (not valid_mch_lcid(lcid)) {
|
|
|
|
if (not valid_mch_lcid(lcid)) {
|
|
|
|
if (pdcp_array_mrb.insert(pdcp_map_pair_t(lcid, new pdcp_entity())).second) {
|
|
|
|
if (not pdcp_array_mrb.insert(pdcp_map_pair_t(lcid, new pdcp_entity())).second) {
|
|
|
|
pdcp_log->error("Error inserting PDCP entity in to array\n.");
|
|
|
|
pdcp_log->error("Error inserting PDCP entity in to array\n.");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -167,6 +178,7 @@ void pdcp::add_bearer_mrb(uint32_t lcid, srslte_pdcp_config_t cfg)
|
|
|
|
} 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());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pthread_rwlock_unlock(&rwlock);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void pdcp::config_security(uint32_t lcid,
|
|
|
|
void pdcp::config_security(uint32_t lcid,
|
|
|
@ -175,9 +187,11 @@ 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)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
pthread_rwlock_rdlock(&rwlock);
|
|
|
|
if (valid_lcid(lcid)) {
|
|
|
|
if (valid_lcid(lcid)) {
|
|
|
|
pdcp_array.at(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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pthread_rwlock_unlock(&rwlock);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void pdcp::config_security_all(uint8_t *k_enc,
|
|
|
|
void pdcp::config_security_all(uint8_t *k_enc,
|
|
|
@ -185,25 +199,31 @@ void pdcp::config_security_all(uint8_t *k_enc,
|
|
|
|
CIPHERING_ALGORITHM_ID_ENUM cipher_algo,
|
|
|
|
CIPHERING_ALGORITHM_ID_ENUM cipher_algo,
|
|
|
|
INTEGRITY_ALGORITHM_ID_ENUM integ_algo)
|
|
|
|
INTEGRITY_ALGORITHM_ID_ENUM integ_algo)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
pthread_rwlock_rdlock(&rwlock);
|
|
|
|
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.at(i)->is_active()) {
|
|
|
|
if (pdcp_array.at(i)->is_active()) {
|
|
|
|
pdcp_array.at(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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pthread_rwlock_unlock(&rwlock);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void pdcp::enable_integrity(uint32_t lcid)
|
|
|
|
void pdcp::enable_integrity(uint32_t lcid)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
pthread_rwlock_rdlock(&rwlock);
|
|
|
|
if (valid_lcid(lcid)) {
|
|
|
|
if (valid_lcid(lcid)) {
|
|
|
|
pdcp_array.at(lcid)->enable_integrity();
|
|
|
|
pdcp_array.at(lcid)->enable_integrity();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pthread_rwlock_unlock(&rwlock);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void pdcp::enable_encryption(uint32_t lcid)
|
|
|
|
void pdcp::enable_encryption(uint32_t lcid)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
pthread_rwlock_rdlock(&rwlock);
|
|
|
|
if (valid_lcid(lcid)) {
|
|
|
|
if (valid_lcid(lcid)) {
|
|
|
|
pdcp_array.at(lcid)->enable_encryption();
|
|
|
|
pdcp_array.at(lcid)->enable_encryption();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pthread_rwlock_unlock(&rwlock);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
/*******************************************************************************
|
|
|
@ -211,18 +231,21 @@ 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)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
pthread_rwlock_rdlock(&rwlock);
|
|
|
|
if (valid_lcid(lcid)) {
|
|
|
|
if (valid_lcid(lcid)) {
|
|
|
|
pdcp_array.at(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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pthread_rwlock_unlock(&rwlock);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void pdcp::write_pdu_bcch_bch(byte_buffer_t *sdu)
|
|
|
|
void pdcp::write_pdu_bcch_bch(byte_buffer_t *sdu)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
rrc->write_pdu_bcch_bch(sdu);
|
|
|
|
rrc->write_pdu_bcch_bch(sdu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void pdcp::write_pdu_bcch_dlsch(byte_buffer_t *sdu)
|
|
|
|
void pdcp::write_pdu_bcch_dlsch(byte_buffer_t *sdu)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
rrc->write_pdu_bcch_dlsch(sdu);
|
|
|
|
rrc->write_pdu_bcch_dlsch(sdu);
|
|
|
@ -243,7 +266,7 @@ void pdcp::write_pdu_mch(uint32_t lcid, byte_buffer_t *sdu)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
/*******************************************************************************
|
|
|
|
Helpers
|
|
|
|
Helpers (Lock must be hold when calling those)
|
|
|
|
*******************************************************************************/
|
|
|
|
*******************************************************************************/
|
|
|
|
bool pdcp::valid_lcid(uint32_t lcid)
|
|
|
|
bool pdcp::valid_lcid(uint32_t lcid)
|
|
|
|
{
|
|
|
|
{
|
|
|
|