UE/API/USER: rename _user_data to user_at_commands_t and move it to nas_user_t
This commit is contained in:
@@ -110,23 +110,16 @@ static struct {
|
|||||||
* The buffer used to receive data from the user application layer
|
* The buffer used to receive data from the user application layer
|
||||||
*/
|
*/
|
||||||
#define USER_API_RECV_BUFFER_SIZE 4096
|
#define USER_API_RECV_BUFFER_SIZE 4096
|
||||||
|
// FIXME not reentrant
|
||||||
static char _user_api_recv_buffer[USER_API_RECV_BUFFER_SIZE];
|
static char _user_api_recv_buffer[USER_API_RECV_BUFFER_SIZE];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The buffer used to send data to the user application layer
|
* The buffer used to send data to the user application layer
|
||||||
*/
|
*/
|
||||||
#define USER_API_SEND_BUFFER_SIZE USER_API_RECV_BUFFER_SIZE
|
#define USER_API_SEND_BUFFER_SIZE USER_API_RECV_BUFFER_SIZE
|
||||||
|
// FIXME not reentrant
|
||||||
static char _user_api_send_buffer[USER_API_SEND_BUFFER_SIZE];
|
static char _user_api_send_buffer[USER_API_SEND_BUFFER_SIZE];
|
||||||
|
|
||||||
/*
|
|
||||||
* The decoded data received from the user application layer
|
|
||||||
*/
|
|
||||||
static struct {
|
|
||||||
int n_cmd; /* number of user data to be processed */
|
|
||||||
#define USER_DATA_MAX 10
|
|
||||||
at_command_t cmd[USER_DATA_MAX]; /* user data to be processed */
|
|
||||||
} _user_data = {};
|
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/****************** E X P O R T E D F U N C T I O N S ******************/
|
/****************** E X P O R T E D F U N C T I O N S ******************/
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
@@ -261,12 +254,12 @@ int user_api_get_fd(void)
|
|||||||
** Others: None **
|
** Others: None **
|
||||||
** **
|
** **
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
const void* user_api_get_data(int index)
|
const void* user_api_get_data(user_at_commands_t *commands, int index)
|
||||||
{
|
{
|
||||||
LOG_FUNC_IN;
|
LOG_FUNC_IN;
|
||||||
|
|
||||||
if (index < _user_data.n_cmd) {
|
if (index < commands->n_cmd) {
|
||||||
LOG_FUNC_RETURN ((void*)(&_user_data.cmd[index]));
|
LOG_FUNC_RETURN ((void*)(&commands->cmd[index]));
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_FUNC_RETURN (NULL);
|
LOG_FUNC_RETURN (NULL);
|
||||||
@@ -458,22 +451,22 @@ void user_api_close(int fd)
|
|||||||
** Others: _user_api_send_buffer, _user_data **
|
** Others: _user_api_send_buffer, _user_data **
|
||||||
** **
|
** **
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
int user_api_decode_data(int length)
|
int user_api_decode_data(user_at_commands_t *commands, int length)
|
||||||
{
|
{
|
||||||
LOG_FUNC_IN;
|
LOG_FUNC_IN;
|
||||||
|
|
||||||
/* Parse the AT command line */
|
/* Parse the AT command line */
|
||||||
LOG_TRACE(INFO, "USR-API - Decode user data: %s", _user_api_recv_buffer);
|
LOG_TRACE(INFO, "USR-API - Decode user data: %s", _user_api_recv_buffer);
|
||||||
_user_data.n_cmd = at_command_decode(_user_api_recv_buffer, length,
|
commands->n_cmd = at_command_decode(_user_api_recv_buffer, length,
|
||||||
_user_data.cmd);
|
commands->cmd);
|
||||||
|
|
||||||
if (_user_data.n_cmd > 0) {
|
if (commands->n_cmd > 0) {
|
||||||
/* AT command data received from the user application layer
|
/* AT command data received from the user application layer
|
||||||
* has been successfully decoded */
|
* has been successfully decoded */
|
||||||
LOG_TRACE(INFO, "USR-API - %d AT command%s ha%s been successfully "
|
LOG_TRACE(INFO, "USR-API - %d AT command%s ha%s been successfully "
|
||||||
"decoded", _user_data.n_cmd,
|
"decoded", commands->n_cmd,
|
||||||
(_user_data.n_cmd > 1) ? "s" : "",
|
(commands->n_cmd > 1) ? "s" : "",
|
||||||
(_user_data.n_cmd > 1) ? "ve" : "s");
|
(commands->n_cmd > 1) ? "ve" : "s");
|
||||||
} else {
|
} else {
|
||||||
int bytes;
|
int bytes;
|
||||||
|
|
||||||
@@ -490,7 +483,7 @@ int user_api_decode_data(int length)
|
|||||||
(void) _user_api_send_data(bytes);
|
(void) _user_api_send_data(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_FUNC_RETURN (_user_data.n_cmd);
|
LOG_FUNC_RETURN (commands->n_cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ Description Implements the API used by the NAS layer running in the UE
|
|||||||
|
|
||||||
#include "commonDef.h"
|
#include "commonDef.h"
|
||||||
#include "networkDef.h"
|
#include "networkDef.h"
|
||||||
|
#include "at_command.h"
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/********************* G L O B A L C O N S T A N T S *******************/
|
/********************* G L O B A L C O N S T A N T S *******************/
|
||||||
@@ -51,6 +52,16 @@ Description Implements the API used by the NAS layer running in the UE
|
|||||||
/************************ G L O B A L T Y P E S ************************/
|
/************************ G L O B A L T Y P E S ************************/
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The decoded data received from the user application layer
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
int n_cmd; /* number of user data to be processed */
|
||||||
|
#define USER_DATA_MAX 10
|
||||||
|
at_command_t cmd[USER_DATA_MAX]; /* user data to be processed */
|
||||||
|
} user_at_commands_t;
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/******************** G L O B A L V A R I A B L E S ********************/
|
/******************** G L O B A L V A R I A B L E S ********************/
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
@@ -65,14 +76,14 @@ int user_api_emm_callback(Stat_t stat, tac_t tac, ci_t ci, AcT_t AcT, const char
|
|||||||
int user_api_esm_callback(int cid, network_pdn_state_t state);
|
int user_api_esm_callback(int cid, network_pdn_state_t state);
|
||||||
|
|
||||||
int user_api_get_fd(void);
|
int user_api_get_fd(void);
|
||||||
const void* user_api_get_data(int index);
|
const void* user_api_get_data(user_at_commands_t *commands, int index);
|
||||||
|
|
||||||
int user_api_read_data(int fd);
|
int user_api_read_data(int fd);
|
||||||
int user_api_set_data(char *message);
|
int user_api_set_data(char *message);
|
||||||
int user_api_send_data(int fd, int length);
|
int user_api_send_data(int fd, int length);
|
||||||
void user_api_close(int fd);
|
void user_api_close(int fd);
|
||||||
|
|
||||||
int user_api_decode_data(int length);
|
int user_api_decode_data(user_at_commands_t *commands, int length);
|
||||||
int user_api_encode_data(const void* data, int add_success_code);
|
int user_api_encode_data(const void* data, int add_success_code);
|
||||||
|
|
||||||
#endif /* __USER_API_H__ */
|
#endif /* __USER_API_H__ */
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ static void _nas_clean(int usr_fd, 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
|
||||||
|
// FIXME allocate user and initialize its fields
|
||||||
nas_user_t *user = NULL;
|
nas_user_t *user = NULL;
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|||||||
@@ -88,6 +88,12 @@ void *nas_ue_task(void *args_p)
|
|||||||
itti_subscribe_event_fd (TASK_NAS_UE, user->fd);
|
itti_subscribe_event_fd (TASK_NAS_UE, user->fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
user->user_at_commands = calloc(1, sizeof(user_at_commands_t));
|
||||||
|
if ( user->user_at_commands == NULL ) {
|
||||||
|
LOG_E(NAS, "[UE %d] Can't allocate memory for user_at_commands\n", 0);
|
||||||
|
// FIXME stop here
|
||||||
|
}
|
||||||
|
|
||||||
user->at_response = calloc(1, sizeof(at_response_t));
|
user->at_response = calloc(1, sizeof(at_response_t));
|
||||||
if ( user->at_response == NULL ) {
|
if ( user->at_response == NULL ) {
|
||||||
LOG_E(NAS, "[UE %d] Can't allocate memory for user_at_commands\n", 0);
|
LOG_E(NAS, "[UE %d] Can't allocate memory for user_at_commands\n", 0);
|
||||||
|
|||||||
@@ -239,11 +239,11 @@ int nas_user_receive_and_process(nas_user_t *user, char *message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Decode the user data message */
|
/* Decode the user data message */
|
||||||
nb_command = user_api_decode_data (bytes);
|
nb_command = user_api_decode_data (user->user_at_commands, bytes);
|
||||||
|
|
||||||
for (i = 0; i < nb_command; i++) {
|
for (i = 0; i < nb_command; i++) {
|
||||||
/* Get the user data to be processed */
|
/* Get the user data to be processed */
|
||||||
const void *data = user_api_get_data (i);
|
const void *data = user_api_get_data (user->user_at_commands, i);
|
||||||
|
|
||||||
if (data == NULL) {
|
if (data == NULL) {
|
||||||
/* Failed to get user data at the given index;
|
/* Failed to get user data at the given index;
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ Description NAS type definition to manage a user equipment
|
|||||||
#include "EMM/Authentication.h"
|
#include "EMM/Authentication.h"
|
||||||
#include "EMM/IdleMode_defs.h"
|
#include "EMM/IdleMode_defs.h"
|
||||||
#include "API/USIM/usim_api.h"
|
#include "API/USIM/usim_api.h"
|
||||||
|
#include "API/USER/user_api.h"
|
||||||
#include "SecurityModeControl.h"
|
#include "SecurityModeControl.h"
|
||||||
#include "userDef.h"
|
#include "userDef.h"
|
||||||
#include "at_response.h"
|
#include "at_response.h"
|
||||||
@@ -77,6 +78,8 @@ typedef struct {
|
|||||||
//
|
//
|
||||||
nas_user_context_t *nas_user_context;
|
nas_user_context_t *nas_user_context;
|
||||||
at_response_t *at_response; // data structure returned to the user as the result of NAS procedure function call
|
at_response_t *at_response; // data structure returned to the user as the result of NAS procedure function call
|
||||||
|
//
|
||||||
|
user_at_commands_t *user_at_commands; //decoded data received from the user application layer
|
||||||
} nas_user_t;
|
} nas_user_t;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user