Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG UE
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Michael Black
OpenXG UE
Commits
f05bd7de
Commit
f05bd7de
authored
Jul 22, 2016
by
Frédéric Leroy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UE/API/USER: move _user_api_*_buffer to user_api_id_t
parent
80d7d842
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
49 deletions
+34
-49
openair3/NAS/UE/API/USER/user_api.c
openair3/NAS/UE/API/USER/user_api.c
+24
-44
openair3/NAS/UE/API/USER/user_api.h
openair3/NAS/UE/API/USER/user_api.h
+2
-2
openair3/NAS/UE/API/USER/user_api_defs.h
openair3/NAS/UE/API/USER/user_api_defs.h
+6
-1
openair3/NAS/UE/nas_user.c
openair3/NAS/UE/nas_user.c
+2
-2
No files found.
openair3/NAS/UE/API/USER/user_api.c
View file @
f05bd7de
...
...
@@ -75,20 +75,6 @@ static int _user_api_pdn_connection_handler(user_api_id_t *user_api_id, unsigned
static
int
_user_api_send
(
user_api_id_t
*
user_api_id
,
at_response_t
*
data
);
/*
* The buffer used to receive data from the user application layer
*/
#define USER_API_RECV_BUFFER_SIZE 4096
// FIXME not reentrant
static
char
_user_api_recv_buffer
[
USER_API_RECV_BUFFER_SIZE
];
/*
* The buffer used to send data to the user application layer
*/
#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
];
/****************************************************************************/
/****************** E X P O R T E D F U N C T I O N S ******************/
/****************************************************************************/
...
...
@@ -115,7 +101,7 @@ int user_api_initialize(user_api_id_t *user_api_id, const char* host, const char
{
LOG_FUNC_IN
;
gethostname
(
_user_api_
send_buffer
,
USER_API_SEND_BUFFER_SIZE
);
gethostname
(
user_api_id
->
send_buffer
,
USER_API_SEND_BUFFER_SIZE
);
if
(
devname
!=
NULL
)
{
/* Initialize device handlers */
...
...
@@ -135,7 +121,7 @@ int user_api_initialize(user_api_id_t *user_api_id, const char* host, const char
}
LOG_TRACE
(
INFO
,
"USR-API - User's communication device %d is OPENED "
"on %s/%s"
,
user_api_get_fd
(
user_api_id
),
_user_api_
send_buffer
,
devname
);
"on %s/%s"
,
user_api_get_fd
(
user_api_id
),
user_api_id
->
send_buffer
,
devname
);
}
else
{
/* Initialize network socket handlers */
user_api_id
->
open
=
socket_udp_open
;
...
...
@@ -156,7 +142,7 @@ int user_api_initialize(user_api_id_t *user_api_id, const char* host, const char
}
LOG_TRACE
(
INFO
,
"USR-API - User's UDP socket %d is BOUND to %s/%s"
,
user_api_get_fd
(
user_api_id
),
_user_api_
send_buffer
,
port
);
user_api_get_fd
(
user_api_id
),
user_api_id
->
send_buffer
,
port
);
}
/* Register the asynchronous notification handlers */
...
...
@@ -245,7 +231,7 @@ const void* user_api_get_data(user_at_commands_t *commands, int index)
** **
** Outputs: Return: The number of bytes read when success; **
** RETURNerror Otherwise **
** Others:
_user_api_
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
)
...
...
@@ -262,10 +248,10 @@ int user_api_read_data(user_api_id_t *user_api_id, int fd)
LOG_FUNC_RETURN
(
RETURNerror
);
}
memset
(
_user_api_
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 */
rbytes
=
user_api_id
->
recv
(
user_api_id
->
endpoint
,
_user_api_
recv_buffer
,
USER_API_RECV_BUFFER_SIZE
);
rbytes
=
user_api_id
->
recv
(
user_api_id
->
endpoint
,
user_api_id
->
recv_buffer
,
USER_API_RECV_BUFFER_SIZE
);
if
(
rbytes
==
RETURNerror
)
{
LOG_TRACE
(
ERROR
,
"USR-API - recv() failed, %s"
,
strerror
(
errno
));
...
...
@@ -275,7 +261,7 @@ int user_api_read_data(user_api_id_t *user_api_id, int fd)
}
else
{
LOG_TRACE
(
INFO
,
"USR-API - %d bytes received "
"from the user application layer"
,
rbytes
);
LOG_DUMP
(
_user_api_
recv_buffer
,
rbytes
);
LOG_DUMP
(
user_api_id
->
recv_buffer
,
rbytes
);
}
LOG_FUNC_RETURN
(
rbytes
);
...
...
@@ -291,22 +277,22 @@ int user_api_read_data(user_api_id_t *user_api_id, int fd)
** **
** Outputs: Return: The number of bytes write when success; **
** RETURNerror Otherwise **
** Others:
_user_api_
recv_buffer **
** Others:
user_api_id->
recv_buffer **
** **
***************************************************************************/
int
user_api_set_data
(
char
*
message
)
int
user_api_set_data
(
user_api_id_t
*
user_api_id
,
char
*
message
)
{
LOG_FUNC_IN
;
int
rbytes
;
memset
(
_user_api_
recv_buffer
,
0
,
USER_API_RECV_BUFFER_SIZE
);
memset
(
user_api_id
->
recv_buffer
,
0
,
USER_API_RECV_BUFFER_SIZE
);
strncpy
(
_user_api_
recv_buffer
,
message
,
USER_API_RECV_BUFFER_SIZE
);
rbytes
=
strlen
(
_user_api_
recv_buffer
);
strncpy
(
user_api_id
->
recv_buffer
,
message
,
USER_API_RECV_BUFFER_SIZE
);
rbytes
=
strlen
(
user_api_id
->
recv_buffer
);
LOG_TRACE
(
INFO
,
"USR-API - %d bytes write"
,
rbytes
);
LOG_DUMP
(
_user_api_
recv_buffer
,
rbytes
);
LOG_DUMP
(
user_api_id
->
recv_buffer
,
rbytes
);
LOG_FUNC_RETURN
(
rbytes
);
}
...
...
@@ -320,7 +306,6 @@ int user_api_set_data(char *message)
** Inputs: fd: File descriptor of the connection endpoint **
** to which data have to be sent **
** length: Number of bytes to send **
** Others: _user_api_send_buffer, _user_api_id **
** **
** Outputs: Return: The number of bytes sent when success; **
** RETURNerror Otherwise **
...
...
@@ -329,7 +314,7 @@ int user_api_set_data(char *message)
***************************************************************************/
static
int
_user_api_send_data
(
user_api_id_t
*
user_api_id
,
int
length
)
{
int
sbytes
=
user_api_id
->
send
(
user_api_id
->
endpoint
,
_user_api_
send_buffer
,
length
);
int
sbytes
=
user_api_id
->
send
(
user_api_id
->
endpoint
,
user_api_id
->
send_buffer
,
length
);
if
(
sbytes
==
RETURNerror
)
{
LOG_TRACE
(
ERROR
,
"USR-API - send() failed, %s"
,
strerror
(
errno
));
...
...
@@ -339,7 +324,7 @@ static int _user_api_send_data(user_api_id_t *user_api_id, int length)
}
else
{
LOG_TRACE
(
INFO
,
"USR-API - %d bytes sent "
"to the user application layer"
,
sbytes
);
LOG_DUMP
(
_user_api_
send_buffer
,
sbytes
);
LOG_DUMP
(
user_api_id
->
send_buffer
,
sbytes
);
}
return
sbytes
;
...
...
@@ -379,7 +364,6 @@ int user_api_send_data(user_api_id_t *user_api_id, int fd, int length)
** Others: None **
** **
** Outputs: Return: None **
** Others: _user_api_id **
** **
***************************************************************************/
void
user_api_close
(
user_api_id_t
*
user_api_id
,
int
fd
)
...
...
@@ -412,11 +396,9 @@ void user_api_close(user_api_id_t *user_api_id, int fd)
** layer when the AT command failed to be decoded. **
** **
** Inputs: length: Number of bytes to decode **
** Others: _user_api_recv_buffer **
** **
** Outputs: Return: The number of AT commands succeessfully **
** decoded **
** Others: _user_api_send_buffer, _user_data **
** **
***************************************************************************/
int
user_api_decode_data
(
user_api_id_t
*
user_api_id
,
user_at_commands_t
*
commands
,
int
length
)
...
...
@@ -424,8 +406,8 @@ int user_api_decode_data(user_api_id_t *user_api_id, user_at_commands_t *command
LOG_FUNC_IN
;
/* Parse the AT command line */
LOG_TRACE
(
INFO
,
"USR-API - Decode user data: %s"
,
_user_api_
recv_buffer
);
commands
->
n_cmd
=
at_command_decode
(
_user_api_
recv_buffer
,
length
,
LOG_TRACE
(
INFO
,
"USR-API - Decode user data: %s"
,
user_api_id
->
recv_buffer
);
commands
->
n_cmd
=
at_command_decode
(
user_api_id
->
recv_buffer
,
length
,
commands
->
cmd
);
if
(
commands
->
n_cmd
>
0
)
{
...
...
@@ -441,10 +423,10 @@ int user_api_decode_data(user_api_id_t *user_api_id, user_at_commands_t *command
/* Failed to decode AT command data received from the user
* application layer; Return syntax error code message */
LOG_TRACE
(
ERROR
,
"USR-API - Syntax error: Failed to decode "
"AT command data %s"
,
_user_api_
recv_buffer
);
"AT command data %s"
,
user_api_id
->
recv_buffer
);
/* Encode the syntax error code message */
bytes
=
at_error_encode
(
_user_api_
send_buffer
,
AT_ERROR_SYNTAX
,
bytes
=
at_error_encode
(
user_api_id
->
send_buffer
,
AT_ERROR_SYNTAX
,
AT_ERROR_OPERATION_NOT_SUPPORTED
);
// FIXME move _user_data call
...
...
@@ -471,10 +453,9 @@ int user_api_decode_data(user_api_id_t *user_api_id, user_at_commands_t *command
** Outputs: Return: The number of characters that have been **
** successfully encoded; **
** RETURNerror otherwise. **
** Others: _user_api_send_buffer **
** **
***************************************************************************/
int
user_api_encode_data
(
const
void
*
data
,
int
success_code
)
int
user_api_encode_data
(
user_api_id_t
*
user_api_id
,
const
void
*
data
,
int
success_code
)
{
LOG_FUNC_IN
;
...
...
@@ -483,16 +464,16 @@ int user_api_encode_data(const void* data, int success_code)
/* Encode AT command error message */
if
(
user_data
->
cause_code
!=
AT_ERROR_SUCCESS
)
{
bytes
=
at_error_encode
(
_user_api_
send_buffer
,
AT_ERROR_CME
,
bytes
=
at_error_encode
(
user_api_id
->
send_buffer
,
AT_ERROR_CME
,
user_data
->
cause_code
);
}
/* Encode AT command response message */
else
{
bytes
=
at_response_encode
(
_user_api_
send_buffer
,
user_data
);
bytes
=
at_response_encode
(
user_api_id
->
send_buffer
,
user_data
);
/* Add success result code */
if
(
(
success_code
)
&&
(
bytes
!=
RETURNerror
)
)
{
bytes
+=
at_error_encode
(
&
_user_api_
send_buffer
[
bytes
],
bytes
+=
at_error_encode
(
&
user_api_id
->
send_buffer
[
bytes
],
AT_ERROR_OK
,
0
);
}
}
...
...
@@ -613,7 +594,6 @@ int user_api_esm_callback(user_api_id_t *user_api_id, int cid, network_pdn_state
** Description: Encodes and sends data to the user application layer **
** **
** Inputs: data: The data to send **
** Others: _user_api_send_buffer, _user_api_id **
** **
** Outputs: Return: The number of bytes sent when success; **
** RETURNerror Otherwise **
...
...
@@ -625,7 +605,7 @@ static int _user_api_send(user_api_id_t *user_api_id, at_response_t* data)
LOG_FUNC_IN
;
/* Encode AT command response message */
int
bytes
=
at_response_encode
(
_user_api_
send_buffer
,
data
);
int
bytes
=
at_response_encode
(
user_api_id
->
send_buffer
,
data
);
/* Send the AT command response message to the user application */
if
(
bytes
!=
RETURNerror
)
{
...
...
openair3/NAS/UE/API/USER/user_api.h
View file @
f05bd7de
...
...
@@ -67,11 +67,11 @@ 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_set_data
(
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
);
void
user_api_close
(
user_api_id_t
*
user_api_id
,
int
fd
);
int
user_api_decode_data
(
user_api_id_t
*
user_api_id
,
user_at_commands_t
*
commands
,
int
length
);
int
user_api_encode_data
(
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
);
#endif
/* __USER_API_H__ */
openair3/NAS/UE/API/USER/user_api_defs.h
View file @
f05bd7de
...
...
@@ -8,12 +8,15 @@
/************************ G L O B A L T Y P E S ************************/
/****************************************************************************/
#define USER_API_RECV_BUFFER_SIZE 4096
#define USER_API_SEND_BUFFER_SIZE USER_API_RECV_BUFFER_SIZE
#define USER_DATA_MAX 10
/*
* 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
;
...
...
@@ -39,6 +42,8 @@ typedef struct {
ssize_t
(
*
recv
)
(
void
*
,
char
*
,
size_t
);
ssize_t
(
*
send
)
(
const
void
*
,
const
char
*
,
size_t
);
void
(
*
close
)(
void
*
);
char
recv_buffer
[
USER_API_RECV_BUFFER_SIZE
];
char
send_buffer
[
USER_API_SEND_BUFFER_SIZE
];
}
user_api_id_t
;
...
...
openair3/NAS/UE/nas_user.c
View file @
f05bd7de
...
...
@@ -220,7 +220,7 @@ int nas_user_receive_and_process(nas_user_t *user, char *message)
if
(
message
!=
NULL
)
{
/* Set the message in receive buffer (Use to simulate reception of data from UserProcess) */
bytes
=
user_api_set_data
(
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
);
...
...
@@ -270,7 +270,7 @@ int nas_user_receive_and_process(nas_user_t *user, char *message)
/* Send response to UserProcess (If not in simulated reception) */
if
(
message
==
NULL
)
{
/* Encode the user data message */
bytes
=
user_api_encode_data
(
nas_user_get_data
(
user
),
i
==
nb_command
-
1
);
bytes
=
user_api_encode_data
(
user
->
user_api_id
,
nas_user_get_data
(
user
),
i
==
nb_command
-
1
);
if
(
bytes
==
RETURNerror
)
{
/* Failed to encode the user data message;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment