Commit f277cd47 authored by winckel's avatar winckel

Fixed an issue with stand alone EURECOM-NAS builds.

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4672 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 50b0c9c8
......@@ -201,7 +201,7 @@ static void *_nas_user_mngr(void *args)
/* User receiving loop */
while (!exit_loop) {
exit_loop = user_api_receive_and_process(fd);
exit_loop = nas_user_receive_and_process(fd);
}
/* Close the connection to the user application layer */
......
......@@ -209,90 +209,6 @@ 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,8 +42,6 @@ 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);
......
......@@ -30,6 +30,7 @@ Description NAS procedure functions triggered by the user
#include "at_error.h"
#include "user_indication.h"
#include "nas_proc.h"
#include "user_api.h"
#include <string.h> // memset, strncpy, strncmp
#include <stdlib.h> // free
......@@ -198,6 +199,90 @@ void nas_user_initialize(emm_indication_callback_t emm_cb,
LOG_FUNC_OUT;
}
/****************************************************************************
** **
** Name: nas_user_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 nas_user_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: nas_user_process_data() **
......
......@@ -40,6 +40,8 @@ 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_process_data(const void *data);
const void *nas_user_get_data(void);
......
......@@ -55,7 +55,7 @@ static int nas_ue_process_events(struct epoll_event *events, int nb_events, unsi
{
/* If the event has not been yet been processed (not an itti message) */
if (events[event].data.fd == user_fd) {
exit_loop = user_api_receive_and_process(&user_fd);
exit_loop = nas_user_process_data(&user_fd);
} else {
LOG_E(NAS, "[UE %d] Received an event from an unknown fd %d!\n", Mod_id, events[event].data.fd);
}
......
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