|
|
@ -14,140 +14,172 @@
|
|
|
|
|
|
|
|
|
|
|
|
namespace srsran {
|
|
|
|
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);
|
|
|
|
return bearers.count(eps_bearer_id) > 0;
|
|
|
|
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;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void bearer_manager::remove_eps_bearer(uint8_t eps_bearer_id)
|
|
|
|
ue_bearer_manager_impl::radio_bearer_t ue_bearer_manager_impl::get_radio_bearer(uint32_t eps_bearer_id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
remove_eps_bearer(default_key, eps_bearer_id);
|
|
|
|
auto it = bearers.find(eps_bearer_id);
|
|
|
|
|
|
|
|
return it != bearers.end() ? it->second : invalid_rb;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void bearer_manager::remove_eps_bearer(uint16_t rnti, uint8_t eps_bearer_id)
|
|
|
|
ue_bearer_manager_impl::radio_bearer_t ue_bearer_manager_impl::get_lcid_bearer(uint32_t lcid)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
srsran::rwlock_write_guard rw_lock(rwlock);
|
|
|
|
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;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
auto user_it = users_map.find(rnti);
|
|
|
|
} // namespace detail
|
|
|
|
if (user_it == users_map.end()) {
|
|
|
|
} // namespace srsran
|
|
|
|
logger.error("No EPS bearer registered for rnti=%x", rnti);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto bearer_it = user_it->second.bearers.find(eps_bearer_id);
|
|
|
|
namespace srsue {
|
|
|
|
if (bearer_it == user_it->second.bearers.end()) {
|
|
|
|
|
|
|
|
logger.error("Can't remove EPS bearer ID %d", eps_bearer_id);
|
|
|
|
ue_bearer_manager::ue_bearer_manager() : logger(srslog::fetch_basic_logger("STCK", false))
|
|
|
|
return;
|
|
|
|
{
|
|
|
|
}
|
|
|
|
pthread_rwlock_init(&rwlock, nullptr);
|
|
|
|
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()
|
|
|
|
ue_bearer_manager::~ue_bearer_manager()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
reset(default_key);
|
|
|
|
pthread_rwlock_destroy(&rwlock);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void bearer_manager::reset(uint16_t rnti)
|
|
|
|
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);
|
|
|
|
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 user_it = users_map.find(rnti);
|
|
|
|
void ue_bearer_manager::remove_eps_bearer(uint8_t eps_bearer_id)
|
|
|
|
if (user_it == users_map.end()) {
|
|
|
|
{
|
|
|
|
logger.error("No EPS bearer registered for rnti=%x", rnti);
|
|
|
|
srsran::rwlock_write_guard rw_lock(rwlock);
|
|
|
|
return;
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
user_it->second.lcid_to_eps_bearer_id.clear();
|
|
|
|
void ue_bearer_manager::reset()
|
|
|
|
user_it->second.bearers.clear();
|
|
|
|
{
|
|
|
|
|
|
|
|
impl.reset();
|
|
|
|
logger.info("Reset EPS bearer manager");
|
|
|
|
logger.info("Reset EPS bearer manager");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// GW interface
|
|
|
|
} // namespace srsue
|
|
|
|
bool bearer_manager::has_active_radio_bearer(uint32_t eps_bearer_id)
|
|
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return has_active_radio_bearer(default_key, eps_bearer_id);
|
|
|
|
auto user_it = users_map.find(rnti);
|
|
|
|
|
|
|
|
if (user_it == users_map.end()) {
|
|
|
|
|
|
|
|
// add empty bearer map
|
|
|
|
|
|
|
|
auto p = users_map.insert(rnti, srsran::detail::ue_bearer_manager_impl{});
|
|
|
|
|
|
|
|
user_it = p.value();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
auto user_it = users_map.find(rnti);
|
|
|
|
if (user_it == users_map.end()) {
|
|
|
|
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
|
|
|
|
void enb_bearer_manager::rem_user(uint16_t rnti)
|
|
|
|
bearer_manager::radio_bearer_t bearer_manager::get_radio_bearer(uint32_t eps_bearer_id)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
auto user_it = users_map.find(rnti);
|
|
|
|
if (user_it == users_map.end()) {
|
|
|
|
if (user_it == users_map.end()) {
|
|
|
|
return invalid_rb;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 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);
|
|
|
|
auto user_it = users_map.find(rnti);
|
|
|
|
if (user_it == users_map.end()) {
|
|
|
|
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()) {
|
|
|
|
enb_bearer_manager::radio_bearer_t enb_bearer_manager::get_radio_bearer(uint16_t rnti, uint32_t eps_bearer_id)
|
|
|
|
return user_it->second.bearers.at(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
|