@@ -233,8 +233,26 @@ int bearer_cfg_handler::add_erab(uint8_t
233233 cause.set_radio_network ().value = asn1::s1ap::cause_radio_network_opts::unknown_erab_id;
234234 return SRSRAN_ERROR;
235235 }
236- uint8_t lcid = erab_id - 2 ; // Map e.g. E-RAB 5 to LCID 3 (==DRB1)
237- uint8_t drbid = erab_id - 4 ;
236+
237+ uint8_t lcid = 3 ; // first E-RAB with DRB1 gets LCID3
238+ for (const auto & drb : current_drbs) {
239+ if (drb.lc_ch_id == lcid) {
240+ lcid++;
241+ }
242+ }
243+ if (lcid > srsran::MAX_LTE_LCID) {
244+ logger->error (" Can't allocate LCID for ERAB id=%d" , erab_id);
245+ cause.set_radio_network ().value = asn1::s1ap::cause_radio_network_opts::radio_res_not_available;
246+ return SRSRAN_ERROR;
247+ }
248+
249+ // We currently have this static mapping between LCID->DRB ID
250+ uint8_t drbid = lcid - 2 ;
251+ if (drbid > srsran::MAX_LTE_DRB_ID) {
252+ logger->error (" Can't allocate DRB ID for ERAB id=%d" , erab_id);
253+ cause.set_radio_network ().value = asn1::s1ap::cause_radio_network_opts::radio_res_not_available;
254+ return SRSRAN_ERROR;
255+ }
238256
239257 auto qci_it = cfg->qci_cfg .find (qos.qci );
240258 if (qci_it == cfg->qci_cfg .end () or not qci_it->second .configured ) {
@@ -250,6 +268,7 @@ int bearer_cfg_handler::add_erab(uint8_t
250268 const rrc_cfg_qci_t & qci_cfg = qci_it->second ;
251269
252270 erabs[erab_id].id = erab_id;
271+ erabs[erab_id].lcid = lcid;
253272 erabs[erab_id].qos_params = qos;
254273 erabs[erab_id].address = addr;
255274 erabs[erab_id].teid_out = teid_out;
@@ -385,7 +404,7 @@ srsran::expected<uint32_t> bearer_cfg_handler::add_gtpu_bearer(uint32_t
385404 erab_t ::gtpu_tunnel bearer;
386405 bearer.teid_out = teid_out;
387406 bearer.addr = addr;
388- srsran::expected<uint32_t > teidin = gtpu->add_bearer (rnti, erab.id - 2 , addr, teid_out, props);
407+ srsran::expected<uint32_t > teidin = gtpu->add_bearer (rnti, erab.lcid , addr, teid_out, props);
389408 if (teidin.is_error ()) {
390409 logger->error (" Adding erab_id=%d to GTPU" , erab_id);
391410 return srsran::default_error_t ();
@@ -397,7 +416,12 @@ srsran::expected<uint32_t> bearer_cfg_handler::add_gtpu_bearer(uint32_t
397416
398417void bearer_cfg_handler::rem_gtpu_bearer (uint32_t erab_id)
399418{
400- gtpu->rem_bearer (rnti, erab_id - 2 );
419+ auto it = erabs.find (erab_id);
420+ if (it == erabs.end ()) {
421+ logger->error (" Removing erab_id=%d from GTPU" , erab_id);
422+ return ;
423+ }
424+ gtpu->rem_bearer (rnti, it->second .lcid );
401425}
402426
403427void bearer_cfg_handler::fill_pending_nas_info (asn1::rrc::rrc_conn_recfg_r8_ies_s* msg)
0 commit comments