diff --git a/openair3/NAS/UE/API/USER/user_api.c b/openair3/NAS/UE/API/USER/user_api.c index 21e4eacf9d866ddba429f1cfef7e12c118f154ba..a1300ea059d9dac26cfe107c3c6d9c0e02fc4f38 100644 --- a/openair3/NAS/UE/API/USER/user_api.c +++ b/openair3/NAS/UE/API/USER/user_api.c @@ -225,8 +225,6 @@ const void* user_api_get_data(user_at_commands_t *commands, int index) ** ** ** Description: Read data received from the user application layer ** ** ** - ** Inputs: fd: File descriptor of the connection endpoint ** - ** from which data have been received ** ** Others: _user_api_id ** ** ** ** Outputs: Return: The number of bytes read when success; ** @@ -234,20 +232,12 @@ const void* user_api_get_data(user_at_commands_t *commands, int index) ** Others: user_api_id->recv_buffer, _user_api_id ** ** ** ***************************************************************************/ -int user_api_read_data(user_api_id_t *user_api_id, int fd) +int user_api_read_data(user_api_id_t *user_api_id) { LOG_FUNC_IN; int rbytes; - /* Sanity check */ - int sfd = user_api_get_fd(user_api_id); - - if (fd != sfd) { - LOG_TRACE(ERROR, "USR-API - Endpoint %d is not the one created for communication with the user application layer (%d)", fd, sfd); - LOG_FUNC_RETURN (RETURNerror); - } - memset(user_api_id->recv_buffer, 0, USER_API_RECV_BUFFER_SIZE); /* Receive data from the user application layer */ @@ -303,8 +293,6 @@ int user_api_set_data(user_api_id_t *user_api_id, char *message) ** ** ** Description: Send data to the user application layer ** ** ** - ** Inputs: fd: File descriptor of the connection endpoint ** - ** to which data have to be sent ** ** length: Number of bytes to send ** ** ** ** Outputs: Return: The number of bytes sent when success; ** @@ -329,18 +317,15 @@ static int _user_api_send_data(user_api_id_t *user_api_id, int length) return sbytes; } -int user_api_send_data(user_api_id_t *user_api_id, int fd, int length) + +/**************************************************************************** + ** ** + ** Name: user_api_close() ** + ***************************************************************************/ + int user_api_send_data(user_api_id_t *user_api_id, int length) { LOG_FUNC_IN; - /* Sanity check */ - int sfd = user_api_get_fd(user_api_id); - - if (fd != sfd) { - LOG_TRACE(ERROR, "USR-API - Endpoint %d is not the one created for communication with the user application layer (%d)", fd, sfd); - LOG_FUNC_RETURN (RETURNerror); - } - /* Send data to the user application layer */ int sbytes = 0; @@ -358,27 +343,15 @@ int user_api_send_data(user_api_id_t *user_api_id, int fd, int length) ** Description: Close the user API from which the NAS layer sent/received ** ** messages to/from the user application layer ** ** ** - ** Inputs: fd: File descriptor of the connection endpoint ** - ** allocated by the system to communicate ** - ** with the user application layer ** ** Others: None ** ** ** ** Outputs: Return: None ** ** ** ***************************************************************************/ -void user_api_close(user_api_id_t *user_api_id, int fd) +void user_api_close(user_api_id_t *user_api_id) { LOG_FUNC_IN; - /* Sanity check */ - int sfd = user_api_get_fd(user_api_id); - - if (fd != sfd) { - LOG_TRACE(ERROR, "USR-API - Endpoint %d is not the one created for communication with the user application layer (%d)", fd, sfd); - LOG_FUNC_OUT; - return; - } - /* Cleanup the connection endpoint */ user_api_id->close(user_api_id->endpoint) ; user_api_id->endpoint = NULL; diff --git a/openair3/NAS/UE/API/USER/user_api.h b/openair3/NAS/UE/API/USER/user_api.h index 513a44e4fb05822f55eb1a434a1a2ed4e07459ec..6536144165b540bd9bf186d888aaf14c41eeb00b 100644 --- a/openair3/NAS/UE/API/USER/user_api.h +++ b/openair3/NAS/UE/API/USER/user_api.h @@ -66,10 +66,10 @@ int user_api_esm_callback(user_api_id_t *user_api_id, int cid, network_pdn_state int user_api_get_fd(user_api_id_t *user_api_id); const void* user_api_get_data(user_at_commands_t *commands, int index); -int user_api_read_data(user_api_id_t *user_api_id, int fd); +int user_api_read_data(user_api_id_t *user_api_id); int user_api_set_data(user_api_id_t *user_api_id, char *message); -int user_api_send_data(user_api_id_t *user_api_id, int fd, int length); -void user_api_close(user_api_id_t *user_api_id, int fd); +int user_api_send_data(user_api_id_t *user_api_id, int length); +void user_api_close(user_api_id_t *user_api_id); int user_api_decode_data(user_api_id_t *user_api_id, user_at_commands_t *commands, int length); int user_api_encode_data(user_api_id_t *user_api_id, const void* data, int add_success_code); diff --git a/openair3/NAS/UE/UEprocess.c b/openair3/NAS/UE/UEprocess.c index 122ee72f6e22d72e3898aa96cb81416dd69687e6..72035da6c8c0fb687a4381a1ef332807463b05d5 100644 --- a/openair3/NAS/UE/UEprocess.c +++ b/openair3/NAS/UE/UEprocess.c @@ -70,7 +70,7 @@ static void *_nas_network_mngr(void *); static int _nas_set_signal_handler(int signal, void (handler)(int)); static void _nas_signal_handler(int signal); -static void _nas_clean(user_api_id_t *user_api_id, int usr_fd, int net_fd); +static void _nas_clean(user_api_id_t *user_api_id, int net_fd); uint8_t usim_test = 0; // FIXME user must be set up with right itti message instance @@ -126,7 +126,7 @@ int main(int argc, const char *argv[]) */ if (network_api_initialize (nhost, nport) != RETURNok) { LOG_TRACE (ERROR, "UE-MAIN - network_api_initialize() failed"); - user_api_close (user_api_id, user_fd); + user_api_close (user_api_id); exit (EXIT_FAILURE); } @@ -163,7 +163,7 @@ int main(int argc, const char *argv[]) if (pthread_create (&user_mngr, &attr, _nas_user_mngr, &user_fd) != 0) { LOG_TRACE (ERROR, "UE-MAIN - " "Failed to create the user management thread"); - user_api_close (user_api_id, user_fd); + user_api_close (user_api_id); network_api_close (network_fd); exit (EXIT_FAILURE); } @@ -177,7 +177,7 @@ int main(int argc, const char *argv[]) &network_fd) != 0) { LOG_TRACE (ERROR, "UE-MAIN - " "Failed to create the network management thread"); - user_api_close (user_api_id, user_fd); + user_api_close (user_api_id); network_api_close (network_fd); exit (EXIT_FAILURE); } @@ -195,7 +195,7 @@ int main(int argc, const char *argv[]) } /* Termination cleanup */ - _nas_clean (user_api_id, user_fd, network_fd); + _nas_clean (user_api_id, network_fd); LOG_TRACE (WARNING, "UE-MAIN - NAS main process exited"); @@ -236,7 +236,7 @@ static void *_nas_user_mngr(void *args) } /* Close the connection to the user application layer */ - user_api_close (user->user_api_id, *fd); + user_api_close (user->user_api_id); LOG_TRACE (WARNING, "UE-MAIN - " "The user connection endpoint manager exited"); @@ -386,7 +386,7 @@ static void _nas_signal_handler(int signal) LOG_TRACE (WARNING, "UE-MAIN - Signal %d received", signal); // FIXME acces to global - _nas_clean (user->user_api_id, user_api_get_fd (user->user_api_id), network_api_get_fd ()); + _nas_clean (user->user_api_id, network_api_get_fd ()); exit (EXIT_SUCCESS); LOG_FUNC_OUT @@ -407,7 +407,7 @@ static void _nas_signal_handler(int signal) ** Others: None ** ** ** ***************************************************************************/ -static void _nas_clean(user_api_id_t *user_api_id, int usr_fd, int net_fd) +static void _nas_clean(user_api_id_t *user_api_id, int net_fd) { LOG_FUNC_IN; @@ -418,8 +418,8 @@ static void _nas_clean(user_api_id_t *user_api_id, int usr_fd, int net_fd) LOG_TRACE (INFO, "UE-MAIN - " "Closing user connection %d and network connection %d", - usr_fd, net_fd); - user_api_close (user_api_id, usr_fd); + user_api_get_fd (user_api_id), net_fd); + user_api_close (user_api_id); network_api_close (net_fd); LOG_FUNC_OUT diff --git a/openair3/NAS/UE/nas_ue_task.c b/openair3/NAS/UE/nas_ue_task.c index 2b4112344636c5501d7d055d1c6b70f4aead0c2b..6b4b7d97d909e94f26f37fe69417e9d23485410a 100644 --- a/openair3/NAS/UE/nas_ue_task.c +++ b/openair3/NAS/UE/nas_ue_task.c @@ -48,7 +48,7 @@ static int nas_ue_process_events(nas_user_t *user, struct epoll_event *events, i for (event = 0; event < nb_events; event++) { if (events[event].events != 0) { /* If the event has not been yet been processed (not an itti message) */ - if (events[event].data.fd == user->fd) { + if (events[event].data.fd == user_api_get_fd(user->user_api_id)) { exit_loop = nas_user_receive_and_process(user, NULL); } else { LOG_E(NAS, "[UE] Received an event from an unknown fd %d!\n", events[event].data.fd); @@ -94,8 +94,7 @@ void *nas_ue_task(void *args_p) exit (EXIT_FAILURE); } - user->fd = user_api_get_fd (user_api_id); - itti_subscribe_event_fd (TASK_NAS_UE, user->fd); + itti_subscribe_event_fd (TASK_NAS_UE, user_api_get_fd(user_api_id)); } user->user_at_commands = calloc(1, sizeof(user_at_commands_t)); diff --git a/openair3/NAS/UE/nas_user.c b/openair3/NAS/UE/nas_user.c index 065bbca17d592c38290f0c731c4818e5d9f2dd29..120037d366c487e5c7933b8408e10c54b17f6fee 100644 --- a/openair3/NAS/UE/nas_user.c +++ b/openair3/NAS/UE/nas_user.c @@ -223,7 +223,7 @@ int nas_user_receive_and_process(nas_user_t *user, char *message) bytes = user_api_set_data(user_api_id, message); } else { /* Read the user data message */ - bytes = user_api_read_data (user_api_id, user->fd); + bytes = user_api_read_data (user_api_id); if (bytes == RETURNerror) { /* Failed to read data from the user application layer; @@ -279,7 +279,7 @@ int nas_user_receive_and_process(nas_user_t *user, char *message) } /* Send the data message to the user */ - bytes = user_api_send_data (user_api_id, user->fd, bytes); + bytes = user_api_send_data (user_api_id, bytes); if (bytes == RETURNerror) { /* Failed to send data to the user application layer; diff --git a/openair3/NAS/UE/user_defs.h b/openair3/NAS/UE/user_defs.h index a30e13663a1143b29d26f12734dd078d60da1755..993e0d667466ddece2204dd8b46a7234304aebca 100644 --- a/openair3/NAS/UE/user_defs.h +++ b/openair3/NAS/UE/user_defs.h @@ -60,7 +60,6 @@ Description NAS type definition to manage a user equipment typedef struct { int ueid; /* UE lower layer identifier */ - int fd; proc_data_t proc; // Eps Session Management esm_data_t *esm_data; // ESM internal data (used within ESM only)