Moved user interface processing code from "_nas_user_mngr" into "user_api_receive_and_process" function in user_api.c" file to use it from "nas_ue_task.c".
git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4664 818b1a75-f10b-46b9-bf7c-635c3b92a50f
This commit is contained in:
@@ -193,11 +193,7 @@ static void *_nas_user_mngr(void *args)
|
||||
{
|
||||
LOG_FUNC_IN;
|
||||
|
||||
int ret_code;
|
||||
int exit_loop = FALSE;
|
||||
int nb_command;
|
||||
int bytes;
|
||||
int i;
|
||||
|
||||
int *fd = (int *) args;
|
||||
|
||||
@@ -205,65 +201,7 @@ static void *_nas_user_mngr(void *args)
|
||||
|
||||
/* User receiving loop */
|
||||
while (!exit_loop) {
|
||||
/* 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");
|
||||
break;
|
||||
}
|
||||
|
||||
if (bytes == 0) {
|
||||
/* A signal was caught before any data were available */
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Decode the user data message */
|
||||
nb_command = user_api_decode_data (bytes);
|
||||
for (i = 0; i < nb_command; i++) {
|
||||
/* Get the user data to be processed */
|
||||
const void *data = user_api_get_data (i);
|
||||
if (data == NULL) {
|
||||
/* Failed to get user data at the given index;
|
||||
* go ahead and process the next user data */
|
||||
LOG_TRACE (ERROR, "UE-MAIN - "
|
||||
"Failed to get user data at index %d",
|
||||
i);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Process the user data message */
|
||||
ret_code = nas_user_process_data (data);
|
||||
if (ret_code != RETURNok) {
|
||||
/* The user data message has not been successfully
|
||||
* processed; cause code will be encoded and sent back
|
||||
* to the user */
|
||||
LOG_TRACE
|
||||
(WARNING, "UE-MAIN - "
|
||||
"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 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");
|
||||
exit_loop = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
exit_loop = user_api_receive_and_process(fd);
|
||||
}
|
||||
|
||||
/* Close the connection to the user application layer */
|
||||
|
||||
@@ -5,7 +5,7 @@ endif
|
||||
include $(PROJDIR)/Makerules
|
||||
include $(PROJDIR)/Makefile.inc
|
||||
|
||||
export INCLUDES = -I. -I$(INCDIR) -I$(UTILDIR) -I$(IESDIR) -I$(EMMMSGDIR) -I$(ESMMSGDIR)
|
||||
export INCLUDES = -I. -I$(INCDIR) -I$(UTILDIR) -I$(IESDIR) -I$(EMMMSGDIR) -I$(ESMMSGDIR) -I$(SRCDIR)
|
||||
|
||||
TARGET = $(LIBAPI)
|
||||
TARGETS = $(TARGET).a $(TARGET).so
|
||||
|
||||
@@ -25,6 +25,7 @@ Description Implements the API used by the NAS layer running in the UE
|
||||
#include "nas_log.h"
|
||||
#include "socket.h"
|
||||
#include "device.h"
|
||||
#include "nas_user.h"
|
||||
|
||||
#include "at_command.h"
|
||||
#include "at_response.h"
|
||||
@@ -208,6 +209,90 @@ int user_api_initialize(const char* host, const char* port,
|
||||
LOG_FUNC_RETURN (RETURNok);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
** **
|
||||
** Name: user_api_receive_and_process() **
|
||||
** **
|
||||
** Description: Receives and process messages from user application **
|
||||
** **
|
||||
** Inputs: fd: File descriptor of the connection endpoint **
|
||||
** from which data have been received **
|
||||
** Others: None **
|
||||
** **
|
||||
** Outputs: Return: FALSE, TRUE **
|
||||
** **
|
||||
***************************************************************************/
|
||||
int user_api_receive_and_process(int * fd)
|
||||
{
|
||||
LOG_FUNC_IN;
|
||||
|
||||
int ret_code;
|
||||
int nb_command;
|
||||
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 (bytes == 0) {
|
||||
/* A signal was caught before any data were available */
|
||||
LOG_FUNC_RETURN(FALSE);
|
||||
}
|
||||
|
||||
/* Decode the user data message */
|
||||
nb_command = user_api_decode_data (bytes);
|
||||
for (i = 0; i < nb_command; i++) {
|
||||
/* Get the user data to be processed */
|
||||
const void *data = user_api_get_data (i);
|
||||
if (data == NULL) {
|
||||
/* Failed to get user data at the given index;
|
||||
* go ahead and process the next user data */
|
||||
LOG_TRACE (ERROR, "UE-MAIN - "
|
||||
"Failed to get user data at index %d",
|
||||
i);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Process the user data message */
|
||||
ret_code = nas_user_process_data (data);
|
||||
if (ret_code != RETURNok) {
|
||||
/* The user data message has not been successfully
|
||||
* processed; cause code will be encoded and sent back
|
||||
* to the user */
|
||||
LOG_TRACE
|
||||
(WARNING, "UE-MAIN - "
|
||||
"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 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);
|
||||
}
|
||||
}
|
||||
|
||||
LOG_FUNC_RETURN(FALSE);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
** **
|
||||
** Name: user_api_get_fd() **
|
||||
|
||||
@@ -42,6 +42,8 @@ Description Implements the API used by the NAS layer running in the UE
|
||||
|
||||
int user_api_initialize(const char* host, const char* port, const char* devname, const char* devparams);
|
||||
|
||||
int user_api_receive_and_process(int * fd);
|
||||
|
||||
int user_api_emm_callback(Stat_t stat, tac_t tac, ci_t ci, AcT_t AcT, const char* data, size_t size);
|
||||
int user_api_esm_callback(int cid, network_pdn_state_t state);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user