Commit c2c84a93 authored by yaojie's avatar yaojie

Add Downlink(NAS Identity Request)/Uplink(NAS Identity Response)

parent b6e038e0
......@@ -424,6 +424,8 @@ typedef struct gNB_RRC_INST_s {
int Nb_ue;
hash_table_t *initial_id2_s1ap_ids; // key is content is rrc_ue_s1ap_ids_t
hash_table_t *s1ap_id2_s1ap_ids ; // key is content is rrc_ue_s1ap_ids_t
hash_table_t *initial_id2_ngap_ids;
hash_table_t *ngap_id2_ngap_ids ;
// other PLMN parameters
/// Mobile country code
......
......@@ -293,6 +293,8 @@ char openair_rrc_gNB_configuration(const module_id_t gnb_mod_idP, gNB_RrcConfigu
RB_INIT(&rrc->rrc_ue_head);
rrc->initial_id2_s1ap_ids = hashtable_create (NUMBER_OF_UE_MAX * 2, NULL, NULL);
rrc->s1ap_id2_s1ap_ids = hashtable_create (NUMBER_OF_UE_MAX * 2, NULL, NULL);
rrc->initial_id2_ngap_ids = hashtable_create (NUMBER_OF_UE_MAX * 2, NULL, NULL);
rrc->ngap_id2_ngap_ids = hashtable_create (NUMBER_OF_UE_MAX * 2, NULL, NULL);
rrc->carrier.servingcellconfigcommon = configuration->scc;
rrc->carrier.ssb_SubcarrierOffset = configuration->ssb_SubcarrierOffset;
rrc->carrier.pdsch_AntennaPorts = configuration->pdsch_AntennaPorts;
......@@ -1092,6 +1094,34 @@ rrc_gNB_decode_dcch(
ue_context_p->ue_context.ue_release_timer = 0;
break;
case NR_UL_DCCH_MessageType__c1_PR_ulInformationTransfer:
LOG_I(NR_RRC,"Recived RRC GNB UL Information Transfer \n");
if(!ue_context_p) {
LOG_I(NR_RRC, "Processing ulInformationTransfer UE %x, ue_context_p is NULL\n", ctxt_pP->rnti);
break;
}
LOG_D(NR_RRC,"[MSG] RRC UL Information Transfer \n");
LOG_DUMPMSG(RRC,DEBUG_RRC,(char *)Rx_sdu,sdu_sizeP,
"[MSG] RRC UL Information Transfer \n");
MSC_LOG_RX_MESSAGE(
MSC_RRC_GNB,
MSC_RRC_UE,
Rx_sdu,
sdu_sizeP,
MSC_AS_TIME_FMT" ulInformationTransfer UE %x size %u",
MSC_AS_TIME_ARGS(ctxt_pP),
ue_context_p->ue_context.rnti,
sdu_sizeP);
if (AMF_MODE_ENABLED == 1) {
rrc_gNB_send_NGAP_UPLINK_NAS(ctxt_pP,
ue_context_p,
ul_dcch_msg);
}
break;
case NR_UL_DCCH_MessageType__c1_PR_securityModeComplete:
// to avoid segmentation fault
if(!ue_context_p) {
......
......@@ -48,6 +48,10 @@
#include "S1AP_NAS-PDU.h"
#include "executables/softmodem-common.h"
#include "UTIL/OSA/osa_defs.h"
#include "ngap_gNB_defs.h"
#include "ngap_gNB_ue_context.h"
#include "NR_ULInformationTransfer.h"
#include "NR_UL-DCCH-Message.h"
extern RAN_CONTEXT_t RC;
......@@ -91,8 +95,62 @@ rrc_gNB_NGAP_get_ue_ids(
//------------------------------------------------------------------------------
{
rrc_ue_ngap_ids_t *result = NULL;
rrc_ue_ngap_ids_t *result2 = NULL;
/*****************************/
instance_t instance = 0;
ngap_gNB_instance_t *ngap_gNB_instance_p = NULL;
ngap_gNB_ue_context_t *ue_desc_p = NULL;
rrc_gNB_ue_context_t *ue_context_p = NULL;
/*****************************/
hashtable_rc_t h_rc;
if (ue_initial_id != UE_INITIAL_ID_INVALID) {
h_rc = hashtable_get(rrc_instance_pP->initial_id2_ngap_ids, (hash_key_t)ue_initial_id, (void **)&result);
if (h_rc == HASH_TABLE_OK) {
if (gNB_ue_ngap_idP > 0) {
h_rc = hashtable_get(rrc_instance_pP->ngap_id2_ngap_ids, (hash_key_t)gNB_ue_ngap_idP, (void **)&result2);
if (h_rc != HASH_TABLE_OK) { // this case is equivalent to associate gNB_ue_ngap_idP and ue_initial_id
result2 = malloc(sizeof(*result2));
if (NULL != result2) {
*result2 = *result;
result2->gNB_ue_ngap_id = gNB_ue_ngap_idP;
result->gNB_ue_ngap_id = gNB_ue_ngap_idP;
h_rc = hashtable_insert(rrc_instance_pP->ngap_id2_ngap_ids, (hash_key_t)gNB_ue_ngap_idP, result2);
if (h_rc != HASH_TABLE_OK) {
LOG_E(NGAP, "[gNB %ld] Error while hashtable_insert in ngap_id2_ngap_ids gNB_ue_ngap_idP %"PRIu32"\n",
rrc_instance_pP - RC.nrrrc[0],
gNB_ue_ngap_idP);
}
}
} else { // here we should check that the association was done correctly
if ((result->ue_initial_id != result2->ue_initial_id) || (result->gNB_ue_ngap_id != result2->gNB_ue_ngap_id)) {
LOG_E(NGAP, "[gNB %ld] Error while hashtable_get, two rrc_ue_ngap_ids_t that should be equal, are not:\n \
ue_initial_id 1 = %"PRIu16",\n \
ue_initial_id 2 = %"PRIu16",\n \
gNB_ue_ngap_idP 1 = %"PRIu32",\n \
gNB_ue_ngap_idP 2 = %"PRIu32"\n",
rrc_instance_pP - RC.nrrrc[0],
result->ue_initial_id,
result2->ue_initial_id,
result->gNB_ue_ngap_id,
result2->gNB_ue_ngap_id);
// Still return *result
}
}
} // end if if (eNB_ue_s1ap_id > 0)
} else { // end if (h_rc == HASH_TABLE_OK)
LOG_E(NGAP, "[gNB %ld] In hashtable_get, couldn't find in initial_id2_ngap_ids ue_initial_id %"PRIu16"\n",
rrc_instance_pP - RC.nrrrc[0],
ue_initial_id);
return NULL;
} // end else (h_rc != HASH_TABLE_OK)
} else { // end if (ue_initial_id != UE_INITIAL_ID_INVALID)
/* TODO */
} // end else (ue_initial_id == UE_INITIAL_ID_INVALID)
return result;
}
......@@ -199,10 +257,10 @@ rrc_gNB_send_NGAP_NAS_FIRST_REQ(
)
//------------------------------------------------------------------------------
{
// gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id];
gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id];
MessageDef *message_p = NULL;
rrc_ue_ngap_ids_t *rrc_ue_ngap_ids_p = NULL;
// hashtable_rc_t h_rc;
hashtable_rc_t h_rc;
message_p = itti_alloc_new_message(TASK_RRC_GNB, NGAP_NAS_FIRST_REQ);
memset(&message_p->ittiMsg.ngap_nas_first_req, 0, sizeof(ngap_nas_first_req_t));
......@@ -213,15 +271,15 @@ rrc_gNB_send_NGAP_NAS_FIRST_REQ(
rrc_ue_ngap_ids_p->gNB_ue_ngap_id = UE_INITIAL_ID_INVALID;
rrc_ue_ngap_ids_p->ue_rnti = ctxt_pP->rnti;
// h_rc = hashtable_insert(RC.nrrrc[ctxt_pP->module_id]->initial_id2_s1ap_ids,
// (hash_key_t)ue_context_pP->ue_context.ue_initial_id,
// rrc_ue_s1ap_ids_p);
h_rc = hashtable_insert(RC.nrrrc[ctxt_pP->module_id]->initial_id2_ngap_ids,
(hash_key_t)ue_context_pP->ue_context.ue_initial_id,
rrc_ue_ngap_ids_p);
// if (h_rc != HASH_TABLE_OK) {
// LOG_E(S1AP, "[eNB %d] Error while hashtable_insert in initial_id2_s1ap_ids ue_initial_id %u\n",
// ctxt_pP->module_id,
// ue_context_pP->ue_context.ue_initial_id);
// }
if (h_rc != HASH_TABLE_OK) {
LOG_E(NGAP, "[gNB %d] Error while hashtable_insert in initial_id2_ngap_ids ue_initial_id %u\n",
ctxt_pP->module_id,
ue_context_pP->ue_context.ue_initial_id);
}
/* Assume that cause is coded in the same way in RRC and NGap, just check that the value is in NGap range */
AssertFatal(ue_context_pP->ue_context.establishment_cause < NGAP_RRC_CAUSE_LAST,
......@@ -590,3 +648,32 @@ rrc_gNB_process_NGAP_DOWNLINK_NAS(
return (0);
}
}
//------------------------------------------------------------------------------
void
rrc_gNB_send_NGAP_UPLINK_NAS(
const protocol_ctxt_t *const ctxt_pP,
rrc_gNB_ue_context_t *const ue_context_pP,
NR_UL_DCCH_Message_t *const ul_dcch_msg
)
//------------------------------------------------------------------------------
{
uint32_t pdu_length;
uint8_t *pdu_buffer;
MessageDef *msg_p;
NR_ULInformationTransfer_t *ulInformationTransfer = ul_dcch_msg->message.choice.c1->choice.ulInformationTransfer;
if (ulInformationTransfer->criticalExtensions.present == NR_ULInformationTransfer__criticalExtensions_PR_ulInformationTransfer) {
pdu_length = ulInformationTransfer->criticalExtensions.choice.ulInformationTransfer->dedicatedNAS_Message->size;
pdu_buffer = ulInformationTransfer->criticalExtensions.choice.ulInformationTransfer->dedicatedNAS_Message->buf;
msg_p = itti_alloc_new_message (TASK_RRC_GNB, NGAP_UPLINK_NAS);
NGAP_UPLINK_NAS (msg_p).gNB_ue_ngap_id = ue_context_pP->ue_context.gNB_ue_ngap_id;
NGAP_UPLINK_NAS (msg_p).nas_pdu.length = pdu_length;
NGAP_UPLINK_NAS (msg_p).nas_pdu.buffer = pdu_buffer;
// extract_imsi(NGAP_UPLINK_NAS (msg_p).nas_pdu.buffer,
// NGAP_UPLINK_NAS (msg_p).nas_pdu.length,
// ue_context_pP);
itti_send_msg_to_task (TASK_NGAP, ctxt_pP->instance, msg_p);
LOG_I(NR_RRC,"Send RRC GNB UL Information Transfer \n");
}
}
......@@ -37,6 +37,7 @@
#include "NR_RRCSetupComplete-IEs.h"
#include "NR_RegisteredAMF.h"
#include "NR_UL-DCCH-Message.h"
typedef struct rrc_ue_ngap_ids_s {
/* Tree related data */
......@@ -85,4 +86,11 @@ rrc_gNB_process_NGAP_DOWNLINK_NAS(
mui_t *rrc_gNB_mui
);
void
rrc_gNB_send_NGAP_UPLINK_NAS(
const protocol_ctxt_t *const ctxt_pP,
rrc_gNB_ue_context_t *const ue_context_pP,
NR_UL_DCCH_Message_t *const ul_dcch_msg
);
#endif
......@@ -2350,6 +2350,13 @@ nr_rrc_ue_decode_dcch(
LOG_I(NR_RRC, "[UE %d] Received %s: UEid %u, length %u , buffer %p\n", ctxt_pP->module_id, messages_info[NAS_DOWNLINK_DATA_IND].name,
ctxt_pP->module_id, pdu_length, pdu_buffer);
//nas_proc_dl_transfer_ind (user, pdu_buffer, pdu_length);
/* MessageDef *message_p;
message_p = itti_alloc_new_message(TASK_RRC_NRUE, NAS_UPLINK_DATA_REQ);
NAS_UPLINK_DATA_REQ(message_p).UEid = ctxt_pP->module_id;
NAS_UPLINK_DATA_REQ(message_p).nasMsg.data = pdu_buffer;
NAS_UPLINK_DATA_REQ(message_p).nasMsg.length = pdu_length;
itti_send_msg_to_task(TASK_RRC_NRUE, ctxt_pP->instance, message_p);
LOG_I(NR_RRC, " Send NAS_UPLINK_DATA_REQ message\n");*/
#else
MessageDef *msg_p;
msg_p = itti_alloc_new_message(TASK_RRC_UE, NAS_DOWNLINK_DATA_IND);
......@@ -2466,7 +2473,7 @@ void *rrc_nrue_task( void *args_p ) {
case NAS_UPLINK_DATA_REQ: {
uint32_t length;
uint8_t *buffer;
LOG_D(NR_RRC, "[UE %d] Received %s: UEid %d\n", ue_mod_id, ITTI_MSG_NAME (msg_p), NAS_UPLINK_DATA_REQ (msg_p).UEid);
LOG_I(NR_RRC, "[UE %d] Received %s: UEid %d\n", ue_mod_id, ITTI_MSG_NAME (msg_p), NAS_UPLINK_DATA_REQ (msg_p).UEid);
/* Create message for PDCP (ULInformationTransfer_t) */
length = do_NR_ULInformationTransfer(&buffer, NAS_UPLINK_DATA_REQ (msg_p).nasMsg.length, NAS_UPLINK_DATA_REQ (msg_p).nasMsg.data);
/* Transfer data to PDCP */
......
......@@ -522,8 +522,8 @@ int main( int argc, char **argv )
exit(-1);
}
// AMF_MODE_ENABLED = !IS_SOFTMODEM_NOS1;
AMF_MODE_ENABLED = 0;
AMF_MODE_ENABLED = !IS_SOFTMODEM_NOS1;
// AMF_MODE_ENABLED = 0;
NGAP_CONF_MODE = !IS_SOFTMODEM_NOS1; //!get_softmodem_params()->phy_test;
#if T_TRACER
......
......@@ -465,6 +465,7 @@ int ngap_gNB_nas_uplink(instance_t instance, ngap_uplink_nas_t *ngap_uplink_nas_
/* Prepare the NGAP message to encode */
memset(&pdu, 0, sizeof(pdu));
pdu.present = NGAP_NGAP_PDU_PR_initiatingMessage;
pdu.choice.initiatingMessage = (NGAP_InitiatingMessage_t *)calloc(1,sizeof(NGAP_InitiatingMessage_t));
pdu.choice.initiatingMessage->procedureCode = NGAP_ProcedureCode_id_UplinkNASTransport;
pdu.choice.initiatingMessage->criticality = NGAP_Criticality_ignore;
pdu.choice.initiatingMessage->value.present = NGAP_InitiatingMessage__value_PR_UplinkNASTransport;
......@@ -499,6 +500,7 @@ int ngap_gNB_nas_uplink(instance_t instance, ngap_uplink_nas_t *ngap_uplink_nas_
ie->value.present = NGAP_UplinkNASTransport_IEs__value_PR_UserLocationInformation;
ie->value.choice.UserLocationInformation.present = NGAP_UserLocationInformation_PR_userLocationInformationNR;
ie->value.choice.UserLocationInformation.choice.userLocationInformationNR = CALLOC(1,sizeof(struct NGAP_UserLocationInformationNR));
userinfo_nr_p = ie->value.choice.UserLocationInformation.choice.userLocationInformationNR;
/* Set nRCellIdentity. default userLocationInformationNR */
......@@ -575,6 +577,7 @@ int ngap_gNB_nas_non_delivery_ind(instance_t instance,
/* Prepare the NGAP message to encode */
memset(&pdu, 0, sizeof(pdu));
pdu.present = NGAP_NGAP_PDU_PR_initiatingMessage;
pdu.choice.initiatingMessage = (NGAP_InitiatingMessage_t *)calloc(1,sizeof(NGAP_InitiatingMessage_t));
pdu.choice.initiatingMessage->procedureCode = NGAP_ProcedureCode_id_NASNonDeliveryIndication;
pdu.choice.initiatingMessage->criticality = NGAP_Criticality_ignore;
pdu.choice.initiatingMessage->value.present = NGAP_InitiatingMessage__value_PR_NASNonDeliveryIndication;
......@@ -899,6 +902,7 @@ int ngap_gNB_ue_capabilities(instance_t instance,
/* Prepare the NGAP message to encode */
memset(&pdu, 0, sizeof(pdu));
pdu.present = NGAP_NGAP_PDU_PR_initiatingMessage;
pdu.choice.initiatingMessage = (NGAP_InitiatingMessage_t *)calloc(1,sizeof(NGAP_InitiatingMessage_t));
pdu.choice.initiatingMessage->procedureCode = NGAP_ProcedureCode_id_UERadioCapabilityInfoIndication;
pdu.choice.initiatingMessage->criticality = NGAP_Criticality_ignore;
pdu.choice.initiatingMessage->value.present = NGAP_InitiatingMessage__value_PR_UERadioCapabilityInfoIndication;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment