diff --git a/srsgnb/hdr/stack/ric/e2ap.h b/srsgnb/hdr/stack/ric/e2ap.h index 83074787b..d38b0474d 100644 --- a/srsgnb/hdr/stack/ric/e2ap.h +++ b/srsgnb/hdr/stack/ric/e2ap.h @@ -52,7 +52,7 @@ public: int process_setup_failure(); int process_subscription_request(ricsubscription_request_s subscription_request); e2_ap_pdu_c generate_subscription_response(ric_subscription_reponse_t ric_subscription_reponse); - int generate_subscription_failure(); + e2_ap_pdu_c generate_subscription_failure(ric_subscription_reponse_t ric_subscription_reponse); e2_ap_pdu_c generate_subscription_delete_response(uint32_t ric_requestor_id, uint32_t ric_instance_id, uint32_t ra_nfunction_id); e2_ap_pdu_c generate_indication(ric_indication_t& ric_indication); diff --git a/srsgnb/hdr/stack/ric/ric_subscription.h b/srsgnb/hdr/stack/ric/ric_subscription.h index 49b3ea6c0..a9bd4bf35 100644 --- a/srsgnb/hdr/stack/ric/ric_subscription.h +++ b/srsgnb/hdr/stack/ric/ric_subscription.h @@ -30,14 +30,17 @@ public: uint32_t get_ric_requestor_id() { return ric_requestor_id; }; uint32_t get_ric_instance_id() { return ric_instance_id; }; + bool is_initialized() { return initialized; }; void start_subscription(); + void send_subscription_failure(); void delete_subscription(); private: void send_ric_indication(); - ric_client* parent = nullptr; + ric_client* parent = nullptr; + bool initialized = false; uint32_t ric_requestor_id; uint32_t ric_instance_id; diff --git a/srsgnb/src/stack/ric/e2ap.cc b/srsgnb/src/stack/ric/e2ap.cc index 7f3e0b723..6cd388d4b 100644 --- a/srsgnb/src/stack/ric/e2ap.cc +++ b/srsgnb/src/stack/ric/e2ap.cc @@ -115,6 +115,29 @@ e2_ap_pdu_c e2ap::generate_subscription_response(ric_subscription_reponse_t ric_ return pdu; } +e2_ap_pdu_c e2ap::generate_subscription_failure(ric_subscription_reponse_t ric_subscription_reponse) +{ + e2_ap_pdu_c pdu; + unsuccessful_outcome_s& failure = pdu.set_unsuccessful_outcome(); + failure.load_info_obj(ASN1_E2AP_ID_RICSUBSCRIPTION); + failure.crit = asn1::crit_opts::reject; + ricsubscription_fail_s& sub_resp = failure.value.ricsubscription_fail(); + + sub_resp->ri_crequest_id.crit = asn1::crit_opts::reject; + sub_resp->ri_crequest_id.id = ASN1_E2AP_ID_RI_CREQUEST_ID; + sub_resp->ri_crequest_id.value.ric_requestor_id = ric_subscription_reponse.ric_requestor_id; + sub_resp->ri_crequest_id.value.ric_instance_id = ric_subscription_reponse.ric_instance_id; + + sub_resp->ra_nfunction_id.crit = asn1::crit_opts::reject; + sub_resp->ra_nfunction_id.id = ASN1_E2AP_ID_RA_NFUNCTION_ID; + sub_resp->ra_nfunction_id->value = ric_subscription_reponse.ra_nfunction_id; + + sub_resp->cause->set_misc(); // TODO: set the cause and crit_diagnostics properly + sub_resp->crit_diagnostics_present = false; + + return pdu; +} + e2_ap_pdu_c e2ap::generate_subscription_delete_response(uint32_t ric_requestor_id, uint32_t ric_instance_id, uint32_t ra_nfunction_id) diff --git a/srsgnb/src/stack/ric/ric_client.cc b/srsgnb/src/stack/ric/ric_client.cc index 8765d0111..b0a5de1db 100644 --- a/srsgnb/src/stack/ric/ric_client.cc +++ b/srsgnb/src/stack/ric/ric_client.cc @@ -272,8 +272,15 @@ bool ric_client::handle_ric_subscription_request(ricsubscription_request_s ric_s std::unique_ptr new_ric_subs = std::make_unique(this, ric_subscription_request); - new_ric_subs->start_subscription(); - active_subscriptions.push_back(std::move(new_ric_subs)); + + if (new_ric_subs->is_initialized()) { + new_ric_subs->start_subscription(); + active_subscriptions.push_back(std::move(new_ric_subs)); + } else { + new_ric_subs->send_subscription_failure(); + return false; + } + return true; } diff --git a/srsgnb/src/stack/ric/ric_subscription.cc b/srsgnb/src/stack/ric/ric_subscription.cc index 7cc1eb250..7d19b4eb4 100644 --- a/srsgnb/src/stack/ric/ric_subscription.cc +++ b/srsgnb/src/stack/ric/ric_subscription.cc @@ -18,6 +18,7 @@ namespace srsenb { ric_client::ric_subscription::ric_subscription(ric_client* ric_client, ricsubscription_request_s ric_subscription_request) : parent(ric_client), + initialized(false), ric_requestor_id(ric_subscription_request->ri_crequest_id->ric_requestor_id), ric_instance_id(ric_subscription_request->ri_crequest_id->ric_instance_id), ra_nfunction_id(ric_subscription_request->ra_nfunction_id->value), @@ -77,6 +78,7 @@ ric_client::ric_subscription::ric_subscription(ric_client* ric_cli not_admitted_actions.push_back(action_item.ric_action_id); } } + initialized = true; } void ric_client::ric_subscription::start_subscription() @@ -106,6 +108,18 @@ void ric_client::ric_subscription::start_subscription() } } +void ric_client::ric_subscription::send_subscription_failure() +{ + parent->logger.debug("Send RIC Subscription Failure Response to RIC Requestor ID: %i\n", ric_requestor_id); + ric_subscription_reponse_t ric_subscription_reponse; + ric_subscription_reponse.ric_requestor_id = ric_requestor_id; + ric_subscription_reponse.ric_instance_id = ric_instance_id; + ric_subscription_reponse.ra_nfunction_id = ra_nfunction_id; + + e2_ap_pdu_c send_pdu = parent->e2ap_.generate_subscription_failure(ric_subscription_reponse); + parent->queue_send_e2ap_pdu(send_pdu); +} + void ric_client::ric_subscription::delete_subscription() { if (reporting_timer.is_running()) {