Fix various problems in 4G NAS handling
- rename as_nas_info_t member data to nas_data to have a uniq name to trace between complex malloc/free of this pointer - fix, maybe not perfect, these pais od malloc/free - remove typedef name changes across transmission of these as_nas_info_t over itti, as name changing makes it even more confusing - remove globals that are likely possible races - in as_message_decode() fix memcpy size, it is hard to understand the initial idea, likely the author beleives a struct of struct makes a intermediate pointer - in network_api.c remove globals (static but used globally) - remove casts that are there to hide gcc warnings on probable unaligned access - remain a weird mix of packed/unpacked versions of the same typedef, but gcc is happy
This commit is contained in:
@@ -167,7 +167,7 @@ typedef struct as_stmsi_s {
|
||||
/* Dedicated NAS information */
|
||||
typedef struct as_nas_info_s {
|
||||
uint32_t length; /* Length of the NAS information data */
|
||||
Byte_t* data; /* Dedicated NAS information data container */
|
||||
Byte_t* nas_data; /* Dedicated NAS information data container */
|
||||
} as_nas_info_t;
|
||||
|
||||
/* Radio Access Bearer identity */
|
||||
|
||||
@@ -57,26 +57,26 @@ MESSAGE_DEF(RRC_CONFIGURATION_REQ, MESSAGE_PRIORITY_MED, RrcConfigura
|
||||
MESSAGE_DEF(NBIOTRRC_CONFIGURATION_REQ, MESSAGE_PRIORITY_MED, NbIoTRrcConfigurationReq, nbiotrrc_configuration_req)
|
||||
|
||||
// UE: NAS -> RRC messages
|
||||
MESSAGE_DEF(NAS_KENB_REFRESH_REQ, MESSAGE_PRIORITY_MED, NasKenbRefreshReq, nas_kenb_refresh_req)
|
||||
MESSAGE_DEF(NAS_CELL_SELECTION_REQ, MESSAGE_PRIORITY_MED, NasCellSelectionReq, nas_cell_selection_req)
|
||||
MESSAGE_DEF(NAS_CONN_ESTABLI_REQ, MESSAGE_PRIORITY_MED, NasConnEstabliReq, nas_conn_establi_req)
|
||||
MESSAGE_DEF(NAS_UPLINK_DATA_REQ, MESSAGE_PRIORITY_MED, NasUlDataReq, nas_ul_data_req)
|
||||
MESSAGE_DEF(NAS_DETACH_REQ, MESSAGE_PRIORITY_MED, NasDetachReq, nas_detach_req)
|
||||
MESSAGE_DEF(NAS_DEREGISTRATION_REQ, MESSAGE_PRIORITY_MED, NasDeregistrationReq, nas_deregistration_req)
|
||||
MESSAGE_DEF(NAS_KENB_REFRESH_REQ, MESSAGE_PRIORITY_MED, kenb_refresh_req_t, nas_kenb_refresh_req)
|
||||
MESSAGE_DEF(NAS_CELL_SELECTION_REQ, MESSAGE_PRIORITY_MED, cell_info_req_t, nas_cell_selection_req)
|
||||
MESSAGE_DEF(NAS_CONN_ESTABLI_REQ, MESSAGE_PRIORITY_MED, nas_establish_req_t, nas_conn_establi_req)
|
||||
MESSAGE_DEF(NAS_UPLINK_DATA_REQ, MESSAGE_PRIORITY_MED, ul_info_transfer_req_t, nas_ul_data_req)
|
||||
MESSAGE_DEF(NAS_DETACH_REQ, MESSAGE_PRIORITY_MED, nas_detach_req_t, nas_detach_req)
|
||||
MESSAGE_DEF(NAS_DEREGISTRATION_REQ, MESSAGE_PRIORITY_MED, nas_deregistration_req_t, nas_deregistration_req)
|
||||
|
||||
MESSAGE_DEF(NAS_RAB_ESTABLI_RSP, MESSAGE_PRIORITY_MED, NasRabEstRsp, nas_rab_est_rsp)
|
||||
MESSAGE_DEF(NAS_RAB_ESTABLI_RSP, MESSAGE_PRIORITY_MED, rab_establish_rsp_t, nas_rab_est_rsp)
|
||||
|
||||
MESSAGE_DEF(NAS_OAI_TUN_NSA, MESSAGE_PRIORITY_MED, NasOaiTunNsa, nas_oai_tun_nsa)
|
||||
MESSAGE_DEF(NAS_OAI_TUN_NSA, MESSAGE_PRIORITY_MED, nas_oai_tun_nsa_t, nas_oai_tun_nsa)
|
||||
|
||||
// UE: RRC -> NAS messages
|
||||
MESSAGE_DEF(NAS_CELL_SELECTION_CNF, MESSAGE_PRIORITY_MED, NasCellSelectionCnf, nas_cell_selection_cnf)
|
||||
MESSAGE_DEF(NAS_CELL_SELECTION_IND, MESSAGE_PRIORITY_MED, NasCellSelectionInd, nas_cell_selection_ind)
|
||||
MESSAGE_DEF(NAS_PAGING_IND, MESSAGE_PRIORITY_MED, NasPagingInd, nas_paging_ind)
|
||||
MESSAGE_DEF(NAS_CONN_ESTABLI_CNF, MESSAGE_PRIORITY_MED, NasConnEstabCnf, nas_conn_establi_cnf)
|
||||
MESSAGE_DEF(NAS_CONN_RELEASE_IND, MESSAGE_PRIORITY_MED, NasConnReleaseInd, nas_conn_release_ind)
|
||||
MESSAGE_DEF(NAS_CELL_SELECTION_CNF, MESSAGE_PRIORITY_MED, cell_info_cnf_t, nas_cell_selection_cnf)
|
||||
MESSAGE_DEF(NAS_CELL_SELECTION_IND, MESSAGE_PRIORITY_MED, cell_info_ind_t, nas_cell_selection_ind)
|
||||
MESSAGE_DEF(NAS_PAGING_IND, MESSAGE_PRIORITY_MED, paging_ind_t, nas_paging_ind)
|
||||
MESSAGE_DEF(NAS_CONN_ESTABLI_CNF, MESSAGE_PRIORITY_MED, nas_establish_cnf_t, nas_conn_establi_cnf)
|
||||
MESSAGE_DEF(NAS_CONN_RELEASE_IND, MESSAGE_PRIORITY_MED, nas_release_ind_t, nas_conn_release_ind)
|
||||
MESSAGE_DEF(NR_NAS_CONN_RELEASE_IND, MESSAGE_PRIORITY_MED, NRNasConnReleaseInd, nr_nas_conn_release_ind)
|
||||
MESSAGE_DEF(NAS_UPLINK_DATA_CNF, MESSAGE_PRIORITY_MED, NasUlDataCnf, nas_ul_data_cnf)
|
||||
MESSAGE_DEF(NAS_DOWNLINK_DATA_IND, MESSAGE_PRIORITY_MED, NasDlDataInd, nas_dl_data_ind)
|
||||
MESSAGE_DEF(NAS_UPLINK_DATA_CNF, MESSAGE_PRIORITY_MED, ul_info_transfer_cnf_t, nas_ul_data_cnf)
|
||||
MESSAGE_DEF(NAS_DOWNLINK_DATA_IND, MESSAGE_PRIORITY_MED, dl_info_transfer_ind_t, nas_dl_data_ind)
|
||||
|
||||
// xNB: realtime -> RRC messages
|
||||
MESSAGE_DEF(RRC_SUBFRAME_PROCESS, MESSAGE_PRIORITY_MED, RrcSubframeProcess, rrc_subframe_process)
|
||||
|
||||
@@ -422,28 +422,7 @@ typedef struct NRDuDlReq_s {
|
||||
rnti_t rnti;
|
||||
uint8_t *buf;
|
||||
uint64_t srb_id;
|
||||
} NRDuDlReq_t;
|
||||
|
||||
// UE: NAS -> RRC messages
|
||||
typedef kenb_refresh_req_t NasKenbRefreshReq;
|
||||
typedef cell_info_req_t NasCellSelectionReq;
|
||||
typedef nas_establish_req_t NasConnEstabliReq;
|
||||
typedef ul_info_transfer_req_t NasUlDataReq;
|
||||
typedef nas_deregistration_req_t NasDeregistrationReq;
|
||||
typedef nas_detach_req_t NasDetachReq;
|
||||
|
||||
typedef rab_establish_rsp_t NasRabEstRsp;
|
||||
|
||||
typedef nas_oai_tun_nsa_t NasOaiTunNsa;
|
||||
|
||||
// UE: RRC -> NAS messages
|
||||
typedef cell_info_cnf_t NasCellSelectionCnf;
|
||||
typedef cell_info_ind_t NasCellSelectionInd;
|
||||
typedef paging_ind_t NasPagingInd;
|
||||
typedef nas_establish_cnf_t NasConnEstabCnf;
|
||||
typedef nas_release_ind_t NasConnReleaseInd;
|
||||
typedef ul_info_transfer_cnf_t NasUlDataCnf;
|
||||
typedef dl_info_transfer_ind_t NasDlDataInd;
|
||||
} NRDuDlReq_t;
|
||||
|
||||
// eNB: realtime -> RRC messages
|
||||
typedef struct rrc_subframe_process_s {
|
||||
|
||||
+32
-30
@@ -536,18 +536,18 @@ rrc_t310_expiration(
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
static void rrc_ue_generate_RRCConnectionSetupComplete(
|
||||
const protocol_ctxt_t *const ctxt_pP,
|
||||
const uint8_t eNB_index,
|
||||
const uint8_t Transaction_id,
|
||||
uint8_t sel_plmn_id) {
|
||||
static void rrc_ue_generate_RRCConnectionSetupComplete(const protocol_ctxt_t *const ctxt_pP,
|
||||
const uint8_t eNB_index,
|
||||
const uint8_t Transaction_id,
|
||||
uint8_t sel_plmn_id)
|
||||
{
|
||||
uint8_t buffer[100];
|
||||
uint8_t size;
|
||||
const char *nas_msg;
|
||||
int nas_msg_length;
|
||||
|
||||
if (EPC_MODE_ENABLED) {
|
||||
nas_msg = (char *) UE_rrc_inst[ctxt_pP->module_id].initialNasMsg.data;
|
||||
nas_msg = (char *)UE_rrc_inst[ctxt_pP->module_id].initialNasMsg.nas_data;
|
||||
nas_msg_length = UE_rrc_inst[ctxt_pP->module_id].initialNasMsg.length;
|
||||
} else {
|
||||
nas_msg = nas_attach_req_imsi;
|
||||
@@ -1904,14 +1904,13 @@ static bool is_nr_r15_config_present(LTE_RRCConnectionReconfiguration_r8_IEs_t *
|
||||
#undef NCE
|
||||
#undef chk
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void
|
||||
rrc_ue_process_rrcConnectionReconfiguration(
|
||||
const protocol_ctxt_t *const ctxt_pP,
|
||||
LTE_RRCConnectionReconfiguration_t *rrcConnectionReconfiguration,
|
||||
uint8_t eNB_index
|
||||
)
|
||||
/** \brief process the received rrcConnectionReconfiguration message at UE
|
||||
\param ctxt_pP Running context
|
||||
\param *rrcConnectionReconfiguration pointer to the sturcture
|
||||
\param eNB_index Index of corresponding eNB/CH*/
|
||||
static void rrc_ue_process_rrcConnectionReconfiguration(const protocol_ctxt_t *const ctxt_pP,
|
||||
LTE_RRCConnectionReconfiguration_t *rrcConnectionReconfiguration,
|
||||
uint8_t eNB_index)
|
||||
//-----------------------------------------------------------------------------
|
||||
{
|
||||
LOG_I(RRC,"[UE %d] Frame %d: Receiving from SRB1 (DL-DCCH), Processing RRCConnectionReconfiguration (eNB %d)\n",
|
||||
@@ -2035,7 +2034,7 @@ rrc_ue_process_rrcConnectionReconfiguration(
|
||||
msg_p = itti_alloc_new_message(TASK_RRC_UE, 0, NAS_CONN_ESTABLI_CNF);
|
||||
NAS_CONN_ESTABLI_CNF(msg_p).errCode = AS_SUCCESS;
|
||||
NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.length = pdu_length;
|
||||
NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.data = pdu_buffer;
|
||||
NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.nas_data = pdu_buffer;
|
||||
itti_send_msg_to_task(TASK_NAS_UE, ctxt_pP->instance, msg_p);
|
||||
}
|
||||
LOG_D(RRC, "Sent NAS_CONN_ESTABLI_CNF to NAS layer via itti!\n");
|
||||
@@ -2185,14 +2184,17 @@ rrc_detach_from_eNB(
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void
|
||||
rrc_ue_decode_dcch(
|
||||
const protocol_ctxt_t *const ctxt_pP,
|
||||
const rb_id_t Srb_id,
|
||||
const uint8_t *const Buffer,
|
||||
const uint32_t Buffer_size,
|
||||
const uint8_t eNB_indexP
|
||||
)
|
||||
/** \brief Decodes a DL-DCCH message and invokes appropriate routine to handle the message
|
||||
\param ctxt_pP Running context
|
||||
\param Srb_id Index of Srb (1,2)
|
||||
\param Buffer Pointer to received SDU
|
||||
\param Buffer_size
|
||||
\param eNB_indexP Index of corresponding eNB/CH*/
|
||||
static void rrc_ue_decode_dcch(const protocol_ctxt_t *const ctxt_pP,
|
||||
const rb_id_t Srb_id,
|
||||
const uint8_t *const Buffer,
|
||||
const uint32_t Buffer_size,
|
||||
const uint8_t eNB_indexP)
|
||||
//-----------------------------------------------------------------------------
|
||||
{
|
||||
//DL_DCCH_Message_t dldcchmsg;
|
||||
@@ -2247,15 +2249,14 @@ rrc_ue_decode_dcch(
|
||||
/* This message hold a dedicated info NAS payload, forward it to NAS */
|
||||
struct LTE_DLInformationTransfer_r8_IEs__dedicatedInfoType *dedicatedInfoType =
|
||||
&dlInformationTransfer->criticalExtensions.choice.c1.choice.dlInformationTransfer_r8.dedicatedInfoType;
|
||||
uint32_t pdu_length;
|
||||
uint8_t *pdu_buffer;
|
||||
MessageDef *msg_p;
|
||||
pdu_length = dedicatedInfoType->choice.dedicatedInfoNAS.size;
|
||||
pdu_buffer = dedicatedInfoType->choice.dedicatedInfoNAS.buf;
|
||||
uint32_t pdu_length = dedicatedInfoType->choice.dedicatedInfoNAS.size;
|
||||
uint8_t *pdu_buffer = malloc(pdu_length);
|
||||
memcpy(pdu_buffer, dedicatedInfoType->choice.dedicatedInfoNAS.buf, pdu_length);
|
||||
msg_p = itti_alloc_new_message(TASK_RRC_UE, 0, NAS_DOWNLINK_DATA_IND);
|
||||
NAS_DOWNLINK_DATA_IND(msg_p).UEid = ctxt_pP->module_id; // TODO set the UEid to something else ?
|
||||
NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.length = pdu_length;
|
||||
NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.data = pdu_buffer;
|
||||
NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.nas_data = pdu_buffer;
|
||||
itti_send_msg_to_task(TASK_NAS_UE, ctxt_pP->instance, msg_p);
|
||||
}
|
||||
|
||||
@@ -2918,7 +2919,7 @@ int decode_BCCH_DLSCH_Message(
|
||||
}
|
||||
|
||||
if (rrc_get_sub_state(ctxt_pP->module_id) == RRC_SUB_STATE_IDLE_SIB_COMPLETE) {
|
||||
if ( (UE_rrc_inst[ctxt_pP->module_id].initialNasMsg.data != NULL) || (!EPC_MODE_ENABLED)) {
|
||||
if ((UE_rrc_inst[ctxt_pP->module_id].initialNasMsg.nas_data != NULL) || (!EPC_MODE_ENABLED)) {
|
||||
rrc_ue_generate_RRCConnectionRequest(ctxt_pP, 0);
|
||||
rrc_set_sub_state( ctxt_pP->module_id, RRC_SUB_STATE_IDLE_CONNECTING );
|
||||
}
|
||||
@@ -5173,7 +5174,8 @@ void *rrc_ue_task( void *args_p ) {
|
||||
uint8_t *buffer;
|
||||
LOG_D(RRC, "[UE %d] Received %s: UEid %d\n", ue_mod_id, ITTI_MSG_NAME (msg_p), NAS_UPLINK_DATA_REQ (msg_p).UEid);
|
||||
/* Create message for PDCP (ULInformationTransfer_t) */
|
||||
length = do_ULInformationTransfer(&buffer, NAS_UPLINK_DATA_REQ (msg_p).nasMsg.length, NAS_UPLINK_DATA_REQ (msg_p).nasMsg.data);
|
||||
length =
|
||||
do_ULInformationTransfer(&buffer, NAS_UPLINK_DATA_REQ(msg_p).nasMsg.length, NAS_UPLINK_DATA_REQ(msg_p).nasMsg.nas_data);
|
||||
/* Transfer data to PDCP */
|
||||
PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, ue_mod_id, ENB_FLAG_NO, UE_rrc_inst[ue_mod_id].Info[0].rnti, 0, 0,0);
|
||||
|
||||
|
||||
@@ -93,21 +93,6 @@ rrc_rx_tx_ue(
|
||||
\param eNB_index Index of corresponding eNB/CH*/
|
||||
int rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const SRB_INFO *const Srb_info, const uint8_t eNB_index );
|
||||
|
||||
/** \brief Decodes a DL-DCCH message and invokes appropriate routine to handle the message
|
||||
\param ctxt_pP Running context
|
||||
\param Srb_id Index of Srb (1,2)
|
||||
\param Buffer Pointer to received SDU
|
||||
\param Buffer_size
|
||||
\param eNB_indexP Index of corresponding eNB/CH*/
|
||||
void
|
||||
rrc_ue_decode_dcch(
|
||||
const protocol_ctxt_t *const ctxt_pP,
|
||||
const rb_id_t Srb_id,
|
||||
const uint8_t *const Buffer,
|
||||
const uint32_t Buffer_size,
|
||||
const uint8_t eNB_indexP
|
||||
);
|
||||
|
||||
int decode_SL_Discovery_Message(
|
||||
const protocol_ctxt_t *const ctxt_pP,
|
||||
const uint8_t eNB_index,
|
||||
@@ -123,17 +108,6 @@ rrc_ue_generate_RRCConnectionRequest(
|
||||
const uint8_t eNB_index
|
||||
);
|
||||
|
||||
/** \brief process the received rrcConnectionReconfiguration message at UE
|
||||
\param ctxt_pP Running context
|
||||
\param *rrcConnectionReconfiguration pointer to the sturcture
|
||||
\param eNB_index Index of corresponding eNB/CH*/
|
||||
void
|
||||
rrc_ue_process_rrcConnectionReconfiguration(
|
||||
const protocol_ctxt_t *const ctxt_pP,
|
||||
LTE_RRCConnectionReconfiguration_t *rrcConnectionReconfiguration,
|
||||
uint8_t eNB_index
|
||||
);
|
||||
|
||||
/** \brief Establish SRB1 based on configuration in SRB_ToAddMod structure. Configures RLC/PDCP accordingly
|
||||
\param module_idP Instance ID of UE
|
||||
\param frameP Frame index
|
||||
|
||||
@@ -189,10 +189,10 @@ static void nr_rrc_ue_process_rrcReconfiguration(NR_UE_RRC_INST_t *rrc,
|
||||
struct NR_RRCReconfiguration_v1530_IEs__dedicatedNAS_MessageList *tmp = ext->dedicatedNAS_MessageList;
|
||||
for (int i = 0; i < tmp->list.count; i++) {
|
||||
MessageDef *ittiMsg = itti_alloc_new_message(TASK_RRC_NRUE, rrc->ue_id, NAS_CONN_ESTABLI_CNF);
|
||||
NasConnEstabCnf *msg = &NAS_CONN_ESTABLI_CNF(ittiMsg);
|
||||
nas_establish_cnf_t *msg = &NAS_CONN_ESTABLI_CNF(ittiMsg);
|
||||
msg->errCode = AS_SUCCESS;
|
||||
msg->nasMsg.length = tmp->list.array[i]->size;
|
||||
msg->nasMsg.data = tmp->list.array[i]->buf;
|
||||
msg->nasMsg.nas_data = tmp->list.array[i]->buf;
|
||||
itti_send_msg_to_task(TASK_NAS_NRUE, rrc->ue_id, ittiMsg);
|
||||
}
|
||||
tmp->list.count = 0; // to prevent the automatic free by ASN1_FREE
|
||||
@@ -998,7 +998,7 @@ static void rrc_ue_generate_RRCSetupComplete(const NR_UE_RRC_INST_t *rrc, const
|
||||
as_nas_info_t initialNasMsg;
|
||||
nr_ue_nas_t *nas = get_ue_nas_info(rrc->ue_id);
|
||||
generateRegistrationRequest(&initialNasMsg, nas);
|
||||
nas_msg = (char*)initialNasMsg.data;
|
||||
nas_msg = (char *)initialNasMsg.nas_data;
|
||||
nas_msg_length = initialNasMsg.length;
|
||||
} else {
|
||||
nas_msg = nr_nas_attach_req_imsi_dummy_NSA_case;
|
||||
@@ -1751,10 +1751,11 @@ static int nr_rrc_ue_decode_dcch(NR_UE_RRC_INST_t *rrc,
|
||||
dlInformationTransfer->criticalExtensions.choice.dlInformationTransfer->dedicatedNAS_Message;
|
||||
|
||||
MessageDef *ittiMsg = itti_alloc_new_message(TASK_RRC_NRUE, rrc->ue_id, NAS_DOWNLINK_DATA_IND);
|
||||
NasDlDataInd *msg = &NAS_DOWNLINK_DATA_IND(ittiMsg);
|
||||
dl_info_transfer_ind_t *msg = &NAS_DOWNLINK_DATA_IND(ittiMsg);
|
||||
msg->UEid = rrc->ue_id;
|
||||
msg->nasMsg.length = dedicatedNAS_Message->size;
|
||||
msg->nasMsg.data = dedicatedNAS_Message->buf;
|
||||
msg->nasMsg.nas_data = malloc(msg->nasMsg.length);
|
||||
memcpy(msg->nasMsg.nas_data, dedicatedNAS_Message->buf, msg->nasMsg.length);
|
||||
itti_send_msg_to_task(TASK_NAS_NRUE, rrc->ue_id, ittiMsg);
|
||||
dedicatedNAS_Message->buf = NULL; // to keep the buffer, up to NAS to free it
|
||||
}
|
||||
@@ -1907,15 +1908,15 @@ void *rrc_nrue(void *notUsed)
|
||||
case NAS_UPLINK_DATA_REQ: {
|
||||
uint32_t length;
|
||||
uint8_t *buffer = NULL;
|
||||
NasUlDataReq *req = &NAS_UPLINK_DATA_REQ(msg_p);
|
||||
ul_info_transfer_req_t *req = &NAS_UPLINK_DATA_REQ(msg_p);
|
||||
/* Create message for PDCP (ULInformationTransfer_t) */
|
||||
length = do_NR_ULInformationTransfer(&buffer, req->nasMsg.length, req->nasMsg.data);
|
||||
length = do_NR_ULInformationTransfer(&buffer, req->nasMsg.length, req->nasMsg.nas_data);
|
||||
/* Transfer data to PDCP */
|
||||
// check if SRB2 is created, if yes request data_req on SRB2
|
||||
// error: the remote gNB is hardcoded here
|
||||
rb_id_t srb_id = rrc->Srb[2] == RB_ESTABLISHED ? 2 : 1;
|
||||
nr_pdcp_data_req_srb(rrc->ue_id, srb_id, 0, length, buffer, deliver_pdu_srb_rlc, NULL);
|
||||
free(req->nasMsg.data);
|
||||
free(req->nasMsg.nas_data);
|
||||
free(buffer);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -80,65 +80,55 @@ int as_message_decode(const char* buffer, as_message_t* msg, int length)
|
||||
{
|
||||
LOG_FUNC_IN;
|
||||
|
||||
int bytes;
|
||||
/* pointers to msg fields possibly not aligned because msg points to a packed structure
|
||||
* Using these possibly unaligned pointers in a function call may trigger alignment errors at run time and
|
||||
* gcc, from v9, now warns about it. fix these warnings by removing the indirection on data
|
||||
* (in fact i don't understand this code data seems to be useless...)
|
||||
*/
|
||||
Byte_t *data = NULL;
|
||||
* Using these possibly unaligned pointers in a function call may trigger alignment errors at run time and
|
||||
* gcc, from v9, now warns about it. fix these warnings by removing the indirection on data
|
||||
* (in fact i don't understand this code data seems to be useless...)
|
||||
*/
|
||||
|
||||
/* Get the message type */
|
||||
msg->msgID = *(uint16_t*)(buffer);
|
||||
bytes = sizeof(uint16_t);
|
||||
int bytes = 0;
|
||||
|
||||
switch (msg->msgID) {
|
||||
case AS_NAS_ESTABLISH_REQ:
|
||||
/* NAS signalling connection establish request */
|
||||
bytes += sizeof(nas_establish_req_t) - sizeof(Byte_t*);
|
||||
data = msg->msg.nas_establish_req.initialNasMsg.data;
|
||||
bytes = sizeof(uint16_t) + sizeof(nas_establish_req_t) - sizeof(as_nas_info_t);
|
||||
break;
|
||||
|
||||
case AS_NAS_ESTABLISH_IND:
|
||||
/* NAS signalling connection establishment indication */
|
||||
bytes += sizeof(nas_establish_ind_t) - sizeof(Byte_t*);
|
||||
data = msg->msg.nas_establish_ind.initialNasMsg.data;
|
||||
bytes = sizeof(uint16_t) + sizeof(nas_establish_ind_t) - sizeof(as_nas_info_t);
|
||||
break;
|
||||
|
||||
case AS_NAS_ESTABLISH_RSP:
|
||||
/* NAS signalling connection establishment response */
|
||||
bytes += sizeof(nas_establish_rsp_t) - sizeof(Byte_t*);
|
||||
data = msg->msg.nas_establish_rsp.nasMsg.data;
|
||||
bytes = sizeof(uint16_t) + sizeof(nas_establish_rsp_t) - sizeof(as_nas_info_t);
|
||||
break;
|
||||
|
||||
case AS_NAS_ESTABLISH_CNF:
|
||||
/* NAS signalling connection establishment confirm */
|
||||
bytes += sizeof(nas_establish_cnf_t) - sizeof(Byte_t*);
|
||||
data = msg->msg.nas_establish_cnf.nasMsg.data;
|
||||
bytes = sizeof(uint16_t) + sizeof(nas_establish_cnf_t) - sizeof(as_nas_info_t);
|
||||
break;
|
||||
|
||||
case AS_UL_INFO_TRANSFER_REQ:
|
||||
/* Uplink L3 data transfer request */
|
||||
bytes += sizeof(ul_info_transfer_req_t) - sizeof(Byte_t*);
|
||||
data = msg->msg.ul_info_transfer_req.nasMsg.data;
|
||||
bytes = sizeof(uint16_t) + sizeof(ul_info_transfer_req_t) - sizeof(as_nas_info_t);
|
||||
break;
|
||||
|
||||
case AS_UL_INFO_TRANSFER_IND:
|
||||
/* Uplink L3 data transfer indication */
|
||||
bytes += sizeof(ul_info_transfer_ind_t) - sizeof(Byte_t*);
|
||||
data = msg->msg.ul_info_transfer_ind.nasMsg.data;
|
||||
bytes = sizeof(uint16_t) + sizeof(ul_info_transfer_ind_t) - sizeof(as_nas_info_t);
|
||||
break;
|
||||
|
||||
case AS_DL_INFO_TRANSFER_REQ:
|
||||
/* Downlink L3 data transfer request */
|
||||
bytes += sizeof(dl_info_transfer_req_t) - sizeof(Byte_t*);
|
||||
data = msg->msg.dl_info_transfer_req.nasMsg.data;
|
||||
bytes = sizeof(uint16_t) + sizeof(dl_info_transfer_req_t) - sizeof(as_nas_info_t);
|
||||
break;
|
||||
|
||||
case AS_DL_INFO_TRANSFER_IND:
|
||||
/* Downlink L3 data transfer indication */
|
||||
bytes += sizeof(dl_info_transfer_ind_t) - sizeof(Byte_t*);
|
||||
data = msg->msg.dl_info_transfer_ind.nasMsg.data;
|
||||
bytes = sizeof(uint16_t) + sizeof(dl_info_transfer_ind_t) - sizeof(as_nas_info_t);
|
||||
break;
|
||||
|
||||
case AS_BROADCAST_INFO_IND:
|
||||
@@ -169,14 +159,8 @@ int as_message_decode(const char* buffer, as_message_t* msg, int length)
|
||||
}
|
||||
|
||||
if (bytes > 0) {
|
||||
if (data) {
|
||||
/* Set the pointer to dedicated NAS information */
|
||||
/* wasn't data already computed above for specific cases here we override ?? */
|
||||
data = (Byte_t *)buffer + bytes;
|
||||
}
|
||||
|
||||
/* Decode the message */
|
||||
memcpy(msg, (as_message_t*)buffer, bytes);
|
||||
memcpy(msg, buffer, bytes);
|
||||
LOG_FUNC_RETURN (msg->msgID);
|
||||
}
|
||||
|
||||
@@ -254,7 +238,7 @@ int as_message_encode(char* buffer, as_message_t* msg, int length)
|
||||
/* NAS signalling connection establish indication */
|
||||
bytes += sizeof(nas_establish_ind_t) - sizeof(Byte_t*);
|
||||
nas_msg = msg->msg.nas_establish_ind.initialNasMsg;
|
||||
dataptr=(Byte_t *)&(msg->msg.nas_establish_ind.initialNasMsg.data);
|
||||
dataptr = (Byte_t*)&(msg->msg.nas_establish_ind.initialNasMsg.nas_data);
|
||||
len=msg->msg.nas_establish_ind.initialNasMsg.length;
|
||||
break;
|
||||
|
||||
@@ -269,7 +253,7 @@ int as_message_encode(char* buffer, as_message_t* msg, int length)
|
||||
/* NAS signalling connection establish confirm */
|
||||
bytes += sizeof(nas_establish_cnf_t) - sizeof(Byte_t*);
|
||||
nas_msg = msg->msg.nas_establish_cnf.nasMsg;
|
||||
dataptr=(Byte_t *)&(msg->msg.nas_establish_cnf.nasMsg.data);
|
||||
dataptr = (Byte_t*)&(msg->msg.nas_establish_cnf.nasMsg.nas_data);
|
||||
len=msg->msg.nas_establish_ind.initialNasMsg.length;
|
||||
break;
|
||||
|
||||
@@ -361,10 +345,10 @@ int as_message_encode(char* buffer, as_message_t* msg, int length)
|
||||
|
||||
if ( (dataptr!=NULL) && (len > 0) ) {
|
||||
/* Copy the NAS message */
|
||||
memcpy(buffer + bytes, nas_msg.data, nas_msg.length);
|
||||
memcpy(buffer + bytes, nas_msg.nas_data, nas_msg.length);
|
||||
bytes += len;
|
||||
/* Release NAS message memory */
|
||||
free(nas_msg.data);
|
||||
free(nas_msg.nas_data);
|
||||
len=0;
|
||||
dataptr = NULL;
|
||||
}
|
||||
|
||||
@@ -91,19 +91,12 @@ static struct {
|
||||
/*
|
||||
* The buffer used to receive data from the network sublayer
|
||||
*/
|
||||
#define NETWORK_API_RECV_BUFFER_SIZE 4096
|
||||
static char _network_api_recv_buffer[NETWORK_API_RECV_BUFFER_SIZE];
|
||||
#define NETWORK_API_RECV_BUFFER_SIZE 4096
|
||||
|
||||
/*
|
||||
* The buffer used to send data to the network sublayer
|
||||
*/
|
||||
#define NETWORK_API_SEND_BUFFER_SIZE NETWORK_API_RECV_BUFFER_SIZE
|
||||
static char _network_api_send_buffer[NETWORK_API_SEND_BUFFER_SIZE];
|
||||
|
||||
/*
|
||||
* The decoded data received from the network sublayer
|
||||
*/
|
||||
static as_message_t _as_data = {}; /* Access Stratum message */
|
||||
#define NETWORK_API_SEND_BUFFER_SIZE NETWORK_API_RECV_BUFFER_SIZE
|
||||
|
||||
/****************************************************************************/
|
||||
/****************** E X P O R T E D F U N C T I O N S ******************/
|
||||
@@ -148,6 +141,7 @@ int network_api_initialize(const char* host, const char* port)
|
||||
((errno < 0) ? gai_strerror(errno) : strerror(errno)));
|
||||
LOG_FUNC_RETURN (RETURNerror);
|
||||
}
|
||||
char _network_api_send_buffer[NETWORK_API_SEND_BUFFER_SIZE];
|
||||
|
||||
gethostname(_network_api_send_buffer, NETWORK_API_SEND_BUFFER_SIZE);
|
||||
LOG_TRACE(INFO, "NET-API - Network's UDP socket %d is BOUND to %s/%s",
|
||||
@@ -177,27 +171,6 @@ int network_api_get_fd(void)
|
||||
LOG_FUNC_RETURN (NETWORK_API_GETFD());
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
** **
|
||||
** Name: network_api_get_data() **
|
||||
** **
|
||||
** Description: Get a generic pointer to the network data structure. **
|
||||
** Casting to the proper type is necessary before its usage. **
|
||||
** **
|
||||
** Inputs: None **
|
||||
** Others: _as_data **
|
||||
** **
|
||||
** Outputs: Return: A generic pointer to the network data **
|
||||
** structure **
|
||||
** Others: None **
|
||||
** **
|
||||
***************************************************************************/
|
||||
const void* network_api_get_data(void)
|
||||
{
|
||||
LOG_FUNC_IN;
|
||||
LOG_FUNC_RETURN ((void*)(&_as_data));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
** **
|
||||
** Name: network_api_read_data() **
|
||||
@@ -213,7 +186,7 @@ const void* network_api_get_data(void)
|
||||
** Others: _network_api_recv_buffer, _network_api_id **
|
||||
** **
|
||||
***************************************************************************/
|
||||
int network_api_read_data(int fd)
|
||||
int network_api_read_data(int fd, char* _network_api_recv_buffer)
|
||||
{
|
||||
LOG_FUNC_IN;
|
||||
|
||||
@@ -263,7 +236,7 @@ int network_api_read_data(int fd)
|
||||
** Others: None **
|
||||
** **
|
||||
***************************************************************************/
|
||||
int network_api_send_data(int fd, int length)
|
||||
static int network_api_send_data(int fd, int length, char* _network_api_send_buffer)
|
||||
{
|
||||
LOG_FUNC_IN;
|
||||
|
||||
@@ -346,12 +319,12 @@ void network_api_close(int fd)
|
||||
** Others: _as_data **
|
||||
** **
|
||||
***************************************************************************/
|
||||
int network_api_decode_data(int length)
|
||||
int network_api_decode_data(char* _network_api_recv_buffer, int length, as_message_t* _as_data)
|
||||
{
|
||||
LOG_FUNC_IN;
|
||||
|
||||
/* Decode the Access Stratum message received from the network */
|
||||
int as_id = as_message_decode(_network_api_recv_buffer, &_as_data, length);
|
||||
int as_id = as_message_decode(_network_api_recv_buffer, _as_data, length);
|
||||
|
||||
if (as_id != RETURNerror) {
|
||||
LOG_TRACE(INFO, "NET-API - AS message id=0x%x successfully decoded",
|
||||
@@ -376,7 +349,7 @@ int network_api_decode_data(int length)
|
||||
** Others: _network_api_send_buffer **
|
||||
** **
|
||||
***************************************************************************/
|
||||
int network_api_encode_data(void* data)
|
||||
static int network_api_encode_data(void* data, char* _network_api_send_buffer)
|
||||
{
|
||||
LOG_FUNC_IN;
|
||||
|
||||
@@ -415,9 +388,10 @@ int as_message_send(as_message_t* as_msg)
|
||||
|
||||
LOG_TRACE(INFO, "NET-API - Send message 0x%.4x to the Access Stratum "
|
||||
"layer", as_msg->msgID);
|
||||
char _network_api_send_buffer[NETWORK_API_SEND_BUFFER_SIZE];
|
||||
|
||||
/* Encode the AS message */
|
||||
bytes = network_api_encode_data(as_msg);
|
||||
bytes = network_api_encode_data(as_msg, _network_api_send_buffer);
|
||||
|
||||
if (bytes > 0) {
|
||||
/* Get the network file descriptor */
|
||||
@@ -425,7 +399,7 @@ int as_message_send(as_message_t* as_msg)
|
||||
|
||||
if (fd != RETURNerror) {
|
||||
/* Send the AS message to the network */
|
||||
bytes = network_api_send_data(fd, bytes);
|
||||
bytes = network_api_send_data(fd, bytes, _network_api_send_buffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,17 +55,14 @@ Description Implements the API used by the NAS layer to send/receive
|
||||
/****************************************************************************/
|
||||
/****************** E X P O R T E D F U N C T I O N S ******************/
|
||||
/****************************************************************************/
|
||||
|
||||
#include "openair2/COMMON/as_message.h"
|
||||
int network_api_initialize(const char* host, const char* port);
|
||||
|
||||
int network_api_get_fd(void);
|
||||
const void* network_api_get_data(void);
|
||||
|
||||
int network_api_read_data(int fd);
|
||||
int network_api_send_data(int fd, int length);
|
||||
int network_api_read_data(int fd, char *_network_api_recv_buffer);
|
||||
void network_api_close(int fd);
|
||||
|
||||
int network_api_decode_data(int length);
|
||||
int network_api_encode_data(void* data);
|
||||
int network_api_decode_data(char *_network_api_recv_buffer, int length, as_message_t *_as_data);
|
||||
|
||||
#endif /* __NETWORK_API_H__*/
|
||||
|
||||
@@ -543,10 +543,10 @@ void generateRegistrationRequest(as_nas_info_t *initialNasMsg, nr_ue_nas_t *nas)
|
||||
size += 10;
|
||||
|
||||
// encode the message
|
||||
initialNasMsg->data = malloc16_clear(size * sizeof(Byte_t));
|
||||
nas->registration_request_buf = initialNasMsg->data;
|
||||
initialNasMsg->nas_data = malloc16_clear(size * sizeof(Byte_t));
|
||||
nas->registration_request_buf = initialNasMsg->nas_data;
|
||||
|
||||
initialNasMsg->length = mm_msg_encode(mm_msg, (uint8_t *)(initialNasMsg->data), size);
|
||||
initialNasMsg->length = mm_msg_encode(mm_msg, initialNasMsg->nas_data, size);
|
||||
nas->registration_request_len = initialNasMsg->length;
|
||||
}
|
||||
|
||||
@@ -575,9 +575,9 @@ void generateIdentityResponse(as_nas_info_t *initialNasMsg, uint8_t identitytype
|
||||
}
|
||||
|
||||
// encode the message
|
||||
initialNasMsg->data = (Byte_t *)malloc(size * sizeof(Byte_t));
|
||||
initialNasMsg->nas_data = malloc(size * sizeof(Byte_t));
|
||||
|
||||
initialNasMsg->length = mm_msg_encode(mm_msg, (uint8_t *)(initialNasMsg->data), size);
|
||||
initialNasMsg->length = mm_msg_encode(mm_msg, initialNasMsg->nas_data, size);
|
||||
}
|
||||
|
||||
static void generateAuthenticationResp(nr_ue_nas_t *nas, as_nas_info_t *initialNasMsg, uint8_t *buf)
|
||||
@@ -611,9 +611,9 @@ static void generateAuthenticationResp(nr_ue_nas_t *nas, as_nas_info_t *initialN
|
||||
mm_msg->fgs_auth_response.authenticationresponseparameter.res = res;
|
||||
size += 18;
|
||||
// encode the message
|
||||
initialNasMsg->data = (Byte_t *)malloc(size * sizeof(Byte_t));
|
||||
initialNasMsg->nas_data = malloc(size * sizeof(Byte_t));
|
||||
|
||||
initialNasMsg->length = mm_msg_encode(mm_msg, (uint8_t *)(initialNasMsg->data), size);
|
||||
initialNasMsg->length = mm_msg_encode(mm_msg, initialNasMsg->nas_data, size);
|
||||
// Free res value after encode
|
||||
free(res.value);
|
||||
}
|
||||
@@ -663,13 +663,13 @@ static void generateSecurityModeComplete(nr_ue_nas_t *nas, as_nas_info_t *initia
|
||||
size += (nas->registration_request_len + 2);
|
||||
|
||||
// encode the message
|
||||
initialNasMsg->data = (Byte_t *)malloc(size * sizeof(Byte_t));
|
||||
initialNasMsg->nas_data = malloc(size * sizeof(Byte_t));
|
||||
|
||||
int security_header_len = nas_protected_security_header_encode((char *)(initialNasMsg->data), &(nas_msg.header), size);
|
||||
int security_header_len = nas_protected_security_header_encode((char *)(initialNasMsg->nas_data), &(nas_msg.header), size);
|
||||
|
||||
initialNasMsg->length =
|
||||
security_header_len
|
||||
+ mm_msg_encode(mm_msg, (uint8_t *)(initialNasMsg->data + security_header_len), size - security_header_len);
|
||||
+ mm_msg_encode(mm_msg, (uint8_t *)(initialNasMsg->nas_data + security_header_len), size - security_header_len);
|
||||
|
||||
/* ciphering */
|
||||
uint8_t buf[initialNasMsg->length - 7];
|
||||
@@ -678,7 +678,7 @@ static void generateSecurityModeComplete(nr_ue_nas_t *nas, as_nas_info_t *initia
|
||||
stream_cipher.count = nas->security.nas_count_ul;
|
||||
stream_cipher.bearer = 1;
|
||||
stream_cipher.direction = 0;
|
||||
stream_cipher.message = (unsigned char *)(initialNasMsg->data + 7);
|
||||
stream_cipher.message = (unsigned char *)(initialNasMsg->nas_data + 7);
|
||||
/* length in bits */
|
||||
stream_cipher.blength = (initialNasMsg->length - 7) << 3;
|
||||
stream_compute_encrypt(nas->security_container->ciphering_algorithm, &stream_cipher, buf);
|
||||
@@ -689,7 +689,7 @@ static void generateSecurityModeComplete(nr_ue_nas_t *nas, as_nas_info_t *initia
|
||||
stream_cipher.count = nas->security.nas_count_ul++;
|
||||
stream_cipher.bearer = 1;
|
||||
stream_cipher.direction = 0;
|
||||
stream_cipher.message = (unsigned char *)(initialNasMsg->data + 6);
|
||||
stream_cipher.message = (unsigned char *)(initialNasMsg->nas_data + 6);
|
||||
/* length in bits */
|
||||
stream_cipher.blength = (initialNasMsg->length - 6) << 3;
|
||||
|
||||
@@ -697,7 +697,7 @@ static void generateSecurityModeComplete(nr_ue_nas_t *nas, as_nas_info_t *initia
|
||||
|
||||
printf("mac %x %x %x %x \n", mac[0], mac[1], mac[2], mac[3]);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
initialNasMsg->data[2 + i] = mac[i];
|
||||
initialNasMsg->nas_data[2 + i] = mac[i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -791,32 +791,32 @@ static void generateRegistrationComplete(nr_ue_nas_t *nas,
|
||||
}
|
||||
|
||||
// encode the message
|
||||
initialNasMsg->data = (Byte_t *)malloc(length * sizeof(Byte_t));
|
||||
initialNasMsg->nas_data = malloc(length * sizeof(Byte_t));
|
||||
initialNasMsg->length = length;
|
||||
|
||||
/* Encode the first octet of the header (extended protocol discriminator) */
|
||||
ENCODE_U8(initialNasMsg->data + size, sp_msg->header.protocol_discriminator, size);
|
||||
ENCODE_U8(initialNasMsg->nas_data + size, sp_msg->header.protocol_discriminator, size);
|
||||
|
||||
/* Encode the security header type */
|
||||
ENCODE_U8(initialNasMsg->data + size, sp_msg->header.security_header_type, size);
|
||||
ENCODE_U8(initialNasMsg->nas_data + size, sp_msg->header.security_header_type, size);
|
||||
|
||||
/* Encode the message authentication code */
|
||||
ENCODE_U32(initialNasMsg->data + size, sp_msg->header.message_authentication_code, size);
|
||||
ENCODE_U32(initialNasMsg->nas_data + size, sp_msg->header.message_authentication_code, size);
|
||||
|
||||
/* Encode the sequence number */
|
||||
ENCODE_U8(initialNasMsg->data + size, sp_msg->header.sequence_number, size);
|
||||
ENCODE_U8(initialNasMsg->nas_data + size, sp_msg->header.sequence_number, size);
|
||||
|
||||
/* Encode the extended protocol discriminator */
|
||||
ENCODE_U8(initialNasMsg->data + size, sp_msg->plain.mm_msg.registration_complete.protocoldiscriminator, size);
|
||||
ENCODE_U8(initialNasMsg->nas_data + size, sp_msg->plain.mm_msg.registration_complete.protocoldiscriminator, size);
|
||||
|
||||
/* Encode the security header type */
|
||||
ENCODE_U8(initialNasMsg->data + size, sp_msg->plain.mm_msg.registration_complete.securityheadertype, size);
|
||||
ENCODE_U8(initialNasMsg->nas_data + size, sp_msg->plain.mm_msg.registration_complete.securityheadertype, size);
|
||||
|
||||
/* Encode the message type */
|
||||
ENCODE_U8(initialNasMsg->data + size, sp_msg->plain.mm_msg.registration_complete.messagetype, size);
|
||||
ENCODE_U8(initialNasMsg->nas_data + size, sp_msg->plain.mm_msg.registration_complete.messagetype, size);
|
||||
|
||||
if (sortransparentcontainer) {
|
||||
encode_registration_complete(&sp_msg->plain.mm_msg.registration_complete, initialNasMsg->data + size, length - size);
|
||||
encode_registration_complete(&sp_msg->plain.mm_msg.registration_complete, initialNasMsg->nas_data + size, length - size);
|
||||
}
|
||||
|
||||
/* ciphering */
|
||||
@@ -826,7 +826,7 @@ static void generateRegistrationComplete(nr_ue_nas_t *nas,
|
||||
stream_cipher.count = nas->security.nas_count_ul;
|
||||
stream_cipher.bearer = 1;
|
||||
stream_cipher.direction = 0;
|
||||
stream_cipher.message = (unsigned char *)(initialNasMsg->data + 7);
|
||||
stream_cipher.message = (unsigned char *)(initialNasMsg->nas_data + 7);
|
||||
/* length in bits */
|
||||
stream_cipher.blength = (initialNasMsg->length - 7) << 3;
|
||||
stream_compute_encrypt(nas->security_container->ciphering_algorithm, &stream_cipher, buf);
|
||||
@@ -837,14 +837,14 @@ static void generateRegistrationComplete(nr_ue_nas_t *nas,
|
||||
stream_cipher.count = nas->security.nas_count_ul++;
|
||||
stream_cipher.bearer = 1;
|
||||
stream_cipher.direction = 0;
|
||||
stream_cipher.message = (unsigned char *)(initialNasMsg->data + 6);
|
||||
stream_cipher.message = (unsigned char *)(initialNasMsg->nas_data + 6);
|
||||
/* length in bits */
|
||||
stream_cipher.blength = (initialNasMsg->length - 6) << 3;
|
||||
stream_compute_integrity(nas->security_container->integrity_algorithm, &stream_cipher, mac);
|
||||
|
||||
printf("mac %x %x %x %x \n", mac[0], mac[1], mac[2], mac[3]);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
initialNasMsg->data[2 + i] = mac[i];
|
||||
initialNasMsg->nas_data[2 + i] = mac[i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -889,12 +889,12 @@ static void generateDeregistrationRequest(nr_ue_nas_t *nas, as_nas_info_t *initi
|
||||
size += fill_guti(&dereg_req->fgsmobileidentity, nas->guti);
|
||||
|
||||
// encode the message
|
||||
initialNasMsg->data = calloc(size, sizeof(Byte_t));
|
||||
int security_header_len = nas_protected_security_header_encode((char *)(initialNasMsg->data), &nas_msg.header, size);
|
||||
initialNasMsg->nas_data = calloc(size, sizeof(Byte_t));
|
||||
int security_header_len = nas_protected_security_header_encode((char *)(initialNasMsg->nas_data), &nas_msg.header, size);
|
||||
|
||||
initialNasMsg->length =
|
||||
security_header_len
|
||||
+ mm_msg_encode(&sp_msg->plain.mm_msg, (uint8_t *)(initialNasMsg->data + security_header_len), size - security_header_len);
|
||||
+ mm_msg_encode(&sp_msg->plain.mm_msg, (uint8_t *)(initialNasMsg->nas_data + security_header_len), size - security_header_len);
|
||||
|
||||
nas_stream_cipher_t stream_cipher;
|
||||
|
||||
@@ -905,7 +905,7 @@ static void generateDeregistrationRequest(nr_ue_nas_t *nas, as_nas_info_t *initi
|
||||
stream_cipher.count = nas->security.nas_count_ul;
|
||||
stream_cipher.bearer = 1;
|
||||
stream_cipher.direction = 0;
|
||||
stream_cipher.message = (unsigned char *)(initialNasMsg->data + 7);
|
||||
stream_cipher.message = (unsigned char *)(initialNasMsg->nas_data + 7);
|
||||
/* length in bits */
|
||||
stream_cipher.blength = (initialNasMsg->length - 7) << 3;
|
||||
stream_compute_encrypt(nas->security_container->ciphering_algorithm, &stream_cipher, buf);
|
||||
@@ -916,7 +916,7 @@ static void generateDeregistrationRequest(nr_ue_nas_t *nas, as_nas_info_t *initi
|
||||
stream_cipher.count = nas->security.nas_count_ul++;
|
||||
stream_cipher.bearer = 1;
|
||||
stream_cipher.direction = 0;
|
||||
stream_cipher.message = (unsigned char *)(initialNasMsg->data + 6);
|
||||
stream_cipher.message = (unsigned char *)(initialNasMsg->nas_data + 6);
|
||||
/* length in bits */
|
||||
stream_cipher.blength = (initialNasMsg->length - 6) << 3;
|
||||
uint8_t mac[4];
|
||||
@@ -924,7 +924,7 @@ static void generateDeregistrationRequest(nr_ue_nas_t *nas, as_nas_info_t *initi
|
||||
|
||||
printf("mac %x %x %x %x \n", mac[0], mac[1], mac[2], mac[3]);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
initialNasMsg->data[2 + i] = mac[i];
|
||||
initialNasMsg->nas_data[2 + i] = mac[i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -997,12 +997,12 @@ static void generatePduSessionEstablishRequest(nr_ue_nas_t *nas, as_nas_info_t *
|
||||
size += (1 + 1 + dnnSize + 1);
|
||||
|
||||
// encode the message
|
||||
initialNasMsg->data = (Byte_t *)malloc(size * sizeof(Byte_t));
|
||||
int security_header_len = nas_protected_security_header_encode((char *)(initialNasMsg->data), &(nas_msg.header), size);
|
||||
initialNasMsg->nas_data = (Byte_t *)malloc(size * sizeof(Byte_t));
|
||||
int security_header_len = nas_protected_security_header_encode((char *)(initialNasMsg->nas_data), &(nas_msg.header), size);
|
||||
|
||||
initialNasMsg->length =
|
||||
security_header_len
|
||||
+ mm_msg_encode(mm_msg, (uint8_t *)(initialNasMsg->data + security_header_len), size - security_header_len);
|
||||
+ mm_msg_encode(mm_msg, (uint8_t *)(initialNasMsg->nas_data + security_header_len), size - security_header_len);
|
||||
|
||||
// Free allocated memory after encode
|
||||
free(req_buffer);
|
||||
@@ -1016,7 +1016,7 @@ static void generatePduSessionEstablishRequest(nr_ue_nas_t *nas, as_nas_info_t *
|
||||
stream_cipher.count = nas->security.nas_count_ul;
|
||||
stream_cipher.bearer = 1;
|
||||
stream_cipher.direction = 0;
|
||||
stream_cipher.message = (unsigned char *)(initialNasMsg->data + 7);
|
||||
stream_cipher.message = (unsigned char *)(initialNasMsg->nas_data + 7);
|
||||
/* length in bits */
|
||||
stream_cipher.blength = (initialNasMsg->length - 7) << 3;
|
||||
stream_compute_encrypt(nas->security_container->ciphering_algorithm, &stream_cipher, buf);
|
||||
@@ -1027,14 +1027,14 @@ static void generatePduSessionEstablishRequest(nr_ue_nas_t *nas, as_nas_info_t *
|
||||
stream_cipher.count = nas->security.nas_count_ul++;
|
||||
stream_cipher.bearer = 1;
|
||||
stream_cipher.direction = 0;
|
||||
stream_cipher.message = (unsigned char *)(initialNasMsg->data + 6);
|
||||
stream_cipher.message = (unsigned char *)(initialNasMsg->nas_data + 6);
|
||||
/* length in bits */
|
||||
stream_cipher.blength = (initialNasMsg->length - 6) << 3;
|
||||
stream_compute_integrity(nas->security_container->integrity_algorithm, &stream_cipher, mac);
|
||||
|
||||
printf("mac %x %x %x %x \n", mac[0], mac[1], mac[2], mac[3]);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
initialNasMsg->data[2 + i] = mac[i];
|
||||
initialNasMsg->nas_data[2 + i] = mac[i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1080,7 +1080,7 @@ static void send_nas_uplink_data_req(nr_ue_nas_t *nas, const as_nas_info_t *init
|
||||
MessageDef *msg = itti_alloc_new_message(TASK_NAS_NRUE, nas->UE_id, NAS_UPLINK_DATA_REQ);
|
||||
ul_info_transfer_req_t *req = &NAS_UPLINK_DATA_REQ(msg);
|
||||
req->UEid = nas->UE_id;
|
||||
req->nasMsg.data = (uint8_t *)initial_nas_msg->data;
|
||||
req->nasMsg.nas_data = (uint8_t *)initial_nas_msg->nas_data;
|
||||
req->nasMsg.length = initial_nas_msg->length;
|
||||
itti_send_msg_to_task(TASK_RRC_NRUE, nas->UE_id, msg);
|
||||
}
|
||||
@@ -1313,7 +1313,7 @@ void *nas_nrue(void *args_p)
|
||||
NAS_CONN_ESTABLI_CNF(msg_p).errCode,
|
||||
NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.length);
|
||||
|
||||
uint8_t *pdu_buffer = NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.data;
|
||||
uint8_t *pdu_buffer = NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.nas_data;
|
||||
int pdu_length = NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.length;
|
||||
|
||||
security_state_t security_state = nas_security_rx_process(nas, pdu_buffer, pdu_length);
|
||||
@@ -1382,10 +1382,10 @@ void *nas_nrue(void *args_p)
|
||||
nas->UE_id,
|
||||
ITTI_MSG_NAME(msg_p),
|
||||
NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.length,
|
||||
NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.data);
|
||||
NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.nas_data);
|
||||
as_nas_info_t initialNasMsg = {0};
|
||||
|
||||
uint8_t *pdu_buffer = NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.data;
|
||||
uint8_t *pdu_buffer = NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.nas_data;
|
||||
int pdu_length = NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.length;
|
||||
|
||||
security_state_t security_state = nas_security_rx_process(nas, pdu_buffer, pdu_length);
|
||||
|
||||
@@ -147,13 +147,11 @@ static int _emm_as_cell_info_req(const emm_as_cell_info_t *, cell_info_req_t *);
|
||||
* On X86 this is not fatal, as at run time the problem can be fixed (but it's better for perf to avoid). On other
|
||||
* processor as Arm i think it can end in seg fault
|
||||
*/
|
||||
static int _emm_as_security_res(const emm_data_t *emm_data, const emm_as_security_t *,
|
||||
void *ul_info_transfer_req_unaligned);
|
||||
static int _emm_as_establish_req(const emm_data_t *emm_data, const emm_as_establish_t *,
|
||||
void *nas_establish_req_unaligned);
|
||||
static int _emm_as_data_req(const emm_data_t *emm_data, const emm_as_data_t *msg, void *ul_info_transfer_req_unaligned);
|
||||
static int _emm_as_status_ind(const emm_data_t *emm_data, const emm_as_status_t *, void *ul_info_transfer_req_unaligned);
|
||||
static int _emm_as_release_req(const emm_as_release_t *, void *nas_release_req_unaligned);
|
||||
static int _emm_as_security_res(const emm_data_t *emm_data, const emm_as_security_t *, ul_info_transfer_req_t *as_msg);
|
||||
static int _emm_as_establish_req(const emm_data_t *emm_data, const emm_as_establish_t *, nas_establish_req_t *);
|
||||
static int _emm_as_data_req(const emm_data_t *emm_data, const emm_as_data_t *msg, ul_info_transfer_req_t *as_msg);
|
||||
static int _emm_as_status_ind(const emm_data_t *emm_data, const emm_as_status_t *, ul_info_transfer_req_t *as_msg);
|
||||
static int _emm_as_release_req(const emm_as_release_t *, nas_release_req_t *as_msg);
|
||||
|
||||
/****************************************************************************/
|
||||
/****************** E X P O R T E D F U N C T I O N S ******************/
|
||||
@@ -839,22 +837,18 @@ _emm_as_encode(
|
||||
}
|
||||
|
||||
/* Allocate memory to the NAS information container */
|
||||
info->data = (Byte_t *)malloc(length * sizeof(Byte_t));
|
||||
info->nas_data = malloc(length * sizeof(Byte_t));
|
||||
|
||||
if (info->data != NULL) {
|
||||
if (info->nas_data != NULL) {
|
||||
/* Encode the NAS message */
|
||||
bytes = nas_message_encode(
|
||||
(char *)(info->data),
|
||||
msg,
|
||||
length,
|
||||
emm_security_context);
|
||||
bytes = nas_message_encode((char *)(info->nas_data), msg, length, emm_security_context);
|
||||
|
||||
if (bytes > 0) {
|
||||
info->length = bytes;
|
||||
} else {
|
||||
free(info->data);
|
||||
free(info->nas_data);
|
||||
info->length = 0;
|
||||
info->data = NULL;
|
||||
info->nas_data = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -895,23 +889,18 @@ _emm_as_encrypt(
|
||||
}
|
||||
|
||||
/* Allocate memory to the NAS information container */
|
||||
info->data = (Byte_t *)malloc(length * sizeof(Byte_t));
|
||||
info->nas_data = malloc(length * sizeof(Byte_t));
|
||||
|
||||
if (info->data != NULL) {
|
||||
if (info->nas_data != NULL) {
|
||||
/* Encrypt the NAS information message */
|
||||
bytes = nas_message_encrypt(
|
||||
msg,
|
||||
(char *)(info->data),
|
||||
header,
|
||||
length,
|
||||
emm_security_context);
|
||||
bytes = nas_message_encrypt(msg, (char *)(info->nas_data), header, length, emm_security_context);
|
||||
|
||||
if (bytes > 0) {
|
||||
info->length = bytes;
|
||||
} else {
|
||||
free(info->data);
|
||||
free(info->nas_data);
|
||||
info->length = 0;
|
||||
info->data = NULL;
|
||||
info->nas_data = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -938,41 +927,38 @@ static int _emm_as_send(const nas_user_t *user, const emm_as_t *msg)
|
||||
{
|
||||
LOG_FUNC_IN;
|
||||
|
||||
as_message_t as_msg;
|
||||
memset(&as_msg, 0 , sizeof(as_message_t));
|
||||
as_message_t as_msg = {0};
|
||||
|
||||
switch (msg->primitive) {
|
||||
case _EMMAS_DATA_REQ:
|
||||
as_msg.msgID = _emm_as_data_req(user->emm_data,
|
||||
&msg->u.data,
|
||||
(void *)(&as_msg.msg.ul_info_transfer_req));
|
||||
break;
|
||||
case _EMMAS_DATA_REQ: {
|
||||
ul_info_transfer_req_t ul = {0};
|
||||
as_msg.msgID = _emm_as_data_req(user->emm_data, &msg->u.data, &ul);
|
||||
as_msg.msg.ul_info_transfer_req = ul;
|
||||
} break;
|
||||
|
||||
case _EMMAS_STATUS_IND:
|
||||
as_msg.msgID = _emm_as_status_ind(user->emm_data,
|
||||
&msg->u.status,
|
||||
(void *)(&as_msg.msg.ul_info_transfer_req));
|
||||
break;
|
||||
case _EMMAS_STATUS_IND: {
|
||||
ul_info_transfer_req_t st = {0};
|
||||
as_msg.msgID = _emm_as_status_ind(user->emm_data, &msg->u.status, &st);
|
||||
as_msg.msg.ul_info_transfer_req = st;
|
||||
} break;
|
||||
|
||||
case _EMMAS_RELEASE_REQ:
|
||||
as_msg.msgID = _emm_as_release_req(
|
||||
&msg->u.release,
|
||||
(void *)(&as_msg.msg.nas_release_req));
|
||||
break;
|
||||
case _EMMAS_RELEASE_REQ: {
|
||||
nas_release_req_t rel = {0};
|
||||
as_msg.msgID = _emm_as_release_req(&msg->u.release, &rel);
|
||||
as_msg.msg.nas_release_req = rel;
|
||||
} break;
|
||||
|
||||
case _EMMAS_SECURITY_RES: {
|
||||
ul_info_transfer_req_t ul = {0};
|
||||
as_msg.msgID = _emm_as_security_res(user->emm_data, &msg->u.security, &ul);
|
||||
as_msg.msg.ul_info_transfer_req = ul;
|
||||
} break;
|
||||
|
||||
case _EMMAS_SECURITY_RES:
|
||||
as_msg.msgID = _emm_as_security_res(user->emm_data,
|
||||
&msg->u.security,
|
||||
(void *)(&as_msg.msg.ul_info_transfer_req));
|
||||
break;
|
||||
|
||||
case _EMMAS_ESTABLISH_REQ:
|
||||
as_msg.msgID = _emm_as_establish_req(user->emm_data,
|
||||
&msg->u.establish,
|
||||
(void *)(&as_msg.msg.nas_establish_req));
|
||||
break;
|
||||
|
||||
case _EMMAS_ESTABLISH_REQ: {
|
||||
nas_establish_req_t nas_establish_req = {0};
|
||||
as_msg.msgID = _emm_as_establish_req(user->emm_data, &msg->u.establish, &nas_establish_req);
|
||||
as_msg.msg.nas_establish_req = nas_establish_req;
|
||||
} break;
|
||||
|
||||
case _EMMAS_CELL_INFO_REQ:
|
||||
as_msg.msgID = _emm_as_cell_info_req(&msg->u.cell_info,
|
||||
@@ -1009,24 +995,22 @@ static int _emm_as_send(const nas_user_t *user, const emm_as_t *msg)
|
||||
break;
|
||||
|
||||
case AS_NAS_ESTABLISH_REQ: {
|
||||
nas_itti_nas_establish_req(
|
||||
as_msg.msg.nas_establish_req.cause,
|
||||
as_msg.msg.nas_establish_req.type,
|
||||
as_msg.msg.nas_establish_req.s_tmsi,
|
||||
as_msg.msg.nas_establish_req.plmnID,
|
||||
as_msg.msg.nas_establish_req.initialNasMsg.data,
|
||||
as_msg.msg.nas_establish_req.initialNasMsg.length,
|
||||
user->ueid);
|
||||
nas_itti_nas_establish_req(as_msg.msg.nas_establish_req.cause,
|
||||
as_msg.msg.nas_establish_req.type,
|
||||
as_msg.msg.nas_establish_req.s_tmsi,
|
||||
as_msg.msg.nas_establish_req.plmnID,
|
||||
as_msg.msg.nas_establish_req.initialNasMsg.nas_data,
|
||||
as_msg.msg.nas_establish_req.initialNasMsg.length,
|
||||
user->ueid);
|
||||
LOG_FUNC_RETURN (RETURNok);
|
||||
}
|
||||
break;
|
||||
|
||||
case AS_UL_INFO_TRANSFER_REQ: {
|
||||
nas_itti_ul_data_req(
|
||||
as_msg.msg.ul_info_transfer_req.UEid,
|
||||
as_msg.msg.ul_info_transfer_req.nasMsg.data,
|
||||
as_msg.msg.ul_info_transfer_req.nasMsg.length,
|
||||
user->ueid);
|
||||
nas_itti_ul_data_req(as_msg.msg.ul_info_transfer_req.UEid,
|
||||
as_msg.msg.ul_info_transfer_req.nasMsg.nas_data,
|
||||
as_msg.msg.ul_info_transfer_req.nasMsg.length,
|
||||
user->ueid);
|
||||
LOG_FUNC_RETURN (RETURNok);
|
||||
}
|
||||
break;
|
||||
@@ -1075,11 +1059,9 @@ static int _emm_as_send(const nas_user_t *user, const emm_as_t *msg)
|
||||
** Others: None **
|
||||
** **
|
||||
***************************************************************************/
|
||||
static int _emm_as_data_req(const emm_data_t *emm_data, const emm_as_data_t *msg,
|
||||
void *ul_info_transfer_req_unaligned)
|
||||
static int _emm_as_data_req(const emm_data_t *emm_data, const emm_as_data_t *msg, ul_info_transfer_req_t *as_msg)
|
||||
{
|
||||
LOG_FUNC_IN;
|
||||
ul_info_transfer_req_t *as_msg = (ul_info_transfer_req_t *)ul_info_transfer_req_unaligned;
|
||||
int size = 0;
|
||||
bool is_encoded = false;
|
||||
|
||||
@@ -1171,19 +1153,14 @@ static int _emm_as_data_req(const emm_data_t *emm_data, const emm_as_data_t *msg
|
||||
** Others: None **
|
||||
** **
|
||||
***************************************************************************/
|
||||
static int _emm_as_status_ind(const emm_data_t *emm_data, const emm_as_status_t *msg,
|
||||
void *ul_info_transfer_req_unaligned)
|
||||
static int _emm_as_status_ind(const emm_data_t *emm_data, const emm_as_status_t *msg, ul_info_transfer_req_t *as_msg)
|
||||
{
|
||||
LOG_FUNC_IN;
|
||||
|
||||
int size = 0;
|
||||
ul_info_transfer_req_t *as_msg = (ul_info_transfer_req_t *)ul_info_transfer_req_unaligned;
|
||||
LOG_TRACE(INFO, "EMMAS-SAP - Send AS status indication (cause=%d)",
|
||||
msg->emm_cause);
|
||||
|
||||
nas_message_t nas_msg;
|
||||
memset(&nas_msg, 0 , sizeof(nas_message_t));
|
||||
|
||||
/* Setup the AS message */
|
||||
if (msg->guti) {
|
||||
as_msg->s_tmsi.MMEcode = msg->guti->gummei.MMEcode;
|
||||
@@ -1193,6 +1170,7 @@ static int _emm_as_status_ind(const emm_data_t *emm_data, const emm_as_status_t
|
||||
}
|
||||
|
||||
/* Setup the NAS security header */
|
||||
nas_message_t nas_msg = {0};
|
||||
EMM_msg *emm_msg = _emm_as_set_header(&nas_msg, &msg->sctx);
|
||||
|
||||
/* Setup the NAS information message */
|
||||
@@ -1245,13 +1223,11 @@ static int _emm_as_status_ind(const emm_data_t *emm_data, const emm_as_status_t
|
||||
** Others: None **
|
||||
** **
|
||||
***************************************************************************/
|
||||
static int _emm_as_release_req(const emm_as_release_t *msg,
|
||||
void *nas_release_req_unaligned)
|
||||
static int _emm_as_release_req(const emm_as_release_t *msg, nas_release_req_t *as_msg)
|
||||
{
|
||||
LOG_FUNC_IN;
|
||||
|
||||
LOG_TRACE(INFO, "EMMAS-SAP - Send AS release request");
|
||||
nas_release_req_t *as_msg = (nas_release_req_t *)nas_release_req_unaligned;
|
||||
/* Setup the AS message */
|
||||
if (msg->guti) {
|
||||
as_msg->s_tmsi.MMEcode = msg->guti->gummei.MMEcode;
|
||||
@@ -1285,18 +1261,13 @@ static int _emm_as_release_req(const emm_as_release_t *msg,
|
||||
** Others: None **
|
||||
** **
|
||||
***************************************************************************/
|
||||
static int _emm_as_security_res(const emm_data_t *emm_data, const emm_as_security_t *msg,
|
||||
void *ul_info_transfer_req_unaligned)
|
||||
static int _emm_as_security_res(const emm_data_t *emm_data, const emm_as_security_t *msg, ul_info_transfer_req_t *as_msg)
|
||||
{
|
||||
LOG_FUNC_IN;
|
||||
ul_info_transfer_req_t *as_msg=(ul_info_transfer_req_t *)ul_info_transfer_req_unaligned;
|
||||
int size = 0;
|
||||
|
||||
LOG_TRACE(INFO, "EMMAS-SAP - Send AS security response");
|
||||
|
||||
nas_message_t nas_msg;
|
||||
memset(&nas_msg, 0 , sizeof(nas_message_t));
|
||||
|
||||
/* Setup the AS message */
|
||||
if (msg->guti) {
|
||||
as_msg->s_tmsi.MMEcode = msg->guti->gummei.MMEcode;
|
||||
@@ -1304,6 +1275,7 @@ static int _emm_as_security_res(const emm_data_t *emm_data, const emm_as_securit
|
||||
}
|
||||
|
||||
/* Setup the NAS security header */
|
||||
nas_message_t nas_msg = {0};
|
||||
EMM_msg *emm_msg = _emm_as_set_header(&nas_msg, &msg->sctx);
|
||||
|
||||
/* Setup the NAS security message */
|
||||
@@ -1379,18 +1351,13 @@ static int _emm_as_security_res(const emm_data_t *emm_data, const emm_as_securit
|
||||
** Others: None **
|
||||
** **
|
||||
***************************************************************************/
|
||||
static int _emm_as_establish_req(const emm_data_t *emm_data, const emm_as_establish_t *msg,
|
||||
void *nas_establish_req_unaligned)
|
||||
static int _emm_as_establish_req(const emm_data_t *emm_data, const emm_as_establish_t *msg, nas_establish_req_t *as_msg)
|
||||
{
|
||||
LOG_FUNC_IN;
|
||||
|
||||
int size = 0;
|
||||
nas_establish_req_t *as_msg = (nas_establish_req_t *)nas_establish_req_unaligned;
|
||||
LOG_TRACE(INFO, "EMMAS-SAP - Send AS connection establish request");
|
||||
|
||||
nas_message_t nas_msg;
|
||||
memset(&nas_msg, 0 , sizeof(nas_message_t));
|
||||
|
||||
/* Setup the AS message */
|
||||
as_msg->cause = msg->RRCcause;
|
||||
as_msg->type = msg->RRCtype;
|
||||
@@ -1403,6 +1370,7 @@ static int _emm_as_establish_req(const emm_data_t *emm_data, const emm_as_establ
|
||||
}
|
||||
|
||||
/* Setup the NAS security header */
|
||||
nas_message_t nas_msg = {0};
|
||||
EMM_msg *emm_msg = _emm_as_set_header(&nas_msg, &msg->sctx);
|
||||
|
||||
/* Setup the initial NAS information message */
|
||||
|
||||
@@ -253,7 +253,8 @@ static void *_nas_network_mngr(void *args)
|
||||
/* Network receiving loop */
|
||||
while (true) {
|
||||
/* Read the network data message */
|
||||
bytes = network_api_read_data (*fd);
|
||||
char _network_api_recv_buffer[NETWORK_API_RECV_BUFFER_SIZE] = {0};
|
||||
bytes = network_api_read_data(*fd, _network_api_recv_buffer);
|
||||
|
||||
if (bytes == RETURNerror) {
|
||||
/* Failed to read data from the network sublayer;
|
||||
@@ -269,7 +270,8 @@ static void *_nas_network_mngr(void *args)
|
||||
}
|
||||
|
||||
/* Decode the network data message */
|
||||
network_message_id = network_api_decode_data (bytes);
|
||||
as_message_t _as_data = {};
|
||||
network_message_id = network_api_decode_data(bytes, &_as_data);
|
||||
|
||||
if (network_message_id == RETURNerror) {
|
||||
/* Failed to decode data read from the network sublayer */
|
||||
@@ -277,8 +279,7 @@ static void *_nas_network_mngr(void *args)
|
||||
}
|
||||
|
||||
/* Process the network data message */
|
||||
ret_code = nas_network_process_data (user, network_message_id,
|
||||
network_api_get_data ());
|
||||
ret_code = nas_network_process_data(user, network_message_id, &_as_data);
|
||||
|
||||
if (ret_code != RETURNok) {
|
||||
/* The network data message has not been successfully
|
||||
|
||||
@@ -118,7 +118,7 @@ int nas_itti_nas_establish_req(as_cause_t cause, as_call_type_t type, as_stmsi_t
|
||||
NAS_CONN_ESTABLI_REQ(message_p).type = type;
|
||||
NAS_CONN_ESTABLI_REQ(message_p).s_tmsi = s_tmsi;
|
||||
NAS_CONN_ESTABLI_REQ(message_p).plmnID = plmnID;
|
||||
NAS_CONN_ESTABLI_REQ(message_p).initialNasMsg.data = data;
|
||||
NAS_CONN_ESTABLI_REQ(message_p).initialNasMsg.nas_data = data;
|
||||
NAS_CONN_ESTABLI_REQ(message_p).initialNasMsg.length = length;
|
||||
return itti_send_msg_to_task(TASK_RRC_UE, NB_eNB_INST + user_id, message_p);
|
||||
}
|
||||
@@ -127,7 +127,7 @@ int nas_itti_ul_data_req(const uint32_t ue_id, void *const data, const uint32_t
|
||||
MessageDef *message_p;
|
||||
message_p = itti_alloc_new_message(TASK_NAS_UE, 0, NAS_UPLINK_DATA_REQ);
|
||||
NAS_UPLINK_DATA_REQ(message_p).UEid = ue_id;
|
||||
NAS_UPLINK_DATA_REQ(message_p).nasMsg.data = data;
|
||||
NAS_UPLINK_DATA_REQ(message_p).nasMsg.nas_data = data;
|
||||
NAS_UPLINK_DATA_REQ(message_p).nasMsg.length = length;
|
||||
return itti_send_msg_to_task(TASK_RRC_UE, NB_eNB_INST + user_id, message_p);
|
||||
}
|
||||
|
||||
@@ -161,8 +161,7 @@ int nas_network_process_data(nas_user_t *user, int msg_id, const void *data)
|
||||
|
||||
if ( (confirm.errCode == AS_SUCCESS) ||
|
||||
(confirm.errCode == AS_TERMINATED_NAS) ) {
|
||||
rc = nas_proc_establish_cnf(user, confirm.nasMsg.data,
|
||||
confirm.nasMsg.length);
|
||||
rc = nas_proc_establish_cnf(user, confirm.nasMsg.nas_data, confirm.nasMsg.length);
|
||||
} else {
|
||||
LOG_TRACE(WARNING, "NET-MAIN - "
|
||||
"Initial NAS message not delivered");
|
||||
@@ -193,8 +192,7 @@ int nas_network_process_data(nas_user_t *user, int msg_id, const void *data)
|
||||
case AS_DL_INFO_TRANSFER_IND: {
|
||||
const dl_info_transfer_ind_t info = msg->msg.dl_info_transfer_ind;
|
||||
/* Received downlink data transfer indication */
|
||||
rc = nas_proc_dl_transfer_ind(user, info.nasMsg.data,
|
||||
info.nasMsg.length);
|
||||
rc = nas_proc_dl_transfer_ind(user, info.nasMsg.nas_data, info.nasMsg.length);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -255,7 +255,7 @@ void *nas_ue_task(void *args_p)
|
||||
|
||||
if ((NAS_CONN_ESTABLI_CNF (msg_p).errCode == AS_SUCCESS)
|
||||
|| (NAS_CONN_ESTABLI_CNF (msg_p).errCode == AS_TERMINATED_NAS)) {
|
||||
nas_proc_establish_cnf(user, NAS_CONN_ESTABLI_CNF (msg_p).nasMsg.data, NAS_CONN_ESTABLI_CNF (msg_p).nasMsg.length);
|
||||
nas_proc_establish_cnf(user, NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.nas_data, NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.length);
|
||||
|
||||
/* TODO checks if NAS will free the nas message, better to do it there anyway! */
|
||||
// result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.data);
|
||||
@@ -287,13 +287,8 @@ void *nas_ue_task(void *args_p)
|
||||
LOG_I(NAS, "[UE %d] Received %s: UEid %u, length %u\n", Mod_id, ITTI_MSG_NAME (msg_p),
|
||||
NAS_DOWNLINK_DATA_IND (msg_p).UEid, NAS_DOWNLINK_DATA_IND (msg_p).nasMsg.length);
|
||||
|
||||
nas_proc_dl_transfer_ind (user, NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.data, NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.length);
|
||||
|
||||
if (0) {
|
||||
/* TODO checks if NAS will free the nas message, better to do it there anyway! */
|
||||
result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.data);
|
||||
AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
|
||||
}
|
||||
nas_proc_dl_transfer_ind(user, NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.nas_data, NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.length);
|
||||
free(NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.nas_data);
|
||||
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user