diff --git a/openair-cn/NAS/EURECOM-NAS/src/UEprocess.c b/openair-cn/NAS/EURECOM-NAS/src/UEprocess.c index dc8c58389929c98a226c22e8ce3217a77ccc905f..3783f0dc95863fb7a97aac07856c81a239e41df4 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/UEprocess.c +++ b/openair-cn/NAS/EURECOM-NAS/src/UEprocess.c @@ -201,7 +201,7 @@ static void *_nas_user_mngr(void *args) /* User receiving loop */ while (!exit_loop) { - exit_loop = nas_user_receive_and_process(fd); + exit_loop = nas_user_receive_and_process(fd, NULL); } /* Close the connection to the user application layer */ diff --git a/openair-cn/NAS/EURECOM-NAS/src/nas_user.c b/openair-cn/NAS/EURECOM-NAS/src/nas_user.c index 65eaf4430c2b40224f591c812ab7c8f4b5818536..7b8592110841043141ec097fc5c44e936760f0bd 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/nas_user.c +++ b/openair-cn/NAS/EURECOM-NAS/src/nas_user.c @@ -212,7 +212,7 @@ void nas_user_initialize(emm_indication_callback_t emm_cb, ** Outputs: Return: FALSE, TRUE ** ** ** ***************************************************************************/ -int nas_user_receive_and_process(int * fd) +int nas_user_receive_and_process(int *fd, char *message) { LOG_FUNC_IN; @@ -221,14 +221,19 @@ int nas_user_receive_and_process(int * fd) int bytes; int i; - /* Read the user data message */ - bytes = user_api_read_data (*fd); - if (bytes == RETURNerror) { - /* Failed to read data from the user application layer; - * exit from the receiving loop */ - LOG_TRACE (ERROR, "UE-MAIN - " - "Failed to read data from the user application layer"); - LOG_FUNC_RETURN(TRUE); + if (message != NULL) { + /* Set the message in receive buffer (Use to simulate reception of data from UserProcess) */ + bytes = user_api_set_data(message); + } else { + /* Read the user data message */ + bytes = user_api_read_data (*fd); + if (bytes == RETURNerror) { + /* Failed to read data from the user application layer; + * exit from the receiving loop */ + LOG_TRACE (ERROR, "UE-MAIN - " + "Failed to read data from the user application layer"); + LOG_FUNC_RETURN(TRUE); + } } if (bytes == 0) { @@ -261,22 +266,25 @@ int nas_user_receive_and_process(int * fd) "The user procedure call failed"); } - /* Encode the user data message */ - bytes = user_api_encode_data (nas_user_get_data (), i == nb_command - 1); - if (bytes == RETURNerror) { - /* Failed to encode the user data message; - * go ahead and process the next user data */ - continue; - } + /* Send response to UserProcess (If not in simulated reception) */ + if (message == NULL) { + /* Encode the user data message */ + bytes = user_api_encode_data (nas_user_get_data (), i == nb_command - 1); + if (bytes == RETURNerror) { + /* Failed to encode the user data message; + * go ahead and process the next user data */ + continue; + } - /* Send the data message to the user */ - bytes = user_api_send_data (*fd, bytes); - if (bytes == RETURNerror) { - /* Failed to send data to the user application layer; - * exit from the receiving loop */ - LOG_TRACE (ERROR, "UE-MAIN - " - "Failed to send data to the user application layer"); - LOG_FUNC_RETURN(TRUE); + /* Send the data message to the user */ + bytes = user_api_send_data (*fd, bytes); + if (bytes == RETURNerror) { + /* Failed to send data to the user application layer; + * exit from the receiving loop */ + LOG_TRACE (ERROR, "UE-MAIN - " + "Failed to send data to the user application layer"); + LOG_FUNC_RETURN(TRUE); + } } } diff --git a/openair-cn/NAS/EURECOM-NAS/src/nas_user.h b/openair-cn/NAS/EURECOM-NAS/src/nas_user.h index ded7156423fa17770d9a839bbdcc884ba6ab9b07..51da3978efb8df6c58cf56e92ac9f21279051298 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/nas_user.h +++ b/openair-cn/NAS/EURECOM-NAS/src/nas_user.h @@ -40,7 +40,7 @@ Description NAS procedure functions triggered by the user void nas_user_initialize(emm_indication_callback_t emm_cb, esm_indication_callback_t esm_cb, const char *version); -int nas_user_receive_and_process(int * fd); +int nas_user_receive_and_process(int * fd, char *message); int nas_user_process_data(const void *data); diff --git a/openair-cn/NAS/nas_ue_task.c b/openair-cn/NAS/nas_ue_task.c index daf9b59ce95ad86fb786bc599d94504cfc2f7f25..5896712fd73b4e0ce186f51ee9a8b36c91d2f8cf 100644 --- a/openair-cn/NAS/nas_ue_task.c +++ b/openair-cn/NAS/nas_ue_task.c @@ -58,7 +58,7 @@ static int nas_ue_process_events(struct epoll_event *events, int nb_events) { /* If the event has not been yet been processed (not an itti message) */ if (events[event].data.fd == user_fd) { - exit_loop = nas_user_receive_and_process(&user_fd); + exit_loop = nas_user_receive_and_process(&user_fd, NULL); } else { LOG_E(NAS, "[UE] Received an event from an unknown fd %d!\n", events[event].data.fd); } @@ -101,11 +101,7 @@ void *nas_ue_task(void *args_p) { { MessageDef *message_p; -#if (NAS_UE_AUTOSTART == 0) message_p = itti_alloc_new_message(TASK_NAS_UE, DEACTIVATE_MESSAGE); -#else - message_p = itti_alloc_new_message(TASK_NAS_UE, ACTIVATE_MESSAGE); -#endif itti_send_msg_to_task(TASK_L2L1, instance, message_p); } @@ -122,6 +118,12 @@ void *nas_ue_task(void *args_p) { case INITIALIZE_MESSAGE: LOG_I(NAS, "[UE %d] Received %s\n", Mod_id, msg_name); #if (NAS_UE_AUTOSTART != 0) + { + /* Send an activate modem command to NAS like UserProcess should do it */ + char *user_data = "at+cfun=1\r"; + + nas_user_receive_and_process (&user_fd, user_data); + } #endif break;