/**************************************************************************** ** ** ** Name: network_api_encode_data() ** ** ** ** Description: Encodes Access Stratum message to be sent to the network ** ** ** ** Inputs data: Generic pointer to the AS data to encode ** ** Others: None ** ** ** ** Outputs: Return: The number of characters that have been ** ** successfully encoded; ** ** RETURNerror otherwise. ** ** Others: _network_api_send_buffer ** ** ** ***************************************************************************/ int network_api_encode_data(void* data) { LOG_FUNC_IN; /* Encode the Access Stratum message */ int bytes = as_message_encode(_network_api_send_buffer, (as_message_t*)(data), NETWORK_API_SEND_BUFFER_SIZE); if (bytes != RETURNerror) { LOG_TRACE(INFO, "NET-API - %d bytes encoded", bytes); } LOG_FUNC_RETURN (bytes); }
/* * ----------------------------------------------------------------------------- * Functions used to process messages received from the MME NAS process * ----------------------------------------------------------------------------- */ static int _as_simulator_mme_process(int msg_id, as_message_t* msg) { int rc = RETURNok; as_message_t cnf; as_message_t ind; printf("\nINFO\t: %s - Received AS message 0x%x from MME NAS process\n", __FUNCTION__, msg_id); _as_simulator_mme_transfer = AS_SIMULATOR_NO_TRANSFER; memset(&cnf, 0, sizeof(as_message_t)); memset(&ind, 0, sizeof(as_message_t)); switch (msg_id) { case AS_NAS_ESTABLISH_RSP: cnf.msgID = process_nas_establish_rsp(msg_id, &msg->msg.nas_establish_rsp, &cnf.msg.nas_establish_cnf); if (cnf.msgID) { /* Forward confirm message to the UE */ _as_simulator_mme_transfer |= AS_SIMULATOR_TRANSFER_TO_UE; } break; case AS_DL_INFO_TRANSFER_REQ: ind.msgID = process_dl_info_transfer_req(msg_id, &msg->msg.dl_info_transfer_req, &ind.msg.dl_info_transfer_ind, &cnf.msg.dl_info_transfer_cnf); if (ind.msgID) { /* Forward indication message to the UE */ _as_simulator_mme_transfer |= AS_SIMULATOR_TRANSFER_TO_UE; } /* Return confirm message to the MME */ cnf.msgID = AS_DL_INFO_TRANSFER_CNF; _as_simulator_mme_transfer |= AS_SIMULATOR_TRANSFER_TO_MME; break; case AS_NAS_RELEASE_REQ: ind.msgID = process_nas_release_ind(msg_id, &msg->msg.nas_release_req, &ind.msg.nas_release_ind); /* Forward indication message to the UE */ _as_simulator_mme_transfer |= AS_SIMULATOR_TRANSFER_TO_UE; break; default: printf("WARNING\t: %s - AS message is not valid (0x%x)\n", __FUNCTION__, msg_id); rc = RETURNerror; break; } if (_as_simulator_mme_transfer & AS_SIMULATOR_TRANSFER_TO_UE) { if (ind.msgID > 0) { /* Encode the message indication forwarded to the NAS running * at the UE side */ _as_simulator_ue_size = as_message_encode(_as_simulator_ue_buffer, &ind, AS_SIMULATOR_UE_BUFFER_SIZE); } else if (cnf.msgID > 0) { /* Encode the message confirmation forwarded to the NAS running * at the UE side */ _as_simulator_ue_size = as_message_encode(_as_simulator_ue_buffer, &cnf, AS_SIMULATOR_UE_BUFFER_SIZE); } if (_as_simulator_ue_size == RETURNerror) { _as_simulator_ue_size = 0; rc = RETURNerror; } } if (_as_simulator_mme_transfer & AS_SIMULATOR_TRANSFER_TO_MME) { /* Encode the message confirmation returned to the NAS running * at the MME side */ _as_simulator_mme_size = as_message_encode(_as_simulator_mme_buffer, &cnf, AS_SIMULATOR_MME_BUFFER_SIZE); if (_as_simulator_mme_size == RETURNerror) { _as_simulator_mme_size = 0; rc = RETURNerror; } } return (rc); }