@@ -225,6 +225,7 @@ void ngap_impl::handle_dl_nas_transport_message(const asn1::ngap::dl_nas_transpo
225225 ue_index,
226226 msg->ran_ue_ngap_id ,
227227 msg->amf_ue_ngap_id );
228+ send_error_indication (ue_index, cause_radio_network_t ::unknown_local_ue_ngap_id);
228229 return ;
229230 }
230231
@@ -234,6 +235,7 @@ void ngap_impl::handle_dl_nas_transport_message(const asn1::ngap::dl_nas_transpo
234235 ue_index,
235236 msg->ran_ue_ngap_id ,
236237 msg->amf_ue_ngap_id );
238+ send_error_indication (ue_index, cause_radio_network_t ::unknown_local_ue_ngap_id);
237239 return ;
238240 }
239241
@@ -262,6 +264,7 @@ void ngap_impl::handle_initial_context_setup_request(const asn1::ngap::init_cont
262264 auto * ue = ue_manager.find_ngap_ue (ue_index);
263265 if (ue == nullptr ) {
264266 logger.warning (" ue={}: Dropping InitialContextSetupRequest. UE does not exist" , ue_index);
267+ send_error_indication (ue_index, cause_radio_network_t ::unknown_local_ue_ngap_id);
265268 return ;
266269 }
267270
@@ -288,6 +291,7 @@ void ngap_impl::handle_pdu_session_resource_setup_request(const asn1::ngap::pdu_
288291 ue_index,
289292 request->ran_ue_ngap_id ,
290293 request->amf_ue_ngap_id );
294+ send_error_indication (ue_index, cause_radio_network_t ::unknown_local_ue_ngap_id);
291295 return ;
292296 }
293297
@@ -297,6 +301,7 @@ void ngap_impl::handle_pdu_session_resource_setup_request(const asn1::ngap::pdu_
297301 ue_index,
298302 request->ran_ue_ngap_id ,
299303 request->amf_ue_ngap_id );
304+ send_error_indication (ue_index);
300305 return ;
301306 }
302307
@@ -319,6 +324,7 @@ void ngap_impl::handle_pdu_session_resource_setup_request(const asn1::ngap::pdu_
319324 ue_index,
320325 ue->get_ran_ue_id (),
321326 ue->get_amf_ue_id ());
327+ send_error_indication (ue_index);
322328 return ;
323329 }
324330 msg.ue_aggregate_maximum_bit_rate_dl = ue->get_aggregate_maximum_bit_rate_dl ();
@@ -339,6 +345,7 @@ void ngap_impl::handle_pdu_session_resource_modify_request(const asn1::ngap::pdu
339345 ue_index,
340346 request->ran_ue_ngap_id ,
341347 request->amf_ue_ngap_id );
348+ send_error_indication (ue_index, cause_radio_network_t ::unknown_local_ue_ngap_id);
342349 return ;
343350 }
344351
@@ -371,6 +378,7 @@ void ngap_impl::handle_pdu_session_resource_release_command(const asn1::ngap::pd
371378 ue_index,
372379 command->ran_ue_ngap_id ,
373380 command->amf_ue_ngap_id );
381+ send_error_indication (ue_index, cause_radio_network_t ::unknown_local_ue_ngap_id);
374382 return ;
375383 }
376384
@@ -420,6 +428,7 @@ void ngap_impl::handle_ue_context_release_command(const asn1::ngap::ue_context_r
420428 ue_index,
421429 ran_ue_id == ran_ue_id_t ::invalid ? " " : fmt::format (" ran_ue_id={}" , ran_ue_id),
422430 amf_ue_id);
431+ send_error_indication (ue_index, cause_radio_network_t ::unknown_local_ue_ngap_id);
423432 return ;
424433 }
425434
@@ -454,6 +463,7 @@ void ngap_impl::handle_paging(const asn1::ngap::paging_s& msg)
454463
455464 if (msg->ue_paging_id .type () != asn1::ngap::ue_paging_id_c::types::five_g_s_tmsi) {
456465 logger.error (" Dropping PDU. Unsupportet UE Paging ID" );
466+ send_error_indication ();
457467 return ;
458468 }
459469
@@ -533,6 +543,7 @@ void ngap_impl::handle_error_indication(const asn1::ngap::error_ind_s& msg)
533543 ue_index,
534544 msg->ran_ue_ngap_id_present ? fmt::format (" ran_ue_id={}" , msg->ran_ue_ngap_id ) : " " ,
535545 msg->amf_ue_ngap_id_present ? fmt::format (" amf_ue_id={}" , msg->amf_ue_ngap_id ) : " " );
546+ send_error_indication (ue_index, cause);
536547 return ;
537548 } else {
538549 std::string msg_cause = " " ;
@@ -686,3 +697,38 @@ size_t ngap_impl::get_nof_ues() const
686697{
687698 return ue_manager.get_nof_ngap_ues ();
688699}
700+
701+ void ngap_impl::send_error_indication (ue_index_t ue_index, optional<cause_t > cause)
702+ {
703+ ngap_message ngap_msg = {};
704+ ngap_msg.pdu .set_init_msg ();
705+ ngap_msg.pdu .init_msg ().load_info_obj (ASN1_NGAP_ID_ERROR_IND);
706+ auto & error_ind = ngap_msg.pdu .init_msg ().value .error_ind ();
707+
708+ if (ue_index != ue_index_t ::invalid) {
709+ auto * ue = ue_manager.find_ngap_ue (ue_index);
710+ if (ue != nullptr ) {
711+ error_ind->ran_ue_ngap_id_present = true ;
712+ error_ind->ran_ue_ngap_id = ran_ue_id_to_uint (ue->get_ran_ue_id ());
713+
714+ if (ue->get_amf_ue_id () != amf_ue_id_t ::invalid) {
715+ error_ind->amf_ue_ngap_id_present = true ;
716+ error_ind->amf_ue_ngap_id = amf_ue_id_to_uint (ue->get_amf_ue_id ());
717+ }
718+ }
719+ }
720+
721+ if (cause.has_value ()) {
722+ error_ind->cause_present = true ;
723+ error_ind->cause = cause_to_asn1 (cause.value ());
724+ }
725+
726+ // TODO: Add missing values
727+
728+ // Forward message to AMF
729+ logger.info (" {}{}{}: Sending ErrorIndication" ,
730+ ue_index != ue_index_t ::invalid ? fmt::format (" ue={}" , ue_index) : " " ,
731+ error_ind->ran_ue_ngap_id_present ? fmt::format (" ran_ue_id={}" , error_ind->ran_ue_ngap_id ) : " " ,
732+ error_ind->amf_ue_ngap_id_present ? fmt::format (" amf_ue_id={}" , error_ind->amf_ue_ngap_id ) : " " );
733+ ngap_notifier.on_new_message (ngap_msg);
734+ }
0 commit comments