From 192508e6ccfb698a65387eaf916920a7d2781f66 Mon Sep 17 00:00:00 2001 From: Rakesh Mundlamuri Date: Fri, 23 Jan 2026 19:09:42 +0530 Subject: [PATCH] Add Positioning Activation Response NRPPA message encoding procedures --- openair2/COMMON/nrppa_messages_def.h | 4 ++ openair2/COMMON/nrppa_messages_types.h | 6 ++ openair3/NRPPA/nrppa_gNB.c | 3 + .../nrppa_gNB_location_information_transfer.c | 65 +++++++++++++++++++ .../nrppa_gNB_location_information_transfer.h | 1 + tests/nr-cu-nrppa/nr-cu-nrppa.c | 10 +++ 6 files changed, 89 insertions(+) diff --git a/openair2/COMMON/nrppa_messages_def.h b/openair2/COMMON/nrppa_messages_def.h index bb5d534856..d8090ab4a4 100644 --- a/openair2/COMMON/nrppa_messages_def.h +++ b/openair2/COMMON/nrppa_messages_def.h @@ -36,3 +36,7 @@ MESSAGE_DEF(NRPPA_POSITIONING_ACTIVATION_REQ, MESSAGE_PRIORITY_MED, nrppa_positioning_activation_req_t, nrppa_positioning_activation_req) +MESSAGE_DEF(NRPPA_POSITIONING_ACTIVATION_RESP, + MESSAGE_PRIORITY_MED, + nrppa_positioning_activation_resp_t, + nrppa_positioning_activation_resp) diff --git a/openair2/COMMON/nrppa_messages_types.h b/openair2/COMMON/nrppa_messages_types.h index 077c5a89b0..21f74288f5 100644 --- a/openair2/COMMON/nrppa_messages_types.h +++ b/openair2/COMMON/nrppa_messages_types.h @@ -29,6 +29,7 @@ #define NRPPA_POSITIONING_INFORMATION_REQ(mSGpTR) (mSGpTR)->ittiMsg.nrppa_positioning_information_req #define NRPPA_POSITIONING_INFORMATION_RESP(mSGpTR) (mSGpTR)->ittiMsg.nrppa_positioning_information_resp #define NRPPA_POSITIONING_ACTIVATION_REQ(mSGpTR) (mSGpTR)->ittiMsg.nrppa_positioning_activation_req +#define NRPPA_POSITIONING_ACTIVATION_RESP(mSGpTR) (mSGpTR)->ittiMsg.nrppa_positioning_activation_resp /* Structure of Positioning related NRPPA messages */ /* IE structures for Positioning related messages as per TS 38.455 V16.7.1*/ @@ -623,4 +624,9 @@ typedef struct nrppa_positioning_activation_req_s { nrppa_srs_type_t srs_type; } nrppa_positioning_activation_req_t; +typedef struct nrppa_positioning_activation_resp_s { + // IE 9.2.4 (mandatory) + uint16_t transaction_id; +} nrppa_positioning_activation_resp_t; + #endif // NRPPA_MESSAGES_TYPES_H_ diff --git a/openair3/NRPPA/nrppa_gNB.c b/openair3/NRPPA/nrppa_gNB.c index 19e76bc392..0da07e018e 100644 --- a/openair3/NRPPA/nrppa_gNB.c +++ b/openair3/NRPPA/nrppa_gNB.c @@ -63,6 +63,9 @@ void *nrppa_gNB_process_itti_msg(void *notUsed) case NRPPA_POSITIONING_INFORMATION_RESP: nrppa_gNB_positioning_information_response(instance, received_msg); break; + case NRPPA_POSITIONING_ACTIVATION_RESP: + nrppa_gNB_positioning_activation_response(instance, received_msg); + break; default: LOG_E(NRPPA, "Received unhandled message: %d:%s\n", ITTI_MSG_ID(received_msg), ITTI_MSG_NAME(received_msg)); break; diff --git a/openair3/NRPPA/nrppa_gNB_location_information_transfer.c b/openair3/NRPPA/nrppa_gNB_location_information_transfer.c index dfaa7f1efc..2bc0d9d9bc 100644 --- a/openair3/NRPPA/nrppa_gNB_location_information_transfer.c +++ b/openair3/NRPPA/nrppa_gNB_location_information_transfer.c @@ -1312,3 +1312,68 @@ int nrppa_gNB_handle_positioning_activation_request(nrppa_gnb_ue_info_t *nrppa_m ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_NRPPA_NRPPA_PDU, &pdu); return 0; } + +int nrppa_gNB_positioning_activation_response(instance_t instance, MessageDef *msg_p) +{ + DevAssert(msg_p); + nrppa_positioning_activation_resp_t *resp = &NRPPA_POSITIONING_ACTIVATION_RESP(msg_p); + nrppa_gNB_ue_context_t *ue_info = nrppa_detach_ue_context(resp->transaction_id); + + if (ue_info->gNB_ue_ngap_id <= 0 && ue_info->amf_ue_ngap_id <= 0) { + LOG_E(NRPPA, "Illegal gNB_ue_ngap_id %d and amf_ue_ngap_id %ld\n", ue_info->gNB_ue_ngap_id, ue_info->amf_ue_ngap_id); + nrppa_free_ue_context(ue_info); + return -1; + } + + LOG_I(NRPPA, + "Received PositioningInformationResponse info from RRC with transaction_id=%u and gNB_ue_ngap_id %u\n", + ue_info->transaction_id, + ue_info->gNB_ue_ngap_id); + + // Prepare NRPPA TRP Information transfer Response + NRPPA_NRPPA_PDU_t pdu = {0}; + + // IE: 9.2.3 Message Type : mandatory + pdu.present = NRPPA_NRPPA_PDU_PR_successfulOutcome; + asn1cCalloc(pdu.choice.successfulOutcome, head); + head->procedureCode = NRPPA_ProcedureCode_id_positioningActivation; + head->criticality = NRPPA_Criticality_reject; + head->value.present = NRPPA_SuccessfulOutcome__value_PR_PositioningActivationResponse; + + // IE 9.2.4 nrppatransactionID : mandatory + head->nrppatransactionID = resp->transaction_id; + + LOG_I(NRPPA, "Calling encoder for PositioningActivationResponse \n"); + + if (LOG_DEBUGFLAG(DEBUG_ASN1)) { + xer_fprint(stdout, &asn_DEF_NRPPA_NRPPA_PDU, &pdu); + } + + // Encode NRPPA message + uint8_t *buffer = NULL; + uint32_t length = 0; + if (nrppa_gNB_encode_pdu(&pdu, &buffer, &length) < 0) { + LOG_E(NRPPA, "Failed to encode Uplink NRPPa PositioningActivationResponse\n"); + nrppa_free_ue_context(ue_info); + ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_NRPPA_NRPPA_PDU, &pdu); + return -1; + } + + MessageDef *msg = itti_alloc_new_message(TASK_NRPPA, 0, NGAP_UPLINKUEASSOCIATEDNRPPA); + ngap_uplink_ue_associated_nrppa_t *ULNRPPA = &NGAP_UPLINKUEASSOCIATEDNRPPA(msg); + + ULNRPPA->gNB_ue_ngap_id = ue_info->gNB_ue_ngap_id; + ULNRPPA->amf_ue_ngap_id = ue_info->amf_ue_ngap_id; + + // Routing ID + ULNRPPA->routing_id = create_byte_array(ue_info->routing_id.len, ue_info->routing_id.buf); + + // NRPPA PDU + ULNRPPA->nrppa_pdu = create_byte_array(length, buffer); + + // Forward the NRPPA PDU to NGAP + itti_send_msg_to_task(TASK_NGAP, instance, msg); + nrppa_free_ue_context(ue_info); + free(buffer); + return length; +} diff --git a/openair3/NRPPA/nrppa_gNB_location_information_transfer.h b/openair3/NRPPA/nrppa_gNB_location_information_transfer.h index d86c7b2744..dc64738dfd 100644 --- a/openair3/NRPPA/nrppa_gNB_location_information_transfer.h +++ b/openair3/NRPPA/nrppa_gNB_location_information_transfer.h @@ -35,5 +35,6 @@ void free_positioning_information_response(nrppa_positioning_information_resp_t int nrppa_gNB_handle_positioning_activation_request(nrppa_gnb_ue_info_t *nrppa_msg_info, const NRPPA_NRPPA_PDU_t *pdu); void decode_nrppa_srstype(NRPPA_SRSType_t *srs_type, nrppa_srs_type_t *out); void free_positioning_activation_request(nrppa_positioning_activation_req_t *msg); +int nrppa_gNB_positioning_activation_response(instance_t instance, MessageDef *msg_p); #endif /* NRPPA_GNB_POSITIONING_PROCEDURES_H_ */ diff --git a/tests/nr-cu-nrppa/nr-cu-nrppa.c b/tests/nr-cu-nrppa/nr-cu-nrppa.c index ca47199133..0edd0842f4 100644 --- a/tests/nr-cu-nrppa/nr-cu-nrppa.c +++ b/tests/nr-cu-nrppa/nr-cu-nrppa.c @@ -31,6 +31,7 @@ #include "openair3/NRPPA/nrppa_gNB.h" #include "openair3/NAS/NR_UE/nr_nas_msg.h" #include "executables/nr-uesoftmodem.h" +#include "openair3/NRPPA/nrppa_gNB_location_information_transfer.c" RAN_CONTEXT_t RC; THREAD_STRUCT thread_struct; @@ -579,6 +580,15 @@ void *rrc_gnb_task(void *args_p) LOG_I(NR_RRC, "Sending NRPPA_POSITIONING_INFORMATION_RESP to TASK_NRPPA\n"); itti_send_msg_to_task(TASK_NRPPA, 0, msg_p_resp); break; + case NRPPA_POSITIONING_ACTIVATION_REQ: + nrppa_positioning_activation_req_t *req = &NRPPA_POSITIONING_ACTIVATION_REQ(msg_p); + LOG_I(NR_RRC, "Received NRPPA_POSITIONING_ACTIVATION_REQ transaction_id %d\n", req->transaction_id); + msg_p_resp = itti_alloc_new_message(TASK_RRC_GNB, 0, NRPPA_POSITIONING_ACTIVATION_RESP); + NRPPA_POSITIONING_ACTIVATION_RESP(msg_p_resp).transaction_id = req->transaction_id; + LOG_I(NR_RRC, "Sending NRPPA_POSITIONING_ACTIVATION_RESP to TASK_NRPPA\n"); + itti_send_msg_to_task(TASK_NRPPA, 0, msg_p_resp); + free_positioning_activation_request(req); + break; default: LOG_E(NR_RRC, "[gNB %ld] Received unexpected message %s\n", instance, msg_name_p); break;