Commit 9dc3f4f6 authored by Robert Schmidt's avatar Robert Schmidt

Merge remote-tracking branch 'origin/rework-ngap' into integration_2023_w11b

parents f97d002c 0b7da436
...@@ -169,7 +169,7 @@ gNBs = ...@@ -169,7 +169,7 @@ gNBs =
////////// AMF parameters: ////////// AMF parameters:
amf_ip_address = ( { ipv4 = "192.168.5.233"; amf_ip_address = ( { ipv4 = "192.168.70.132";
ipv6 = "192:168:30::17"; ipv6 = "192:168:30::17";
active = "yes"; active = "yes";
preference = "ipv4"; preference = "ipv4";
...@@ -178,11 +178,10 @@ gNBs = ...@@ -178,11 +178,10 @@ gNBs =
NETWORK_INTERFACES : NETWORK_INTERFACES :
{ {
GNB_INTERFACE_NAME_FOR_NG_AMF = "demo-oai";
GNB_INTERFACE_NAME_FOR_NG_AMF = "eth0"; GNB_IPV4_ADDRESS_FOR_NG_AMF = "192.168.70.129/24";
GNB_IPV4_ADDRESS_FOR_NG_AMF = "CI_GNB_IP_ADDR"; GNB_INTERFACE_NAME_FOR_NGU = "demo-oai";
GNB_INTERFACE_NAME_FOR_NGU = "eth0"; GNB_IPV4_ADDRESS_FOR_NGU = "192.168.70.129/24";
GNB_IPV4_ADDRESS_FOR_NGU = "CI_GNB_IP_ADDR";
GNB_PORT_FOR_S1U = 2152; # Spec 2152 GNB_PORT_FOR_S1U = 2152; # Spec 2152
}; };
} }
......
...@@ -54,4 +54,7 @@ typedef enum { CPtype = 0, UPtype } E1_t; ...@@ -54,4 +54,7 @@ typedef enum { CPtype = 0, UPtype } E1_t;
#define NODE_IS_DU(nOdE_TyPe) ((nOdE_TyPe) == ngran_eNB_DU || (nOdE_TyPe) == ngran_gNB_DU) #define NODE_IS_DU(nOdE_TyPe) ((nOdE_TyPe) == ngran_eNB_DU || (nOdE_TyPe) == ngran_gNB_DU)
#define NODE_IS_MBMS(nOdE_TyPe) ((nOdE_TyPe) == ngran_eNB_MBMS_STA) #define NODE_IS_MBMS(nOdE_TyPe) ((nOdE_TyPe) == ngran_eNB_MBMS_STA)
#define GTPV1_U_PORT_NUMBER (2152) #define GTPV1_U_PORT_NUMBER (2152)
typedef enum { non_dynamic, dynamic } fiveQI_type_t;
#define maxSRBs 4
#endif #endif
...@@ -49,7 +49,7 @@ static int get_single_ue_rnti(void) ...@@ -49,7 +49,7 @@ static int get_single_ue_rnti(void)
return -1; return -1;
// verify it exists in RRC as well // verify it exists in RRC as well
rrc_gNB_ue_context_t *rrcue = rrc_gNB_get_ue_context(RC.nrrrc[0], ue->rnti); rrc_gNB_ue_context_t *rrcue = rrc_gNB_get_ue_context_by_rnti(RC.nrrrc[0], ue->rnti);
if (!rrcue) if (!rrcue)
return -1; return -1;
...@@ -82,7 +82,7 @@ int get_reestab_count(char *buf, int debug, telnet_printfunc_t prnt) ...@@ -82,7 +82,7 @@ int get_reestab_count(char *buf, int debug, telnet_printfunc_t prnt)
ERROR_MSG_RET("RNTI needs to be [1,0xfffe]\n"); ERROR_MSG_RET("RNTI needs to be [1,0xfffe]\n");
} }
rrc_gNB_ue_context_t *ue = rrc_gNB_get_ue_context(RC.nrrrc[0], rnti); rrc_gNB_ue_context_t *ue = rrc_gNB_get_ue_context_by_rnti(RC.nrrrc[0], rnti);
if (!ue) if (!ue)
ERROR_MSG_RET("could not find UE with RNTI %04x\n", rnti); ERROR_MSG_RET("could not find UE with RNTI %04x\n", rnti);
...@@ -107,7 +107,7 @@ int trigger_reestab(char *buf, int debug, telnet_printfunc_t prnt) ...@@ -107,7 +107,7 @@ int trigger_reestab(char *buf, int debug, telnet_printfunc_t prnt)
} }
// verify it exists in RRC as well // verify it exists in RRC as well
rrc_gNB_ue_context_t *rrcue = rrc_gNB_get_ue_context(RC.nrrrc[0], rnti); rrc_gNB_ue_context_t *rrcue = rrc_gNB_get_ue_context_by_rnti(RC.nrrrc[0], rnti);
if (!rrcue) if (!rrcue)
ERROR_MSG_RET("could not find UE with RNTI %04x\n", rnti); ERROR_MSG_RET("could not find UE with RNTI %04x\n", rnti);
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#ifndef E1AP_MESSAGES_TYPES_H #ifndef E1AP_MESSAGES_TYPES_H
#define E1AP_MESSAGES_TYPES_H #define E1AP_MESSAGES_TYPES_H
#include "common/ngran_types.h"
#include "f1ap_messages_types.h" #include "f1ap_messages_types.h"
#include "ngap_messages_types.h" #include "ngap_messages_types.h"
......
This diff is collapsed.
...@@ -230,8 +230,7 @@ typedef struct protocol_ctxt_s { ...@@ -230,8 +230,7 @@ typedef struct protocol_ctxt_s {
#define ENB_INSTANCE_TO_MODULE_ID( iNSTANCE )iNSTANCE #define ENB_INSTANCE_TO_MODULE_ID( iNSTANCE )iNSTANCE
//NR //NR
#define GNB_MODULE_ID_TO_INSTANCE( mODULE_iD ) mODULE_iD #define GNB_MODULE_ID_TO_INSTANCE(mODULE_iD) mODULE_iD
#define GNB_INSTANCE_TO_MODULE_ID( iNSTANCE )iNSTANCE
#define MODULE_ID_TO_INSTANCE(mODULE_iD, iNSTANCE, eNB_fLAG) \ #define MODULE_ID_TO_INSTANCE(mODULE_iD, iNSTANCE, eNB_fLAG) \
do { \ do { \
......
...@@ -220,16 +220,15 @@ int e1ap_encode_send(E1_t type, e1ap_setup_req_t *setupReq, E1AP_E1AP_PDU_t *pdu ...@@ -220,16 +220,15 @@ int e1ap_encode_send(E1_t type, e1ap_setup_req_t *setupReq, E1AP_E1AP_PDU_t *pdu
if (encoded < 0) { if (encoded < 0) {
LOG_E(E1AP, "%s: Failed to encode E1AP message\n", func); LOG_E(E1AP, "%s: Failed to encode E1AP message\n", func);
return -1; return -1;
} else {
MessageDef *message = itti_alloc_new_message((type==CPtype)?TASK_CUCP_E1:TASK_CUUP_E1, 0, SCTP_DATA_REQ);
sctp_data_req_t *s = &message->ittiMsg.sctp_data_req;
s->assoc_id = setupReq->assoc_id;
s->buffer = buffer;
s->buffer_length = encoded;
s->stream = stream;
LOG_I(E1AP, "%s: Sending ITTI message to SCTP Task\n", func);
itti_send_msg_to_task(TASK_SCTP, 0 /*unused by callee*/, message);
} }
MessageDef *message = itti_alloc_new_message((type == CPtype) ? TASK_CUCP_E1 : TASK_CUUP_E1, 0, SCTP_DATA_REQ);
sctp_data_req_t *s = &message->ittiMsg.sctp_data_req;
s->assoc_id = setupReq->assoc_id;
s->buffer = buffer;
s->buffer_length = encoded;
s->stream = stream;
LOG_I(E1AP, "%s: Sending ITTI message to SCTP Task\n", func);
itti_send_msg_to_task(TASK_SCTP, 0 /*unused by callee*/, message);
return encoded; return encoded;
} }
...@@ -57,7 +57,7 @@ static void cu_task_handle_sctp_association_ind(instance_t instance, sctp_new_as ...@@ -57,7 +57,7 @@ static void cu_task_handle_sctp_association_ind(instance_t instance, sctp_new_as
f1ap_cu_data->sctp_in_streams = sctp_new_association_ind->in_streams; f1ap_cu_data->sctp_in_streams = sctp_new_association_ind->in_streams;
f1ap_cu_data->sctp_out_streams = sctp_new_association_ind->out_streams; f1ap_cu_data->sctp_out_streams = sctp_new_association_ind->out_streams;
f1ap_cu_data->default_sctp_stream_id = 0; f1ap_cu_data->default_sctp_stream_id = 0;
if (RC.nrrrc[GNB_INSTANCE_TO_MODULE_ID(instance)]->node_type != ngran_gNB_CUCP) { if (RC.nrrrc[instance]->node_type != ngran_gNB_CUCP) {
getCxt(CUtype, instance)->gtpInst = cu_task_create_gtpu_instance(IPaddrs); getCxt(CUtype, instance)->gtpInst = cu_task_create_gtpu_instance(IPaddrs);
AssertFatal(getCxt(CUtype, instance)->gtpInst > 0, "Failed to create CU F1-U UDP listener"); AssertFatal(getCxt(CUtype, instance)->gtpInst > 0, "Failed to create CU F1-U UDP listener");
} else } else
......
...@@ -947,13 +947,13 @@ int CU_handle_UE_CONTEXT_RELEASE_COMPLETE(instance_t instance, ...@@ -947,13 +947,13 @@ int CU_handle_UE_CONTEXT_RELEASE_COMPLETE(instance_t instance,
protocol_ctxt_t ctxt; protocol_ctxt_t ctxt;
PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, instance, GNB_FLAG_YES, rnti, 0, 0, instance); PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, instance, GNB_FLAG_YES, rnti, 0, 0, instance);
struct rrc_gNB_ue_context_s *ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[instance], rnti); rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context_by_rnti(RC.nrrrc[instance], rnti);
if (ue_context_p) { if (ue_context_p) {
MessageDef *msg = itti_alloc_new_message(TASK_CU_F1, 0, NGAP_UE_CONTEXT_RELEASE_COMPLETE); MessageDef *msg = itti_alloc_new_message(TASK_CU_F1, 0, NGAP_UE_CONTEXT_RELEASE_COMPLETE);
NGAP_UE_CONTEXT_RELEASE_COMPLETE(msg).gNB_ue_ngap_id = ue_context_p->ue_context.gNB_ue_ngap_id; NGAP_UE_CONTEXT_RELEASE_COMPLETE(msg).gNB_ue_ngap_id = ue_context_p->ue_context.gNB_ue_ngap_id;
itti_send_msg_to_task(TASK_NGAP, instance, msg); itti_send_msg_to_task(TASK_NGAP, instance, msg);
rrc_gNB_remove_ue_context(&ctxt, RC.nrrrc[instance], ue_context_p); rrc_gNB_remove_ue_context(RC.nrrrc[instance], ue_context_p);
} else { } else {
LOG_E(F1AP, "could not find ue_context of UE RNTI %x\n", rnti); LOG_E(F1AP, "could not find ue_context of UE RNTI %x\n", rnti);
} }
...@@ -1600,7 +1600,7 @@ int CU_handle_UE_CONTEXT_MODIFICATION_RESPONSE(instance_t instance, ...@@ -1600,7 +1600,7 @@ int CU_handle_UE_CONTEXT_MODIFICATION_RESPONSE(instance_t instance,
F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID, true); F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID, true);
f1ap_ue_context_modification_resp->gNB_DU_ue_id = ie->value.choice.GNB_DU_UE_F1AP_ID; f1ap_ue_context_modification_resp->gNB_DU_ue_id = ie->value.choice.GNB_DU_UE_F1AP_ID;
LOG_D(F1AP, "f1ap_ue_context_setup_resp->gNB_DU_ue_id is: %d \n", f1ap_ue_context_modification_resp->gNB_DU_ue_id); LOG_D(F1AP, "f1ap_ue_context_modification_resp->gNB_DU_ue_id is: %d \n", f1ap_ue_context_modification_resp->gNB_DU_ue_id);
f1ap_ue_context_modification_resp->rnti = f1ap_ue_context_modification_resp->rnti =
f1ap_get_rnti_by_du_id(CUtype, instance, f1ap_ue_context_modification_resp->gNB_DU_ue_id); f1ap_get_rnti_by_du_id(CUtype, instance, f1ap_ue_context_modification_resp->gNB_DU_ue_id);
......
...@@ -31,7 +31,7 @@ void f1ap_itti_send_sctp_data_req(bool isCu, instance_t instance, uint8_t *buffe ...@@ -31,7 +31,7 @@ void f1ap_itti_send_sctp_data_req(bool isCu, instance_t instance, uint8_t *buffe
sctp_data_req->assoc_id = f1ap_assoc_id(isCu,instance); sctp_data_req->assoc_id = f1ap_assoc_id(isCu,instance);
sctp_data_req->buffer = buffer; sctp_data_req->buffer = buffer;
sctp_data_req->buffer_length = buffer_length; sctp_data_req->buffer_length = buffer_length;
sctp_data_req->stream = stream; sctp_data_req->stream = stream;
LOG_D(F1AP, "Sending ITTI message to SCTP Task\n"); LOG_D(F1AP, "Sending ITTI message to SCTP Task\n");
itti_send_msg_to_task(TASK_SCTP, instance, message_p); itti_send_msg_to_task(TASK_SCTP, instance, message_p);
} }
......
...@@ -2810,10 +2810,12 @@ void nr_mac_update_timers(module_id_t module_id, ...@@ -2810,10 +2810,12 @@ void nr_mac_update_timers(module_id_t module_id,
NR_CellGroupConfig_t *cg = NULL; NR_CellGroupConfig_t *cg = NULL;
uper_decode(NULL, uper_decode(NULL,
&asn_DEF_NR_CellGroupConfig, //might be added prefix later &asn_DEF_NR_CellGroupConfig, // might be added prefix later
(void **)&cg, (void **)&cg,
(uint8_t *)UE->cg_buf, (uint8_t *)UE->cg_buf,
(UE->enc_rval.encoded+7)/8, 0, 0); (UE->enc_rval.encoded + 7) / 8,
0,
0);
UE->CellGroup = cg; UE->CellGroup = cg;
if (LOG_DEBUGFLAG(DEBUG_ASN1)) { if (LOG_DEBUGFLAG(DEBUG_ASN1)) {
...@@ -2918,13 +2920,8 @@ void send_initial_ul_rrc_message(module_id_t module_id, ...@@ -2918,13 +2920,8 @@ void send_initial_ul_rrc_message(module_id_t module_id,
sdu_len, rnti); sdu_len, rnti);
/* TODO REMOVE_DU_RRC: the RRC in the DU is a hack and should be taken out in the future */ /* TODO REMOVE_DU_RRC: the RRC in the DU is a hack and should be taken out in the future */
if (NODE_IS_DU(RC.nrrrc[module_id]->node_type)) { if (NODE_IS_DU(RC.nrrrc[module_id]->node_type))
struct rrc_gNB_ue_context_s *ue_context_p = rrc_gNB_allocate_new_UE_context(RC.nrrrc[module_id]); rrc_gNB_create_ue_context(rnti, RC.nrrrc[module_id], rnti);
ue_context_p->ue_id_rnti = rnti;
ue_context_p->ue_context.rnti = rnti;
ue_context_p->ue_context.random_ue_identity = rnti;
RB_INSERT(rrc_nr_ue_tree_s, &RC.nrrrc[module_id]->rrc_ue_head, ue_context_p);
}
const NR_ServingCellConfigCommon_t *scc = RC.nrrrc[module_id]->carrier.servingcellconfigcommon; const NR_ServingCellConfigCommon_t *scc = RC.nrrrc[module_id]->carrier.servingcellconfigcommon;
const NR_ServingCellConfig_t *sccd = RC.nrrrc[module_id]->configuration.scd; const NR_ServingCellConfig_t *sccd = RC.nrrrc[module_id]->configuration.scd;
......
...@@ -106,7 +106,7 @@ int dl_rrc_message_rrcSetup(module_id_t module_id, const f1ap_dl_rrc_message_t * ...@@ -106,7 +106,7 @@ int dl_rrc_message_rrcSetup(module_id_t module_id, const f1ap_dl_rrc_message_t *
/* TODO: drop the RRC context */ /* TODO: drop the RRC context */
gNB_RRC_INST *rrc = RC.nrrrc[module_id]; gNB_RRC_INST *rrc = RC.nrrrc[module_id];
struct rrc_gNB_ue_context_s *ue_context_p = rrc_gNB_get_ue_context(rrc, dl_rrc->rnti); rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context_by_rnti(rrc, dl_rrc->rnti);
gNB_RRC_UE_t *ue_p = &ue_context_p->ue_context; gNB_RRC_UE_t *ue_p = &ue_context_p->ue_context;
ue_p->SRB_configList = rrcSetup_ies->radioBearerConfig.srb_ToAddModList; ue_p->SRB_configList = rrcSetup_ies->radioBearerConfig.srb_ToAddModList;
ue_p->masterCellGroup = cellGroup; ue_p->masterCellGroup = cellGroup;
......
...@@ -162,8 +162,7 @@ int8_t nr_mac_rrc_bwp_switch_req(const module_id_t module_idP, ...@@ -162,8 +162,7 @@ int8_t nr_mac_rrc_bwp_switch_req(const module_id_t module_idP,
const rnti_t rntiP, const rnti_t rntiP,
const int dl_bwp_id, const int dl_bwp_id,
const int ul_bwp_id) { const int ul_bwp_id) {
rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context_by_rnti(RC.nrrrc[module_idP], rntiP);
struct rrc_gNB_ue_context_s *ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[module_idP], rntiP);
protocol_ctxt_t ctxt; protocol_ctxt_t ctxt;
PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, GNB_FLAG_YES, rntiP, frameP, sub_frameP, 0); PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, GNB_FLAG_YES, rntiP, frameP, sub_frameP, 0);
...@@ -177,10 +176,7 @@ void nr_mac_gNB_rrc_ul_failure(const module_id_t Mod_instP, ...@@ -177,10 +176,7 @@ void nr_mac_gNB_rrc_ul_failure(const module_id_t Mod_instP,
const frame_t frameP, const frame_t frameP,
const sub_frame_t subframeP, const sub_frame_t subframeP,
const rnti_t rntiP) { const rnti_t rntiP) {
struct rrc_gNB_ue_context_s *ue_context_p = NULL; rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context_by_rnti(RC.nrrrc[Mod_instP], rntiP);
ue_context_p = rrc_gNB_get_ue_context(
RC.nrrrc[Mod_instP],
rntiP);
if (ue_context_p != NULL) { if (ue_context_p != NULL) {
LOG_D(RRC,"Frame %d, Subframe %d: UE %x UL failure, activating timer\n",frameP,subframeP,rntiP); LOG_D(RRC,"Frame %d, Subframe %d: UE %x UL failure, activating timer\n",frameP,subframeP,rntiP);
...@@ -195,8 +191,7 @@ void nr_mac_gNB_rrc_ul_failure_reset(const module_id_t Mod_instP, ...@@ -195,8 +191,7 @@ void nr_mac_gNB_rrc_ul_failure_reset(const module_id_t Mod_instP,
const frame_t frameP, const frame_t frameP,
const sub_frame_t subframeP, const sub_frame_t subframeP,
const rnti_t rntiP) { const rnti_t rntiP) {
struct rrc_gNB_ue_context_s *ue_context_p = NULL; rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context_by_rnti(RC.nrrrc[Mod_instP], rntiP);
ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[Mod_instP], rntiP);
if (ue_context_p != NULL) { if (ue_context_p != NULL) {
LOG_W(RRC,"Frame %d, Subframe %d: UE %x UL failure reset, deactivating timer\n",frameP,subframeP,rntiP); LOG_W(RRC,"Frame %d, Subframe %d: UE %x UL failure reset, deactivating timer\n",frameP,subframeP,rntiP);
ue_context_p->ue_context.ul_failure_timer=0; ue_context_p->ue_context.ul_failure_timer=0;
......
...@@ -1298,27 +1298,24 @@ uint8_t do_NR_SecurityModeCommand( ...@@ -1298,27 +1298,24 @@ uint8_t do_NR_SecurityModeCommand(
uint8_t *const buffer, uint8_t *const buffer,
const uint8_t Transaction_id, const uint8_t Transaction_id,
const uint8_t cipheringAlgorithm, const uint8_t cipheringAlgorithm,
NR_IntegrityProtAlgorithm_t *integrityProtAlgorithm NR_IntegrityProtAlgorithm_t integrityProtAlgorithm
) )
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
{ {
NR_DL_DCCH_Message_t dl_dcch_msg; NR_DL_DCCH_Message_t dl_dcch_msg={0};
asn_enc_rval_t enc_rval; asn_enc_rval_t enc_rval;
memset(&dl_dcch_msg,0,sizeof(NR_DL_DCCH_Message_t));
dl_dcch_msg.message.present = NR_DL_DCCH_MessageType_PR_c1; dl_dcch_msg.message.present = NR_DL_DCCH_MessageType_PR_c1;
dl_dcch_msg.message.choice.c1=CALLOC(1,sizeof(struct NR_DL_DCCH_MessageType__c1)); asn1cCalloc(dl_dcch_msg.message.choice.c1, c1);
dl_dcch_msg.message.choice.c1->present = NR_DL_DCCH_MessageType__c1_PR_securityModeCommand; c1->present = NR_DL_DCCH_MessageType__c1_PR_securityModeCommand;
dl_dcch_msg.message.choice.c1->choice.securityModeCommand = CALLOC(1, sizeof(struct NR_SecurityModeCommand)); asn1cCalloc(c1->choice.securityModeCommand,scm);
dl_dcch_msg.message.choice.c1->choice.securityModeCommand->rrc_TransactionIdentifier = Transaction_id; scm->rrc_TransactionIdentifier = Transaction_id;
dl_dcch_msg.message.choice.c1->choice.securityModeCommand->criticalExtensions.present = NR_SecurityModeCommand__criticalExtensions_PR_securityModeCommand; scm->criticalExtensions.present = NR_SecurityModeCommand__criticalExtensions_PR_securityModeCommand;
dl_dcch_msg.message.choice.c1->choice.securityModeCommand->criticalExtensions.choice.securityModeCommand = asn1cCalloc(scm->criticalExtensions.choice.securityModeCommand,scmIE);
CALLOC(1, sizeof(struct NR_SecurityModeCommand_IEs));
// the two following information could be based on the mod_id // the two following information could be based on the mod_id
dl_dcch_msg.message.choice.c1->choice.securityModeCommand->criticalExtensions.choice.securityModeCommand->securityConfigSMC.securityAlgorithmConfig.cipheringAlgorithm scmIE->securityConfigSMC.securityAlgorithmConfig.cipheringAlgorithm
= (NR_CipheringAlgorithm_t)cipheringAlgorithm; = (NR_CipheringAlgorithm_t)cipheringAlgorithm;
dl_dcch_msg.message.choice.c1->choice.securityModeCommand->criticalExtensions.choice.securityModeCommand->securityConfigSMC.securityAlgorithmConfig.integrityProtAlgorithm asn1cCallocOne(scmIE->securityConfigSMC.securityAlgorithmConfig.integrityProtAlgorithm, integrityProtAlgorithm);
= integrityProtAlgorithm;
if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) {
xer_fprint(stdout, &asn_DEF_NR_DL_DCCH_Message, (void *)&dl_dcch_msg); xer_fprint(stdout, &asn_DEF_NR_DL_DCCH_Message, (void *)&dl_dcch_msg);
...@@ -1332,7 +1329,7 @@ uint8_t do_NR_SecurityModeCommand( ...@@ -1332,7 +1329,7 @@ uint8_t do_NR_SecurityModeCommand(
AssertFatal(enc_rval.encoded >0 , "ASN1 message encoding failed (%s, %lu)!\n", AssertFatal(enc_rval.encoded >0 , "ASN1 message encoding failed (%s, %lu)!\n",
enc_rval.failed_type->name, enc_rval.encoded); enc_rval.failed_type->name, enc_rval.encoded);
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_NR_DL_DCCH_Message,&dl_dcch_msg);
LOG_D(NR_RRC, "[gNB %d] securityModeCommand for UE %lx Encoded %zd bits (%zd bytes)\n", ctxt_pP->module_id, ctxt_pP->rntiMaybeUEid, enc_rval.encoded, (enc_rval.encoded + 7) / 8); LOG_D(NR_RRC, "[gNB %d] securityModeCommand for UE %lx Encoded %zd bits (%zd bytes)\n", ctxt_pP->module_id, ctxt_pP->rntiMaybeUEid, enc_rval.encoded, (enc_rval.encoded + 7) / 8);
// rrc_ue_process_ueCapabilityEnquiry(0,1000,&dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry,0); // rrc_ue_process_ueCapabilityEnquiry(0,1000,&dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry,0);
...@@ -1521,10 +1518,7 @@ int16_t do_RRCReconfiguration( ...@@ -1521,10 +1518,7 @@ int16_t do_RRCReconfiguration(
} }
if(cellGroupConfig!=NULL){ if(cellGroupConfig!=NULL){
update_cellGroupConfig(cellGroupConfig, update_cellGroupConfig(cellGroupConfig, ue_context_pP->ue_context.gNB_ue_ngap_id, ue_context_pP ? ue_context_pP->ue_context.UE_Capability_nr : NULL, configuration);
ue_context_pP->local_uid,
ue_context_pP ? ue_context_pP->ue_context.UE_Capability_nr : NULL,
configuration);
enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig,
NULL, NULL,
...@@ -1754,29 +1748,27 @@ do_NR_DLInformationTransfer( ...@@ -1754,29 +1748,27 @@ do_NR_DLInformationTransfer(
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
{ {
ssize_t encoded; ssize_t encoded;
NR_DL_DCCH_Message_t dl_dcch_msg; NR_DL_DCCH_Message_t dl_dcch_msg={0};
memset(&dl_dcch_msg, 0, sizeof(NR_DL_DCCH_Message_t));
dl_dcch_msg.message.present = NR_DL_DCCH_MessageType_PR_c1; dl_dcch_msg.message.present = NR_DL_DCCH_MessageType_PR_c1;
dl_dcch_msg.message.choice.c1 = CALLOC(1, sizeof(struct NR_DL_DCCH_MessageType__c1)); asn1cCalloc(dl_dcch_msg.message.choice.c1, c1);
dl_dcch_msg.message.choice.c1->present = NR_DL_DCCH_MessageType__c1_PR_dlInformationTransfer; c1->present = NR_DL_DCCH_MessageType__c1_PR_dlInformationTransfer;
dl_dcch_msg.message.choice.c1->choice.dlInformationTransfer = CALLOC(1, sizeof(NR_DLInformationTransfer_t)); asn1cCalloc(c1->choice.dlInformationTransfer, infoTransfer);
dl_dcch_msg.message.choice.c1->choice.dlInformationTransfer->rrc_TransactionIdentifier = transaction_id; infoTransfer->rrc_TransactionIdentifier = transaction_id;
dl_dcch_msg.message.choice.c1->choice.dlInformationTransfer->criticalExtensions.present = infoTransfer->criticalExtensions.present =
NR_DLInformationTransfer__criticalExtensions_PR_dlInformationTransfer; NR_DLInformationTransfer__criticalExtensions_PR_dlInformationTransfer;
dl_dcch_msg.message.choice.c1->choice.dlInformationTransfer-> asn1cCalloc(infoTransfer->criticalExtensions.choice.dlInformationTransfer, dlInfoTransfer);
criticalExtensions.choice.dlInformationTransfer = CALLOC(1, sizeof(NR_DLInformationTransfer_IEs_t)); asn1cCalloc(dlInfoTransfer->dedicatedNAS_Message,msg);
dl_dcch_msg.message.choice.c1->choice.dlInformationTransfer-> // we will free the caller buffer, that is ok in the present code logic (else it will leak memory) but not natural,
criticalExtensions.choice.dlInformationTransfer->dedicatedNAS_Message = CALLOC(1, sizeof(NR_DedicatedNAS_Message_t)); // comprehensive code design
dl_dcch_msg.message.choice.c1->choice.dlInformationTransfer-> msg->buf = pdu_buffer;
criticalExtensions.choice.dlInformationTransfer->dedicatedNAS_Message->buf = pdu_buffer; msg->size = pdu_length;
dl_dcch_msg.message.choice.c1->choice.dlInformationTransfer->
criticalExtensions.choice.dlInformationTransfer->dedicatedNAS_Message->size = pdu_length;
encoded = uper_encode_to_new_buffer (&asn_DEF_NR_DL_DCCH_Message, NULL, (void *) &dl_dcch_msg, (void **)buffer); encoded = uper_encode_to_new_buffer (&asn_DEF_NR_DL_DCCH_Message, NULL, (void *) &dl_dcch_msg, (void **)buffer);
AssertFatal(encoded > 0,"ASN1 message encoding failed (%s, %ld)!\n", AssertFatal(encoded > 0,"ASN1 message encoding failed (%s, %ld)!\n",
"DLInformationTransfer", encoded); "DLInformationTransfer", encoded);
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_NR_DL_DCCH_Message,&dl_dcch_msg );
LOG_D(NR_RRC,"DLInformationTransfer Encoded %zd bytes\n", encoded); LOG_D(NR_RRC,"DLInformationTransfer Encoded %zd bytes\n", encoded);
//for (int i=0;i<encoded;i++) printf("%02x ",(*buffer)[i]); //for (int i=0;i<encoded;i++) printf("%02x ",(*buffer)[i]);
return encoded; return encoded;
......
...@@ -113,7 +113,7 @@ uint8_t do_NR_SecurityModeCommand( ...@@ -113,7 +113,7 @@ uint8_t do_NR_SecurityModeCommand(
uint8_t *const buffer, uint8_t *const buffer,
const uint8_t Transaction_id, const uint8_t Transaction_id,
const uint8_t cipheringAlgorithm, const uint8_t cipheringAlgorithm,
NR_IntegrityProtAlgorithm_t *integrityProtAlgorithm); NR_IntegrityProtAlgorithm_t integrityProtAlgorithm);
uint8_t do_NR_SA_UECapabilityEnquiry( const protocol_ctxt_t *const ctxt_pP, uint8_t do_NR_SA_UECapabilityEnquiry( const protocol_ctxt_t *const ctxt_pP,
uint8_t *const buffer, uint8_t *const buffer,
......
...@@ -107,18 +107,19 @@ static int drb_config_gtpu_create(const protocol_ctxt_t *const ctxt_p, ...@@ -107,18 +107,19 @@ static int drb_config_gtpu_create(const protocol_ctxt_t *const ctxt_p,
gtpv1u_gnb_create_tunnel_req_t create_tunnel_req={0}; gtpv1u_gnb_create_tunnel_req_t create_tunnel_req={0};
gtpv1u_gnb_create_tunnel_resp_t create_tunnel_resp={0}; gtpv1u_gnb_create_tunnel_resp_t create_tunnel_resp={0};
gNB_RRC_UE_t *UE = &ue_context_p->ue_context;
int i = ue_context_p->ue_context.nb_of_pdusessions - 1; LOG_W(NR_RRC, "recreate existing tunnels, while adding new ones\n");
pdu_session_param_t *pdu = ue_context_p->ue_context.pduSession + i; for (int i = 0; i < UE->nb_of_pdusessions; i++) {
create_tunnel_req.pdusession_id[0] = pdu->param.pdusession_id; rrc_pdu_session_param_t *pdu = UE->pduSession + i;
create_tunnel_req.incoming_rb_id[0] = i + 1; create_tunnel_req.pdusession_id[i] = pdu->param.pdusession_id;
create_tunnel_req.outgoing_qfi[0] = req->pduSession[i].DRBnGRanList[0].qosFlows[0].id; create_tunnel_req.incoming_rb_id[i] = i + 1;
memcpy(&create_tunnel_req.dst_addr[0].buffer, &pdu->param.upf_addr.buffer, sizeof(create_tunnel_req.dst_addr[0].buffer)); create_tunnel_req.outgoing_qfi[i] = req->pduSession[i].DRBnGRanList[0].qosFlows[0].id;
create_tunnel_req.dst_addr[0].length = pdu->param.upf_addr.length; memcpy(&create_tunnel_req.dst_addr[i].buffer, &pdu->param.upf_addr.buffer, sizeof(create_tunnel_req.dst_addr[0].buffer));
create_tunnel_req.outgoing_teid[0] = pdu->param.gtp_teid; create_tunnel_req.dst_addr[i].length = pdu->param.upf_addr.length;
create_tunnel_req.outgoing_teid[i] = pdu->param.gtp_teid;
create_tunnel_req.num_tunnels = 1; }
create_tunnel_req.ue_id = ue_context_p->ue_context.rnti; create_tunnel_req.num_tunnels = UE->nb_of_pdusessions;
create_tunnel_req.ue_id = UE->rnti;
int ret = gtpv1u_create_ngu_tunnel(getCxtE1(instance)->gtpInstN3, &create_tunnel_req, &create_tunnel_resp); int ret = gtpv1u_create_ngu_tunnel(getCxtE1(instance)->gtpInstN3, &create_tunnel_req, &create_tunnel_resp);
if (ret != 0) { if (ret != 0) {
...@@ -127,7 +128,7 @@ static int drb_config_gtpu_create(const protocol_ctxt_t *const ctxt_p, ...@@ -127,7 +128,7 @@ static int drb_config_gtpu_create(const protocol_ctxt_t *const ctxt_p,
return ret; return ret;
} }
nr_rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP(ctxt_p, &create_tunnel_resp, i); nr_rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP(ctxt_p, &create_tunnel_resp, 0);
uint8_t *kRRCenc = NULL; uint8_t *kRRCenc = NULL;
uint8_t *kRRCint = NULL; uint8_t *kRRCint = NULL;
...@@ -135,39 +136,27 @@ static int drb_config_gtpu_create(const protocol_ctxt_t *const ctxt_p, ...@@ -135,39 +136,27 @@ static int drb_config_gtpu_create(const protocol_ctxt_t *const ctxt_p,
uint8_t *kUPint = NULL; uint8_t *kUPint = NULL;
/* Derive the keys from kgnb */ /* Derive the keys from kgnb */
if (DRB_configList != NULL) { if (DRB_configList != NULL) {
nr_derive_key_up_enc(ue_context_p->ue_context.ciphering_algorithm, nr_derive_key_up_enc(UE->ciphering_algorithm, UE->kgnb, &kUPenc);
ue_context_p->ue_context.kgnb, nr_derive_key_up_int(UE->integrity_algorithm, UE->kgnb, &kUPint);
&kUPenc);
nr_derive_key_up_int(ue_context_p->ue_context.integrity_algorithm,
ue_context_p->ue_context.kgnb,
&kUPint);
} }
nr_derive_key_rrc_enc(ue_context_p->ue_context.ciphering_algorithm, nr_derive_key_rrc_enc(UE->ciphering_algorithm, UE->kgnb, &kRRCenc);
ue_context_p->ue_context.kgnb, nr_derive_key_rrc_int(UE->integrity_algorithm, UE->kgnb, &kRRCint);
&kRRCenc);
nr_derive_key_rrc_int(ue_context_p->ue_context.integrity_algorithm,
ue_context_p->ue_context.kgnb,
&kRRCint);
/* Refresh SRBs/DRBs */ /* Refresh SRBs/DRBs */
LOG_D(NR_RRC,"Configuring PDCP DRBs/SRBs for UE %x\n",ue_context_p->ue_context.rnti); LOG_D(NR_RRC, "Configuring PDCP DRBs/SRBs for UE %x\n", UE->rnti);
nr_pdcp_add_srbs(ctxt_p->enb_flag, ctxt_p->rntiMaybeUEid, nr_pdcp_add_srbs(ctxt_p->enb_flag, ctxt_p->rntiMaybeUEid, SRB_configList, (UE->integrity_algorithm << 4) | UE->ciphering_algorithm, kRRCenc, kRRCint);
SRB_configList,
(ue_context_p->ue_context.integrity_algorithm << 4) nr_pdcp_add_drbs(ctxt_p->enb_flag,
| ue_context_p->ue_context.ciphering_algorithm, ctxt_p->rntiMaybeUEid,
kRRCenc, 0,
kRRCint);
nr_pdcp_add_drbs(ctxt_p->enb_flag, ctxt_p->rntiMaybeUEid, 0,
DRB_configList, DRB_configList,
(ue_context_p->ue_context.integrity_algorithm << 4) (UE->integrity_algorithm << 4) | UE->ciphering_algorithm,
| ue_context_p->ue_context.ciphering_algorithm,
kUPenc, kUPenc,
kUPint, kUPint,
get_softmodem_params()->sa ? ue_context_p->ue_context.masterCellGroup->rlc_BearerToAddModList : NULL); get_softmodem_params()->sa ? UE->masterCellGroup->rlc_BearerToAddModList : NULL);
return ret; return ret;
} }
...@@ -187,17 +176,18 @@ static NR_SRB_ToAddModList_t **generateSRB2_confList(gNB_RRC_UE_t *ue, NR_SRB_To ...@@ -187,17 +176,18 @@ static NR_SRB_ToAddModList_t **generateSRB2_confList(gNB_RRC_UE_t *ue, NR_SRB_To
return SRB_configList2; return SRB_configList2;
} }
static void cucp_cuup_bearer_context_setup_direct(e1ap_bearer_setup_req_t *const req, instance_t instance) { static void cucp_cuup_bearer_context_setup_direct(e1ap_bearer_setup_req_t *const req, instance_t instance) {
rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[GNB_INSTANCE_TO_MODULE_ID(instance)], req->rnti); rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context_by_rnti(RC.nrrrc[instance], req->rnti);
gNB_RRC_UE_t *UE = &ue_context_p->ue_context;
protocol_ctxt_t ctxt = {0}; protocol_ctxt_t ctxt = {0};
PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, 0, GNB_FLAG_YES, ue_context_p->ue_context.rnti, 0, 0, 0); PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, 0, GNB_FLAG_YES, UE->rnti, 0, 0, 0);
fill_DRB_configList(&ctxt, ue_context_p); fill_DRB_configList(&ctxt, ue_context_p);
gNB_RRC_INST *rrc = RC.nrrrc[ctxt.module_id]; gNB_RRC_INST *rrc = RC.nrrrc[ctxt.module_id];
// Fixme: xid not random, but almost! // Fixme: xid not random, but almost!
NR_SRB_ToAddModList_t **SRB_configList2 = generateSRB2_confList(&ue_context_p->ue_context, ue_context_p->ue_context.SRB_configList, ue_context_p->ue_context.pduSession[0].xid); NR_SRB_ToAddModList_t **SRB_configList2 = generateSRB2_confList(UE, UE->SRB_configList, UE->pduSession[0].xid);
// GTP tunnel for UL // GTP tunnel for UL
int ret = drb_config_gtpu_create(&ctxt, ue_context_p, req, ue_context_p->ue_context.DRB_configList, *SRB_configList2, rrc->e1_inst); int ret = drb_config_gtpu_create(&ctxt, ue_context_p, req, UE->DRB_configList, *SRB_configList2, rrc->e1_inst);
if (ret < 0) AssertFatal(false, "Unable to configure DRB or to create GTP Tunnel\n"); if (ret < 0) AssertFatal(false, "Unable to configure DRB or to create GTP Tunnel\n");
if(!NODE_IS_CU(RC.nrrrc[ctxt.module_id]->node_type)) { if(!NODE_IS_CU(RC.nrrrc[ctxt.module_id]->node_type)) {
...@@ -208,7 +198,7 @@ static void cucp_cuup_bearer_context_setup_direct(e1ap_bearer_setup_req_t *const ...@@ -208,7 +198,7 @@ static void cucp_cuup_bearer_context_setup_direct(e1ap_bearer_setup_req_t *const
in_addr_t my_addr = inet_addr(RC.nrrrc[ctxt.module_id]->eth_params_s.my_addr); in_addr_t my_addr = inet_addr(RC.nrrrc[ctxt.module_id]->eth_params_s.my_addr);
instance_t gtpInst = getCxt(CUtype, instance)->gtpInst; instance_t gtpInst = getCxt(CUtype, instance)->gtpInst;
// GTP tunnel for DL // GTP tunnel for DL
fill_e1ap_bearer_setup_resp(&resp, req, gtpInst, ue_context_p->ue_context.rnti, remote_port, my_addr); fill_e1ap_bearer_setup_resp(&resp, req, gtpInst, UE->rnti, remote_port, my_addr);
prepare_and_send_ue_context_modification_f1(ue_context_p, &resp); prepare_and_send_ue_context_modification_f1(ue_context_p, &resp);
} }
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
extern RAN_CONTEXT_t RC; extern RAN_CONTEXT_t RC;
static void cucp_cuup_bearer_context_setup_e1ap(e1ap_bearer_setup_req_t *const req, instance_t instance) { static void cucp_cuup_bearer_context_setup_e1ap(e1ap_bearer_setup_req_t *const req, instance_t instance) {
rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[GNB_INSTANCE_TO_MODULE_ID(instance)], req->rnti); rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context_by_rnti(RC.nrrrc[instance], req->rnti);
protocol_ctxt_t ctxt = {0}; protocol_ctxt_t ctxt = {0};
PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, 0, GNB_FLAG_YES, ue_context_p->ue_context.rnti, 0, 0, 0); PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, 0, GNB_FLAG_YES, ue_context_p->ue_context.rnti, 0, 0, 0);
......
...@@ -269,7 +269,7 @@ typedef struct pdu_session_param_s { ...@@ -269,7 +269,7 @@ typedef struct pdu_session_param_s {
uint8_t xid; // transaction_id uint8_t xid; // transaction_id
ngap_Cause_t cause; ngap_Cause_t cause;
uint8_t cause_value; uint8_t cause_value;
} __attribute__ ((__packed__)) pdu_session_param_t; } rrc_pdu_session_param_t;
typedef struct gNB_RRC_UE_s { typedef struct gNB_RRC_UE_s {
uint8_t primaryCC_id; uint8_t primaryCC_id;
...@@ -281,8 +281,7 @@ typedef struct gNB_RRC_UE_s { ...@@ -281,8 +281,7 @@ typedef struct gNB_RRC_UE_s {
uint8_t DRB_active[NGAP_MAX_DRBS_PER_UE]; uint8_t DRB_active[NGAP_MAX_DRBS_PER_UE];
NR_SRB_INFO SI; NR_SRB_INFO SI;
NR_SRB_INFO_TABLE_ENTRY Srb1; NR_SRB_INFO_TABLE_ENTRY Srb[maxSRBs]; // 3gpp max is 3 SRBs, number 1..3, we waste the entry 0 for code simplicity
NR_SRB_INFO_TABLE_ENTRY Srb2;
NR_MeasConfig_t *measConfig; NR_MeasConfig_t *measConfig;
NR_HANDOVER_INFO *handover_info; NR_HANDOVER_INFO *handover_info;
NR_MeasResults_t *measResults; NR_MeasResults_t *measResults;
...@@ -332,7 +331,7 @@ typedef struct gNB_RRC_UE_s { ...@@ -332,7 +331,7 @@ typedef struct gNB_RRC_UE_s {
/* Information from S1AP initial_context_setup_req */ /* Information from S1AP initial_context_setup_req */
uint32_t gNB_ue_s1ap_id :24; uint32_t gNB_ue_s1ap_id :24;
uint32_t gNB_ue_ngap_id; uint32_t gNB_ue_ngap_id;
uint64_t amf_ue_ngap_id:40; uint64_t amf_ue_ngap_id;
nr_rrc_guami_t ue_guami; nr_rrc_guami_t ue_guami;
ngap_security_capabilities_t security_capabilities; ngap_security_capabilities_t security_capabilities;
...@@ -350,11 +349,11 @@ typedef struct gNB_RRC_UE_s { ...@@ -350,11 +349,11 @@ typedef struct gNB_RRC_UE_s {
/* Number of e_rab to be modified in the list */ /* Number of e_rab to be modified in the list */
uint8_t nb_of_modify_pdusessions; uint8_t nb_of_modify_pdusessions;
uint8_t nb_of_failed_pdusessions; uint8_t nb_of_failed_pdusessions;
pdu_session_param_t modify_pdusession[NR_NB_RB_MAX]; rrc_pdu_session_param_t modify_pdusession[NR_NB_RB_MAX];
/* list of e_rab to be setup by RRC layers */ /* list of e_rab to be setup by RRC layers */
/* list of pdu session to be setup by RRC layers */ /* list of pdu session to be setup by RRC layers */
nr_e_rab_param_t e_rab[NB_RB_MAX];//[S1AP_MAX_E_RAB]; nr_e_rab_param_t e_rab[NB_RB_MAX];//[S1AP_MAX_E_RAB];
pdu_session_param_t pduSession[NGAP_MAX_PDU_SESSION]; rrc_pdu_session_param_t pduSession[NGAP_MAX_PDU_SESSION];
//release e_rabs //release e_rabs
uint8_t nb_release_of_e_rabs; uint8_t nb_release_of_e_rabs;
e_rab_failed_t e_rabs_release_failed[S1AP_MAX_E_RAB]; e_rab_failed_t e_rabs_release_failed[S1AP_MAX_E_RAB];
...@@ -396,23 +395,13 @@ typedef struct gNB_RRC_UE_s { ...@@ -396,23 +395,13 @@ typedef struct gNB_RRC_UE_s {
struct NR_PhysicalCellGroupConfig *physicalCellGroupConfig; struct NR_PhysicalCellGroupConfig *physicalCellGroupConfig;
/* Nas Pdu */ /* Nas Pdu */
uint8_t nas_pdu_flag; ngap_pdu_t nas_pdu;
ngap_nas_pdu_t nas_pdu;
} gNB_RRC_UE_t; } gNB_RRC_UE_t;
typedef struct rrc_gNB_ue_context_s { typedef struct rrc_gNB_ue_context_s {
/* Tree related data */ /* Tree related data */
RB_ENTRY(rrc_gNB_ue_context_s) entries; RB_ENTRY(rrc_gNB_ue_context_s) entries;
/* Uniquely identifies the UE between MME and eNB within the eNB.
* This id is encoded on 24bits.
*/
ue_id_t ue_id_rnti;
// another key for protocol layers but should not be used as a key for RB tree
uid_t local_uid;
/* UE id for initial connection to NGAP */ /* UE id for initial connection to NGAP */
struct gNB_RRC_UE_s ue_context; struct gNB_RRC_UE_s ue_context;
} rrc_gNB_ue_context_t; } rrc_gNB_ue_context_t;
...@@ -492,13 +481,7 @@ typedef struct gNB_RRC_INST_s { ...@@ -492,13 +481,7 @@ typedef struct gNB_RRC_INST_s {
eth_params_t eth_params_s; eth_params_t eth_params_s;
rrc_gNB_carrier_data_t carrier; rrc_gNB_carrier_data_t carrier;
uid_allocator_t uid_allocator; uid_allocator_t uid_allocator;
RB_HEAD(rrc_nr_ue_tree_s, rrc_gNB_ue_context_s) rrc_ue_head; // ue_context tree key search by rnti RB_HEAD(rrc_nr_ue_tree_s, rrc_gNB_ue_context_s) rrc_ue_head; // ue_context tree key search by rnti
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 ;
/// NR cell id /// NR cell id
uint64_t nr_cellid; uint64_t nr_cellid;
......
...@@ -64,11 +64,11 @@ void rrc_gNB_generate_SgNBAdditionRequestAcknowledge( ...@@ -64,11 +64,11 @@ void rrc_gNB_generate_SgNBAdditionRequestAcknowledge(
rrc_gNB_ue_context_t *const ue_context_pP rrc_gNB_ue_context_t *const ue_context_pP
); );
struct rrc_gNB_ue_context_s *rrc_gNB_allocate_new_UE_context(gNB_RRC_INST *rrc_instance_pP); rrc_gNB_ue_context_t *rrc_gNB_allocate_new_UE_context(gNB_RRC_INST *rrc_instance_pP);
void rrc_parse_ue_capabilities(gNB_RRC_INST *rrc,NR_UE_CapabilityRAT_ContainerList_t *UE_CapabilityRAT_ContainerList, x2ap_ENDC_sgnb_addition_req_t *m, NR_CG_ConfigInfo_IEs_t * cg_config_info); void rrc_parse_ue_capabilities(gNB_RRC_INST *rrc,NR_UE_CapabilityRAT_ContainerList_t *UE_CapabilityRAT_ContainerList, x2ap_ENDC_sgnb_addition_req_t *m, NR_CG_ConfigInfo_IEs_t * cg_config_info);
void rrc_add_nsa_user(gNB_RRC_INST *rrc,struct rrc_gNB_ue_context_s *ue_context_p, x2ap_ENDC_sgnb_addition_req_t *m); void rrc_add_nsa_user(gNB_RRC_INST *rrc, rrc_gNB_ue_context_t *ue_context_p, x2ap_ENDC_sgnb_addition_req_t *m);
void rrc_remove_nsa_user(gNB_RRC_INST *rrc, int rnti); void rrc_remove_nsa_user(gNB_RRC_INST *rrc, int rnti);
...@@ -163,12 +163,6 @@ int nr_rrc_reconfiguration_req(rrc_gNB_ue_context_t *const ue_context_pP ...@@ -163,12 +163,6 @@ int nr_rrc_reconfiguration_req(rrc_gNB_ue_context_t *const ue_context_pP
const int dl_bwp_id, const int dl_bwp_id,
const int ul_bwp_id); const int ul_bwp_id);
int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP,
const uint8_t *buffer,
int buffer_length,
const uint8_t *du_to_cu_rrc_container,
int du_to_cu_rrc_container_length);
void void
rrc_gNB_generate_dedicatedRRCReconfiguration_release( rrc_gNB_generate_dedicatedRRCReconfiguration_release(
const protocol_ctxt_t *const ctxt_pP, const protocol_ctxt_t *const ctxt_pP,
...@@ -217,9 +211,5 @@ void nr_pdcp_add_drbs(eNB_flag_t enb_flag, ...@@ -217,9 +211,5 @@ void nr_pdcp_add_drbs(eNB_flag_t enb_flag,
uint8_t *const kUPint, uint8_t *const kUPint,
struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list); struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list);
int rrc_gNB_generate_pcch_msg(uint32_t tmsi, int rrc_gNB_generate_pcch_msg(uint32_t tmsi, uint8_t paging_drx, instance_t instance, uint8_t CC_id);
uint8_t paging_drx,
instance_t instance,
uint8_t CC_id);
#endif #endif
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -44,68 +44,64 @@ ...@@ -44,68 +44,64 @@
extern RAN_CONTEXT_t RC; extern RAN_CONTEXT_t RC;
int int rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP(const protocol_ctxt_t *const ctxt_pP, const gtpv1u_enb_create_tunnel_resp_t *const create_tunnel_resp_pP, uint8_t *inde_list)
rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP( {
const protocol_ctxt_t *const ctxt_pP, if (!create_tunnel_resp_pP) {
const gtpv1u_enb_create_tunnel_resp_t *const create_tunnel_resp_pP, LOG_E(NR_RRC, "create_tunnel_resp_pP error\n");
uint8_t *inde_list return -1;
) { }
int i;
struct rrc_gNB_ue_context_s *ue_context_p = NULL;
if (create_tunnel_resp_pP) {
LOG_D(RRC, PROTOCOL_RRC_CTXT_UE_FMT" RX CREATE_TUNNEL_RESP num tunnels %u \n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
create_tunnel_resp_pP->num_tunnels);
ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[ctxt_pP->module_id], ctxt_pP->rntiMaybeUEid);
for (i = 0; i < create_tunnel_resp_pP->num_tunnels; i++) {
ue_context_p->ue_context.gnb_gtp_teid[inde_list[i]] = create_tunnel_resp_pP->enb_S1u_teid[i];
ue_context_p->ue_context.gnb_gtp_addrs[inde_list[i]] = create_tunnel_resp_pP->enb_addr;
ue_context_p->ue_context.gnb_gtp_ebi[inde_list[i]] = create_tunnel_resp_pP->eps_bearer_id[i];
LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" rrc_eNB_process_GTPV1U_CREATE_TUNNEL_RESP tunnel (%u, %u) bearer UE context index %u, msg index %u, id %u, gtp addr len %d \n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
create_tunnel_resp_pP->enb_S1u_teid[i],
ue_context_p->ue_context.gnb_gtp_teid[inde_list[i]],
inde_list[i],
i,
create_tunnel_resp_pP->eps_bearer_id[i],
create_tunnel_resp_pP->enb_addr.length);
}
return 0; LOG_D(RRC, PROTOCOL_RRC_CTXT_UE_FMT " RX CREATE_TUNNEL_RESP num tunnels %u \n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), create_tunnel_resp_pP->num_tunnels);
} else { rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context_by_rnti(RC.nrrrc[ctxt_pP->module_id], ctxt_pP->rntiMaybeUEid);
if (!ue_context_p) {
LOG_E(NR_RRC, "UE table error\n");
return -1; return -1;
} }
for (int i = 0; i < create_tunnel_resp_pP->num_tunnels; i++) {
ue_context_p->ue_context.gnb_gtp_teid[inde_list[i]] = create_tunnel_resp_pP->enb_S1u_teid[i];
ue_context_p->ue_context.gnb_gtp_addrs[inde_list[i]] = create_tunnel_resp_pP->enb_addr;
ue_context_p->ue_context.gnb_gtp_ebi[inde_list[i]] = create_tunnel_resp_pP->eps_bearer_id[i];
LOG_I(RRC,
PROTOCOL_RRC_CTXT_UE_FMT " rrc_eNB_process_GTPV1U_CREATE_TUNNEL_RESP tunnel (%u, %u) bearer UE context index %u, msg index %u, id %u, gtp addr len %d \n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
create_tunnel_resp_pP->enb_S1u_teid[i],
ue_context_p->ue_context.gnb_gtp_teid[inde_list[i]],
inde_list[i],
i,
create_tunnel_resp_pP->eps_bearer_id[i],
create_tunnel_resp_pP->enb_addr.length);
}
return 0;
} }
int nr_rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP(const protocol_ctxt_t *const ctxt_pP, const gtpv1u_gnb_create_tunnel_resp_t *const create_tunnel_resp_pP, int offset) int nr_rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP(const protocol_ctxt_t *const ctxt_pP, const gtpv1u_gnb_create_tunnel_resp_t *const create_tunnel_resp_pP, int offset)
{ {
int i; if (!create_tunnel_resp_pP) {
struct rrc_gNB_ue_context_s *ue_context_p = NULL; LOG_E(NR_RRC, "create_tunnel_resp_pP error\n");
return -1;
if (create_tunnel_resp_pP) { }
LOG_D(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT" RX CREATE_TUNNEL_RESP num tunnels %u \n",
PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP),
create_tunnel_resp_pP->num_tunnels);
ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[ctxt_pP->module_id], ctxt_pP->rntiMaybeUEid);
for (i = 0; i < create_tunnel_resp_pP->num_tunnels; i++) {
ue_context_p->ue_context.gnb_gtp_teid[i + offset] = create_tunnel_resp_pP->gnb_NGu_teid[i];
ue_context_p->ue_context.gnb_gtp_addrs[i + offset] = create_tunnel_resp_pP->gnb_addr;
ue_context_p->ue_context.gnb_gtp_psi[i + offset] = create_tunnel_resp_pP->pdusession_id[i];
LOG_I(NR_RRC,
PROTOCOL_NR_RRC_CTXT_UE_FMT " nr_rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP tunnel (%u, %u) bearer UE context index %u, id %u, gtp addr len %d \n",
PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP),
create_tunnel_resp_pP->gnb_NGu_teid[i],
ue_context_p->ue_context.gnb_gtp_teid[i + offset],
i,
create_tunnel_resp_pP->pdusession_id[i],
create_tunnel_resp_pP->gnb_addr.length);
}
return 0; LOG_D(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT " RX CREATE_TUNNEL_RESP num tunnels %u \n", PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP), create_tunnel_resp_pP->num_tunnels);
} else { rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context_by_rnti(RC.nrrrc[ctxt_pP->module_id], ctxt_pP->rntiMaybeUEid);
if (!ue_context_p) {
LOG_E(NR_RRC, "UE table error\n");
return -1; return -1;
} }
for (int i = 0; i < create_tunnel_resp_pP->num_tunnels; i++) {
ue_context_p->ue_context.gnb_gtp_teid[i + offset] = create_tunnel_resp_pP->gnb_NGu_teid[i];
ue_context_p->ue_context.gnb_gtp_addrs[i + offset] = create_tunnel_resp_pP->gnb_addr;
ue_context_p->ue_context.gnb_gtp_psi[i + offset] = create_tunnel_resp_pP->pdusession_id[i];
LOG_I(NR_RRC,
PROTOCOL_NR_RRC_CTXT_UE_FMT " nr_rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP tunnel (%u, %u) bearer UE context index %u, id %u, gtp addr len %d \n",
PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP),
create_tunnel_resp_pP->gnb_NGu_teid[i],
ue_context_p->ue_context.gnb_gtp_teid[i + offset],
i,
create_tunnel_resp_pP->pdusession_id[i],
create_tunnel_resp_pP->gnb_addr.length);
}
return 0;
} }
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -40,18 +40,6 @@ ...@@ -40,18 +40,6 @@
#include "NR_UL-DCCH-Message.h" #include "NR_UL-DCCH-Message.h"
#include "NGAP_CauseRadioNetwork.h" #include "NGAP_CauseRadioNetwork.h"
typedef struct rrc_ue_ngap_ids_s {
/* Tree related data */
RB_ENTRY(rrc_ue_ngap_ids_s) entries;
// keys
uint16_t ue_initial_id;
uint32_t gNB_ue_ngap_id;
// value
rnti_t ue_rnti;
} rrc_ue_ngap_ids_t;
void void
rrc_gNB_send_NGAP_NAS_FIRST_REQ( rrc_gNB_send_NGAP_NAS_FIRST_REQ(
const protocol_ctxt_t *const ctxt_pP, const protocol_ctxt_t *const ctxt_pP,
...@@ -59,12 +47,7 @@ rrc_gNB_send_NGAP_NAS_FIRST_REQ( ...@@ -59,12 +47,7 @@ rrc_gNB_send_NGAP_NAS_FIRST_REQ(
NR_RRCSetupComplete_IEs_t *rrcSetupComplete NR_RRCSetupComplete_IEs_t *rrcSetupComplete
); );
int int rrc_gNB_process_NGAP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, instance_t instance);
rrc_gNB_process_NGAP_INITIAL_CONTEXT_SETUP_REQ(
MessageDef *msg_p,
const char *msg_name,
instance_t instance
);
void void
rrc_gNB_send_NGAP_INITIAL_CONTEXT_SETUP_RESP( rrc_gNB_send_NGAP_INITIAL_CONTEXT_SETUP_RESP(
...@@ -72,20 +55,7 @@ rrc_gNB_send_NGAP_INITIAL_CONTEXT_SETUP_RESP( ...@@ -72,20 +55,7 @@ rrc_gNB_send_NGAP_INITIAL_CONTEXT_SETUP_RESP(
rrc_gNB_ue_context_t *const ue_context_pP rrc_gNB_ue_context_t *const ue_context_pP
); );
int int rrc_gNB_process_NGAP_DOWNLINK_NAS(MessageDef *msg_p, instance_t instance, mui_t *rrc_gNB_mui);
rrc_gNB_process_security(
const protocol_ctxt_t *const ctxt_pP,
rrc_gNB_ue_context_t *const ue_context_pP,
ngap_security_capabilities_t *security_capabilities_pP
);
int
rrc_gNB_process_NGAP_DOWNLINK_NAS(
MessageDef *msg_p,
const char *msg_name,
instance_t instance,
mui_t *rrc_gNB_mui
);
void void
rrc_gNB_send_NGAP_UPLINK_NAS( rrc_gNB_send_NGAP_UPLINK_NAS(
...@@ -101,19 +71,9 @@ rrc_gNB_send_NGAP_PDUSESSION_SETUP_RESP( ...@@ -101,19 +71,9 @@ rrc_gNB_send_NGAP_PDUSESSION_SETUP_RESP(
uint8_t xid uint8_t xid
); );
void void rrc_gNB_process_NGAP_PDUSESSION_SETUP_REQ(MessageDef *msg_p, instance_t instance);
rrc_gNB_process_NGAP_PDUSESSION_SETUP_REQ(
MessageDef *msg_p,
const char *msg_name,
instance_t instance
);
int int rrc_gNB_process_NGAP_PDUSESSION_MODIFY_REQ(MessageDef *msg_p, instance_t instance);
rrc_gNB_process_NGAP_PDUSESSION_MODIFY_REQ(
MessageDef *msg_p,
const char *msg_name,
instance_t instance
);
int int
rrc_gNB_send_NGAP_PDUSESSION_MODIFY_RESP( rrc_gNB_send_NGAP_PDUSESSION_MODIFY_RESP(
...@@ -128,38 +88,13 @@ rrc_gNB_modify_dedicatedRRCReconfiguration( ...@@ -128,38 +88,13 @@ rrc_gNB_modify_dedicatedRRCReconfiguration(
rrc_gNB_ue_context_t *ue_context_pP rrc_gNB_ue_context_t *ue_context_pP
); );
void rrc_gNB_send_NGAP_UE_CONTEXT_RELEASE_REQ(const module_id_t gnb_mod_idP, const rrc_gNB_ue_context_t *const ue_context_pP, const ngap_Cause_t causeP, const long cause_valueP);
void int rrc_gNB_process_NGAP_UE_CONTEXT_RELEASE_REQ(MessageDef *msg_p, instance_t instance);
rrc_gNB_send_NGAP_UE_CONTEXT_RELEASE_REQ(
const module_id_t gnb_mod_idP,
const rrc_gNB_ue_context_t *const ue_context_pP,
const ngap_Cause_t causeP,
const long cause_valueP
);
int
rrc_gNB_process_NGAP_UE_CONTEXT_RELEASE_REQ (
MessageDef *msg_p,
const char *msg_name,
instance_t instance
);
int
rrc_gNB_process_NGAP_UE_CONTEXT_RELEASE_COMMAND(
MessageDef *msg_p,
const char *msg_name,
instance_t instance
);
void rrc_gNB_send_NGAP_UE_CONTEXT_RELEASE_COMPLETE( int rrc_gNB_process_NGAP_UE_CONTEXT_RELEASE_COMMAND(MessageDef *msg_p, instance_t instance);
instance_t instance,
uint32_t gNB_ue_ngap_id);
void void rrc_gNB_send_NGAP_UE_CONTEXT_RELEASE_COMPLETE(instance_t instance, uint32_t gNB_ue_ngap_id);
rrc_gNB_NGAP_remove_ue_ids(
gNB_RRC_INST *const rrc_instance_pP,
struct rrc_ue_ngap_ids_s *const ue_ids_pP
);
void void
rrc_gNB_send_NGAP_UE_CAPABILITIES_IND( rrc_gNB_send_NGAP_UE_CAPABILITIES_IND(
...@@ -168,12 +103,7 @@ rrc_gNB_send_NGAP_UE_CAPABILITIES_IND( ...@@ -168,12 +103,7 @@ rrc_gNB_send_NGAP_UE_CAPABILITIES_IND(
NR_UL_DCCH_Message_t *const ul_dcch_msg NR_UL_DCCH_Message_t *const ul_dcch_msg
); );
int int rrc_gNB_process_NGAP_PDUSESSION_RELEASE_COMMAND(MessageDef *msg_p, instance_t instance);
rrc_gNB_process_NGAP_PDUSESSION_RELEASE_COMMAND(
MessageDef *msg_p,
const char *msg_name,
instance_t instance
);
void void
rrc_gNB_send_NGAP_PDUSESSION_RELEASE_RESPONSE( rrc_gNB_send_NGAP_PDUSESSION_RELEASE_RESPONSE(
...@@ -189,17 +119,6 @@ nr_rrc_pdcp_config_security( ...@@ -189,17 +119,6 @@ nr_rrc_pdcp_config_security(
const uint8_t send_security_mode_command const uint8_t send_security_mode_command
); );
struct rrc_gNB_ue_context_s * int rrc_gNB_process_PAGING_IND(MessageDef *msg_p, instance_t instance);
rrc_gNB_get_ue_context_from_ngap_ids(
const instance_t instanceP,
const uint16_t ue_initial_idP,
const uint32_t gNB_ue_ngap_idP
);
int
rrc_gNB_process_PAGING_IND(
MessageDef *msg_p,
const char *msg_name,
instance_t instance);
#endif #endif
This diff is collapsed.
...@@ -34,52 +34,23 @@ ...@@ -34,52 +34,23 @@
#include "COMMON/platform_types.h" #include "COMMON/platform_types.h"
#include "nr_rrc_defs.h" #include "nr_rrc_defs.h"
int rrc_gNB_compare_ue_rnti_id( int rrc_gNB_compare_ue_rnti_id(rrc_gNB_ue_context_t* c1_pP, rrc_gNB_ue_context_t* c2_pP);
struct rrc_gNB_ue_context_s* c1_pP,
struct rrc_gNB_ue_context_s* c2_pP
);
RB_PROTOTYPE(rrc_nr_ue_tree_s, rrc_gNB_ue_context_s, entries, rrc_gNB_compare_ue_rnti_id); RB_PROTOTYPE(rrc_nr_ue_tree_s, rrc_gNB_ue_context_s, entries, rrc_gNB_compare_ue_rnti_id);
struct rrc_gNB_ue_context_s* rrc_gNB_ue_context_t* rrc_gNB_allocate_new_ue_context(gNB_RRC_INST* rrc_instance_pP);
rrc_gNB_allocate_new_UE_context(
gNB_RRC_INST* rrc_instance_pP
);
struct rrc_gNB_ue_context_s* rrc_gNB_ue_context_t* rrc_gNB_get_ue_context(gNB_RRC_INST* rrc_instance_pP, ue_id_t ue);
rrc_gNB_get_ue_context( rrc_gNB_ue_context_t* rrc_gNB_get_ue_context_by_rnti(gNB_RRC_INST* rrc_instance_pP, rnti_t rntiP);
gNB_RRC_INST* rrc_instance_pP,
rnti_t rntiP
);
void rrc_gNB_free_mem_UE_context( void rrc_gNB_free_mem_ue_context(rrc_gNB_ue_context_t* const ue_context_pP);
const protocol_ctxt_t *const ctxt_pP,
struct rrc_gNB_ue_context_s *const ue_context_pP
);
void rrc_gNB_remove_ue_context( void rrc_gNB_remove_ue_context(gNB_RRC_INST* rrc_instance_pP, rrc_gNB_ue_context_t* ue_context_pP);
const protocol_ctxt_t* const ctxt_pP,
gNB_RRC_INST* rrc_instance_pP,
struct rrc_gNB_ue_context_s* ue_context_pP
);
struct rrc_gNB_ue_context_s * rrc_gNB_ue_context_t* rrc_gNB_ue_context_random_exist(gNB_RRC_INST* rrc_instance_pP, const uint64_t ue_identityP);
rrc_gNB_ue_context_random_exist(
gNB_RRC_INST *rrc_instance_pP,
const uint64_t ue_identityP
);
struct rrc_gNB_ue_context_s * rrc_gNB_ue_context_t* rrc_gNB_ue_context_5g_s_tmsi_exist(gNB_RRC_INST* rrc_instance_pP, const uint64_t s_TMSI);
rrc_gNB_ue_context_5g_s_tmsi_exist( void rrc_gNB_update_ue_context_rnti(rnti_t rnti, gNB_RRC_INST* rrc_instance_pP, uint32_t gNB_ue_ngap_id);
gNB_RRC_INST *rrc_instance_pP, rrc_gNB_ue_context_t* rrc_gNB_create_ue_context(rnti_t rnti, gNB_RRC_INST* rrc_instance_pP, const uint64_t ue_identityP);
const uint64_t s_TMSI
);
struct rrc_gNB_ue_context_s *
rrc_gNB_get_next_free_ue_context(
const protocol_ctxt_t *const ctxt_pP,
gNB_RRC_INST *rrc_instance_pP,
const uint64_t ue_identityP
);
#endif #endif
This diff is collapsed.
...@@ -22,19 +22,30 @@ ...@@ -22,19 +22,30 @@
#include "rrc_gNB_radio_bearers.h" #include "rrc_gNB_radio_bearers.h"
#include "oai_asn1.h" #include "oai_asn1.h"
NR_DRB_ToAddMod_t *generateDRB(gNB_RRC_UE_t *ue, uint8_t drb_id, pdu_session_param_t *pduSession, bool enable_sdap, int do_drb_integrity, int do_drb_ciphering) rrc_pdu_session_param_t *find_pduSession(gNB_RRC_UE_t *ue, int id, bool create)
{ {
NR_DRB_ToAddMod_t *DRB_config = NULL; int j;
NR_SDAP_Config_t *SDAP_config = NULL; for (j = 0; j < ue->nb_of_pdusessions; j++)
if (id == ue->pduSession[j].param.pdusession_id)
break;
if (j == ue->nb_of_pdusessions && create)
ue->nb_of_pdusessions++;
else
return NULL;
AssertFatal(ue->nb_of_pdusessions < NGAP_MAX_PDU_SESSION, "");
return ue->pduSession + j;
}
DRB_config = CALLOC(1, sizeof(*DRB_config)); NR_DRB_ToAddMod_t *generateDRB(gNB_RRC_UE_t *ue, uint8_t drb_id, rrc_pdu_session_param_t *pduSession, bool enable_sdap, int do_drb_integrity, int do_drb_ciphering)
{
NR_DRB_ToAddMod_t *DRB_config = CALLOC(1, sizeof(*DRB_config));
DRB_config->drb_Identity = drb_id; DRB_config->drb_Identity = drb_id;
DRB_config->cnAssociation = CALLOC(1, sizeof(*DRB_config->cnAssociation)); asn1cCalloc(DRB_config->cnAssociation, association);
DRB_config->cnAssociation->present = NR_DRB_ToAddMod__cnAssociation_PR_sdap_Config; association->present = NR_DRB_ToAddMod__cnAssociation_PR_sdap_Config;
/* SDAP Configuration */ /* SDAP Configuration */
SDAP_config = CALLOC(1, sizeof(NR_SDAP_Config_t)); NR_SDAP_Config_t *SDAP_config = CALLOC(1, sizeof(NR_SDAP_Config_t));
SDAP_config->mappedQoS_FlowsToAdd = calloc(1, sizeof(struct NR_SDAP_Config__mappedQoS_FlowsToAdd)); asn1cCalloc(SDAP_config->mappedQoS_FlowsToAdd, sdapFlows);
SDAP_config->pdu_Session = pduSession->param.pdusession_id; SDAP_config->pdu_Session = pduSession->param.pdusession_id;
...@@ -50,53 +61,36 @@ NR_DRB_ToAddMod_t *generateDRB(gNB_RRC_UE_t *ue, uint8_t drb_id, pdu_session_par ...@@ -50,53 +61,36 @@ NR_DRB_ToAddMod_t *generateDRB(gNB_RRC_UE_t *ue, uint8_t drb_id, pdu_session_par
for (int qos_flow_index = 0; qos_flow_index < pduSession->param.nb_qos; qos_flow_index++) for (int qos_flow_index = 0; qos_flow_index < pduSession->param.nb_qos; qos_flow_index++)
{ {
NR_QFI_t *qfi = calloc(1, sizeof(NR_QFI_t)); asn1cSequenceAdd(sdapFlows->list, NR_QFI_t, qfi);
*qfi = pduSession->param.qos[qos_flow_index].qfi; *qfi = pduSession->param.qos[qos_flow_index].qfi;
asn1cSeqAdd(&SDAP_config->mappedQoS_FlowsToAdd->list, qfi);
if(pduSession->param.qos[qos_flow_index].fiveQI > 5) if(pduSession->param.qos[qos_flow_index].fiveQI > 5)
pduSession->param.used_drbs[drb_id - 1] = DRB_ACTIVE_NONGBR; pduSession->param.used_drbs[drb_id - 1] = DRB_ACTIVE_NONGBR;
else else
pduSession->param.used_drbs[drb_id - 1] = DRB_ACTIVE; pduSession->param.used_drbs[drb_id - 1] = DRB_ACTIVE;
} }
SDAP_config->mappedQoS_FlowsToRelease = NULL; association->choice.sdap_Config = SDAP_config;
DRB_config->cnAssociation->choice.sdap_Config = SDAP_config;
/* PDCP Configuration */ /* PDCP Configuration */
DRB_config->reestablishPDCP = NULL; asn1cCalloc(DRB_config->pdcp_Config, pdcpConfig);
DRB_config->recoverPDCP = NULL; asn1cCalloc(pdcpConfig->drb, drb);
DRB_config->pdcp_Config = calloc(1, sizeof(*DRB_config->pdcp_Config));
DRB_config->pdcp_Config->drb = calloc(1,sizeof(*DRB_config->pdcp_Config->drb)); asn1cCallocOne(drb->discardTimer, NR_PDCP_Config__drb__discardTimer_infinity);
DRB_config->pdcp_Config->drb->discardTimer = calloc(1, sizeof(*DRB_config->pdcp_Config->drb->discardTimer)); asn1cCallocOne(drb->pdcp_SN_SizeUL, NR_PDCP_Config__drb__pdcp_SN_SizeUL_len18bits);
*DRB_config->pdcp_Config->drb->discardTimer = NR_PDCP_Config__drb__discardTimer_infinity; asn1cCallocOne(drb->pdcp_SN_SizeDL, NR_PDCP_Config__drb__pdcp_SN_SizeDL_len18bits);
DRB_config->pdcp_Config->drb->pdcp_SN_SizeUL = calloc(1, sizeof(*DRB_config->pdcp_Config->drb->pdcp_SN_SizeUL));
*DRB_config->pdcp_Config->drb->pdcp_SN_SizeUL = NR_PDCP_Config__drb__pdcp_SN_SizeUL_len18bits; drb->headerCompression.present = NR_PDCP_Config__drb__headerCompression_PR_notUsed;
DRB_config->pdcp_Config->drb->pdcp_SN_SizeDL = calloc(1, sizeof(*DRB_config->pdcp_Config->drb->pdcp_SN_SizeDL)); drb->headerCompression.choice.notUsed = 0;
*DRB_config->pdcp_Config->drb->pdcp_SN_SizeDL = NR_PDCP_Config__drb__pdcp_SN_SizeDL_len18bits;
asn1cCallocOne(pdcpConfig->t_Reordering, NR_PDCP_Config__t_Reordering_ms100);
DRB_config->pdcp_Config->drb->headerCompression.present = NR_PDCP_Config__drb__headerCompression_PR_notUsed;
DRB_config->pdcp_Config->drb->headerCompression.choice.notUsed = 0;
DRB_config->pdcp_Config->drb->integrityProtection = NULL;
DRB_config->pdcp_Config->drb->statusReportRequired = NULL;
DRB_config->pdcp_Config->drb->outOfOrderDelivery = NULL;
DRB_config->pdcp_Config->moreThanOneRLC = NULL;
DRB_config->pdcp_Config->t_Reordering = calloc(1, sizeof(*DRB_config->pdcp_Config->t_Reordering));
*DRB_config->pdcp_Config->t_Reordering = NR_PDCP_Config__t_Reordering_ms100;
DRB_config->pdcp_Config->ext1 = NULL;
if (do_drb_integrity) { if (do_drb_integrity) {
DRB_config->pdcp_Config->drb->integrityProtection = calloc(1, sizeof(*DRB_config->pdcp_Config->drb->integrityProtection)); asn1cCallocOne(drb->integrityProtection, NR_PDCP_Config__drb__integrityProtection_enabled);
*DRB_config->pdcp_Config->drb->integrityProtection = NR_PDCP_Config__drb__integrityProtection_enabled;
} }
if (!do_drb_ciphering) { if (!do_drb_ciphering) {
DRB_config->pdcp_Config->ext1 = calloc(1, sizeof(*DRB_config->pdcp_Config->ext1)); asn1cCalloc(pdcpConfig->ext1, ext1);
DRB_config->pdcp_Config->ext1->cipheringDisabled = calloc(1, sizeof(*DRB_config->pdcp_Config->ext1->cipheringDisabled)); asn1cCallocOne(ext1->cipheringDisabled, NR_PDCP_Config__ext1__cipheringDisabled_true);
*DRB_config->pdcp_Config->ext1->cipheringDisabled = NR_PDCP_Config__ext1__cipheringDisabled_true;
} }
ue->DRB_active[drb_id-1] = DRB_ACTIVE; ue->DRB_active[drb_id-1] = DRB_ACTIVE;
...@@ -104,7 +98,7 @@ NR_DRB_ToAddMod_t *generateDRB(gNB_RRC_UE_t *ue, uint8_t drb_id, pdu_session_par ...@@ -104,7 +98,7 @@ NR_DRB_ToAddMod_t *generateDRB(gNB_RRC_UE_t *ue, uint8_t drb_id, pdu_session_par
return DRB_config; return DRB_config;
} }
uint8_t next_available_drb(gNB_RRC_UE_t *ue, pdu_session_param_t *pdusession, bool is_gbr) uint8_t next_available_drb(gNB_RRC_UE_t *ue, rrc_pdu_session_param_t *pdusession, bool is_gbr)
{ {
uint8_t drb_id; uint8_t drb_id;
......
...@@ -35,10 +35,10 @@ ...@@ -35,10 +35,10 @@
#define GBR_FLOW (1) #define GBR_FLOW (1)
#define NONGBR_FLOW (0) #define NONGBR_FLOW (0)
NR_DRB_ToAddMod_t *generateDRB(gNB_RRC_UE_t *rrc_ue, uint8_t drb_id, pdu_session_param_t *pduSession, bool enable_sdap, int do_drb_integrity, int do_drb_ciphering); NR_DRB_ToAddMod_t *generateDRB(gNB_RRC_UE_t *rrc_ue, uint8_t drb_id, rrc_pdu_session_param_t *pduSession, bool enable_sdap, int do_drb_integrity, int do_drb_ciphering);
uint8_t next_available_drb(gNB_RRC_UE_t *ue, rrc_pdu_session_param_t *pdusession, bool is_gbr);
uint8_t next_available_drb(gNB_RRC_UE_t *ue, pdu_session_param_t *pdusession, bool is_gbr);
bool drb_is_active(gNB_RRC_UE_t *ue, uint8_t drb_id); bool drb_is_active(gNB_RRC_UE_t *ue, uint8_t drb_id);
rrc_pdu_session_param_t *find_pduSession(gNB_RRC_UE_t *ue, int id, bool create);
#endif #endif
...@@ -435,14 +435,9 @@ nr_sdap_entity_t *new_nr_sdap_entity(int is_gnb, bool has_sdap_rx, bool has_sdap ...@@ -435,14 +435,9 @@ nr_sdap_entity_t *new_nr_sdap_entity(int is_gnb, bool has_sdap_rx, bool has_sdap
if(is_defaultDRB) { if(is_defaultDRB) {
sdap_entity->default_drb = drb_identity; sdap_entity->default_drb = drb_identity;
LOG_I(SDAP, "Default DRB for the created SDAP entity: %ld \n", sdap_entity->default_drb); LOG_I(SDAP, "Default DRB for the created SDAP entity: %ld \n", sdap_entity->default_drb);
LOG_D(SDAP, "RRC updating mapping rules: %d\n", mappedQFIs2AddCount);
if(mappedQFIs2AddCount) { for (int i = 0; i < mappedQFIs2AddCount; i++)
LOG_D(SDAP, "RRC updating mapping rules\n"); sdap_entity->qfi2drb_map_update(sdap_entity, mapped_qfi_2_add[i], sdap_entity->default_drb, has_sdap_rx, has_sdap_tx);
for (int i = 0; i < mappedQFIs2AddCount; i++)
{
sdap_entity->qfi2drb_map_update(sdap_entity, mapped_qfi_2_add[i], sdap_entity->default_drb, has_sdap_rx, has_sdap_tx);
}
}
} }
sdap_entity->next_entity = sdap_info.sdap_entity_llist; sdap_entity->next_entity = sdap_info.sdap_entity_llist;
......
...@@ -43,7 +43,7 @@ void x2ap_eNB_itti_send_sctp_data_req(instance_t instance, int32_t assoc_id, uin ...@@ -43,7 +43,7 @@ void x2ap_eNB_itti_send_sctp_data_req(instance_t instance, int32_t assoc_id, uin
sctp_data_req->assoc_id = assoc_id; sctp_data_req->assoc_id = assoc_id;
sctp_data_req->buffer = buffer; sctp_data_req->buffer = buffer;
sctp_data_req->buffer_length = buffer_length; sctp_data_req->buffer_length = buffer_length;
sctp_data_req->stream = stream; sctp_data_req->stream = stream;
itti_send_msg_to_task(TASK_SCTP, instance, message_p); itti_send_msg_to_task(TASK_SCTP, instance, message_p);
} }
......
...@@ -859,6 +859,7 @@ void *nas_nrue_task(void *args_p) ...@@ -859,6 +859,7 @@ void *nas_nrue_task(void *args_p)
instance = msg_p->ittiMsgHeader.originInstance; instance = msg_p->ittiMsgHeader.originInstance;
Mod_id = instance ; Mod_id = instance ;
uicc_t *uicc=checkUicc(Mod_id); uicc_t *uicc=checkUicc(Mod_id);
LOG_I(NAS, "[UE %d] Received %s\n", Mod_id, ITTI_MSG_NAME(msg_p));
if (instance == INSTANCE_DEFAULT) { if (instance == INSTANCE_DEFAULT) {
printf("%s:%d: FATAL: instance is INSTANCE_DEFAULT, should not happen.\n", printf("%s:%d: FATAL: instance is INSTANCE_DEFAULT, should not happen.\n",
...@@ -867,84 +868,83 @@ void *nas_nrue_task(void *args_p) ...@@ -867,84 +868,83 @@ void *nas_nrue_task(void *args_p)
} }
switch (ITTI_MSG_ID(msg_p)) { switch (ITTI_MSG_ID(msg_p)) {
case INITIALIZE_MESSAGE: case INITIALIZE_MESSAGE:
LOG_I(NAS, "[UE %d] Received %s\n", Mod_id, ITTI_MSG_NAME (msg_p));
break;
break;
case TERMINATE_MESSAGE:
case TERMINATE_MESSAGE: itti_exit_task();
itti_exit_task (); break;
break;
case MESSAGE_TEST:
case MESSAGE_TEST: break;
LOG_I(NAS, "[UE %d] Received %s\n", Mod_id, ITTI_MSG_NAME (msg_p));
break; case NAS_CELL_SELECTION_CNF:
LOG_I(NAS,
case NAS_CELL_SELECTION_CNF: "[UE %d] Received %s: errCode %u, cellID %u, tac %u\n",
LOG_I(NAS, "[UE %d] Received %s: errCode %u, cellID %u, tac %u\n", Mod_id, ITTI_MSG_NAME (msg_p), Mod_id,
NAS_CELL_SELECTION_CNF (msg_p).errCode, NAS_CELL_SELECTION_CNF (msg_p).cellID, NAS_CELL_SELECTION_CNF (msg_p).tac); ITTI_MSG_NAME(msg_p),
// as_stmsi_t s_tmsi={0, 0}; NAS_CELL_SELECTION_CNF(msg_p).errCode,
// as_nas_info_t nas_info; NAS_CELL_SELECTION_CNF(msg_p).cellID,
// plmn_t plmnID={0, 0, 0, 0}; NAS_CELL_SELECTION_CNF(msg_p).tac);
// generateRegistrationRequest(&nas_info); // as_stmsi_t s_tmsi={0, 0};
// nr_nas_itti_nas_establish_req(0, AS_TYPE_ORIGINATING_SIGNAL, s_tmsi, plmnID, nas_info.data, nas_info.length, 0); // as_nas_info_t nas_info;
break; // plmn_t plmnID={0, 0, 0, 0};
// generateRegistrationRequest(&nas_info);
case NAS_CELL_SELECTION_IND: // nr_nas_itti_nas_establish_req(0, AS_TYPE_ORIGINATING_SIGNAL, s_tmsi, plmnID, nas_info.data, nas_info.length, 0);
LOG_I(NAS, "[UE %d] Received %s: cellID %u, tac %u\n", Mod_id, ITTI_MSG_NAME (msg_p), break;
NAS_CELL_SELECTION_IND (msg_p).cellID, NAS_CELL_SELECTION_IND (msg_p).tac);
case NAS_CELL_SELECTION_IND:
/* TODO not processed by NAS currently */ LOG_I(NAS, "[UE %d] Received %s: cellID %u, tac %u\n", Mod_id, ITTI_MSG_NAME(msg_p), NAS_CELL_SELECTION_IND(msg_p).cellID, NAS_CELL_SELECTION_IND(msg_p).tac);
break;
/* TODO not processed by NAS currently */
case NAS_PAGING_IND: break;
LOG_I(NAS, "[UE %d] Received %s: cause %u\n", Mod_id, ITTI_MSG_NAME (msg_p),
NAS_PAGING_IND (msg_p).cause); case NAS_PAGING_IND:
LOG_I(NAS, "[UE %d] Received %s: cause %u\n", Mod_id, ITTI_MSG_NAME(msg_p), NAS_PAGING_IND(msg_p).cause);
/* TODO not processed by NAS currently */
break; /* TODO not processed by NAS currently */
break;
case NAS_CONN_ESTABLI_CNF:
{ case NAS_CONN_ESTABLI_CNF: {
LOG_I(NAS, "[UE %d] Received %s: errCode %u, length %u\n", Mod_id, ITTI_MSG_NAME (msg_p), LOG_I(NAS, "[UE %d] Received %s: errCode %u, length %u\n", Mod_id, ITTI_MSG_NAME(msg_p), NAS_CONN_ESTABLI_CNF(msg_p).errCode, NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.length);
NAS_CONN_ESTABLI_CNF (msg_p).errCode, NAS_CONN_ESTABLI_CNF (msg_p).nasMsg.length);
pdu_buffer = NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.data;
pdu_buffer = NAS_CONN_ESTABLI_CNF (msg_p).nasMsg.data; msg_type = get_msg_type(pdu_buffer, NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.length);
msg_type = get_msg_type(pdu_buffer, NAS_CONN_ESTABLI_CNF (msg_p).nasMsg.length);
if (msg_type == REGISTRATION_ACCEPT) {
if(msg_type == REGISTRATION_ACCEPT){ LOG_I(NAS, "[UE] Received REGISTRATION ACCEPT message\n");
LOG_I(NAS, "[UE] Received REGISTRATION ACCEPT message\n");
as_nas_info_t initialNasMsg;
as_nas_info_t initialNasMsg; memset(&initialNasMsg, 0, sizeof(as_nas_info_t));
memset(&initialNasMsg, 0, sizeof(as_nas_info_t)); generateRegistrationComplete(Mod_id, &initialNasMsg, NULL);
generateRegistrationComplete(Mod_id,&initialNasMsg, NULL); if (initialNasMsg.length > 0) {
if(initialNasMsg.length > 0){ MessageDef *message_p;
MessageDef *message_p; message_p = itti_alloc_new_message(TASK_NAS_NRUE, 0, NAS_UPLINK_DATA_REQ);
message_p = itti_alloc_new_message(TASK_NAS_NRUE, 0, NAS_UPLINK_DATA_REQ); NAS_UPLINK_DATA_REQ(message_p).UEid = Mod_id;
NAS_UPLINK_DATA_REQ(message_p).UEid = Mod_id; NAS_UPLINK_DATA_REQ(message_p).nasMsg.data = (uint8_t *)initialNasMsg.data;
NAS_UPLINK_DATA_REQ(message_p).nasMsg.data = (uint8_t *)initialNasMsg.data; NAS_UPLINK_DATA_REQ(message_p).nasMsg.length = initialNasMsg.length;
NAS_UPLINK_DATA_REQ(message_p).nasMsg.length = initialNasMsg.length; itti_send_msg_to_task(TASK_RRC_NRUE, instance, message_p);
itti_send_msg_to_task(TASK_RRC_NRUE, instance, message_p); LOG_I(NAS, "Send NAS_UPLINK_DATA_REQ message(RegistrationComplete)\n");
LOG_I(NAS, "Send NAS_UPLINK_DATA_REQ message(RegistrationComplete)\n"); }
as_nas_info_t pduEstablishMsg;
memset(&pduEstablishMsg, 0, sizeof(as_nas_info_t));
generatePduSessionEstablishRequest(Mod_id, uicc, &pduEstablishMsg);
if (pduEstablishMsg.length > 0) {
MessageDef *message_p;
message_p = itti_alloc_new_message(TASK_NAS_NRUE, 0, NAS_UPLINK_DATA_REQ);
NAS_UPLINK_DATA_REQ(message_p).UEid = Mod_id;
NAS_UPLINK_DATA_REQ(message_p).nasMsg.data = (uint8_t *)pduEstablishMsg.data;
NAS_UPLINK_DATA_REQ(message_p).nasMsg.length = pduEstablishMsg.length;
itti_send_msg_to_task(TASK_RRC_NRUE, instance, message_p);
LOG_I(NAS, "Send NAS_UPLINK_DATA_REQ message(PduSessionEstablishRequest)\n");
}
} else if (msg_type == FGS_PDU_SESSION_ESTABLISHMENT_ACC) {
capture_pdu_session_establishment_accept_msg(pdu_buffer, NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.length);
} }
as_nas_info_t pduEstablishMsg; break;
memset(&pduEstablishMsg, 0, sizeof(as_nas_info_t));
generatePduSessionEstablishRequest(Mod_id, uicc, &pduEstablishMsg);
if(pduEstablishMsg.length > 0){
MessageDef *message_p;
message_p = itti_alloc_new_message(TASK_NAS_NRUE, 0, NAS_UPLINK_DATA_REQ);
NAS_UPLINK_DATA_REQ(message_p).UEid = Mod_id;
NAS_UPLINK_DATA_REQ(message_p).nasMsg.data = (uint8_t *)pduEstablishMsg.data;
NAS_UPLINK_DATA_REQ(message_p).nasMsg.length = pduEstablishMsg.length;
itti_send_msg_to_task(TASK_RRC_NRUE, instance, message_p);
LOG_I(NAS, "Send NAS_UPLINK_DATA_REQ message(PduSessionEstablishRequest)\n");
}
} else if(msg_type == FGS_PDU_SESSION_ESTABLISHMENT_ACC){
capture_pdu_session_establishment_accept_msg(pdu_buffer, NAS_CONN_ESTABLI_CNF (msg_p).nasMsg.length);
}
break;
} }
case NAS_CONN_RELEASE_IND: case NAS_CONN_RELEASE_IND:
......
...@@ -113,27 +113,27 @@ extern int asn1_xer_print; ...@@ -113,27 +113,27 @@ extern int asn1_xer_print;
# define NGAP_DEBUG(x, args...) do { fprintf(stdout, "[NGAP][D]"x, ##args); } while(0) # define NGAP_DEBUG(x, args...) do { fprintf(stdout, "[NGAP][D]"x, ##args); } while(0)
#endif #endif
#define NGAP_FIND_PROTOCOLIE_BY_ID(IE_TYPE, ie, container, IE_ID, mandatory) \
do { \
IE_TYPE **ptr; \
ie = NULL; \
for (ptr = container->protocolIEs.list.array; ptr < &container->protocolIEs.list.array[container->protocolIEs.list.count]; ptr++) { \
if ((*ptr)->id == IE_ID) { \
ie = *ptr; \
break; \
} \
} \
if (ie == NULL) { \
if (mandatory) { \
AssertFatal(NGAP, "NGAP_FIND_PROTOCOLIE_BY_ID ie is NULL (searching for ie: %ld)\n", IE_ID); \
} else { \
NGAP_INFO("NGAP_FIND_PROTOCOLIE_BY_ID ie is NULL (searching for ie: %ld)\n", IE_ID); \
} \
} \
} while (0); \
if (mandatory && !ie) \
return -1
#define NGAP_FIND_PROTOCOLIE_BY_ID(IE_TYPE, ie, container, IE_ID, mandatory) \
do {\
IE_TYPE **ptr; \
ie = NULL; \
for (ptr = container->protocolIEs.list.array; \
ptr < &container->protocolIEs.list.array[container->protocolIEs.list.count]; \
ptr++) { \
if((*ptr)->id == IE_ID) { \
ie = *ptr; \
break; \
} \
} \
if (ie == NULL ) { \
if (mandatory) {\
NGAP_ERROR("NGAP_FIND_PROTOCOLIE_BY_ID: %s %d: ie is NULL (searching for ie: %ld)\n",__FILE__,__LINE__, IE_ID);\
abort();\
}\
else NGAP_INFO("NGAP_FIND_PROTOCOLIE_BY_ID: %s %d: ie is NULL (searching for ie: %ld)\n",__FILE__,__LINE__, IE_ID);\
} \
} while(0)
/** \brief Function callback prototype. /** \brief Function callback prototype.
**/ **/
typedef int (*ngap_message_decoded_callback)( typedef int (*ngap_message_decoded_callback)(
......
...@@ -162,7 +162,6 @@ void ngap_gNB_handle_register_gNB(instance_t instance, ngap_register_gnb_req_t * ...@@ -162,7 +162,6 @@ void ngap_gNB_handle_register_gNB(instance_t instance, ngap_register_gnb_req_t *
} else { } else {
new_instance = calloc(1, sizeof(ngap_gNB_instance_t)); new_instance = calloc(1, sizeof(ngap_gNB_instance_t));
DevAssert(new_instance != NULL); DevAssert(new_instance != NULL);
RB_INIT(&new_instance->ngap_ue_head);
RB_INIT(&new_instance->ngap_amf_head); RB_INIT(&new_instance->ngap_amf_head);
/* Copy usefull parameters */ /* Copy usefull parameters */
new_instance->instance = instance; new_instance->instance = instance;
...@@ -276,127 +275,88 @@ void *ngap_gNB_process_itti_msg(void *notUsed) { ...@@ -276,127 +275,88 @@ void *ngap_gNB_process_itti_msg(void *notUsed) {
MessageDef *received_msg = NULL; MessageDef *received_msg = NULL;
int result; int result;
itti_receive_msg(TASK_NGAP, &received_msg); itti_receive_msg(TASK_NGAP, &received_msg);
if (received_msg) {
instance_t instance = ITTI_MSG_DESTINATION_INSTANCE(received_msg);
LOG_D(RRC, "Received message %s\n", ITTI_MSG_NAME(received_msg));
switch (ITTI_MSG_ID(received_msg)) {
case TERMINATE_MESSAGE:
NGAP_WARN(" *** Exiting NGAP thread\n");
itti_exit_task();
break;
switch (ITTI_MSG_ID(received_msg)) { case NGAP_REGISTER_GNB_REQ:
case TERMINATE_MESSAGE: /* Register a new gNB.
NGAP_WARN(" *** Exiting NGAP thread\n"); * in Virtual mode gNBs will be distinguished using the mod_id/
itti_exit_task(); * Each gNB has to send an NGAP_REGISTER_GNB message with its
break; * own parameters.
*/
case NGAP_REGISTER_GNB_REQ: { ngap_gNB_handle_register_gNB(instance, &NGAP_REGISTER_GNB_REQ(received_msg));
/* Register a new gNB. break;
* in Virtual mode gNBs will be distinguished using the mod_id/
* Each gNB has to send an NGAP_REGISTER_GNB message with its
* own parameters.
*/
ngap_gNB_handle_register_gNB(ITTI_MSG_DESTINATION_INSTANCE(received_msg),
&NGAP_REGISTER_GNB_REQ(received_msg));
}
break;
case SCTP_NEW_ASSOCIATION_RESP: { case SCTP_NEW_ASSOCIATION_RESP:
ngap_gNB_handle_sctp_association_resp(ITTI_MSG_DESTINATION_INSTANCE(received_msg), ngap_gNB_handle_sctp_association_resp(instance, &received_msg->ittiMsg.sctp_new_association_resp);
&received_msg->ittiMsg.sctp_new_association_resp); break;
}
break;
case SCTP_DATA_IND: { case SCTP_DATA_IND:
ngap_gNB_handle_sctp_data_ind(&received_msg->ittiMsg.sctp_data_ind); ngap_gNB_handle_sctp_data_ind(&received_msg->ittiMsg.sctp_data_ind);
} break;
break;
case NGAP_NAS_FIRST_REQ: { case NGAP_NAS_FIRST_REQ:
ngap_gNB_handle_nas_first_req(ITTI_MSG_DESTINATION_INSTANCE(received_msg), ngap_gNB_handle_nas_first_req(instance, &NGAP_NAS_FIRST_REQ(received_msg));
&NGAP_NAS_FIRST_REQ(received_msg)); break;
}
break;
case NGAP_UPLINK_NAS: { case NGAP_UPLINK_NAS:
ngap_gNB_nas_uplink(ITTI_MSG_DESTINATION_INSTANCE(received_msg), ngap_gNB_nas_uplink(instance, &NGAP_UPLINK_NAS(received_msg));
&NGAP_UPLINK_NAS(received_msg)); break;
}
break;
case NGAP_UE_CAPABILITIES_IND: { case NGAP_UE_CAPABILITIES_IND:
ngap_gNB_ue_capabilities(ITTI_MSG_DESTINATION_INSTANCE(received_msg), ngap_gNB_ue_capabilities(instance, &NGAP_UE_CAPABILITIES_IND(received_msg));
&NGAP_UE_CAPABILITIES_IND(received_msg)); break;
}
break;
case NGAP_INITIAL_CONTEXT_SETUP_RESP: { case NGAP_INITIAL_CONTEXT_SETUP_RESP:
ngap_gNB_initial_ctxt_resp(ITTI_MSG_DESTINATION_INSTANCE(received_msg), ngap_gNB_initial_ctxt_resp(instance, &NGAP_INITIAL_CONTEXT_SETUP_RESP(received_msg));
&NGAP_INITIAL_CONTEXT_SETUP_RESP(received_msg)); break;
}
break;
case NGAP_PDUSESSION_SETUP_RESP: { case NGAP_PDUSESSION_SETUP_RESP:
ngap_gNB_pdusession_setup_resp(ITTI_MSG_DESTINATION_INSTANCE(received_msg), ngap_gNB_pdusession_setup_resp(instance, &NGAP_PDUSESSION_SETUP_RESP(received_msg));
&NGAP_PDUSESSION_SETUP_RESP(received_msg)); break;
}
break;
case NGAP_PDUSESSION_MODIFY_RESP: { case NGAP_PDUSESSION_MODIFY_RESP:
ngap_gNB_pdusession_modify_resp(ITTI_MSG_DESTINATION_INSTANCE(received_msg), ngap_gNB_pdusession_modify_resp(instance, &NGAP_PDUSESSION_MODIFY_RESP(received_msg));
&NGAP_PDUSESSION_MODIFY_RESP(received_msg)); break;
}
break;
case NGAP_NAS_NON_DELIVERY_IND: { case NGAP_NAS_NON_DELIVERY_IND:
ngap_gNB_nas_non_delivery_ind(ITTI_MSG_DESTINATION_INSTANCE(received_msg), ngap_gNB_nas_non_delivery_ind(instance, &NGAP_NAS_NON_DELIVERY_IND(received_msg));
&NGAP_NAS_NON_DELIVERY_IND(received_msg)); break;
}
break;
case NGAP_PATH_SWITCH_REQ: { case NGAP_PATH_SWITCH_REQ:
ngap_gNB_path_switch_req(ITTI_MSG_DESTINATION_INSTANCE(received_msg), ngap_gNB_path_switch_req(instance, &NGAP_PATH_SWITCH_REQ(received_msg));
&NGAP_PATH_SWITCH_REQ(received_msg)); break;
}
break;
case NGAP_PDUSESSION_MODIFICATION_IND: { case NGAP_PDUSESSION_MODIFICATION_IND:
ngap_gNB_generate_PDUSESSION_Modification_Indication(ITTI_MSG_DESTINATION_INSTANCE(received_msg), ngap_gNB_generate_PDUSESSION_Modification_Indication(instance, &NGAP_PDUSESSION_MODIFICATION_IND(received_msg));
&NGAP_PDUSESSION_MODIFICATION_IND(received_msg)); break;
}
break;
case NGAP_UE_CONTEXT_RELEASE_COMPLETE: { case NGAP_UE_CONTEXT_RELEASE_COMPLETE:
ngap_ue_context_release_complete(ITTI_MSG_DESTINATION_INSTANCE(received_msg), ngap_ue_context_release_complete(instance, &NGAP_UE_CONTEXT_RELEASE_COMPLETE(received_msg));
&NGAP_UE_CONTEXT_RELEASE_COMPLETE(received_msg)); break;
}
break; case NGAP_UE_CONTEXT_RELEASE_REQ:
ngap_ue_context_release_req(instance, &NGAP_UE_CONTEXT_RELEASE_REQ(received_msg));
case NGAP_UE_CONTEXT_RELEASE_REQ: { break;
ngap_gNB_instance_t *ngap_gNB_instance_p = NULL; // test
struct ngap_gNB_ue_context_s *ue_context_p = NULL; // test case NGAP_PDUSESSION_RELEASE_RESPONSE:
ngap_ue_context_release_req(ITTI_MSG_DESTINATION_INSTANCE(received_msg), ngap_gNB_pdusession_release_resp(instance, &NGAP_PDUSESSION_RELEASE_RESPONSE(received_msg));
&NGAP_UE_CONTEXT_RELEASE_REQ(received_msg)); break;
ngap_gNB_instance_p = ngap_gNB_get_instance(ITTI_MSG_DESTINATION_INSTANCE(received_msg)); // test
DevAssert(ngap_gNB_instance_p != NULL); // test
if ((ue_context_p = ngap_gNB_get_ue_context(ngap_gNB_instance_p,
NGAP_UE_CONTEXT_RELEASE_REQ(received_msg).gNB_ue_ngap_id)) == NULL) { // test
/* The context for this gNB ue ngap id doesn't exist in the map of gNB UEs */
NGAP_ERROR("Failed to find ue context associated with gNB ue ngap id: %u\n",
NGAP_UE_CONTEXT_RELEASE_REQ(received_msg).gNB_ue_ngap_id); // test
} // test
}
break;
case NGAP_PDUSESSION_RELEASE_RESPONSE: { default:
ngap_gNB_pdusession_release_resp(ITTI_MSG_DESTINATION_INSTANCE(received_msg), NGAP_ERROR("Received unhandled message: %d:%s\n", ITTI_MSG_ID(received_msg), ITTI_MSG_NAME(received_msg));
&NGAP_PDUSESSION_RELEASE_RESPONSE(received_msg)); break;
} }
break;
default: result = itti_free(ITTI_MSG_ORIGIN_ID(received_msg), received_msg);
NGAP_ERROR("Received unhandled message: %d:%s\n", AssertFatal(result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
ITTI_MSG_ID(received_msg), ITTI_MSG_NAME(received_msg));
break;
} }
result = itti_free (ITTI_MSG_ORIGIN_ID(received_msg), received_msg);
AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
received_msg = NULL;
return NULL; return NULL;
} }
......
...@@ -156,13 +156,8 @@ int ngap_gNB_decode_pdu(NGAP_NGAP_PDU_t *pdu, const uint8_t *const buffer, ...@@ -156,13 +156,8 @@ int ngap_gNB_decode_pdu(NGAP_NGAP_PDU_t *pdu, const uint8_t *const buffer,
asn_dec_rval_t dec_ret; asn_dec_rval_t dec_ret;
DevAssert(pdu != NULL); DevAssert(pdu != NULL);
DevAssert(buffer != NULL); DevAssert(buffer != NULL);
dec_ret = aper_decode(NULL, asn_codec_ctx_t st = {.max_stack_size = 100 * 1000}; // if we enable asn1c debug the stack size become large
&asn_DEF_NGAP_NGAP_PDU, dec_ret = aper_decode(&st, &asn_DEF_NGAP_NGAP_PDU, (void **)&pdu, buffer, length, 0, 0);
(void **)&pdu,
buffer,
length,
0,
0);
if (dec_ret.code != RC_OK) { if (dec_ret.code != RC_OK) {
NGAP_ERROR("Failed to decode pdu\n"); NGAP_ERROR("Failed to decode pdu\n");
......
...@@ -236,11 +236,6 @@ typedef struct ngap_gNB_instance_s { ...@@ -236,11 +236,6 @@ typedef struct ngap_gNB_instance_s {
/* Tree of NGAP AMF associations ordered by association ID */ /* Tree of NGAP AMF associations ordered by association ID */
RB_HEAD(ngap_amf_map, ngap_gNB_amf_data_s) ngap_amf_head; RB_HEAD(ngap_amf_map, ngap_gNB_amf_data_s) ngap_amf_head;
/* TODO: add a map ordered by relative AMF capacity */
/* Tree of UE ordered by gNB_ue_ngap_id's */
RB_HEAD(ngap_ue_map, ngap_gNB_ue_context_s) ngap_ue_head;
/* For virtual mode, mod_id as defined in the rest of the L1/L2 stack */ /* For virtual mode, mod_id as defined in the rest of the L1/L2 stack */
instance_t instance; instance_t instance;
......
...@@ -38,186 +38,100 @@ ...@@ -38,186 +38,100 @@
#include "ngap_common.h" #include "ngap_common.h"
#include "ngap_gNB_encoder.h" #include "ngap_gNB_encoder.h"
static inline int ngap_gNB_encode_initiating(NGAP_NGAP_PDU_t *pdu, static inline int ngap_gNB_encode_initiating(NGAP_NGAP_PDU_t *pdu, uint8_t **buffer, uint32_t *len)
uint8_t **buffer, {
uint32_t *len);
static inline int ngap_gNB_encode_successfull_outcome(NGAP_NGAP_PDU_t *pdu,
uint8_t **buffer, uint32_t *len);
static inline int ngap_gNB_encode_unsuccessfull_outcome(NGAP_NGAP_PDU_t *pdu,
uint8_t **buffer, uint32_t *len);
int ngap_gNB_encode_pdu(NGAP_NGAP_PDU_t *pdu, uint8_t **buffer, uint32_t *len) {
int ret = -1;
DevAssert(pdu != NULL); DevAssert(pdu != NULL);
DevAssert(buffer != NULL);
DevAssert(len != NULL);
switch(pdu->present) {
case NGAP_NGAP_PDU_PR_initiatingMessage:
ret = ngap_gNB_encode_initiating(pdu, buffer, len);
break;
case NGAP_NGAP_PDU_PR_successfulOutcome:
ret = ngap_gNB_encode_successfull_outcome(pdu, buffer, len);
break;
case NGAP_NGAP_PDU_PR_unsuccessfulOutcome: const NGAP_ProcedureCode_t tmp[] = {NGAP_ProcedureCode_id_NGSetup,
ret = ngap_gNB_encode_unsuccessfull_outcome(pdu, buffer, len); NGAP_ProcedureCode_id_UplinkNASTransport,
break; NGAP_ProcedureCode_id_UERadioCapabilityInfoIndication,
NGAP_ProcedureCode_id_InitialUEMessage,
default: NGAP_ProcedureCode_id_NASNonDeliveryIndication,
NGAP_DEBUG("Unknown message outcome (%d) or not implemented", NGAP_ProcedureCode_id_UEContextReleaseRequest,
(int)pdu->present); NGAP_ProcedureCode_id_PathSwitchRequest,
return -1; NGAP_ProcedureCode_id_PDUSessionResourceModifyIndication};
int i;
for (i = 0; i < sizeofArray(tmp); i++)
if (pdu->choice.initiatingMessage->procedureCode == tmp[i])
break;
if (i == sizeofArray(tmp)) {
NGAP_DEBUG("Unknown procedure ID (%d) for initiating message\n", (int)pdu->choice.initiatingMessage->procedureCode);
return -1;
} }
//ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_NGAP_NGAP_PDU, pdu); asn_encode_to_new_buffer_result_t res = asn_encode_to_new_buffer(NULL, ATS_ALIGNED_CANONICAL_PER, &asn_DEF_NGAP_NGAP_PDU, pdu);
return ret; AssertFatal(res.result.encoded > 0, "failed to encode NGAP msg\n");
*buffer = res.buffer;
*len = res.result.encoded;
return 0;
} }
static inline static inline int ngap_gNB_encode_successfull_outcome(NGAP_NGAP_PDU_t *pdu, uint8_t **buffer, uint32_t *len)
int ngap_gNB_encode_initiating(NGAP_NGAP_PDU_t *pdu, {
uint8_t **buffer, uint32_t *len) {
asn_encode_to_new_buffer_result_t res = { NULL, {0, NULL, NULL} };
DevAssert(pdu != NULL); DevAssert(pdu != NULL);
const NGAP_ProcedureCode_t tmp[] = {NGAP_ProcedureCode_id_InitialContextSetup,
switch(pdu->choice.initiatingMessage->procedureCode) { NGAP_ProcedureCode_id_UEContextRelease,
case NGAP_ProcedureCode_id_NGSetup: NGAP_ProcedureCode_id_PDUSessionResourceSetup,
res = asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_NGAP_NGAP_PDU, pdu); NGAP_ProcedureCode_id_PDUSessionResourceModify,
free(res.buffer); NGAP_ProcedureCode_id_PDUSessionResourceRelease};
break; int i;
for (i = 0; i < sizeofArray(tmp); i++)
case NGAP_ProcedureCode_id_UplinkNASTransport: if (pdu->choice.successfulOutcome->procedureCode == tmp[i])
res = asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_NGAP_NGAP_PDU, pdu); break;
free(res.buffer); if (i == sizeofArray(tmp)) {
break; NGAP_WARN("Unknown procedure ID (%ld) for successfull outcome message\n", pdu->choice.successfulOutcome->procedureCode);
return -1;
case NGAP_ProcedureCode_id_UERadioCapabilityInfoIndication:
res = asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_NGAP_NGAP_PDU, pdu);
free(res.buffer);
break;
case NGAP_ProcedureCode_id_InitialUEMessage:
res = asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_NGAP_NGAP_PDU, pdu);
free(res.buffer);
break;
case NGAP_ProcedureCode_id_NASNonDeliveryIndication:
res = asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_NGAP_NGAP_PDU, pdu);
free(res.buffer);
break;
case NGAP_ProcedureCode_id_UEContextReleaseRequest:
res = asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_NGAP_NGAP_PDU, pdu);
free(res.buffer);
break;
case NGAP_ProcedureCode_id_PathSwitchRequest:
res = asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_NGAP_NGAP_PDU, pdu);
free(res.buffer);
break;
case NGAP_ProcedureCode_id_PDUSessionResourceModifyIndication:
res = asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_NGAP_NGAP_PDU, pdu);
free(res.buffer);
break;
default:
NGAP_DEBUG("Unknown procedure ID (%d) for initiating message\n",
(int)pdu->choice.initiatingMessage->procedureCode);
return -1;
} }
if (asn1_xer_print) { asn_encode_to_new_buffer_result_t res = asn_encode_to_new_buffer(NULL, ATS_ALIGNED_CANONICAL_PER, &asn_DEF_NGAP_NGAP_PDU, pdu);
xer_fprint(stdout, &asn_DEF_NGAP_NGAP_PDU, (void *)pdu); AssertFatal(res.result.encoded > 0, "failed to encode NGAP msg\n");
}
memset(&res, 0, sizeof(res));
res = asn_encode_to_new_buffer(NULL, ATS_ALIGNED_CANONICAL_PER, &asn_DEF_NGAP_NGAP_PDU, pdu);
*buffer = res.buffer; *buffer = res.buffer;
*len = res.result.encoded; *len = res.result.encoded;
return 0; return 0;
} }
static inline static inline int ngap_gNB_encode_unsuccessfull_outcome(NGAP_NGAP_PDU_t *pdu, uint8_t **buffer, uint32_t *len)
int ngap_gNB_encode_successfull_outcome(NGAP_NGAP_PDU_t *pdu, {
uint8_t **buffer, uint32_t *len) {
asn_encode_to_new_buffer_result_t res = { NULL, {0, NULL, NULL} };
DevAssert(pdu != NULL); DevAssert(pdu != NULL);
switch(pdu->choice.successfulOutcome->procedureCode) { if (pdu->choice.unsuccessfulOutcome->procedureCode != NGAP_ProcedureCode_id_InitialContextSetup) {
case NGAP_ProcedureCode_id_InitialContextSetup: NGAP_DEBUG("Unknown procedure ID (%d) for unsuccessfull outcome message\n", (int)pdu->choice.unsuccessfulOutcome->procedureCode);
res = asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_NGAP_NGAP_PDU, pdu); return -1;
free(res.buffer);
break;
case NGAP_ProcedureCode_id_UEContextRelease:
res = asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_NGAP_NGAP_PDU, pdu);
free(res.buffer);
break;
case NGAP_ProcedureCode_id_PDUSessionResourceSetup:
res = asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_NGAP_NGAP_PDU, pdu);
free(res.buffer);
NGAP_INFO("PDUSESSIONSetup successful message\n");
break;
case NGAP_ProcedureCode_id_PDUSessionResourceModify:
res = asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_NGAP_NGAP_PDU, pdu);
free(res.buffer);
NGAP_INFO("PDUSESSIONModify successful message\n");
break;
case NGAP_ProcedureCode_id_PDUSessionResourceRelease:
res = asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_NGAP_NGAP_PDU, pdu);
free(res.buffer);
NGAP_INFO("PDUSESSION Release successful message\n");
break;
default:
NGAP_WARN("Unknown procedure ID (%d) for successfull outcome message\n",
(int)pdu->choice.successfulOutcome->procedureCode);
return -1;
} }
if (asn1_xer_print) { asn_encode_to_new_buffer_result_t res = asn_encode_to_new_buffer(NULL, ATS_ALIGNED_CANONICAL_PER, &asn_DEF_NGAP_NGAP_PDU, pdu);
xer_fprint(stdout, &asn_DEF_NGAP_NGAP_PDU, (void *)pdu); AssertFatal(res.result.encoded > 0, "failed to encode NGAP msg\n");
}
memset(&res, 0, sizeof(res));
res = asn_encode_to_new_buffer(NULL, ATS_ALIGNED_CANONICAL_PER, &asn_DEF_NGAP_NGAP_PDU, pdu);
*buffer = res.buffer; *buffer = res.buffer;
*len = res.result.encoded; *len = res.result.encoded;
return 0; return 0;
} }
static inline int ngap_gNB_encode_pdu(NGAP_NGAP_PDU_t *pdu, uint8_t **buffer, uint32_t *len)
int ngap_gNB_encode_unsuccessfull_outcome(NGAP_NGAP_PDU_t *pdu, {
uint8_t **buffer, uint32_t *len) { int ret = -1;
asn_encode_to_new_buffer_result_t res = { NULL, {0, NULL, NULL} };
DevAssert(pdu != NULL); DevAssert(pdu != NULL);
DevAssert(buffer != NULL);
DevAssert(len != NULL);
if (asn1_xer_print) {
xer_fprint(stdout, &asn_DEF_NGAP_NGAP_PDU, (void *)pdu);
}
switch (pdu->present) {
case NGAP_NGAP_PDU_PR_initiatingMessage:
ret = ngap_gNB_encode_initiating(pdu, buffer, len);
break;
switch(pdu->choice.unsuccessfulOutcome->procedureCode) { case NGAP_NGAP_PDU_PR_successfulOutcome:
case NGAP_ProcedureCode_id_InitialContextSetup: ret = ngap_gNB_encode_successfull_outcome(pdu, buffer, len);
res = asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_NGAP_NGAP_PDU, pdu); break;
free(res.buffer);
case NGAP_NGAP_PDU_PR_unsuccessfulOutcome:
ret = ngap_gNB_encode_unsuccessfull_outcome(pdu, buffer, len);
break; break;
default: default:
NGAP_DEBUG("Unknown procedure ID (%d) for unsuccessfull outcome message\n", NGAP_DEBUG("Unknown message outcome (%d) or not implemented", (int)pdu->present);
(int)pdu->choice.unsuccessfulOutcome->procedureCode);
return -1; return -1;
} }
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_NGAP_NGAP_PDU, pdu);
if (asn1_xer_print) { return ret;
xer_fprint(stdout, &asn_DEF_NGAP_NGAP_PDU, (void *)pdu);
}
memset(&res, 0, sizeof(res));
res = asn_encode_to_new_buffer(NULL, ATS_ALIGNED_CANONICAL_PER, &asn_DEF_NGAP_NGAP_PDU, pdu);
*buffer = res.buffer;
*len = res.result.encoded;
return 0;
} }
This diff is collapsed.
...@@ -44,16 +44,12 @@ void ngap_gNB_itti_send_sctp_data_req(instance_t instance, int32_t assoc_id, uin ...@@ -44,16 +44,12 @@ void ngap_gNB_itti_send_sctp_data_req(instance_t instance, int32_t assoc_id, uin
sctp_data_req->assoc_id = assoc_id; sctp_data_req->assoc_id = assoc_id;
sctp_data_req->buffer = buffer; sctp_data_req->buffer = buffer;
sctp_data_req->buffer_length = buffer_length; sctp_data_req->buffer_length = buffer_length;
sctp_data_req->stream = stream; sctp_data_req->stream = stream;
itti_send_msg_to_task(TASK_SCTP, instance, message_p); itti_send_msg_to_task(TASK_SCTP, instance, message_p);
} }
void ngap_gNB_itti_send_nas_downlink_ind(instance_t instance, void ngap_gNB_itti_send_nas_downlink_ind(instance_t instance, uint32_t gNB_ue_ngap_id, uint8_t *nas_pdu, uint32_t nas_pdu_length)
uint16_t ue_initial_id,
uint32_t gNB_ue_ngap_id,
uint8_t *nas_pdu,
uint32_t nas_pdu_length)
{ {
MessageDef *message_p; MessageDef *message_p;
ngap_downlink_nas_t *ngap_downlink_nas; ngap_downlink_nas_t *ngap_downlink_nas;
...@@ -62,7 +58,6 @@ void ngap_gNB_itti_send_nas_downlink_ind(instance_t instance, ...@@ -62,7 +58,6 @@ void ngap_gNB_itti_send_nas_downlink_ind(instance_t instance,
ngap_downlink_nas = &message_p->ittiMsg.ngap_downlink_nas; ngap_downlink_nas = &message_p->ittiMsg.ngap_downlink_nas;
ngap_downlink_nas->ue_initial_id = ue_initial_id;
ngap_downlink_nas->gNB_ue_ngap_id = gNB_ue_ngap_id; ngap_downlink_nas->gNB_ue_ngap_id = gNB_ue_ngap_id;
ngap_downlink_nas->nas_pdu.buffer = malloc(sizeof(uint8_t) * nas_pdu_length); ngap_downlink_nas->nas_pdu.buffer = malloc(sizeof(uint8_t) * nas_pdu_length);
memcpy(ngap_downlink_nas->nas_pdu.buffer, nas_pdu, nas_pdu_length); memcpy(ngap_downlink_nas->nas_pdu.buffer, nas_pdu, nas_pdu_length);
......
...@@ -33,11 +33,7 @@ ...@@ -33,11 +33,7 @@
void ngap_gNB_itti_send_sctp_data_req(instance_t instance, int32_t assoc_id, uint8_t *buffer, void ngap_gNB_itti_send_sctp_data_req(instance_t instance, int32_t assoc_id, uint8_t *buffer,
uint32_t buffer_length, uint16_t stream); uint32_t buffer_length, uint16_t stream);
void ngap_gNB_itti_send_nas_downlink_ind(instance_t instance, void ngap_gNB_itti_send_nas_downlink_ind(instance_t instance, uint32_t gNB_ue_ngap_id, uint8_t *nas_pdu, uint32_t nas_pdu_length);
uint16_t ue_initial_id,
uint32_t gNB_ue_ngap_id,
uint8_t *nas_pdu,
uint32_t nas_pdu_length);
void ngap_gNB_itti_send_sctp_close_association(instance_t instance, void ngap_gNB_itti_send_sctp_close_association(instance_t instance,
int32_t assoc_id); int32_t assoc_id);
......
This diff is collapsed.
...@@ -30,23 +30,10 @@ ...@@ -30,23 +30,10 @@
#ifndef NGAP_GNB_TRACE_H_ #ifndef NGAP_GNB_TRACE_H_
#define NGAP_GNB_TRACE_H_ #define NGAP_GNB_TRACE_H_
// int ngap_gNB_generate_trace_failure(sctp_data_t *sctp_data_p,
// int32_t stream,
// uint32_t gNB_ue_ngap_id,
// uint32_t amf_ue_ngap_id,
// E_UTRAN_Trace_ID_t *trace_id,
// Cause_t *cause_p);
// int ngap_gNB_handle_trace_start(gNB_amf_desc_t *gNB_desc_p,
// sctp_queue_item_t *packet_p,
// struct ngap_message_s *message_p);
int ngap_gNB_handle_trace_start(uint32_t assoc_id, int ngap_gNB_handle_trace_start(uint32_t assoc_id,
uint32_t stream, uint32_t stream,
NGAP_NGAP_PDU_t *pdu); NGAP_NGAP_PDU_t *pdu);
// int ngap_gNB_handle_deactivate_trace(gNB_amf_desc_t *gNB_desc_p,
// sctp_queue_item_t *packet_p,
// struct ngap_message_s *message_p);
int ngap_gNB_handle_deactivate_trace(uint32_t assoc_id, int ngap_gNB_handle_deactivate_trace(uint32_t assoc_id,
uint32_t stream, uint32_t stream,
NGAP_NGAP_PDU_t *pdu); NGAP_NGAP_PDU_t *pdu);
......
...@@ -40,8 +40,15 @@ ...@@ -40,8 +40,15 @@
#include "ngap_gNB_defs.h" #include "ngap_gNB_defs.h"
#include "ngap_gNB_ue_context.h" #include "ngap_gNB_ue_context.h"
int ngap_gNB_compare_gNB_ue_ngap_id( /* Tree of UE ordered by gNB_ue_ngap_id's
struct ngap_gNB_ue_context_s *p1, struct ngap_gNB_ue_context_s *p2) * NO INSTANCE, the 32 bits id is large enough to handle all UEs, regardless the cell, gNB, ...
*/
static RB_HEAD(ngap_ue_map, ngap_gNB_ue_context_s) ngap_ue_head = RB_INITIALIZER(&ngap_ue_head);
/* Generate the tree management functions prototypes */
RB_PROTOTYPE(ngap_ue_map, ngap_gNB_ue_context_s, entries, ngap_gNB_compare_gNB_ue_ngap_id);
static int ngap_gNB_compare_gNB_ue_ngap_id(struct ngap_gNB_ue_context_s *p1, struct ngap_gNB_ue_context_s *p2)
{ {
if (p1->gNB_ue_ngap_id > p2->gNB_ue_ngap_id) { if (p1->gNB_ue_ngap_id > p2->gNB_ue_ngap_id) {
return 1; return 1;
...@@ -58,46 +65,26 @@ int ngap_gNB_compare_gNB_ue_ngap_id( ...@@ -58,46 +65,26 @@ int ngap_gNB_compare_gNB_ue_ngap_id(
RB_GENERATE(ngap_ue_map, ngap_gNB_ue_context_s, entries, RB_GENERATE(ngap_ue_map, ngap_gNB_ue_context_s, entries,
ngap_gNB_compare_gNB_ue_ngap_id); ngap_gNB_compare_gNB_ue_ngap_id);
struct ngap_gNB_ue_context_s *ngap_gNB_allocate_new_UE_context(void) void ngap_store_ue_context(struct ngap_gNB_ue_context_s *ue_desc_p)
{ {
struct ngap_gNB_ue_context_s *new_p; if (RB_INSERT(ngap_ue_map, &ngap_ue_head, ue_desc_p))
LOG_E(NGAP, "Bug in UE uniq number allocation %u, we try to add a existing UE\n", ue_desc_p->gNB_ue_ngap_id);
new_p = malloc(sizeof(struct ngap_gNB_ue_context_s)); return;
if (new_p == NULL) {
NGAP_ERROR("Cannot allocate new ue context\n");
return NULL;
}
memset(new_p, 0, sizeof(struct ngap_gNB_ue_context_s));
return new_p;
} }
struct ngap_gNB_ue_context_s *ngap_gNB_get_ue_context( struct ngap_gNB_ue_context_s *ngap_get_ue_context(uint32_t gNB_ue_ngap_id)
ngap_gNB_instance_t *instance_p,
uint32_t gNB_ue_ngap_id)
{ {
ngap_gNB_ue_context_t temp; ngap_gNB_ue_context_t temp = {.gNB_ue_ngap_id = gNB_ue_ngap_id};
return RB_FIND(ngap_ue_map, &ngap_ue_head, &temp);
memset(&temp, 0, sizeof(struct ngap_gNB_ue_context_s));
/* gNB ue ngap id = 32 bits wide */
temp.gNB_ue_ngap_id = gNB_ue_ngap_id & 0xFFFFFFFF;
return RB_FIND(ngap_ue_map, &instance_p->ngap_ue_head, &temp);
} }
void ngap_gNB_free_ue_context(struct ngap_gNB_ue_context_s *ue_context_p) struct ngap_gNB_ue_context_s *ngap_detach_ue_context(uint32_t gNB_ue_ngap_id)
{ {
if (ue_context_p == NULL) { struct ngap_gNB_ue_context_s *tmp = ngap_get_ue_context(gNB_ue_ngap_id);
NGAP_ERROR("Trying to free a NULL context\n"); if (tmp == NULL) {
return; NGAP_ERROR("Trying to free a NULL UE context, %u\n", gNB_ue_ngap_id);
return NULL;
} }
RB_REMOVE(ngap_ue_map, &ngap_ue_head, tmp);
/* TODO: check that context is currently not in the tree of known return tmp;
* contexts.
*/
free(ue_context_p);
} }
...@@ -37,7 +37,6 @@ ...@@ -37,7 +37,6 @@
// Forward declarations // Forward declarations
struct ngap_gNB_amf_data_s; struct ngap_gNB_amf_data_s;
struct ngap_ue_map;
struct gNB_amf_desc_s; struct gNB_amf_desc_s;
typedef enum { typedef enum {
...@@ -59,11 +58,7 @@ typedef struct ngap_gNB_ue_context_s { ...@@ -59,11 +58,7 @@ typedef struct ngap_gNB_ue_context_s {
*/ */
uint32_t gNB_ue_ngap_id; uint32_t gNB_ue_ngap_id;
/* UE id for initial connection to NGAP */ uint64_t amf_ue_ngap_id;
uint16_t ue_initial_id;
/* Uniquely identifies the UE within AMF. Encoded on 32 bits. */
uint64_t amf_ue_ngap_id:40;
/* Stream used for this particular UE */ /* Stream used for this particular UE */
int32_t tx_stream; int32_t tx_stream;
...@@ -84,20 +79,9 @@ typedef struct ngap_gNB_ue_context_s { ...@@ -84,20 +79,9 @@ typedef struct ngap_gNB_ue_context_s {
ngap_gNB_instance_t *gNB_instance; ngap_gNB_instance_t *gNB_instance;
} ngap_gNB_ue_context_t; } ngap_gNB_ue_context_t;
int ngap_gNB_compare_gNB_ue_ngap_id( void ngap_store_ue_context(ngap_gNB_ue_context_t *ue_desc_p);
struct ngap_gNB_ue_context_s *p1, struct ngap_gNB_ue_context_s *p2);
/* Generate the tree management functions prototypes */
RB_PROTOTYPE(ngap_ue_map, ngap_gNB_ue_context_s, entries,
ngap_gNB_compare_gNB_ue_ngap_id);
struct ngap_gNB_ue_context_s *ngap_gNB_allocate_new_UE_context(void);
struct ngap_gNB_ue_context_s *ngap_gNB_get_ue_context(
ngap_gNB_instance_t *instance_p,
uint32_t gNB_ue_ngap_id);
void ngap_gNB_free_ue_context(struct ngap_gNB_ue_context_s *ue_context_p);
ngap_gNB_ue_context_t *ngap_get_ue_context(uint32_t gNB_ue_ngap_id);
ngap_gNB_ue_context_t *ngap_detach_ue_context(uint32_t gNB_ue_ngap_id);
#endif /* NGAP_GNB_UE_CONTEXT_H_ */ #endif /* NGAP_GNB_UE_CONTEXT_H_ */
...@@ -650,7 +650,7 @@ static void sctp_send_data(sctp_data_req_t *sctp_data_req_p) ...@@ -650,7 +650,7 @@ static void sctp_send_data(sctp_data_req_t *sctp_data_req_p)
/* TODO: notify upper layer */ /* TODO: notify upper layer */
return; return;
} }
free(sctp_data_req_p->buffer); // assuming it has been malloced
SCTP_DEBUG("Successfully sent %u bytes on stream %d for assoc_id %u\n", SCTP_DEBUG("Successfully sent %u bytes on stream %d for assoc_id %u\n",
sctp_data_req_p->buffer_length, sctp_data_req_p->stream, sctp_data_req_p->buffer_length, sctp_data_req_p->stream,
sctp_cnx->assoc_id); sctp_cnx->assoc_id);
......
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