Commit c67aafd2 authored by Cedric Roux's avatar Cedric Roux

- Fixed origin task id of sctp date req message

- Unified structures names
- Added nas ul data ind between S1AP and NAS
- Fixed indentation of NAS files

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4554 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent f355cc61
......@@ -5,7 +5,8 @@ MESSAGE_DEF(NAS_CONNECTION_ESTABLISHMENT_IND, MESSAGE_PRIORITY_MED, nas_conn_est
MESSAGE_DEF(NAS_CONNECTION_ESTABLISHMENT_RSP, MESSAGE_PRIORITY_MED, nas_conn_est_rsp_t, nas_conn_est_rsp)
MESSAGE_DEF(NAS_CONNECTION_RELEASE_IND, MESSAGE_PRIORITY_MED, nas_conn_rel_ind_t, nas_conn_rel_ind)
MESSAGE_DEF(NAS_UPLINK_DATA_IND, MESSAGE_PRIORITY_MED, nas_ul_data_ind_t, nas_ul_data_ind)
MESSAGE_DEF(NAS_DOWNLINK_DATA_IND, MESSAGE_PRIORITY_MED, nas_dl_data_ind_t, nas_dl_data_ind)
MESSAGE_DEF(NAS_DOWNLINK_DATA_REQ, MESSAGE_PRIORITY_MED, nas_dl_data_req_t, nas_dl_data_req)
MESSAGE_DEF(NAS_DOWNLINK_DATA_CNF, MESSAGE_PRIORITY_MED, nas_dl_data_cnf_t, nas_dl_data_cnf)
MESSAGE_DEF(NAS_NON_DELIVERY_IND, MESSAGE_PRIORITY_MED, nas_non_del_ind_t, nas_non_del_ind)
MESSAGE_DEF(NAS_RAB_ESTABLISHMENT_REQ, MESSAGE_PRIORITY_MED, nas_rab_est_req_t, nas_rab_est_req)
MESSAGE_DEF(NAS_RAB_ESTABLISHMENT_RESP, MESSAGE_PRIORITY_MED, nas_rab_est_rsp_t, nas_rab_est_rsp)
......
......@@ -3,6 +3,10 @@
#ifndef NAS_MESSAGES_TYPES_H_
#define NAS_MESSAGES_TYPES_H_
#define NAS_UL_DATA_IND(mSGpTR) (mSGpTR)->ittiMsg.nas_ul_data_ind
#define NAS_DL_DATA_REQ(mSGpTR) (mSGpTR)->ittiMsg.nas_dl_data_req
#define NAS_DL_DATA_CNF(mSGpTR) (mSGpTR)->ittiMsg.nas_dl_data_cnf
typedef struct {
} nas_paging_ind_t;
......@@ -24,11 +28,10 @@ typedef struct {
} nas_conn_rel_ind_t;
typedef struct {
} nas_ul_data_ind_t;
typedef ul_info_transfer_ind_t nas_ul_data_ind_t;
typedef dl_info_transfer_req_t nas_dl_data_ind_t;
typedef dl_info_transfer_req_t nas_dl_data_req_t;
typedef dl_info_transfer_cnf_t nas_dl_data_cnf_t;
typedef struct {
......
//WARNING: Do not include this header directly. Use intertask_interface.h instead.
MESSAGE_DEF(S1AP_SCTP_NEW_MESSAGE_IND, MESSAGE_PRIORITY_MED, s1ap_sctp_new_msg_ind_t, s1ap_sctp_new_msg_ind)
MESSAGE_DEF(S1AP_UE_CAPABILITIES_IND, MESSAGE_PRIORITY_MED, s1ap_ue_cap_ind_t, s1ap_ue_cap_ind)
#ifndef S1AP_MESSAGES_TYPES_H_
#define S1AP_MESSAGES_TYPES_H_
typedef struct {
uint8_t *buffer; ///< SCTP buffer
uint32_t buf_length; ///< SCTP buffer length
int32_t assoc_id; ///< SCTP physical association ID
uint8_t stream; ///< Stream number on which data had been received
uint16_t instreams; ///< Number of input streams for the SCTP connection between peers
uint16_t outstreams; ///< Number of output streams for the SCTP connection between peers
} s1ap_sctp_new_msg_ind_t;
typedef struct s1ap_initial_ue_message_s {
unsigned eNB_ue_s1ap_id:24;
uint32_t mme_ue_s1ap_id;
......
//WARNING: Do not include this header directly. Use intertask_interface.h instead.
MESSAGE_DEF(SCTP_INIT_MSG, MESSAGE_PRIORITY_MED, SctpInit, sctpInit)
MESSAGE_DEF(SCTP_NEW_DATA_REQ, MESSAGE_PRIORITY_MED, SctpNewDataReq, sctpNewDataReq)
MESSAGE_DEF(SCTP_DATA_REQ, MESSAGE_PRIORITY_MED, sctp_data_req_t, sctp_data_req)
MESSAGE_DEF(SCTP_DATA_IND, MESSAGE_PRIORITY_MED, sctp_data_ind_t, sctp_data_ind)
MESSAGE_DEF(SCTP_NEW_ASSOCIATION, MESSAGE_PRIORITY_MAX, sctp_new_peer_t, sctp_new_peer)
MESSAGE_DEF(SCTP_CLOSE_ASSOCIATION, MESSAGE_PRIORITY_MAX, sctp_close_association_t, sctp_close_association)
#ifndef SCTP_MESSAGES_TYPES_H_
#define SCTP_MESSAGES_TYPES_H_
typedef struct {
#define SCTP_DATA_IND(mSGpTR) (mSGpTR)->ittiMsg.sctp_data_ind
#define SCTP_DATA_REQ(mSGpTR) (mSGpTR)->ittiMsg.sctp_data_req
#define SCTP_INIT(mSGpTR) (mSGpTR)->ittiMsg.sctpInit
#define SCTP_CLOSE_ASSOCIATION(mSGpTR) (mSGpTR)->ittiMsg.sctp_close_association
typedef struct sctp_data_req_s {
uint8_t *buffer;
uint32_t bufLen;
uint32_t assocId;
uint16_t stream;
} SctpNewDataReq;
} sctp_data_req_t;
typedef struct sctp_data_ind_s {
uint8_t *buffer; ///< SCTP buffer
uint32_t buf_length; ///< SCTP buffer length
int32_t assoc_id; ///< SCTP physical association ID
uint8_t stream; ///< Stream number on which data had been received
uint16_t instreams; ///< Number of input streams for the SCTP connection between peers
uint16_t outstreams; ///< Number of output streams for the SCTP connection between peers
} sctp_data_ind_t;
typedef struct {
typedef struct sctp_init_s {
/* Request usage of ipv4 */
unsigned ipv4:1;
/* Request usage of ipv6 */
......@@ -21,11 +35,11 @@ typedef struct {
uint32_t ppid;
} SctpInit;
typedef struct {
typedef struct sctp_close_association_s {
uint32_t assoc_id;
} sctp_close_association_t;
typedef struct {
typedef struct sctp_new_peer_s {
uint32_t instreams;
uint32_t outstreams;
uint32_t assoc_id;
......
......@@ -37,10 +37,12 @@ messages_hdr = \
$(top_srcdir)/COMMON/udp_messages_types.h
messages.xml: $(top_srcdir)/INTERTASK_INTERFACE/intertask_interface_types.h $(messages_hdr)
gccxml $(AM_CFLAGS) $< -fxml=$(top_builddir)/$@
@echo "Generating $<"
@gccxml $(AM_CFLAGS) $< -fxml=$(top_builddir)/$@
messages_xml.h: messages.xml
sed -e 's/[ ]*//' -e 's/"/\\"/g' -e 's/^/"/' -e 's/$$/"/' messages.xml > messages_xml.h
@echo "Generating $<"
@sed -e 's/[ ]*//' -e 's/"/\\"/g' -e 's/^/"/' -e 's/$$/"/' messages.xml > messages_xml.h
endif
SUBDIRS = \
......
......@@ -43,7 +43,7 @@
#define NAS_SLEEP_TIMEOUT 1000 /* 1 second */
static void* _nas_network_mngr(void*);
static void *_nas_network_mngr(void *);
static int _nas_set_signal_handler(int signal, void (handler)(int));
static void _nas_signal_handler(int signal);
......@@ -55,13 +55,12 @@ static void _nas_clean(int net_fd);
/****************************************************************************/
/****************************************************************************/
int main(int argc, const char* argv[])
int main(int argc, const char *argv[])
{
/*
* Get the command line options
*/
if (nas_parser_get_options (argc, argv) != RETURNok)
{
if (nas_parser_get_options (argc, argv) != RETURNok) {
nas_parser_print_usage (FIRMWARE_VERSION);
exit (EXIT_FAILURE);
}
......@@ -71,17 +70,17 @@ int main(int argc, const char* argv[])
*/
nas_log_init (nas_parser_get_trace_level ());
const char* nhost = nas_parser_get_network_host ();
const char* nport = nas_parser_get_network_port ();
const char *nhost = nas_parser_get_network_host ();
const char *nport = nas_parser_get_network_port ();
LOG_TRACE (INFO, "MME-MAIN - %s -nhost %s -nport %s -trace 0x%x", argv[0], nhost, nport,
LOG_TRACE (INFO, "MME-MAIN - %s -nhost %s -nport %s -trace 0x%x", argv[0],
nhost, nport,
nas_parser_get_trace_level ());
/*
* Initialize the Network interface
*/
if (network_api_initialize (nhost, nport) != RETURNok)
{
if (network_api_initialize (nhost, nport) != RETURNok) {
LOG_TRACE (ERROR, "MME-MAIN - network_api_initialize() failed");
exit (EXIT_FAILURE);
}
......@@ -112,8 +111,8 @@ int main(int argc, const char* argv[])
* Start thread use to manage the network connection endpoint
*/
pthread_t network_mngr;
if (pthread_create (&network_mngr, &attr, _nas_network_mngr, &network_fd) != 0)
{
if (pthread_create (&network_mngr, &attr, _nas_network_mngr,
&network_fd) != 0) {
LOG_TRACE (ERROR, "MME-MAIN - "
"Failed to create the network management thread");
network_api_close (network_fd);
......@@ -125,8 +124,7 @@ int main(int argc, const char* argv[])
* Suspend execution of the main process until the network connection
* endpoint is still active
*/
while (network_fd != -1)
{
while (network_fd != -1) {
poll (NULL, 0, NAS_SLEEP_TIMEOUT);
network_fd = network_api_get_fd ();
}
......@@ -157,7 +155,7 @@ int main(int argc, const char* argv[])
** Others: None **
** **
***************************************************************************/
static void* _nas_network_mngr(void* args)
static void *_nas_network_mngr(void *args)
{
LOG_FUNC_IN;
......@@ -165,17 +163,15 @@ static void* _nas_network_mngr(void* args)
int network_message_id;
int bytes;
int *fd = (int*) args;
int *fd = (int *) args;
LOG_TRACE (INFO, "MME-MAIN - Network connection manager started (%d)", *fd);
/* Network receiving loop */
while (TRUE)
{
while (TRUE) {
/* Read the network data message */
bytes = network_api_read_data (*fd);
if (bytes == RETURNerror)
{
if (bytes == RETURNerror) {
/* Failed to read data from the network sublayer;
* exit from the receiving loop */
LOG_TRACE (ERROR, "MME-MAIN - "
......@@ -183,24 +179,22 @@ static void* _nas_network_mngr(void* args)
break;
}
if (bytes == 0)
{
if (bytes == 0) {
/* A signal was caught before any data were available */
continue;
}
/* Decode the network data message */
network_message_id = network_api_decode_data (bytes);
if (network_message_id == RETURNerror)
{
if (network_message_id == RETURNerror) {
/* Failed to decode data read from the network sublayer */
continue;
}
/* Process the network data message */
ret_code = nas_network_process_data (network_message_id, network_api_get_data ());
if (ret_code != RETURNok)
{
ret_code = nas_network_process_data (network_message_id,
network_api_get_data ());
if (ret_code != RETURNok) {
/* The network data message has not been successfully
* processed */
LOG_TRACE
......@@ -210,7 +204,8 @@ static void* _nas_network_mngr(void* args)
}
}
/* Close the connection to the network sublayer */LOG_TRACE (WARNING, "MME-MAIN - "
/* Close the connection to the network sublayer */LOG_TRACE (WARNING,
"MME-MAIN - "
"The network connection endpoint manager exited");
LOG_FUNC_RETURN(NULL);
......@@ -255,8 +250,7 @@ static int _nas_set_signal_handler(int signal, void (handler)(int))
/* Initialize signal handler */
act.sa_handler = handler;
if (sigaction (signal, &act, 0) < 0)
{
if (sigaction (signal, &act, 0) < 0) {
return RETURNerror;
}
......
......@@ -45,8 +45,8 @@
#define NAS_SLEEP_TIMEOUT 1000 /* 1 second */
static void* _nas_user_mngr(void*);
static void* _nas_network_mngr(void*);
static void *_nas_user_mngr(void *);
static void *_nas_network_mngr(void *);
static int _nas_set_signal_handler(int signal, void (handler)(int));
static void _nas_signal_handler(int signal);
......@@ -58,13 +58,12 @@ static void _nas_clean(int usr_fd, int net_fd);
/****************************************************************************/
/****************************************************************************/
int main(int argc, const char* argv[])
int main(int argc, const char *argv[])
{
/*
* Get the command line options
*/
if (nas_parser_get_options (argc, argv) != RETURNok)
{
if (nas_parser_get_options (argc, argv) != RETURNok) {
nas_parser_print_usage (FIRMWARE_VERSION);
exit (EXIT_FAILURE);
}
......@@ -74,22 +73,22 @@ int main(int argc, const char* argv[])
*/
nas_log_init (nas_parser_get_trace_level ());
const char* uhost = nas_parser_get_user_host ();
const char* uport = nas_parser_get_user_port ();
const char* devpath = nas_parser_get_device_path ();
const char* devparams = nas_parser_get_device_params ();
const char* nhost = nas_parser_get_network_host ();
const char* nport = nas_parser_get_network_port ();
const char *uhost = nas_parser_get_user_host ();
const char *uport = nas_parser_get_user_port ();
const char *devpath = nas_parser_get_device_path ();
const char *devparams = nas_parser_get_device_params ();
const char *nhost = nas_parser_get_network_host ();
const char *nport = nas_parser_get_network_port ();
LOG_TRACE (INFO, "UE-MAIN - %s -ueid %d -uhost %s -uport %s -nhost %s -nport %s -dev %s -params %s -trace 0x%x",
LOG_TRACE (INFO,
"UE-MAIN - %s -ueid %d -uhost %s -uport %s -nhost %s -nport %s -dev %s -params %s -trace 0x%x",
argv[0], nas_parser_get_ueid (), uhost, uport, nhost, nport, devpath, devparams,
nas_parser_get_trace_level ());
/*
* Initialize the User interface
*/
if (user_api_initialize (uhost, uport, devpath, devparams) != RETURNok)
{
if (user_api_initialize (uhost, uport, devpath, devparams) != RETURNok) {
LOG_TRACE (ERROR, "UE-MAIN - user_api_initialize() failed");
exit (EXIT_FAILURE);
}
......@@ -98,8 +97,7 @@ int main(int argc, const char* argv[])
/*
* Initialize the Network interface
*/
if (network_api_initialize (nhost, nport) != RETURNok)
{
if (network_api_initialize (nhost, nport) != RETURNok) {
LOG_TRACE (ERROR, "UE-MAIN - network_api_initialize() failed");
user_api_close (user_fd);
exit (EXIT_FAILURE);
......@@ -109,7 +107,8 @@ int main(int argc, const char* argv[])
/*
* Initialize the NAS contexts
*/
nas_user_initialize (&user_api_emm_callback, &user_api_esm_callback, FIRMWARE_VERSION);
nas_user_initialize (&user_api_emm_callback, &user_api_esm_callback,
FIRMWARE_VERSION);
nas_network_initialize ();
/*
......@@ -132,8 +131,7 @@ int main(int argc, const char* argv[])
* Start thread use to manage the user connection endpoint
*/
pthread_t user_mngr;
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 - "
"Failed to create the user management thread");
user_api_close (user_fd);
......@@ -145,8 +143,8 @@ int main(int argc, const char* argv[])
* Start thread use to manage the network connection endpoint
*/
pthread_t network_mngr;
if (pthread_create (&network_mngr, &attr, _nas_network_mngr, &network_fd) != 0)
{
if (pthread_create (&network_mngr, &attr, _nas_network_mngr,
&network_fd) != 0) {
LOG_TRACE (ERROR, "UE-MAIN - "
"Failed to create the network management thread");
user_api_close (user_fd);
......@@ -159,8 +157,7 @@ int main(int argc, const char* argv[])
* Suspend execution of the main process until all connection
* endpoints are still active
*/
while ((user_fd != -1) && (network_fd != -1))
{
while ((user_fd != -1) && (network_fd != -1)) {
poll (NULL, 0, NAS_SLEEP_TIMEOUT);
user_fd = user_api_get_fd ();
network_fd = network_api_get_fd ();
......@@ -192,7 +189,7 @@ int main(int argc, const char* argv[])
** Others: None **
** **
***************************************************************************/
static void* _nas_user_mngr(void* args)
static void *_nas_user_mngr(void *args)
{
LOG_FUNC_IN;
......@@ -202,17 +199,15 @@ static void* _nas_user_mngr(void* args)
int bytes;
int i;
int *fd = (int*) args;
int *fd = (int *) args;
LOG_TRACE (INFO, "UE-MAIN - User connection manager started (%d)", *fd);
/* User receiving loop */
while (!exit_loop)
{
while (!exit_loop) {
/* Read the user data message */
bytes = user_api_read_data (*fd);
if (bytes == RETURNerror)
{
if (bytes == RETURNerror) {
/* Failed to read data from the user application layer;
* exit from the receiving loop */
LOG_TRACE (ERROR, "UE-MAIN - "
......@@ -220,20 +215,17 @@ static void* _nas_user_mngr(void* args)
break;
}
if (bytes == 0)
{
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++)
{
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)
{
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 - "
......@@ -244,8 +236,7 @@ static void* _nas_user_mngr(void* args)
/* Process the user data message */
ret_code = nas_user_process_data (data);
if (ret_code != RETURNok)
{
if (ret_code != RETURNok) {
/* The user data message has not been successfully
* processed; cause code will be encoded and sent back
* to the user */
......@@ -256,8 +247,7 @@ static void* _nas_user_mngr(void* args)
/* Encode the user data message */
bytes = user_api_encode_data (nas_user_get_data (), i == nb_command - 1);
if (bytes == RETURNerror)
{
if (bytes == RETURNerror) {
/* Failed to encode the user data message;
* go ahead and process the next user data */
continue;
......@@ -265,8 +255,7 @@ static void* _nas_user_mngr(void* args)
/* Send the data message to the user */
bytes = user_api_send_data (*fd, bytes);
if (bytes == RETURNerror)
{
if (bytes == RETURNerror) {
/* Failed to send data to the user application layer;
* exit from the receiving loop */
LOG_TRACE (ERROR, "UE-MAIN - "
......@@ -300,7 +289,7 @@ static void* _nas_user_mngr(void* args)
** Others: None **
** **
***************************************************************************/
static void* _nas_network_mngr(void* args)
static void *_nas_network_mngr(void *args)
{
LOG_FUNC_IN;
......@@ -308,17 +297,15 @@ static void* _nas_network_mngr(void* args)
int network_message_id;
int bytes;
int *fd = (int*) args;
int *fd = (int *) args;
LOG_TRACE (INFO, "UE-MAIN - Network connection manager started (%d)", *fd);
/* Network receiving loop */
while (TRUE)
{
while (TRUE) {
/* Read the network data message */
bytes = network_api_read_data (*fd);
if (bytes == RETURNerror)
{
if (bytes == RETURNerror) {
/* Failed to read data from the network sublayer;
* exit from the receiving loop */
LOG_TRACE (ERROR, "UE-MAIN - "
......@@ -326,24 +313,22 @@ static void* _nas_network_mngr(void* args)
break;
}
if (bytes == 0)
{
if (bytes == 0) {
/* A signal was caught before any data were available */
continue;
}
/* Decode the network data message */
network_message_id = network_api_decode_data (bytes);
if (network_message_id == RETURNerror)
{
if (network_message_id == RETURNerror) {
/* Failed to decode data read from the network sublayer */
continue;
}
/* Process the network data message */
ret_code = nas_network_process_data (network_message_id, network_api_get_data ());
if (ret_code != RETURNok)
{
ret_code = nas_network_process_data (network_message_id,
network_api_get_data ());
if (ret_code != RETURNok) {
/* The network data message has not been successfully
* processed */
LOG_TRACE
......@@ -400,8 +385,7 @@ static int _nas_set_signal_handler(int signal, void (handler)(int))
/* Initialize signal handler */
act.sa_handler = handler;
if (sigaction (signal, &act, 0) < 0)
{
if (sigaction (signal, &act, 0) < 0) {
return RETURNerror;
}
......
......@@ -62,16 +62,16 @@ Description Implements the EPS Mobility Management procedures executed
** Others: emm_fsm_status **
** **
***************************************************************************/
int EmmCommonProcedureInitiated(const emm_reg_t* evt)
int EmmCommonProcedureInitiated(const emm_reg_t *evt)
{
int rc = RETURNerror;
LOG_FUNC_IN;
assert(emm_fsm_get_status(evt->ueid, evt->ctx) == EMM_COMMON_PROCEDURE_INITIATED);
assert(emm_fsm_get_status(evt->ueid,
evt->ctx) == EMM_COMMON_PROCEDURE_INITIATED);
switch (evt->primitive)
{
switch (evt->primitive) {
case _EMMREG_PROC_ABORT:
/*
* The EMM procedure that initiated EMM common procedure aborted
......
......@@ -67,7 +67,7 @@ Description Implements the EPS Mobility Management procedures executed
** Others: emm_fsm_status **
** **
***************************************************************************/
int EmmDeregistered(const emm_reg_t* evt)
int EmmDeregistered(const emm_reg_t *evt)
{
LOG_FUNC_IN;
......@@ -94,8 +94,7 @@ int EmmDeregistered(const emm_reg_t* evt)
*/
#endif
switch (evt->primitive)
{
switch (evt->primitive) {
#ifdef NAS_UE
case _EMMREG_NO_IMSI:
......
......@@ -60,7 +60,7 @@ Description Implements the EPS Mobility Management procedures executed
** Others: emm_fsm_status **
** **
***************************************************************************/
int EmmDeregisteredAttachNeeded(const emm_reg_t* evt)
int EmmDeregisteredAttachNeeded(const emm_reg_t *evt)
{
LOG_FUNC_IN;
......
......@@ -62,7 +62,7 @@ Description Implements the EPS Mobility Management procedures executed
** Others: emm_fsm_status **
** **
***************************************************************************/
int EmmDeregisteredAttemptingToAttach(const emm_reg_t* evt)
int EmmDeregisteredAttemptingToAttach(const emm_reg_t *evt)
{
LOG_FUNC_IN;
......@@ -70,8 +70,7 @@ int EmmDeregisteredAttemptingToAttach(const emm_reg_t* evt)
assert(emm_fsm_get_status() == EMM_DEREGISTERED_ATTEMPTING_TO_ATTACH);
switch (evt->primitive)
{
switch (evt->primitive) {
case _EMMREG_ATTACH_INIT:
/*
* Attach procedure has to be restarted (timers T3402 or T3411
......
......@@ -60,7 +60,7 @@ Description Implements the EPS Mobility Management procedures executed
** Others: emm_fsm_status **
** **
***************************************************************************/
int EmmDeregisteredInitiated(const emm_reg_t* evt)
int EmmDeregisteredInitiated(const emm_reg_t *evt)
{
LOG_FUNC_IN;
......@@ -73,8 +73,7 @@ int EmmDeregisteredInitiated(const emm_reg_t* evt)
assert(emm_fsm_get_status(evt->ueid, evt->ctx) == EMM_DEREGISTERED_INITIATED);
#endif
switch (evt->primitive)
{
switch (evt->primitive) {
#ifdef NAS_UE
case _EMMREG_DETACH_CNF:
/*
......
......@@ -66,7 +66,7 @@ Description Implements the EPS Mobility Management procedures executed
** Others: emm_fsm_status **
** **
***************************************************************************/
int EmmDeregisteredLimitedService(const emm_reg_t* evt)
int EmmDeregisteredLimitedService(const emm_reg_t *evt)
{
LOG_FUNC_IN;
......@@ -74,8 +74,7 @@ int EmmDeregisteredLimitedService(const emm_reg_t* evt)
assert(emm_fsm_get_status() == EMM_DEREGISTERED_LIMITED_SERVICE);
switch (evt->primitive)
{
switch (evt->primitive) {
case _EMMREG_REGISTER_REQ:
/*
* The user manually re-selected a PLMN to register to
......
......@@ -67,7 +67,7 @@ Description Implements the EPS Mobility Management procedures executed
** Others: emm_fsm_status **
** **
***************************************************************************/
int EmmDeregisteredNoCellAvailable(const emm_reg_t* evt)
int EmmDeregisteredNoCellAvailable(const emm_reg_t *evt)
{
LOG_FUNC_IN;
......@@ -75,8 +75,7 @@ int EmmDeregisteredNoCellAvailable(const emm_reg_t* evt)
assert(emm_fsm_get_status() == EMM_DEREGISTERED_NO_CELL_AVAILABLE);
switch (evt->primitive)
{
switch (evt->primitive) {
/* TODO: network re-selection is not allowed when in No Cell
* Available substate. The AS should search for a suitable cell
* and notify the NAS when such a cell is found (TS 24.008 section
......
......@@ -61,7 +61,7 @@ Description Implements the EPS Mobility Management procedures executed
** Others: emm_fsm_status **
** **
***************************************************************************/
int EmmDeregisteredNoImsi(const emm_reg_t* evt)
int EmmDeregisteredNoImsi(const emm_reg_t *evt)
{
LOG_FUNC_IN;
......
......@@ -66,7 +66,7 @@ Description Implements the EPS Mobility Management procedures executed
** Others: emm_fsm_status **
** **
***************************************************************************/
int EmmDeregisteredNormalService(const emm_reg_t* evt)
int EmmDeregisteredNormalService(const emm_reg_t *evt)
{
LOG_FUNC_IN;
......@@ -74,8 +74,7 @@ int EmmDeregisteredNormalService(const emm_reg_t* evt)
assert(emm_fsm_get_status() == EMM_DEREGISTERED_NORMAL_SERVICE);
switch (evt->primitive)
{
switch (evt->primitive) {
case _EMMREG_REGISTER_REQ:
/*
* The user manually re-selected a PLMN to register to
......
......@@ -65,7 +65,7 @@ Description Implements the EPS Mobility Management procedures executed
** Others: emm_fsm_status **
** **
***************************************************************************/
int EmmDeregisteredPlmnSearch(const emm_reg_t* evt)
int EmmDeregisteredPlmnSearch(const emm_reg_t *evt)
{
LOG_FUNC_IN;
......@@ -73,8 +73,7 @@ int EmmDeregisteredPlmnSearch(const emm_reg_t* evt)
assert(emm_fsm_get_status() == EMM_DEREGISTERED_PLMN_SEARCH);
switch (evt->primitive)
{
switch (evt->primitive) {
case _EMMREG_NO_CELL:
/*
* No suitable cell of the selected PLMN has been found to camp on
......
......@@ -59,7 +59,7 @@ Description Implements the EPS Mobility Management procedures executed
** Others: emm_fsm_status **
** **
***************************************************************************/
int EmmNull(const emm_reg_t* evt)
int EmmNull(const emm_reg_t *evt)
{
LOG_FUNC_IN;
......@@ -73,8 +73,7 @@ int EmmNull(const emm_reg_t* evt)
LOG_FUNC_RETURN (rc);
}
switch (evt->primitive)
{
switch (evt->primitive) {
case _EMMREG_S1_ENABLED:
/*
* The EPS capability has been enabled in the UE:
......
......@@ -63,7 +63,7 @@ Description Implements the EPS Mobility Management procedures executed
** Others: emm_fsm_status **
** **
***************************************************************************/
int EmmRegistered(const emm_reg_t* evt)
int EmmRegistered(const emm_reg_t *evt)
{
LOG_FUNC_IN;
......@@ -76,8 +76,7 @@ int EmmRegistered(const emm_reg_t* evt)
assert(emm_fsm_get_status(evt->ueid, evt->ctx) == EMM_REGISTERED);
#endif
switch (evt->primitive)
{
switch (evt->primitive) {
#ifdef NAS_UE
case _EMMREG_DETACH_INIT:
/*
......
......@@ -62,7 +62,7 @@ Description Implements the EPS Mobility Management procedures executed
** Others: emm_fsm_status **
** **
***************************************************************************/
int EmmRegisteredAttemptingToUpdate(const emm_reg_t* evt)
int EmmRegisteredAttemptingToUpdate(const emm_reg_t *evt)
{
LOG_FUNC_IN;
......
......@@ -61,7 +61,7 @@ Description Implements the EPS Mobility Management procedures executed
** Others: emm_fsm_status **
** **
***************************************************************************/
int EmmRegisteredImsiDetachInitiated(const emm_reg_t* evt)
int EmmRegisteredImsiDetachInitiated(const emm_reg_t *evt)
{
LOG_FUNC_IN;
......
......@@ -61,7 +61,7 @@ Description Implements the EPS Mobility Management procedures executed
** Others: emm_fsm_status **
** **
***************************************************************************/
int EmmRegisteredInitiated(const emm_reg_t* evt)
int EmmRegisteredInitiated(const emm_reg_t *evt)
{
LOG_FUNC_IN;
......@@ -69,8 +69,7 @@ int EmmRegisteredInitiated(const emm_reg_t* evt)
assert(emm_fsm_get_status() == EMM_REGISTERED_INITIATED);
switch (evt->primitive)
{
switch (evt->primitive) {
case _EMMREG_ATTACH_INIT:
/*
* Attach procedure has to be restarted (timers T3402 or T3411
......
......@@ -57,7 +57,7 @@ Description Implements the EPS Mobility Management procedures executed
** Others: emm_fsm_status **
** **
***************************************************************************/
int EmmRegisteredLimitedService(const emm_reg_t* evt)
int EmmRegisteredLimitedService(const emm_reg_t *evt)
{
LOG_FUNC_IN;
......
......@@ -58,7 +58,7 @@ Description Implements the EPS Mobility Management procedures executed
** Others: emm_fsm_status **
** **
***************************************************************************/
int EmmRegisteredNoCellAvailable(const emm_reg_t* evt)
int EmmRegisteredNoCellAvailable(const emm_reg_t *evt)
{
LOG_FUNC_IN;
......
......@@ -57,7 +57,7 @@ Description Implements the EPS Mobility Management procedures executed
** Others: emm_fsm_status **
** **
***************************************************************************/
int EmmRegisteredNormalService(const emm_reg_t* evt)
int EmmRegisteredNormalService(const emm_reg_t *evt)
{
LOG_FUNC_IN;
......
......@@ -57,7 +57,7 @@ Description Implements the EPS Mobility Management procedures executed
** Others: emm_fsm_status **
** **
***************************************************************************/
int EmmRegisteredPlmnSearch(const emm_reg_t* evt)
int EmmRegisteredPlmnSearch(const emm_reg_t *evt)
{
LOG_FUNC_IN;
......@@ -84,7 +84,7 @@ int EmmRegisteredPlmnSearch(const emm_reg_t* evt)
** Others: emm_fsm_status **
** **
***************************************************************************/
int EmmRegisteredPlmnSearch_xxx(const emm_reg_t* evt)
int EmmRegisteredPlmnSearch_xxx(const emm_reg_t *evt)
{
LOG_FUNC_IN;
......
......@@ -63,7 +63,7 @@ Description Implements the EPS Mobility Management procedures executed
** Others: emm_fsm_status **
** **
***************************************************************************/
int EmmRegisteredUpdateNeeded(const emm_reg_t* evt)
int EmmRegisteredUpdateNeeded(const emm_reg_t *evt)
{
LOG_FUNC_IN;
......
......@@ -59,7 +59,7 @@ Description Implements the EPS Mobility Management procedures executed
** Others: emm_fsm_status **
** **
***************************************************************************/
int EmmServiceRequestInitiated(const emm_reg_t* evt)
int EmmServiceRequestInitiated(const emm_reg_t *evt)
{
LOG_FUNC_IN;
......
......@@ -59,7 +59,7 @@ Description Implements the EPS Mobility Management procedures executed
** Others: emm_fsm_status **
** **
***************************************************************************/
int EmmTrackingAreaUpdatingInitiated(const emm_reg_t* evt)
int EmmTrackingAreaUpdatingInitiated(const emm_reg_t *evt)
{
LOG_FUNC_IN;
......
......@@ -36,8 +36,8 @@ Description Defines the EMMAS Service Access Point that provides
#include <string.h> // memset
#include <stdlib.h> // malloc, free
#if defined(EPC_BUILD)
# include "intertask_interface.h"
#if defined(EPC_BUILD) && defined(NAS_MME)
# include "nas_itti_messaging.h"
#endif
/****************************************************************************/
......@@ -57,7 +57,7 @@ extern int emm_proc_status(unsigned int ueid, int emm_cause);
/*
* String representation of EMMAS-SAP primitives
*/
static const char* _emm_as_primitive_str[] = {
static const char *_emm_as_primitive_str[] = {
"EMMAS_SECURITY_REQ",
"EMMAS_SECURITY_IND",
"EMMAS_SECURITY_RES",
......@@ -80,51 +80,60 @@ static const char* _emm_as_primitive_str[] = {
* Functions executed to process EMM procedures upon receiving
* data from the network
*/
static int _emm_as_recv(unsigned int ueid, const char* msg, int len, int *emm_cause);
static int _emm_as_recv(unsigned int ueid, const char *msg, int len,
int *emm_cause);
#ifdef NAS_UE
static int _emm_as_establish_cnf(const emm_as_establish_t* msg, int *emm_cause);
static int _emm_as_establish_cnf(const emm_as_establish_t *msg, int *emm_cause);
static int _emm_as_establish_rej(void);
static int _emm_as_release_ind(const emm_as_release_t* msg);
static int _emm_as_page_ind(const emm_as_page_t* msg);
static int _emm_as_release_ind(const emm_as_release_t *msg);
static int _emm_as_page_ind(const emm_as_page_t *msg);
#endif
#ifdef NAS_MME
static int _emm_as_establish_req(const emm_as_establish_t* msg, int *emm_cause);
static int _emm_as_establish_req(const emm_as_establish_t *msg, int *emm_cause);
#endif
static int _emm_as_cell_info_res(const emm_as_cell_info_t* msg);
static int _emm_as_cell_info_ind(const emm_as_cell_info_t* msg);
static int _emm_as_cell_info_res(const emm_as_cell_info_t *msg);
static int _emm_as_cell_info_ind(const emm_as_cell_info_t *msg);
static int _emm_as_data_ind(const emm_as_data_t* msg, int *emm_cause);
static int _emm_as_data_ind(const emm_as_data_t *msg, int *emm_cause);
/*
* Functions executed to send data to the network when requested
* within EMM procedure processing
*/
static EMM_msg* _emm_as_set_header(nas_message_t* msg, const emm_as_security_data_t* security);
static int _emm_as_encode(as_nas_info_t* info, nas_message_t* msg, int length);
static int _emm_as_encrypt(as_nas_info_t* info, const nas_message_security_header_t* header, const char* buffer, int length);
static int _emm_as_send(const emm_as_t* msg);
static EMM_msg *_emm_as_set_header(nas_message_t *msg,
const emm_as_security_data_t *security);
static int _emm_as_encode(as_nas_info_t *info, nas_message_t *msg, int length);
static int _emm_as_encrypt(as_nas_info_t *info,
const nas_message_security_header_t *header, const char *buffer, int length);
static int _emm_as_send(const emm_as_t *msg);
#ifdef NAS_UE
static int _emm_as_security_res(const emm_as_security_t*, ul_info_transfer_req_t*);
static int _emm_as_establish_req(const emm_as_establish_t*, nas_establish_req_t*);
static int _emm_as_security_res(const emm_as_security_t *,
ul_info_transfer_req_t *);
static int _emm_as_establish_req(const emm_as_establish_t *,
nas_establish_req_t *);
#endif
#ifdef NAS_MME
static int _emm_as_security_req(const emm_as_security_t*, dl_info_transfer_req_t*);
static int _emm_as_security_rej(const emm_as_security_t*, dl_info_transfer_req_t*);
static int _emm_as_establish_cnf(const emm_as_establish_t*, nas_establish_rsp_t*);
static int _emm_as_establish_rej(const emm_as_establish_t*, nas_establish_rsp_t*);
static int _emm_as_page_ind(const emm_as_page_t*, paging_req_t*);
static int _emm_as_security_req(const emm_as_security_t *,
dl_info_transfer_req_t *);
static int _emm_as_security_rej(const emm_as_security_t *,
dl_info_transfer_req_t *);
static int _emm_as_establish_cnf(const emm_as_establish_t *,
nas_establish_rsp_t *);
static int _emm_as_establish_rej(const emm_as_establish_t *,
nas_establish_rsp_t *);
static int _emm_as_page_ind(const emm_as_page_t *, paging_req_t *);
#endif
static int _emm_as_cell_info_req(const emm_as_cell_info_t*, cell_info_req_t*);
static int _emm_as_cell_info_req(const emm_as_cell_info_t *, cell_info_req_t *);
static int _emm_as_data_req(const emm_as_data_t*, ul_info_transfer_req_t*);
static int _emm_as_status_ind(const emm_as_status_t*, ul_info_transfer_req_t*);
static int _emm_as_release_req(const emm_as_release_t*, nas_release_req_t*);
static int _emm_as_data_req(const emm_as_data_t *, ul_info_transfer_req_t *);
static int _emm_as_status_ind(const emm_as_status_t *, ul_info_transfer_req_t *);
static int _emm_as_release_req(const emm_as_release_t *, nas_release_req_t *);
/****************************************************************************/
/****************** E X P O R T E D F U N C T I O N S ******************/
......@@ -167,7 +176,7 @@ void emm_as_initialize(void)
** Others: None **
** **
***************************************************************************/
int emm_as_send(const emm_as_t* msg)
int emm_as_send(const emm_as_t *msg)
{
LOG_FUNC_IN;
......@@ -180,8 +189,7 @@ int emm_as_send(const emm_as_t* msg)
LOG_TRACE(INFO, "EMMAS-SAP - Received primitive %s (%d)",
_emm_as_primitive_str[primitive - _EMMAS_START - 1], primitive);
switch (primitive)
{
switch (primitive) {
case _EMMAS_DATA_IND:
rc = _emm_as_data_ind(&msg->u.data, &emm_cause);
ueid = msg->u.data.ueid;
......@@ -242,8 +250,7 @@ int emm_as_send(const emm_as_t* msg)
* discriminator */
else if (rc == TLV_DECODE_PROTOCOL_NOT_SUPPORTED) {
LOG_FUNC_RETURN (RETURNok);
}
else if (rc == TLV_DECODE_WRONG_MESSAGE_TYPE) {
} else if (rc == TLV_DECODE_WRONG_MESSAGE_TYPE) {
emm_cause = EMM_CAUSE_MESSAGE_TYPE_NOT_IMPLEMENTED;
}
/* EMM message processing failed */
......@@ -290,7 +297,7 @@ int emm_as_send(const emm_as_t* msg)
** Others: None **
** **
***************************************************************************/
static int _emm_as_recv(unsigned int ueid, const char* msg, int len,
static int _emm_as_recv(unsigned int ueid, const char *msg, int len,
int *emm_cause)
{
LOG_FUNC_IN;
......@@ -314,9 +321,8 @@ static int _emm_as_recv(unsigned int ueid, const char* msg, int len,
}
/* Process NAS message */
EMM_msg* emm_msg = &nas_msg.plain.emm;
switch (emm_msg->header.message_type)
{
EMM_msg *emm_msg = &nas_msg.plain.emm;
switch (emm_msg->header.message_type) {
case EMM_STATUS:
rc = emm_recv_status(ueid, &emm_msg->emm_status, emm_cause);
break;
......@@ -436,7 +442,7 @@ static int _emm_as_recv(unsigned int ueid, const char* msg, int len,
** Others: None **
** **
***************************************************************************/
static int _emm_as_data_ind(const emm_as_data_t* msg, int *emm_cause)
static int _emm_as_data_ind(const emm_as_data_t *msg, int *emm_cause)
{
LOG_FUNC_IN;
......@@ -447,42 +453,36 @@ static int _emm_as_data_ind(const emm_as_data_t* msg, int *emm_cause)
(msg->delivered)? "TRUE" : "FALSE", msg->NASmsg.length);
if (msg->delivered) {
if (msg->NASmsg.length > 0)
{
if (msg->NASmsg.length > 0) {
/* Process the received NAS message */
char* plain_msg = (char*)malloc(msg->NASmsg.length);
if (plain_msg)
{
char *plain_msg = (char *)malloc(msg->NASmsg.length);
if (plain_msg) {
nas_message_security_header_t header;
/* Decrypt the received security protected message */
int bytes = nas_message_decrypt((char*)(msg->NASmsg.value),
int bytes = nas_message_decrypt((char *)(msg->NASmsg.value),
plain_msg, &header,
msg->NASmsg.length);
if (bytes < 0) {
/* Failed to decrypt the message */
*emm_cause = EMM_CAUSE_PROTOCOL_ERROR;
LOG_FUNC_RETURN (bytes);
}
else if (header.protocol_discriminator ==
} else if (header.protocol_discriminator ==
EPS_MOBILITY_MANAGEMENT_MESSAGE) {
/* Process EMM data */
rc = _emm_as_recv(msg->ueid, plain_msg, bytes, emm_cause);
}
else if (header.protocol_discriminator ==
} else if (header.protocol_discriminator ==
EPS_SESSION_MANAGEMENT_MESSAGE) {
const OctetString data = {bytes, (uint8_t*)plain_msg};
const OctetString data = {bytes, (uint8_t *)plain_msg};
/* Foward ESM data to EPS session management */
rc = lowerlayer_data_ind(msg->ueid, &data);
}
free(plain_msg);
}
}
else {
} else {
/* Process successfull lower layer transfer indication */
rc = lowerlayer_success(msg->ueid);
}
}
else {
} else {
/* Process lower layer transmission failure of NAS message */
rc = lowerlayer_failure(msg->ueid);
}
......@@ -508,7 +508,7 @@ static int _emm_as_data_ind(const emm_as_data_t* msg, int *emm_cause)
** Others: None **
** **
***************************************************************************/
static int _emm_as_establish_cnf(const emm_as_establish_t* msg,
static int _emm_as_establish_cnf(const emm_as_establish_t *msg,
int *emm_cause)
{
LOG_FUNC_IN;
......@@ -532,7 +532,7 @@ static int _emm_as_establish_cnf(const emm_as_establish_t* msg,
memset(&nas_msg, 0 , sizeof(nas_message_t));
/* Decode initial NAS message */
decoder_rc = nas_message_decode((char*)(msg->NASmsg.value), &nas_msg,
decoder_rc = nas_message_decode((char *)(msg->NASmsg.value), &nas_msg,
msg->NASmsg.length);
if (decoder_rc < 0) {
LOG_TRACE(WARNING, "EMMAS-SAP - Failed to decode initial NAS message"
......@@ -542,9 +542,8 @@ static int _emm_as_establish_cnf(const emm_as_establish_t* msg,
}
/* Process initial NAS message */
EMM_msg* emm_msg = &nas_msg.plain.emm;
switch (emm_msg->header.message_type)
{
EMM_msg *emm_msg = &nas_msg.plain.emm;
switch (emm_msg->header.message_type) {
case ATTACH_ACCEPT:
rc = emm_recv_attach_accept(&emm_msg->attach_accept, emm_cause);
break;
......@@ -618,7 +617,7 @@ static int _emm_as_establish_rej(void)
** Others: None **
** **
***************************************************************************/
static int _emm_as_release_ind(const emm_as_release_t* msg)
static int _emm_as_release_ind(const emm_as_release_t *msg)
{
LOG_FUNC_IN;
......@@ -649,7 +648,7 @@ static int _emm_as_release_ind(const emm_as_release_t* msg)
** Others: None **
** **
***************************************************************************/
static int _emm_as_page_ind(const emm_as_page_t* msg)
static int _emm_as_page_ind(const emm_as_page_t *msg)
{
LOG_FUNC_IN;
......@@ -685,7 +684,7 @@ static int _emm_as_page_ind(const emm_as_page_t* msg)
** Others: None **
** **
***************************************************************************/
static int _emm_as_establish_req(const emm_as_establish_t* msg, int *emm_cause)
static int _emm_as_establish_req(const emm_as_establish_t *msg, int *emm_cause)
{
LOG_FUNC_IN;
......@@ -698,7 +697,7 @@ static int _emm_as_establish_req(const emm_as_establish_t* msg, int *emm_cause)
memset(&nas_msg, 0 , sizeof(nas_message_t));
/* Decode initial NAS message */
decoder_rc = nas_message_decode((char*)(msg->NASmsg.value), &nas_msg,
decoder_rc = nas_message_decode((char *)(msg->NASmsg.value), &nas_msg,
msg->NASmsg.length);
if (decoder_rc < TLV_DECODE_FATAL_ERROR) {
......@@ -711,9 +710,8 @@ static int _emm_as_establish_req(const emm_as_establish_t* msg, int *emm_cause)
}
/* Process initial NAS message */
EMM_msg* emm_msg = &nas_msg.plain.emm;
switch (emm_msg->header.message_type)
{
EMM_msg *emm_msg = &nas_msg.plain.emm;
switch (emm_msg->header.message_type) {
case ATTACH_REQUEST:
rc = emm_recv_attach_request(msg->ueid, &emm_msg->attach_request,
emm_cause);
......@@ -767,7 +765,7 @@ static int _emm_as_establish_req(const emm_as_establish_t* msg, int *emm_cause)
** Others: None **
** **
***************************************************************************/
static int _emm_as_cell_info_res(const emm_as_cell_info_t* msg)
static int _emm_as_cell_info_res(const emm_as_cell_info_t *msg)
{
LOG_FUNC_IN;
......@@ -810,7 +808,7 @@ static int _emm_as_cell_info_res(const emm_as_cell_info_t* msg)
** Others: None **
** **
***************************************************************************/
static int _emm_as_cell_info_ind(const emm_as_cell_info_t* msg)
static int _emm_as_cell_info_ind(const emm_as_cell_info_t *msg)
{
LOG_FUNC_IN;
......@@ -847,8 +845,8 @@ static int _emm_as_cell_info_ind(const emm_as_cell_info_t* msg)
** Others: None **
** **
***************************************************************************/
static EMM_msg* _emm_as_set_header(nas_message_t* msg,
const emm_as_security_data_t* security)
static EMM_msg *_emm_as_set_header(nas_message_t *msg,
const emm_as_security_data_t *security)
{
LOG_FUNC_IN;
......@@ -870,8 +868,7 @@ static EMM_msg* _emm_as_set_header(nas_message_t* msg,
}
LOG_FUNC_RETURN (&msg->protected.plain.emm);
}
}
else if (security->k_int) {
} else if (security->k_int) {
if (security->k_enc) {
/* NAS integrity and cyphering keys are available */
msg->header.security_header_type =
......@@ -883,8 +880,7 @@ static EMM_msg* _emm_as_set_header(nas_message_t* msg,
}
LOG_FUNC_RETURN (&msg->protected.plain.emm);
}
}
else {
} else {
/* No valid EPS security context exists */
msg->header.security_header_type = SECURITY_HEADER_TYPE_NOT_PROTECTED;
LOG_FUNC_RETURN (&msg->plain.emm);
......@@ -911,15 +907,14 @@ static EMM_msg* _emm_as_set_header(nas_message_t* msg,
** Others: None **
** **
***************************************************************************/
static int _emm_as_encode(as_nas_info_t* info, nas_message_t* msg, int length)
static int _emm_as_encode(as_nas_info_t *info, nas_message_t *msg, int length)
{
LOG_FUNC_IN;
int bytes = 0;
if (msg->header.security_header_type != SECURITY_HEADER_TYPE_NOT_PROTECTED)
{
emm_msg_header_t* header = &msg->protected.plain.emm.header;
if (msg->header.security_header_type != SECURITY_HEADER_TYPE_NOT_PROTECTED) {
emm_msg_header_t *header = &msg->protected.plain.emm.header;
/* Expand size of protected NAS message */
length += NAS_MESSAGE_SECURITY_HEADER_SIZE;
/* Set header of plain NAS message */
......@@ -927,10 +922,10 @@ static int _emm_as_encode(as_nas_info_t* info, nas_message_t* msg, int length)
header->security_header_type = SECURITY_HEADER_TYPE_NOT_PROTECTED;
}
/* Allocate memory to the NAS information container */
info->data = (Byte_t*)malloc(length * sizeof(Byte_t));
info->data = (Byte_t *)malloc(length * sizeof(Byte_t));
if (info->data != NULL) {
/* Encode the NAS message */
bytes = nas_message_encode((char*)(info->data), msg, length);
bytes = nas_message_encode((char *)(info->data), msg, length);
if (bytes > 0) {
info->length = bytes;
} else {
......@@ -959,9 +954,9 @@ static int _emm_as_encode(as_nas_info_t* info, nas_message_t* msg, int length)
** Others: None **
** **
***************************************************************************/
static int _emm_as_encrypt(as_nas_info_t* info,
const nas_message_security_header_t* header,
const char* msg, int length)
static int _emm_as_encrypt(as_nas_info_t *info,
const nas_message_security_header_t *header,
const char *msg, int length)
{
LOG_FUNC_IN;
......@@ -972,10 +967,10 @@ static int _emm_as_encrypt(as_nas_info_t* info,
length += NAS_MESSAGE_SECURITY_HEADER_SIZE;
}
/* Allocate memory to the NAS information container */
info->data = (Byte_t*)malloc(length * sizeof(Byte_t));
info->data = (Byte_t *)malloc(length * sizeof(Byte_t));
if (info->data != NULL) {
/* Encrypt the NAS information message */
bytes = nas_message_encrypt(msg, (char*)(info->data), header, length);
bytes = nas_message_encrypt(msg, (char *)(info->data), header, length);
if (bytes > 0) {
info->length = bytes;
} else {
......@@ -1004,15 +999,14 @@ static int _emm_as_encrypt(as_nas_info_t* info,
** Others: None **
** **
***************************************************************************/
static int _emm_as_send(const emm_as_t* msg)
static int _emm_as_send(const emm_as_t *msg)
{
LOG_FUNC_IN;
as_message_t as_msg;
memset(&as_msg, 0 , sizeof(as_message_t));
switch (msg->primitive)
{
switch (msg->primitive) {
case _EMMAS_DATA_REQ:
as_msg.msgID = _emm_as_data_req(&msg->u.data,
&as_msg.msg.ul_info_transfer_req);
......@@ -1084,24 +1078,19 @@ static int _emm_as_send(const emm_as_t* msg)
/* Send the message to the Access Stratum or S1AP in case of MME */
if (as_msg.msgID > 0) {
#if defined(EPC_BUILD) && defined(NAS_MME)
MessageDef *message_p = NULL;
switch (as_msg.msgID) {
case AS_DL_INFO_TRANSFER_REQ: {
int ret;
message_p = itti_alloc_new_message(TASK_NAS, NAS_DOWNLINK_DATA_IND);
memcpy(&message_p->ittiMsg.nas_dl_data_ind,
&as_msg.msg.dl_info_transfer_req,
sizeof(nas_dl_data_ind_t));
ret = itti_send_msg_to_task(TASK_S1AP, 0, message_p);
ret = nas_itti_dl_data_req(as_msg.msg.dl_info_transfer_req.UEid,
as_msg.msg.dl_info_transfer_req.nasMsg.data,
as_msg.msg.dl_info_transfer_req.nasMsg.length);
if (ret != -1) {
LOG_FUNC_RETURN (RETURNok);
}
} break;
}
break;
default:
break;
}
......@@ -1132,8 +1121,8 @@ static int _emm_as_send(const emm_as_t* msg)
** Others: None **
** **
***************************************************************************/
static int _emm_as_data_req(const emm_as_data_t* msg,
ul_info_transfer_req_t* as_msg)
static int _emm_as_data_req(const emm_as_data_t *msg,
ul_info_transfer_req_t *as_msg)
{
LOG_FUNC_IN;
......@@ -1149,17 +1138,15 @@ static int _emm_as_data_req(const emm_as_data_t* msg,
if (msg->guti) {
as_msg->s_tmsi.MMEcode = msg->guti->gummei.MMEcode;
as_msg->s_tmsi.m_tmsi = msg->guti->m_tmsi;
}
else {
} else {
as_msg->UEid = msg->ueid;
}
/* Setup the NAS security header */
EMM_msg* emm_msg = _emm_as_set_header(&nas_msg, &msg->sctx);
EMM_msg *emm_msg = _emm_as_set_header(&nas_msg, &msg->sctx);
/* Setup the NAS information message */
if (emm_msg != NULL) switch (msg->NASinfo)
{
if (emm_msg != NULL) switch (msg->NASinfo) {
#ifdef NAS_UE
case EMM_AS_NAS_DATA_ATTACH:
size = emm_send_attach_complete(msg, &emm_msg->attach_complete);
......@@ -1191,7 +1178,7 @@ static int _emm_as_data_req(const emm_as_data_t* msg,
} else {
/* Encrypt the NAS information message */
bytes = _emm_as_encrypt(&as_msg->nasMsg, &nas_msg.header,
(char*)(msg->NASmsg.value), size);
(char *)(msg->NASmsg.value), size);
}
if (bytes > 0) {
#ifdef NAS_UE
......@@ -1221,8 +1208,8 @@ static int _emm_as_data_req(const emm_as_data_t* msg,
** Others: None **
** **
***************************************************************************/
static int _emm_as_status_ind(const emm_as_status_t* msg,
ul_info_transfer_req_t* as_msg)
static int _emm_as_status_ind(const emm_as_status_t *msg,
ul_info_transfer_req_t *as_msg)
{
LOG_FUNC_IN;
......@@ -1238,13 +1225,12 @@ static int _emm_as_status_ind(const emm_as_status_t* msg,
if (msg->guti) {
as_msg->s_tmsi.MMEcode = msg->guti->gummei.MMEcode;
as_msg->s_tmsi.m_tmsi = msg->guti->m_tmsi;
}
else {
} else {
as_msg->UEid = msg->ueid;
}
/* Setup the NAS security header */
EMM_msg* emm_msg = _emm_as_set_header(&nas_msg, &msg->sctx);
EMM_msg *emm_msg = _emm_as_set_header(&nas_msg, &msg->sctx);
/* Setup the NAS information message */
if (emm_msg != NULL) {
......@@ -1283,8 +1269,8 @@ static int _emm_as_status_ind(const emm_as_status_t* msg,
** Others: None **
** **
***************************************************************************/
static int _emm_as_release_req(const emm_as_release_t* msg,
nas_release_req_t* as_msg)
static int _emm_as_release_req(const emm_as_release_t *msg,
nas_release_req_t *as_msg)
{
LOG_FUNC_IN;
......@@ -1294,8 +1280,7 @@ static int _emm_as_release_req(const emm_as_release_t* msg,
if (msg->guti) {
as_msg->s_tmsi.MMEcode = msg->guti->gummei.MMEcode;
as_msg->s_tmsi.m_tmsi = msg->guti->m_tmsi;
}
else {
} else {
as_msg->UEid = msg->ueid;
}
......@@ -1325,8 +1310,8 @@ static int _emm_as_release_req(const emm_as_release_t* msg,
** Others: None **
** **
***************************************************************************/
static int _emm_as_security_res(const emm_as_security_t* msg,
ul_info_transfer_req_t* as_msg)
static int _emm_as_security_res(const emm_as_security_t *msg,
ul_info_transfer_req_t *as_msg)
{
LOG_FUNC_IN;
......@@ -1344,11 +1329,10 @@ static int _emm_as_security_res(const emm_as_security_t* msg,
}
/* Setup the NAS security header */
EMM_msg* emm_msg = _emm_as_set_header(&nas_msg, &msg->sctx);
EMM_msg *emm_msg = _emm_as_set_header(&nas_msg, &msg->sctx);
/* Setup the NAS security message */
if (emm_msg != NULL) switch (msg->msgType)
{
if (emm_msg != NULL) switch (msg->msgType) {
case EMM_AS_MSG_TYPE_IDENT:
size = emm_send_identity_response(msg, &emm_msg->identity_response);
break;
......@@ -1407,8 +1391,8 @@ static int _emm_as_security_res(const emm_as_security_t* msg,
** Others: None **
** **
***************************************************************************/
static int _emm_as_establish_req(const emm_as_establish_t* msg,
nas_establish_req_t* as_msg)
static int _emm_as_establish_req(const emm_as_establish_t *msg,
nas_establish_req_t *as_msg)
{
LOG_FUNC_IN;
......@@ -1430,11 +1414,10 @@ static int _emm_as_establish_req(const emm_as_establish_t* msg,
}
/* Setup the NAS security header */
EMM_msg* emm_msg = _emm_as_set_header(&nas_msg, &msg->sctx);
EMM_msg *emm_msg = _emm_as_set_header(&nas_msg, &msg->sctx);
/* Setup the initial NAS information message */
if (emm_msg != NULL) switch (msg->NASinfo)
{
if (emm_msg != NULL) switch (msg->NASinfo) {
case EMM_AS_NAS_INFO_ATTACH:
size = emm_send_attach_request(msg, &emm_msg->attach_request);
break;
......@@ -1492,8 +1475,8 @@ static int _emm_as_establish_req(const emm_as_establish_t* msg,
** Others: None **
** **
***************************************************************************/
static int _emm_as_security_req(const emm_as_security_t* msg,
dl_info_transfer_req_t* as_msg)
static int _emm_as_security_req(const emm_as_security_t *msg,
dl_info_transfer_req_t *as_msg)
{
LOG_FUNC_IN;
......@@ -1508,17 +1491,15 @@ static int _emm_as_security_req(const emm_as_security_t* msg,
if (msg->guti) {
as_msg->s_tmsi.MMEcode = msg->guti->gummei.MMEcode;
as_msg->s_tmsi.m_tmsi = msg->guti->m_tmsi;
}
else {
} else {
as_msg->UEid = msg->ueid;
}
/* Setup the NAS security header */
EMM_msg* emm_msg = _emm_as_set_header(&nas_msg, &msg->sctx);
EMM_msg *emm_msg = _emm_as_set_header(&nas_msg, &msg->sctx);
/* Setup the NAS security message */
if (emm_msg != NULL) switch (msg->msgType)
{
if (emm_msg != NULL) switch (msg->msgType) {
case EMM_AS_MSG_TYPE_IDENT:
size = emm_send_identity_request(msg, &emm_msg->identity_request);
break;
......@@ -1564,8 +1545,8 @@ static int _emm_as_security_req(const emm_as_security_t* msg,
** Others: None **
** **
***************************************************************************/
static int _emm_as_security_rej(const emm_as_security_t* msg,
dl_info_transfer_req_t* as_msg)
static int _emm_as_security_rej(const emm_as_security_t *msg,
dl_info_transfer_req_t *as_msg)
{
LOG_FUNC_IN;
......@@ -1580,17 +1561,15 @@ static int _emm_as_security_rej(const emm_as_security_t* msg,
if (msg->guti) {
as_msg->s_tmsi.MMEcode = msg->guti->gummei.MMEcode;
as_msg->s_tmsi.m_tmsi = msg->guti->m_tmsi;
}
else {
} else {
as_msg->UEid = msg->ueid;
}
/* Setup the NAS security header */
EMM_msg* emm_msg = _emm_as_set_header(&nas_msg, &msg->sctx);
EMM_msg *emm_msg = _emm_as_set_header(&nas_msg, &msg->sctx);
/* Setup the NAS security message */
if (emm_msg != NULL) switch (msg->msgType)
{
if (emm_msg != NULL) switch (msg->msgType) {
case EMM_AS_MSG_TYPE_AUTH:
size = emm_send_authentication_reject(
&emm_msg->authentication_reject);
......@@ -1628,8 +1607,8 @@ static int _emm_as_security_rej(const emm_as_security_t* msg,
** Others: None **
** **
***************************************************************************/
static int _emm_as_establish_cnf(const emm_as_establish_t* msg,
nas_establish_rsp_t* as_msg)
static int _emm_as_establish_cnf(const emm_as_establish_t *msg,
nas_establish_rsp_t *as_msg)
{
LOG_FUNC_IN;
......@@ -1649,11 +1628,10 @@ static int _emm_as_establish_cnf(const emm_as_establish_t* msg,
as_msg->s_tmsi.m_tmsi = msg->UEid.guti->m_tmsi;
/* Setup the NAS security header */
EMM_msg* emm_msg = _emm_as_set_header(&nas_msg, &msg->sctx);
EMM_msg *emm_msg = _emm_as_set_header(&nas_msg, &msg->sctx);
/* Setup the initial NAS information message */
if (emm_msg != NULL) switch (msg->NASinfo)
{
if (emm_msg != NULL) switch (msg->NASinfo) {
case EMM_AS_NAS_INFO_ATTACH:
size = emm_send_attach_accept(msg, &emm_msg->attach_accept);
break;
......@@ -1692,8 +1670,8 @@ static int _emm_as_establish_cnf(const emm_as_establish_t* msg,
** Others: None **
** **
***************************************************************************/
static int _emm_as_establish_rej(const emm_as_establish_t* msg,
nas_establish_rsp_t* as_msg)
static int _emm_as_establish_rej(const emm_as_establish_t *msg,
nas_establish_rsp_t *as_msg)
{
LOG_FUNC_IN;
......@@ -1708,17 +1686,15 @@ static int _emm_as_establish_rej(const emm_as_establish_t* msg,
if (msg->UEid.guti) {
as_msg->s_tmsi.MMEcode = msg->UEid.guti->gummei.MMEcode;
as_msg->s_tmsi.m_tmsi = msg->UEid.guti->m_tmsi;
}
else {
} else {
as_msg->UEid = msg->ueid;
}
/* Setup the NAS security header */
EMM_msg* emm_msg = _emm_as_set_header(&nas_msg, &msg->sctx);
EMM_msg *emm_msg = _emm_as_set_header(&nas_msg, &msg->sctx);
/* Setup the NAS information message */
if (emm_msg != NULL) switch (msg->NASinfo)
{
if (emm_msg != NULL) switch (msg->NASinfo) {
case EMM_AS_NAS_INFO_ATTACH:
size = emm_send_attach_reject(msg, &emm_msg->attach_reject);
break;
......@@ -1756,7 +1732,7 @@ static int _emm_as_establish_rej(const emm_as_establish_t* msg,
** Others: None **
** **
***************************************************************************/
static int _emm_as_page_ind(const emm_as_page_t* msg, paging_req_t* as_msg)
static int _emm_as_page_ind(const emm_as_page_t *msg, paging_req_t *as_msg)
{
LOG_FUNC_IN;
......@@ -1793,8 +1769,8 @@ static int _emm_as_page_ind(const emm_as_page_t* msg, paging_req_t* as_msg)
** Others: None **
** **
***************************************************************************/
static int _emm_as_cell_info_req(const emm_as_cell_info_t* msg,
cell_info_req_t* as_msg)
static int _emm_as_cell_info_req(const emm_as_cell_info_t *msg,
cell_info_req_t *as_msg)
{
LOG_FUNC_IN;
......
......@@ -42,6 +42,6 @@ Description Defines the EMMAS Service Access Point that provides
void emm_as_initialize(void);
int emm_as_send(const emm_as_t* msg);
int emm_as_send(const emm_as_t *msg);
#endif /* __EMM_AS_H__*/
......@@ -60,8 +60,8 @@ typedef struct {
UInt8_t ksi; /* NAS key set identifier */
UInt8_t sqn; /* Sequence number */
UInt32_t count; /* NAS counter */
const OctetString* k_enc; /* NAS cyphering key */
const OctetString* k_int; /* NAS integrity key */
const OctetString *k_enc; /* NAS cyphering key */
const OctetString *k_int; /* NAS integrity key */
} emm_as_security_data_t;
/****************************************************************************/
......@@ -88,10 +88,10 @@ typedef struct {
* Authentication request/response
*/
UInt8_t ksi; /* NAS key set identifier */
const OctetString* rand; /* Random challenge number */
const OctetString* autn; /* Authentication token */
const OctetString* res; /* Authentication response */
const OctetString* auts; /* Synchronisation failure */
const OctetString *rand; /* Random challenge number */
const OctetString *autn; /* Authentication token */
const OctetString *res; /* Authentication response */
const OctetString *auts; /* Synchronisation failure */
/*
* Security Mode Command
*/
......@@ -124,7 +124,7 @@ typedef struct {
UInt8_t type; /* Network attach/detach type */
UInt8_t RRCcause; /* Connection establishment cause */
UInt8_t RRCtype; /* Associated call type */
const plmn_t* plmnID; /* Identifier of the selected PLMN */
const plmn_t *plmnID; /* Identifier of the selected PLMN */
UInt8_t ksi; /* NAS key set identifier */
UInt8_t encryption:4; /* Ciphering algorithm */
UInt8_t integrity:4; /* Integrity protection algorithm */
......@@ -234,7 +234,7 @@ typedef struct {
* Defined in LowerLayer.c
* Setup security data according to the given EPS security context
*/
void emm_as_set_security_data(emm_as_security_data_t* data, const void* context,
void emm_as_set_security_data(emm_as_security_data_t *data, const void *context,
int is_new, int is_ciphered);
#endif /* __EMM_ASDEF_H__*/
......@@ -42,7 +42,7 @@ Description Defines the EMMESM Service Access Point that provides
/*
* String representation of EMMESM-SAP primitives
*/
static const char* _emm_esm_primitive_str[] = {
static const char *_emm_esm_primitive_str[] = {
#ifdef NAS_UE
"EMMESM_ESTABLISH_REQ",
"EMMESM_ESTABLISH_CNF",
......@@ -94,7 +94,7 @@ void emm_esm_initialize(void)
** Others: None **
** **
***************************************************************************/
int emm_esm_send(const emm_esm_t* msg)
int emm_esm_send(const emm_esm_t *msg)
{
LOG_FUNC_IN;
......@@ -104,8 +104,7 @@ int emm_esm_send(const emm_esm_t* msg)
LOG_TRACE(INFO, "EMMESM-SAP - Received primitive %s (%d)",
_emm_esm_primitive_str[primitive - _EMMESM_START - 1], primitive);
switch (primitive)
{
switch (primitive) {
#ifdef NAS_UE
case _EMMESM_ESTABLISH_REQ:
/* ESM requests EMM to initiate an attach procedure before
......@@ -122,8 +121,7 @@ int emm_esm_send(const emm_esm_t* msg)
* only */
rc = emm_proc_attach_set_emergency();
}
}
else {
} else {
/* Consider the UE locally detached from the network */
rc = emm_proc_attach_set_detach();
}
......
......@@ -42,6 +42,6 @@ Description Defines the EMMESM Service Access Point that provides
void emm_esm_initialize(void);
int emm_esm_send(const emm_esm_t* msg);
int emm_esm_send(const emm_esm_t *msg);
#endif /* __EMM_ESM_H__*/
......@@ -52,7 +52,7 @@ Description Defines the EPS Mobility Management procedures executed at
*/
/* String representation of EMM events */
static const char* _emm_fsm_event_str[] = {
static const char *_emm_fsm_event_str[] = {
#ifdef NAS_UE
"S1_ENABLED",
"S1_DISABLED",
......@@ -91,8 +91,7 @@ static const char* _emm_fsm_event_str[] = {
};
/* String representation of EMM status */
static const char* _emm_fsm_status_str[EMM_STATE_MAX] =
{
static const char *_emm_fsm_status_str[EMM_STATE_MAX] = {
#ifdef NAS_UE
"NULL",
#endif
......@@ -131,41 +130,40 @@ static const char* _emm_fsm_status_str[EMM_STATE_MAX] =
*/
/* Type of the EPS Mobility Management state machine handler */
typedef int(*emm_fsm_handler_t)(const emm_reg_t*);
typedef int(*emm_fsm_handler_t)(const emm_reg_t *);
#ifdef NAS_UE
int EmmNull(const emm_reg_t*);
int EmmNull(const emm_reg_t *);
#endif
int EmmDeregistered(const emm_reg_t*);
int EmmRegistered(const emm_reg_t*);
int EmmDeregisteredInitiated(const emm_reg_t*);
int EmmDeregistered(const emm_reg_t *);
int EmmRegistered(const emm_reg_t *);
int EmmDeregisteredInitiated(const emm_reg_t *);
#ifdef NAS_UE
int EmmDeregisteredNormalService(const emm_reg_t*);
int EmmDeregisteredLimitedService(const emm_reg_t*);
int EmmDeregisteredAttemptingToAttach(const emm_reg_t*);
int EmmDeregisteredPlmnSearch(const emm_reg_t*);
int EmmDeregisteredNoImsi(const emm_reg_t*);
int EmmDeregisteredAttachNeeded(const emm_reg_t*);
int EmmDeregisteredNoCellAvailable(const emm_reg_t*);
int EmmRegisteredInitiated(const emm_reg_t*);
int EmmRegisteredNormalService(const emm_reg_t*);
int EmmRegisteredAttemptingToUpdate(const emm_reg_t*);
int EmmRegisteredLimitedService(const emm_reg_t*);
int EmmRegisteredPlmnSearch(const emm_reg_t*);
int EmmRegisteredUpdateNeeded(const emm_reg_t*);
int EmmRegisteredNoCellAvailable(const emm_reg_t*);
int EmmRegisteredAttemptingToUpdate(const emm_reg_t*);
int EmmRegisteredImsiDetachInitiated(const emm_reg_t*);
int EmmTrackingAreaUpdatingInitiated(const emm_reg_t*);
int EmmServiceRequestInitiated(const emm_reg_t*);
int EmmDeregisteredNormalService(const emm_reg_t *);
int EmmDeregisteredLimitedService(const emm_reg_t *);
int EmmDeregisteredAttemptingToAttach(const emm_reg_t *);
int EmmDeregisteredPlmnSearch(const emm_reg_t *);
int EmmDeregisteredNoImsi(const emm_reg_t *);
int EmmDeregisteredAttachNeeded(const emm_reg_t *);
int EmmDeregisteredNoCellAvailable(const emm_reg_t *);
int EmmRegisteredInitiated(const emm_reg_t *);
int EmmRegisteredNormalService(const emm_reg_t *);
int EmmRegisteredAttemptingToUpdate(const emm_reg_t *);
int EmmRegisteredLimitedService(const emm_reg_t *);
int EmmRegisteredPlmnSearch(const emm_reg_t *);
int EmmRegisteredUpdateNeeded(const emm_reg_t *);
int EmmRegisteredNoCellAvailable(const emm_reg_t *);
int EmmRegisteredAttemptingToUpdate(const emm_reg_t *);
int EmmRegisteredImsiDetachInitiated(const emm_reg_t *);
int EmmTrackingAreaUpdatingInitiated(const emm_reg_t *);
int EmmServiceRequestInitiated(const emm_reg_t *);
#endif
#ifdef NAS_MME
int EmmCommonProcedureInitiated(const emm_reg_t*);
int EmmCommonProcedureInitiated(const emm_reg_t *);
#endif
/* EMM state machine handlers */
static const emm_fsm_handler_t _emm_fsm_handlers[EMM_STATE_MAX] =
{
static const emm_fsm_handler_t _emm_fsm_handlers[EMM_STATE_MAX] = {
#ifdef NAS_UE
EmmNull,
#endif
......@@ -272,7 +270,7 @@ int emm_fsm_set_status(
#endif
#if defined(EPC_BUILD)
emm_data_context_t *emm_ctx = (emm_data_context_t*)ctx;
emm_data_context_t *emm_ctx = (emm_data_context_t *)ctx;
DevAssert(emm_ctx != NULL);
......@@ -326,7 +324,7 @@ emm_fsm_state_t emm_fsm_get_status(void)
emm_fsm_state_t emm_fsm_get_status(unsigned int ueid, void *ctx)
{
# if defined(EPC_BUILD)
emm_data_context_t *emm_ctx = (emm_data_context_t*)ctx;
emm_data_context_t *emm_ctx = (emm_data_context_t *)ctx;
if (emm_ctx != NULL) {
return emm_ctx->_emm_fsm_status;
......@@ -354,7 +352,7 @@ emm_fsm_state_t emm_fsm_get_status(unsigned int ueid, void *ctx)
** Others: None **
** **
***************************************************************************/
int emm_fsm_process(const emm_reg_t* evt)
int emm_fsm_process(const emm_reg_t *evt)
{
emm_fsm_state_t status;
......@@ -368,7 +366,7 @@ int emm_fsm_process(const emm_reg_t* evt)
#endif
#ifdef NAS_MME
# if defined(EPC_BUILD)
emm_data_context_t *emm_ctx = (emm_data_context_t*)evt->ctx;
emm_data_context_t *emm_ctx = (emm_data_context_t *)evt->ctx;
DevAssert(emm_ctx != NULL);
......
......@@ -90,6 +90,6 @@ int emm_fsm_set_status(unsigned int ueid, void *ctx, emm_fsm_state_t status);
emm_fsm_state_t emm_fsm_get_status(unsigned int ueid, void *ctx);
#endif
int emm_fsm_process(const emm_reg_t* evt);
int emm_fsm_process(const emm_reg_t *evt);
#endif /* __EMM_FSM_H__*/
......@@ -66,7 +66,7 @@ Description Defines functions executed at the EMMAS Service Access
** Others: None **
** **
***************************************************************************/
int emm_recv_status(unsigned int ueid, emm_status_msg* msg, int* emm_cause)
int emm_recv_status(unsigned int ueid, emm_status_msg *msg, int *emm_cause)
{
LOG_FUNC_IN;
......@@ -107,7 +107,7 @@ int emm_recv_status(unsigned int ueid, emm_status_msg* msg, int* emm_cause)
** Others: None **
** **
***************************************************************************/
int emm_recv_attach_accept(attach_accept_msg* msg, int* emm_cause)
int emm_recv_attach_accept(attach_accept_msg *msg, int *emm_cause)
{
LOG_FUNC_IN;
......@@ -123,13 +123,11 @@ int emm_recv_attach_accept(attach_accept_msg* msg, int* emm_cause)
/* Only list of TACs belonging to one PLMN with consecutive
* TAC values is supported */
*emm_cause = EMM_CAUSE_IE_NOT_IMPLEMENTED;
}
else if (msg->tailist.numberofelements < 1) {
} else if (msg->tailist.numberofelements < 1) {
/* The tracking area identity list shall contain
* at leat one TAI value */
*emm_cause = EMM_CAUSE_INVALID_MANDATORY_INFO;
}
else if ( (msg->presencemask & ATTACH_ACCEPT_GUTI_PRESENT) &&
} else if ( (msg->presencemask & ATTACH_ACCEPT_GUTI_PRESENT) &&
(msg->guti.guti.typeofidentity != EPS_MOBILE_IDENTITY_GUTI) ) {
/* The only supported type of EPS mobile identity is GUTI */
*emm_cause = EMM_CAUSE_IE_NOT_IMPLEMENTED;
......@@ -164,7 +162,7 @@ int emm_recv_attach_accept(attach_accept_msg* msg, int* emm_cause)
tai[i].tac = msg->tailist.tac + i;
}
/* Get the GUTI */
GUTI_t* pguti = NULL;
GUTI_t *pguti = NULL;
GUTI_t guti;
if (msg->presencemask & ATTACH_ACCEPT_GUTI_PRESENT) {
pguti = &guti;
......@@ -213,7 +211,7 @@ int emm_recv_attach_accept(attach_accept_msg* msg, int* emm_cause)
** Others: None **
** **
***************************************************************************/
int emm_recv_attach_reject(attach_reject_msg* msg, int* emm_cause)
int emm_recv_attach_reject(attach_reject_msg *msg, int *emm_cause)
{
LOG_FUNC_IN;
......@@ -266,7 +264,7 @@ int emm_recv_attach_reject(attach_reject_msg* msg, int* emm_cause)
** Others: None **
** **
***************************************************************************/
int emm_recv_detach_accept(detach_accept_msg* msg, int* emm_cause)
int emm_recv_detach_accept(detach_accept_msg *msg, int *emm_cause)
{
LOG_FUNC_IN;
......@@ -297,7 +295,7 @@ int emm_recv_detach_accept(detach_accept_msg* msg, int* emm_cause)
** Others: None **
** **
***************************************************************************/
int emm_recv_identity_request(identity_request_msg* msg, int* emm_cause)
int emm_recv_identity_request(identity_request_msg *msg, int *emm_cause)
{
LOG_FUNC_IN;
......@@ -343,8 +341,8 @@ int emm_recv_identity_request(identity_request_msg* msg, int* emm_cause)
** Others: None **
** **
***************************************************************************/
int emm_recv_authentication_request(authentication_request_msg* msg,
int* emm_cause)
int emm_recv_authentication_request(authentication_request_msg *msg,
int *emm_cause)
{
LOG_FUNC_IN;
......@@ -391,8 +389,8 @@ int emm_recv_authentication_request(authentication_request_msg* msg,
** Others: None **
** **
***************************************************************************/
int emm_recv_authentication_reject(authentication_reject_msg* msg,
int* emm_cause)
int emm_recv_authentication_reject(authentication_reject_msg *msg,
int *emm_cause)
{
LOG_FUNC_IN;
......@@ -423,8 +421,8 @@ int emm_recv_authentication_reject(authentication_reject_msg* msg,
** Others: None **
** **
***************************************************************************/
int emm_recv_security_mode_command(security_mode_command_msg* msg,
int* emm_cause)
int emm_recv_security_mode_command(security_mode_command_msg *msg,
int *emm_cause)
{
LOG_FUNC_IN;
......@@ -470,8 +468,8 @@ int emm_recv_security_mode_command(security_mode_command_msg* msg,
** Others: None **
** **
***************************************************************************/
int emm_recv_attach_request(unsigned int ueid, const attach_request_msg* msg,
int* emm_cause)
int emm_recv_attach_request(unsigned int ueid, const attach_request_msg *msg,
int *emm_cause)
{
int rc;
emm_proc_attach_type_t type;
......@@ -492,8 +490,7 @@ int emm_recv_attach_request(unsigned int ueid, const attach_request_msg* msg,
*emm_cause = EMM_CAUSE_INVALID_MANDATORY_INFO;
LOG_TRACE(WARNING, "EMMAS-SAP - [%08x] - Received GUTI identity without "
"old GUTI IEI", ueid);
}
else
} else
#endif /* !defined(UPDATE_RELEASE_9) */
if (msg->uenetworkcapability.spare != 0b000) {
/* Spare bits shall be coded as zero */
......@@ -530,8 +527,7 @@ int emm_recv_attach_request(unsigned int ueid, const attach_request_msg* msg,
GUTI_t guti, *p_guti = NULL;
imsi_t imsi, *p_imsi = NULL;
imei_t imei, *p_imei = NULL;
if (msg->oldgutiorimsi.guti.typeofidentity == EPS_MOBILE_IDENTITY_GUTI)
{
if (msg->oldgutiorimsi.guti.typeofidentity == EPS_MOBILE_IDENTITY_GUTI) {
/* Get the GUTI */
p_guti = &guti;
guti.gummei.plmn.MCCdigit1 = msg->oldgutiorimsi.guti.mccdigit1;
......@@ -543,9 +539,7 @@ int emm_recv_attach_request(unsigned int ueid, const attach_request_msg* msg,
guti.gummei.MMEgid = msg->oldgutiorimsi.guti.mmegroupid;
guti.gummei.MMEcode = msg->oldgutiorimsi.guti.mmecode;
guti.m_tmsi = msg->oldgutiorimsi.guti.mtmsi;
}
else if (msg->oldgutiorimsi.imsi.typeofidentity == EPS_MOBILE_IDENTITY_IMSI)
{
} else if (msg->oldgutiorimsi.imsi.typeofidentity == EPS_MOBILE_IDENTITY_IMSI) {
/* Get the IMSI */
p_imsi = &imsi;
imsi.u.num.digit1 = msg->oldgutiorimsi.imsi.digit1;
......@@ -564,9 +558,7 @@ int emm_recv_attach_request(unsigned int ueid, const attach_request_msg* msg,
imsi.u.num.digit14 = msg->oldgutiorimsi.imsi.digit14;
imsi.u.num.digit15 = msg->oldgutiorimsi.imsi.digit15;
imsi.u.num.parity = msg->oldgutiorimsi.imsi.oddeven;
}
else if (msg->oldgutiorimsi.imei.typeofidentity == EPS_MOBILE_IDENTITY_IMEI)
{
} else if (msg->oldgutiorimsi.imei.typeofidentity == EPS_MOBILE_IDENTITY_IMEI) {
/* Get the IMEI */
p_imei = &imei;
imei.u.num.digit1 = msg->oldgutiorimsi.imei.digit1;
......@@ -627,8 +619,8 @@ int emm_recv_attach_request(unsigned int ueid, const attach_request_msg* msg,
** Others: None **
** **
***************************************************************************/
int emm_recv_attach_complete(unsigned int ueid, const attach_complete_msg* msg,
int* emm_cause)
int emm_recv_attach_complete(unsigned int ueid, const attach_complete_msg *msg,
int *emm_cause)
{
LOG_FUNC_IN;
......@@ -658,8 +650,8 @@ int emm_recv_attach_complete(unsigned int ueid, const attach_complete_msg* msg,
** Others: None **
** **
***************************************************************************/
int emm_recv_detach_request(unsigned int ueid, const detach_request_msg* msg,
int* emm_cause)
int emm_recv_detach_request(unsigned int ueid, const detach_request_msg *msg,
int *emm_cause)
{
LOG_FUNC_IN;
......@@ -691,8 +683,7 @@ int emm_recv_detach_request(unsigned int ueid, const detach_request_msg* msg,
GUTI_t guti, *p_guti = NULL;
imsi_t imsi, *p_imsi = NULL;
imei_t imei, *p_imei = NULL;
if (msg->gutiorimsi.guti.typeofidentity == EPS_MOBILE_IDENTITY_GUTI)
{
if (msg->gutiorimsi.guti.typeofidentity == EPS_MOBILE_IDENTITY_GUTI) {
/* Get the GUTI */
p_guti = &guti;
guti.gummei.plmn.MCCdigit1 = msg->gutiorimsi.guti.mccdigit1;
......@@ -704,9 +695,7 @@ int emm_recv_detach_request(unsigned int ueid, const detach_request_msg* msg,
guti.gummei.MMEgid = msg->gutiorimsi.guti.mmegroupid;
guti.gummei.MMEcode = msg->gutiorimsi.guti.mmecode;
guti.m_tmsi = msg->gutiorimsi.guti.mtmsi;
}
else if (msg->gutiorimsi.imsi.typeofidentity == EPS_MOBILE_IDENTITY_IMSI)
{
} else if (msg->gutiorimsi.imsi.typeofidentity == EPS_MOBILE_IDENTITY_IMSI) {
/* Get the IMSI */
p_imsi = &imsi;
imsi.u.num.digit1 = msg->gutiorimsi.imsi.digit1;
......@@ -725,9 +714,7 @@ int emm_recv_detach_request(unsigned int ueid, const detach_request_msg* msg,
imsi.u.num.digit14 = msg->gutiorimsi.imsi.digit14;
imsi.u.num.digit15 = msg->gutiorimsi.imsi.digit15;
imsi.u.num.parity = msg->gutiorimsi.imsi.oddeven;
}
else if (msg->gutiorimsi.imei.typeofidentity == EPS_MOBILE_IDENTITY_IMEI)
{
} else if (msg->gutiorimsi.imei.typeofidentity == EPS_MOBILE_IDENTITY_IMEI) {
/* Get the IMEI */
p_imei = &imei;
imei.u.num.digit1 = msg->gutiorimsi.imei.digit1;
......@@ -773,8 +760,8 @@ int emm_recv_detach_request(unsigned int ueid, const detach_request_msg* msg,
** Others: None **
** **
***************************************************************************/
int emm_recv_identity_response(unsigned int ueid, identity_response_msg* msg,
int* emm_cause)
int emm_recv_identity_response(unsigned int ueid, identity_response_msg *msg,
int *emm_cause)
{
LOG_FUNC_IN;
......@@ -817,10 +804,8 @@ int emm_recv_identity_response(unsigned int ueid, identity_response_msg* msg,
imsi.u.num.digit14 = msg->mobileidentity.imsi.digit14;
imsi.u.num.digit15 = msg->mobileidentity.imsi.digit15;
imsi.u.num.parity = msg->mobileidentity.imsi.oddeven;
}
else if ((msg->mobileidentity.imei.typeofidentity == MOBILE_IDENTITY_IMEI) ||
(msg->mobileidentity.imeisv.typeofidentity==MOBILE_IDENTITY_IMEISV))
{
} else if ((msg->mobileidentity.imei.typeofidentity == MOBILE_IDENTITY_IMEI) ||
(msg->mobileidentity.imeisv.typeofidentity==MOBILE_IDENTITY_IMEISV)) {
/* Get the IMEI */
p_imei = &imei;
imei.u.num.digit1 = msg->mobileidentity.imei.digit1;
......@@ -839,9 +824,7 @@ int emm_recv_identity_response(unsigned int ueid, identity_response_msg* msg,
imei.u.num.digit14 = msg->mobileidentity.imei.digit14;
imei.u.num.digit15 = msg->mobileidentity.imei.digit15;
imei.u.num.parity = msg->mobileidentity.imei.oddeven;
}
else if (msg->mobileidentity.tmsi.typeofidentity == MOBILE_IDENTITY_TMSI)
{
} else if (msg->mobileidentity.tmsi.typeofidentity == MOBILE_IDENTITY_TMSI) {
/* Get the TMSI */
p_tmsi = &tmsi;
tmsi.digit1 = msg->mobileidentity.tmsi.digit2;
......@@ -856,7 +839,7 @@ int emm_recv_identity_response(unsigned int ueid, identity_response_msg* msg,
/* Execute the identification completion procedure */
rc = emm_proc_identification_complete(ueid, p_imsi, p_imei,
(UInt32_t*)(p_tmsi));
(UInt32_t *)(p_tmsi));
LOG_FUNC_RETURN (rc);
}
......@@ -876,8 +859,8 @@ int emm_recv_identity_response(unsigned int ueid, identity_response_msg* msg,
** **
***************************************************************************/
int emm_recv_authentication_response(unsigned int ueid,
authentication_response_msg* msg,
int* emm_cause)
authentication_response_msg *msg,
int *emm_cause)
{
LOG_FUNC_IN;
......@@ -921,8 +904,8 @@ int emm_recv_authentication_response(unsigned int ueid,
** **
***************************************************************************/
int emm_recv_authentication_failure(unsigned int ueid,
authentication_failure_msg* msg,
int* emm_cause)
authentication_failure_msg *msg,
int *emm_cause)
{
LOG_FUNC_IN;
......@@ -935,10 +918,9 @@ int emm_recv_authentication_failure(unsigned int ueid,
*/
if (msg->emmcause == EMM_CAUSE_SUCCESS) {
*emm_cause = EMM_CAUSE_INVALID_MANDATORY_INFO;
}
else if ( (msg->emmcause == EMM_CAUSE_SYNCH_FAILURE) &&
!(msg->presencemask & AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_PRESENT) )
{
} else if ( (msg->emmcause == EMM_CAUSE_SYNCH_FAILURE) &&
!(msg->presencemask &
AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_PRESENT) ) {
/* AUTS parameter shall be present in case of "synch failure" */
*emm_cause = EMM_CAUSE_INVALID_MANDATORY_INFO;
}
......@@ -971,8 +953,8 @@ int emm_recv_authentication_failure(unsigned int ueid,
** **
***************************************************************************/
int emm_recv_security_mode_complete(unsigned int ueid,
security_mode_complete_msg* msg,
int* emm_cause)
security_mode_complete_msg *msg,
int *emm_cause)
{
LOG_FUNC_IN;
......@@ -1005,8 +987,8 @@ int emm_recv_security_mode_complete(unsigned int ueid,
** **
***************************************************************************/
int emm_recv_security_mode_reject(unsigned int ueid,
security_mode_reject_msg* msg,
int* emm_cause)
security_mode_reject_msg *msg,
int *emm_cause)
{
LOG_FUNC_IN;
......
......@@ -80,7 +80,7 @@ Description Defines functions executed at the EMMAS Service Access
* Functions executed by both the UE and the MME upon receiving EMM messages
* --------------------------------------------------------------------------
*/
int emm_recv_status(unsigned int ueid, emm_status_msg* msg, int* emm_cause);
int emm_recv_status(unsigned int ueid, emm_status_msg *msg, int *emm_cause);
/*
* --------------------------------------------------------------------------
......@@ -88,15 +88,18 @@ int emm_recv_status(unsigned int ueid, emm_status_msg* msg, int* emm_cause);
* --------------------------------------------------------------------------
*/
#ifdef NAS_UE
int emm_recv_attach_accept(attach_accept_msg* msg, int* emm_cause);
int emm_recv_attach_reject(attach_reject_msg* msg, int* emm_cause);
int emm_recv_detach_accept(detach_accept_msg* msg, int* emm_cause);
int emm_recv_identity_request(identity_request_msg* msg, int* emm_cause);
int emm_recv_authentication_request(authentication_request_msg* msg, int* emm_cause);
int emm_recv_authentication_reject(authentication_reject_msg* msg, int* emm_cause);
int emm_recv_security_mode_command(security_mode_command_msg* msg, int* emm_cause);
int emm_recv_attach_accept(attach_accept_msg *msg, int *emm_cause);
int emm_recv_attach_reject(attach_reject_msg *msg, int *emm_cause);
int emm_recv_detach_accept(detach_accept_msg *msg, int *emm_cause);
int emm_recv_identity_request(identity_request_msg *msg, int *emm_cause);
int emm_recv_authentication_request(authentication_request_msg *msg,
int *emm_cause);
int emm_recv_authentication_reject(authentication_reject_msg *msg,
int *emm_cause);
int emm_recv_security_mode_command(security_mode_command_msg *msg,
int *emm_cause);
#endif
/*
......@@ -105,16 +108,24 @@ int emm_recv_security_mode_command(security_mode_command_msg* msg, int* emm_caus
* --------------------------------------------------------------------------
*/
#ifdef NAS_MME
int emm_recv_attach_request(unsigned int ueid, const attach_request_msg* msg, int* emm_cause);
int emm_recv_attach_complete(unsigned int ueid, const attach_complete_msg* msg, int* emm_cause);
int emm_recv_detach_request(unsigned int ueid, const detach_request_msg* msg, int* emm_cause);
int emm_recv_identity_response(unsigned int ueid, identity_response_msg* msg, int* emm_cause);
int emm_recv_authentication_response(unsigned int ueid, authentication_response_msg* msg, int* emm_cause);
int emm_recv_authentication_failure(unsigned int ueid, authentication_failure_msg* msg, int* emm_cause);
int emm_recv_security_mode_complete(unsigned int ueid, security_mode_complete_msg* msg, int* emm_cause);
int emm_recv_security_mode_reject(unsigned int ueid, security_mode_reject_msg* msg, int* emm_cause);
int emm_recv_attach_request(unsigned int ueid, const attach_request_msg *msg,
int *emm_cause);
int emm_recv_attach_complete(unsigned int ueid, const attach_complete_msg *msg,
int *emm_cause);
int emm_recv_detach_request(unsigned int ueid, const detach_request_msg *msg,
int *emm_cause);
int emm_recv_identity_response(unsigned int ueid, identity_response_msg *msg,
int *emm_cause);
int emm_recv_authentication_response(unsigned int ueid,
authentication_response_msg *msg, int *emm_cause);
int emm_recv_authentication_failure(unsigned int ueid,
authentication_failure_msg *msg, int *emm_cause);
int emm_recv_security_mode_complete(unsigned int ueid,
security_mode_complete_msg *msg, int *emm_cause);
int emm_recv_security_mode_reject(unsigned int ueid,
security_mode_reject_msg *msg, int *emm_cause);
#endif
#endif /* __EMM_RECV_H__*/
......@@ -78,7 +78,7 @@ void emm_reg_initialize(void)
** Others: None **
** **
***************************************************************************/
int emm_reg_send(const emm_reg_t* msg)
int emm_reg_send(const emm_reg_t *msg)
{
LOG_FUNC_IN;
......
......@@ -42,6 +42,6 @@ Description Defines the EMMREG Service Access Point that provides
void emm_reg_initialize(void);
int emm_reg_send(const emm_reg_t* msg);
int emm_reg_send(const emm_reg_t *msg);
#endif /* __EMM_REG_H__*/
......@@ -80,7 +80,7 @@ void emm_sap_initialize(void)
** Others: None **
** **
***************************************************************************/
int emm_sap_send(emm_sap_t* msg)
int emm_sap_send(emm_sap_t *msg)
{
LOG_FUNC_IN;
......@@ -94,20 +94,17 @@ int emm_sap_send(emm_sap_t* msg)
/* Forward to the EMMREG-SAP */
msg->u.emm_reg.primitive = primitive;
rc = emm_reg_send(&msg->u.emm_reg);
}
else if ( (primitive > EMMESM_PRIMITIVE_MIN) &&
} else if ( (primitive > EMMESM_PRIMITIVE_MIN) &&
(primitive < EMMESM_PRIMITIVE_MAX) ) {
/* Forward to the EMMESM-SAP */
msg->u.emm_esm.primitive = primitive;
rc = emm_esm_send(&msg->u.emm_esm);
}
else if ( (primitive > EMMAS_PRIMITIVE_MIN) &&
} else if ( (primitive > EMMAS_PRIMITIVE_MIN) &&
(primitive < EMMAS_PRIMITIVE_MAX) ) {
/* Forward to the EMMAS-SAP */
msg->u.emm_as.primitive = primitive;
rc = emm_as_send(&msg->u.emm_as);
}
else {
} else {
LOG_TRACE(WARNING, "EMM-SAP - Out of range primitive (%d)", primitive);
}
......
......@@ -146,6 +146,6 @@ typedef struct {
void emm_sap_initialize(void);
int emm_sap_send(emm_sap_t* msg);
int emm_sap_send(emm_sap_t *msg);
#endif /* __EMM_SAP_H__*/
......@@ -63,7 +63,7 @@ Description Defines functions executed at the EMMAS Service Access
** Others: None **
** **
***************************************************************************/
int emm_send_status(const emm_as_status_t* msg, emm_status_msg* emm_msg)
int emm_send_status(const emm_as_status_t *msg, emm_status_msg *emm_msg)
{
LOG_FUNC_IN;
......@@ -100,8 +100,8 @@ int emm_send_status(const emm_as_status_t* msg, emm_status_msg* emm_msg)
** Others: None **
** **
***************************************************************************/
int emm_send_detach_accept(const emm_as_data_t* msg,
detach_accept_msg* emm_msg)
int emm_send_detach_accept(const emm_as_data_t *msg,
detach_accept_msg *emm_msg)
{
LOG_FUNC_IN;
......@@ -138,8 +138,8 @@ int emm_send_detach_accept(const emm_as_data_t* msg,
** Others: None **
** **
***************************************************************************/
int emm_send_attach_request(const emm_as_establish_t* msg,
attach_request_msg* emm_msg)
int emm_send_attach_request(const emm_as_establish_t *msg,
attach_request_msg *emm_msg)
{
LOG_FUNC_IN;
......@@ -178,7 +178,7 @@ int emm_send_attach_request(const emm_as_establish_t* msg,
size += EPS_MOBILE_IDENTITY_MAXIMUM_LENGTH;
if (msg->UEid.guti) {
/* Set GUTI mobile identity */
GutiEpsMobileIdentity_t* guti = &emm_msg->oldgutiorimsi.guti;
GutiEpsMobileIdentity_t *guti = &emm_msg->oldgutiorimsi.guti;
guti->typeofidentity = EPS_MOBILE_IDENTITY_GUTI;
guti->oddeven = EPS_MOBILE_IDENTITY_EVEN;
guti->mmegroupid = msg->UEid.guti->gummei.MMEgid;
......@@ -192,7 +192,7 @@ int emm_send_attach_request(const emm_as_establish_t* msg,
guti->mncdigit3 = msg->UEid.guti->gummei.plmn.MNCdigit3;
} else if (msg->UEid.imsi) {
/* Set IMSI mobile identity */
ImsiEpsMobileIdentity_t* imsi = &emm_msg->oldgutiorimsi.imsi;
ImsiEpsMobileIdentity_t *imsi = &emm_msg->oldgutiorimsi.imsi;
imsi->typeofidentity = EPS_MOBILE_IDENTITY_IMSI;
imsi->oddeven = msg->UEid.imsi->u.num.parity;
imsi->digit1 = msg->UEid.imsi->u.num.digit1;
......@@ -212,7 +212,7 @@ int emm_send_attach_request(const emm_as_establish_t* msg,
imsi->digit15 = msg->UEid.imsi->u.num.digit15;
} else if (msg->UEid.imei) {
/* Set IMEI mobile identity */
ImeiEpsMobileIdentity_t* imei = &emm_msg->oldgutiorimsi.imei;
ImeiEpsMobileIdentity_t *imei = &emm_msg->oldgutiorimsi.imei;
imei->typeofidentity = EPS_MOBILE_IDENTITY_IMEI;
imei->oddeven = msg->UEid.imei->u.num.parity;
imei->digit1 = msg->UEid.imei->u.num.digit1;
......@@ -295,8 +295,8 @@ int emm_send_attach_request(const emm_as_establish_t* msg,
** Others: None **
** **
***************************************************************************/
int emm_send_attach_complete(const emm_as_data_t* msg,
attach_complete_msg* emm_msg)
int emm_send_attach_complete(const emm_as_data_t *msg,
attach_complete_msg *emm_msg)
{
LOG_FUNC_IN;
......@@ -331,8 +331,8 @@ int emm_send_attach_complete(const emm_as_data_t* msg,
** Others: None **
** **
***************************************************************************/
int emm_send_initial_detach_request(const emm_as_establish_t* msg,
detach_request_msg* emm_msg)
int emm_send_initial_detach_request(const emm_as_establish_t *msg,
detach_request_msg *emm_msg)
{
LOG_FUNC_IN;
......@@ -376,7 +376,7 @@ int emm_send_initial_detach_request(const emm_as_establish_t* msg,
size += EPS_MOBILE_IDENTITY_MAXIMUM_LENGTH;
if (msg->UEid.guti) {
/* Set GUTI mobile identity */
GutiEpsMobileIdentity_t* guti = &emm_msg->gutiorimsi.guti;
GutiEpsMobileIdentity_t *guti = &emm_msg->gutiorimsi.guti;
guti->typeofidentity = EPS_MOBILE_IDENTITY_GUTI;
guti->oddeven = EPS_MOBILE_IDENTITY_EVEN;
guti->mmegroupid = msg->UEid.guti->gummei.MMEgid;
......@@ -390,7 +390,7 @@ int emm_send_initial_detach_request(const emm_as_establish_t* msg,
guti->mncdigit3 = msg->UEid.guti->gummei.plmn.MNCdigit3;
} else if (msg->UEid.imsi) {
/* Set IMSI mobile identity */
ImsiEpsMobileIdentity_t* imsi = &emm_msg->gutiorimsi.imsi;
ImsiEpsMobileIdentity_t *imsi = &emm_msg->gutiorimsi.imsi;
imsi->typeofidentity = EPS_MOBILE_IDENTITY_IMSI;
imsi->oddeven = msg->UEid.imsi->u.num.parity;
imsi->digit1 = msg->UEid.imsi->u.num.digit1;
......@@ -410,7 +410,7 @@ int emm_send_initial_detach_request(const emm_as_establish_t* msg,
imsi->digit15 = msg->UEid.imsi->u.num.digit15;
} else if (msg->UEid.imei) {
/* Set IMEI mobile identity */
ImeiEpsMobileIdentity_t* imei = &emm_msg->gutiorimsi.imei;
ImeiEpsMobileIdentity_t *imei = &emm_msg->gutiorimsi.imei;
imei->typeofidentity = EPS_MOBILE_IDENTITY_IMEI;
imei->oddeven = msg->UEid.imei->u.num.parity;
imei->digit1 = msg->UEid.imei->u.num.digit1;
......@@ -450,8 +450,8 @@ int emm_send_initial_detach_request(const emm_as_establish_t* msg,
** Others: None **
** **
***************************************************************************/
int emm_send_detach_request(const emm_as_data_t* msg,
detach_request_msg* emm_msg)
int emm_send_detach_request(const emm_as_data_t *msg,
detach_request_msg *emm_msg)
{
LOG_FUNC_IN;
......@@ -495,7 +495,7 @@ int emm_send_detach_request(const emm_as_data_t* msg,
size += EPS_MOBILE_IDENTITY_MAXIMUM_LENGTH;
if (msg->guti) {
/* Set GUTI mobile identity */
GutiEpsMobileIdentity_t* guti = &emm_msg->gutiorimsi.guti;
GutiEpsMobileIdentity_t *guti = &emm_msg->gutiorimsi.guti;
guti->typeofidentity = EPS_MOBILE_IDENTITY_GUTI;
guti->oddeven = EPS_MOBILE_IDENTITY_EVEN;
guti->mmegroupid = msg->guti->gummei.MMEgid;
......@@ -531,8 +531,8 @@ int emm_send_detach_request(const emm_as_data_t* msg,
** Others: None **
** **
***************************************************************************/
int emm_send_initial_tau_request(const emm_as_establish_t* msg,
tracking_area_update_request_msg* emm_msg)
int emm_send_initial_tau_request(const emm_as_establish_t *msg,
tracking_area_update_request_msg *emm_msg)
{
LOG_FUNC_IN;
......@@ -564,8 +564,8 @@ int emm_send_initial_tau_request(const emm_as_establish_t* msg,
** Others: None **
** **
***************************************************************************/
int emm_send_initial_sr_request(const emm_as_establish_t* msg,
service_request_msg* emm_msg)
int emm_send_initial_sr_request(const emm_as_establish_t *msg,
service_request_msg *emm_msg)
{
LOG_FUNC_IN;
......@@ -597,8 +597,8 @@ int emm_send_initial_sr_request(const emm_as_establish_t* msg,
** Others: None **
** **
***************************************************************************/
int emm_send_initial_extsr_request(const emm_as_establish_t* msg,
extended_service_request_msg* emm_msg)
int emm_send_initial_extsr_request(const emm_as_establish_t *msg,
extended_service_request_msg *emm_msg)
{
LOG_FUNC_IN;
......@@ -630,8 +630,8 @@ int emm_send_initial_extsr_request(const emm_as_establish_t* msg,
** Others: None **
** **
***************************************************************************/
int emm_send_identity_response(const emm_as_security_t* msg,
identity_response_msg* emm_msg)
int emm_send_identity_response(const emm_as_security_t *msg,
identity_response_msg *emm_msg)
{
LOG_FUNC_IN;
......@@ -646,7 +646,7 @@ int emm_send_identity_response(const emm_as_security_t* msg,
size += MOBILE_IDENTITY_MAXIMUM_LENGTH;
if (msg->identType == EMM_IDENT_TYPE_IMSI) {
if (msg->imsi) {
ImsiMobileIdentity_t* imsi = &emm_msg->mobileidentity.imsi;
ImsiMobileIdentity_t *imsi = &emm_msg->mobileidentity.imsi;
imsi->typeofidentity = MOBILE_IDENTITY_IMSI;
imsi->oddeven = msg->imsi->u.num.parity;
imsi->digit1 = msg->imsi->u.num.digit1;
......@@ -667,8 +667,8 @@ int emm_send_identity_response(const emm_as_security_t* msg,
}
} else if (msg->identType == EMM_IDENT_TYPE_TMSI) {
if (msg->tmsi) {
const char *p_tmsi = (char*)(&msg->tmsi);
TmsiMobileIdentity_t* tmsi = &emm_msg->mobileidentity.tmsi;
const char *p_tmsi = (char *)(&msg->tmsi);
TmsiMobileIdentity_t *tmsi = &emm_msg->mobileidentity.tmsi;
tmsi->typeofidentity = MOBILE_IDENTITY_TMSI;
tmsi->oddeven = MOBILE_IDENTITY_EVEN;
tmsi->digit1 = 0xf;
......@@ -686,7 +686,7 @@ int emm_send_identity_response(const emm_as_security_t* msg,
}
} else if (msg->identType == EMM_IDENT_TYPE_IMEI) {
if (msg->imei) {
ImeiMobileIdentity_t* imei = &emm_msg->mobileidentity.imei;
ImeiMobileIdentity_t *imei = &emm_msg->mobileidentity.imei;
imei->typeofidentity = MOBILE_IDENTITY_IMEI;
imei->oddeven = msg->imei->u.num.parity;
imei->digit1 = msg->imei->u.num.digit1;
......@@ -706,7 +706,7 @@ int emm_send_identity_response(const emm_as_security_t* msg,
imei->digit15 = msg->imei->u.num.digit15;
}
} else if (msg->identType == EMM_IDENT_TYPE_NOT_AVAILABLE) {
NoMobileIdentity_t* no_id = &emm_msg->mobileidentity.no_id;
NoMobileIdentity_t *no_id = &emm_msg->mobileidentity.no_id;
no_id->typeofidentity = MOBILE_IDENTITY_NOT_AVAILABLE;
}
......@@ -731,8 +731,8 @@ int emm_send_identity_response(const emm_as_security_t* msg,
** Others: None **
** **
***************************************************************************/
int emm_send_authentication_response(const emm_as_security_t* msg,
authentication_response_msg* emm_msg)
int emm_send_authentication_response(const emm_as_security_t *msg,
authentication_response_msg *emm_msg)
{
int size = EMM_HEADER_MAXIMUM_LENGTH;
......@@ -766,8 +766,8 @@ int emm_send_authentication_response(const emm_as_security_t* msg,
** Others: None **
** **
***************************************************************************/
int emm_send_authentication_failure(const emm_as_security_t* msg,
authentication_failure_msg* emm_msg)
int emm_send_authentication_failure(const emm_as_security_t *msg,
authentication_failure_msg *emm_msg)
{
int size = EMM_HEADER_MAXIMUM_LENGTH;
......@@ -784,7 +784,8 @@ int emm_send_authentication_failure(const emm_as_security_t* msg,
/* Optional - Authentication response parameter */
if (msg->auts && msg->auts->length > 0) {
size += AUTHENTICATION_RESPONSE_PARAMETER_MAXIMUM_LENGTH;
emm_msg->presencemask |= AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_PRESENT;
emm_msg->presencemask |=
AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_PRESENT;
emm_msg->authenticationfailureparameter.auts = *msg->auts;
}
......@@ -809,8 +810,8 @@ int emm_send_authentication_failure(const emm_as_security_t* msg,
** Others: None **
** **
***************************************************************************/
int emm_send_security_mode_complete(const emm_as_security_t* msg,
security_mode_complete_msg* emm_msg)
int emm_send_security_mode_complete(const emm_as_security_t *msg,
security_mode_complete_msg *emm_msg)
{
LOG_FUNC_IN;
......@@ -842,8 +843,8 @@ int emm_send_security_mode_complete(const emm_as_security_t* msg,
** Others: None **
** **
***************************************************************************/
int emm_send_security_mode_reject(const emm_as_security_t* msg,
security_mode_reject_msg* emm_msg)
int emm_send_security_mode_reject(const emm_as_security_t *msg,
security_mode_reject_msg *emm_msg)
{
LOG_FUNC_IN;
......@@ -888,8 +889,8 @@ int emm_send_security_mode_reject(const emm_as_security_t* msg,
** Others: None **
** **
***************************************************************************/
int emm_send_attach_accept(const emm_as_establish_t* msg,
attach_accept_msg* emm_msg)
int emm_send_attach_accept(const emm_as_establish_t *msg,
attach_accept_msg *emm_msg)
{
LOG_FUNC_IN;
......@@ -962,8 +963,8 @@ int emm_send_attach_accept(const emm_as_establish_t* msg,
** Others: None **
** **
***************************************************************************/
int emm_send_attach_reject(const emm_as_establish_t* msg,
attach_reject_msg* emm_msg)
int emm_send_attach_reject(const emm_as_establish_t *msg,
attach_reject_msg *emm_msg)
{
LOG_FUNC_IN;
......@@ -1007,8 +1008,8 @@ int emm_send_attach_reject(const emm_as_establish_t* msg,
** Others: None **
** **
***************************************************************************/
int emm_send_identity_request(const emm_as_security_t* msg,
identity_request_msg* emm_msg)
int emm_send_identity_request(const emm_as_security_t *msg,
identity_request_msg *emm_msg)
{
LOG_FUNC_IN;
......@@ -1052,8 +1053,8 @@ int emm_send_identity_request(const emm_as_security_t* msg,
** Others: None **
** **
***************************************************************************/
int emm_send_authentication_request(const emm_as_security_t* msg,
authentication_request_msg* emm_msg)
int emm_send_authentication_request(const emm_as_security_t *msg,
authentication_request_msg *emm_msg)
{
LOG_FUNC_IN;
......@@ -1098,7 +1099,7 @@ int emm_send_authentication_request(const emm_as_security_t* msg,
** Others: None **
** **
***************************************************************************/
int emm_send_authentication_reject(authentication_reject_msg* emm_msg)
int emm_send_authentication_reject(authentication_reject_msg *emm_msg)
{
LOG_FUNC_IN;
......@@ -1129,8 +1130,8 @@ int emm_send_authentication_reject(authentication_reject_msg* emm_msg)
** Others: None **
** **
***************************************************************************/
int emm_send_security_mode_command(const emm_as_security_t* msg,
security_mode_command_msg* emm_msg)
int emm_send_security_mode_command(const emm_as_security_t *msg,
security_mode_command_msg *emm_msg)
{
LOG_FUNC_IN;
......
......@@ -82,9 +82,9 @@ Description Defines functions executed at the EMMAS Service Access
* Functions executed by both the UE and the MME to send EMM messages
* --------------------------------------------------------------------------
*/
int emm_send_status(const emm_as_status_t*, emm_status_msg*);
int emm_send_status(const emm_as_status_t *, emm_status_msg *);
int emm_send_detach_accept(const emm_as_data_t*, detach_accept_msg*);
int emm_send_detach_accept(const emm_as_data_t *, detach_accept_msg *);
/*
* --------------------------------------------------------------------------
......@@ -92,24 +92,33 @@ int emm_send_detach_accept(const emm_as_data_t*, detach_accept_msg*);
* --------------------------------------------------------------------------
*/
#ifdef NAS_UE
int emm_send_attach_request(const emm_as_establish_t*, attach_request_msg*);
int emm_send_attach_complete(const emm_as_data_t*, attach_complete_msg*);
int emm_send_attach_request(const emm_as_establish_t *, attach_request_msg *);
int emm_send_attach_complete(const emm_as_data_t *, attach_complete_msg *);
int emm_send_initial_detach_request(const emm_as_establish_t*, detach_request_msg*);
int emm_send_detach_request(const emm_as_data_t*, detach_request_msg*);
int emm_send_initial_detach_request(const emm_as_establish_t *,
detach_request_msg *);
int emm_send_detach_request(const emm_as_data_t *, detach_request_msg *);
int emm_send_initial_tau_request(const emm_as_establish_t*, tracking_area_update_request_msg*);
int emm_send_initial_tau_request(const emm_as_establish_t *,
tracking_area_update_request_msg *);
int emm_send_initial_sr_request(const emm_as_establish_t*, service_request_msg*);
int emm_send_initial_sr_request(const emm_as_establish_t *,
service_request_msg *);
int emm_send_initial_extsr_request(const emm_as_establish_t*, extended_service_request_msg*);
int emm_send_initial_extsr_request(const emm_as_establish_t *,
extended_service_request_msg *);
int emm_send_identity_response(const emm_as_security_t*, identity_response_msg*);
int emm_send_authentication_response(const emm_as_security_t*, authentication_response_msg*);
int emm_send_authentication_failure(const emm_as_security_t*, authentication_failure_msg*);
int emm_send_security_mode_complete(const emm_as_security_t*, security_mode_complete_msg*);
int emm_send_security_mode_reject(const emm_as_security_t*, security_mode_reject_msg*);
int emm_send_identity_response(const emm_as_security_t *,
identity_response_msg *);
int emm_send_authentication_response(const emm_as_security_t *,
authentication_response_msg *);
int emm_send_authentication_failure(const emm_as_security_t *,
authentication_failure_msg *);
int emm_send_security_mode_complete(const emm_as_security_t *,
security_mode_complete_msg *);
int emm_send_security_mode_reject(const emm_as_security_t *,
security_mode_reject_msg *);
#endif
/*
......@@ -118,13 +127,15 @@ int emm_send_security_mode_reject(const emm_as_security_t*, security_mode_reject
* --------------------------------------------------------------------------
*/
#ifdef NAS_MME
int emm_send_attach_accept(const emm_as_establish_t*, attach_accept_msg*);
int emm_send_attach_reject(const emm_as_establish_t*, attach_reject_msg*);
int emm_send_identity_request(const emm_as_security_t*, identity_request_msg*);
int emm_send_authentication_request(const emm_as_security_t*, authentication_request_msg*);
int emm_send_authentication_reject(authentication_reject_msg*);
int emm_send_security_mode_command(const emm_as_security_t*, security_mode_command_msg*);
int emm_send_attach_accept(const emm_as_establish_t *, attach_accept_msg *);
int emm_send_attach_reject(const emm_as_establish_t *, attach_reject_msg *);
int emm_send_identity_request(const emm_as_security_t *, identity_request_msg *);
int emm_send_authentication_request(const emm_as_security_t *,
authentication_request_msg *);
int emm_send_authentication_reject(authentication_reject_msg *);
int emm_send_security_mode_command(const emm_as_security_t *,
security_mode_command_msg *);
#endif
#endif /* __EMM_SEND_H__*/
......@@ -59,14 +59,14 @@ Description Defines the dedicated EPS bearer context activation ESM
/*
* Timer handlers
*/
static void* _dedicated_eps_bearer_activate_t3485_handler(void*);
static void *_dedicated_eps_bearer_activate_t3485_handler(void *);
/* Maximum value of the activate dedicated EPS bearer context request
* retransmission counter */
#define DEDICATED_EPS_BEARER_ACTIVATE_COUNTER_MAX 5
static int _dedicated_eps_bearer_activate(unsigned int ueid, int ebi,
const OctetString* msg);
const OctetString *msg);
#endif // NAS_MME
/****************************************************************************/
......@@ -103,11 +103,11 @@ static int _dedicated_eps_bearer_activate(unsigned int ueid, int ebi,
** **
***************************************************************************/
int esm_proc_dedicated_eps_bearer_context(unsigned int ueid, int pid,
unsigned int* ebi,
unsigned int* default_ebi,
const esm_proc_qos_t* qos,
const esm_proc_tft_t* tft,
int* esm_cause)
unsigned int *ebi,
unsigned int *default_ebi,
const esm_proc_qos_t *qos,
const esm_proc_tft_t *tft,
int *esm_cause)
{
LOG_FUNC_IN;
......@@ -163,7 +163,7 @@ int esm_proc_dedicated_eps_bearer_context(unsigned int ueid, int pid,
***************************************************************************/
int esm_proc_dedicated_eps_bearer_context_request(int is_standalone,
unsigned int ueid, int ebi,
OctetString* msg, int ue_triggered)
OctetString *msg, int ue_triggered)
{
LOG_FUNC_IN;
......@@ -212,7 +212,7 @@ int esm_proc_dedicated_eps_bearer_context_request(int is_standalone,
** **
***************************************************************************/
int esm_proc_dedicated_eps_bearer_context_accept(unsigned int ueid, int ebi,
int* esm_cause)
int *esm_cause)
{
LOG_FUNC_IN;
......@@ -263,7 +263,7 @@ int esm_proc_dedicated_eps_bearer_context_accept(unsigned int ueid, int ebi,
** **
***************************************************************************/
int esm_proc_dedicated_eps_bearer_context_reject(unsigned int ueid, int ebi,
int* esm_cause)
int *esm_cause)
{
LOG_FUNC_IN;
......@@ -317,9 +317,9 @@ int esm_proc_dedicated_eps_bearer_context_reject(unsigned int ueid, int ebi,
** **
***************************************************************************/
int esm_proc_dedicated_eps_bearer_context_request(int ebi, int default_ebi,
const esm_proc_qos_t* qos,
const esm_proc_tft_t* tft,
int* esm_cause)
const esm_proc_qos_t *qos,
const esm_proc_tft_t *tft,
int *esm_cause)
{
LOG_FUNC_IN;
......@@ -356,8 +356,7 @@ int esm_proc_dedicated_eps_bearer_context_request(int ebi, int default_ebi,
if (rc != RETURNok) {
/* Failed to release EPS bearer context */
*esm_cause = ESM_CAUSE_PROTOCOL_ERROR;
}
else {
} else {
/* Assign new dedicated EPS bearer context */
ebi = esm_ebr_assign(ebi, pid+1, FALSE);
}
......@@ -372,15 +371,13 @@ int esm_proc_dedicated_eps_bearer_context_request(int ebi, int default_ebi,
LOG_TRACE(WARNING, "ESM-PROC - Syntactical errors in packet "
"filters");
*esm_cause = ESM_CAUSE_SYNTACTICAL_ERROR_IN_PACKET_FILTER;
}
else {
} else {
/* Create new dedicated EPS bearer context */
default_ebi = esm_ebr_context_create(pid, ebi, FALSE, qos, tft);
if (default_ebi != ESM_EBI_UNASSIGNED) {
/* Dedicated EPS bearer contextx successfully created */
rc = RETURNok;
}
else {
} else {
/* No resource available */
LOG_TRACE(WARNING, "ESM-PROC - Failed to create new dedicated "
"EPS bearer context");
......@@ -417,7 +414,7 @@ int esm_proc_dedicated_eps_bearer_context_request(int ebi, int default_ebi,
** **
***************************************************************************/
int esm_proc_dedicated_eps_bearer_context_accept(int is_standalone, int ebi,
OctetString* msg, int ue_triggered)
OctetString *msg, int ue_triggered)
{
LOG_FUNC_IN;
......@@ -476,7 +473,7 @@ int esm_proc_dedicated_eps_bearer_context_accept(int is_standalone, int ebi,
** **
***************************************************************************/
int esm_proc_dedicated_eps_bearer_context_reject(int is_standalone, int ebi,
OctetString* msg, int ue_triggered)
OctetString *msg, int ue_triggered)
{
LOG_FUNC_IN;
......@@ -492,8 +489,7 @@ int esm_proc_dedicated_eps_bearer_context_reject(int is_standalone, int ebi,
if (rc != RETURNok) {
LOG_TRACE(WARNING, "ESM-PROC - Failed to release EPS bearer data");
}
else {
} else {
emm_sap_t emm_sap;
emm_esm_data_t *emm_esm = &emm_sap.u.emm_esm.u.data;
/*
......@@ -543,14 +539,14 @@ int esm_proc_dedicated_eps_bearer_context_reject(int is_standalone, int ebi,
** Others: None **
** **
***************************************************************************/
static void* _dedicated_eps_bearer_activate_t3485_handler(void* args)
static void *_dedicated_eps_bearer_activate_t3485_handler(void *args)
{
LOG_FUNC_IN;
int rc;
/* Get retransmission timer parameters data */
esm_ebr_timer_data_t* data = (esm_ebr_timer_data_t*)(args);
esm_ebr_timer_data_t *data = (esm_ebr_timer_data_t *)(args);
/* Increment the retransmission counter */
data->count += 1;
......@@ -563,8 +559,7 @@ static void* _dedicated_eps_bearer_activate_t3485_handler(void* args)
/* Re-send activate dedicated EPS bearer context request message
* to the UE */
rc = _dedicated_eps_bearer_activate(data->ueid, data->ebi, &data->msg);
}
else {
} else {
/*
* The maximum number of activate dedicated EPS bearer context request
* message retransmission has exceed
......@@ -607,7 +602,7 @@ static void* _dedicated_eps_bearer_activate_t3485_handler(void* args)
** **
***************************************************************************/
static int _dedicated_eps_bearer_activate(unsigned int ueid, int ebi,
const OctetString* msg)
const OctetString *msg)
{
LOG_FUNC_IN;
......
......@@ -69,14 +69,14 @@ static struct {
/*
* Timer handlers
*/
static void* _default_eps_bearer_activate_t3485_handler(void*);
static void *_default_eps_bearer_activate_t3485_handler(void *);
/* Maximum value of the activate default EPS bearer context request
* retransmission counter */
#define DEFAULT_EPS_BEARER_ACTIVATE_COUNTER_MAX 5
static int _default_eps_bearer_activate(unsigned int ueid, int ebi,
const OctetString* msg);
const OctetString *msg);
#endif // NAS_MME
/****************************************************************************/
......@@ -110,9 +110,9 @@ static int _default_eps_bearer_activate(unsigned int ueid, int ebi,
** **
***************************************************************************/
int esm_proc_default_eps_bearer_context(unsigned int ueid, int pid,
unsigned int* ebi,
const esm_proc_qos_t* qos,
int* esm_cause)
unsigned int *ebi,
const esm_proc_qos_t *qos,
int *esm_cause)
{
LOG_FUNC_IN;
......@@ -171,7 +171,7 @@ int esm_proc_default_eps_bearer_context(unsigned int ueid, int pid,
***************************************************************************/
int esm_proc_default_eps_bearer_context_request(int is_standalone,
unsigned int ueid, int ebi,
OctetString* msg, int ue_triggered)
OctetString *msg, int ue_triggered)
{
LOG_FUNC_IN;
......@@ -222,7 +222,7 @@ int esm_proc_default_eps_bearer_context_request(int is_standalone,
** **
***************************************************************************/
int esm_proc_default_eps_bearer_context_accept(unsigned int ueid, int ebi,
int* esm_cause)
int *esm_cause)
{
LOG_FUNC_IN;
......@@ -269,7 +269,7 @@ int esm_proc_default_eps_bearer_context_accept(unsigned int ueid, int ebi,
** **
***************************************************************************/
int esm_proc_default_eps_bearer_context_reject(unsigned int ueid, int ebi,
int* esm_cause)
int *esm_cause)
{
LOG_FUNC_IN;
......@@ -371,8 +371,8 @@ int esm_proc_default_eps_bearer_context_failure(unsigned int ueid)
** **
***************************************************************************/
int esm_proc_default_eps_bearer_context_request(int pid, int ebi,
const esm_proc_qos_t* qos,
int* esm_cause)
const esm_proc_qos_t *qos,
int *esm_cause)
{
LOG_FUNC_IN;
......@@ -396,8 +396,7 @@ int esm_proc_default_eps_bearer_context_request(int pid, int ebi,
if (rc != RETURNok) {
/* Failed to release EPS bearer context */
*esm_cause = ESM_CAUSE_PROTOCOL_ERROR;
}
else {
} else {
/* Assign new default EPS bearer context */
ebi = esm_ebr_assign(ebi, pid+1, TRUE);
}
......@@ -410,8 +409,7 @@ int esm_proc_default_eps_bearer_context_request(int pid, int ebi,
/* Default EPS bearer contextx successfully created */
_default_eps_bearer_context_data.ebi = ebi;
rc = RETURNok;
}
else {
} else {
/* No resource available */
LOG_TRACE(WARNING, "ESM-PROC - Failed to create new default EPS "
"bearer context");
......@@ -454,7 +452,7 @@ int esm_proc_default_eps_bearer_context_request(int pid, int ebi,
** **
***************************************************************************/
int esm_proc_default_eps_bearer_context_accept(int is_standalone, int ebi,
OctetString* msg, int ue_triggered)
OctetString *msg, int ue_triggered)
{
LOG_FUNC_IN;
......@@ -521,7 +519,7 @@ int esm_proc_default_eps_bearer_context_accept(int is_standalone, int ebi,
** **
***************************************************************************/
int esm_proc_default_eps_bearer_context_reject(int is_standalone, int ebi,
OctetString* msg, int ue_triggered)
OctetString *msg, int ue_triggered)
{
LOG_FUNC_IN;
......@@ -537,8 +535,7 @@ int esm_proc_default_eps_bearer_context_reject(int is_standalone, int ebi,
if (rc != RETURNok) {
LOG_TRACE(WARNING, "ESM-PROC - Failed to release EPS bearer data");
}
else if (is_standalone) {
} else if (is_standalone) {
emm_sap_t emm_sap;
emm_esm_data_t *emm_esm = &emm_sap.u.emm_esm.u.data;
/*
......@@ -549,8 +546,7 @@ int esm_proc_default_eps_bearer_context_reject(int is_standalone, int ebi,
emm_esm->msg.length = msg->length;
emm_esm->msg.value = msg->value;
rc = emm_sap_send(&emm_sap);
}
else {
} else {
/* An error is returned to notify EMM that the default EPS bearer
* activation procedure initiated as part of the initial attach
* procedure has failed
......@@ -665,14 +661,14 @@ int esm_proc_default_eps_bearer_context_failure(void)
** Others: None **
** **
***************************************************************************/
static void* _default_eps_bearer_activate_t3485_handler(void* args)
static void *_default_eps_bearer_activate_t3485_handler(void *args)
{
LOG_FUNC_IN;
int rc;
/* Get retransmission timer parameters data */
esm_ebr_timer_data_t* data = (esm_ebr_timer_data_t*)(args);
esm_ebr_timer_data_t *data = (esm_ebr_timer_data_t *)(args);
/* Increment the retransmission counter */
data->count += 1;
......@@ -685,8 +681,7 @@ static void* _default_eps_bearer_activate_t3485_handler(void* args)
/* Re-send activate default EPS bearer context request message
* to the UE */
rc = _default_eps_bearer_activate(data->ueid, data->ebi, &data->msg);
}
else {
} else {
/*
* The maximum number of activate default EPS bearer context request
* message retransmission has exceed
......@@ -729,7 +724,7 @@ static void* _default_eps_bearer_activate_t3485_handler(void* args)
** **
***************************************************************************/
static int _default_eps_bearer_activate(unsigned int ueid, int ebi,
const OctetString* msg)
const OctetString *msg)
{
LOG_FUNC_IN;
......
......@@ -58,7 +58,7 @@ Description Defines the EPS bearer context deactivation ESM procedure
* --------------------------------------------------------------------------
*/
#ifdef NAS_UE
static int _eps_bearer_release(int ebi, int* pid, int* bid);
static int _eps_bearer_release(int ebi, int *pid, int *bid);
#endif // NAS_UE
/*
......@@ -71,15 +71,15 @@ static int _eps_bearer_release(int ebi, int* pid, int* bid);
/*
* Timer handlers
*/
static void* _eps_bearer_deactivate_t3495_handler(void*);
static void *_eps_bearer_deactivate_t3495_handler(void *);
/* Maximum value of the deactivate EPS bearer context request
* retransmission counter */
#define EPS_BEARER_DEACTIVATE_COUNTER_MAX 5
static int _eps_bearer_deactivate(unsigned int ueid, int ebi,
const OctetString* msg);
static int _eps_bearer_release(unsigned int ueid, int ebi, int* pid, int* bid);
const OctetString *msg);
static int _eps_bearer_release(unsigned int ueid, int ebi, int *pid, int *bid);
#endif // NAS_MME
......@@ -122,8 +122,8 @@ static int _eps_bearer_release(unsigned int ueid, int ebi, int* pid, int* bid);
** **
***************************************************************************/
int esm_proc_eps_bearer_context_deactivate(unsigned int ueid, int is_local,
int ebi, int* pid, int* bid,
int* esm_cause)
int ebi, int *pid, int *bid,
int *esm_cause)
{
LOG_FUNC_IN;
......@@ -133,15 +133,16 @@ int esm_proc_eps_bearer_context_deactivate(unsigned int ueid, int is_local,
if (ebi != ESM_SAP_ALL_EBI) {
/* Locally release the specified EPS bearer context */
rc = _eps_bearer_release(ueid, ebi, pid, bid);
}
else if ( (ueid < ESM_DATA_NB_UE_MAX) && _esm_data.ctx[ueid] ) {
} else if ( (ueid < ESM_DATA_NB_UE_MAX) && _esm_data.ctx[ueid] ) {
/* Locally release all the EPS bearer contexts */
*bid = 0;
for (*pid = 0; *pid < ESM_DATA_PDN_MAX; (*pid)++) {
if (_esm_data.ctx[ueid]->pdn[*pid].data) {
rc = _eps_bearer_release(ueid, ESM_EBI_UNASSIGNED,
pid, bid);
if (rc != RETURNok) break;
if (rc != RETURNok) {
break;
}
}
}
}
......@@ -152,29 +153,27 @@ int esm_proc_eps_bearer_context_deactivate(unsigned int ueid, int is_local,
"(ueid=%u, ebi=%d)", ueid, ebi);
if ( (ueid < ESM_DATA_NB_UE_MAX) && (_esm_data.ctx[ueid] != NULL) &&
(*pid < ESM_DATA_PDN_MAX) )
{
(*pid < ESM_DATA_PDN_MAX) ) {
if (_esm_data.ctx[ueid]->pdn[*pid].pid != *pid) {
LOG_TRACE(ERROR, "ESM-PROC - PDN connection identifier %d "
"is not valid", *pid);
*esm_cause = ESM_CAUSE_PROTOCOL_ERROR;
}
else if (_esm_data.ctx[ueid]->pdn[*pid].data == NULL) {
} else if (_esm_data.ctx[ueid]->pdn[*pid].data == NULL) {
LOG_TRACE(ERROR, "ESM-PROC - PDN connection %d has not been "
"allocated", *pid);
*esm_cause = ESM_CAUSE_PROTOCOL_ERROR;
}
else if (!_esm_data.ctx[ueid]->pdn[*pid].is_active) {
} else if (!_esm_data.ctx[ueid]->pdn[*pid].is_active) {
LOG_TRACE(WARNING, "ESM-PROC - PDN connection %d is not active",
*pid);
*esm_cause = ESM_CAUSE_PROTOCOL_ERROR;
}
else {
} else {
int i;
*esm_cause = ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY;
esm_pdn_t* pdn = _esm_data.ctx[ueid]->pdn[*pid].data;
esm_pdn_t *pdn = _esm_data.ctx[ueid]->pdn[*pid].data;
for (i = 0; i < pdn->n_bearers; i++) {
if (pdn->bearer[i]->ebi != ebi) continue;
if (pdn->bearer[i]->ebi != ebi) {
continue;
}
/* The EPS bearer context to be released is valid */
rc = RETURNok;
}
......@@ -211,7 +210,7 @@ int esm_proc_eps_bearer_context_deactivate(unsigned int ueid, int is_local,
***************************************************************************/
int esm_proc_eps_bearer_context_deactivate_request(int is_standalone,
unsigned int ueid, int ebi,
OctetString* msg, int ue_triggered)
OctetString *msg, int ue_triggered)
{
LOG_FUNC_IN;
......@@ -263,7 +262,7 @@ int esm_proc_eps_bearer_context_deactivate_request(int is_standalone,
** **
***************************************************************************/
int esm_proc_eps_bearer_context_deactivate_accept(unsigned int ueid, int ebi,
int* esm_cause)
int *esm_cause)
{
LOG_FUNC_IN;
......@@ -323,7 +322,7 @@ int esm_proc_eps_bearer_context_deactivate_accept(unsigned int ueid, int ebi,
** **
***************************************************************************/
int esm_proc_eps_bearer_context_deactivate(int is_local, int ebi,
int* pid, int* bid)
int *pid, int *bid)
{
LOG_FUNC_IN;
......@@ -333,14 +332,15 @@ int esm_proc_eps_bearer_context_deactivate(int is_local, int ebi,
if (ebi != ESM_SAP_ALL_EBI) {
/* Locally release the EPS bearer context */
rc = _eps_bearer_release(ebi, pid, bid);
}
else {
} else {
/* Locally release all the EPS bearer contexts */
*bid = 0;
for (*pid = 0; *pid < ESM_DATA_PDN_MAX; (*pid)++) {
if (_esm_data.pdn[*pid].data) {
rc = _eps_bearer_release(ESM_EBI_UNASSIGNED, pid, bid);
if (rc != RETURNok) break;
if (rc != RETURNok) {
break;
}
}
}
}
......@@ -354,19 +354,18 @@ int esm_proc_eps_bearer_context_deactivate(int is_local, int ebi,
if (_esm_data.pdn[*pid].pid != *pid) {
LOG_TRACE(ERROR, "ESM-PROC - PDN connection identifier %d "
"is not valid", *pid);
}
else if (_esm_data.pdn[*pid].data == NULL) {
} else if (_esm_data.pdn[*pid].data == NULL) {
LOG_TRACE(ERROR, "ESM-PROC - PDN connection %d has not been "
"allocated", *pid);
}
else if (!_esm_data.pdn[*pid].is_active) {
} else if (!_esm_data.pdn[*pid].is_active) {
LOG_TRACE(WARNING, "ESM-PROC - PDN connection %d is not active",
*pid);
}
else {
esm_pdn_t* pdn = _esm_data.pdn[*pid].data;
} else {
esm_pdn_t *pdn = _esm_data.pdn[*pid].data;
for (int i = 0; i < pdn->n_bearers; i++) {
if (pdn->bearer[i]->ebi != ebi) continue;
if (pdn->bearer[i]->ebi != ebi) {
continue;
}
/* The EPS bearer context to be released is valid */
rc = RETURNok;
}
......@@ -393,7 +392,7 @@ int esm_proc_eps_bearer_context_deactivate(int is_local, int ebi,
** Others: None **
** **
***************************************************************************/
int esm_proc_eps_bearer_context_deactivate_request(int ebi, int* esm_cause)
int esm_proc_eps_bearer_context_deactivate_request(int ebi, int *esm_cause)
{
LOG_FUNC_IN;
......@@ -413,8 +412,7 @@ int esm_proc_eps_bearer_context_deactivate_request(int ebi, int* esm_cause)
if (bid == 0) {
/* The EPS bearer identity is that of the default bearer assigned to
* the PDN connection */
if (*esm_cause == ESM_CAUSE_REACTIVATION_REQUESTED)
{
if (*esm_cause == ESM_CAUSE_REACTIVATION_REQUESTED) {
esm_sap_t esm_sap;
int active = FALSE;
......@@ -479,7 +477,7 @@ int esm_proc_eps_bearer_context_deactivate_request(int ebi, int* esm_cause)
** **
***************************************************************************/
int esm_proc_eps_bearer_context_deactivate_accept(int is_standalone, int ebi,
OctetString* msg, int ue_triggered)
OctetString *msg, int ue_triggered)
{
LOG_FUNC_IN;
......@@ -550,14 +548,14 @@ int esm_proc_eps_bearer_context_deactivate_accept(int is_standalone, int ebi,
** Others: None **
** **
***************************************************************************/
static void* _eps_bearer_deactivate_t3495_handler(void* args)
static void *_eps_bearer_deactivate_t3495_handler(void *args)
{
LOG_FUNC_IN;
int rc;
/* Get retransmission timer parameters data */
esm_ebr_timer_data_t* data = (esm_ebr_timer_data_t*)(args);
esm_ebr_timer_data_t *data = (esm_ebr_timer_data_t *)(args);
/* Increment the retransmission counter */
data->count += 1;
......@@ -569,8 +567,7 @@ static void* _eps_bearer_deactivate_t3495_handler(void* args)
if (data->count < EPS_BEARER_DEACTIVATE_COUNTER_MAX) {
/* Re-send deactivate EPS bearer context request message to the UE */
rc = _eps_bearer_deactivate(data->ueid, data->ebi, &data->msg);
}
else {
} else {
/*
* The maximum number of deactivate EPS bearer context request
* message retransmission has exceed
......@@ -614,7 +611,7 @@ static void* _eps_bearer_deactivate_t3495_handler(void* args)
** **
***************************************************************************/
static int _eps_bearer_deactivate(unsigned int ueid, int ebi,
const OctetString* msg)
const OctetString *msg)
{
LOG_FUNC_IN;
......@@ -659,7 +656,7 @@ static int _eps_bearer_deactivate(unsigned int ueid, int ebi,
** Others: None **
** **
***************************************************************************/
static int _eps_bearer_release(unsigned int ueid, int ebi, int* pid, int* bid)
static int _eps_bearer_release(unsigned int ueid, int ebi, int *pid, int *bid)
{
LOG_FUNC_IN;
......@@ -669,15 +666,13 @@ static int _eps_bearer_release(unsigned int ueid, int ebi, int* pid, int* bid)
ebi = esm_ebr_context_release(ueid, ebi, pid, bid);
if (ebi == ESM_EBI_UNASSIGNED) {
LOG_TRACE(WARNING, "ESM-PROC - Failed to release EPS bearer context");
}
else {
} else {
/* Set the EPS bearer context state to INACTIVE */
rc = esm_ebr_set_status(ueid, ebi, ESM_EBR_INACTIVE, FALSE);
if (rc != RETURNok) {
/* The EPS bearer context was already in INACTIVE state */
LOG_TRACE(WARNING, "ESM-PROC - EBI %d was already INACTIVE", ebi);
}
else {
} else {
/* Release EPS bearer data */
rc = esm_ebr_release(ueid, ebi);
if (rc != RETURNok) {
......@@ -716,7 +711,7 @@ static int _eps_bearer_release(unsigned int ueid, int ebi, int* pid, int* bid)
** Others: None **
** **
***************************************************************************/
static int _eps_bearer_release(int ebi, int* pid, int* bid)
static int _eps_bearer_release(int ebi, int *pid, int *bid)
{
LOG_FUNC_IN;
......@@ -726,15 +721,13 @@ static int _eps_bearer_release(int ebi, int* pid, int* bid)
ebi = esm_ebr_context_release(ebi, pid, bid);
if (ebi == ESM_EBI_UNASSIGNED) {
LOG_TRACE(WARNING, "ESM-PROC - Failed to release EPS bearer context");
}
else {
} else {
/* Set the EPS bearer context state to INACTIVE */
rc = esm_ebr_set_status(ebi, ESM_EBR_INACTIVE, FALSE);
if (rc != RETURNok) {
/* The EPS bearer context was already in INACTIVE state */
LOG_TRACE(WARNING, "ESM-PROC - EBI %d was already INACTIVE", ebi);
}
else {
} else {
/* Release EPS bearer data */
rc = esm_ebr_release(ebi);
if (rc != RETURNok) {
......
......@@ -75,7 +75,7 @@ int esm_proc_status_ind(
#ifdef NAS_MME
unsigned int ueid,
#endif
int pti, int ebi, int* esm_cause)
int pti, int ebi, int *esm_cause)
{
LOG_FUNC_IN;
......@@ -86,8 +86,7 @@ int esm_proc_status_ind(
LOG_TRACE(DEBUG, "ESM-PROC - To be implemented");
switch (*esm_cause)
{
switch (*esm_cause) {
case ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY:
/*
* Abort any ongoing ESM procedure related to the received EPS
......@@ -151,7 +150,7 @@ int esm_proc_status(int is_standalone,
#ifdef NAS_MME
unsigned int ueid,
#endif
int ebi, OctetString* msg,
int ebi, OctetString *msg,
int ue_triggered)
{
LOG_FUNC_IN;
......
......@@ -63,18 +63,21 @@ Description Defines the PDN connectivity ESM procedure executed by the
/*
* PDN connection handlers
*/
static int _pdn_connectivity_create(int pid, const OctetString* apn, esm_proc_pdn_type_t pdn_type, int is_emergency);
static int _pdn_connectivity_update(int pid, const OctetString* apn, esm_proc_pdn_type_t pdn_type, const OctetString* pdn_addr, int esm_cause);
static int _pdn_connectivity_create(int pid, const OctetString *apn,
esm_proc_pdn_type_t pdn_type, int is_emergency);
static int _pdn_connectivity_update(int pid, const OctetString *apn,
esm_proc_pdn_type_t pdn_type, const OctetString *pdn_addr, int esm_cause);
static int _pdn_connectivity_delete(int pid);
static int _pdn_connectivity_set_pti(int pid, int pti);
static int _pdn_connectivity_find_apn(const OctetString* apn);
static int _pdn_connectivity_find_pdn(const OctetString* apn, esm_proc_pdn_type_t pdn_type);
static int _pdn_connectivity_find_apn(const OctetString *apn);
static int _pdn_connectivity_find_pdn(const OctetString *apn,
esm_proc_pdn_type_t pdn_type);
/*
* Timer handlers
*/
static void* _pdn_connectivity_t3482_handler(void*);
static void *_pdn_connectivity_t3482_handler(void *);
/* Maximum value of the PDN connectivity request retransmission counter */
#define ESM_PDN_CONNECTIVITY_COUNTER_MAX 5
......@@ -90,7 +93,9 @@ static void* _pdn_connectivity_t3482_handler(void*);
/*
* PDN connection handlers
*/
static int _pdn_connectivity_create(unsigned int ueid, int pti, const OctetString* apn, esm_proc_pdn_type_t pdn_type, const OctetString* pdn_addr, int is_emergency);
static int _pdn_connectivity_create(unsigned int ueid, int pti,
const OctetString *apn, esm_proc_pdn_type_t pdn_type,
const OctetString *pdn_addr, int is_emergency);
int _pdn_connectivity_delete(unsigned int ueid, int pid);
#endif // NAS_MME
......@@ -131,8 +136,8 @@ int _pdn_connectivity_delete(unsigned int ueid, int pid);
***************************************************************************/
int esm_proc_pdn_connectivity(int cid, int is_to_define,
esm_proc_pdn_type_t pdn_type,
const OctetString* apn, int is_emergency,
unsigned int* pti)
const OctetString *apn, int is_emergency,
unsigned int *pti)
{
LOG_FUNC_IN;
......@@ -148,8 +153,7 @@ int esm_proc_pdn_connectivity(int cid, int is_to_define,
rc = esm_pt_release(pti);
}
LOG_FUNC_RETURN(rc);
}
else if (pti != NULL) {
} else if (pti != NULL) {
LOG_TRACE(INFO, "ESM-PROC - Assign new procedure transaction identity "
"(cid=%d)", cid);
/* Assign new procedure transaction identity */
......@@ -178,15 +182,13 @@ int esm_proc_pdn_connectivity(int cid, int is_to_define,
LOG_TRACE(WARNING, "ESM-PROC - PDN connection for emergency bearer "
"services is already active");
LOG_FUNC_RETURN (RETURNerror);
}
else if (pid < ESM_DATA_PDN_MAX) {
} else if (pid < ESM_DATA_PDN_MAX) {
if ((pid == _esm_data.pdn[pid].pid) && (_esm_data.pdn[pid].is_active)) {
/* PDN connection with the specified identifier is active */
LOG_TRACE(WARNING, "ESM-PROC - PDN connection is active");
LOG_FUNC_RETURN (RETURNerror);
}
}
else {
} else {
LOG_TRACE(WARNING, "ESM-PROC - PDN connection identifier is not valid");
LOG_FUNC_RETURN (RETURNerror);
}
......@@ -217,8 +219,7 @@ int esm_proc_pdn_connectivity(int cid, int is_to_define,
}
LOG_FUNC_RETURN (RETURNerror);
}
}
else {
} else {
/* The UE is requesting PDN connection to this APN using the
* same IP version than the one already activated */
LOG_TRACE(WARNING, "ESM-PROC - %s PDN connection to %s "
......@@ -271,7 +272,7 @@ int esm_proc_pdn_connectivity(int cid, int is_to_define,
** **
***************************************************************************/
int esm_proc_pdn_connectivity_request(int is_standalone, int pti,
OctetString* msg, int sent_by_ue)
OctetString *msg, int sent_by_ue)
{
LOG_FUNC_IN;
......@@ -279,8 +280,7 @@ int esm_proc_pdn_connectivity_request(int is_standalone, int pti,
LOG_TRACE(INFO, "ESM-PROC - Initiate PDN connectivity (pti=%d)", pti);
if (is_standalone)
{
if (is_standalone) {
emm_sap_t emm_sap;
emm_esm_data_t *emm_esm = &emm_sap.u.emm_esm.u.data;
/*
......@@ -337,8 +337,8 @@ int esm_proc_pdn_connectivity_request(int is_standalone, int pti,
** **
***************************************************************************/
int esm_proc_pdn_connectivity_accept(int pti, esm_proc_pdn_type_t pdn_type,
const OctetString* pdn_addr,
const OctetString* apn, int* esm_cause)
const OctetString *pdn_addr,
const OctetString *apn, int *esm_cause)
{
LOG_FUNC_IN;
......@@ -362,8 +362,7 @@ int esm_proc_pdn_connectivity_accept(int pti, esm_proc_pdn_type_t pdn_type,
* transmission */
LOG_TRACE(WARNING, "ESM-PROC - PTI %d network retransmission", pti);
*esm_cause = ESM_CAUSE_PTI_ALREADY_IN_USE;
}
else {
} else {
/* XXX - 3GPP TS 24.301, section 6.5.1.3 and 7.3.1
* The UE should ensure that the procedure transaction identity
* (PTI) assigned to this procedure is not released immediately.
......@@ -420,7 +419,7 @@ int esm_proc_pdn_connectivity_accept(int pti, esm_proc_pdn_type_t pdn_type,
** Others: None **
** **
***************************************************************************/
int esm_proc_pdn_connectivity_reject(int pti, int* esm_cause)
int esm_proc_pdn_connectivity_reject(int pti, int *esm_cause)
{
LOG_FUNC_IN;
......@@ -437,8 +436,7 @@ int esm_proc_pdn_connectivity_reject(int pti, int* esm_cause)
/* The procedure transaction was already in INACTIVE state */
LOG_TRACE(WARNING, "ESM-PROC - PTI %d was already INACTIVE", pti);
*esm_cause = ESM_CAUSE_MESSAGE_TYPE_NOT_COMPATIBLE;
}
else {
} else {
/* Release the procedure transaction identity */
rc = esm_pt_release(pti);
if (rc != RETURNok) {
......@@ -520,8 +518,7 @@ int esm_proc_pdn_connectivity_failure(int is_pending)
LOG_TRACE(WARNING, "ESM-PROC - PDN connectivity failure in state %s",
(is_pending)? "PENDING" : "INACTIVE");
if (is_pending)
{
if (is_pending) {
/* Get the procedure transaction identity assigned to the pending PDN
* connection entry */
pti = esm_pt_get_pending_pti(ESM_PT_PENDING);
......@@ -531,8 +528,7 @@ int esm_proc_pdn_connectivity_failure(int is_pending)
}
/* Set the procedure transaction state to INACTIVE */
(void) esm_pt_set_status(pti, ESM_PT_INACTIVE);
}
else {
} else {
/* Get the procedure transaction identity assigned to the PDN
* connection entry which is still pending in the inactive state */
pti = esm_pt_get_pending_pti(ESM_PT_INACTIVE);
......@@ -594,11 +590,11 @@ int esm_proc_pdn_connectivity_failure(int is_pending)
***************************************************************************/
int esm_proc_pdn_connectivity_request(unsigned int ueid, int pti,
esm_proc_pdn_request_t request_type,
OctetString* apn,
OctetString *apn,
esm_proc_pdn_type_t pdn_type,
OctetString* pdn_addr,
esm_proc_qos_t* esm_qos,
int* esm_cause)
OctetString *pdn_addr,
esm_proc_qos_t *esm_qos,
int *esm_cause)
{
LOG_FUNC_IN;
......@@ -609,7 +605,7 @@ int esm_proc_pdn_connectivity_request(unsigned int ueid, int pti,
"(ueid=%u, pti=%d) PDN type = %s, APN = %s", ueid, pti,
(pdn_type == ESM_PDN_TYPE_IPV4)? "IPv4" :
(pdn_type == ESM_PDN_TYPE_IPV6)? "IPv6" : "IPv4v6",
(apn)? (char*)(apn->value) : "null");
(apn)? (char *)(apn->value) : "null");
/* UE identifier sanity check */
if (ueid >= ESM_DATA_NB_UE_MAX) {
......@@ -621,8 +617,7 @@ int esm_proc_pdn_connectivity_request(unsigned int ueid, int pti,
* Check network IP capabilities
*/
*esm_cause = ESM_CAUSE_SUCCESS;
switch (_esm_data.conf.features & (MME_API_IPV4 | MME_API_IPV6))
{
switch (_esm_data.conf.features & (MME_API_IPV4 | MME_API_IPV6)) {
case (MME_API_IPV4 | MME_API_IPV6):
/* The network supports both IPv4 and IPv6 connection */
if ( (pdn_type == ESM_PDN_TYPE_IPV4V6) &&
......@@ -650,8 +645,7 @@ int esm_proc_pdn_connectivity_request(unsigned int ueid, int pti,
break;
}
if (rc != RETURNerror)
{
if (rc != RETURNerror) {
int is_emergency = (request_type == ESM_PDN_REQUEST_EMERGENCY);
mme_api_qos_t qos;
......@@ -668,7 +662,7 @@ int esm_proc_pdn_connectivity_request(unsigned int ueid, int pti,
/* Create new ESM context for the UE within the MME */
if (_esm_data.ctx[ueid] == NULL) {
_esm_data.ctx[ueid] =
(esm_data_context_t*)malloc(sizeof(esm_data_context_t));
(esm_data_context_t *)malloc(sizeof(esm_data_context_t));
memset(_esm_data.ctx[ueid], 0 , sizeof(esm_data_context_t));
}
if (_esm_data.ctx[ueid]) {
......@@ -723,7 +717,7 @@ int esm_proc_pdn_connectivity_request(unsigned int ueid, int pti,
** **
***************************************************************************/
int esm_proc_pdn_connectivity_reject(int is_standalone, unsigned int ueid,
int ebi, OctetString* msg, int ue_triggered)
int ebi, OctetString *msg, int ue_triggered)
{
LOG_FUNC_IN;
......@@ -822,14 +816,14 @@ int esm_proc_pdn_connectivity_failure(unsigned int ueid, int pid)
** Others: None **
** **
***************************************************************************/
static void* _pdn_connectivity_t3482_handler(void* args)
static void *_pdn_connectivity_t3482_handler(void *args)
{
LOG_FUNC_IN;
int rc;
/* Get retransmission timer parameters data */
esm_pt_timer_data_t* data = (esm_pt_timer_data_t*)(args);
esm_pt_timer_data_t *data = (esm_pt_timer_data_t *)(args);
/* Increment the retransmission counter */
data->count += 1;
......@@ -855,16 +849,14 @@ static void* _pdn_connectivity_t3482_handler(void* args)
rc = esm_pt_start_timer(data->pti, &data->msg, T3482_DEFAULT_VALUE,
_pdn_connectivity_t3482_handler);
}
}
else {
} else {
/* Set the procedure transaction state to INACTIVE */
rc = esm_pt_set_status(data->pti, ESM_PT_INACTIVE);
if (rc != RETURNok) {
/* The procedure transaction was already in INACTIVE state */
LOG_TRACE(WARNING, "ESM-PROC - PTI %d was already INACTIVE",
data->pti);
}
else {
} else {
/* Release the transaction identity assigned to this procedure */
rc = esm_pt_release(data->pti);
if (rc != RETURNok) {
......@@ -902,18 +894,17 @@ static void* _pdn_connectivity_t3482_handler(void* args)
** Others: _esm_data **
** **
***************************************************************************/
static int _pdn_connectivity_create(int pid, const OctetString* apn,
static int _pdn_connectivity_create(int pid, const OctetString *apn,
esm_proc_pdn_type_t pdn_type,
int is_emergency)
{
esm_pdn_t* pdn = NULL;
esm_pdn_t *pdn = NULL;
LOG_TRACE(INFO, "ESM-PROC - Create new PDN connection (pid=%d)", pid);
if (pid >= ESM_DATA_PDN_MAX) {
return (RETURNerror);
}
else if (_esm_data.pdn[pid].is_active) {
} else if (_esm_data.pdn[pid].is_active) {
LOG_TRACE(ERROR, "ESM-PROC - PDN connection is active");
return (RETURNerror);
}
......@@ -923,7 +914,7 @@ static int _pdn_connectivity_create(int pid, const OctetString* apn,
pdn = _esm_data.pdn[pid].data;
} else {
/* Create new PDN connection */
pdn = (esm_pdn_t*)malloc(sizeof(esm_pdn_t));
pdn = (esm_pdn_t *)malloc(sizeof(esm_pdn_t));
if (pdn == NULL) {
LOG_TRACE(WARNING, "ESM-PROC - "
"Failed to create new PDN connection");
......@@ -947,7 +938,7 @@ static int _pdn_connectivity_create(int pid, const OctetString* apn,
free(pdn->apn.value);
pdn->apn.length = 0;
}
pdn->apn.value = (uint8_t*)malloc(apn->length + 1);
pdn->apn.value = (uint8_t *)malloc(apn->length + 1);
if (pdn->apn.value) {
pdn->apn.length = apn->length;
memcpy(pdn->apn.value, apn->value, apn->length);
......@@ -977,25 +968,22 @@ static int _pdn_connectivity_create(int pid, const OctetString* apn,
** Others: _esm_data **
** **
***************************************************************************/
static int _pdn_connectivity_update(int pid, const OctetString* apn,
static int _pdn_connectivity_update(int pid, const OctetString *apn,
esm_proc_pdn_type_t pdn_type,
const OctetString* pdn_addr,
const OctetString *pdn_addr,
int esm_cause)
{
LOG_TRACE(INFO, "ESM-PROC - Update PDN connection (pid=%d)", pid);
if (pid >= ESM_DATA_PDN_MAX) {
return (RETURNerror);
}
else if (pid != _esm_data.pdn[pid].pid) {
} else if (pid != _esm_data.pdn[pid].pid) {
LOG_TRACE(ERROR, "ESM-PROC - PDN connection identifier is not valid");
return (RETURNerror);
}
else if (_esm_data.pdn[pid].data == NULL) {
} else if (_esm_data.pdn[pid].data == NULL) {
LOG_TRACE(ERROR, "ESM-PROC - PDN connection has not been allocated");
return (RETURNerror);
}
else if (_esm_data.pdn[pid].is_active) {
} else if (_esm_data.pdn[pid].is_active) {
LOG_TRACE(WARNING, "ESM-PROC - Active %s PDN connection to %s already "
"exists", (_esm_data.pdn[pid].data->type != ESM_PDN_TYPE_IPV4)?
"IPv6" : "IPv4", _esm_data.pdn[pid].data->apn.value);
......@@ -1003,14 +991,14 @@ static int _pdn_connectivity_update(int pid, const OctetString* apn,
}
/* Get the PDN connection */
esm_pdn_t* pdn = _esm_data.pdn[pid].data;
esm_pdn_t *pdn = _esm_data.pdn[pid].data;
/* Setup the Access Point Name value */
if ( apn && (apn->length > 0) ) {
if (pdn->apn.length > 0) {
free(pdn->apn.value);
pdn->apn.length = 0;
}
pdn->apn.value = (uint8_t*)malloc(apn->length + 1);
pdn->apn.value = (uint8_t *)malloc(apn->length + 1);
if (pdn->apn.value) {
pdn->apn.length = apn->length;
memcpy(pdn->apn.value, apn->value, apn->length);
......@@ -1036,8 +1024,7 @@ static int _pdn_connectivity_update(int pid, const OctetString* apn,
* procedure to the same APN with a single address PDN type
* (IPv4 or IPv6) other than the one already activated */
pdn->addr_realloc = TRUE;
}
else if ( (esm_cause == ESM_CAUSE_PDN_TYPE_IPV4_ONLY_ALLOWED) ||
} else if ( (esm_cause == ESM_CAUSE_PDN_TYPE_IPV4_ONLY_ALLOWED) ||
(esm_cause == ESM_CAUSE_PDN_TYPE_IPV6_ONLY_ALLOWED) ) {
/* The UE requested IPv4 or IPv6 address and the network allows
* IPv4 or IPv6 PDN address only:
......@@ -1045,8 +1032,7 @@ static int _pdn_connectivity_update(int pid, const OctetString* apn,
* PDN connectivity procedure to the same APN to obtain a PDN
* type different from the one allowed by the network */
pdn->addr_realloc = FALSE;
}
else if (pdn_type != ESM_PDN_TYPE_IPV4V6) {
} else if (pdn_type != ESM_PDN_TYPE_IPV4V6) {
pdn->addr_realloc = TRUE;
}
......@@ -1075,20 +1061,16 @@ static int _pdn_connectivity_delete(int pid)
{
int pti = ESM_PT_UNASSIGNED;
if (pid < ESM_DATA_PDN_MAX)
{
if (pid < ESM_DATA_PDN_MAX) {
if (pid != _esm_data.pdn[pid].pid) {
LOG_TRACE(ERROR,
"ESM-PROC - PDN connection identifier is not valid");
}
else if (_esm_data.pdn[pid].data == NULL) {
} else if (_esm_data.pdn[pid].data == NULL) {
LOG_TRACE(ERROR,
"ESM-PROC - PDN connection has not been allocated");
}
else if (_esm_data.pdn[pid].is_active) {
} else if (_esm_data.pdn[pid].is_active) {
LOG_TRACE(ERROR, "ESM-PROC - PDN connection is active");
}
else {
} else {
/* Get the identity of the procedure transaction that created
* the PDN connection */
pti = _esm_data.pdn[pid].data->pti;
......@@ -1131,20 +1113,16 @@ static int _pdn_connectivity_delete(int pid)
***************************************************************************/
static int _pdn_connectivity_set_pti(int pid, int pti)
{
if (pid < ESM_DATA_PDN_MAX)
{
if (pid < ESM_DATA_PDN_MAX) {
if (pid != _esm_data.pdn[pid].pid) {
LOG_TRACE(ERROR,
"ESM-PROC - PDN connection identifier is not valid");
}
else if (_esm_data.pdn[pid].data == NULL) {
} else if (_esm_data.pdn[pid].data == NULL) {
LOG_TRACE(ERROR,
"ESM-PROC - PDN connection has not been allocated");
}
else if (_esm_data.pdn[pid].is_active) {
} else if (_esm_data.pdn[pid].is_active) {
LOG_TRACE(ERROR, "ESM-PROC - PDN connection is active");
}
else {
} else {
/* Update the identity of the procedure transaction assigned to
* the PDN connection */
_esm_data.pdn[pid].data->pti = pti;
......@@ -1171,12 +1149,11 @@ static int _pdn_connectivity_set_pti(int pid, int pti)
** Others: None **
** **
***************************************************************************/
static int _pdn_connectivity_find_apn(const OctetString* apn)
static int _pdn_connectivity_find_apn(const OctetString *apn)
{
int i;
for (i = 0; i < ESM_DATA_PDN_MAX; i++)
{
for (i = 0; i < ESM_DATA_PDN_MAX; i++) {
if ( (_esm_data.pdn[i].pid != -1) && _esm_data.pdn[i].data ) {
if (_esm_data.pdn[i].data->apn.length != apn->length) {
continue;
......@@ -1211,13 +1188,12 @@ static int _pdn_connectivity_find_apn(const OctetString* apn)
** Others: None **
** **
***************************************************************************/
static int _pdn_connectivity_find_pdn(const OctetString* apn,
static int _pdn_connectivity_find_pdn(const OctetString *apn,
const esm_proc_pdn_type_t pdn_type)
{
int i;
for (i = 0; i < ESM_DATA_PDN_MAX; i++)
{
for (i = 0; i < ESM_DATA_PDN_MAX; i++) {
if ( (_esm_data.pdn[i].pid != -1) && _esm_data.pdn[i].data ) {
/* PDN connection established during initial network attachment */
if (_esm_data.pdn[i].data->apn.length == 0) {
......@@ -1273,9 +1249,9 @@ static int _pdn_connectivity_find_pdn(const OctetString* apn,
** **
***************************************************************************/
static int _pdn_connectivity_create(unsigned int ueid, int pti,
const OctetString* apn,
const OctetString *apn,
esm_proc_pdn_type_t pdn_type,
const OctetString* pdn_addr,
const OctetString *pdn_addr,
int is_emergency)
{
int pid = ESM_DATA_PDN_MAX;
......@@ -1286,31 +1262,28 @@ static int _pdn_connectivity_create(unsigned int ueid, int pti,
(pdn_type == ESM_PDN_TYPE_IPV6)? esm_data_get_ipv6_addr(pdn_addr) :
esm_data_get_ipv4v6_addr(pdn_addr), ueid);
if (ueid < ESM_DATA_NB_UE_MAX)
{
if (ueid < ESM_DATA_NB_UE_MAX) {
if (_esm_data.ctx[ueid] == NULL) {
LOG_TRACE(ERROR, "ESM-PROC - ESM context has not been allocated");
}
else if (_esm_data.ctx[ueid]->n_pdns > ESM_DATA_PDN_MAX) {
} else if (_esm_data.ctx[ueid]->n_pdns > ESM_DATA_PDN_MAX) {
LOG_TRACE(WARNING, "ESM-PROC - Number of PDN connection exceeded");
}
else if (_esm_data.ctx[ueid]->emergency && is_emergency) {
} else if (_esm_data.ctx[ueid]->emergency && is_emergency) {
LOG_TRACE(WARNING, "ESM-PROC - PDN connection for emergency bearer "
"services already established");
}
else {
} else {
/* Search for an available PDN connection entry */
for (pid = 0; pid < ESM_DATA_PDN_MAX; pid++) {
if (_esm_data.ctx[ueid]->pdn[pid].data != NULL) continue;
if (_esm_data.ctx[ueid]->pdn[pid].data != NULL) {
continue;
}
break;
}
}
}
if (pid < ESM_DATA_PDN_MAX)
{
if (pid < ESM_DATA_PDN_MAX) {
/* Create new PDN connection */
esm_pdn_t* pdn = (esm_pdn_t*)malloc(sizeof(esm_pdn_t));
esm_pdn_t *pdn = (esm_pdn_t *)malloc(sizeof(esm_pdn_t));
if (pdn != NULL) {
memset(pdn, 0, sizeof(esm_pdn_t));
/* Increment the number of PDN connections */
......@@ -1328,7 +1301,7 @@ static int _pdn_connectivity_create(unsigned int ueid, int pti,
pdn->is_emergency = is_emergency;
/* Setup the Access Point Name */
if ( apn && (apn->length > 0) ) {
pdn->apn.value = (uint8_t*)malloc(apn->length + 1);
pdn->apn.value = (uint8_t *)malloc(apn->length + 1);
if (pdn->apn.value) {
pdn->apn.length = apn->length;
memcpy(pdn->apn.value, apn->value, apn->length);
......@@ -1377,24 +1350,19 @@ int _pdn_connectivity_delete(unsigned int ueid, int pid)
{
int pti = ESM_PT_UNASSIGNED;
if (ueid < ESM_DATA_NB_UE_MAX)
{
if (ueid < ESM_DATA_NB_UE_MAX) {
if (_esm_data.ctx[ueid] == NULL) {
LOG_TRACE(ERROR, "ESM-PROC - ESM context has not been allocated");
}
else if (pid < ESM_DATA_PDN_MAX) {
} else if (pid < ESM_DATA_PDN_MAX) {
if (pid != _esm_data.ctx[ueid]->pdn[pid].pid) {
LOG_TRACE(ERROR,
"ESM-PROC - PDN connection identifier is not valid");
}
else if (_esm_data.ctx[ueid]->pdn[pid].data == NULL) {
} else if (_esm_data.ctx[ueid]->pdn[pid].data == NULL) {
LOG_TRACE(ERROR,
"ESM-PROC - PDN connection has not been allocated");
}
else if (_esm_data.ctx[ueid]->pdn[pid].is_active) {
} else if (_esm_data.ctx[ueid]->pdn[pid].is_active) {
LOG_TRACE(ERROR, "ESM-PROC - PDN connection is active");
}
else {
} else {
/* Get the identity of the procedure transaction that created
* the PDN connection */
pti = _esm_data.ctx[ueid]->pdn[pid].data->pti;
......@@ -1402,8 +1370,7 @@ int _pdn_connectivity_delete(unsigned int ueid, int pid)
}
}
if (pti != ESM_PT_UNASSIGNED)
{
if (pti != ESM_PT_UNASSIGNED) {
/* Decrement the number of PDN connections */
_esm_data.ctx[ueid]->n_pdns -= 1;
/* Set the PDN connection as available */
......
......@@ -65,7 +65,7 @@ static int _pdn_disconnect_get_default_ebi(int pti);
/*
* Timer handlers
*/
static void* _pdn_disconnect_t3492_handler(void*);
static void *_pdn_disconnect_t3492_handler(void *);
/* Maximum value of the PDN disconnect request retransmission counter */
#define ESM_PDN_DISCONNECT_COUNTER_MAX 5
......@@ -115,7 +115,7 @@ static int _pdn_disconnect_get_pid(unsigned int ueid, int pti);
** Others: None **
** **
***************************************************************************/
int esm_proc_pdn_disconnect(int cid, unsigned int* pti, unsigned int* ebi)
int esm_proc_pdn_disconnect(int cid, unsigned int *pti, unsigned int *ebi)
{
LOG_FUNC_IN;
......@@ -126,15 +126,12 @@ int esm_proc_pdn_disconnect(int cid, unsigned int* pti, unsigned int* ebi)
if (pid != _esm_data.pdn[pid].pid) {
LOG_TRACE(WARNING, "ESM-PROC - PDN connection identifier %d is "
"not valid", pid);
}
else if (_esm_data.pdn[pid].data == NULL) {
} else if (_esm_data.pdn[pid].data == NULL) {
LOG_TRACE(ERROR, "ESM-PROC - PDN connection %d has not been "
"allocated", pid);
}
else if (!_esm_data.pdn[pid].is_active) {
} else if (!_esm_data.pdn[pid].is_active) {
LOG_TRACE(WARNING, "ESM-PROC - PDN connection is not active");
}
else {
} else {
/* Get the procedure transaction identity assigned to the PDN
* connection to be released */
*pti = _esm_data.pdn[pid].data->pti;
......@@ -173,7 +170,7 @@ int esm_proc_pdn_disconnect(int cid, unsigned int* pti, unsigned int* ebi)
** **
***************************************************************************/
int esm_proc_pdn_disconnect_request(int is_standalone, int pti,
OctetString* msg, int sent_by_ue)
OctetString *msg, int sent_by_ue)
{
LOG_FUNC_IN;
......@@ -181,8 +178,7 @@ int esm_proc_pdn_disconnect_request(int is_standalone, int pti,
LOG_TRACE(INFO, "ESM-PROC - Initiate PDN disconnection (pti=%d)", pti);
if (is_standalone)
{
if (is_standalone) {
emm_sap_t emm_sap;
emm_esm_data_t *emm_esm = &emm_sap.u.emm_esm.u.data;
/*
......@@ -235,7 +231,7 @@ int esm_proc_pdn_disconnect_request(int is_standalone, int pti,
** Others: None **
** **
***************************************************************************/
int esm_proc_pdn_disconnect_accept(int pti, int* esm_cause)
int esm_proc_pdn_disconnect_accept(int pti, int *esm_cause)
{
LOG_FUNC_IN;
......@@ -250,8 +246,7 @@ int esm_proc_pdn_disconnect_accept(int pti, int* esm_cause)
/* The procedure transaction was already in INACTIVE state */
LOG_TRACE(WARNING, "ESM-PROC - PTI %d was already INACTIVE", pti);
*esm_cause = ESM_CAUSE_MESSAGE_TYPE_NOT_COMPATIBLE;
}
else {
} else {
/* Immediately release the transaction identity assigned to this
* procedure */
rc = esm_pt_release(pti);
......@@ -286,7 +281,7 @@ int esm_proc_pdn_disconnect_accept(int pti, int* esm_cause)
** Others: None **
** **
***************************************************************************/
int esm_proc_pdn_disconnect_reject(int pti, int* esm_cause)
int esm_proc_pdn_disconnect_reject(int pti, int *esm_cause)
{
LOG_FUNC_IN;
......@@ -304,16 +299,13 @@ int esm_proc_pdn_disconnect_reject(int pti, int* esm_cause)
* as the request may have already been rejected */
LOG_TRACE(WARNING, "ESM-PROC - PTI %d was already INACTIVE", pti);
*esm_cause = ESM_CAUSE_MESSAGE_TYPE_NOT_COMPATIBLE;
}
else {
} else {
/* Release the transaction identity assigned to this procedure */
rc = esm_pt_release(pti);
if (rc != RETURNok) {
LOG_TRACE(WARNING, "ESM-PROC - Failed to release PTI %d", pti);
*esm_cause = ESM_CAUSE_REQUEST_REJECTED_UNSPECIFIED;
}
else if (*esm_cause != ESM_CAUSE_LAST_PDN_DISCONNECTION_NOT_ALLOWED)
{
} else if (*esm_cause != ESM_CAUSE_LAST_PDN_DISCONNECTION_NOT_ALLOWED) {
/* Get the identity of the default EPS bearer context allocated to
* the PDN connection entry assigned to this procedure transaction */
int ebi = _pdn_disconnect_get_default_ebi(pti);
......@@ -376,7 +368,7 @@ int esm_proc_pdn_disconnect_reject(int pti, int* esm_cause)
** Others: None **
** **
***************************************************************************/
int esm_proc_pdn_disconnect_request(unsigned int ueid, int pti, int* esm_cause)
int esm_proc_pdn_disconnect_request(unsigned int ueid, int pti, int *esm_cause)
{
LOG_FUNC_IN;
......@@ -385,15 +377,13 @@ int esm_proc_pdn_disconnect_request(unsigned int ueid, int pti, int* esm_cause)
LOG_TRACE(INFO, "ESM-PROC - PDN disconnect requested by the UE "
"(ueid=%d, pti=%d)", ueid, pti);
if (ueid < ESM_DATA_NB_UE_MAX)
{
if (ueid < ESM_DATA_NB_UE_MAX) {
/* Get UE's ESM context */
esm_data_context_t* ctx = _esm_data.ctx[ueid];
esm_data_context_t *ctx = _esm_data.ctx[ueid];
if (_esm_data.ctx[ueid] == NULL) {
LOG_TRACE(ERROR, "ESM-PROC - No ESM context exists");
*esm_cause = ESM_CAUSE_PROTOCOL_ERROR;
}
else if (ctx->n_pdns > 1) {
} else if (ctx->n_pdns > 1) {
/* Get the identifier of the PDN connection entry assigned to the
* procedure transaction identity */
pid = _pdn_disconnect_get_pid(ueid, pti);
......@@ -403,8 +393,7 @@ int esm_proc_pdn_disconnect_request(unsigned int ueid, int pti, int* esm_cause)
*esm_cause = ESM_CAUSE_PROTOCOL_ERROR;
LOG_FUNC_RETURN (RETURNerror);
}
}
else {
} else {
/* Attempt to disconnect from the last PDN disconnection
* is not allowed */
*esm_cause = ESM_CAUSE_LAST_PDN_DISCONNECTION_NOT_ALLOWED;
......@@ -436,7 +425,7 @@ int esm_proc_pdn_disconnect_request(unsigned int ueid, int pti, int* esm_cause)
** Others: None **
** **
***************************************************************************/
int esm_proc_pdn_disconnect_accept(unsigned int ueid, int pid, int* esm_cause)
int esm_proc_pdn_disconnect_accept(unsigned int ueid, int pid, int *esm_cause)
{
LOG_FUNC_IN;
......@@ -482,7 +471,7 @@ int esm_proc_pdn_disconnect_accept(unsigned int ueid, int pid, int* esm_cause)
** **
***************************************************************************/
int esm_proc_pdn_disconnect_reject(int is_standalone, unsigned int ueid,
int ebi, OctetString* msg, int ue_triggered)
int ebi, OctetString *msg, int ue_triggered)
{
LOG_FUNC_IN;
......@@ -540,14 +529,14 @@ int esm_proc_pdn_disconnect_reject(int is_standalone, unsigned int ueid,
** Others: None **
** **
***************************************************************************/
static void* _pdn_disconnect_t3492_handler(void* args)
static void *_pdn_disconnect_t3492_handler(void *args)
{
LOG_FUNC_IN;
int rc;
/* Get retransmission timer parameters data */
esm_pt_timer_data_t* data = (esm_pt_timer_data_t*)(args);
esm_pt_timer_data_t *data = (esm_pt_timer_data_t *)(args);
/* Increment the retransmission counter */
data->count += 1;
......@@ -573,23 +562,20 @@ static void* _pdn_disconnect_t3492_handler(void* args)
rc = esm_pt_start_timer(data->pti, &data->msg, T3492_DEFAULT_VALUE,
_pdn_disconnect_t3492_handler);
}
}
else {
} else {
/* Set the procedure transaction state to INACTIVE */
rc = esm_pt_set_status(data->pti, ESM_PT_INACTIVE);
if (rc != RETURNok) {
/* The procedure transaction was already in INACTIVE state */
LOG_TRACE(WARNING, "ESM-PROC - PTI %d was already INACTIVE",
data->pti);
}
else {
} else {
/* Release the transaction identity assigned to this procedure */
rc = esm_pt_release(data->pti);
if (rc != RETURNok) {
LOG_TRACE(WARNING, "ESM-PROC - Failed to release PTI %d",
data->pti);
}
else {
} else {
/* Get the identity of the default EPS bearer context
* allocated to the PDN connection entry assigned to
* this procedure transaction */
......@@ -647,7 +633,9 @@ static int _pdn_disconnect_get_default_ebi(int pti)
for (int i = 0; i < ESM_DATA_PDN_MAX; i++) {
if ( (_esm_data.pdn[i].pid != -1) && _esm_data.pdn[i].data ) {
if (_esm_data.pdn[i].data->pti != pti) continue;
if (_esm_data.pdn[i].data->pti != pti) {
continue;
}
/* PDN entry found */
if (_esm_data.pdn[i].data->bearer[0] != NULL) {
/* Get the EPS bearer identity of the default EPS bearer
......@@ -689,7 +677,9 @@ static int _pdn_disconnect_get_pid(unsigned int ueid, int pti)
for (i = 0; i < ESM_DATA_PDN_MAX; i++) {
if ( (_esm_data.ctx[ueid]->pdn[i].pid != -1) &&
(_esm_data.ctx[ueid]->pdn[i].data != NULL) ) {
if (_esm_data.ctx[ueid]->pdn[i].data->pti != pti) continue;
if (_esm_data.ctx[ueid]->pdn[i].data->pti != pti) {
continue;
}
/* PDN entry found */
break;
}
......
......@@ -90,7 +90,7 @@ typedef struct {
int n_bearers; /* Number of allocated EPS bearers;
* default EPS bearer is defined at index 0 */
#define ESM_DATA_EPS_BEARER_MAX 4
esm_bearer_t* bearer[ESM_DATA_EPS_BEARER_MAX];
esm_bearer_t *bearer[ESM_DATA_EPS_BEARER_MAX];
} esm_pdn_t;
/*
......@@ -112,7 +112,7 @@ typedef struct {
int is_active; /* TRUE/FALSE if the PDN connection is active/inactive
* or the process to activate/deactivate the PDN
* connection is in progress */
esm_pdn_t* data; /* Active PDN connection data */
esm_pdn_t *data; /* Active PDN connection data */
} pdn[ESM_DATA_PDN_MAX+1];
} esm_data_context_t;
......@@ -150,7 +150,7 @@ typedef struct {
* ------------
*/
#define ESM_DATA_NB_UE_MAX (MME_API_NB_UE_MAX + 1)
esm_data_context_t* ctx[ESM_DATA_NB_UE_MAX];
esm_data_context_t *ctx[ESM_DATA_NB_UE_MAX];
} esm_data_t;
......@@ -172,10 +172,10 @@ esm_data_t _esm_data;
extern char ip_addr_str[100];
extern inline char* esm_data_get_ipv4_addr(const OctetString* ip_addr);
extern inline char *esm_data_get_ipv4_addr(const OctetString *ip_addr);
extern inline char* esm_data_get_ipv6_addr(const OctetString* ip_addr);
extern inline char *esm_data_get_ipv6_addr(const OctetString *ip_addr);
extern inline char* esm_data_get_ipv4v6_addr(const OctetString* ip_addr);
extern inline char *esm_data_get_ipv4v6_addr(const OctetString *ip_addr);
#endif /* __ESMDATA_H__*/
......@@ -51,7 +51,7 @@ Description Defines functions used to handle state of EPS bearer contexts
/****************************************************************************/
/* String representation of EPS bearer context status */
static const char* _esm_ebr_state_str[ESM_EBR_STATE_MAX] = {
static const char *_esm_ebr_state_str[ESM_EBR_STATE_MAX] = {
"BEARER CONTEXT INACTIVE",
"BEARER CONTEXT ACTIVE",
#ifdef NAS_MME
......@@ -77,7 +77,7 @@ typedef struct {
#endif
#ifdef NAS_MME
struct nas_timer_t timer; /* Retransmission timer */
esm_ebr_timer_data_t* args; /* Retransmission timer parameters data */
esm_ebr_timer_data_t *args; /* Retransmission timer parameters data */
#endif
} esm_ebr_context_t;
......@@ -90,7 +90,7 @@ static struct {
unsigned char index; /* Index of the next EPS bearer context
* identity to be used */
#define ESM_EBR_DATA_SIZE (ESM_EBI_MAX - ESM_EBI_MIN + 1)
esm_ebr_context_t* context[ESM_EBR_DATA_SIZE + 1];
esm_ebr_context_t *context[ESM_EBR_DATA_SIZE + 1];
} _esm_ebr_data[ESM_EBR_NB_UE_MAX];
/*
......@@ -147,7 +147,7 @@ void esm_ebr_initialize(
#ifdef NAS_UE
esm_indication_callback_t cb
#endif
)
)
{
int ueid, i;
LOG_FUNC_IN;
......@@ -210,17 +210,14 @@ int esm_ebr_assign(unsigned int ueid, int ebi)
if (ebi != ESM_EBI_UNASSIGNED) {
if ( (ebi < ESM_EBI_MIN) || (ebi > ESM_EBI_MAX) ) {
LOG_FUNC_RETURN (ESM_EBI_UNASSIGNED);
}
else if (_esm_ebr_data[ueid].context[ebi - ESM_EBI_MIN] != NULL) {
} else if (_esm_ebr_data[ueid].context[ebi - ESM_EBI_MIN] != NULL) {
LOG_TRACE(WARNING, "ESM-FSM - EPS bearer context already "
"assigned (ebi=%d)", ebi);
LOG_FUNC_RETURN (ESM_EBI_UNASSIGNED);
}
/* The specified EPS bearer context is available */
i = ebi - ESM_EBI_MIN;
}
else
{
} else {
/* Search for an available EPS bearer identity */
i = _esm_ebr_get_available_entry(ueid);
if (i < 0) {
......@@ -232,7 +229,7 @@ int esm_ebr_assign(unsigned int ueid, int ebi)
/* Assign new EPS bearer context */
_esm_ebr_data[ueid].context[i] =
(esm_ebr_context_t*)malloc(sizeof(esm_ebr_context_t));
(esm_ebr_context_t *)malloc(sizeof(esm_ebr_context_t));
if (_esm_ebr_data[ueid].context[i] == NULL) {
LOG_FUNC_RETURN(ESM_EBI_UNASSIGNED);
}
......@@ -298,7 +295,7 @@ int esm_ebr_release(
}
/* Get EPS bearer context data */
esm_ebr_context_t* ctx = _esm_ebr_data[ueid].context[ebi - ESM_EBI_MIN];
esm_ebr_context_t *ctx = _esm_ebr_data[ueid].context[ebi - ESM_EBI_MIN];
if ( (ctx == NULL) || (ctx->ebi != ebi) ) {
/* EPS bearer context not assigned */
LOG_FUNC_RETURN (RETURNerror);
......@@ -356,7 +353,7 @@ int esm_ebr_release(
** Others: _esm_ebr_data **
** **
***************************************************************************/
int esm_ebr_start_timer( unsigned int ueid, int ebi, const OctetString* msg,
int esm_ebr_start_timer( unsigned int ueid, int ebi, const OctetString *msg,
long sec, nas_timer_callback_t cb)
{
LOG_FUNC_IN;
......@@ -369,7 +366,7 @@ int esm_ebr_start_timer( unsigned int ueid, int ebi, const OctetString* msg,
}
/* Get EPS bearer context data */
esm_ebr_context_t* ctx = _esm_ebr_data[ueid].context[ebi - ESM_EBI_MIN];
esm_ebr_context_t *ctx = _esm_ebr_data[ueid].context[ebi - ESM_EBI_MIN];
if ( (ctx == NULL) || (ctx->ebi != ebi) ) {
/* EPS bearer context not assigned */
LOG_FUNC_RETURN (RETURNerror);
......@@ -380,10 +377,9 @@ int esm_ebr_start_timer( unsigned int ueid, int ebi, const OctetString* msg,
/* Re-start the retransmission timer */
ctx->timer.id = nas_timer_restart(ctx->timer.id);
}
}
else {
} else {
/* Setup the retransmission timer parameters */
ctx->args = (esm_ebr_timer_data_t*)malloc(sizeof(esm_ebr_timer_data_t));
ctx->args = (esm_ebr_timer_data_t *)malloc(sizeof(esm_ebr_timer_data_t));
if (ctx->args) {
/* Set the UE identifier */
ctx->args->ueid = ueid;
......@@ -392,7 +388,7 @@ int esm_ebr_start_timer( unsigned int ueid, int ebi, const OctetString* msg,
/* Reset the retransmission counter */
ctx->args->count = 0;
/* Set the ESM message to be re-transmited */
ctx->args->msg.value = (uint8_t*)malloc(msg->length);
ctx->args->msg.value = (uint8_t *)malloc(msg->length);
ctx->args->msg.length = 0;
if (ctx->args->msg.value) {
memcpy(ctx->args->msg.value, msg->value, msg->length);
......@@ -441,7 +437,7 @@ int esm_ebr_stop_timer( unsigned int ueid, int ebi)
}
/* Get EPS bearer context data */
esm_ebr_context_t* ctx = _esm_ebr_data[ueid].context[ebi - ESM_EBI_MIN];
esm_ebr_context_t *ctx = _esm_ebr_data[ueid].context[ebi - ESM_EBI_MIN];
if ( (ctx == NULL) || (ctx->ebi != ebi) ) {
/* EPS bearer context not assigned */
LOG_FUNC_RETURN (RETURNerror);
......@@ -490,8 +486,12 @@ int esm_ebr_get_pending_ebi(unsigned int ueid, esm_ebr_state status)
int i;
for (i = 0; i < ESM_EBR_DATA_SIZE; i++) {
if (_esm_ebr_data[ueid].context[i] == NULL) continue;
if (_esm_ebr_data[ueid].context[i]->status != status) continue;
if (_esm_ebr_data[ueid].context[i] == NULL) {
continue;
}
if (_esm_ebr_data[ueid].context[i]->status != status) {
continue;
}
/* EPS bearer context entry found */
break;
}
......@@ -546,7 +546,7 @@ int esm_ebr_set_status(
}
/* Get EPS bearer context data */
esm_ebr_context_t* ctx = _esm_ebr_data[ueid].context[ebi - ESM_EBI_MIN];
esm_ebr_context_t *ctx = _esm_ebr_data[ueid].context[ebi - ESM_EBI_MIN];
if ( (ctx == NULL) || (ctx->ebi != ebi) ) {
/* EPS bearer context not assigned */
LOG_TRACE(ERROR, "ESM-FSM - EPS bearer context not assigned "
......@@ -692,13 +692,17 @@ static int _esm_ebr_get_available_entry(unsigned int ueid)
{
int i;
for (i = _esm_ebr_data[ueid].index; i < ESM_EBR_DATA_SIZE; i++) {
if (_esm_ebr_data[ueid].context[i] != NULL) continue;
if (_esm_ebr_data[ueid].context[i] != NULL) {
continue;
}
return i;
}
for (i = 0; i < _esm_ebr_data[ueid].index; i++) {
if (_esm_ebr_data[ueid].context[i] != NULL) continue;
if (_esm_ebr_data[ueid].context[i] != NULL) {
continue;
}
return i;
}
/* No available EBI entry found */
return (-1);
}
}
......@@ -93,12 +93,14 @@ void esm_ebr_initialize(void);
int esm_ebr_assign(unsigned int ueid, int ebi);
int esm_ebr_release(unsigned int ueid, int ebi);
int esm_ebr_start_timer(unsigned int ueid, int ebi, const OctetString* msg, long sec, nas_timer_callback_t cb);
int esm_ebr_start_timer(unsigned int ueid, int ebi, const OctetString *msg,
long sec, nas_timer_callback_t cb);
int esm_ebr_stop_timer(unsigned int ueid, int ebi);
int esm_ebr_get_pending_ebi(unsigned int ueid, esm_ebr_state status);
int esm_ebr_set_status(unsigned int ueid, int ebi, esm_ebr_state status, int ue_requested);
int esm_ebr_set_status(unsigned int ueid, int ebi, esm_ebr_state status,
int ue_requested);
esm_ebr_state esm_ebr_get_status(unsigned int ueid, int ebi);
int esm_ebr_is_not_in_use(unsigned int ueid, int ebi);
......
......@@ -39,8 +39,10 @@ Description Defines functions used to handle EPS bearer contexts.
/****************************************************************************/
#ifdef NAS_UE
static int _esm_ebr_context_check_identifiers(const network_tft_t*, const network_tft_t*);
static int _esm_ebr_context_check_precedence(const network_tft_t*, const network_tft_t*);
static int _esm_ebr_context_check_identifiers(const network_tft_t *,
const network_tft_t *);
static int _esm_ebr_context_check_precedence(const network_tft_t *,
const network_tft_t *);
#endif
/****************************************************************************/
......@@ -76,11 +78,11 @@ int esm_ebr_context_create(
unsigned int ueid,
#endif
int pid, int ebi, int is_default,
const network_qos_t* qos, const network_tft_t* tft)
const network_qos_t *qos, const network_tft_t *tft)
{
LOG_FUNC_IN;
esm_data_context_t* ctx;
esm_data_context_t *ctx;
#ifdef NAS_UE
ctx = &_esm_data;
......@@ -94,7 +96,7 @@ int esm_ebr_context_create(
#endif
int bid = ESM_DATA_EPS_BEARER_MAX;
esm_pdn_t* pdn = NULL;
esm_pdn_t *pdn = NULL;
LOG_TRACE(INFO, "ESM-PROC - Create new %s EPS bearer context (ebi=%d) "
"for PDN connection (pid=%d)",
......@@ -104,8 +106,7 @@ int esm_ebr_context_create(
if (pid != ctx->pdn[pid].pid) {
LOG_TRACE(ERROR, "ESM-PROC - PDN connection identifier %d is "
"not valid", pid);
}
else if (ctx->pdn[pid].data == NULL) {
} else if (ctx->pdn[pid].data == NULL) {
LOG_TRACE(ERROR, "ESM-PROC - PDN connection %d has not been "
"allocated", pid);
}
......@@ -113,8 +114,7 @@ int esm_ebr_context_create(
else if (ctx->n_ebrs > ESM_DATA_EPS_BEARER_TOTAL) {
LOG_TRACE(WARNING, "ESM-PROC - The total number of active EPS"
"bearers is exeeded");
}
else {
} else {
/* Get the PDN connection entry */
pdn = ctx->pdn[pid].data;
if (is_default) {
......@@ -125,11 +125,12 @@ int esm_ebr_context_create(
"is already allocated");
LOG_FUNC_RETURN (ESM_EBI_UNASSIGNED);
}
}
else {
} else {
/* Search for an available EPS bearer context entry */
for (bid = 1; bid < ESM_DATA_EPS_BEARER_MAX; bid++) {
if (pdn->bearer[bid] != NULL) continue;
if (pdn->bearer[bid] != NULL) {
continue;
}
break;
}
}
......@@ -138,7 +139,7 @@ int esm_ebr_context_create(
if (bid < ESM_DATA_EPS_BEARER_MAX) {
/* Create new EPS bearer context */
esm_bearer_t* ebr = (esm_bearer_t*)malloc(sizeof(esm_bearer_t));
esm_bearer_t *ebr = (esm_bearer_t *)malloc(sizeof(esm_bearer_t));
if (ebr != NULL) {
memset(ebr, 0 , sizeof(esm_bearer_t));
/* Increment the total number of active EPS bearers */
......@@ -156,10 +157,9 @@ int esm_ebr_context_create(
if ( (tft != NULL) && (tft->n_pkfs < NET_PACKET_FILTER_MAX) ) {
int i;
/* Traffic flow template parameters */
for (i = 0; i < tft->n_pkfs; i++)
{
for (i = 0; i < tft->n_pkfs; i++) {
ebr->tft.pkf[i] =
(network_pkf_t*)malloc(sizeof(network_pkf_t));
(network_pkf_t *)malloc(sizeof(network_pkf_t));
if (ebr->tft.pkf[i] != NULL) {
*(ebr->tft.pkf[i]) = *(tft->pkf[i]);
ebr->tft.n_pkfs += 1;
......@@ -212,11 +212,11 @@ int esm_ebr_context_release(
#ifdef NAS_MME
unsigned int ueid,
#endif
int ebi, int* pid, int* bid)
int ebi, int *pid, int *bid)
{
LOG_FUNC_IN;
esm_data_context_t* ctx;
esm_data_context_t *ctx;
#ifdef NAS_UE
ctx = &_esm_data;
......@@ -230,7 +230,7 @@ int esm_ebr_context_release(
#endif
int found = FALSE;
esm_pdn_t* pdn = NULL;
esm_pdn_t *pdn = NULL;
if (ebi != ESM_EBI_UNASSIGNED) {
/*
......@@ -241,24 +241,29 @@ int esm_ebr_context_release(
/* Search for active PDN connection */
for (*pid = 0; *pid < ESM_DATA_PDN_MAX; (*pid)++) {
if ( !ctx->pdn[*pid].is_active ) continue;
if ( !ctx->pdn[*pid].is_active ) {
continue;
}
/* An active PDN connection is found */
if (ctx->pdn[*pid].data != NULL) {
pdn = ctx->pdn[*pid].data;
/* Search for the specified EPS bearer context entry */
for (*bid = 0; *bid < pdn->n_bearers; (*bid)++) {
if (pdn->bearer[*bid] != NULL) {
if (pdn->bearer[*bid]->ebi != ebi) continue;
if (pdn->bearer[*bid]->ebi != ebi) {
continue;
}
/* The EPS bearer context entry is found */
found = TRUE;
break;
}
}
}
if (found) break;
if (found) {
break;
}
}
else {
} else {
/*
* The identity of the EPS bearer to released is not given;
* Release the EPS bearer context entry allocated with the EPS
......@@ -271,16 +276,13 @@ int esm_ebr_context_release(
if (*pid != ctx->pdn[*pid].pid) {
LOG_TRACE(ERROR, "ESM-PROC - PDN connection identifier %d "
"is not valid", *pid);
}
else if (!ctx->pdn[*pid].is_active) {
} else if (!ctx->pdn[*pid].is_active) {
LOG_TRACE(WARNING,"ESM-PROC - PDN connection %d is not active",
*pid);
}
else if (ctx->pdn[*pid].data == NULL) {
} else if (ctx->pdn[*pid].data == NULL) {
LOG_TRACE(ERROR, "ESM-PROC - PDN connection %d has not been "
"allocated", *pid);
}
else {
} else {
pdn = ctx->pdn[*pid].data;
if (pdn->bearer[*bid] != NULL) {
ebi = pdn->bearer[*bid]->ebi;
......@@ -433,9 +435,15 @@ int esm_ebr_context_get_pid(int ebi)
int pid;
for (pid = 0; pid < ESM_DATA_PDN_MAX; pid++) {
if (_esm_data.pdn[pid].data == NULL) continue;
if (_esm_data.pdn[pid].data->bearer[0] == NULL) continue;
if (_esm_data.pdn[pid].data->bearer[0]->ebi == ebi) break;
if (_esm_data.pdn[pid].data == NULL) {
continue;
}
if (_esm_data.pdn[pid].data->bearer[0] == NULL) {
continue;
}
if (_esm_data.pdn[pid].data->bearer[0]->ebi == ebi) {
break;
}
}
if (pid < ESM_DATA_PDN_MAX) {
......@@ -468,7 +476,7 @@ int esm_ebr_context_get_pid(int ebi)
** **
***************************************************************************/
int esm_ebr_context_check_tft(int pid, int ebi,
const network_tft_t* tft,
const network_tft_t *tft,
esm_ebr_context_tft_t operation)
{
LOG_FUNC_IN;
......@@ -479,13 +487,11 @@ int esm_ebr_context_check_tft(int pid, int ebi,
if (pid != _esm_data.pdn[pid].pid) {
LOG_TRACE(ERROR, "ESM-PROC - PDN connection identifier %d "
"is not valid", pid);
}
else if (_esm_data.pdn[pid].data == NULL) {
} else if (_esm_data.pdn[pid].data == NULL) {
LOG_TRACE(ERROR, "ESM-PROC - PDN connection %d has not been "
"allocated", pid);
}
else if (operation == ESM_EBR_CONTEXT_TFT_CREATE) {
esm_pdn_t* pdn = _esm_data.pdn[pid].data;
} else if (operation == ESM_EBR_CONTEXT_TFT_CREATE) {
esm_pdn_t *pdn = _esm_data.pdn[pid].data;
/* For each EPS bearer context associated to the PDN connection */
for (int i = 0; i < pdn->n_bearers; i++) {
if (pdn->bearer[i]) {
......@@ -493,12 +499,16 @@ int esm_ebr_context_check_tft(int pid, int ebi,
/* Check the packet filter identifiers */
rc = _esm_ebr_context_check_identifiers(tft,
&pdn->bearer[i]->tft);
if (rc != RETURNok) break;
if (rc != RETURNok) {
break;
}
}
/* Check the packet filter precedence values */
rc = _esm_ebr_context_check_precedence(tft,
&pdn->bearer[i]->tft);
if (rc != RETURNok) break;
if (rc != RETURNok) {
break;
}
}
}
}
......@@ -532,8 +542,8 @@ int esm_ebr_context_check_tft(int pid, int ebi,
** Others: None **
** **
***************************************************************************/
static int _esm_ebr_context_check_identifiers(const network_tft_t* tft1,
const network_tft_t* tft2)
static int _esm_ebr_context_check_identifiers(const network_tft_t *tft1,
const network_tft_t *tft2)
{
if ( (tft1 == NULL) || (tft2 == NULL) ) {
return (RETURNok);
......@@ -569,8 +579,8 @@ static int _esm_ebr_context_check_identifiers(const network_tft_t* tft1,
** Others: None **
** **
***************************************************************************/
static int _esm_ebr_context_check_precedence(const network_tft_t* tft1,
const network_tft_t* tft2)
static int _esm_ebr_context_check_precedence(const network_tft_t *tft1,
const network_tft_t *tft2)
{
if ( (tft1 == NULL) || (tft2 == NULL) ) {
return (RETURNok);
......
......@@ -50,19 +50,22 @@ typedef enum {
/****************************************************************************/
#ifdef NAS_UE
int esm_ebr_context_create(int pid, int ebi, int is_default, const network_qos_t* qos, const network_tft_t* tft);
int esm_ebr_context_create(int pid, int ebi, int is_default,
const network_qos_t *qos, const network_tft_t *tft);
int esm_ebr_context_release(int ebi, int* pid, int* bid);
int esm_ebr_context_release(int ebi, int *pid, int *bid);
int esm_ebr_context_get_pid(int ebi);
int esm_ebr_context_check_tft(int pid, int ebi, const network_tft_t* tft, esm_ebr_context_tft_t operation);
int esm_ebr_context_check_tft(int pid, int ebi, const network_tft_t *tft,
esm_ebr_context_tft_t operation);
#endif
#ifdef NAS_MME
int esm_ebr_context_create(unsigned int ueid, int pid, int ebi, int is_default, const network_qos_t* qos, const network_tft_t* tft);
int esm_ebr_context_create(unsigned int ueid, int pid, int ebi, int is_default,
const network_qos_t *qos, const network_tft_t *tft);
int esm_ebr_context_release(unsigned int ueid, int ebi, int* pid, int* bid);
int esm_ebr_context_release(unsigned int ueid, int ebi, int *pid, int *bid);
#endif
#endif /* __ESM_EBR_CONTEXT_H__ */
......@@ -3,7 +3,7 @@
char ip_addr_str[100];
inline char* esm_data_get_ipv4_addr(const OctetString* ip_addr)
inline char *esm_data_get_ipv4_addr(const OctetString *ip_addr)
{
if (ip_addr->length > 0) {
sprintf(ip_addr_str, "%u.%u.%u.%u",
......@@ -14,7 +14,7 @@ inline char* esm_data_get_ipv4_addr(const OctetString* ip_addr)
return (NULL);
}
inline char* esm_data_get_ipv6_addr(const OctetString* ip_addr)
inline char *esm_data_get_ipv6_addr(const OctetString *ip_addr)
{
if (ip_addr->length > 0) {
sprintf(ip_addr_str, "%x%.2x:%x%.2x:%x%.2x:%x%.2x",
......@@ -27,7 +27,7 @@ inline char* esm_data_get_ipv6_addr(const OctetString* ip_addr)
return (NULL);
}
inline char* esm_data_get_ipv4v6_addr(const OctetString* ip_addr)
inline char *esm_data_get_ipv4v6_addr(const OctetString *ip_addr)
{
if (ip_addr->length > 0) {
sprintf(ip_addr_str, "%u.%u.%u.%u / %x%.2x:%x%.2x:%x%.2x:%x%.2x",
......
......@@ -139,7 +139,7 @@ void esm_main_cleanup(void)
/* De-activate EPS bearers and clean up PDN connections */
for (int pid = 0; pid < ESM_DATA_PDN_MAX; pid++) {
if (_esm_data.pdn[pid].data) {
esm_pdn_t* pdn = _esm_data.pdn[pid].data;
esm_pdn_t *pdn = _esm_data.pdn[pid].data;
if (pdn->apn.length > 0) {
free(pdn->apn.value);
}
......@@ -252,7 +252,7 @@ int esm_main_has_emergency(void)
** Others: None **
** **
***************************************************************************/
int esm_main_get_pdn_status(int cid, int* state)
int esm_main_get_pdn_status(int cid, int *state)
{
LOG_FUNC_IN;
......@@ -260,12 +260,10 @@ int esm_main_get_pdn_status(int cid, int* state)
if (pid >= ESM_DATA_PDN_MAX) {
return (FALSE);
}
else if (pid != _esm_data.pdn[pid].pid) {
} else if (pid != _esm_data.pdn[pid].pid) {
LOG_TRACE(WARNING, "ESM-MAIN - PDN connection %d is not defined", cid);
return (FALSE);
}
else if (_esm_data.pdn[pid].data == NULL) {
} else if (_esm_data.pdn[pid].data == NULL) {
LOG_TRACE(ERROR, "ESM-MAIN - PDN connection %d has not been allocated",
cid);
return (FALSE);
......@@ -298,8 +296,8 @@ int esm_main_get_pdn_status(int cid, int* state)
** Others: None **
** **
***************************************************************************/
int esm_main_get_pdn(int cid, int* type, const char** apn,
int* is_emergency, int* is_active)
int esm_main_get_pdn(int cid, int *type, const char **apn,
int *is_emergency, int *is_active)
{
LOG_FUNC_IN;
......@@ -307,12 +305,10 @@ int esm_main_get_pdn(int cid, int* type, const char** apn,
if (pid >= ESM_DATA_PDN_MAX) {
return (RETURNerror);
}
else if (pid != _esm_data.pdn[pid].pid) {
} else if (pid != _esm_data.pdn[pid].pid) {
LOG_TRACE(WARNING, "ESM-MAIN - PDN connection %d is not defined", cid);
return (RETURNerror);
}
else if (_esm_data.pdn[pid].data == NULL) {
} else if (_esm_data.pdn[pid].data == NULL) {
LOG_TRACE(ERROR, "ESM-MAIN - PDN connection %d has not been allocated",
cid);
return (RETURNerror);
......@@ -322,7 +318,7 @@ int esm_main_get_pdn(int cid, int* type, const char** apn,
*type = _esm_data.pdn[pid].data->type;
/* Get the Access Point Name */
if (_esm_data.pdn[pid].data->apn.length > 0) {
*apn = (char*)(_esm_data.pdn[pid].data->apn.value);
*apn = (char *)(_esm_data.pdn[pid].data->apn.value);
} else {
*apn = NULL;
}
......@@ -350,7 +346,7 @@ int esm_main_get_pdn(int cid, int* type, const char** apn,
** Others: None **
** **
***************************************************************************/
int esm_main_get_pdn_addr(int cid, const char** ipv4addr, const char** ipv6addr)
int esm_main_get_pdn_addr(int cid, const char **ipv4addr, const char **ipv6addr)
{
LOG_FUNC_IN;
......@@ -358,17 +354,14 @@ int esm_main_get_pdn_addr(int cid, const char** ipv4addr, const char** ipv6addr)
if (pid >= ESM_DATA_PDN_MAX) {
return (RETURNerror);
}
else if (pid != _esm_data.pdn[pid].pid) {
} else if (pid != _esm_data.pdn[pid].pid) {
LOG_TRACE(WARNING, "ESM-MAIN - PDN connection %d is not defined", cid);
return (RETURNerror);
}
else if (_esm_data.pdn[pid].data == NULL) {
} else if (_esm_data.pdn[pid].data == NULL) {
LOG_TRACE(ERROR, "ESM-MAIN - PDN connection %d has not been allocated",
cid);
return (RETURNerror);
}
else if (!_esm_data.pdn[pid].is_active) {
} else if (!_esm_data.pdn[pid].is_active) {
/* No any IP address has been assigned to this PDN connection */
return (RETURNok);
}
......@@ -376,12 +369,10 @@ int esm_main_get_pdn_addr(int cid, const char** ipv4addr, const char** ipv6addr)
if (_esm_data.pdn[pid].data->type == NET_PDN_TYPE_IPV4) {
/* Get IPv4 address */
*ipv4addr = _esm_data.pdn[pid].data->ip_addr;
}
else if (_esm_data.pdn[pid].data->type == NET_PDN_TYPE_IPV6) {
} else if (_esm_data.pdn[pid].data->type == NET_PDN_TYPE_IPV6) {
/* Get IPv6 address */
*ipv6addr = _esm_data.pdn[pid].data->ip_addr;
}
else {
} else {
/* IPv4v6 dual-stack terminal */
*ipv4addr = _esm_data.pdn[pid].data->ip_addr;
*ipv6addr = _esm_data.pdn[pid].data->ip_addr+ESM_DATA_IPV4_ADDRESS_SIZE;
......
......@@ -54,9 +54,10 @@ void esm_main_cleanup(void);
int esm_main_get_nb_pdns_max(void);
int esm_main_get_nb_pdns(void);
int esm_main_has_emergency(void);
int esm_main_get_pdn_status(int cid, int* state);
int esm_main_get_pdn(int cid, int* type, const char** apn, int* is_emergency, int* is_active);
int esm_main_get_pdn_addr(int cid, const char** ipv4addr, const char** ipv6addr);
int esm_main_get_pdn_status(int cid, int *state);
int esm_main_get_pdn(int cid, int *type, const char **apn, int *is_emergency,
int *is_active);
int esm_main_get_pdn_addr(int cid, const char **ipv4addr, const char **ipv6addr);
#endif // NAS_UE
......
......@@ -65,10 +65,10 @@ typedef enum {
* or initiated by the network
*/
#ifdef NAS_UE
typedef int (*esm_proc_procedure_t) (int, int, OctetString*, int);
typedef int (*esm_proc_procedure_t) (int, int, OctetString *, int);
#endif
#ifdef NAS_MME
typedef int (*esm_proc_procedure_t) (int, unsigned int, int, OctetString*, int);
typedef int (*esm_proc_procedure_t) (int, unsigned int, int, OctetString *, int);
#endif
/* EPS bearer level QoS parameters */
......@@ -100,13 +100,15 @@ typedef struct {
* --------------------------------------------------------------------------
*/
#ifdef NAS_UE
int esm_proc_status_ind(int pti, int ebi, int* esm_cause);
int esm_proc_status(int is_standalone, int pti, OctetString* msg, int sent_by_ue);
int esm_proc_status_ind(int pti, int ebi, int *esm_cause);
int esm_proc_status(int is_standalone, int pti, OctetString *msg,
int sent_by_ue);
#endif
#ifdef NAS_MME
int esm_proc_status_ind(unsigned int ueid, int pti, int ebi, int* esm_cause);
int esm_proc_status(int is_standalone, unsigned int ueid, int pti, OctetString* msg, int sent_by_ue);
int esm_proc_status_ind(unsigned int ueid, int pti, int ebi, int *esm_cause);
int esm_proc_status(int is_standalone, unsigned int ueid, int pti,
OctetString *msg, int sent_by_ue);
#endif
......@@ -116,18 +118,26 @@ int esm_proc_status(int is_standalone, unsigned int ueid, int pti, OctetString*
* --------------------------------------------------------------------------
*/
#ifdef NAS_UE
int esm_proc_pdn_connectivity(int cid, int to_define, esm_proc_pdn_type_t pdn_type, const OctetString* apn, int is_emergency, unsigned int* pti);
int esm_proc_pdn_connectivity_request(int is_standalone, int pti, OctetString* msg, int sent_by_ue);
int esm_proc_pdn_connectivity_accept(int pti, esm_proc_pdn_type_t pdn_type, const OctetString* pdn_address, const OctetString* apn, int* esm_cause);
int esm_proc_pdn_connectivity_reject(int pti, int* esm_cause);
int esm_proc_pdn_connectivity(int cid, int to_define,
esm_proc_pdn_type_t pdn_type, const OctetString *apn, int is_emergency,
unsigned int *pti);
int esm_proc_pdn_connectivity_request(int is_standalone, int pti,
OctetString *msg, int sent_by_ue);
int esm_proc_pdn_connectivity_accept(int pti, esm_proc_pdn_type_t pdn_type,
const OctetString *pdn_address, const OctetString *apn, int *esm_cause);
int esm_proc_pdn_connectivity_reject(int pti, int *esm_cause);
int esm_proc_pdn_connectivity_complete(void);
int esm_proc_pdn_connectivity_failure(int is_pending);
#endif
#ifdef NAS_MME
int esm_proc_pdn_connectivity_request(unsigned int ueid, int pti, esm_proc_pdn_request_t request_type, OctetString* apn, esm_proc_pdn_type_t pdn_type, OctetString* pdn_addr, esm_proc_qos_t* esm_qos, int* esm_cause);
int esm_proc_pdn_connectivity_request(unsigned int ueid, int pti,
esm_proc_pdn_request_t request_type, OctetString *apn,
esm_proc_pdn_type_t pdn_type, OctetString *pdn_addr, esm_proc_qos_t *esm_qos,
int *esm_cause);
int esm_proc_pdn_connectivity_reject(int is_standalone, unsigned int ueid, int ebi, OctetString* msg, int ue_triggered);
int esm_proc_pdn_connectivity_reject(int is_standalone, unsigned int ueid,
int ebi, OctetString *msg, int ue_triggered);
int esm_proc_pdn_connectivity_failure(unsigned int ueid, int pid);
#endif
......@@ -137,18 +147,20 @@ int esm_proc_pdn_connectivity_failure(unsigned int ueid, int pid);
* --------------------------------------------------------------------------
*/
#ifdef NAS_UE
int esm_proc_pdn_disconnect(int cid, unsigned int* pti, unsigned int* ebi);
int esm_proc_pdn_disconnect_request(int is_standalone, int pti, OctetString* msg, int sent_by_ue);
int esm_proc_pdn_disconnect(int cid, unsigned int *pti, unsigned int *ebi);
int esm_proc_pdn_disconnect_request(int is_standalone, int pti,
OctetString *msg, int sent_by_ue);
int esm_proc_pdn_disconnect_accept(int pti, int* esm_cause);
int esm_proc_pdn_disconnect_reject(int pti, int* esm_cause);
int esm_proc_pdn_disconnect_accept(int pti, int *esm_cause);
int esm_proc_pdn_disconnect_reject(int pti, int *esm_cause);
#endif
#ifdef NAS_MME
int esm_proc_pdn_disconnect_request(unsigned int ueid, int pti, int* esm_cause);
int esm_proc_pdn_disconnect_request(unsigned int ueid, int pti, int *esm_cause);
int esm_proc_pdn_disconnect_accept(unsigned int ueid, int pid, int* esm_cause);
int esm_proc_pdn_disconnect_reject(int is_standalone, unsigned int ueid, int ebi, OctetString* msg, int ue_triggered);
int esm_proc_pdn_disconnect_accept(unsigned int ueid, int pid, int *esm_cause);
int esm_proc_pdn_disconnect_reject(int is_standalone, unsigned int ueid,
int ebi, OctetString *msg, int ue_triggered);
#endif
/*
......@@ -157,21 +169,28 @@ int esm_proc_pdn_disconnect_reject(int is_standalone, unsigned int ueid, int ebi
* --------------------------------------------------------------------------
*/
#ifdef NAS_MME
int esm_proc_default_eps_bearer_context(unsigned int ueid, int pid, unsigned int* ebi, const esm_proc_qos_t* esm_qos, int* esm_cause);
int esm_proc_default_eps_bearer_context_request(int is_standalone, unsigned int ueid, int ebi, OctetString* msg, int ue_triggered);
int esm_proc_default_eps_bearer_context(unsigned int ueid, int pid,
unsigned int *ebi, const esm_proc_qos_t *esm_qos, int *esm_cause);
int esm_proc_default_eps_bearer_context_request(int is_standalone,
unsigned int ueid, int ebi, OctetString *msg, int ue_triggered);
int esm_proc_default_eps_bearer_context_failure(unsigned int ueid);
int esm_proc_default_eps_bearer_context_accept(unsigned int ueid, int ebi, int* esm_cause);
int esm_proc_default_eps_bearer_context_reject(unsigned int ueid, int ebi, int* esm_cause);
int esm_proc_default_eps_bearer_context_accept(unsigned int ueid, int ebi,
int *esm_cause);
int esm_proc_default_eps_bearer_context_reject(unsigned int ueid, int ebi,
int *esm_cause);
#endif
#ifdef NAS_UE
int esm_proc_default_eps_bearer_context_request(int pid, int ebi, const esm_proc_qos_t* esm_qos, int* esm_cause);
int esm_proc_default_eps_bearer_context_request(int pid, int ebi,
const esm_proc_qos_t *esm_qos, int *esm_cause);
int esm_proc_default_eps_bearer_context_complete(void);
int esm_proc_default_eps_bearer_context_failure(void);
int esm_proc_default_eps_bearer_context_accept(int is_standalone, int ebi, OctetString* msg, int ue_triggered);
int esm_proc_default_eps_bearer_context_reject(int is_standalone, int ebi, OctetString* msg, int ue_triggered);
int esm_proc_default_eps_bearer_context_accept(int is_standalone, int ebi,
OctetString *msg, int ue_triggered);
int esm_proc_default_eps_bearer_context_reject(int is_standalone, int ebi,
OctetString *msg, int ue_triggered);
#endif
/*
......@@ -180,18 +199,26 @@ int esm_proc_default_eps_bearer_context_reject(int is_standalone, int ebi, Octet
* --------------------------------------------------------------------------
*/
#ifdef NAS_MME
int esm_proc_dedicated_eps_bearer_context(unsigned int ueid, int pid, unsigned int* ebi, unsigned int* default_ebi, const esm_proc_qos_t* qos, const esm_proc_tft_t* tft, int* esm_cause);
int esm_proc_dedicated_eps_bearer_context_request(int is_standalone, unsigned int ueid, int ebi, OctetString* msg, int ue_triggered);
int esm_proc_dedicated_eps_bearer_context(unsigned int ueid, int pid,
unsigned int *ebi, unsigned int *default_ebi, const esm_proc_qos_t *qos,
const esm_proc_tft_t *tft, int *esm_cause);
int esm_proc_dedicated_eps_bearer_context_request(int is_standalone,
unsigned int ueid, int ebi, OctetString *msg, int ue_triggered);
int esm_proc_dedicated_eps_bearer_context_accept(unsigned int ueid, int ebi, int* esm_cause);
int esm_proc_dedicated_eps_bearer_context_reject(unsigned int ueid, int ebi, int* esm_cause);
int esm_proc_dedicated_eps_bearer_context_accept(unsigned int ueid, int ebi,
int *esm_cause);
int esm_proc_dedicated_eps_bearer_context_reject(unsigned int ueid, int ebi,
int *esm_cause);
#endif
#ifdef NAS_UE
int esm_proc_dedicated_eps_bearer_context_request(int ebi, int default_ebi, const esm_proc_qos_t* qos, const esm_proc_tft_t* tft, int* esm_cause);
int esm_proc_dedicated_eps_bearer_context_request(int ebi, int default_ebi,
const esm_proc_qos_t *qos, const esm_proc_tft_t *tft, int *esm_cause);
int esm_proc_dedicated_eps_bearer_context_accept(int is_standalone, int ebi, OctetString* msg, int ue_triggered);
int esm_proc_dedicated_eps_bearer_context_reject(int is_standalone, int ebi, OctetString* msg, int ue_triggered);
int esm_proc_dedicated_eps_bearer_context_accept(int is_standalone, int ebi,
OctetString *msg, int ue_triggered);
int esm_proc_dedicated_eps_bearer_context_reject(int is_standalone, int ebi,
OctetString *msg, int ue_triggered);
#endif
/*
......@@ -200,17 +227,22 @@ int esm_proc_dedicated_eps_bearer_context_reject(int is_standalone, int ebi, Oct
* --------------------------------------------------------------------------
*/
#ifdef NAS_MME
int esm_proc_eps_bearer_context_deactivate(unsigned int ueid, int is_local, int ebi, int* pid, int* bid, int* esm_cause);
int esm_proc_eps_bearer_context_deactivate_request(int is_standalone, unsigned int ueid, int ebi, OctetString* msg, int ue_triggered);
int esm_proc_eps_bearer_context_deactivate(unsigned int ueid, int is_local,
int ebi, int *pid, int *bid, int *esm_cause);
int esm_proc_eps_bearer_context_deactivate_request(int is_standalone,
unsigned int ueid, int ebi, OctetString *msg, int ue_triggered);
int esm_proc_eps_bearer_context_deactivate_accept(unsigned int ueid, int ebi, int* esm_cause);
int esm_proc_eps_bearer_context_deactivate_accept(unsigned int ueid, int ebi,
int *esm_cause);
#endif
#ifdef NAS_UE
int esm_proc_eps_bearer_context_deactivate(int is_local, int ebi, int* pid, int* bid);
int esm_proc_eps_bearer_context_deactivate_request(int ebi, int* esm_cause);
int esm_proc_eps_bearer_context_deactivate(int is_local, int ebi, int *pid,
int *bid);
int esm_proc_eps_bearer_context_deactivate_request(int ebi, int *esm_cause);
int esm_proc_eps_bearer_context_deactivate_accept(int is_standalone, int ebi, OctetString* msg, int ue_triggered);
int esm_proc_eps_bearer_context_deactivate_accept(int is_standalone, int ebi,
OctetString *msg, int ue_triggered);
#endif
#endif /* __ESM_PROC_H__*/
......@@ -46,7 +46,7 @@ Description Defines functions used to handle ESM procedure transactions.
#ifdef NAS_UE
/* String representation of ESM procedure transaction status */
static const char* _esm_pt_state_str[ESM_PT_STATE_MAX] = {
static const char *_esm_pt_state_str[ESM_PT_STATE_MAX] = {
"PROCEDURE TRANSACTION INACTIVE",
"PROCEDURE TRANSACTION PENDING"
};
......@@ -60,7 +60,7 @@ typedef struct {
unsigned char pti; /* Procedure transaction identity */
esm_pt_state status; /* Procedure transaction status */
struct nas_timer_t timer; /* Retransmission timer */
esm_pt_timer_data_t* args; /* Retransmission timer parameters data */
esm_pt_timer_data_t *args; /* Retransmission timer parameters data */
} esm_pt_context_t;
/*
......@@ -72,7 +72,7 @@ static struct {
unsigned char index; /* Index of the next procedure transaction
* identity to be used */
#define ESM_PT_DATA_SIZE (ESM_PTI_MAX - ESM_PTI_MIN + 1)
esm_pt_context_t* context[ESM_PT_DATA_SIZE + 1];
esm_pt_context_t *context[ESM_PT_DATA_SIZE + 1];
} _esm_pt_data;
/* Return the index of the next available entry in the list of procedure
......@@ -139,7 +139,7 @@ int esm_pt_assign(void)
/* Assign new procedure transaction */
_esm_pt_data.context[i] =
(esm_pt_context_t*)malloc(sizeof(esm_pt_context_t));
(esm_pt_context_t *)malloc(sizeof(esm_pt_context_t));
if (_esm_pt_data.context[i] == NULL) {
LOG_FUNC_RETURN (ESM_PT_UNASSIGNED);
}
......@@ -187,7 +187,7 @@ int esm_pt_release(int pti)
}
/* Get procedure transaction data */
esm_pt_context_t* ctx = _esm_pt_data.context[pti - ESM_PTI_MIN];
esm_pt_context_t *ctx = _esm_pt_data.context[pti - ESM_PTI_MIN];
if ( (ctx == NULL) || (ctx->pti != pti) ) {
/* Procedure transaction not assigned */
LOG_FUNC_RETURN (RETURNerror);
......@@ -242,7 +242,7 @@ int esm_pt_release(int pti)
** Others: _esm_pt_data **
** **
***************************************************************************/
int esm_pt_start_timer(int pti, const OctetString* msg,
int esm_pt_start_timer(int pti, const OctetString *msg,
long sec, nas_timer_callback_t cb)
{
LOG_FUNC_IN;
......@@ -252,7 +252,7 @@ int esm_pt_start_timer(int pti, const OctetString* msg,
}
/* Get procedure transaction data */
esm_pt_context_t* ctx = _esm_pt_data.context[pti - ESM_PTI_MIN];
esm_pt_context_t *ctx = _esm_pt_data.context[pti - ESM_PTI_MIN];
if ( (ctx == NULL) || (ctx->pti != pti) ) {
/* Procedure transaction not assigned */
LOG_FUNC_RETURN (RETURNerror);
......@@ -263,17 +263,16 @@ int esm_pt_start_timer(int pti, const OctetString* msg,
/* Re-start the retransmission timer */
ctx->timer.id = nas_timer_restart(ctx->timer.id);
}
}
else {
} else {
/* Setup the retransmission timer parameters */
ctx->args = (esm_pt_timer_data_t*)malloc(sizeof(esm_pt_timer_data_t));
ctx->args = (esm_pt_timer_data_t *)malloc(sizeof(esm_pt_timer_data_t));
if (ctx->args) {
/* Set the EPS bearer identity */
ctx->args->pti = pti;
/* Reset the retransmission counter */
ctx->args->count = 0;
/* Set the ESM message to be re-transmited */
ctx->args->msg.value = (uint8_t*)malloc(msg->length);
ctx->args->msg.value = (uint8_t *)malloc(msg->length);
ctx->args->msg.length = 0;
if (ctx->args->msg.value) {
memcpy(ctx->args->msg.value, msg->value, msg->length);
......@@ -318,7 +317,7 @@ int esm_pt_stop_timer(int pti)
}
/* Get procedure transaction data */
esm_pt_context_t* ctx = _esm_pt_data.context[pti - ESM_PTI_MIN];
esm_pt_context_t *ctx = _esm_pt_data.context[pti - ESM_PTI_MIN];
if ( (ctx == NULL) || (ctx->pti != pti) ) {
/* Procedure transaction not assigned */
LOG_FUNC_RETURN (RETURNerror);
......@@ -370,7 +369,7 @@ int esm_pt_set_status(int pti, esm_pt_state status)
}
/* Get procedure transaction data */
esm_pt_context_t* ctx = _esm_pt_data.context[pti - ESM_PTI_MIN];
esm_pt_context_t *ctx = _esm_pt_data.context[pti - ESM_PTI_MIN];
if ( (ctx == NULL) || (ctx->pti != pti) ) {
/* Procedure transaction not assigned */
LOG_TRACE(ERROR, "ESM-FSM - Procedure transaction not assigned "
......@@ -448,8 +447,12 @@ int esm_pt_get_pending_pti(esm_pt_state status)
int i;
for (i = 0; i < ESM_PT_DATA_SIZE; i++) {
if (_esm_pt_data.context[i] == NULL) continue;
if (_esm_pt_data.context[i]->status != status) continue;
if (_esm_pt_data.context[i] == NULL) {
continue;
}
if (_esm_pt_data.context[i]->status != status) {
continue;
}
/* PDN connection entry found */
break;
}
......@@ -530,14 +533,18 @@ static int _esm_pt_get_available_entry(void)
{
int i;
for (i = _esm_pt_data.index; i < ESM_PT_DATA_SIZE; i++) {
if (_esm_pt_data.context[i] != NULL) continue;
if (_esm_pt_data.context[i] != NULL) {
continue;
}
return i;
}
for (i = 0; i < _esm_pt_data.index; i++) {
if (_esm_pt_data.context[i] != NULL) continue;
if (_esm_pt_data.context[i] != NULL) {
continue;
}
return i;
}
/* No available PTI entry found */
return (-1);
}
}
#endif // NAS_UE
......@@ -71,7 +71,8 @@ void esm_pt_initialize(void);
int esm_pt_assign(void);
int esm_pt_release(int pti);
int esm_pt_start_timer(int pti, const OctetString* msg, long sec, nas_timer_callback_t cb);
int esm_pt_start_timer(int pti, const OctetString *msg, long sec,
nas_timer_callback_t cb);
int esm_pt_stop_timer(int pti);
int esm_pt_set_status(int pti, esm_pt_state status);
......
......@@ -71,11 +71,11 @@ Description Defines functions executed at the ESM Service Access
** **
***************************************************************************/
#ifdef NAS_UE
int esm_recv_status(int pti, int ebi, const esm_status_msg* msg)
int esm_recv_status(int pti, int ebi, const esm_status_msg *msg)
#endif
#ifdef NAS_MME
int esm_recv_status(unsigned int ueid, int pti, int ebi,
const esm_status_msg* msg)
const esm_status_msg *msg)
#endif
{
LOG_FUNC_IN;
......@@ -131,7 +131,7 @@ int esm_recv_status(unsigned int ueid, int pti, int ebi,
** **
***************************************************************************/
int esm_recv_pdn_connectivity_reject(int pti, int ebi,
const pdn_connectivity_reject_msg* msg)
const pdn_connectivity_reject_msg *msg)
{
LOG_FUNC_IN;
......@@ -149,8 +149,7 @@ int esm_recv_pdn_connectivity_reject(int pti, int ebi,
*/
LOG_TRACE(WARNING, "ESM-SAP - Invalid PTI value (pti=%d)", pti);
LOG_FUNC_RETURN (ESM_CAUSE_INVALID_PTI_VALUE);
}
else if ( esm_pt_is_not_in_use(pti) ) {
} else if ( esm_pt_is_not_in_use(pti) ) {
/* 3GPP TS 24.301, section 7.3.1, case a
* Assigned value that does not match any PTI in use
*/
......@@ -202,7 +201,7 @@ int esm_recv_pdn_connectivity_reject(int pti, int ebi,
** **
***************************************************************************/
int esm_recv_pdn_disconnect_reject(int pti, int ebi,
const pdn_disconnect_reject_msg* msg)
const pdn_disconnect_reject_msg *msg)
{
LOG_FUNC_IN;
......@@ -220,8 +219,7 @@ int esm_recv_pdn_disconnect_reject(int pti, int ebi,
*/
LOG_TRACE(WARNING, "ESM-SAP - Invalid PTI value (pti=%d)", pti);
LOG_FUNC_RETURN (ESM_CAUSE_INVALID_PTI_VALUE);
}
else if ( esm_pt_is_not_in_use(pti) ) {
} else if ( esm_pt_is_not_in_use(pti) ) {
/* 3GPP TS 24.301, section 7.3.1, case b
* Assigned value that does not match any PTI in use
*/
......@@ -274,7 +272,7 @@ int esm_recv_pdn_disconnect_reject(int pti, int ebi,
** **
***************************************************************************/
int esm_recv_activate_default_eps_bearer_context_request(int pti, int ebi,
const activate_default_eps_bearer_context_request_msg* msg)
const activate_default_eps_bearer_context_request_msg *msg)
{
LOG_FUNC_IN;
......@@ -292,8 +290,7 @@ int esm_recv_activate_default_eps_bearer_context_request(int pti, int ebi,
*/
LOG_TRACE(WARNING, "ESM-SAP - Invalid PTI value (pti=%d)", pti);
LOG_FUNC_RETURN (ESM_CAUSE_INVALID_PTI_VALUE);
}
else if ( esm_pt_is_not_in_use(pti) ) {
} else if ( esm_pt_is_not_in_use(pti) ) {
/* 3GPP TS 24.301, section 7.3.1, case g
* Assigned value that does not match any PTI in use
*/
......@@ -322,8 +319,7 @@ int esm_recv_activate_default_eps_bearer_context_request(int pti, int ebi,
eps_qos_bit_rate_ext_value(msg->epsqos.bitRatesExt.maxBitRateForUL);
qos.mbrDL =
eps_qos_bit_rate_ext_value(msg->epsqos.bitRatesExt.maxBitRateForDL);
}
else if (msg->epsqos.bitRatesPresent) {
} else if (msg->epsqos.bitRatesPresent) {
qos.mbrUL =
eps_qos_bit_rate_value(msg->epsqos.bitRates.maxBitRateForUL);
qos.mbrDL =
......@@ -335,8 +331,7 @@ int esm_recv_activate_default_eps_bearer_context_request(int pti, int ebi,
eps_qos_bit_rate_ext_value(msg->epsqos.bitRatesExt.guarBitRateForUL);
qos.gbrDL =
eps_qos_bit_rate_ext_value(msg->epsqos.bitRatesExt.guarBitRateForDL);
}
else if (msg->epsqos.bitRatesPresent) {
} else if (msg->epsqos.bitRatesPresent) {
qos.gbrUL =
eps_qos_bit_rate_value(msg->epsqos.bitRates.guarBitRateForUL);
qos.gbrDL =
......@@ -354,7 +349,8 @@ int esm_recv_activate_default_eps_bearer_context_request(int pti, int ebi,
pdn_type = ESM_PDN_TYPE_IPV4V6;
}
/* Get the ESM cause */
if (msg->presencemask & ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_ESM_CAUSE_PRESENT) {
if (msg->presencemask &
ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_ESM_CAUSE_PRESENT) {
/* The network allocated a PDN address of a PDN type which is different
* from the requested PDN type */
esm_cause = msg->esmcause;
......@@ -398,7 +394,7 @@ int esm_recv_activate_default_eps_bearer_context_request(int pti, int ebi,
** **
***************************************************************************/
int esm_recv_activate_dedicated_eps_bearer_context_request(int pti, int ebi,
const activate_dedicated_eps_bearer_context_request_msg* msg)
const activate_dedicated_eps_bearer_context_request_msg *msg)
{
LOG_FUNC_IN;
......@@ -416,8 +412,7 @@ int esm_recv_activate_dedicated_eps_bearer_context_request(int pti, int ebi,
*/
LOG_TRACE(WARNING, "ESM-SAP - Invalid PTI value (pti=%d)", pti);
LOG_FUNC_RETURN (ESM_CAUSE_INVALID_PTI_VALUE);
}
else if ( (pti != ESM_PT_UNASSIGNED) && esm_pt_is_not_in_use(pti) ) {
} else if ( (pti != ESM_PT_UNASSIGNED) && esm_pt_is_not_in_use(pti) ) {
/* 3GPP TS 24.301, section 7.3.1, case i
* Assigned value that does not match any PTI in use
*/
......@@ -443,8 +438,7 @@ int esm_recv_activate_dedicated_eps_bearer_context_request(int pti, int ebi,
* Semantic errors in TFT operations
*/
LOG_FUNC_RETURN (ESM_CAUSE_SEMANTIC_ERROR_IN_THE_TFT_OPERATION);
}
else if (msg->tft.numberofpacketfilters == 0) {
} else if (msg->tft.numberofpacketfilters == 0) {
/* 3GPP TS 24.301, section 6.4.2.4, case b1
* Syntactical errors in TFT operations
*/
......@@ -462,8 +456,7 @@ int esm_recv_activate_dedicated_eps_bearer_context_request(int pti, int ebi,
eps_qos_bit_rate_ext_value(msg->epsqos.bitRatesExt.maxBitRateForUL);
qos.mbrDL =
eps_qos_bit_rate_ext_value(msg->epsqos.bitRatesExt.maxBitRateForDL);
}
else if (msg->epsqos.bitRatesPresent) {
} else if (msg->epsqos.bitRatesPresent) {
qos.mbrUL =
eps_qos_bit_rate_value(msg->epsqos.bitRates.maxBitRateForUL);
qos.mbrDL =
......@@ -475,8 +468,7 @@ int esm_recv_activate_dedicated_eps_bearer_context_request(int pti, int ebi,
eps_qos_bit_rate_ext_value(msg->epsqos.bitRatesExt.guarBitRateForUL);
qos.gbrDL =
eps_qos_bit_rate_ext_value(msg->epsqos.bitRatesExt.guarBitRateForDL);
}
else if (msg->epsqos.bitRatesPresent) {
} else if (msg->epsqos.bitRatesPresent) {
qos.gbrUL =
eps_qos_bit_rate_value(msg->epsqos.bitRates.guarBitRateForUL);
qos.gbrDL =
......@@ -488,13 +480,11 @@ int esm_recv_activate_dedicated_eps_bearer_context_request(int pti, int ebi,
/* Processing of the traffic flow template parameters */
esm_proc_tft_t tft = {0, {NULL}};
/* Get the list of packet filters */
const PacketFilters* pkfs = &(msg->tft.packetfilterlist.createtft);
for (int i = 0; i < msg->tft.numberofpacketfilters; i++)
{
const PacketFilters *pkfs = &(msg->tft.packetfilterlist.createtft);
for (int i = 0; i < msg->tft.numberofpacketfilters; i++) {
/* Create new temporary packet filter */
tft.pkf[i] = (network_pkf_t*)malloc(sizeof(network_pkf_t));
if (tft.pkf[i] != NULL)
{
tft.pkf[i] = (network_pkf_t *)malloc(sizeof(network_pkf_t));
if (tft.pkf[i] != NULL) {
/* Initialize the temporary packet filter */
memset(tft.pkf[i], 0, sizeof(network_pkf_t));
/* Increment the number of packet filters contained in the TFT */
......@@ -507,19 +497,20 @@ int esm_recv_activate_dedicated_eps_bearer_context_request(int pti, int ebi,
tft.pkf[i]->precedence = pkfs[i]->eval_precedence;
/* Get the packet filter components */
const PacketFilter* pkf = &(pkfs[i]->packetfilter);
const PacketFilter *pkf = &(pkfs[i]->packetfilter);
if (pkf->flags & TRAFFIC_FLOW_TEMPLATE_IPV4_REMOTE_ADDR_FLAG) {
/* IPv4 remote address component */
for (int j = 0; (j < TRAFFIC_FLOW_TEMPLATE_IPV4_ADDR_SIZE) && (j < NET_PACKET_FILTER_IPV4_ADDR_SIZE); j++)
{
for (int j = 0;
(j < TRAFFIC_FLOW_TEMPLATE_IPV4_ADDR_SIZE)
&& (j < NET_PACKET_FILTER_IPV4_ADDR_SIZE); j++) {
tft.pkf[i]->data.ipv4.addr[j] = pkf->ipv4remoteaddr[j].addr;
tft.pkf[i]->data.ipv4.mask[j] = pkf->ipv4remoteaddr[j].mask;
}
}
else if (pkf->flags & TRAFFIC_FLOW_TEMPLATE_IPV6_REMOTE_ADDR_FLAG) {
} else if (pkf->flags & TRAFFIC_FLOW_TEMPLATE_IPV6_REMOTE_ADDR_FLAG) {
/* IPv6 remote address component */
for (int j = 0; (j < TRAFFIC_FLOW_TEMPLATE_IPV6_ADDR_SIZE) && (j < NET_PACKET_FILTER_IPV6_ADDR_SIZE); j++)
{
for (int j = 0;
(j < TRAFFIC_FLOW_TEMPLATE_IPV6_ADDR_SIZE)
&& (j < NET_PACKET_FILTER_IPV6_ADDR_SIZE); j++) {
tft.pkf[i]->data.ipv6.addr[j] = pkf->ipv6remoteaddr[j].addr;
tft.pkf[i]->data.ipv6.mask[j] = pkf->ipv6remoteaddr[j].mask;
}
......@@ -532,8 +523,7 @@ int esm_recv_activate_dedicated_eps_bearer_context_request(int pti, int ebi,
if (pkf->flags & TRAFFIC_FLOW_TEMPLATE_SINGLE_LOCAL_PORT_FLAG) {
/* Single local port component */
tft.pkf[i]->lport = pkf->singlelocalport;
}
else if (pkf->flags & TRAFFIC_FLOW_TEMPLATE_LOCAL_PORT_RANGE_FLAG) {
} else if (pkf->flags & TRAFFIC_FLOW_TEMPLATE_LOCAL_PORT_RANGE_FLAG) {
/* Local port range component */
/* TODO: Add port range type to network_pkf_t in networkDef.h */
tft.pkf[i]->lport = pkf->localportrange.lowlimit;
......@@ -541,9 +531,7 @@ int esm_recv_activate_dedicated_eps_bearer_context_request(int pti, int ebi,
if (pkf->flags & TRAFFIC_FLOW_TEMPLATE_SINGLE_REMOTE_PORT_FLAG) {
/* Single remote port component */
tft.pkf[i]->rport = pkf->singleremoteport;
}
else if (pkf->flags & TRAFFIC_FLOW_TEMPLATE_REMOTE_PORT_RANGE_FLAG)
{
} else if (pkf->flags & TRAFFIC_FLOW_TEMPLATE_REMOTE_PORT_RANGE_FLAG) {
/* Remote port range component */
/* TODO: Add port range type to network_pkf_t in networkDef.h */
tft.pkf[i]->rport = pkf->remoteportrange.lowlimit;
......@@ -597,7 +585,7 @@ int esm_recv_activate_dedicated_eps_bearer_context_request(int pti, int ebi,
** **
***************************************************************************/
int esm_recv_deactivate_eps_bearer_context_request(int pti, int ebi,
const deactivate_eps_bearer_context_request_msg* msg)
const deactivate_eps_bearer_context_request_msg *msg)
{
LOG_FUNC_IN;
......@@ -616,8 +604,7 @@ int esm_recv_deactivate_eps_bearer_context_request(int pti, int ebi,
*/
LOG_TRACE(WARNING, "ESM-SAP - Invalid PTI value (pti=%d)", pti);
LOG_FUNC_RETURN (ESM_CAUSE_INVALID_PTI_VALUE);
}
else if ( esm_pt_is_not_in_use(pti) ) {
} else if ( esm_pt_is_not_in_use(pti) ) {
/* 3GPP TS 24.301, section 7.3.1, case m
* Assigned value does not match any PTI in use
*/
......@@ -690,8 +677,8 @@ int esm_recv_deactivate_eps_bearer_context_request(int pti, int ebi,
** **
***************************************************************************/
int esm_recv_pdn_connectivity_request(unsigned int ueid, int pti, int ebi,
const pdn_connectivity_request_msg* msg,
unsigned int* new_ebi, void* data)
const pdn_connectivity_request_msg *msg,
unsigned int *new_ebi, void *data)
{
LOG_FUNC_IN;
......@@ -725,7 +712,7 @@ int esm_recv_pdn_connectivity_request(unsigned int ueid, int pti, int ebi,
* Message processing
*/
/* Get PDN connection and EPS bearer context data structure to setup */
esm_proc_data_t* esm_data = (esm_proc_data_t*)(data);
esm_proc_data_t *esm_data = (esm_proc_data_t *)(data);
if (data == NULL) {
LOG_TRACE(ERROR, "ESM-SAP - Invalid ESM data structure");
LOG_FUNC_RETURN (ESM_CAUSE_PROTOCOL_ERROR);
......@@ -755,14 +742,13 @@ int esm_recv_pdn_connectivity_request(unsigned int ueid, int pti, int ebi,
}
/* Get the Access Point Name, if provided */
if (msg->presencemask & PDN_CONNECTIVITY_REQUEST_ACCESS_POINT_NAME_PRESENT)
{
if (msg->presencemask & PDN_CONNECTIVITY_REQUEST_ACCESS_POINT_NAME_PRESENT) {
esm_data->apn = msg->accesspointname.accesspointnamevalue;
}
/* Get the ESM information transfer flag */
if (msg->presencemask & PDN_CONNECTIVITY_REQUEST_ESM_INFORMATION_TRANSFER_FLAG_PRESENT)
{
if (msg->presencemask &
PDN_CONNECTIVITY_REQUEST_ESM_INFORMATION_TRANSFER_FLAG_PRESENT) {
/* 3GPP TS 24.301, sections 6.5.1.2, 6.5.1.3
* ESM information, i.e. protocol configuration options, APN, or both,
* has to be sent after the NAS signalling security has been activated
......@@ -819,8 +805,8 @@ int esm_recv_pdn_connectivity_request(unsigned int ueid, int pti, int ebi,
** **
***************************************************************************/
int esm_recv_pdn_disconnect_request(unsigned int ueid, int pti, int ebi,
const pdn_disconnect_request_msg* msg,
unsigned int* linked_ebi)
const pdn_disconnect_request_msg *msg,
unsigned int *linked_ebi)
{
LOG_FUNC_IN;
......@@ -894,7 +880,7 @@ int esm_recv_pdn_disconnect_request(unsigned int ueid, int pti, int ebi,
***************************************************************************/
int esm_recv_activate_default_eps_bearer_context_accept(unsigned int ueid,
int pti, int ebi,
const activate_default_eps_bearer_context_accept_msg* msg)
const activate_default_eps_bearer_context_accept_msg *msg)
{
LOG_FUNC_IN;
......@@ -960,7 +946,7 @@ int esm_recv_activate_default_eps_bearer_context_accept(unsigned int ueid,
***************************************************************************/
int esm_recv_activate_default_eps_bearer_context_reject(unsigned int ueid,
int pti, int ebi,
const activate_default_eps_bearer_context_reject_msg* msg)
const activate_default_eps_bearer_context_reject_msg *msg)
{
LOG_FUNC_IN;
......@@ -1026,7 +1012,7 @@ int esm_recv_activate_default_eps_bearer_context_reject(unsigned int ueid,
***************************************************************************/
int esm_recv_activate_dedicated_eps_bearer_context_accept(unsigned int ueid,
int pti, int ebi,
const activate_dedicated_eps_bearer_context_accept_msg* msg)
const activate_dedicated_eps_bearer_context_accept_msg *msg)
{
LOG_FUNC_IN;
......@@ -1094,7 +1080,7 @@ int esm_recv_activate_dedicated_eps_bearer_context_accept(unsigned int ueid,
***************************************************************************/
int esm_recv_activate_dedicated_eps_bearer_context_reject(unsigned int ueid,
int pti, int ebi,
const activate_dedicated_eps_bearer_context_reject_msg* msg)
const activate_dedicated_eps_bearer_context_reject_msg *msg)
{
LOG_FUNC_IN;
......@@ -1161,7 +1147,7 @@ int esm_recv_activate_dedicated_eps_bearer_context_reject(unsigned int ueid,
***************************************************************************/
int esm_recv_deactivate_eps_bearer_context_accept(unsigned int ueid,
int pti, int ebi,
const deactivate_eps_bearer_context_accept_msg* msg)
const deactivate_eps_bearer_context_accept_msg *msg)
{
LOG_FUNC_IN;
......
......@@ -77,10 +77,11 @@ Description Defines functions executed at the ESM Service Access
* --------------------------------------------------------------------------
*/
#ifdef NAS_UE
int esm_recv_status(int pti, int ebi, const esm_status_msg* msg);
int esm_recv_status(int pti, int ebi, const esm_status_msg *msg);
#endif
#ifdef NAS_MME
int esm_recv_status(unsigned int ueid, int pti, int ebi, const esm_status_msg* msg);
int esm_recv_status(unsigned int ueid, int pti, int ebi,
const esm_status_msg *msg);
#endif
/*
......@@ -93,19 +94,24 @@ int esm_recv_status(unsigned int ueid, int pti, int ebi, const esm_status_msg* m
* Transaction related messages
* ----------------------------
*/
int esm_recv_pdn_connectivity_reject(int pti, int ebi, const pdn_connectivity_reject_msg* msg);
int esm_recv_pdn_connectivity_reject(int pti, int ebi,
const pdn_connectivity_reject_msg *msg);
int esm_recv_pdn_disconnect_reject(int pti, int ebi, const pdn_disconnect_reject_msg* msg);
int esm_recv_pdn_disconnect_reject(int pti, int ebi,
const pdn_disconnect_reject_msg *msg);
/*
* Messages related to EPS bearer contexts
* ---------------------------------------
*/
int esm_recv_activate_default_eps_bearer_context_request(int pti, int ebi, const activate_default_eps_bearer_context_request_msg* msg);
int esm_recv_activate_default_eps_bearer_context_request(int pti, int ebi,
const activate_default_eps_bearer_context_request_msg *msg);
int esm_recv_activate_dedicated_eps_bearer_context_request(int pti, int ebi, const activate_dedicated_eps_bearer_context_request_msg* msg);
int esm_recv_activate_dedicated_eps_bearer_context_request(int pti, int ebi,
const activate_dedicated_eps_bearer_context_request_msg *msg);
int esm_recv_deactivate_eps_bearer_context_request(int pti, int ebi, const deactivate_eps_bearer_context_request_msg* msg);
int esm_recv_deactivate_eps_bearer_context_request(int pti, int ebi,
const deactivate_eps_bearer_context_request_msg *msg);
#endif
/*
......@@ -118,23 +124,30 @@ int esm_recv_deactivate_eps_bearer_context_request(int pti, int ebi, const deact
* Transaction related messages
* ----------------------------
*/
int esm_recv_pdn_connectivity_request(unsigned int ueid, int pti, int ebi, const pdn_connectivity_request_msg* msg, unsigned int* new_ebi, void* data);
int esm_recv_pdn_connectivity_request(unsigned int ueid, int pti, int ebi,
const pdn_connectivity_request_msg *msg, unsigned int *new_ebi, void *data);
int esm_recv_pdn_disconnect_request(unsigned int ueid, int pti, int ebi, const pdn_disconnect_request_msg* msg, unsigned int* linked_ebi);
int esm_recv_pdn_disconnect_request(unsigned int ueid, int pti, int ebi,
const pdn_disconnect_request_msg *msg, unsigned int *linked_ebi);
/*
* Messages related to EPS bearer contexts
* ---------------------------------------
*/
int esm_recv_activate_default_eps_bearer_context_accept(unsigned int ueid, int pti, int ebi, const activate_default_eps_bearer_context_accept_msg* msg);
int esm_recv_activate_default_eps_bearer_context_accept(unsigned int ueid,
int pti, int ebi, const activate_default_eps_bearer_context_accept_msg *msg);
int esm_recv_activate_default_eps_bearer_context_reject(unsigned int ueid, int pti, int ebi, const activate_default_eps_bearer_context_reject_msg* msg);
int esm_recv_activate_default_eps_bearer_context_reject(unsigned int ueid,
int pti, int ebi, const activate_default_eps_bearer_context_reject_msg *msg);
int esm_recv_activate_dedicated_eps_bearer_context_accept(unsigned int ueid, int pti, int ebi, const activate_dedicated_eps_bearer_context_accept_msg* msg);
int esm_recv_activate_dedicated_eps_bearer_context_accept(unsigned int ueid,
int pti, int ebi, const activate_dedicated_eps_bearer_context_accept_msg *msg);
int esm_recv_activate_dedicated_eps_bearer_context_reject(unsigned int ueid, int pti, int ebi, const activate_dedicated_eps_bearer_context_reject_msg* msg);
int esm_recv_activate_dedicated_eps_bearer_context_reject(unsigned int ueid,
int pti, int ebi, const activate_dedicated_eps_bearer_context_reject_msg *msg);
int esm_recv_deactivate_eps_bearer_context_accept(unsigned int ueid, int pti, int ebi, const deactivate_eps_bearer_context_accept_msg* msg);
int esm_recv_deactivate_eps_bearer_context_accept(unsigned int ueid, int pti,
int ebi, const deactivate_eps_bearer_context_accept_msg *msg);
#endif
#endif /* __ESM_RECV_H__*/
......@@ -46,19 +46,23 @@ Description Defines the ESM Service Access Points at which the EPS
/****************************************************************************/
#ifdef NAS_UE
static int _esm_sap_recv(int msg_type, int is_standalone, const OctetString* req, OctetString* rsp, esm_sap_error_t* err);
static int _esm_sap_send(int msg_type, int is_standalone, int pti, int ebi, const esm_sap_data_t* data, OctetString* rsp);
static int _esm_sap_recv(int msg_type, int is_standalone,
const OctetString *req, OctetString *rsp, esm_sap_error_t *err);
static int _esm_sap_send(int msg_type, int is_standalone, int pti, int ebi,
const esm_sap_data_t *data, OctetString *rsp);
#endif
#ifdef NAS_MME
static int _esm_sap_recv(int msg_type, int is_standalone, unsigned int ueid, const OctetString* req, OctetString* rsp, esm_sap_error_t* err);
static int _esm_sap_send(int msg_type, int is_standalone, unsigned int ueid, int pti, int ebi, const esm_sap_data_t* data, OctetString* rsp);
static int _esm_sap_recv(int msg_type, int is_standalone, unsigned int ueid,
const OctetString *req, OctetString *rsp, esm_sap_error_t *err);
static int _esm_sap_send(int msg_type, int is_standalone, unsigned int ueid,
int pti, int ebi, const esm_sap_data_t *data, OctetString *rsp);
#endif
/*
* String representation of ESM-SAP primitives
*/
static const char* _esm_sap_primitive_str[] = {
static const char *_esm_sap_primitive_str[] = {
"ESM_DEFAULT_EPS_BEARER_CONTEXT_ACTIVATE_REQ",
"ESM_DEFAULT_EPS_BEARER_CONTEXT_ACTIVATE_CNF",
"ESM_DEFAULT_EPS_BEARER_CONTEXT_ACTIVATE_REJ",
......@@ -130,7 +134,7 @@ void esm_sap_initialize(void)
** Others: None **
** **
***************************************************************************/
int esm_sap_send(esm_sap_t* msg)
int esm_sap_send(esm_sap_t *msg)
{
LOG_FUNC_IN;
......@@ -144,18 +148,16 @@ int esm_sap_send(esm_sap_t* msg)
LOG_TRACE(INFO, "ESM-SAP - Received primitive %s (%d)",
_esm_sap_primitive_str[primitive - ESM_START - 1], primitive);
switch (primitive)
{
switch (primitive) {
case ESM_PDN_CONNECTIVITY_REQ:
#ifdef NAS_UE
{
esm_pdn_connectivity_t* pdn_connect = &msg->data.pdn_connect;
if ( !msg->is_standalone || !pdn_connect->is_defined )
{
esm_pdn_connectivity_t *pdn_connect = &msg->data.pdn_connect;
if ( !msg->is_standalone || !pdn_connect->is_defined ) {
OctetString apn = {0, NULL};
if (pdn_connect->apn) {
apn.length = strlen(pdn_connect->apn);
apn.value = (uint8_t*)pdn_connect->apn;
apn.value = (uint8_t *)pdn_connect->apn;
}
/* Define new PDN context */
rc = esm_proc_pdn_connectivity(pdn_connect->cid, TRUE,
......@@ -165,8 +167,7 @@ int esm_sap_send(esm_sap_t* msg)
break;
}
}
if (pdn_connect->is_defined)
{
if (pdn_connect->is_defined) {
unsigned int pti;
/* Assign new procedure transaction identity */
rc = esm_proc_pdn_connectivity(pdn_connect->cid, TRUE,
......@@ -199,20 +200,17 @@ int esm_sap_send(esm_sap_t* msg)
#endif
#ifdef NAS_UE
{
esm_pdn_connectivity_t* pdn_connect = &msg->data.pdn_connect;
if ( msg->is_standalone && pdn_connect->is_defined )
{
esm_pdn_connectivity_t *pdn_connect = &msg->data.pdn_connect;
if ( msg->is_standalone && pdn_connect->is_defined ) {
/* Undefine the specified PDN context */
rc = esm_proc_pdn_connectivity(pdn_connect->cid, FALSE,
pdn_connect->pdn_type, NULL,
pdn_connect->is_emergency, NULL);
}
else if (msg->recv != NULL) {
} else if (msg->recv != NULL) {
/* The UE received a PDN connectivity reject message */
rc = _esm_sap_recv(PDN_CONNECTIVITY_REJECT, msg->is_standalone,
msg->recv, &msg->send, &msg->err);
}
else {
} else {
/* The PDN connectivity procedure locally failed */
rc = esm_proc_pdn_connectivity_failure(TRUE);
}
......@@ -317,8 +315,7 @@ int esm_sap_send(esm_sap_t* msg)
case ESM_EPS_BEARER_CONTEXT_MODIFY_REJ:
break;
case ESM_EPS_BEARER_CONTEXT_DEACTIVATE_REQ:
{
case ESM_EPS_BEARER_CONTEXT_DEACTIVATE_REQ: {
int bid;
/*
* Locally deactivate EPS bearer context
......@@ -401,8 +398,8 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
#ifdef NAS_MME
unsigned int ueid,
#endif
const OctetString* req, OctetString* rsp,
esm_sap_error_t* err)
const OctetString *req, OctetString *rsp,
esm_sap_error_t *err)
{
LOG_FUNC_IN;
......@@ -437,8 +434,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
* Conditional IE errors */
else if (decoder_rc == TLV_DECODE_UNEXPECTED_IEI) {
esm_cause = ESM_CAUSE_CONDITIONAL_IE_ERROR;
}
else {
} else {
esm_cause = ESM_CAUSE_PROTOCOL_ERROR;
}
}
......@@ -469,8 +465,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
"0x%x", msg_type);
}
/* Process the received ESM message */
else switch (esm_msg.header.message_type)
{
else switch (esm_msg.header.message_type) {
#ifdef NAS_UE
case ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST:
/*
......@@ -482,8 +477,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
&esm_msg.activate_default_eps_bearer_context_request);
if ( (esm_cause == ESM_CAUSE_SUCCESS) ||
(esm_cause == ESM_CAUSE_PTI_ALREADY_IN_USE) )
{
(esm_cause == ESM_CAUSE_PTI_ALREADY_IN_USE) ) {
/* Return accept message */
rc = esm_send_activate_default_eps_bearer_context_accept(ebi,
&esm_msg.activate_default_eps_bearer_context_accept);
......@@ -498,8 +492,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
*/
is_discarded = TRUE;
}
}
else {
} else {
/* Return reject message */
rc = esm_send_activate_default_eps_bearer_context_reject(ebi,
&esm_msg.activate_default_eps_bearer_context_reject,
......@@ -520,8 +513,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
&esm_msg.activate_dedicated_eps_bearer_context_request);
if ( (esm_cause == ESM_CAUSE_SUCCESS) ||
(esm_cause == ESM_CAUSE_PTI_ALREADY_IN_USE) )
{
(esm_cause == ESM_CAUSE_PTI_ALREADY_IN_USE) ) {
/* Return accept message */
rc = esm_send_activate_dedicated_eps_bearer_context_accept(ebi,
&esm_msg.activate_dedicated_eps_bearer_context_accept);
......@@ -536,8 +528,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
*/
is_discarded = TRUE;
}
}
else {
} else {
/* Return reject message */
rc = esm_send_activate_dedicated_eps_bearer_context_reject(ebi,
&esm_msg.activate_dedicated_eps_bearer_context_reject,
......@@ -560,18 +551,15 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
&esm_msg.deactivate_eps_bearer_context_request);
if ( (esm_cause == ESM_CAUSE_INVALID_PTI_VALUE) ||
(esm_cause == ESM_CAUSE_PTI_MISMATCH) )
{
(esm_cause == ESM_CAUSE_PTI_MISMATCH) ) {
/* 3GPP TS 24.301, section 7.3.1, case m
* Ignore deactivate EPS bearer context request message
* received with PTI reserved value, or assigned value
* that does not match any PTI in use
*/
is_discarded = TRUE;
}
else if ( (esm_cause == ESM_CAUSE_SUCCESS) ||
(esm_cause == ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY) )
{
} else if ( (esm_cause == ESM_CAUSE_SUCCESS) ||
(esm_cause == ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY) ) {
/* Return accept message */
rc = esm_send_deactivate_eps_bearer_context_accept(ebi,
&esm_msg.deactivate_eps_bearer_context_accept);
......@@ -598,8 +586,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
if ( (esm_cause == ESM_CAUSE_INVALID_PTI_VALUE) ||
(esm_cause == ESM_CAUSE_PTI_MISMATCH) ||
(esm_cause == ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY) )
{
(esm_cause == ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY) ) {
/* 3GPP TS 24.301, section 7.3.1, case a
* Ignore PDN connectivity reject message received with
* reserved or unassigned PTI value, or assigned value that
......@@ -621,8 +608,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
if ( (esm_cause == ESM_CAUSE_INVALID_PTI_VALUE) ||
(esm_cause == ESM_CAUSE_PTI_MISMATCH) ||
(esm_cause == ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY) )
{
(esm_cause == ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY) ) {
/* 3GPP TS 24.301, section 7.3.1, case b
* Ignore PDN disconnect reject message received with
* reserved or unassigned PTI value, or assigned value that
......@@ -663,8 +649,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
&esm_msg.activate_default_eps_bearer_context_accept);
if ( (esm_cause == ESM_CAUSE_INVALID_PTI_VALUE) ||
(esm_cause == ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY) )
{
(esm_cause == ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY) ) {
/* 3GPP TS 24.301, section 7.3.1, case f
* Ignore ESM message received with reserved PTI value
* 3GPP TS 24.301, section 7.3.2, case f
......@@ -685,8 +670,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
&esm_msg.activate_default_eps_bearer_context_reject);
if ( (esm_cause == ESM_CAUSE_INVALID_PTI_VALUE) ||
(esm_cause == ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY) )
{
(esm_cause == ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY) ) {
/* 3GPP TS 24.301, section 7.3.1, case f
* Ignore ESM message received with reserved PTI value
* 3GPP TS 24.301, section 7.3.2, case f
......@@ -707,8 +691,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
&esm_msg.deactivate_eps_bearer_context_accept);
if ( (esm_cause == ESM_CAUSE_INVALID_PTI_VALUE) ||
(esm_cause == ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY) )
{
(esm_cause == ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY) ) {
/* 3GPP TS 24.301, section 7.3.1, case f
* Ignore ESM message received with reserved PTI value
* 3GPP TS 24.301, section 7.3.2, case f
......@@ -729,8 +712,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
&esm_msg.activate_dedicated_eps_bearer_context_accept);
if ( (esm_cause == ESM_CAUSE_INVALID_PTI_VALUE) ||
(esm_cause == ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY) )
{
(esm_cause == ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY) ) {
/* 3GPP TS 24.301, section 7.3.1, case f
* Ignore ESM message received with reserved PTI value
* 3GPP TS 24.301, section 7.3.2, case f
......@@ -751,8 +733,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
&esm_msg.activate_dedicated_eps_bearer_context_reject);
if ( (esm_cause == ESM_CAUSE_INVALID_PTI_VALUE) ||
(esm_cause == ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY) )
{
(esm_cause == ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY) ) {
/* 3GPP TS 24.301, section 7.3.1, case f
* Ignore ESM message received with reserved PTI value
* 3GPP TS 24.301, section 7.3.2, case f
......@@ -769,8 +750,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
case MODIFY_EPS_BEARER_CONTEXT_REJECT:
break;
case PDN_CONNECTIVITY_REQUEST:
{
case PDN_CONNECTIVITY_REQUEST: {
esm_proc_data_t data;
memset(&data, 0, sizeof(esm_proc_data_t));
......@@ -790,8 +770,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
esm_procedure = esm_proc_pdn_connectivity_reject;
/* No ESM status message should be returned */
esm_cause = ESM_CAUSE_SUCCESS;
}
else {
} else {
/* Setup PDN type */
int pdn_type = -1;
if (data.pdn_type == ESM_PDN_TYPE_IPV4) {
......@@ -885,8 +864,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
esm_procedure = esm_proc_pdn_disconnect_reject;
/* No ESM status message should be returned */
esm_cause = ESM_CAUSE_SUCCESS;
}
else {
} else {
/* Return deactivate EPS bearer context request message */
rc = esm_send_deactivate_eps_bearer_context_request(pti, ebi,
&esm_msg.deactivate_eps_bearer_context_request,
......@@ -936,8 +914,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
/* Discard received ESM message */
is_discarded = TRUE;
}
}
else {
} else {
/* ESM message processing succeed */
*err = ESM_SAP_SUCCESS;
rc = RETURNok;
......@@ -945,11 +922,11 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
if ( (rc != RETURNerror) && (esm_procedure != NULL) ) {
/* Encode the returned ESM response message */
int size = esm_msg_encode(&esm_msg, (uint8_t*)_esm_sap_buffer,
int size = esm_msg_encode(&esm_msg, (uint8_t *)_esm_sap_buffer,
ESM_SAP_BUFFER_SIZE);
if (size > 0) {
rsp->length = size;
rsp->value = (uint8_t*)(_esm_sap_buffer);
rsp->value = (uint8_t *)(_esm_sap_buffer);
}
/* Complete the relevant ESM procedure */
#ifdef NAS_UE
......@@ -961,13 +938,11 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
if (is_discarded) {
/* Return indication that received message has been discarded */
*err = ESM_SAP_DISCARDED;
}
else if (rc != RETURNok) {
} else if (rc != RETURNok) {
/* Return indication that ESM procedure failed */
*err = ESM_SAP_FAILED;
}
}
else if (is_discarded) {
} else if (is_discarded) {
LOG_TRACE(WARNING, "ESM-SAP - Silently discard message type 0x%x",
esm_msg.header.message_type);
/* Return indication that received message has been discarded */
......@@ -1005,8 +980,8 @@ static int _esm_sap_send(int msg_type, int is_standalone,
#ifdef NAS_MME
unsigned int ueid,
#endif
int pti, int ebi, const esm_sap_data_t* data,
OctetString* rsp)
int pti, int ebi, const esm_sap_data_t *data,
OctetString *rsp)
{
LOG_FUNC_IN;
......@@ -1025,8 +1000,7 @@ static int _esm_sap_send(int msg_type, int is_standalone,
memset(&esm_msg, 0 , sizeof(ESM_msg));
/* Process the ESM message to send */
switch (msg_type)
{
switch (msg_type) {
#ifdef NAS_UE
case ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_ACCEPT:
break;
......@@ -1049,12 +1023,11 @@ static int _esm_sap_send(int msg_type, int is_standalone,
case DEACTIVATE_EPS_BEARER_CONTEXT_ACCEPT:
break;
case PDN_CONNECTIVITY_REQUEST:
{
case PDN_CONNECTIVITY_REQUEST: {
/*
* Process PDN connectivity request message to send to the MME
*/
const esm_pdn_connectivity_t* msg = &data->pdn_connect;
const esm_pdn_connectivity_t *msg = &data->pdn_connect;
rc = esm_send_pdn_connectivity_request(pti, msg->is_emergency,
msg->pdn_type, msg->apn,
&esm_msg.pdn_connectivity_request);
......@@ -1115,12 +1088,12 @@ static int _esm_sap_send(int msg_type, int is_standalone,
if (rc != RETURNerror) {
/* Encode the returned ESM response message */
int size = esm_msg_encode(&esm_msg, (uint8_t*)_esm_sap_buffer,
int size = esm_msg_encode(&esm_msg, (uint8_t *)_esm_sap_buffer,
ESM_SAP_BUFFER_SIZE);
if (size > 0) {
rsp->length = size;
rsp->value = (uint8_t*)(_esm_sap_buffer);
rsp->value = (uint8_t *)(_esm_sap_buffer);
}
/* Execute the relevant ESM procedure */
if (esm_procedure) {
......
......@@ -42,6 +42,6 @@ Description Defines the ESM Service Access Points at which the EPS
void esm_sap_initialize(void);
int esm_sap_send(esm_sap_t* msg);
int esm_sap_send(esm_sap_t *msg);
#endif /* __ESM_SAP_H__*/
......@@ -91,7 +91,7 @@ typedef struct {
int is_defined; /* Indicates whether a PDN context has been defined
* for the specified APN */
int pdn_type; /* PDN address type (IPv4, IPv6, IPv4v6) */
const char* apn; /* PDN's Access Point Name */
const char *apn; /* PDN's Access Point Name */
int is_emergency; /* Indicates whether the PDN context has been
* defined to establish connection for emergency
* bearer services */
......@@ -134,7 +134,7 @@ typedef struct {
* message */
unsigned int ueid; /* Local UE identifier */
esm_sap_error_t err; /* ESM-SAP error code */
const OctetString* recv; /* Encoded ESM message received */
const OctetString *recv; /* Encoded ESM message received */
OctetString send; /* Encoded ESM message to be sent */
esm_sap_data_t data; /* ESM message data parameters */
} esm_sap_t;
......
......@@ -70,7 +70,7 @@ Description Defines functions executed at the ESM Service Access
** Others: None **
** **
***************************************************************************/
int esm_send_status(int pti, int ebi, esm_status_msg* msg, int esm_cause)
int esm_send_status(int pti, int ebi, esm_status_msg *msg, int esm_cause)
{
LOG_FUNC_IN;
......@@ -118,8 +118,8 @@ int esm_send_status(int pti, int ebi, esm_status_msg* msg, int esm_cause)
** **
***************************************************************************/
int esm_send_pdn_connectivity_request(int pti, int is_emergency, int pdn_type,
const char* apn,
pdn_connectivity_request_msg* msg)
const char *apn,
pdn_connectivity_request_msg *msg)
{
LOG_FUNC_IN;
......@@ -153,7 +153,7 @@ int esm_send_pdn_connectivity_request(int pti, int is_emergency, int pdn_type,
msg->presencemask |=
PDN_CONNECTIVITY_REQUEST_ACCESS_POINT_NAME_PRESENT;
msg->accesspointname.accesspointnamevalue.length = len;
msg->accesspointname.accesspointnamevalue.value = (uint8_t*)apn;
msg->accesspointname.accesspointnamevalue.value = (uint8_t *)apn;
}
}
......@@ -185,7 +185,7 @@ int esm_send_pdn_connectivity_request(int pti, int is_emergency, int pdn_type,
** **
***************************************************************************/
int esm_send_pdn_disconnect_request(int pti, int ebi,
pdn_disconnect_request_msg* msg)
pdn_disconnect_request_msg *msg)
{
LOG_FUNC_IN;
......@@ -226,7 +226,7 @@ int esm_send_pdn_disconnect_request(int pti, int ebi,
** **
***************************************************************************/
int esm_send_activate_default_eps_bearer_context_accept(int ebi,
activate_default_eps_bearer_context_accept_msg* msg)
activate_default_eps_bearer_context_accept_msg *msg)
{
LOG_FUNC_IN;
......@@ -266,7 +266,7 @@ int esm_send_activate_default_eps_bearer_context_accept(int ebi,
** **
***************************************************************************/
int esm_send_activate_default_eps_bearer_context_reject(int ebi,
activate_default_eps_bearer_context_reject_msg* msg, int esm_cause)
activate_default_eps_bearer_context_reject_msg *msg, int esm_cause)
{
LOG_FUNC_IN;
......@@ -309,7 +309,7 @@ int esm_send_activate_default_eps_bearer_context_reject(int ebi,
** **
***************************************************************************/
int esm_send_activate_dedicated_eps_bearer_context_accept(int ebi,
activate_dedicated_eps_bearer_context_accept_msg* msg)
activate_dedicated_eps_bearer_context_accept_msg *msg)
{
LOG_FUNC_IN;
......@@ -350,7 +350,7 @@ int esm_send_activate_dedicated_eps_bearer_context_accept(int ebi,
** **
***************************************************************************/
int esm_send_activate_dedicated_eps_bearer_context_reject(int ebi,
activate_dedicated_eps_bearer_context_reject_msg* msg, int esm_cause)
activate_dedicated_eps_bearer_context_reject_msg *msg, int esm_cause)
{
LOG_FUNC_IN;
......@@ -390,7 +390,7 @@ int esm_send_activate_dedicated_eps_bearer_context_reject(int ebi,
** **
***************************************************************************/
int esm_send_deactivate_eps_bearer_context_accept(int ebi,
deactivate_eps_bearer_context_accept_msg* msg)
deactivate_eps_bearer_context_accept_msg *msg)
{
LOG_FUNC_IN;
......@@ -436,7 +436,7 @@ int esm_send_deactivate_eps_bearer_context_accept(int ebi,
** Others: None **
** **
***************************************************************************/
int esm_send_pdn_connectivity_reject(int pti, pdn_connectivity_reject_msg* msg,
int esm_send_pdn_connectivity_reject(int pti, pdn_connectivity_reject_msg *msg,
int esm_cause)
{
LOG_FUNC_IN;
......@@ -477,7 +477,7 @@ int esm_send_pdn_connectivity_reject(int pti, pdn_connectivity_reject_msg* msg,
** Others: None **
** **
***************************************************************************/
int esm_send_pdn_disconnect_reject(int pti, pdn_disconnect_reject_msg* msg,
int esm_send_pdn_disconnect_reject(int pti, pdn_disconnect_reject_msg *msg,
int esm_cause)
{
LOG_FUNC_IN;
......@@ -525,10 +525,10 @@ int esm_send_pdn_disconnect_reject(int pti, pdn_disconnect_reject_msg* msg,
** **
***************************************************************************/
int esm_send_activate_default_eps_bearer_context_request(int pti, int ebi,
activate_default_eps_bearer_context_request_msg* msg,
const OctetString* apn,
int pdn_type, const OctetString* pdn_addr,
const EpsQualityOfService* qos, int esm_cause)
activate_default_eps_bearer_context_request_msg *msg,
const OctetString *apn,
int pdn_type, const OctetString *pdn_addr,
const EpsQualityOfService *qos, int esm_cause)
{
LOG_FUNC_IN;
......@@ -591,9 +591,9 @@ int esm_send_activate_default_eps_bearer_context_request(int pti, int ebi,
** **
***************************************************************************/
int esm_send_activate_dedicated_eps_bearer_context_request(int pti, int ebi,
activate_dedicated_eps_bearer_context_request_msg* msg,
int linked_ebi, const EpsQualityOfService* qos,
PacketFilters* pkfs, int n_pkfs)
activate_dedicated_eps_bearer_context_request_msg *msg,
int linked_ebi, const EpsQualityOfService *qos,
PacketFilters *pkfs, int n_pkfs)
{
int i;
LOG_FUNC_IN;
......@@ -611,8 +611,7 @@ int esm_send_activate_dedicated_eps_bearer_context_request(int pti, int ebi,
msg->tft.tftoperationcode = TRAFFIC_FLOW_TEMPLATE_OPCODE_CREATE;
msg->tft.ebit = TRAFFIC_FLOW_TEMPLATE_PARAMETER_LIST_IS_NOT_INCLUDED;
msg->tft.numberofpacketfilters = n_pkfs;
for (i = 0; i < msg->tft.numberofpacketfilters; i++)
{
for (i = 0; i < msg->tft.numberofpacketfilters; i++) {
msg->tft.packetfilterlist.createtft[i] = (*pkfs)[i];
}
......@@ -647,7 +646,7 @@ int esm_send_activate_dedicated_eps_bearer_context_request(int pti, int ebi,
** **
***************************************************************************/
int esm_send_deactivate_eps_bearer_context_request(int pti, int ebi,
deactivate_eps_bearer_context_request_msg* msg,
deactivate_eps_bearer_context_request_msg *msg,
int esm_cause)
{
LOG_FUNC_IN;
......
......@@ -76,7 +76,7 @@ Description Defines functions executed at the ESM Service Access
* Functions executed by both the UE and the MME to send ESM messages
* --------------------------------------------------------------------------
*/
int esm_send_status(int pti, int ebi, esm_status_msg* msg, int esm_cause);
int esm_send_status(int pti, int ebi, esm_status_msg *msg, int esm_cause);
/*
* --------------------------------------------------------------------------
......@@ -88,20 +88,27 @@ int esm_send_status(int pti, int ebi, esm_status_msg* msg, int esm_cause);
* Transaction related messages
* ----------------------------
*/
int esm_send_pdn_connectivity_request(int pti, int is_emergency, int pdn_type, const char* apn, pdn_connectivity_request_msg* msg);
int esm_send_pdn_disconnect_request(int pti, int ebi, pdn_disconnect_request_msg* msg);
int esm_send_pdn_connectivity_request(int pti, int is_emergency, int pdn_type,
const char *apn, pdn_connectivity_request_msg *msg);
int esm_send_pdn_disconnect_request(int pti, int ebi,
pdn_disconnect_request_msg *msg);
/*
* Messages related to EPS bearer contexts
* ---------------------------------------
*/
int esm_send_activate_default_eps_bearer_context_accept(int ebi, activate_default_eps_bearer_context_accept_msg* msg);
int esm_send_activate_default_eps_bearer_context_reject(int ebi, activate_default_eps_bearer_context_reject_msg* msg, int esm_cause);
int esm_send_activate_default_eps_bearer_context_accept(int ebi,
activate_default_eps_bearer_context_accept_msg *msg);
int esm_send_activate_default_eps_bearer_context_reject(int ebi,
activate_default_eps_bearer_context_reject_msg *msg, int esm_cause);
int esm_send_activate_dedicated_eps_bearer_context_accept(int ebi, activate_dedicated_eps_bearer_context_accept_msg* msg);
int esm_send_activate_dedicated_eps_bearer_context_reject(int ebi, activate_dedicated_eps_bearer_context_reject_msg* msg, int esm_cause);
int esm_send_activate_dedicated_eps_bearer_context_accept(int ebi,
activate_dedicated_eps_bearer_context_accept_msg *msg);
int esm_send_activate_dedicated_eps_bearer_context_reject(int ebi,
activate_dedicated_eps_bearer_context_reject_msg *msg, int esm_cause);
int esm_send_deactivate_eps_bearer_context_accept(int ebi, deactivate_eps_bearer_context_accept_msg* msg);
int esm_send_deactivate_eps_bearer_context_accept(int ebi,
deactivate_eps_bearer_context_accept_msg *msg);
#endif
......@@ -115,19 +122,27 @@ int esm_send_deactivate_eps_bearer_context_accept(int ebi, deactivate_eps_bearer
* Transaction related messages
* ----------------------------
*/
int esm_send_pdn_connectivity_reject(int pti, pdn_connectivity_reject_msg* msg, int esm_cause);
int esm_send_pdn_connectivity_reject(int pti, pdn_connectivity_reject_msg *msg,
int esm_cause);
int esm_send_pdn_disconnect_reject(int pti, pdn_disconnect_reject_msg* msg, int esm_cause);
int esm_send_pdn_disconnect_reject(int pti, pdn_disconnect_reject_msg *msg,
int esm_cause);
/*
* Messages related to EPS bearer contexts
* ---------------------------------------
*/
int esm_send_activate_default_eps_bearer_context_request(int pti, int ebi, activate_default_eps_bearer_context_request_msg* msg, const OctetString* apn, int pdn_type, const OctetString* pdn_addr, const EpsQualityOfService* qos, int esm_cause);
int esm_send_activate_default_eps_bearer_context_request(int pti, int ebi,
activate_default_eps_bearer_context_request_msg *msg, const OctetString *apn,
int pdn_type, const OctetString *pdn_addr, const EpsQualityOfService *qos,
int esm_cause);
int esm_send_activate_dedicated_eps_bearer_context_request(int pti, int ebi, activate_dedicated_eps_bearer_context_request_msg* msg, int linked_ebi, const EpsQualityOfService* qos, PacketFilters* pkfs, int n_pkfs);
int esm_send_activate_dedicated_eps_bearer_context_request(int pti, int ebi,
activate_dedicated_eps_bearer_context_request_msg *msg, int linked_ebi,
const EpsQualityOfService *qos, PacketFilters *pkfs, int n_pkfs);
int esm_send_deactivate_eps_bearer_context_request(int pti, int ebi, deactivate_eps_bearer_context_request_msg* msg, int esm_cause);
int esm_send_deactivate_eps_bearer_context_request(int pti, int ebi,
deactivate_eps_bearer_context_request_msg *msg, int esm_cause);
#endif
......
......@@ -104,11 +104,11 @@ void nas_network_cleanup(void)
** Others: None **
** **
***************************************************************************/
int nas_network_process_data(int msg_id, const void* data)
int nas_network_process_data(int msg_id, const void *data)
{
LOG_FUNC_IN;
const as_message_t* msg = (as_message_t*)(data);
const as_message_t *msg = (as_message_t *)(data);
int rc = RETURNok;
/* Sanity check */
......@@ -119,16 +119,14 @@ int nas_network_process_data(int msg_id, const void* data)
LOG_FUNC_RETURN (RETURNerror);
}
switch (msg_id)
{
switch (msg_id) {
#ifdef NAS_UE
case AS_BROADCAST_INFO_IND:
break;
case AS_CELL_INFO_CNF:
{
case AS_CELL_INFO_CNF: {
/* Received cell information confirm */
const cell_info_cnf_t* info = &msg->msg.cell_info_cnf;
const cell_info_cnf_t *info = &msg->msg.cell_info_cnf;
int cell_found = (info->errCode == AS_SUCCESS);
rc = nas_proc_cell_info(cell_found, info->tac,
info->cellID, info->rat,
......@@ -142,16 +140,14 @@ int nas_network_process_data(int msg_id, const void* data)
case AS_PAGING_IND:
break;
case AS_NAS_ESTABLISH_CNF:
{
case AS_NAS_ESTABLISH_CNF: {
/* Received NAS signalling connection establishment confirm */
const nas_establish_cnf_t* confirm = &msg->msg.nas_establish_cnf;
const nas_establish_cnf_t *confirm = &msg->msg.nas_establish_cnf;
if ( (confirm->errCode == AS_SUCCESS) ||
(confirm->errCode == AS_TERMINATED_NAS) ) {
rc = nas_proc_establish_cnf(confirm->nasMsg.data,
confirm->nasMsg.length);
}
else {
} else {
LOG_TRACE(WARNING, "NET-MAIN - "
"Initial NAS message not delivered");
rc = nas_proc_establish_rej();
......@@ -170,15 +166,13 @@ int nas_network_process_data(int msg_id, const void* data)
LOG_TRACE(WARNING, "NET-MAIN - "
"Uplink NAS message not delivered");
rc = nas_proc_ul_transfer_rej();
}
else {
} else {
rc = nas_proc_ul_transfer_cnf();
}
break;
case AS_DL_INFO_TRANSFER_IND:
{
const dl_info_transfer_ind_t* info = &msg->msg.dl_info_transfer_ind;
case AS_DL_INFO_TRANSFER_IND: {
const dl_info_transfer_ind_t *info = &msg->msg.dl_info_transfer_ind;
/* Received downlink data transfer indication */
rc = nas_proc_dl_transfer_ind(info->nasMsg.data,
info->nasMsg.length);
......@@ -192,10 +186,9 @@ int nas_network_process_data(int msg_id, const void* data)
break;
#endif
#ifdef NAS_MME
case AS_NAS_ESTABLISH_IND:
{
case AS_NAS_ESTABLISH_IND: {
/* Received NAS signalling connection establishment indication */
const nas_establish_ind_t* indication = &msg->msg.nas_establish_ind;
const nas_establish_ind_t *indication = &msg->msg.nas_establish_ind;
rc = nas_proc_establish_ind(indication->UEid,
indication->tac,
indication->initialNasMsg.data,
......@@ -203,24 +196,21 @@ int nas_network_process_data(int msg_id, const void* data)
break;
}
case AS_DL_INFO_TRANSFER_CNF:
{
const dl_info_transfer_cnf_t* info = &msg->msg.dl_info_transfer_cnf;
case AS_DL_INFO_TRANSFER_CNF: {
const dl_info_transfer_cnf_t *info = &msg->msg.dl_info_transfer_cnf;
/* Received downlink data transfer confirm */
if (info->errCode != AS_SUCCESS) {
LOG_TRACE(WARNING, "NET-MAIN - "
"Downlink NAS message not delivered");
rc = nas_proc_dl_transfer_rej(info->UEid);
}
else {
} else {
rc = nas_proc_dl_transfer_cnf(info->UEid);
}
break;
}
case AS_UL_INFO_TRANSFER_IND:
{
const ul_info_transfer_ind_t* info = &msg->msg.ul_info_transfer_ind;
case AS_UL_INFO_TRANSFER_IND: {
const ul_info_transfer_ind_t *info = &msg->msg.ul_info_transfer_ind;
/* Received uplink data transfer indication */
rc = nas_proc_ul_transfer_ind(info->UEid,
info->nasMsg.data,
......
......@@ -40,8 +40,8 @@ void nas_network_initialize(void);
void nas_network_cleanup(void);
int nas_network_process_data(int command_id, const void* data);
int nas_network_process_data(int command_id, const void *data);
const void* nas_network_get_data(void);
const void *nas_network_get_data(void);
#endif /* __NAS_NETWORK_H__*/
......@@ -33,8 +33,7 @@ Description NAS command line parser
/*
* Identifiers of the NAS command line options
*/
enum
{
enum {
#ifdef NAS_UE
NAS_PARSER_UE_ID, /* User Equipement Identifier */
#endif // NAS_UE
......@@ -68,23 +67,35 @@ static parser_command_line_t nasParserCommandLine = {
NAS_PARSER_NB_OPTIONS, /* Number of options */
{ /* Command line options */
#ifdef NAS_UE
{"-ueid", "<ueid>", "UE identifier\t\t\t",
NAS_PARSER_DEFAULT_UE_ID},
{
"-ueid", "<ueid>", "UE identifier\t\t\t",
NAS_PARSER_DEFAULT_UE_ID
},
#endif // NAS_UE
{"-trace", "<mask>", "Logging trace level\t\t",
NAS_PARSER_DEFAULT_TRACE_LEVEL},
{
"-trace", "<mask>", "Logging trace level\t\t",
NAS_PARSER_DEFAULT_TRACE_LEVEL
},
#ifdef NAS_UE
{"-uhost", "<uhost>", "User app layer's hostname\t",
NAS_PARSER_DEFAULT_USER_HOSTNAME},
{
"-uhost", "<uhost>", "User app layer's hostname\t",
NAS_PARSER_DEFAULT_USER_HOSTNAME
},
#endif // NAS_UE
{"-nhost", "<nhost>", "Network layer's hostname\t",
NAS_PARSER_DEFAULT_NETWORK_HOSTNAME},
{
"-nhost", "<nhost>", "Network layer's hostname\t",
NAS_PARSER_DEFAULT_NETWORK_HOSTNAME
},
#ifdef NAS_UE
{"-uport", "<uport>", "User app layer's port number\t",
NAS_PARSER_DEFAULT_USER_PORT_NUMBER},
{
"-uport", "<uport>", "User app layer's port number\t",
NAS_PARSER_DEFAULT_USER_PORT_NUMBER
},
#endif // NAS_UE
{"-nport", "<nport>", "Network layer's port number\t",
NAS_PARSER_DEFAULT_NETWORK_PORT_NUMBER},
{
"-nport", "<nport>", "Network layer's port number\t",
NAS_PARSER_DEFAULT_NETWORK_PORT_NUMBER
},
#ifdef NAS_UE
{"-dev", "<devpath>", "Device pathname\t\t", "NULL"},
{"-params", "<params>", "Device attribute parameters", "NULL"},
......@@ -95,7 +106,7 @@ static parser_command_line_t nasParserCommandLine = {
/*
* Converts a string, containing hexadecimal formatted integer, to an integer
*/
static int atohex(const char* a_char);
static int atohex(const char *a_char);
/****************************************************************************/
/****************** E X P O R T E D F U N C T I O N S ******************/
......@@ -116,7 +127,7 @@ static int atohex(const char* a_char);
** Others: None **
** **
***************************************************************************/
void nas_parser_print_usage(const char* version)
void nas_parser_print_usage(const char *version)
{
parser_print_usage(&nasParserCommandLine);
fprintf(stderr, "Version: %s\n", version);
......@@ -136,7 +147,7 @@ void nas_parser_print_usage(const char* version)
** Others: None **
** **
***************************************************************************/
int nas_parser_get_options(int argc, const char** argv)
int nas_parser_get_options(int argc, const char **argv)
{
return parser_get_options(argc, argv, &nasParserCommandLine);
}
......@@ -191,7 +202,7 @@ int nas_parser_get_trace_level(void)
** Others: None **
** **
***************************************************************************/
const char* nas_parser_get_network_host(void)
const char *nas_parser_get_network_host(void)
{
return nasParserCommandLine.options[NAS_PARSER_NETWORK_HOST].pvalue;
}
......@@ -209,7 +220,7 @@ const char* nas_parser_get_network_host(void)
** Others: None **
** **
***************************************************************************/
const char* nas_parser_get_network_port(void)
const char *nas_parser_get_network_port(void)
{
return nasParserCommandLine.options[NAS_PARSER_NETWORK_PORT].pvalue;
}
......@@ -246,7 +257,7 @@ int nas_parser_get_ueid(void)
** Others: None **
** **
***************************************************************************/
const char* nas_parser_get_user_host(void)
const char *nas_parser_get_user_host(void)
{
return nasParserCommandLine.options[NAS_PARSER_USER_HOST].pvalue;
}
......@@ -265,7 +276,7 @@ const char* nas_parser_get_user_host(void)
** Others: None **
** **
***************************************************************************/
const char* nas_parser_get_user_port(void)
const char *nas_parser_get_user_port(void)
{
return nasParserCommandLine.options[NAS_PARSER_USER_PORT].pvalue;
}
......@@ -283,7 +294,7 @@ const char* nas_parser_get_user_port(void)
** Others: None **
** **
***************************************************************************/
const char* nas_parser_get_device_path(void)
const char *nas_parser_get_device_path(void)
{
return nasParserCommandLine.options[NAS_PARSER_DEVICE_PATH].pvalue;
}
......@@ -301,7 +312,7 @@ const char* nas_parser_get_device_path(void)
** Others: None **
** **
***************************************************************************/
const char* nas_parser_get_device_params(void)
const char *nas_parser_get_device_params(void)
{
return nasParserCommandLine.options[NAS_PARSER_DEVICE_ATTR].pvalue;
}
......@@ -311,26 +322,18 @@ const char* nas_parser_get_device_params(void)
/********************* L O C A L F U N C T I O N S *********************/
/****************************************************************************/
static int atohex(const char* a_char)
static int atohex(const char *a_char)
{
int result;
for (result=0; a_char; a_char++)
{
if (*a_char >= '0' && *a_char <= '9')
{
for (result=0; a_char; a_char++) {
if (*a_char >= '0' && *a_char <= '9') {
result = (result << 4) + (*a_char - '0');
}
else if (*a_char >= 'A' && *a_char <= 'F')
{
} else if (*a_char >= 'A' && *a_char <= 'F') {
result = (result << 4) + (*a_char - 'A' + 10);
}
else if (*a_char >= 'a' && *a_char <= 'f')
{
} else if (*a_char >= 'a' && *a_char <= 'f') {
result = (result << 4) + (*a_char - 'a' + 10);
}
else
{
} else {
break;
}
}
......
......@@ -54,20 +54,20 @@ Description NAS command line parser
/****************** E X P O R T E D F U N C T I O N S ******************/
/****************************************************************************/
void nas_parser_print_usage(const char* version);
int nas_parser_get_options(int argc, const char** argv);
void nas_parser_print_usage(const char *version);
int nas_parser_get_options(int argc, const char **argv);
int nas_parser_get_nb_options(void);
int nas_parser_get_trace_level(void);
const char* nas_parser_get_network_host(void);
const char* nas_parser_get_network_port(void);
const char *nas_parser_get_network_host(void);
const char *nas_parser_get_network_port(void);
#ifdef NAS_UE
int nas_parser_get_ueid(void);
const char* nas_parser_get_user_host(void);
const char* nas_parser_get_user_port(void);
const char* nas_parser_get_device_path(void);
const char* nas_parser_get_device_params(void);
const char *nas_parser_get_user_host(void);
const char *nas_parser_get_user_port(void);
const char *nas_parser_get_device_path(void);
const char *nas_parser_get_device_params(void);
#endif // NAS_UE
#endif /* __NAS_PARSER_H__*/
......@@ -82,7 +82,7 @@ static int _nas_proc_deactivate(int cid, int apply_to_all);
** **
***************************************************************************/
void nas_proc_initialize(emm_indication_callback_t emm_cb,
esm_indication_callback_t esm_cb, const char* imei)
esm_indication_callback_t esm_cb, const char *imei)
{
LOG_FUNC_IN;
......@@ -251,7 +251,7 @@ int nas_proc_disable_s1_mode(void)
** Others: None **
** **
***************************************************************************/
int nas_proc_get_eps(int* stat)
int nas_proc_get_eps(int *stat)
{
LOG_FUNC_IN;
......@@ -274,11 +274,11 @@ int nas_proc_get_eps(int* stat)
** Others: None **
** **
***************************************************************************/
int nas_proc_get_imsi(char* imsi_str)
int nas_proc_get_imsi(char *imsi_str)
{
LOG_FUNC_IN;
const imsi_t* imsi = emm_main_get_imsi();
const imsi_t *imsi = emm_main_get_imsi();
if (imsi != NULL) {
int offset = 0;
......@@ -318,14 +318,13 @@ int nas_proc_get_imsi(char* imsi_str)
** Others: None **
** **
***************************************************************************/
int nas_proc_get_msisdn(char* msisdn_str, int* ton_npi)
int nas_proc_get_msisdn(char *msisdn_str, int *ton_npi)
{
LOG_FUNC_IN;
const msisdn_t* msisdn = emm_main_get_msisdn();
const msisdn_t *msisdn = emm_main_get_msisdn();
if (msisdn != NULL)
{
if (msisdn != NULL) {
union {
struct {
Byte_t ext:1;
......@@ -368,7 +367,7 @@ int nas_proc_get_msisdn(char* msisdn_str, int* ton_npi)
** Others: None **
** **
***************************************************************************/
int nas_proc_get_signal_quality(int* rsrq, int* rsrp)
int nas_proc_get_signal_quality(int *rsrq, int *rsrp)
{
LOG_FUNC_IN;
......@@ -397,7 +396,7 @@ int nas_proc_get_signal_quality(int* rsrq, int* rsrp)
** Others: None **
** **
***************************************************************************/
int nas_proc_register(int mode, int format, const network_plmn_t* oper, int AcT)
int nas_proc_register(int mode, int format, const network_plmn_t *oper, int AcT)
{
LOG_FUNC_IN;
......@@ -465,7 +464,8 @@ int nas_proc_deregister(void)
** Others: None **
** **
***************************************************************************/
int nas_proc_get_reg_data(int* mode, int* selected, int format, network_plmn_t* oper, int* AcT)
int nas_proc_get_reg_data(int *mode, int *selected, int format,
network_plmn_t *oper, int *AcT)
{
LOG_FUNC_IN;
......@@ -473,15 +473,14 @@ int nas_proc_get_reg_data(int* mode, int* selected, int format, network_plmn_t*
*mode = emm_main_get_plmn_selection_mode();
/* Get the currently selected operator */
const char* oper_name = emm_main_get_selected_plmn(oper, format);
const char *oper_name = emm_main_get_selected_plmn(oper, format);
if (oper_name != NULL) {
/* An operator is currently selected */
*selected = TRUE;
/* Get the supported Radio Access Technology */
*AcT = emm_main_get_plmn_rat();
}
else {
} else {
/* No any operator is selected */
*selected = FALSE;
*AcT = NET_ACCESS_UNAVAILABLE;
......@@ -504,7 +503,7 @@ int nas_proc_get_reg_data(int* mode, int* selected, int format, network_plmn_t*
** Others: None **
** **
***************************************************************************/
int nas_proc_get_oper_list(const char** oper_list)
int nas_proc_get_oper_list(const char **oper_list)
{
LOG_FUNC_IN;
......@@ -529,7 +528,7 @@ int nas_proc_get_oper_list(const char** oper_list)
** Others: None **
** **
***************************************************************************/
int nas_proc_get_reg_status(int* stat)
int nas_proc_get_reg_status(int *stat)
{
LOG_FUNC_IN;
......@@ -557,7 +556,7 @@ int nas_proc_get_reg_status(int* stat)
** Others: None **
** **
***************************************************************************/
int nas_proc_get_loc_info(char* tac, char* ci, int* AcT)
int nas_proc_get_loc_info(char *tac, char *ci, int *AcT)
{
LOG_FUNC_IN;
......@@ -693,7 +692,7 @@ int nas_proc_get_pdn_range(void)
** Others: None **
** **
***************************************************************************/
int nas_proc_get_pdn_status(int* cids, int* states, int n_pdn_max)
int nas_proc_get_pdn_status(int *cids, int *states, int n_pdn_max)
{
LOG_FUNC_IN;
......@@ -735,7 +734,7 @@ int nas_proc_get_pdn_status(int* cids, int* states, int n_pdn_max)
** Others: None **
** **
***************************************************************************/
int nas_proc_get_pdn_param(int* cids, int* types, const char** apns,
int nas_proc_get_pdn_param(int *cids, int *types, const char **apns,
int n_pdn_max)
{
LOG_FUNC_IN;
......@@ -785,8 +784,8 @@ int nas_proc_get_pdn_param(int* cids, int* types, const char** apns,
** Others: None **
** **
***************************************************************************/
int nas_proc_get_pdn_addr(int cid, int* cids, const char** addr1,
const char** addr2, int n_pdn_max)
int nas_proc_get_pdn_addr(int cid, int *cids, const char **addr1,
const char **addr2, int n_pdn_max)
{
LOG_FUNC_IN;
......@@ -800,14 +799,12 @@ int nas_proc_get_pdn_addr(int cid, int* cids, const char** addr1,
*cids = cid;
n_defined_pdn = 1;
}
}
else if (cid < 0) {
} else if (cid < 0) {
/* Get the maximum number of supported PDN contexts */
int n_pdn = esm_main_get_nb_pdns_max();
/* For all PDN contexts */
for (cid = 1; (cid < n_pdn+1) && (n_defined_pdn < n_pdn_max); cid++)
{
for (cid = 1; (cid < n_pdn+1) && (n_defined_pdn < n_pdn_max); cid++) {
/* Get PDN connection addresses */
rc = esm_main_get_pdn_addr(cid, addr1, addr2);
if (rc != RETURNerror) {
......@@ -818,8 +815,7 @@ int nas_proc_get_pdn_addr(int cid, int* cids, const char** addr1,
n_defined_pdn += 1;
}
}
}
else {
} else {
/* Get the list of defined PDN contexts */
}
......@@ -849,7 +845,7 @@ int nas_proc_get_pdn_addr(int cid, int* cids, const char** addr1,
** Others: None **
** **
***************************************************************************/
int nas_proc_set_pdn(int cid, int type, const char* apn, int ipv4_addr,
int nas_proc_set_pdn(int cid, int type, const char *apn, int ipv4_addr,
int emergency, int p_cscf, int im_cn_signal)
{
LOG_FUNC_IN;
......@@ -930,14 +926,12 @@ int nas_proc_deactivate_pdn(int cid)
if (cid > 0) {
/* Deactivate only the specified PDN context */
rc = _nas_proc_deactivate(cid, FALSE);
}
else {
} else {
/* Do not deactivate the PDN connection established during initial
* network attachment (identifier 1) */
cid = 2;
/* Deactivate all active PDN contexts */
while ((rc != RETURNerror) && (cid < esm_main_get_nb_pdns_max()+1))
{
while ((rc != RETURNerror) && (cid < esm_main_get_nb_pdns_max()+1)) {
rc = _nas_proc_deactivate(cid++, TRUE);
}
}
......@@ -974,25 +968,21 @@ int nas_proc_activate_pdn(int cid)
*/
LOG_TRACE(WARNING, "NAS-PROC - UE is not attached to the network");
rc = nas_proc_attach();
}
else if (emm_main_is_emergency()) {
} else if (emm_main_is_emergency()) {
/* The UE is attached for emergency bearer services; It shall not
* request a PDN connection to any other PDN */
LOG_TRACE(WARNING,"NAS-PROC - Attached for emergency bearer services");
rc = RETURNerror;
}
if (rc != RETURNerror)
{
if (rc != RETURNerror) {
if (cid > 0) {
/* Activate only the specified PDN context */
rc = _nas_proc_activate(cid, FALSE);
}
else {
} else {
cid = 1;
/* Activate all defined PDN contexts */
while ((rc != RETURNerror) && (cid < esm_main_get_nb_pdns_max()+1))
{
while ((rc != RETURNerror) && (cid < esm_main_get_nb_pdns_max()+1)) {
rc = _nas_proc_activate(cid++, TRUE);
}
}
......@@ -1076,7 +1066,7 @@ int nas_proc_cell_info(int found, tac_t tac, ci_t ci, AcT_t AcT,
** Others: None **
** **
***************************************************************************/
int nas_proc_establish_cnf(const Byte_t* data, UInt32_t len)
int nas_proc_establish_cnf(const Byte_t *data, UInt32_t len)
{
LOG_FUNC_IN;
......@@ -1090,7 +1080,7 @@ int nas_proc_establish_cnf(const Byte_t* data, UInt32_t len)
*/
emm_sap.primitive = EMMAS_ESTABLISH_CNF;
emm_sap.u.emm_as.u.establish.NASmsg.length = len;
emm_sap.u.emm_as.u.establish.NASmsg.value = (uint8_t*)data;
emm_sap.u.emm_as.u.establish.NASmsg.value = (uint8_t *)data;
rc = emm_sap_send(&emm_sap);
LOG_FUNC_RETURN (rc);
......@@ -1254,7 +1244,7 @@ int nas_proc_ul_transfer_rej(void)
** Others: None **
** **
***************************************************************************/
int nas_proc_dl_transfer_ind(const Byte_t* data, UInt32_t len)
int nas_proc_dl_transfer_ind(const Byte_t *data, UInt32_t len)
{
LOG_FUNC_IN;
......@@ -1270,7 +1260,7 @@ int nas_proc_dl_transfer_ind(const Byte_t* data, UInt32_t len)
emm_sap.u.emm_as.u.data.ueid = 0;
emm_sap.u.emm_as.u.data.delivered = TRUE;
emm_sap.u.emm_as.u.data.NASmsg.length = len;
emm_sap.u.emm_as.u.data.NASmsg.value = (uint8_t*)data;
emm_sap.u.emm_as.u.data.NASmsg.value = (uint8_t *)data;
rc = emm_sap_send(&emm_sap);
}
......@@ -1300,7 +1290,7 @@ int nas_proc_dl_transfer_ind(const Byte_t* data, UInt32_t len)
** **
***************************************************************************/
int nas_proc_establish_ind(UInt32_t ueid, tac_t tac,
const Byte_t* data, UInt32_t len)
const Byte_t *data, UInt32_t len)
{
LOG_FUNC_IN;
......@@ -1316,7 +1306,7 @@ int nas_proc_establish_ind(UInt32_t ueid, tac_t tac,
emm_sap.primitive = EMMAS_ESTABLISH_REQ;
emm_sap.u.emm_as.u.establish.ueid = ueid;
emm_sap.u.emm_as.u.establish.NASmsg.length = len;
emm_sap.u.emm_as.u.establish.NASmsg.value = (uint8_t*)data;
emm_sap.u.emm_as.u.establish.NASmsg.value = (uint8_t *)data;
rc = emm_sap_send(&emm_sap);
}
......@@ -1414,7 +1404,7 @@ int nas_proc_dl_transfer_rej(UInt32_t ueid)
** Others: None **
** **
***************************************************************************/
int nas_proc_ul_transfer_ind(UInt32_t ueid, const Byte_t* data, UInt32_t len)
int nas_proc_ul_transfer_ind(UInt32_t ueid, const Byte_t *data, UInt32_t len)
{
LOG_FUNC_IN;
......@@ -1430,7 +1420,7 @@ int nas_proc_ul_transfer_ind(UInt32_t ueid, const Byte_t* data, UInt32_t len)
emm_sap.u.emm_as.u.data.ueid = ueid;
emm_sap.u.emm_as.u.data.delivered = TRUE;
emm_sap.u.emm_as.u.data.NASmsg.length = len;
emm_sap.u.emm_as.u.data.NASmsg.value = (uint8_t*)data;
emm_sap.u.emm_as.u.data.NASmsg.value = (uint8_t *)data;
rc = emm_sap_send(&emm_sap);
}
......@@ -1536,7 +1526,7 @@ static int _nas_proc_deactivate(int cid, int apply_to_all)
int rc;
int pdn_type;
const char* apn;
const char *apn;
int emergency = FALSE;
int active = FALSE;
......@@ -1566,8 +1556,7 @@ static int _nas_proc_deactivate(int cid, int apply_to_all)
esm_sap.primitive = ESM_PDN_DISCONNECT_REQ;
esm_sap.data.pdn_disconnect.cid = cid;
rc = esm_sap_send(&esm_sap);
}
else {
} else {
/* For EPS, if an attempt is made to disconnect the last PDN
* connection, then the MT responds with an error */
LOG_TRACE(WARNING,"NAS-PROC - "
......
......@@ -40,7 +40,8 @@ Description NAS procedure call manager
/****************************************************************************/
#ifdef NAS_UE
void nas_proc_initialize(emm_indication_callback_t emm_cb, esm_indication_callback_t esm_cb, const char* imei);
void nas_proc_initialize(emm_indication_callback_t emm_cb,
esm_indication_callback_t esm_cb, const char *imei);
#endif
#ifdef NAS_MME
void nas_proc_initialize(void);
......@@ -57,31 +58,35 @@ void nas_proc_cleanup(void);
#ifdef NAS_UE
int nas_proc_enable_s1_mode(void);
int nas_proc_disable_s1_mode(void);
int nas_proc_get_eps(int* stat);
int nas_proc_get_eps(int *stat);
int nas_proc_get_imsi(char* imsi_str);
int nas_proc_get_msisdn(char* msisdn_str, int* ton_npi);
int nas_proc_get_imsi(char *imsi_str);
int nas_proc_get_msisdn(char *msisdn_str, int *ton_npi);
int nas_proc_get_signal_quality(int* rsrq, int* rsrp);
int nas_proc_get_signal_quality(int *rsrq, int *rsrp);
int nas_proc_register(int mode, int format, const network_plmn_t* oper, int AcT);
int nas_proc_register(int mode, int format, const network_plmn_t *oper, int AcT);
int nas_proc_deregister(void);
int nas_proc_get_reg_data(int* mode, int* selected, int format, network_plmn_t* oper, int* AcT);
int nas_proc_get_oper_list(const char** oper_list);
int nas_proc_get_reg_data(int *mode, int *selected, int format,
network_plmn_t *oper, int *AcT);
int nas_proc_get_oper_list(const char **oper_list);
int nas_proc_get_reg_status(int* stat);
int nas_proc_get_loc_info(char* tac, char* ci, int* AcT);
int nas_proc_get_reg_status(int *stat);
int nas_proc_get_loc_info(char *tac, char *ci, int *AcT);
int nas_proc_detach(int switch_off);
int nas_proc_attach(void);
int nas_proc_get_attach_status(void);
int nas_proc_reset_pdn(int cid);
int nas_proc_set_pdn(int cid, int type, const char* apn, int ipv4_addr, int emergency, int p_cscf, int im_cn_signal);
int nas_proc_set_pdn(int cid, int type, const char *apn, int ipv4_addr,
int emergency, int p_cscf, int im_cn_signal);
int nas_proc_get_pdn_range(void);
int nas_proc_get_pdn_status(int* cids, int* states, int n_pdn_max);
int nas_proc_get_pdn_param(int* cids, int* types, const char** apns, int n_pdn_max);
int nas_proc_get_pdn_addr(int cid, int* cids, const char** addr1, const char** addr2, int n_addr_max);
int nas_proc_get_pdn_status(int *cids, int *states, int n_pdn_max);
int nas_proc_get_pdn_param(int *cids, int *types, const char **apns,
int n_pdn_max);
int nas_proc_get_pdn_addr(int cid, int *cids, const char **addr1,
const char **addr2, int n_addr_max);
int nas_proc_deactivate_pdn(int cid);
int nas_proc_activate_pdn(int cid);
#endif
......@@ -93,24 +98,26 @@ int nas_proc_activate_pdn(int cid);
*/
#ifdef NAS_UE
int nas_proc_cell_info(int found, tac_t tac, ci_t ci, AcT_t rat, UInt8_t rsrp, UInt8_t rsrq);
int nas_proc_cell_info(int found, tac_t tac, ci_t ci, AcT_t rat, UInt8_t rsrp,
UInt8_t rsrq);
int nas_proc_establish_cnf(const Byte_t* data, UInt32_t len);
int nas_proc_establish_cnf(const Byte_t *data, UInt32_t len);
int nas_proc_establish_rej(void);
int nas_proc_release_ind(int cause);
int nas_proc_ul_transfer_cnf(void);
int nas_proc_ul_transfer_rej(void);
int nas_proc_dl_transfer_ind(const Byte_t* data, UInt32_t len);
int nas_proc_dl_transfer_ind(const Byte_t *data, UInt32_t len);
#endif
#ifdef NAS_MME
int nas_proc_establish_ind(UInt32_t ueid, tac_t tac, const Byte_t* data, UInt32_t len);
int nas_proc_establish_ind(UInt32_t ueid, tac_t tac, const Byte_t *data,
UInt32_t len);
int nas_proc_dl_transfer_cnf(UInt32_t ueid);
int nas_proc_dl_transfer_rej(UInt32_t ueid);
int nas_proc_ul_transfer_ind(UInt32_t ueid, const Byte_t* data, UInt32_t len);
int nas_proc_ul_transfer_ind(UInt32_t ueid, const Byte_t *data, UInt32_t len);
#endif
#endif /* __NAS_PROC_H__*/
......@@ -47,30 +47,30 @@ Description NAS procedure functions triggered by the user
* Functions executed upon receiving AT command from the user
* ---------------------------------------------------------------------
*/
static int _nas_user_proc_cgsn (const at_command_t* data);
static int _nas_user_proc_cgmi (const at_command_t* data);
static int _nas_user_proc_cgmm (const at_command_t* data);
static int _nas_user_proc_cgmr (const at_command_t* data);
static int _nas_user_proc_cimi (const at_command_t* data);
static int _nas_user_proc_cfun (const at_command_t* data);
static int _nas_user_proc_cpin (const at_command_t* data);
static int _nas_user_proc_csq (const at_command_t* data);
static int _nas_user_proc_cesq (const at_command_t* data);
static int _nas_user_proc_cops (const at_command_t* data);
static int _nas_user_proc_cgatt (const at_command_t* data);
static int _nas_user_proc_creg (const at_command_t* data);
static int _nas_user_proc_cgreg (const at_command_t* data);
static int _nas_user_proc_cereg (const at_command_t* data);
static int _nas_user_proc_cgdcont (const at_command_t* data);
static int _nas_user_proc_cgact (const at_command_t* data);
static int _nas_user_proc_cmee (const at_command_t* data);
static int _nas_user_proc_clck (const at_command_t* data);
static int _nas_user_proc_cgpaddr (const at_command_t* data);
static int _nas_user_proc_cnum (const at_command_t* data);
static int _nas_user_proc_clac (const at_command_t* data);
static int _nas_user_proc_cgsn (const at_command_t *data);
static int _nas_user_proc_cgmi (const at_command_t *data);
static int _nas_user_proc_cgmm (const at_command_t *data);
static int _nas_user_proc_cgmr (const at_command_t *data);
static int _nas_user_proc_cimi (const at_command_t *data);
static int _nas_user_proc_cfun (const at_command_t *data);
static int _nas_user_proc_cpin (const at_command_t *data);
static int _nas_user_proc_csq (const at_command_t *data);
static int _nas_user_proc_cesq (const at_command_t *data);
static int _nas_user_proc_cops (const at_command_t *data);
static int _nas_user_proc_cgatt (const at_command_t *data);
static int _nas_user_proc_creg (const at_command_t *data);
static int _nas_user_proc_cgreg (const at_command_t *data);
static int _nas_user_proc_cereg (const at_command_t *data);
static int _nas_user_proc_cgdcont (const at_command_t *data);
static int _nas_user_proc_cgact (const at_command_t *data);
static int _nas_user_proc_cmee (const at_command_t *data);
static int _nas_user_proc_clck (const at_command_t *data);
static int _nas_user_proc_cgpaddr (const at_command_t *data);
static int _nas_user_proc_cnum (const at_command_t *data);
static int _nas_user_proc_clac (const at_command_t *data);
/* NAS procedures applicable to AT commands */
typedef int (*_nas_user_procedure_t) (const at_command_t*);
typedef int (*_nas_user_procedure_t) (const at_command_t *);
static _nas_user_procedure_t _nas_user_procedure[AT_COMMAND_ID_MAX] = {
NULL,
......@@ -122,7 +122,7 @@ typedef enum {
NAS_USER_PH_SIM_PIN /* MT is waiting phone-to-SIM card
* password to be given */
} nas_user_sim_status;
static const char* _nas_user_sim_status_str[] = {
static const char *_nas_user_sim_status_str[] = {
"READY",
"SIM PIN",
"SIM PUK",
......@@ -132,10 +132,9 @@ static const char* _nas_user_sim_status_str[] = {
/*
* The local UE context
*/
static struct
{
static struct {
/* Firmware version number */
const char* version;
const char *version;
/* SIM pending status */
nas_user_sim_status sim_status;
/* Level of functionality */
......@@ -170,12 +169,12 @@ static user_nvdata_t _nas_user_nvdata;
** **
***************************************************************************/
void nas_user_initialize(emm_indication_callback_t emm_cb,
esm_indication_callback_t esm_cb, const char* version)
esm_indication_callback_t esm_cb, const char *version)
{
LOG_FUNC_IN;
/* Get UE's data pathname */
char* path = memory_get_path(USER_NVRAM_DIRNAME, USER_NVRAM_FILENAME);
char *path = memory_get_path(USER_NVRAM_DIRNAME, USER_NVRAM_FILENAME);
if (path == NULL) {
LOG_TRACE(ERROR, "USR-MAIN - Failed to get UE's data pathname");
}
......@@ -216,14 +215,14 @@ void nas_user_initialize(emm_indication_callback_t emm_cb,
** Others: _nas_user_data **
** **
***************************************************************************/
int nas_user_process_data(const void* data)
int nas_user_process_data(const void *data)
{
LOG_FUNC_IN;
int ret_code = RETURNerror;
if (data) {
const at_command_t* user_data = (at_command_t*)(data);
const at_command_t *user_data = (at_command_t *)(data);
_nas_user_procedure_t nas_procedure;
LOG_TRACE(INFO, "USR-MAIN - Process %s AT command %d",
......@@ -237,8 +236,7 @@ int nas_user_process_data(const void* data)
nas_procedure = _nas_user_procedure[user_data->id];
if (nas_procedure != NULL) {
ret_code = (*nas_procedure)(user_data);
}
else {
} else {
/* AT command related to result format only */
_nas_user_data.id = user_data->id;
_nas_user_data.type = user_data->type;
......@@ -246,8 +244,7 @@ int nas_user_process_data(const void* data)
_nas_user_data.cause_code = AT_ERROR_SUCCESS;
ret_code = RETURNok;
}
}
else {
} else {
LOG_TRACE(ERROR, "USR-MAIN - Data to be processed is null");
_nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED;
}
......@@ -272,10 +269,10 @@ int nas_user_process_data(const void* data)
** Others: None **
** **
***************************************************************************/
const void* nas_user_get_data(void)
const void *nas_user_get_data(void)
{
LOG_FUNC_IN;
LOG_FUNC_RETURN ((void*) &_nas_user_data);
LOG_FUNC_RETURN ((void *) &_nas_user_data);
}
/****************************************************************************/
......@@ -301,12 +298,12 @@ const void* nas_user_get_data(void)
** Others: _nas_user_data **
** **
***************************************************************************/
static int _nas_user_proc_cgsn(const at_command_t* data)
static int _nas_user_proc_cgsn(const at_command_t *data)
{
LOG_FUNC_IN;
int ret_code = RETURNok;
at_cgsn_resp_t * cgsn = &_nas_user_data.response.cgsn;
at_cgsn_resp_t *cgsn = &_nas_user_data.response.cgsn;
memset(cgsn, 0, sizeof(at_cgsn_resp_t));
_nas_user_data.id = data->id;
......@@ -314,8 +311,7 @@ static int _nas_user_proc_cgsn(const at_command_t* data)
_nas_user_data.mask = AT_RESPONSE_CGSN_MASK;
_nas_user_data.cause_code = AT_ERROR_SUCCESS;
switch (data->type)
{
switch (data->type) {
case AT_COMMAND_ACT:
/* Get the Product Serial Number Identification (IMEI) */
strncpy(cgsn->sn, _nas_user_nvdata.IMEI,
......@@ -327,7 +323,8 @@ static int _nas_user_proc_cgsn(const at_command_t* data)
break;
default:
LOG_TRACE(ERROR, "USR-MAIN - AT+CGSN command type %d is not supported", data->type);
LOG_TRACE(ERROR, "USR-MAIN - AT+CGSN command type %d is not supported",
data->type);
_nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED;
ret_code = RETURNerror;
break;
......@@ -353,12 +350,12 @@ static int _nas_user_proc_cgsn(const at_command_t* data)
** Others: _nas_user_data **
** **
***************************************************************************/
static int _nas_user_proc_cgmi(const at_command_t* data)
static int _nas_user_proc_cgmi(const at_command_t *data)
{
LOG_FUNC_IN;
int ret_code = RETURNok;
at_cgmi_resp_t * cgmi = &_nas_user_data.response.cgmi;
at_cgmi_resp_t *cgmi = &_nas_user_data.response.cgmi;
memset(cgmi, 0, sizeof(at_cgmi_resp_t));
_nas_user_data.id = data->id;
......@@ -366,8 +363,7 @@ static int _nas_user_proc_cgmi(const at_command_t* data)
_nas_user_data.mask = AT_RESPONSE_CGMI_MASK;
_nas_user_data.cause_code = AT_ERROR_SUCCESS;
switch (data->type)
{
switch (data->type) {
case AT_COMMAND_ACT:
/* Get the Manufacturer identifier */
strncpy(cgmi->manufacturer, _nas_user_nvdata.manufacturer,
......@@ -379,7 +375,8 @@ static int _nas_user_proc_cgmi(const at_command_t* data)
break;
default:
LOG_TRACE(ERROR, "USR-MAIN - AT+CGMI command type %d is not supported", data->type);
LOG_TRACE(ERROR, "USR-MAIN - AT+CGMI command type %d is not supported",
data->type);
_nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED;
ret_code = RETURNerror;
break;
......@@ -405,12 +402,12 @@ static int _nas_user_proc_cgmi(const at_command_t* data)
** Others: _nas_user_data **
** **
***************************************************************************/
static int _nas_user_proc_cgmm(const at_command_t* data)
static int _nas_user_proc_cgmm(const at_command_t *data)
{
LOG_FUNC_IN;
int ret_code = RETURNok;
at_cgmm_resp_t * cgmm = &_nas_user_data.response.cgmm;
at_cgmm_resp_t *cgmm = &_nas_user_data.response.cgmm;
memset(cgmm, 0, sizeof(at_cgmm_resp_t));
_nas_user_data.id = data->id;
......@@ -418,8 +415,7 @@ static int _nas_user_proc_cgmm(const at_command_t* data)
_nas_user_data.mask = AT_RESPONSE_CGMM_MASK;
_nas_user_data.cause_code = AT_ERROR_SUCCESS;
switch (data->type)
{
switch (data->type) {
case AT_COMMAND_ACT:
/* Get the Model identifier */
strncpy(cgmm->model, _nas_user_nvdata.model,
......@@ -431,7 +427,8 @@ static int _nas_user_proc_cgmm(const at_command_t* data)
break;
default:
LOG_TRACE(ERROR, "USR-MAIN - AT+CGMM command type %d is not supported", data->type);
LOG_TRACE(ERROR, "USR-MAIN - AT+CGMM command type %d is not supported",
data->type);
_nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED;
ret_code = RETURNerror;
break;
......@@ -458,12 +455,12 @@ static int _nas_user_proc_cgmm(const at_command_t* data)
** Others: _nas_user_data **
** **
***************************************************************************/
static int _nas_user_proc_cgmr(const at_command_t* data)
static int _nas_user_proc_cgmr(const at_command_t *data)
{
LOG_FUNC_IN;
int ret_code = RETURNok;
at_cgmr_resp_t * cgmr = &_nas_user_data.response.cgmr;
at_cgmr_resp_t *cgmr = &_nas_user_data.response.cgmr;
memset(cgmr, 0, sizeof(at_cgmr_resp_t));
_nas_user_data.id = data->id;
......@@ -471,8 +468,7 @@ static int _nas_user_proc_cgmr(const at_command_t* data)
_nas_user_data.mask = AT_RESPONSE_CGMR_MASK;
_nas_user_data.cause_code = AT_ERROR_SUCCESS;
switch (data->type)
{
switch (data->type) {
case AT_COMMAND_ACT:
/* Get the revision identifier */
strncpy(cgmr->revision, _nas_user_context.version,
......@@ -484,7 +480,8 @@ static int _nas_user_proc_cgmr(const at_command_t* data)
break;
default:
LOG_TRACE(ERROR, "USR-MAIN - AT+CGMR command type %d is not supported", data->type);
LOG_TRACE(ERROR, "USR-MAIN - AT+CGMR command type %d is not supported",
data->type);
_nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED;
ret_code = RETURNerror;
break;
......@@ -514,12 +511,12 @@ static int _nas_user_proc_cgmr(const at_command_t* data)
** Others: _nas_user_data **
** **
***************************************************************************/
static int _nas_user_proc_cimi(const at_command_t* data)
static int _nas_user_proc_cimi(const at_command_t *data)
{
LOG_FUNC_IN;
int ret_code = RETURNok;
at_cimi_resp_t * cimi = &_nas_user_data.response.cimi;
at_cimi_resp_t *cimi = &_nas_user_data.response.cimi;
memset(cimi, 0, sizeof(at_cimi_resp_t));
_nas_user_data.id = data->id;
......@@ -527,8 +524,7 @@ static int _nas_user_proc_cimi(const at_command_t* data)
_nas_user_data.mask = AT_RESPONSE_CIMI_MASK;
_nas_user_data.cause_code = AT_ERROR_SUCCESS;
switch (data->type)
{
switch (data->type) {
case AT_COMMAND_ACT:
if (_nas_user_context.sim_status != NAS_USER_READY) {
_nas_user_data.cause_code = AT_ERROR_SIM_PIN_REQUIRED;
......@@ -547,7 +543,8 @@ static int _nas_user_proc_cimi(const at_command_t* data)
break;
default:
LOG_TRACE(ERROR, "USR-MAIN - AT+CIMI command type %d is not supported", data->type);
LOG_TRACE(ERROR, "USR-MAIN - AT+CIMI command type %d is not supported",
data->type);
_nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED;
ret_code = RETURNerror;
break;
......@@ -572,12 +569,12 @@ static int _nas_user_proc_cimi(const at_command_t* data)
** Others: _nas_user_data **
** **
***************************************************************************/
static int _nas_user_proc_cfun(const at_command_t* data)
static int _nas_user_proc_cfun(const at_command_t *data)
{
LOG_FUNC_IN;
int ret_code = RETURNok;
at_cfun_resp_t * cfun = &_nas_user_data.response.cfun;
at_cfun_resp_t *cfun = &_nas_user_data.response.cfun;
memset(cfun, 0, sizeof(at_cfun_resp_t));
int fun = AT_CFUN_FUN_DEFAULT;
......@@ -587,18 +584,15 @@ static int _nas_user_proc_cfun(const at_command_t* data)
_nas_user_data.mask = AT_RESPONSE_CFUN_MASK;
_nas_user_data.cause_code = AT_ERROR_SUCCESS;
switch (data->type)
{
switch (data->type) {
case AT_COMMAND_SET:
/*
* Set command selects the level of functionality in the MT
*/
if (data->mask & AT_CFUN_RST_MASK)
{
if (data->mask & AT_CFUN_RST_MASK) {
if (data->command.cfun.rst == AT_CFUN_RST) {
/* TODO: Reset the MT before setting it to <fun> power level */
}
else if (data->command.cfun.rst != AT_CFUN_NORST) {
} else if (data->command.cfun.rst != AT_CFUN_NORST) {
/* The value of the reset parameter is not valid;
* return an error message */
LOG_TRACE(ERROR, "USR-MAIN - <rst> parameter is not valid"
......@@ -609,8 +603,7 @@ static int _nas_user_proc_cfun(const at_command_t* data)
}
}
if (data->mask & AT_CFUN_FUN_MASK)
{
if (data->mask & AT_CFUN_FUN_MASK) {
if ( (data->command.cfun.fun < AT_CFUN_MIN) ||
(data->command.cfun.fun > AT_CFUN_MAX) ) {
/* The value of the functionality level parameter
......@@ -625,8 +618,7 @@ static int _nas_user_proc_cfun(const at_command_t* data)
fun = data->command.cfun.fun;
}
switch (fun)
{
switch (fun) {
case AT_CFUN_MIN:
/* TODO: Shutdown ??? */
break;
......@@ -660,7 +652,8 @@ static int _nas_user_proc_cfun(const at_command_t* data)
break;
default:
LOG_TRACE(ERROR, "USR-MAIN - AT+CFUN command type %d is not supported", data->type);
LOG_TRACE(ERROR, "USR-MAIN - AT+CFUN command type %d is not supported",
data->type);
_nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED;
ret_code = RETURNerror;
break;
......@@ -686,12 +679,12 @@ static int _nas_user_proc_cfun(const at_command_t* data)
** Others: _nas_user_context, _nas_user_data **
** **
***************************************************************************/
static int _nas_user_proc_cpin(const at_command_t* data)
static int _nas_user_proc_cpin(const at_command_t *data)
{
LOG_FUNC_IN;
int ret_code = RETURNok;
at_cpin_resp_t * cpin = &_nas_user_data.response.cpin;
at_cpin_resp_t *cpin = &_nas_user_data.response.cpin;
memset(cpin, 0, sizeof(at_cpin_resp_t));
_nas_user_data.id = data->id;
......@@ -699,15 +692,13 @@ static int _nas_user_proc_cpin(const at_command_t* data)
_nas_user_data.mask = AT_RESPONSE_CPIN_MASK;
_nas_user_data.cause_code = AT_ERROR_SUCCESS;
switch (data->type)
{
switch (data->type) {
case AT_COMMAND_SET:
/*
* Set command sends to the MT a password which is necessary
* before it can be operated
*/
if (_nas_user_context.sim_status == NAS_USER_SIM_PIN)
{
if (_nas_user_context.sim_status == NAS_USER_SIM_PIN) {
/* The MT is waiting for PIN password; check the PIN code */
if (strncmp(_nas_user_nvdata.PIN,
data->command.cpin.pin, USER_PIN_SIZE) != 0) {
......@@ -716,15 +707,12 @@ static int _nas_user_proc_cpin(const at_command_t* data)
"(%s)", data->command.cpin.pin);
_nas_user_data.cause_code = AT_ERROR_INCORRECT_PASSWD;
ret_code = RETURNerror;
}
else {
} else {
/* The PIN code is matching; update the user's PIN
* pending status */
_nas_user_context.sim_status = NAS_USER_READY;
}
}
else
{
} else {
/* The MT is NOT waiting for PIN password;
* return an error message */
_nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_ALLOWED;
......@@ -749,7 +737,8 @@ static int _nas_user_proc_cpin(const at_command_t* data)
default:
/* Other types of AT CPIN command are not valid */
LOG_TRACE(ERROR, "USR-MAIN - AT+CPIN command type %d is not supported", data->type);
LOG_TRACE(ERROR, "USR-MAIN - AT+CPIN command type %d is not supported",
data->type);
_nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED;
ret_code = RETURNerror;
break;
......@@ -775,12 +764,12 @@ static int _nas_user_proc_cpin(const at_command_t* data)
** Others: _nas_user_data **
** **
***************************************************************************/
static int _nas_user_proc_csq(const at_command_t* data)
static int _nas_user_proc_csq(const at_command_t *data)
{
LOG_FUNC_IN;
int ret_code = RETURNok;
at_csq_resp_t * csq = &_nas_user_data.response.csq;
at_csq_resp_t *csq = &_nas_user_data.response.csq;
memset(csq, 0, sizeof(at_csq_resp_t));
_nas_user_data.id = data->id;
......@@ -788,8 +777,7 @@ static int _nas_user_proc_csq(const at_command_t* data)
_nas_user_data.mask = AT_RESPONSE_CSQ_MASK;
_nas_user_data.cause_code = AT_ERROR_SUCCESS;
switch (data->type)
{
switch (data->type) {
case AT_COMMAND_ACT:
if (_nas_user_context.sim_status != NAS_USER_READY) {
_nas_user_data.cause_code = AT_ERROR_SIM_PIN_REQUIRED;
......@@ -810,7 +798,8 @@ static int _nas_user_proc_csq(const at_command_t* data)
break;
default:
LOG_TRACE(ERROR, "USR-MAIN - AT+CSQ command type %d is not supported", data->type);
LOG_TRACE(ERROR, "USR-MAIN - AT+CSQ command type %d is not supported",
data->type);
_nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED;
ret_code = RETURNerror;
break;
......@@ -835,12 +824,12 @@ static int _nas_user_proc_csq(const at_command_t* data)
** Others: _nas_user_data **
** **
***************************************************************************/
static int _nas_user_proc_cesq(const at_command_t* data)
static int _nas_user_proc_cesq(const at_command_t *data)
{
LOG_FUNC_IN;
int ret_code = RETURNok;
at_cesq_resp_t * cesq = &_nas_user_data.response.cesq;
at_cesq_resp_t *cesq = &_nas_user_data.response.cesq;
memset(cesq, 0, sizeof(at_cesq_resp_t));
_nas_user_data.id = data->id;
......@@ -848,8 +837,7 @@ static int _nas_user_proc_cesq(const at_command_t* data)
_nas_user_data.mask = AT_RESPONSE_CESQ_MASK;
_nas_user_data.cause_code = AT_ERROR_SUCCESS;
switch (data->type)
{
switch (data->type) {
case AT_COMMAND_ACT:
if (_nas_user_context.sim_status != NAS_USER_READY) {
_nas_user_data.cause_code = AT_ERROR_SIM_PIN_REQUIRED;
......@@ -872,7 +860,8 @@ static int _nas_user_proc_cesq(const at_command_t* data)
break;
default:
LOG_TRACE(ERROR, "USR-MAIN - AT+CESQ command type %d is not supported", data->type);
LOG_TRACE(ERROR, "USR-MAIN - AT+CESQ command type %d is not supported",
data->type);
_nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED;
ret_code = RETURNerror;
break;
......@@ -899,12 +888,12 @@ static int _nas_user_proc_cesq(const at_command_t* data)
** Others: _nas_user_data **
** **
***************************************************************************/
static int _nas_user_proc_cops(const at_command_t* data)
static int _nas_user_proc_cops(const at_command_t *data)
{
LOG_FUNC_IN;
int ret_code = RETURNok;
at_cops_resp_t * cops = &_nas_user_data.response.cops;
at_cops_resp_t *cops = &_nas_user_data.response.cops;
memset(cops, 0, sizeof(at_cops_resp_t));
static int read_format = AT_COPS_FORMAT_DEFAULT;
......@@ -922,8 +911,7 @@ static int _nas_user_proc_cops(const at_command_t* data)
_nas_user_data.mask = AT_RESPONSE_NO_PARAM;
_nas_user_data.cause_code = AT_ERROR_SUCCESS;
switch (data->type)
{
switch (data->type) {
case AT_COMMAND_SET:
if (_nas_user_context.sim_status != NAS_USER_READY) {
_nas_user_data.cause_code = AT_ERROR_SIM_PIN_REQUIRED;
......@@ -934,11 +922,9 @@ static int _nas_user_proc_cops(const at_command_t* data)
* GSM/UMTS/EPS network operator using the SIM/USIM card
* installed in the currently selected card slot.
*/
if (data->mask & AT_COPS_MODE_MASK)
{
if (data->mask & AT_COPS_MODE_MASK) {
mode = data->command.cops.mode;
switch (mode)
{
switch (mode) {
case AT_COPS_AUTO:
/*
* Register in automatic mode
......@@ -977,7 +963,8 @@ static int _nas_user_proc_cops(const at_command_t* data)
if ( (data->command.cops.format < AT_COPS_FORMAT_MIN) ||
(data->command.cops.format > AT_COPS_FORMAT_MAX) ) {
/* The value of <format> field is not valid */
LOG_TRACE(ERROR, "USR-MAIN - <format> parameter is not valid (%d)", data->command.cops.format);
LOG_TRACE(ERROR, "USR-MAIN - <format> parameter is not valid (%d)",
data->command.cops.format);
_nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS;
ret_code = RETURNerror;
break;
......@@ -985,12 +972,12 @@ static int _nas_user_proc_cops(const at_command_t* data)
read_format = format = data->command.cops.format;
/* Set the access technology */
if (data->mask & AT_COPS_ACT_MASK)
{
if (data->mask & AT_COPS_ACT_MASK) {
if ( (data->command.cops.AcT < AT_COPS_ACT_MIN) ||
(data->command.cops.AcT > AT_COPS_ACT_MAX) ) {
/* The value of <AcT> field is not valid */
LOG_TRACE(ERROR, "USR-MAIN - <AcT> parameter is not valid (%d)", data->command.cops.AcT);
LOG_TRACE(ERROR, "USR-MAIN - <AcT> parameter is not valid (%d)",
data->command.cops.AcT);
_nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS;
ret_code = RETURNerror;
break;
......@@ -1011,20 +998,19 @@ static int _nas_user_proc_cops(const at_command_t* data)
/*
* Set only <format> for read command +COPS?
*/
if (data->mask & AT_COPS_FORMAT_MASK)
{
if (data->mask & AT_COPS_FORMAT_MASK) {
if ( (data->command.cops.format < AT_COPS_FORMAT_MIN) ||
(data->command.cops.format > AT_COPS_FORMAT_MAX) ) {
/* The value of <format> field is not valid */
LOG_TRACE(ERROR, "USR-MAIN - <format> parameter is not valid (%d)", data->command.cops.format);
LOG_TRACE(ERROR, "USR-MAIN - <format> parameter is not valid (%d)",
data->command.cops.format);
_nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS;
ret_code = RETURNerror;
break;
}
/* Set to the selected representation format */
read_format = data->command.cops.format;
}
else {
} else {
/* Format is not present; set to default */
read_format = AT_COPS_FORMAT_DEFAULT;
}
......@@ -1042,8 +1028,7 @@ static int _nas_user_proc_cops(const at_command_t* data)
/*
* Performs network registration
*/
if (ret_code != RETURNerror)
{
if (ret_code != RETURNerror) {
if (mode == AT_COPS_DEREG) {
/* Force an attempt to deregister from the network */
ret_code = nas_proc_deregister();
......@@ -1052,8 +1037,7 @@ static int _nas_user_proc_cops(const at_command_t* data)
_nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED;
break;
}
}
else if (mode != AT_COPS_FORMAT) {
} else if (mode != AT_COPS_FORMAT) {
/* Force an attempt to automatically/manualy select
* and register the GSM/UMTS/EPS network operator */
ret_code = nas_proc_register(mode, format,
......@@ -1079,7 +1063,8 @@ static int _nas_user_proc_cops(const at_command_t* data)
&oper_is_selected, read_format,
&cops->get.plmn, &cops->get.AcT);
if (ret_code != RETURNok) {
LOG_TRACE(ERROR, "USR-MAIN - Failed to get registration data (<mode>=%d)", mode);
LOG_TRACE(ERROR, "USR-MAIN - Failed to get registration data (<mode>=%d)",
mode);
_nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED;
break;
}
......@@ -1087,11 +1072,9 @@ static int _nas_user_proc_cops(const at_command_t* data)
/* Set the network selection operating mode */
if (mode == NET_PLMN_AUTO) {
cops->get.mode = AT_COPS_AUTO;
}
else if (mode == NET_PLMN_MANUAL) {
} else if (mode == NET_PLMN_MANUAL) {
cops->get.mode = AT_COPS_MANUAL;
}
else {
} else {
cops->get.mode = AT_COPS_MANAUTO;
}
......@@ -1117,7 +1100,8 @@ static int _nas_user_proc_cops(const at_command_t* data)
break;
default:
LOG_TRACE(ERROR, "USR-MAIN - AT+COPS command type %d is not supported", data->type);
LOG_TRACE(ERROR, "USR-MAIN - AT+COPS command type %d is not supported",
data->type);
_nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED;
ret_code = RETURNerror;
break;
......@@ -1142,12 +1126,12 @@ static int _nas_user_proc_cops(const at_command_t* data)
** Others: _nas_user_data **
** **
***************************************************************************/
static int _nas_user_proc_cgatt(const at_command_t* data)
static int _nas_user_proc_cgatt(const at_command_t *data)
{
LOG_FUNC_IN;
int ret_code = RETURNok;
at_cgatt_resp_t * cgatt = &_nas_user_data.response.cgatt;
at_cgatt_resp_t *cgatt = &_nas_user_data.response.cgatt;
memset(cgatt, 0, sizeof(at_cgatt_resp_t));
_nas_user_data.id = data->id;
......@@ -1155,8 +1139,7 @@ static int _nas_user_proc_cgatt(const at_command_t* data)
_nas_user_data.mask = AT_RESPONSE_CGATT_MASK;
_nas_user_data.cause_code = AT_ERROR_SUCCESS;
switch (data->type)
{
switch (data->type) {
case AT_COMMAND_SET:
if (_nas_user_context.sim_status != NAS_USER_READY) {
_nas_user_data.cause_code = AT_ERROR_SIM_PIN_REQUIRED;
......@@ -1166,13 +1149,13 @@ static int _nas_user_proc_cgatt(const at_command_t* data)
* The execution command is used to attach the MT to, or detach the
* MT from, the EPS service
*/
if (data->mask & AT_CGATT_STATE_MASK)
{
if (data->mask & AT_CGATT_STATE_MASK) {
if ( (data->command.cgatt.state < AT_CGATT_STATE_MIN) ||
(data->command.cgatt.state > AT_CGATT_STATE_MAX) ) {
/* The value of the EPS attachment code is not valid;
* return an error message */
LOG_TRACE(ERROR, "USR-MAIN - <state> parameter is not valid (%d)", data->command.cgatt.state);
LOG_TRACE(ERROR, "USR-MAIN - <state> parameter is not valid (%d)",
data->command.cgatt.state);
_nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS;
ret_code = RETURNerror;
break;
......@@ -1183,8 +1166,7 @@ static int _nas_user_proc_cgatt(const at_command_t* data)
ret_code = RETURNerror;
if (data->command.cgatt.state == AT_CGATT_ATTACHED) {
ret_code = nas_proc_attach();
}
else if (data->command.cgatt.state == AT_CGATT_DETACHED) {
} else if (data->command.cgatt.state == AT_CGATT_DETACHED) {
ret_code = nas_proc_detach(FALSE);
}
if (ret_code != RETURNok) {
......@@ -1202,8 +1184,7 @@ static int _nas_user_proc_cgatt(const at_command_t* data)
*/
if (nas_proc_get_attach_status() != TRUE) {
cgatt->state = AT_CGATT_DETACHED;
}
else {
} else {
cgatt->state = AT_CGATT_ATTACHED;
}
break;
......@@ -1216,7 +1197,8 @@ static int _nas_user_proc_cgatt(const at_command_t* data)
break;
default:
LOG_TRACE(ERROR, "USR-MAIN - AT+CGATT command type %d is not supported", data->type);
LOG_TRACE(ERROR, "USR-MAIN - AT+CGATT command type %d is not supported",
data->type);
_nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED;
ret_code = RETURNerror;
break;
......@@ -1242,12 +1224,12 @@ static int _nas_user_proc_cgatt(const at_command_t* data)
** Others: _nas_user_data **
** **
***************************************************************************/
static int _nas_user_proc_creg(const at_command_t* data)
static int _nas_user_proc_creg(const at_command_t *data)
{
LOG_FUNC_IN;
int ret_code = RETURNok;
at_creg_resp_t * creg = &_nas_user_data.response.creg;
at_creg_resp_t *creg = &_nas_user_data.response.creg;
memset(creg, 0, sizeof(at_creg_resp_t));
static int n = AT_CREG_N_DEFAULT;
......@@ -1257,8 +1239,7 @@ static int _nas_user_proc_creg(const at_command_t* data)
_nas_user_data.mask = AT_RESPONSE_NO_PARAM;
_nas_user_data.cause_code = AT_ERROR_SUCCESS;
switch (data->type)
{
switch (data->type) {
case AT_COMMAND_SET:
if (_nas_user_context.sim_status != NAS_USER_READY) {
_nas_user_data.cause_code = AT_ERROR_SIM_PIN_REQUIRED;
......@@ -1270,8 +1251,7 @@ static int _nas_user_proc_creg(const at_command_t* data)
* network registration status, or when there is a change of the
* network cell in GERAN/UTRAN/E-UTRAN.
*/
if (data->mask & AT_CREG_N_MASK)
{
if (data->mask & AT_CREG_N_MASK) {
if ( (data->command.creg.n < AT_CREG_N_MIN) ||
(data->command.creg.n > AT_CREG_N_MAX) ) {
/* The value of the unsolicited result code is not valid;
......@@ -1284,15 +1264,13 @@ static int _nas_user_proc_creg(const at_command_t* data)
}
/* Set to the selected parameter value */
n = data->command.creg.n;
}
else {
} else {
/* The numeric parameter is not present; set to default */
n = AT_CREG_N_DEFAULT;
}
/* Disable/Enable network logging */
switch (n)
{
switch (n) {
case AT_CREG_OFF:
/* Disable logging of network registration status */
ret_code = user_ind_deregister(USER_IND_REG);
......@@ -1301,7 +1279,8 @@ static int _nas_user_proc_creg(const at_command_t* data)
ret_code = user_ind_deregister(USER_IND_LOC);
}
if (ret_code != RETURNok) {
LOG_TRACE(ERROR, "USR-MAIN - Failed to disable logging of network notification");
LOG_TRACE(ERROR,
"USR-MAIN - Failed to disable logging of network notification");
_nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED;
}
break;
......@@ -1332,8 +1311,7 @@ static int _nas_user_proc_creg(const at_command_t* data)
* elements when the MT is registered in the network.
*/
creg->n = n;
switch (n)
{
switch (n) {
case AT_CREG_BOTH:
/* Location Area Code (lac) is not available */
case AT_CREG_OFF:
......@@ -1356,7 +1334,8 @@ static int _nas_user_proc_creg(const at_command_t* data)
break;
default:
LOG_TRACE(ERROR, "USR-MAIN - AT+CREG command type %d is not supported", data->type);
LOG_TRACE(ERROR, "USR-MAIN - AT+CREG command type %d is not supported",
data->type);
_nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED;
ret_code = RETURNerror;
break;
......@@ -1382,12 +1361,12 @@ static int _nas_user_proc_creg(const at_command_t* data)
** Others: _nas_user_data **
** **
***************************************************************************/
static int _nas_user_proc_cgreg(const at_command_t* data)
static int _nas_user_proc_cgreg(const at_command_t *data)
{
LOG_FUNC_IN;
int ret_code = RETURNok;
at_cgreg_resp_t * cgreg = &_nas_user_data.response.cgreg;
at_cgreg_resp_t *cgreg = &_nas_user_data.response.cgreg;
memset(cgreg, 0, sizeof(at_cgreg_resp_t));
static int n = AT_CGREG_N_DEFAULT;
......@@ -1397,8 +1376,7 @@ static int _nas_user_proc_cgreg(const at_command_t* data)
_nas_user_data.mask = AT_RESPONSE_NO_PARAM;
_nas_user_data.cause_code = AT_ERROR_SUCCESS;
switch (data->type)
{
switch (data->type) {
case AT_COMMAND_SET:
if (_nas_user_context.sim_status != NAS_USER_READY) {
_nas_user_data.cause_code = AT_ERROR_SIM_PIN_REQUIRED;
......@@ -1410,8 +1388,7 @@ static int _nas_user_proc_cgreg(const at_command_t* data)
* registration status, or when there is a change of the network
* cell in GERAN/UTRAN.
*/
if (data->mask & AT_CGREG_N_MASK)
{
if (data->mask & AT_CGREG_N_MASK) {
if ( (data->command.cgreg.n < AT_CGREG_N_MIN) ||
(data->command.cgreg.n > AT_CGREG_N_MAX) ) {
/* The value of the unsolicited result code is not valid;
......@@ -1424,15 +1401,13 @@ static int _nas_user_proc_cgreg(const at_command_t* data)
}
/* Set to the selected parameter value */
n = data->command.cgreg.n;
}
else {
} else {
/* The numeric parameter is not present; set to default */
n = AT_CGREG_N_DEFAULT;
}
/* Disable/Enable network logging */
switch (n)
{
switch (n) {
case AT_CGREG_OFF:
/* Disable logging of network registration status */
ret_code = user_ind_deregister(USER_IND_REG);
......@@ -1441,7 +1416,8 @@ static int _nas_user_proc_cgreg(const at_command_t* data)
ret_code = user_ind_deregister(USER_IND_LOC);
}
if (ret_code != RETURNok) {
LOG_TRACE(ERROR, "USR-MAIN - Failed to disable logging of network notification");
LOG_TRACE(ERROR,
"USR-MAIN - Failed to disable logging of network notification");
_nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED;
}
break;
......@@ -1472,8 +1448,7 @@ static int _nas_user_proc_cgreg(const at_command_t* data)
* elements when the MT is registered in the network.
*/
cgreg->n = n;
switch (n)
{
switch (n) {
case AT_CGREG_BOTH:
/* Location Area Code (lac) is not available */
case AT_CGREG_OFF:
......@@ -1496,7 +1471,8 @@ static int _nas_user_proc_cgreg(const at_command_t* data)
break;
default:
LOG_TRACE(ERROR, "USR-MAIN - AT+CGREG command type %d is not supported", data->type);
LOG_TRACE(ERROR, "USR-MAIN - AT+CGREG command type %d is not supported",
data->type);
_nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED;
ret_code = RETURNerror;
break;
......@@ -1522,12 +1498,12 @@ static int _nas_user_proc_cgreg(const at_command_t* data)
** Others: _nas_user_data **
** **
***************************************************************************/
static int _nas_user_proc_cereg(const at_command_t* data)
static int _nas_user_proc_cereg(const at_command_t *data)
{
LOG_FUNC_IN;
int ret_code = RETURNok;
at_cereg_resp_t * cereg = &_nas_user_data.response.cereg;
at_cereg_resp_t *cereg = &_nas_user_data.response.cereg;
memset(cereg, 0, sizeof(at_cereg_resp_t));
static int n = AT_CEREG_N_DEFAULT;
......@@ -1537,8 +1513,7 @@ static int _nas_user_proc_cereg(const at_command_t* data)
_nas_user_data.mask = AT_RESPONSE_NO_PARAM;
_nas_user_data.cause_code = AT_ERROR_SUCCESS;
switch (data->type)
{
switch (data->type) {
case AT_COMMAND_SET:
if (_nas_user_context.sim_status != NAS_USER_READY) {
_nas_user_data.cause_code = AT_ERROR_SIM_PIN_REQUIRED;
......@@ -1550,8 +1525,7 @@ static int _nas_user_proc_cereg(const at_command_t* data)
* registration status, or when there is a change of the network
* cell in E-UTRAN.
*/
if (data->mask & AT_CEREG_N_MASK)
{
if (data->mask & AT_CEREG_N_MASK) {
if ( (data->command.cereg.n < AT_CEREG_N_MIN) ||
(data->command.cereg.n > AT_CEREG_N_MAX) ) {
/* The value of the unsolicited result code is not valid;
......@@ -1564,15 +1538,13 @@ static int _nas_user_proc_cereg(const at_command_t* data)
}
/* Set to the selected parameter value */
n = data->command.cereg.n;
}
else {
} else {
/* The numeric parameter is not present; set to default */
n = AT_CEREG_N_DEFAULT;
}
/* Disable/Enable network logging */
switch (n)
{
switch (n) {
case AT_CEREG_OFF:
/* Disable logging of network registration status */
ret_code = user_ind_deregister(USER_IND_REG);
......@@ -1581,7 +1553,8 @@ static int _nas_user_proc_cereg(const at_command_t* data)
ret_code = user_ind_deregister(USER_IND_LOC);
}
if (ret_code != RETURNok) {
LOG_TRACE(ERROR, "USR-MAIN - Failed to disable logging of network notification");
LOG_TRACE(ERROR,
"USR-MAIN - Failed to disable logging of network notification");
_nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED;
}
break;
......@@ -1619,8 +1592,7 @@ static int _nas_user_proc_cereg(const at_command_t* data)
* elements when the MT is registered in the network.
*/
cereg->n = n;
switch (n)
{
switch (n) {
case AT_CEREG_BOTH:
/* Get EPS location information */
ret_code = nas_proc_get_loc_info(cereg->tac, cereg->ci,
......@@ -1661,7 +1633,8 @@ static int _nas_user_proc_cereg(const at_command_t* data)
break;
default:
LOG_TRACE(ERROR, "USR-MAIN - AT+CEREG command type %d is not supported", data->type);
LOG_TRACE(ERROR, "USR-MAIN - AT+CEREG command type %d is not supported",
data->type);
_nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED;
ret_code = RETURNerror;
break;
......@@ -1692,17 +1665,17 @@ static int _nas_user_proc_cereg(const at_command_t* data)
** Others: _nas_user_data **
** **
***************************************************************************/
static int _nas_user_proc_cgdcont(const at_command_t* data)
static int _nas_user_proc_cgdcont(const at_command_t *data)
{
LOG_FUNC_IN;
int ret_code = RETURNok;
at_cgdcont_get_t * cgdcont = &_nas_user_data.response.cgdcont.get;
at_cgdcont_get_t *cgdcont = &_nas_user_data.response.cgdcont.get;
memset(cgdcont, 0, sizeof(at_cgdcont_resp_t));
int cid = AT_CGDCONT_CID_DEFAULT;
int pdn_type = NET_PDN_TYPE_IPV4;
const char* apn = NULL;
const char *apn = NULL;
int ipv4_addr_allocation = AT_CGDCONT_IPV4_DEFAULT;
int emergency = AT_CGDCONT_EBS_DEFAULT;
int p_cscf = AT_CGDCONT_PCSCF_DEFAULT;
......@@ -1714,8 +1687,7 @@ static int _nas_user_proc_cgdcont(const at_command_t* data)
_nas_user_data.mask = AT_RESPONSE_NO_PARAM;
_nas_user_data.cause_code = AT_ERROR_SUCCESS;
switch (data->type)
{
switch (data->type) {
case AT_COMMAND_SET:
if (_nas_user_context.sim_status != NAS_USER_READY) {
_nas_user_data.cause_code = AT_ERROR_SIM_PIN_REQUIRED;
......@@ -1725,8 +1697,7 @@ static int _nas_user_proc_cgdcont(const at_command_t* data)
* Set command specifies PDN connection and its default
* EPS bearer context parameter values
*/
if (data->mask & AT_CGDCONT_CID_MASK)
{
if (data->mask & AT_CGDCONT_CID_MASK) {
if (data->command.cgdcont.cid < AT_CGDCONT_CID_MIN) {
/* The value of the PDP context identifier is not valid;
* return an error message */
......@@ -1738,18 +1709,14 @@ static int _nas_user_proc_cgdcont(const at_command_t* data)
}
cid = data->command.cgdcont.cid;
}
if (data->mask & AT_CGDCONT_PDP_TYPE_MASK)
{
if (data->mask & AT_CGDCONT_PDP_TYPE_MASK) {
if (strcmp(data->command.cgdcont.PDP_type, "IP") == 0) {
pdn_type = NET_PDN_TYPE_IPV4;
}
else if (strcmp(data->command.cgdcont.PDP_type, "IPV6") == 0) {
} else if (strcmp(data->command.cgdcont.PDP_type, "IPV6") == 0) {
pdn_type = NET_PDN_TYPE_IPV6;
}
else if (strcmp(data->command.cgdcont.PDP_type,"IPV4V6") == 0) {
} else if (strcmp(data->command.cgdcont.PDP_type,"IPV4V6") == 0) {
pdn_type = NET_PDN_TYPE_IPV4V6;
}
else {
} else {
/* The value of the PDP type is not valid;
* return an error message */
LOG_TRACE(ERROR, "USR-MAIN - <PDN_type> parameter is not "
......@@ -1760,12 +1727,10 @@ static int _nas_user_proc_cgdcont(const at_command_t* data)
}
reset_pdn = FALSE;
}
if (data->mask & AT_CGDCONT_APN_MASK)
{
if (data->mask & AT_CGDCONT_APN_MASK) {
apn = data->command.cgdcont.APN;
}
if (data->mask & AT_CGDCONT_D_COMP_MASK)
{
if (data->mask & AT_CGDCONT_D_COMP_MASK) {
if ( (data->command.cgdcont.d_comp < AT_CGDCONT_D_COMP_MIN) ||
(data->command.cgdcont.d_comp > AT_CGDCONT_D_COMP_MAX) ) {
/* The value of the PDP data compression parameter is
......@@ -1778,8 +1743,7 @@ static int _nas_user_proc_cgdcont(const at_command_t* data)
}
/* Not supported: Applicable for SNDCP only */
}
if (data->mask & AT_CGDCONT_H_COMP_MASK)
{
if (data->mask & AT_CGDCONT_H_COMP_MASK) {
if ( (data->command.cgdcont.h_comp < AT_CGDCONT_H_COMP_MIN) ||
(data->command.cgdcont.h_comp > AT_CGDCONT_H_COMP_MAX) ) {
/* The value of the PDP header compression parameter is
......@@ -1792,9 +1756,9 @@ static int _nas_user_proc_cgdcont(const at_command_t* data)
}
/* Not supported */
}
if (data->mask & AT_CGDCONT_IPV4ADDRALLOC_MASK)
{
if ( (data->command.cgdcont.IPv4AddrAlloc < AT_CGDCONT_IPV4_MIN) || (data->command.cgdcont.IPv4AddrAlloc > AT_CGDCONT_IPV4_MAX) ) {
if (data->mask & AT_CGDCONT_IPV4ADDRALLOC_MASK) {
if ( (data->command.cgdcont.IPv4AddrAlloc < AT_CGDCONT_IPV4_MIN)
|| (data->command.cgdcont.IPv4AddrAlloc > AT_CGDCONT_IPV4_MAX) ) {
/* The value of the IPv4 address allocation parameter is
* not valid; return an error message */
LOG_TRACE(ERROR, "USR-MAIN - <IPv4AddrAlloc> parameter "
......@@ -1806,9 +1770,9 @@ static int _nas_user_proc_cgdcont(const at_command_t* data)
}
ipv4_addr_allocation = data->command.cgdcont.IPv4AddrAlloc;
}
if (data->mask & AT_CGDCONT_EMERGECY_INDICATION_MASK)
{
if ( (data->command.cgdcont.emergency_indication < AT_CGDCONT_EBS_MIN) || (data->command.cgdcont.emergency_indication > AT_CGDCONT_EBS_MAX) ) {
if (data->mask & AT_CGDCONT_EMERGECY_INDICATION_MASK) {
if ( (data->command.cgdcont.emergency_indication < AT_CGDCONT_EBS_MIN)
|| (data->command.cgdcont.emergency_indication > AT_CGDCONT_EBS_MAX) ) {
/* The value of the emergency indication parameter is
* not valid; return an error message */
LOG_TRACE(ERROR, "USR-MAIN - <emergency indication> "
......@@ -1820,9 +1784,9 @@ static int _nas_user_proc_cgdcont(const at_command_t* data)
}
emergency = data->command.cgdcont.emergency_indication;
}
if (data->mask & AT_CGDCONT_P_CSCF_DISCOVERY_MASK)
{
if ( (data->command.cgdcont.P_CSCF_discovery < AT_CGDCONT_PCSCF_MIN) || (data->command.cgdcont.P_CSCF_discovery > AT_CGDCONT_PCSCF_MAX) ) {
if (data->mask & AT_CGDCONT_P_CSCF_DISCOVERY_MASK) {
if ( (data->command.cgdcont.P_CSCF_discovery < AT_CGDCONT_PCSCF_MIN)
|| (data->command.cgdcont.P_CSCF_discovery > AT_CGDCONT_PCSCF_MAX) ) {
/* The value of the P-CSCF address discovery parameter is
* not valid; return an error message */
LOG_TRACE(ERROR, "USR-MAIN - <P-CSCF_discovery> "
......@@ -1834,9 +1798,9 @@ static int _nas_user_proc_cgdcont(const at_command_t* data)
}
p_cscf = data->command.cgdcont.P_CSCF_discovery;
}
if (data->mask & AT_CGDCONT_IM_CN_SIGNALLING_FLAG_IND_MASK)
{
if ( (data->command.cgdcont.IM_CN_Signalling_Flag_Ind < AT_CGDCONT_IM_CM_MIN) || (data->command.cgdcont.IM_CN_Signalling_Flag_Ind > AT_CGDCONT_IM_CM_MAX) ) {
if (data->mask & AT_CGDCONT_IM_CN_SIGNALLING_FLAG_IND_MASK) {
if ( (data->command.cgdcont.IM_CN_Signalling_Flag_Ind < AT_CGDCONT_IM_CM_MIN)
|| (data->command.cgdcont.IM_CN_Signalling_Flag_Ind > AT_CGDCONT_IM_CM_MAX) ) {
/* The value of the IM CN subsystem-related signalling
* support indication is not valid;
* return an error message */
......@@ -1856,8 +1820,7 @@ static int _nas_user_proc_cgdcont(const at_command_t* data)
/* A special form of the set command, +CGDCONT=<cid> causes
* the values for context number <cid> to become undefined */
ret_code = nas_proc_reset_pdn(cid);
}
else {
} else {
/* Define a new PDN connection */
ret_code = nas_proc_set_pdn(cid, pdn_type, apn,
ipv4_addr_allocation, emergency,
......@@ -1897,8 +1860,7 @@ static int _nas_user_proc_cgdcont(const at_command_t* data)
/* The range is defined by the user interface */
_nas_user_data.response.cgdcont.tst.n_cid =
AT_CGDCONT_RESP_SIZE;
}
else {
} else {
/* The range is defined by the ESM sublayer application */
_nas_user_data.response.cgdcont.tst.n_cid = cid_max;
}
......@@ -1906,7 +1868,8 @@ static int _nas_user_proc_cgdcont(const at_command_t* data)
break;
default:
LOG_TRACE(ERROR, "USR-MAIN - AT+CGDCONT command type %d is not supported", data->type);
LOG_TRACE(ERROR, "USR-MAIN - AT+CGDCONT command type %d is not supported",
data->type);
_nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED;
ret_code = RETURNerror;
break;
......@@ -1932,12 +1895,12 @@ static int _nas_user_proc_cgdcont(const at_command_t* data)
** Others: _nas_user_data **
** **
***************************************************************************/
static int _nas_user_proc_cgact(const at_command_t* data)
static int _nas_user_proc_cgact(const at_command_t *data)
{
LOG_FUNC_IN;
int ret_code = RETURNok;
at_cgact_resp_t * cgact = &_nas_user_data.response.cgact;
at_cgact_resp_t *cgact = &_nas_user_data.response.cgact;
memset(cgact, 0, sizeof(at_cgact_resp_t));
int cid = -1;
......@@ -1948,8 +1911,7 @@ static int _nas_user_proc_cgact(const at_command_t* data)
_nas_user_data.mask = AT_RESPONSE_CGACT_MASK;
_nas_user_data.cause_code = AT_ERROR_SUCCESS;
switch (data->type)
{
switch (data->type) {
case AT_COMMAND_SET:
if (_nas_user_context.sim_status != NAS_USER_READY) {
_nas_user_data.cause_code = AT_ERROR_SIM_PIN_REQUIRED;
......@@ -1959,8 +1921,7 @@ static int _nas_user_proc_cgact(const at_command_t* data)
* The execution command is used to activate or deactivate
* the specified PDN/EPS bearer context(s).
*/
if (data->mask & AT_CGACT_STATE_MASK)
{
if (data->mask & AT_CGACT_STATE_MASK) {
if ( (data->command.cgact.state < AT_CGACT_STATE_MIN) ||
(data->command.cgact.state > AT_CGACT_STATE_MAX) ) {
/* The value of the PDP context activation status is
......@@ -1973,8 +1934,7 @@ static int _nas_user_proc_cgact(const at_command_t* data)
}
state = data->command.cgact.state;
}
if (data->mask & AT_CGACT_CID_MASK)
{
if (data->mask & AT_CGACT_CID_MASK) {
if (data->command.cgact.cid < AT_CGACT_CID_MIN) {
/* The value of the PDP context identifier is not valid;
* return an error message */
......@@ -1992,8 +1952,7 @@ static int _nas_user_proc_cgact(const at_command_t* data)
ret_code = RETURNerror;
if (state == AT_CGACT_DEACTIVATED) {
ret_code = nas_proc_deactivate_pdn(cid);
}
else if (state == AT_CGACT_ACTIVATED) {
} else if (state == AT_CGACT_ACTIVATED) {
ret_code = nas_proc_activate_pdn(cid);
}
if (ret_code != RETURNok) {
......@@ -2027,7 +1986,8 @@ static int _nas_user_proc_cgact(const at_command_t* data)
break;
default:
LOG_TRACE(ERROR, "USR-MAIN - AT+CGACT command type %d is not supported", data->type);
LOG_TRACE(ERROR, "USR-MAIN - AT+CGACT command type %d is not supported",
data->type);
_nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED;
ret_code = RETURNerror;
break;
......@@ -2053,12 +2013,12 @@ static int _nas_user_proc_cgact(const at_command_t* data)
** Others: _nas_user_data **
** **
***************************************************************************/
static int _nas_user_proc_cmee(const at_command_t* data)
static int _nas_user_proc_cmee(const at_command_t *data)
{
LOG_FUNC_IN;
int ret_code = RETURNok;
at_cmee_resp_t * cmee = &_nas_user_data.response.cmee;
at_cmee_resp_t *cmee = &_nas_user_data.response.cmee;
memset(cmee, 0, sizeof(at_cmee_resp_t));
int n = AT_CMEE_N_DEFAULT;
......@@ -2068,8 +2028,7 @@ static int _nas_user_proc_cmee(const at_command_t* data)
_nas_user_data.mask = AT_RESPONSE_CMEE_MASK;
_nas_user_data.cause_code = AT_ERROR_SUCCESS;
switch (data->type)
{
switch (data->type) {
case AT_COMMAND_ACT: /* ATV0, ATV1 response format commands */
case AT_COMMAND_SET:
/*
......@@ -2077,8 +2036,7 @@ static int _nas_user_proc_cmee(const at_command_t* data)
* +CME ERROR: <err> as an indication of an error relating to the
* functionality of the MT.
*/
if (data->mask & AT_CMEE_N_MASK)
{
if (data->mask & AT_CMEE_N_MASK) {
if ( (data->command.cmee.n < AT_CMEE_N_MIN) ||
(data->command.cmee.n > AT_CMEE_N_MAX) ) {
/* The value of the numeric parameter is not valid;
......@@ -2094,8 +2052,7 @@ static int _nas_user_proc_cmee(const at_command_t* data)
}
/* Disable/Enable final result code logging */
switch (n)
{
switch (n) {
case AT_CMEE_OFF:
/* Disable logging of final result code */
at_error_set_format(AT_ERROR_OFF);
......@@ -2139,7 +2096,8 @@ static int _nas_user_proc_cmee(const at_command_t* data)
break;
default:
LOG_TRACE(ERROR, "USR-MAIN - AT+CMEE command type %d is not supported", data->type);
LOG_TRACE(ERROR, "USR-MAIN - AT+CMEE command type %d is not supported",
data->type);
_nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED;
ret_code = RETURNerror;
break;
......@@ -2164,12 +2122,12 @@ static int _nas_user_proc_cmee(const at_command_t* data)
** Others: _nas_user_data **
** **
***************************************************************************/
static int _nas_user_proc_clck(const at_command_t* data)
static int _nas_user_proc_clck(const at_command_t *data)
{
LOG_FUNC_IN;
int ret_code = RETURNok;
at_clck_resp_t * clck = &_nas_user_data.response.clck;
at_clck_resp_t *clck = &_nas_user_data.response.clck;
memset(clck, 0, sizeof(at_clck_resp_t));
_nas_user_data.id = data->id;
......@@ -2177,8 +2135,7 @@ static int _nas_user_proc_clck(const at_command_t* data)
_nas_user_data.mask = AT_RESPONSE_CLCK_MASK;
_nas_user_data.cause_code = AT_ERROR_SUCCESS;
switch (data->type)
{
switch (data->type) {
case AT_COMMAND_SET:
/*
* Execution command locks, unlocks or returns status of a network
......@@ -2187,8 +2144,7 @@ static int _nas_user_proc_clck(const at_command_t* data)
/* Check facility parameter */
if (strncmp(data->command.clck.fac, AT_CLCK_SC,
AT_CLCK_FAC_SIZE) != 0)
{
AT_CLCK_FAC_SIZE) != 0) {
/* Facilities other than SIM is not supported */
LOG_TRACE(ERROR, "USR-MAIN - Facility is not supported (%s)",
data->command.clck.fac);
......@@ -2197,8 +2153,7 @@ static int _nas_user_proc_clck(const at_command_t* data)
break;
}
/* Check password parameter */
if (data->mask & AT_CLCK_PASSWD_MASK)
{
if (data->mask & AT_CLCK_PASSWD_MASK) {
/* Check the PIN code */
if (strncmp(_nas_user_nvdata.PIN,
data->command.clck.passwd, USER_PIN_SIZE) != 0) {
......@@ -2211,8 +2166,7 @@ static int _nas_user_proc_clck(const at_command_t* data)
}
}
/* Execute the command with specified mode of operation */
switch (data->command.clck.mode)
{
switch (data->command.clck.mode) {
case AT_CLCK_UNLOCK:
/* unlock facility */
if ( !(data->mask & AT_CLCK_PASSWD_MASK) ) {
......@@ -2266,7 +2220,8 @@ static int _nas_user_proc_clck(const at_command_t* data)
break;
default:
LOG_TRACE(ERROR, "USR-MAIN - AT+CLCK command type %d is not supported", data->type);
LOG_TRACE(ERROR, "USR-MAIN - AT+CLCK command type %d is not supported",
data->type);
_nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED;
ret_code = RETURNerror;
break;
......@@ -2291,12 +2246,12 @@ static int _nas_user_proc_clck(const at_command_t* data)
** Others: _nas_user_data **
** **
***************************************************************************/
static int _nas_user_proc_cgpaddr(const at_command_t* data)
static int _nas_user_proc_cgpaddr(const at_command_t *data)
{
LOG_FUNC_IN;
int ret_code = RETURNok;
at_cgpaddr_resp_t * cgpaddr = &_nas_user_data.response.cgpaddr;
at_cgpaddr_resp_t *cgpaddr = &_nas_user_data.response.cgpaddr;
memset(cgpaddr, 0, sizeof(at_cgpaddr_resp_t));
int cid = -1;
......@@ -2306,8 +2261,7 @@ static int _nas_user_proc_cgpaddr(const at_command_t* data)
_nas_user_data.mask = AT_RESPONSE_CGPADDR_MASK;
_nas_user_data.cause_code = AT_ERROR_SUCCESS;
switch (data->type)
{
switch (data->type) {
case AT_COMMAND_SET:
if (_nas_user_context.sim_status != NAS_USER_READY) {
_nas_user_data.cause_code = AT_ERROR_SIM_PIN_REQUIRED;
......@@ -2317,8 +2271,7 @@ static int _nas_user_proc_cgpaddr(const at_command_t* data)
* The execution command returns a list of PDP addresses for
* the specified context identifiers
*/
if (data->mask & AT_CGPADDR_CID_MASK)
{
if (data->mask & AT_CGPADDR_CID_MASK) {
if (data->command.cgpaddr.cid < AT_CGPADDR_CID_MIN) {
/* The value of the PDP context identifier is not valid;
* return an error message */
......@@ -2380,12 +2333,12 @@ static int _nas_user_proc_cgpaddr(const at_command_t* data)
** Others: _nas_user_data **
** **
***************************************************************************/
static int _nas_user_proc_cnum(const at_command_t* data)
static int _nas_user_proc_cnum(const at_command_t *data)
{
LOG_FUNC_IN;
int ret_code = RETURNok;
at_cnum_resp_t * cnum = &_nas_user_data.response.cnum;
at_cnum_resp_t *cnum = &_nas_user_data.response.cnum;
memset(cnum, 0, sizeof(at_cnum_resp_t));
_nas_user_data.id = data->id;
......@@ -2393,8 +2346,7 @@ static int _nas_user_proc_cnum(const at_command_t* data)
_nas_user_data.mask = AT_RESPONSE_CNUM_MASK;
_nas_user_data.cause_code = AT_ERROR_SUCCESS;
switch (data->type)
{
switch (data->type) {
case AT_COMMAND_ACT:
if (_nas_user_context.sim_status != NAS_USER_READY) {
_nas_user_data.cause_code = AT_ERROR_SIM_PIN_REQUIRED;
......@@ -2439,12 +2391,12 @@ static int _nas_user_proc_cnum(const at_command_t* data)
** Others: _nas_user_data **
** **
***************************************************************************/
static int _nas_user_proc_clac(const at_command_t* data)
static int _nas_user_proc_clac(const at_command_t *data)
{
LOG_FUNC_IN;
int ret_code = RETURNok;
at_clac_resp_t * clac = &_nas_user_data.response.clac;
at_clac_resp_t *clac = &_nas_user_data.response.clac;
memset(clac, 0, sizeof(at_clac_resp_t));
_nas_user_data.id = data->id;
......@@ -2452,8 +2404,7 @@ static int _nas_user_proc_clac(const at_command_t* data)
_nas_user_data.mask = AT_RESPONSE_CLAC_MASK;
_nas_user_data.cause_code = AT_ERROR_SUCCESS;
switch (data->type)
{
switch (data->type) {
case AT_COMMAND_ACT:
/* Get the list of supported AT commands */
clac->n_acs = at_command_get_list(clac->ac, AT_CLAC_RESP_SIZE);
......
......@@ -37,10 +37,11 @@ Description NAS procedure functions triggered by the user
/****************** E X P O R T E D F U N C T I O N S ******************/
/****************************************************************************/
void nas_user_initialize(emm_indication_callback_t emm_cb, esm_indication_callback_t esm_cb, const char* version);
void nas_user_initialize(emm_indication_callback_t emm_cb,
esm_indication_callback_t esm_cb, const char *version);
int nas_user_process_data(const void* data);
int nas_user_process_data(const void *data);
const void* nas_user_get_data(void);
const void *nas_user_get_data(void);
#endif /* __NAS_USER_H__*/
......@@ -31,5 +31,6 @@ else
include Makefile.inc
libnas_la_SOURCES = \
nas_main.c \
nas_itti_messaging.c nas_itti_messaging.h \
$(libnas_SRCS)
endif
\ No newline at end of file
/*******************************************************************************
Eurecom OpenAirInterface
Copyright(c) 1999 - 2013 Eurecom
This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License,
version 2, as published by the Free Software Foundation.
This program is distributed in the hope it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
The full GNU General Public License is included in this distribution in
the file called "COPYING".
Contact Information
Openair Admin: openair_admin@eurecom.fr
Openair Tech : openair_tech@eurecom.fr
Forums : http://forums.eurecom.fr/openairinterface
Address : EURECOM, Campus SophiaTech, 450 Route des Chappes
06410 Biot FRANCE
*******************************************************************************/
#include "intertask_interface.h"
#include "nas_itti_messaging.h"
int nas_itti_dl_data_req(const uint32_t ue_id, void * const data,
const uint32_t length)
{
MessageDef *message_p;
message_p = itti_alloc_new_message(TASK_NAS, NAS_DOWNLINK_DATA_REQ);
NAS_DL_DATA_REQ(message_p).UEid = ue_id;
NAS_DL_DATA_REQ(message_p).nasMsg.data = data;
NAS_DL_DATA_REQ(message_p).nasMsg.length = length;
return itti_send_msg_to_task(TASK_S1AP, INSTANCE_DEFAULT, message_p);
}
/*******************************************************************************
Eurecom OpenAirInterface
Copyright(c) 1999 - 2013 Eurecom
This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License,
version 2, as published by the Free Software Foundation.
This program is distributed in the hope it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
The full GNU General Public License is included in this distribution in
the file called "COPYING".
Contact Information
Openair Admin: openair_admin@eurecom.fr
Openair Tech : openair_tech@eurecom.fr
Forums : http://forums.eurecom.fr/openairinterface
Address : EURECOM, Campus SophiaTech, 450 Route des Chappes
06410 Biot FRANCE
*******************************************************************************/
#ifndef NAS_ITTI_MESSAGING_H_
#define NAS_ITTI_MESSAGING_H_
int nas_itti_dl_data_req(const uint32_t ue_id, void * const data,
const uint32_t length);
#endif /* NAS_ITTI_MESSAGING_H_ */
......@@ -61,10 +61,12 @@ next_message:
nas_est_ind_p->initialNasMsg.length);
#endif
} break;
case NAS_ATTACH_ACCEPT: {
itti_send_msg_to_task(TASK_S1AP, INSTANCE_DEFAULT, received_message_p);
goto next_message;
} break;
case NAS_AUTHENTICATION_REQ: {
MessageDef *message_p;
nas_auth_resp_t *nas_resp_p;
......@@ -79,9 +81,21 @@ next_message:
itti_send_msg_to_task(TASK_MME_APP, INSTANCE_DEFAULT, message_p);
} break;
case NAS_UPLINK_DATA_IND: {
nas_proc_ul_transfer_ind(NAS_UL_DATA_IND(received_message_p).UEid,
NAS_UL_DATA_IND(received_message_p).nasMsg.data,
NAS_UL_DATA_IND(received_message_p).nasMsg.length);
} break;
case NAS_DOWNLINK_DATA_CNF: {
nas_proc_dl_transfer_cnf(NAS_DL_DATA_CNF(received_message_p).UEid);
} break;
case TERMINATE_MESSAGE: {
itti_exit_task();
} break;
default: {
NAS_DEBUG("Unkwnon message ID %d:%s\n",
ITTI_MSG_ID(received_message_p),
......
......@@ -103,50 +103,58 @@ void *s1ap_mme_thread(void *args)
switch (ITTI_MSG_ID(received_message_p))
{
case S1AP_SCTP_NEW_MESSAGE_IND: {
case SCTP_DATA_IND: {
/* New message received from SCTP layer.
* Decode and handle it.
*/
s1ap_message message;
s1ap_sctp_new_msg_ind_t *s1ap_sctp_new_msg_ind_p;
s1ap_sctp_new_msg_ind_p = &received_message_p->ittiMsg.s1ap_sctp_new_msg_ind;
memset((void *)&message, 0, sizeof(s1ap_message));
/* Invoke S1AP message decoder */
if (s1ap_mme_decode_pdu(&message, s1ap_sctp_new_msg_ind_p->buffer, s1ap_sctp_new_msg_ind_p->buf_length) < 0) {
if (s1ap_mme_decode_pdu(&message,
SCTP_DATA_IND(received_message_p).buffer,
SCTP_DATA_IND(received_message_p).buf_length) < 0)
{
// TODO: Notify eNB of failure with right cause
S1AP_ERROR("Failed to decode new buffer\n");
} else {
s1ap_mme_handle_message(s1ap_sctp_new_msg_ind_p->assoc_id, s1ap_sctp_new_msg_ind_p->stream, &message);
s1ap_mme_handle_message(SCTP_DATA_IND(received_message_p).assoc_id,
SCTP_DATA_IND(received_message_p).stream,
&message);
}
// Free received PDU array
free(s1ap_sctp_new_msg_ind_p->buffer);
/* Free received PDU array */
free(SCTP_DATA_IND(received_message_p).buffer);
} break;
/* SCTP layer notifies S1AP of disconnection of a peer. */
case SCTP_CLOSE_ASSOCIATION: {
sctp_close_association_t *sctp_close_association_p;
sctp_close_association_p = &received_message_p->ittiMsg.sctp_close_association;
s1ap_handle_sctp_deconnection(sctp_close_association_p->assoc_id);
s1ap_handle_sctp_deconnection(SCTP_CLOSE_ASSOCIATION(received_message_p).assoc_id);
} break;
case SCTP_NEW_ASSOCIATION: {
s1ap_handle_new_association(&received_message_p->ittiMsg.sctp_new_peer);
} break;
case NAS_DOWNLINK_DATA_IND: {
case NAS_DOWNLINK_DATA_REQ: {
/* New message received from NAS task.
* This corresponds to a S1AP downlink nas transport message.
*/
s1ap_generate_downlink_nas_transport(&received_message_p->ittiMsg.nas_dl_data_ind);
s1ap_generate_downlink_nas_transport(&NAS_DL_DATA_REQ(received_message_p));
} break;
case NAS_ATTACH_ACCEPT: {
s1ap_handle_attach_accepted(&received_message_p->ittiMsg.nas_attach_accept);
} break;
case TIMER_HAS_EXPIRED: {
s1ap_handle_timer_expiry(&received_message_p->ittiMsg.timer_has_expired);
} break;
case TERMINATE_MESSAGE: {
itti_exit_task();
} break;
default: {
S1AP_DEBUG("Unkwnon message ID %d:%s\n",
ITTI_MSG_ID(received_message_p), ITTI_MSG_NAME(received_message_p));
......
......@@ -34,21 +34,38 @@ int s1ap_mme_itti_send_sctp_request(uint8_t *buffer, uint32_t length,
uint32_t assoc_id, uint16_t stream)
{
MessageDef *message_p;
SctpNewDataReq *sctpNewDataReq_p;
message_p = itti_alloc_new_message(TASK_SCTP, SCTP_NEW_DATA_REQ);
message_p = itti_alloc_new_message(TASK_S1AP, SCTP_DATA_REQ);
sctpNewDataReq_p = &message_p->ittiMsg.sctpNewDataReq;
sctpNewDataReq_p->buffer = buffer;
sctpNewDataReq_p->bufLen = length;
sctpNewDataReq_p->assocId = assoc_id;
sctpNewDataReq_p->stream = stream;
SCTP_DATA_REQ(message_p).buffer = buffer;
SCTP_DATA_REQ(message_p).bufLen = length;
SCTP_DATA_REQ(message_p).assocId = assoc_id;
SCTP_DATA_REQ(message_p).stream = stream;
return itti_send_msg_to_task(TASK_SCTP, INSTANCE_DEFAULT, message_p);
}
int s1ap_mme_itti_forward_nas_uplink(uint8_t *buffer, uint32_t length)
int s1ap_mme_itti_nas_uplink_ind(const uint32_t ue_id, uint8_t * const buffer,
const uint32_t length)
{
MessageDef *message_p;
message_p = itti_alloc_new_message(TASK_S1AP, NAS_UPLINK_DATA_IND);
NAS_UL_DATA_IND(message_p).UEid = ue_id;
NAS_UL_DATA_IND(message_p).nasMsg.data = buffer;
NAS_UL_DATA_IND(message_p).nasMsg.length = length;
return itti_send_msg_to_task(TASK_NAS, INSTANCE_DEFAULT, message_p);
}
int s1ap_mme_itti_nas_downlink_cnf(const uint32_t ue_id)
{
return 0;
MessageDef *message_p;
message_p = itti_alloc_new_message(TASK_S1AP, NAS_DOWNLINK_DATA_CNF);
NAS_DL_DATA_CNF(message_p).UEid = ue_id;
return itti_send_msg_to_task(TASK_NAS, INSTANCE_DEFAULT, message_p);
}
......@@ -38,4 +38,9 @@
int s1ap_mme_itti_send_sctp_request(uint8_t *buffer, uint32_t length,
uint32_t assoc_id, uint16_t stream);
int s1ap_mme_itti_nas_uplink_ind(const uint32_t ue_id, uint8_t * const buffer,
const uint32_t length);
int s1ap_mme_itti_nas_downlink_cnf(const uint32_t ue_id);
#endif /* S1AP_MME_ITTI_MESSAGING_H_ */
......@@ -190,7 +190,12 @@ int s1ap_mme_handle_uplink_nas_transport(uint32_t assoc_id, uint32_t stream,
}
//TODO: forward NAS PDU to NAS
#if defined(DISABLE_USE_NAS)
DevMessage("TODO: forward NAS PDU to NAS\n");
#else
s1ap_mme_itti_nas_uplink_ind(uplinkNASTransport_p->mme_ue_s1ap_id, uplinkNASTransport_p->nas_pdu.buf,
uplinkNASTransport_p->nas_pdu.size);
#endif
return 0;
}
......@@ -207,19 +212,21 @@ int s1ap_mme_handle_nas_non_delivery(uint32_t assoc_id, uint32_t stream,
return 0;
}
int s1ap_generate_downlink_nas_transport(nas_dl_data_ind_t *nas_dl_data_ind)
int s1ap_generate_downlink_nas_transport(nas_dl_data_req_t *nas_dl_data_req_p)
{
ue_description_t *ue_ref;
uint8_t *buffer_p;
uint32_t length;
DevAssert(nas_dl_data_ind != NULL);
DevAssert(nas_dl_data_req_p != NULL);
if ((ue_ref = s1ap_is_ue_mme_id_in_list(nas_dl_data_ind->UEid)) == NULL) {
if ((ue_ref = s1ap_is_ue_mme_id_in_list(nas_dl_data_req_p->UEid)) == NULL) {
/* If the UE-associated logical S1-connection is not established,
* the MME shall allocate a unique MME UE S1AP ID to be used for the UE.
*/
DevMessage("This case is not handled right now\n");
return -1;
} else {
/* We have fount the UE in the list.
* Create new IE list message and encode it.
......@@ -239,16 +246,17 @@ int s1ap_generate_downlink_nas_transport(nas_dl_data_ind_t *nas_dl_data_ind)
downlinkNasTransport->mme_ue_s1ap_id = ue_ref->mme_ue_s1ap_id;
downlinkNasTransport->eNB_UE_S1AP_ID = ue_ref->eNB_ue_s1ap_id;
OCTET_STRING_fromBuf(&downlinkNasTransport->nas_pdu,
(char*)nas_dl_data_ind->nasMsg.data,
nas_dl_data_ind->nasMsg.length);
(char*)nas_dl_data_req_p->nasMsg.data,
nas_dl_data_req_p->nasMsg.length);
if (s1ap_mme_encode_pdu(&message, &buffer_p, &length) < 0) {
// TODO: handle something
return -1;
}
return s1ap_mme_itti_send_sctp_request(buffer_p, length,
s1ap_mme_itti_send_sctp_request(buffer_p, length,
ue_ref->eNB->sctp_assoc_id,
ue_ref->sctp_stream_send);
s1ap_mme_itti_nas_downlink_cnf(ue_ref->mme_ue_s1ap_id);
}
return 0;
}
......
......@@ -66,6 +66,6 @@ int s1ap_mme_handle_nas_non_delivery(uint32_t assocId, uint32_t stream,
int s1ap_handle_attach_accepted(nas_attach_accept_t *attach_accept_p);
int s1ap_generate_downlink_nas_transport(nas_dl_data_ind_t *message);
int s1ap_generate_downlink_nas_transport(nas_dl_data_req_t *nas_dl_data_req);
#endif /* S1AP_MME_NAS_PROCEDURES_H_ */
......@@ -26,21 +26,18 @@ int sctp_itti_send_new_message_ind(int n, uint8_t *buffer, uint32_t assoc_id,
uint16_t instreams, uint16_t outstreams)
{
MessageDef *message_p;
s1ap_sctp_new_msg_ind_t *sctp_new_msg_ind_p;
message_p = itti_alloc_new_message(TASK_SCTP, S1AP_SCTP_NEW_MESSAGE_IND);
message_p = itti_alloc_new_message(TASK_SCTP, SCTP_DATA_IND);
sctp_new_msg_ind_p = &message_p->ittiMsg.s1ap_sctp_new_msg_ind;
SCTP_DATA_IND(message_p).buffer = malloc(sizeof(uint8_t) * n);
sctp_new_msg_ind_p->buffer = malloc(sizeof(uint8_t) * n);
memcpy((void *)SCTP_DATA_IND(message_p).buffer, (void *)buffer, n);
memcpy((void *)sctp_new_msg_ind_p->buffer, (void *)buffer, n);
sctp_new_msg_ind_p->stream = stream;
sctp_new_msg_ind_p->buf_length = n;
sctp_new_msg_ind_p->assoc_id = assoc_id;
sctp_new_msg_ind_p->instreams = instreams;
sctp_new_msg_ind_p->outstreams = outstreams;
SCTP_DATA_IND(message_p).stream = stream;
SCTP_DATA_IND(message_p).buf_length = n;
SCTP_DATA_IND(message_p).assoc_id = assoc_id;
SCTP_DATA_IND(message_p).instreams = instreams;
SCTP_DATA_IND(message_p).outstreams = outstreams;
return itti_send_msg_to_task(TASK_S1AP, INSTANCE_DEFAULT, message_p);
}
......
......@@ -598,26 +598,29 @@ static void *sctp_intertask_interface(void *args_p)
SCTP_ERROR("Failed to create new SCTP listener\n");
}
} break;
case SCTP_CLOSE_ASSOCIATION: {
} break;
case SCTP_NEW_DATA_REQ: {
SctpNewDataReq *sctpNewS1APDataReq;
sctpNewS1APDataReq = &received_message_p->ittiMsg.sctpNewDataReq;
if (sctp_send_msg(sctpNewS1APDataReq->assocId,
sctpNewS1APDataReq->stream,
sctpNewS1APDataReq->buffer,
sctpNewS1APDataReq->bufLen) < 0) {
case SCTP_DATA_REQ: {
if (sctp_send_msg(SCTP_DATA_REQ(received_message_p).assocId,
SCTP_DATA_REQ(received_message_p).stream,
SCTP_DATA_REQ(received_message_p).buffer,
SCTP_DATA_REQ(received_message_p).bufLen) < 0) {
SCTP_ERROR("Failed to send message over SCTP\n");
}
} break;
case MESSAGE_TEST: {
// int i = 10000;
// while(i--);
} break;
case TERMINATE_MESSAGE: {
itti_exit_task();
} break;
default: {
SCTP_DEBUG("Unkwnon message ID %d:%s\n",
ITTI_MSG_ID(received_message_p),
......
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