|
|
|
@ -14,140 +14,172 @@
|
|
|
|
|
|
|
|
|
|
namespace srsran {
|
|
|
|
|
|
|
|
|
|
bearer_manager::bearer_manager() : logger(srslog::fetch_basic_logger("STCK", false))
|
|
|
|
|
namespace detail {
|
|
|
|
|
|
|
|
|
|
const ue_bearer_manager_impl::radio_bearer_t ue_bearer_manager_impl::invalid_rb{srsran::srsran_rat_t::nulltype, 0, 0};
|
|
|
|
|
|
|
|
|
|
bool ue_bearer_manager_impl::add_eps_bearer(uint8_t eps_bearer_id, srsran::srsran_rat_t rat, uint32_t lcid)
|
|
|
|
|
{
|
|
|
|
|
pthread_rwlock_init(&rwlock, nullptr);
|
|
|
|
|
auto bearer_it = bearers.find(eps_bearer_id);
|
|
|
|
|
if (bearer_it != bearers.end()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
bearers.emplace(eps_bearer_id, radio_bearer_t{rat, lcid, eps_bearer_id});
|
|
|
|
|
lcid_to_eps_bearer_id.emplace(lcid, eps_bearer_id);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bearer_manager::~bearer_manager()
|
|
|
|
|
bool ue_bearer_manager_impl::remove_eps_bearer(uint8_t eps_bearer_id)
|
|
|
|
|
{
|
|
|
|
|
pthread_rwlock_destroy(&rwlock);
|
|
|
|
|
auto bearer_it = bearers.find(eps_bearer_id);
|
|
|
|
|
if (bearer_it == bearers.end()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
uint32_t lcid = bearer_it->second.lcid;
|
|
|
|
|
bearers.erase(bearer_it);
|
|
|
|
|
lcid_to_eps_bearer_id.erase(lcid);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void bearer_manager::add_eps_bearer(uint8_t eps_bearer_id, srsran::srsran_rat_t rat, uint32_t lcid)
|
|
|
|
|
void ue_bearer_manager_impl::reset()
|
|
|
|
|
{
|
|
|
|
|
add_eps_bearer(default_key, eps_bearer_id, rat, lcid);
|
|
|
|
|
lcid_to_eps_bearer_id.clear();
|
|
|
|
|
bearers.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void bearer_manager::add_eps_bearer(uint16_t rnti, uint8_t eps_bearer_id, srsran::srsran_rat_t rat, uint32_t lcid)
|
|
|
|
|
bool ue_bearer_manager_impl::has_active_radio_bearer(uint32_t eps_bearer_id)
|
|
|
|
|
{
|
|
|
|
|
srsran::rwlock_write_guard rw_lock(rwlock);
|
|
|
|
|
auto user_it = users_map.find(rnti);
|
|
|
|
|
if (user_it == users_map.end()) {
|
|
|
|
|
// add empty bearer map
|
|
|
|
|
auto p = users_map.emplace(rnti, user_bearers{});
|
|
|
|
|
user_it = p.first;
|
|
|
|
|
return bearers.count(eps_bearer_id) > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto bearer_it = user_it->second.bearers.find(eps_bearer_id);
|
|
|
|
|
if (bearer_it != user_it->second.bearers.end()) {
|
|
|
|
|
logger.error("EPS bearer ID %d already registered", eps_bearer_id);
|
|
|
|
|
return;
|
|
|
|
|
ue_bearer_manager_impl::radio_bearer_t ue_bearer_manager_impl::get_radio_bearer(uint32_t eps_bearer_id)
|
|
|
|
|
{
|
|
|
|
|
auto it = bearers.find(eps_bearer_id);
|
|
|
|
|
return it != bearers.end() ? it->second : invalid_rb;
|
|
|
|
|
}
|
|
|
|
|
user_it->second.bearers.emplace(eps_bearer_id, radio_bearer_t{rat, lcid, eps_bearer_id});
|
|
|
|
|
user_it->second.lcid_to_eps_bearer_id.emplace(lcid, eps_bearer_id);
|
|
|
|
|
logger.info("Registered EPS bearer ID %d for lcid=%d over %s-PDCP", eps_bearer_id, lcid, to_string(rat).c_str());
|
|
|
|
|
|
|
|
|
|
ue_bearer_manager_impl::radio_bearer_t ue_bearer_manager_impl::get_lcid_bearer(uint32_t lcid)
|
|
|
|
|
{
|
|
|
|
|
auto lcid_it = lcid_to_eps_bearer_id.find(lcid);
|
|
|
|
|
return lcid_it != lcid_to_eps_bearer_id.end() ? bearers.at(lcid_it->second) : invalid_rb;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void bearer_manager::remove_eps_bearer(uint8_t eps_bearer_id)
|
|
|
|
|
} // namespace detail
|
|
|
|
|
} // namespace srsran
|
|
|
|
|
|
|
|
|
|
namespace srsue {
|
|
|
|
|
|
|
|
|
|
ue_bearer_manager::ue_bearer_manager() : logger(srslog::fetch_basic_logger("STCK", false))
|
|
|
|
|
{
|
|
|
|
|
remove_eps_bearer(default_key, eps_bearer_id);
|
|
|
|
|
pthread_rwlock_init(&rwlock, nullptr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void bearer_manager::remove_eps_bearer(uint16_t rnti, uint8_t eps_bearer_id)
|
|
|
|
|
ue_bearer_manager::~ue_bearer_manager()
|
|
|
|
|
{
|
|
|
|
|
srsran::rwlock_write_guard rw_lock(rwlock);
|
|
|
|
|
pthread_rwlock_destroy(&rwlock);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto user_it = users_map.find(rnti);
|
|
|
|
|
if (user_it == users_map.end()) {
|
|
|
|
|
logger.error("No EPS bearer registered for rnti=%x", rnti);
|
|
|
|
|
return;
|
|
|
|
|
void ue_bearer_manager::add_eps_bearer(uint8_t eps_bearer_id, srsran::srsran_rat_t rat, uint32_t lcid)
|
|
|
|
|
{
|
|
|
|
|
srsran::rwlock_write_guard rw_lock(rwlock);
|
|
|
|
|
if (impl.add_eps_bearer(eps_bearer_id, rat, lcid)) {
|
|
|
|
|
logger.info("Registered EPS bearer ID %d for lcid=%d over %s-PDCP", eps_bearer_id, lcid, to_string(rat).c_str());
|
|
|
|
|
} else {
|
|
|
|
|
logger.error("EPS bearer ID %d already registered", eps_bearer_id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto bearer_it = user_it->second.bearers.find(eps_bearer_id);
|
|
|
|
|
if (bearer_it == user_it->second.bearers.end()) {
|
|
|
|
|
void ue_bearer_manager::remove_eps_bearer(uint8_t eps_bearer_id)
|
|
|
|
|
{
|
|
|
|
|
srsran::rwlock_write_guard rw_lock(rwlock);
|
|
|
|
|
if (impl.remove_eps_bearer(eps_bearer_id)) {
|
|
|
|
|
logger.info("Removed mapping for EPS bearer ID %d", eps_bearer_id);
|
|
|
|
|
} else {
|
|
|
|
|
logger.error("Can't remove EPS bearer ID %d", eps_bearer_id);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
uint32_t lcid = bearer_it->second.lcid;
|
|
|
|
|
user_it->second.bearers.erase(bearer_it);
|
|
|
|
|
user_it->second.lcid_to_eps_bearer_id.erase(lcid);
|
|
|
|
|
logger.info("Removed mapping for EPS bearer ID %d", eps_bearer_id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void bearer_manager::reset()
|
|
|
|
|
void ue_bearer_manager::reset()
|
|
|
|
|
{
|
|
|
|
|
reset(default_key);
|
|
|
|
|
impl.reset();
|
|
|
|
|
logger.info("Reset EPS bearer manager");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void bearer_manager::reset(uint16_t rnti)
|
|
|
|
|
{
|
|
|
|
|
srsran::rwlock_write_guard rw_lock(rwlock);
|
|
|
|
|
} // namespace srsue
|
|
|
|
|
|
|
|
|
|
namespace srsenb {
|
|
|
|
|
|
|
|
|
|
enb_bearer_manager::enb_bearer_manager() : logger(srslog::fetch_basic_logger("STCK", false)) {}
|
|
|
|
|
|
|
|
|
|
void enb_bearer_manager::add_eps_bearer(uint16_t rnti, uint8_t eps_bearer_id, srsran::srsran_rat_t rat, uint32_t lcid)
|
|
|
|
|
{
|
|
|
|
|
auto user_it = users_map.find(rnti);
|
|
|
|
|
if (user_it == users_map.end()) {
|
|
|
|
|
logger.error("No EPS bearer registered for rnti=%x", rnti);
|
|
|
|
|
return;
|
|
|
|
|
// add empty bearer map
|
|
|
|
|
auto p = users_map.insert(rnti, srsran::detail::ue_bearer_manager_impl{});
|
|
|
|
|
user_it = p.value();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
user_it->second.lcid_to_eps_bearer_id.clear();
|
|
|
|
|
user_it->second.bearers.clear();
|
|
|
|
|
logger.info("Reset EPS bearer manager");
|
|
|
|
|
if (user_it->second.add_eps_bearer(eps_bearer_id, rat, lcid)) {
|
|
|
|
|
logger.info("Registered EPS bearer ID %d for rnti=0x%x, lcid=%d over %s-PDCP",
|
|
|
|
|
eps_bearer_id,
|
|
|
|
|
rnti,
|
|
|
|
|
lcid,
|
|
|
|
|
to_string(rat).c_str());
|
|
|
|
|
} else {
|
|
|
|
|
logger.error("EPS bearer ID %d for rnti=0x%x already registered", eps_bearer_id, rnti);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GW interface
|
|
|
|
|
bool bearer_manager::has_active_radio_bearer(uint32_t eps_bearer_id)
|
|
|
|
|
{
|
|
|
|
|
return has_active_radio_bearer(default_key, eps_bearer_id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool bearer_manager::has_active_radio_bearer(uint16_t rnti, uint32_t eps_bearer_id)
|
|
|
|
|
void enb_bearer_manager::remove_eps_bearer(uint16_t rnti, uint8_t eps_bearer_id)
|
|
|
|
|
{
|
|
|
|
|
srsran::rwlock_read_guard rw_lock(rwlock);
|
|
|
|
|
|
|
|
|
|
auto user_it = users_map.find(rnti);
|
|
|
|
|
if (user_it == users_map.end()) {
|
|
|
|
|
return false;
|
|
|
|
|
logger.error("No EPS bearer registered for rnti=0x%x", rnti);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return user_it->second.bearers.find(eps_bearer_id) != user_it->second.bearers.end();
|
|
|
|
|
if (user_it->second.remove_eps_bearer(eps_bearer_id)) {
|
|
|
|
|
logger.info("Removed mapping for EPS bearer ID %d for rnti=0x%x", eps_bearer_id, rnti);
|
|
|
|
|
} else {
|
|
|
|
|
logger.error("Can't remove EPS bearer ID %d, rnti=0x%x", eps_bearer_id, rnti);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Stack interface
|
|
|
|
|
bearer_manager::radio_bearer_t bearer_manager::get_radio_bearer(uint32_t eps_bearer_id)
|
|
|
|
|
void enb_bearer_manager::rem_user(uint16_t rnti)
|
|
|
|
|
{
|
|
|
|
|
return get_radio_bearer(default_key, eps_bearer_id);
|
|
|
|
|
if (users_map.erase(rnti)) {
|
|
|
|
|
logger.info("Removed rnti=0x%x from EPS bearer manager", rnti);
|
|
|
|
|
} else {
|
|
|
|
|
logger.error("No EPS bearer registered for rnti=0x%x", rnti);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bearer_manager::radio_bearer_t bearer_manager::get_lcid_bearer(uint16_t rnti, uint32_t lcid)
|
|
|
|
|
bool enb_bearer_manager::has_active_radio_bearer(uint16_t rnti, uint32_t eps_bearer_id)
|
|
|
|
|
{
|
|
|
|
|
srsran::rwlock_read_guard rw_lock(rwlock);
|
|
|
|
|
|
|
|
|
|
auto user_it = users_map.find(rnti);
|
|
|
|
|
if (user_it == users_map.end()) {
|
|
|
|
|
return invalid_rb;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto lcid_it = user_it->second.lcid_to_eps_bearer_id.find(lcid);
|
|
|
|
|
if (lcid_it != user_it->second.lcid_to_eps_bearer_id.end()) {
|
|
|
|
|
return user_it->second.bearers.at(lcid_it->second);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return invalid_rb;
|
|
|
|
|
return user_it->second.has_active_radio_bearer(eps_bearer_id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bearer_manager::radio_bearer_t bearer_manager::get_radio_bearer(uint16_t rnti, uint32_t eps_bearer_id)
|
|
|
|
|
enb_bearer_manager::radio_bearer_t enb_bearer_manager::get_lcid_bearer(uint16_t rnti, uint32_t lcid)
|
|
|
|
|
{
|
|
|
|
|
srsran::rwlock_read_guard rw_lock(rwlock);
|
|
|
|
|
|
|
|
|
|
auto user_it = users_map.find(rnti);
|
|
|
|
|
if (user_it == users_map.end()) {
|
|
|
|
|
return invalid_rb;
|
|
|
|
|
return srsran::detail::ue_bearer_manager_impl::invalid_rb;
|
|
|
|
|
}
|
|
|
|
|
return user_it->second.get_lcid_bearer(lcid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (user_it->second.bearers.find(eps_bearer_id) != user_it->second.bearers.end()) {
|
|
|
|
|
return user_it->second.bearers.at(eps_bearer_id);
|
|
|
|
|
enb_bearer_manager::radio_bearer_t enb_bearer_manager::get_radio_bearer(uint16_t rnti, uint32_t eps_bearer_id)
|
|
|
|
|
{
|
|
|
|
|
auto user_it = users_map.find(rnti);
|
|
|
|
|
if (user_it == users_map.end()) {
|
|
|
|
|
return srsran::detail::ue_bearer_manager_impl::invalid_rb;
|
|
|
|
|
}
|
|
|
|
|
return invalid_rb;
|
|
|
|
|
return user_it->second.get_radio_bearer(eps_bearer_id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace srsran
|
|
|
|
|
} // namespace srsenb
|