Commit 2ac3549a authored by Frédéric Leroy's avatar Frédéric Leroy

UE/API/USER: remove fd from nas_user_t

parent 960be16c
...@@ -225,8 +225,6 @@ const void* user_api_get_data(user_at_commands_t *commands, int index) ...@@ -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 ** ** 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 ** ** Others: _user_api_id **
** ** ** **
** Outputs: Return: The number of bytes read when success; ** ** 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) ...@@ -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 ** ** 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; LOG_FUNC_IN;
int rbytes; 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); memset(user_api_id->recv_buffer, 0, USER_API_RECV_BUFFER_SIZE);
/* Receive data from the user application layer */ /* 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) ...@@ -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 ** ** 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 ** ** length: Number of bytes to send **
** ** ** **
** Outputs: Return: The number of bytes sent when success; ** ** 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) ...@@ -329,18 +317,15 @@ static int _user_api_send_data(user_api_id_t *user_api_id, int length)
return sbytes; 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; 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 */ /* Send data to the user application layer */
int sbytes = 0; int sbytes = 0;
...@@ -358,27 +343,15 @@ int user_api_send_data(user_api_id_t *user_api_id, int fd, int length) ...@@ -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 ** ** Description: Close the user API from which the NAS layer sent/received **
** messages to/from the user application layer ** ** 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 ** ** Others: None **
** ** ** **
** Outputs: Return: 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; 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 */ /* Cleanup the connection endpoint */
user_api_id->close(user_api_id->endpoint) ; user_api_id->close(user_api_id->endpoint) ;
user_api_id->endpoint = NULL; user_api_id->endpoint = NULL;
......
...@@ -66,10 +66,10 @@ int user_api_esm_callback(user_api_id_t *user_api_id, int cid, network_pdn_state ...@@ -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); 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); 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_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); 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 fd); 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_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); int user_api_encode_data(user_api_id_t *user_api_id, const void* data, int add_success_code);
......
...@@ -70,7 +70,7 @@ static void *_nas_network_mngr(void *); ...@@ -70,7 +70,7 @@ static void *_nas_network_mngr(void *);
static int _nas_set_signal_handler(int signal, void (handler)(int)); static int _nas_set_signal_handler(int signal, void (handler)(int));
static void _nas_signal_handler(int signal); 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; uint8_t usim_test = 0;
// FIXME user must be set up with right itti message instance // FIXME user must be set up with right itti message instance
...@@ -126,7 +126,7 @@ int main(int argc, const char *argv[]) ...@@ -126,7 +126,7 @@ int main(int argc, const char *argv[])
*/ */
if (network_api_initialize (nhost, nport) != RETURNok) { if (network_api_initialize (nhost, nport) != RETURNok) {
LOG_TRACE (ERROR, "UE-MAIN - network_api_initialize() failed"); 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); exit (EXIT_FAILURE);
} }
...@@ -163,7 +163,7 @@ int main(int argc, const char *argv[]) ...@@ -163,7 +163,7 @@ int main(int argc, const char *argv[])
if (pthread_create (&user_mngr, &attr, _nas_user_mngr, &user_fd) != 0) { if (pthread_create (&user_mngr, &attr, _nas_user_mngr, &user_fd) != 0) {
LOG_TRACE (ERROR, "UE-MAIN - " LOG_TRACE (ERROR, "UE-MAIN - "
"Failed to create the user management thread"); "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); network_api_close (network_fd);
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
...@@ -177,7 +177,7 @@ int main(int argc, const char *argv[]) ...@@ -177,7 +177,7 @@ int main(int argc, const char *argv[])
&network_fd) != 0) { &network_fd) != 0) {
LOG_TRACE (ERROR, "UE-MAIN - " LOG_TRACE (ERROR, "UE-MAIN - "
"Failed to create the network management thread"); "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); network_api_close (network_fd);
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
...@@ -195,7 +195,7 @@ int main(int argc, const char *argv[]) ...@@ -195,7 +195,7 @@ int main(int argc, const char *argv[])
} }
/* Termination cleanup */ /* Termination cleanup */
_nas_clean (user_api_id, user_fd, network_fd); _nas_clean (user_api_id, network_fd);
LOG_TRACE LOG_TRACE
(WARNING, "UE-MAIN - NAS main process exited"); (WARNING, "UE-MAIN - NAS main process exited");
...@@ -236,7 +236,7 @@ static void *_nas_user_mngr(void *args) ...@@ -236,7 +236,7 @@ static void *_nas_user_mngr(void *args)
} }
/* Close the connection to the user application layer */ /* 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 - " LOG_TRACE (WARNING, "UE-MAIN - "
"The user connection endpoint manager exited"); "The user connection endpoint manager exited");
...@@ -386,7 +386,7 @@ static void _nas_signal_handler(int signal) ...@@ -386,7 +386,7 @@ static void _nas_signal_handler(int signal)
LOG_TRACE (WARNING, "UE-MAIN - Signal %d received", signal); LOG_TRACE (WARNING, "UE-MAIN - Signal %d received", signal);
// FIXME acces to global // 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); exit (EXIT_SUCCESS);
LOG_FUNC_OUT LOG_FUNC_OUT
...@@ -407,7 +407,7 @@ static void _nas_signal_handler(int signal) ...@@ -407,7 +407,7 @@ static void _nas_signal_handler(int signal)
** Others: None ** ** 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; LOG_FUNC_IN;
...@@ -418,8 +418,8 @@ static void _nas_clean(user_api_id_t *user_api_id, int usr_fd, int net_fd) ...@@ -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 - " LOG_TRACE (INFO, "UE-MAIN - "
"Closing user connection %d and network connection %d", "Closing user connection %d and network connection %d",
usr_fd, net_fd); user_api_get_fd (user_api_id), net_fd);
user_api_close (user_api_id, usr_fd); user_api_close (user_api_id);
network_api_close (net_fd); network_api_close (net_fd);
LOG_FUNC_OUT LOG_FUNC_OUT
......
...@@ -48,7 +48,7 @@ static int nas_ue_process_events(nas_user_t *user, struct epoll_event *events, i ...@@ -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++) { for (event = 0; event < nb_events; event++) {
if (events[event].events != 0) { if (events[event].events != 0) {
/* If the event has not been yet been processed (not an itti message) */ /* 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); exit_loop = nas_user_receive_and_process(user, NULL);
} else { } else {
LOG_E(NAS, "[UE] Received an event from an unknown fd %d!\n", events[event].data.fd); 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) ...@@ -94,8 +94,7 @@ void *nas_ue_task(void *args_p)
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
user->fd = user_api_get_fd (user_api_id); itti_subscribe_event_fd (TASK_NAS_UE, user_api_get_fd(user_api_id));
itti_subscribe_event_fd (TASK_NAS_UE, user->fd);
} }
user->user_at_commands = calloc(1, sizeof(user_at_commands_t)); user->user_at_commands = calloc(1, sizeof(user_at_commands_t));
......
...@@ -223,7 +223,7 @@ int nas_user_receive_and_process(nas_user_t *user, char *message) ...@@ -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); bytes = user_api_set_data(user_api_id, message);
} else { } else {
/* Read the user data message */ /* 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) { if (bytes == RETURNerror) {
/* Failed to read data from the user application layer; /* 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) ...@@ -279,7 +279,7 @@ int nas_user_receive_and_process(nas_user_t *user, char *message)
} }
/* Send the data message to the user */ /* 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) { if (bytes == RETURNerror) {
/* Failed to send data to the user application layer; /* Failed to send data to the user application layer;
......
...@@ -60,7 +60,6 @@ Description NAS type definition to manage a user equipment ...@@ -60,7 +60,6 @@ Description NAS type definition to manage a user equipment
typedef struct { typedef struct {
int ueid; /* UE lower layer identifier */ int ueid; /* UE lower layer identifier */
int fd;
proc_data_t proc; proc_data_t proc;
// Eps Session Management // Eps Session Management
esm_data_t *esm_data; // ESM internal data (used within ESM only) esm_data_t *esm_data; // ESM internal data (used within ESM only)
......
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