From c67aafd2a688c3a2be5e9c7156b492b8d0dc7014 Mon Sep 17 00:00:00 2001 From: Cedric Roux <cedric.roux@eurecom.fr> Date: Mon, 2 Dec 2013 12:51:30 +0000 Subject: [PATCH] - 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 --- openair-cn/COMMON/nas_messages_def.h | 3 +- openair-cn/COMMON/nas_messages_types.h | 11 +- openair-cn/COMMON/s1ap_messages_def.h | 1 - openair-cn/COMMON/s1ap_messages_types.h | 9 - openair-cn/COMMON/sctp_messages_def.h | 3 +- openair-cn/COMMON/sctp_messages_types.h | 24 +- openair-cn/Makefile.am | 64 +- openair-cn/NAS/EURECOM-NAS/src/MMEprocess.c | 124 +- openair-cn/NAS/EURECOM-NAS/src/UEprocess.c | 184 +- .../NAS/EURECOM-NAS/src/emm/LowerLayer.c | 2 +- .../src/emm/sap/EmmCommonProcedureInitiated.c | 176 +- .../EURECOM-NAS/src/emm/sap/EmmDeregistered.c | 207 +- .../src/emm/sap/EmmDeregisteredAttachNeeded.c | 46 +- .../sap/EmmDeregisteredAttemptingToAttach.c | 117 +- .../src/emm/sap/EmmDeregisteredInitiated.c | 127 +- .../emm/sap/EmmDeregisteredLimitedService.c | 157 +- .../emm/sap/EmmDeregisteredNoCellAvailable.c | 115 +- .../src/emm/sap/EmmDeregisteredNoImsi.c | 44 +- .../emm/sap/EmmDeregisteredNormalService.c | 155 +- .../src/emm/sap/EmmDeregisteredPlmnSearch.c | 147 +- .../NAS/EURECOM-NAS/src/emm/sap/EmmNull.c | 91 +- .../EURECOM-NAS/src/emm/sap/EmmRegistered.c | 249 +- .../emm/sap/EmmRegisteredAttemptingToUpdate.c | 50 +- .../sap/EmmRegisteredImsiDetachInitiated.c | 48 +- .../src/emm/sap/EmmRegisteredInitiated.c | 359 +- .../src/emm/sap/EmmRegisteredLimitedService.c | 40 +- .../emm/sap/EmmRegisteredNoCellAvailable.c | 42 +- .../src/emm/sap/EmmRegisteredNormalService.c | 40 +- .../src/emm/sap/EmmRegisteredPlmnSearch.c | 56 +- .../src/emm/sap/EmmRegisteredUpdateNeeded.c | 52 +- .../src/emm/sap/EmmServiceRequestInitiated.c | 44 +- .../sap/EmmTrackingAreaUpdatingInitiated.c | 44 +- .../NAS/EURECOM-NAS/src/emm/sap/emm_as.c | 1798 +++++---- .../NAS/EURECOM-NAS/src/emm/sap/emm_as.h | 24 +- .../NAS/EURECOM-NAS/src/emm/sap/emm_asDef.h | 234 +- .../NAS/EURECOM-NAS/src/emm/sap/emm_esm.c | 124 +- .../NAS/EURECOM-NAS/src/emm/sap/emm_esm.h | 24 +- .../NAS/EURECOM-NAS/src/emm/sap/emm_esmDef.h | 38 +- .../NAS/EURECOM-NAS/src/emm/sap/emm_fsm.c | 176 +- .../NAS/EURECOM-NAS/src/emm/sap/emm_fsm.h | 22 +- .../NAS/EURECOM-NAS/src/emm/sap/emm_recv.c | 900 ++--- .../NAS/EURECOM-NAS/src/emm/sap/emm_recv.h | 73 +- .../NAS/EURECOM-NAS/src/emm/sap/emm_reg.c | 48 +- .../NAS/EURECOM-NAS/src/emm/sap/emm_reg.h | 24 +- .../NAS/EURECOM-NAS/src/emm/sap/emm_regDef.h | 94 +- .../NAS/EURECOM-NAS/src/emm/sap/emm_sap.c | 85 +- .../NAS/EURECOM-NAS/src/emm/sap/emm_sap.h | 150 +- .../NAS/EURECOM-NAS/src/emm/sap/emm_send.c | 967 ++--- .../NAS/EURECOM-NAS/src/emm/sap/emm_send.h | 75 +- .../esm/DedicatedEpsBearerContextActivation.c | 615 ++- .../esm/DefaultEpsBearerContextActivation.c | 713 ++-- .../src/esm/EpsBearerContextDeactivation.c | 779 ++-- .../NAS/EURECOM-NAS/src/esm/EsmStatusHdl.c | 169 +- .../NAS/EURECOM-NAS/src/esm/PdnConnectivity.c | 1713 ++++---- .../NAS/EURECOM-NAS/src/esm/PdnDisconnect.c | 718 ++-- openair-cn/NAS/EURECOM-NAS/src/esm/esmData.h | 100 +- openair-cn/NAS/EURECOM-NAS/src/esm/esm_ebr.c | 568 +-- openair-cn/NAS/EURECOM-NAS/src/esm/esm_ebr.h | 54 +- .../NAS/EURECOM-NAS/src/esm/esm_ebr_context.c | 788 ++-- .../NAS/EURECOM-NAS/src/esm/esm_ebr_context.h | 31 +- openair-cn/NAS/EURECOM-NAS/src/esm/esm_ip.c | 6 +- openair-cn/NAS/EURECOM-NAS/src/esm/esm_main.c | 309 +- openair-cn/NAS/EURECOM-NAS/src/esm/esm_main.h | 27 +- openair-cn/NAS/EURECOM-NAS/src/esm/esm_proc.h | 150 +- openair-cn/NAS/EURECOM-NAS/src/esm/esm_pt.c | 421 +- openair-cn/NAS/EURECOM-NAS/src/esm/esm_pt.h | 35 +- .../NAS/EURECOM-NAS/src/esm/sap/esm_recv.c | 1156 +++--- .../NAS/EURECOM-NAS/src/esm/sap/esm_recv.h | 63 +- .../NAS/EURECOM-NAS/src/esm/sap/esm_sap.c | 1659 ++++---- .../NAS/EURECOM-NAS/src/esm/sap/esm_sap.h | 24 +- .../NAS/EURECOM-NAS/src/esm/sap/esm_sapDef.h | 76 +- .../NAS/EURECOM-NAS/src/esm/sap/esm_send.c | 459 ++- .../NAS/EURECOM-NAS/src/esm/sap/esm_send.h | 63 +- .../NAS/EURECOM-NAS/src/include/securityDef.h | 70 +- .../NAS/EURECOM-NAS/src/include/userDef.h | 38 +- openair-cn/NAS/EURECOM-NAS/src/nas_network.c | 288 +- openair-cn/NAS/EURECOM-NAS/src/nas_network.h | 22 +- openair-cn/NAS/EURECOM-NAS/src/nas_parser.c | 261 +- openair-cn/NAS/EURECOM-NAS/src/nas_parser.h | 42 +- openair-cn/NAS/EURECOM-NAS/src/nas_proc.c | 1209 +++--- openair-cn/NAS/EURECOM-NAS/src/nas_proc.h | 67 +- openair-cn/NAS/EURECOM-NAS/src/nas_user.c | 3535 ++++++++--------- openair-cn/NAS/EURECOM-NAS/src/nas_user.h | 21 +- openair-cn/NAS/Makefile.am | 1 + openair-cn/NAS/nas_itti_messaging.c | 46 + openair-cn/NAS/nas_itti_messaging.h | 37 + openair-cn/NAS/nas_main.c | 14 + openair-cn/S1AP/s1ap_mme.c | 34 +- openair-cn/S1AP/s1ap_mme_itti_messaging.c | 37 +- openair-cn/S1AP/s1ap_mme_itti_messaging.h | 5 + openair-cn/S1AP/s1ap_mme_nas_procedures.c | 24 +- openair-cn/S1AP/s1ap_mme_nas_procedures.h | 2 +- openair-cn/SCTP/sctp_itti_messaging.c | 21 +- openair-cn/SCTP/sctp_primitives_server.c | 17 +- 94 files changed, 12090 insertions(+), 12084 deletions(-) create mode 100644 openair-cn/NAS/nas_itti_messaging.c create mode 100644 openair-cn/NAS/nas_itti_messaging.h diff --git a/openair-cn/COMMON/nas_messages_def.h b/openair-cn/COMMON/nas_messages_def.h index 07b296697e..da0a36f864 100644 --- a/openair-cn/COMMON/nas_messages_def.h +++ b/openair-cn/COMMON/nas_messages_def.h @@ -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) diff --git a/openair-cn/COMMON/nas_messages_types.h b/openair-cn/COMMON/nas_messages_types.h index bdba9516e1..dc66bf77a4 100644 --- a/openair-cn/COMMON/nas_messages_types.h +++ b/openair-cn/COMMON/nas_messages_types.h @@ -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 { diff --git a/openair-cn/COMMON/s1ap_messages_def.h b/openair-cn/COMMON/s1ap_messages_def.h index 3cd56b0f2d..cf7fd64054 100644 --- a/openair-cn/COMMON/s1ap_messages_def.h +++ b/openair-cn/COMMON/s1ap_messages_def.h @@ -1,4 +1,3 @@ //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) diff --git a/openair-cn/COMMON/s1ap_messages_types.h b/openair-cn/COMMON/s1ap_messages_types.h index 400eca5055..1c847188b7 100644 --- a/openair-cn/COMMON/s1ap_messages_types.h +++ b/openair-cn/COMMON/s1ap_messages_types.h @@ -1,15 +1,6 @@ #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; diff --git a/openair-cn/COMMON/sctp_messages_def.h b/openair-cn/COMMON/sctp_messages_def.h index d145139f1b..54b7a5584c 100644 --- a/openair-cn/COMMON/sctp_messages_def.h +++ b/openair-cn/COMMON/sctp_messages_def.h @@ -1,6 +1,7 @@ //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) diff --git a/openair-cn/COMMON/sctp_messages_types.h b/openair-cn/COMMON/sctp_messages_types.h index fc60467717..3f77e6a697 100644 --- a/openair-cn/COMMON/sctp_messages_types.h +++ b/openair-cn/COMMON/sctp_messages_types.h @@ -1,14 +1,28 @@ #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; diff --git a/openair-cn/Makefile.am b/openair-cn/Makefile.am index ecf2032755..253a828fe5 100644 --- a/openair-cn/Makefile.am +++ b/openair-cn/Makefile.am @@ -1,9 +1,9 @@ ACLOCAL_AMFLAGS = -I m4 -AM_CFLAGS = @ADD_CFLAGS@ \ - -I$(top_srcdir)/COMMON \ - -I$(top_srcdir)/UTILS \ - -I$(top_srcdir)/NAS/EURECOM-NAS/src/api/network \ +AM_CFLAGS = @ADD_CFLAGS@ \ + -I$(top_srcdir)/COMMON \ + -I$(top_srcdir)/UTILS \ + -I$(top_srcdir)/NAS/EURECOM-NAS/src/api/network \ -I$(top_srcdir)/NAS/EURECOM-NAS/src/include \ -I$(top_srcdir)/INTERTASK_INTERFACE @@ -12,52 +12,54 @@ BUILT_SOURCES = \ messages.xml \ messages_xml.h -messages_hdr = \ +messages_hdr = \ $(top_srcdir)/INTERTASK_INTERFACE/intertask_messages_def.h \ $(top_srcdir)/INTERTASK_INTERFACE/timer_messages_def.h \ $(top_srcdir)/INTERTASK_INTERFACE/timer_messages_types.h \ - $(top_srcdir)/COMMON/tasks_def.h \ - $(top_srcdir)/COMMON/messages_def.h \ - $(top_srcdir)/COMMON/messages_types.h \ - $(top_srcdir)/COMMON/gtpv1_u_messages_def.h \ - $(top_srcdir)/COMMON/gtpv1_u_messages_types.h \ - $(top_srcdir)/COMMON/nas_messages_def.h \ - $(top_srcdir)/COMMON/nas_messages_types.h \ - $(top_srcdir)/COMMON/s11_messages_def.h \ - $(top_srcdir)/COMMON/s11_messages_types.h \ - $(top_srcdir)/COMMON/s1ap_messages_def.h \ - $(top_srcdir)/COMMON/s1ap_messages_types.h \ - $(top_srcdir)/COMMON/s6a_messages_def.h \ - $(top_srcdir)/COMMON/s6a_messages_types.h \ - $(top_srcdir)/COMMON/sgw_lite_def.h \ - $(top_srcdir)/COMMON/sgw_lite_messages_types.h \ - $(top_srcdir)/COMMON/sctp_messages_def.h \ - $(top_srcdir)/COMMON/sctp_messages_types.h \ - $(top_srcdir)/COMMON/udp_messages_def.h \ + $(top_srcdir)/COMMON/tasks_def.h \ + $(top_srcdir)/COMMON/messages_def.h \ + $(top_srcdir)/COMMON/messages_types.h \ + $(top_srcdir)/COMMON/gtpv1_u_messages_def.h \ + $(top_srcdir)/COMMON/gtpv1_u_messages_types.h \ + $(top_srcdir)/COMMON/nas_messages_def.h \ + $(top_srcdir)/COMMON/nas_messages_types.h \ + $(top_srcdir)/COMMON/s11_messages_def.h \ + $(top_srcdir)/COMMON/s11_messages_types.h \ + $(top_srcdir)/COMMON/s1ap_messages_def.h \ + $(top_srcdir)/COMMON/s1ap_messages_types.h \ + $(top_srcdir)/COMMON/s6a_messages_def.h \ + $(top_srcdir)/COMMON/s6a_messages_types.h \ + $(top_srcdir)/COMMON/sgw_lite_def.h \ + $(top_srcdir)/COMMON/sgw_lite_messages_types.h \ + $(top_srcdir)/COMMON/sctp_messages_def.h \ + $(top_srcdir)/COMMON/sctp_messages_types.h \ + $(top_srcdir)/COMMON/udp_messages_def.h \ $(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 = \ - . \ + . \ GTPV1-U \ GTPV2-C \ - INTERTASK_INTERFACE \ - SGI \ - NAS \ + INTERTASK_INTERFACE \ + SGI \ + NAS \ SCTP \ - S11 \ + S11 \ S1AP \ S6A \ SECU \ SGW-LITE \ UTILS \ - UDP \ + UDP \ MME_APP \ TEST \ OAISIM_MME \ diff --git a/openair-cn/NAS/EURECOM-NAS/src/MMEprocess.c b/openair-cn/NAS/EURECOM-NAS/src/MMEprocess.c index 4550bf5827..350fba7baa 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/MMEprocess.c +++ b/openair-cn/NAS/EURECOM-NAS/src/MMEprocess.c @@ -2,19 +2,19 @@ Eurecom OpenAirInterface 3 Copyright(c) 2012 Eurecom - Source MMEprocess.c + Source MMEprocess.c - Version 0.1 + Version 0.1 - Date 2013/02/26 + Date 2013/02/26 - Product NAS stack + Product NAS stack - Subsystem MME NAS main process + Subsystem MME NAS main process - Author Frederic Maurel + Author Frederic Maurel - Description Implements the Non-Access Stratum protocol for Evolved Packet + Description Implements the Non-Access Stratum protocol for Evolved Packet system (EPS) running at the Network side. *****************************************************************************/ @@ -27,10 +27,10 @@ #include "nas_network.h" #include "nas_parser.h" -#include <stdlib.h> // exit -#include <poll.h> // poll -#include <string.h> // memset -#include <signal.h> // sigaction +#include <stdlib.h> // exit +#include <poll.h> // poll +#include <string.h> // memset +#include <signal.h> // sigaction #include <pthread.h> /****************************************************************************/ @@ -41,9 +41,9 @@ /******************* L O C A L D E F I N I T I O N S *******************/ /****************************************************************************/ -#define NAS_SLEEP_TIMEOUT 1000 /* 1 second */ +#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 (); } @@ -144,20 +142,20 @@ int main(int argc, const char* argv[]) /**************************************************************************** ** ** - ** Name: _nas_network_mngr() ** + ** Name: _nas_network_mngr() ** ** ** ** Description: Manages the connection endpoint use to communicate with ** - ** the network sublayer ** + ** the network sublayer ** ** ** - ** Inputs: fd: The descriptor of the network connection ** - ** endpoint ** - ** Others: None ** + ** Inputs: fd: The descriptor of the network connection ** + ** endpoint ** + ** Others: None ** ** ** - ** Outputs: Return: None ** - ** Others: None ** + ** Outputs: Return: None ** + ** 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,24 +204,25 @@ static void* _nas_network_mngr(void* args) } } - /* Close the connection to the network sublayer */LOG_TRACE (WARNING, "MME-MAIN - " - "The network connection endpoint manager exited"); + /* Close the connection to the network sublayer */LOG_TRACE (WARNING, + "MME-MAIN - " + "The network connection endpoint manager exited"); LOG_FUNC_RETURN(NULL); } /**************************************************************************** ** ** - ** Name: _nas_set_signal_handler() ** + ** Name: _nas_set_signal_handler() ** ** ** ** Description: Set up a signal handler ** ** ** - ** Inputs: signal: Signal number ** - ** handler: Signal handler ** - ** Others: None ** + ** Inputs: signal: Signal number ** + ** handler: Signal handler ** + ** Others: None ** ** ** - ** Outputs: Return: RETURNerror, RETURNok ** - ** Others: None ** + ** Outputs: Return: RETURNerror, RETURNok ** + ** Others: None ** ** ** ***************************************************************************/ static int _nas_set_signal_handler(int signal, void (handler)(int)) @@ -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; } @@ -267,15 +261,15 @@ static int _nas_set_signal_handler(int signal, void (handler)(int)) /**************************************************************************** ** ** - ** Name: _nas_signal_handler() ** + ** Name: _nas_signal_handler() ** ** ** ** Description: Signal handler ** ** ** - ** Inputs: signal: Signal number ** - ** Others: None ** + ** Inputs: signal: Signal number ** + ** Others: None ** ** ** - ** Outputs: Return: None ** - ** Others: None ** + ** Outputs: Return: None ** + ** Others: None ** ** ** ***************************************************************************/ static void _nas_signal_handler(int signal) @@ -292,15 +286,15 @@ static void _nas_signal_handler(int signal) /**************************************************************************** ** ** - ** Name: _nas_clean() ** + ** Name: _nas_clean() ** ** ** ** Description: Performs termination cleanup ** ** ** - ** Inputs: net_fd: Network's connection file descriptor ** - ** Others: None ** + ** Inputs: net_fd: Network's connection file descriptor ** + ** Others: None ** ** ** - ** Outputs: Return: None ** - ** Others: None ** + ** Outputs: Return: None ** + ** Others: None ** ** ** ***************************************************************************/ static void _nas_clean(int net_fd) diff --git a/openair-cn/NAS/EURECOM-NAS/src/UEprocess.c b/openair-cn/NAS/EURECOM-NAS/src/UEprocess.c index c9f0f4b0a6..3313aeb9d3 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/UEprocess.c +++ b/openair-cn/NAS/EURECOM-NAS/src/UEprocess.c @@ -2,19 +2,19 @@ Eurecom OpenAirInterface 3 Copyright(c) 2012 Eurecom - Source UEprocess.c + Source UEprocess.c - Version 0.1 + Version 0.1 - Date 2012/02/27 + Date 2012/02/27 - Product NAS stack + Product NAS stack - Subsystem UE NAS main process + Subsystem UE NAS main process - Author Frederic Maurel + Author Frederic Maurel - Description Implements the Non-Access Stratum protocol for Evolved Packet + Description Implements the Non-Access Stratum protocol for Evolved Packet system (EPS) running at the User Equipment side. *****************************************************************************/ @@ -29,10 +29,10 @@ #include "nas_network.h" #include "nas_parser.h" -#include <stdlib.h> // exit -#include <poll.h> // poll -#include <string.h> // memset -#include <signal.h> // sigaction +#include <stdlib.h> // exit +#include <poll.h> // poll +#include <string.h> // memset +#include <signal.h> // sigaction #include <pthread.h> /****************************************************************************/ @@ -43,10 +43,10 @@ /******************* L O C A L D E F I N I T I O N S *******************/ /****************************************************************************/ -#define NAS_SLEEP_TIMEOUT 1000 /* 1 second */ +#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 (); @@ -179,20 +176,20 @@ int main(int argc, const char* argv[]) /**************************************************************************** ** ** - ** Name: _nas_user_mngr() ** + ** Name: _nas_user_mngr() ** ** ** ** Description: Manages the connection endpoint use to communicate with ** - ** the user application layer ** + ** the user application layer ** ** ** - ** Inputs: fd: The descriptor of the user connection end- ** - ** point ** - ** Others: None ** + ** Inputs: fd: The descriptor of the user connection end- ** + ** point ** + ** Others: None ** ** ** - ** Outputs: Return: None ** - ** Others: None ** + ** Outputs: Return: None ** + ** 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 - " @@ -287,20 +276,20 @@ static void* _nas_user_mngr(void* args) /**************************************************************************** ** ** - ** Name: _nas_network_mngr() ** + ** Name: _nas_network_mngr() ** ** ** ** Description: Manages the connection endpoint use to communicate with ** - ** the network sublayer ** + ** the network sublayer ** ** ** - ** Inputs: fd: The descriptor of the network connection ** - ** endpoint ** - ** Others: None ** + ** Inputs: fd: The descriptor of the network connection ** + ** endpoint ** + ** Others: None ** ** ** - ** Outputs: Return: None ** - ** Others: None ** + ** Outputs: Return: None ** + ** 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 @@ -363,16 +348,16 @@ static void* _nas_network_mngr(void* args) /**************************************************************************** ** ** - ** Name: _nas_set_signal_handler() ** + ** Name: _nas_set_signal_handler() ** ** ** ** Description: Set up a signal handler ** ** ** - ** Inputs: signal: Signal number ** - ** handler: Signal handler ** - ** Others: None ** + ** Inputs: signal: Signal number ** + ** handler: Signal handler ** + ** Others: None ** ** ** - ** Outputs: Return: RETURNerror, RETURNok ** - ** Others: None ** + ** Outputs: Return: RETURNerror, RETURNok ** + ** Others: None ** ** ** ***************************************************************************/ static int _nas_set_signal_handler(int signal, void (handler)(int)) @@ -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; } @@ -412,15 +396,15 @@ static int _nas_set_signal_handler(int signal, void (handler)(int)) /**************************************************************************** ** ** - ** Name: _nas_signal_handler() ** + ** Name: _nas_signal_handler() ** ** ** ** Description: Signal handler ** ** ** - ** Inputs: signal: Signal number ** - ** Others: None ** + ** Inputs: signal: Signal number ** + ** Others: None ** ** ** - ** Outputs: Return: None ** - ** Others: None ** + ** Outputs: Return: None ** + ** Others: None ** ** ** ***************************************************************************/ static void _nas_signal_handler(int signal) @@ -437,16 +421,16 @@ static void _nas_signal_handler(int signal) /**************************************************************************** ** ** - ** Name: _nas_clean() ** + ** Name: _nas_clean() ** ** ** ** Description: Performs termination cleanup ** ** ** - ** Inputs: usr_fd: User's connection file descriptor ** - ** net_fd: Network's connection file descriptor ** - ** Others: None ** + ** Inputs: usr_fd: User's connection file descriptor ** + ** net_fd: Network's connection file descriptor ** + ** Others: None ** ** ** - ** Outputs: Return: None ** - ** Others: None ** + ** Outputs: Return: None ** + ** Others: None ** ** ** ***************************************************************************/ static void _nas_clean(int usr_fd, int net_fd) diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/LowerLayer.c b/openair-cn/NAS/EURECOM-NAS/src/emm/LowerLayer.c index 4b0a779fba..43049d4e94 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/LowerLayer.c +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/LowerLayer.c @@ -413,7 +413,7 @@ int emm_proc_lowerlayer_release(void) /**************************************************************************** ** ** - ** Name: emm_as_set_security_data() ** + ** Name: emm_as_set_security_data() ** ** ** ** Description: Setup security data according to the given EPS security ** ** context when data transfer to lower layers is requested ** diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmCommonProcedureInitiated.c b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmCommonProcedureInitiated.c index 378805f8f9..21efbd78c9 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmCommonProcedureInitiated.c +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmCommonProcedureInitiated.c @@ -1,25 +1,25 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source EmmCommonProcedureInitiated.c +Source EmmCommonProcedureInitiated.c -Version 0.1 +Version 0.1 -Date 2012/10/03 +Date 2012/10/03 -Product NAS stack +Product NAS stack -Subsystem EPS Mobility Management +Subsystem EPS Mobility Management -Author Frederic Maurel +Author Frederic Maurel -Description Implements the EPS Mobility Management procedures executed - when the EMM-SAP is in EMM-COMMON-PROCEDURE-INITIATED state. +Description Implements the EPS Mobility Management procedures executed + when the EMM-SAP is in EMM-COMMON-PROCEDURE-INITIATED state. - In EMM-COMMON-PROCEDURE-INITIATED state, the MME has started - a common EMM procedure and is waiting for a response from the - UE. + In EMM-COMMON-PROCEDURE-INITIATED state, the MME has started + a common EMM procedure and is waiting for a response from the + UE. *****************************************************************************/ @@ -47,102 +47,102 @@ Description Implements the EPS Mobility Management procedures executed /**************************************************************************** ** ** - ** Name: EmmCommonProcedureInitiated() ** + ** Name: EmmCommonProcedureInitiated() ** ** ** ** Description: Handles the behaviour of the MME while the EMM-SAP is in ** - ** EMM_COMMON_PROCEDURE_INITIATED state. ** + ** EMM_COMMON_PROCEDURE_INITIATED state. ** ** ** ** 3GPP TS 24.301, section 5.1.3.4.2 ** ** ** - ** Inputs: evt: The received EMM-SAP event ** - ** Others: emm_fsm_status ** + ** Inputs: evt: The received EMM-SAP event ** + ** Others: emm_fsm_status ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: emm_fsm_status ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** 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); - - switch (evt->primitive) - { - case _EMMREG_PROC_ABORT: - /* - * The EMM procedure that initiated EMM common procedure aborted - */ - rc = emm_proc_common_abort(evt->ueid); - break; - - case _EMMREG_COMMON_PROC_CNF: - /* - * An EMM common procedure successfully completed; - */ - if (evt->u.common.is_attached) { + assert(emm_fsm_get_status(evt->ueid, + evt->ctx) == EMM_COMMON_PROCEDURE_INITIATED); + + switch (evt->primitive) { + case _EMMREG_PROC_ABORT: + /* + * The EMM procedure that initiated EMM common procedure aborted + */ + rc = emm_proc_common_abort(evt->ueid); + break; + + case _EMMREG_COMMON_PROC_CNF: + /* + * An EMM common procedure successfully completed; + */ + if (evt->u.common.is_attached) { rc = emm_fsm_set_status(evt->ueid, evt->ctx, EMM_REGISTERED); - } else { + } else { rc = emm_fsm_set_status(evt->ueid, evt->ctx, EMM_DEREGISTERED); - } - if (rc != RETURNerror) { - rc = emm_proc_common_success(evt->ueid); - } - break; - - case _EMMREG_COMMON_PROC_REJ: - /* - * An EMM common procedure failed; - * enter state EMM-DEREGISTERED. - */ + } + if (rc != RETURNerror) { + rc = emm_proc_common_success(evt->ueid); + } + break; + + case _EMMREG_COMMON_PROC_REJ: + /* + * An EMM common procedure failed; + * enter state EMM-DEREGISTERED. + */ rc = emm_fsm_set_status(evt->ueid, evt->ctx, EMM_DEREGISTERED); - if (rc != RETURNerror) { - rc = emm_proc_common_reject(evt->ueid); - } - break; - - case _EMMREG_ATTACH_CNF: - /* - * Attach procedure successful and default EPS bearer - * context activated; - * enter state EMM-REGISTERED. - */ + if (rc != RETURNerror) { + rc = emm_proc_common_reject(evt->ueid); + } + break; + + case _EMMREG_ATTACH_CNF: + /* + * Attach procedure successful and default EPS bearer + * context activated; + * enter state EMM-REGISTERED. + */ rc = emm_fsm_set_status(evt->ueid, evt->ctx, EMM_REGISTERED); - break; + break; - case _EMMREG_ATTACH_REJ: - /* - * Attach procedure failed; - * enter state EMM-DEREGISTERED. - */ + case _EMMREG_ATTACH_REJ: + /* + * Attach procedure failed; + * enter state EMM-DEREGISTERED. + */ rc = emm_fsm_set_status(evt->ueid, evt->ctx, EMM_DEREGISTERED); - break; - - case _EMMREG_LOWERLAYER_SUCCESS: - /* - * Data successfully delivered to the network - */ - rc = RETURNok; - break; - - case _EMMREG_LOWERLAYER_FAILURE: - /* - * Transmission failure occurred before the EMM common - * procedure being completed - */ - rc = emm_proc_common_failure(evt->ueid); - if (rc != RETURNerror) { + break; + + case _EMMREG_LOWERLAYER_SUCCESS: + /* + * Data successfully delivered to the network + */ + rc = RETURNok; + break; + + case _EMMREG_LOWERLAYER_FAILURE: + /* + * Transmission failure occurred before the EMM common + * procedure being completed + */ + rc = emm_proc_common_failure(evt->ueid); + if (rc != RETURNerror) { rc = emm_fsm_set_status(evt->ueid, evt->ctx, EMM_DEREGISTERED); - } - break; + } + break; - default: - LOG_TRACE(ERROR, "EMM-FSM - Primitive is not valid (%d)", - evt->primitive); - break; + default: + LOG_TRACE(ERROR, "EMM-FSM - Primitive is not valid (%d)", + evt->primitive); + break; } LOG_FUNC_RETURN (rc); diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmDeregistered.c b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmDeregistered.c index 8daf854c1b..4fa342da14 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmDeregistered.c +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmDeregistered.c @@ -1,31 +1,31 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source EmmDeregistered.c +Source EmmDeregistered.c -Version 0.1 +Version 0.1 -Date 2012/10/03 +Date 2012/10/03 -Product NAS stack +Product NAS stack -Subsystem EPS Mobility Management +Subsystem EPS Mobility Management -Author Frederic Maurel +Author Frederic Maurel -Description Implements the EPS Mobility Management procedures executed - when the EMM-SAP is in EMM-DEREGISTERED state. +Description Implements the EPS Mobility Management procedures executed + when the EMM-SAP is in EMM-DEREGISTERED state. - In EMM-DEREGISTERED state, no EMM context has been established - or the EMM context is marked as detached. - The UE shall start the attach or combined attach procedure to - establish an EMM context. + In EMM-DEREGISTERED state, no EMM context has been established + or the EMM context is marked as detached. + The UE shall start the attach or combined attach procedure to + establish an EMM context. - The MME may answer to an attach or a combined attach procedure - initiated by the UE. It may also answer to a tracking area - updating procedure or combined tracking area updating procedure - initiated by a UE if the EMM context is marked as detached. + The MME may answer to an attach or a combined attach procedure + initiated by the UE. It may also answer to a tracking area + updating procedure or combined tracking area updating procedure + initiated by a UE if the EMM context is marked as detached. *****************************************************************************/ @@ -52,22 +52,22 @@ Description Implements the EPS Mobility Management procedures executed /**************************************************************************** ** ** - ** Name: EmmDeregistered() ** + ** Name: EmmDeregistered() ** ** ** ** Description: Handles the behaviour of the UE and the MME while the ** - ** EMM-SAP is in EMM-DEREGISTERED state. ** + ** EMM-SAP is in EMM-DEREGISTERED state. ** ** ** ** 3GPP TS 24.301, section 5.2.2.2 ** ** ** - ** Inputs: evt: The received EMM-SAP event ** - ** Others: emm_fsm_status ** + ** Inputs: evt: The received EMM-SAP event ** + ** Others: emm_fsm_status ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: emm_fsm_status ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: emm_fsm_status ** ** ** ***************************************************************************/ -int EmmDeregistered(const emm_reg_t* evt) +int EmmDeregistered(const emm_reg_t *evt) { LOG_FUNC_IN; @@ -84,7 +84,7 @@ int EmmDeregistered(const emm_reg_t* evt) /* Delete the authentication data RAND and RES */ rc = emm_proc_authentication_delete(); if (rc != RETURNok) { - LOG_FUNC_RETURN (rc); + LOG_FUNC_RETURN (rc); } /* TODO: 3GPP TS 24.301, section 4.4.2.1 * The UE shall store the current native EPS security context as specified @@ -94,94 +94,93 @@ int EmmDeregistered(const emm_reg_t* evt) */ #endif - switch (evt->primitive) - { + switch (evt->primitive) { #ifdef NAS_UE - case _EMMREG_NO_IMSI: - /* - * The UE was powered on without a valid USIM application present - */ - rc = emm_fsm_set_status(EMM_DEREGISTERED_NO_IMSI); - break; - - case _EMMREG_REGISTER_REQ: - /* - * The default EMM primary substate when the UE is switched on - * with valid USIM application shall be PLMN-SEARCH - */ - rc = emm_fsm_set_status(EMM_DEREGISTERED_PLMN_SEARCH); - if (rc != RETURNerror) { - /* Process the network registration request */ - rc = emm_fsm_process(evt); - } - break; - - case _EMMREG_ATTACH_INIT: - /* - * Attach procedure has to be restarted (timers T3402 or T3411 - * expired) while the UE locally detached from the network - */ - - /* Move to the corresponding initial EMM state */ - if (evt->u.attach.is_emergency) { - rc = emm_fsm_set_status(EMM_DEREGISTERED_LIMITED_SERVICE); - } else { - rc = emm_fsm_set_status(EMM_DEREGISTERED_NORMAL_SERVICE); - } - if (rc != RETURNerror) { - /* Restart the attach procedure */ - rc = emm_proc_attach_restart(); - } - break; + case _EMMREG_NO_IMSI: + /* + * The UE was powered on without a valid USIM application present + */ + rc = emm_fsm_set_status(EMM_DEREGISTERED_NO_IMSI); + break; + + case _EMMREG_REGISTER_REQ: + /* + * The default EMM primary substate when the UE is switched on + * with valid USIM application shall be PLMN-SEARCH + */ + rc = emm_fsm_set_status(EMM_DEREGISTERED_PLMN_SEARCH); + if (rc != RETURNerror) { + /* Process the network registration request */ + rc = emm_fsm_process(evt); + } + break; + + case _EMMREG_ATTACH_INIT: + /* + * Attach procedure has to be restarted (timers T3402 or T3411 + * expired) while the UE locally detached from the network + */ + + /* Move to the corresponding initial EMM state */ + if (evt->u.attach.is_emergency) { + rc = emm_fsm_set_status(EMM_DEREGISTERED_LIMITED_SERVICE); + } else { + rc = emm_fsm_set_status(EMM_DEREGISTERED_NORMAL_SERVICE); + } + if (rc != RETURNerror) { + /* Restart the attach procedure */ + rc = emm_proc_attach_restart(); + } + break; #endif #ifdef NAS_MME - case _EMMREG_PROC_ABORT: - /* - * Ongoing EMM procedure aborted - */ - rc = RETURNok; - break; - - case _EMMREG_COMMON_PROC_REQ: - /* - * An EMM common procedure has been initiated; - * enter state EMM-COMMON-PROCEDURE-INITIATED. - */ + case _EMMREG_PROC_ABORT: + /* + * Ongoing EMM procedure aborted + */ + rc = RETURNok; + break; + + case _EMMREG_COMMON_PROC_REQ: + /* + * An EMM common procedure has been initiated; + * enter state EMM-COMMON-PROCEDURE-INITIATED. + */ rc = emm_fsm_set_status(evt->ueid, evt->ctx, EMM_COMMON_PROCEDURE_INITIATED); - break; - - case _EMMREG_ATTACH_CNF: - /* - * Attach procedure successful and default EPS bearer - * context activated; - * enter state EMM-REGISTERED. - */ + break; + + case _EMMREG_ATTACH_CNF: + /* + * Attach procedure successful and default EPS bearer + * context activated; + * enter state EMM-REGISTERED. + */ rc = emm_fsm_set_status(evt->ueid, evt->ctx, EMM_REGISTERED); - break; + break; #endif - case _EMMREG_LOWERLAYER_SUCCESS: - /* - * Data successfully delivered to the network - */ - rc = RETURNok; - break; - - case _EMMREG_LOWERLAYER_FAILURE: - /* - * Data failed to be delivered to the network - */ - rc = RETURNok; - break; - - default: - LOG_TRACE(ERROR, "EMM-FSM - Primitive is not valid (%d)", - evt->primitive); - break; + case _EMMREG_LOWERLAYER_SUCCESS: + /* + * Data successfully delivered to the network + */ + rc = RETURNok; + break; + + case _EMMREG_LOWERLAYER_FAILURE: + /* + * Data failed to be delivered to the network + */ + rc = RETURNok; + break; + + default: + LOG_TRACE(ERROR, "EMM-FSM - Primitive is not valid (%d)", + evt->primitive); + break; } #ifdef NAS_UE diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmDeregisteredAttachNeeded.c b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmDeregisteredAttachNeeded.c index 4ce29fe1e7..3f69ceb160 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmDeregisteredAttachNeeded.c +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmDeregisteredAttachNeeded.c @@ -1,27 +1,27 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source EmmDeregisteredAttachNeeded.c +Source EmmDeregisteredAttachNeeded.c -Version 0.1 +Version 0.1 -Date 2012/10/03 +Date 2012/10/03 -Product NAS stack +Product NAS stack -Subsystem EPS Mobility Management +Subsystem EPS Mobility Management -Author Frederic Maurel +Author Frederic Maurel -Description Implements the EPS Mobility Management procedures executed - when the EMM-SAP is in EMM-DEREGISTERED.ATTACH-NEEDED state. +Description Implements the EPS Mobility Management procedures executed + when the EMM-SAP is in EMM-DEREGISTERED.ATTACH-NEEDED state. - In EMM-DEREGISTERED.ATTACH-NEEDED state, Valid subscriber - data are available for the UE and for some reason an attach - must be performed as soon as possible. The access class may - be blocked due to access class control, or the network rejec- - ted the NAS signalling connection establishment. + In EMM-DEREGISTERED.ATTACH-NEEDED state, Valid subscriber + data are available for the UE and for some reason an attach + must be performed as soon as possible. The access class may + be blocked due to access class control, or the network rejec- + ted the NAS signalling connection establishment. *****************************************************************************/ @@ -47,20 +47,20 @@ Description Implements the EPS Mobility Management procedures executed /**************************************************************************** ** ** - ** Name: EmmDeregisteredAttachNeeded() ** + ** Name: EmmDeregisteredAttachNeeded() ** ** ** ** Description: Handles the behaviour of the UE while the EMM-SAP is in ** - ** EMM-DEREGISTERED.ATTACH-NEEDED state. ** + ** EMM-DEREGISTERED.ATTACH-NEEDED state. ** ** ** - ** Inputs: evt: The received EMM-SAP event ** - ** Others: emm_fsm_status ** + ** Inputs: evt: The received EMM-SAP event ** + ** Others: emm_fsm_status ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: emm_fsm_status ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: emm_fsm_status ** ** ** ***************************************************************************/ -int EmmDeregisteredAttachNeeded(const emm_reg_t* evt) +int EmmDeregisteredAttachNeeded(const emm_reg_t *evt) { LOG_FUNC_IN; diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmDeregisteredAttemptingToAttach.c b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmDeregisteredAttemptingToAttach.c index 5ab9027968..087ce84c4e 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmDeregisteredAttemptingToAttach.c +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmDeregisteredAttemptingToAttach.c @@ -1,25 +1,25 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source EmmDeregisteredAttemptingToAttach.c +Source EmmDeregisteredAttemptingToAttach.c -Version 0.1 +Version 0.1 -Date 2012/10/03 +Date 2012/10/03 -Product NAS stack +Product NAS stack -Subsystem EPS Mobility Management +Subsystem EPS Mobility Management -Author Frederic Maurel +Author Frederic Maurel -Description Implements the EPS Mobility Management procedures executed - when the EMM-SAP is in EMM-DEREGISTERED.ATTEMPTING-TO-ATTACH - state. +Description Implements the EPS Mobility Management procedures executed + when the EMM-SAP is in EMM-DEREGISTERED.ATTEMPTING-TO-ATTACH + state. - In EMM-DEREGISTERED.ATTEMPTING-TO-ATTACH state, the EPS update - status is EU2, and a previous attach was not successful. + In EMM-DEREGISTERED.ATTEMPTING-TO-ATTACH state, the EPS update + status is EU2, and a previous attach was not successful. *****************************************************************************/ @@ -47,22 +47,22 @@ Description Implements the EPS Mobility Management procedures executed /**************************************************************************** ** ** - ** Name: EmmDeregisteredAttemptingToAttach() ** + ** Name: EmmDeregisteredAttemptingToAttach() ** ** ** ** Description: Handles the behaviour of the UE while the EMM-SAP is in ** - ** EMM-DEREGISTERED.ATTEMPTING-TO-ATTACH state. ** + ** EMM-DEREGISTERED.ATTEMPTING-TO-ATTACH state. ** ** ** ** 3GPP TS 24.301, section 5.2.2.3.3 ** ** ** - ** Inputs: evt: The received EMM-SAP event ** - ** Others: emm_fsm_status ** + ** Inputs: evt: The received EMM-SAP event ** + ** Others: emm_fsm_status ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: emm_fsm_status ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: emm_fsm_status ** ** ** ***************************************************************************/ -int EmmDeregisteredAttemptingToAttach(const emm_reg_t* evt) +int EmmDeregisteredAttemptingToAttach(const emm_reg_t *evt) { LOG_FUNC_IN; @@ -70,44 +70,43 @@ int EmmDeregisteredAttemptingToAttach(const emm_reg_t* evt) assert(emm_fsm_get_status() == EMM_DEREGISTERED_ATTEMPTING_TO_ATTACH); - switch (evt->primitive) - { - case _EMMREG_ATTACH_INIT: - /* - * Attach procedure has to be restarted (timers T3402 or T3411 - * expired) - */ - - /* Move to the corresponding initial EMM state */ - if (evt->u.attach.is_emergency) { - rc = emm_fsm_set_status(EMM_DEREGISTERED_LIMITED_SERVICE); - } else { - rc = emm_fsm_set_status(EMM_DEREGISTERED_NORMAL_SERVICE); - } - if (rc != RETURNerror) { - /* Restart the attach procedure */ - rc = emm_proc_attach_restart(); - } - break; - - case _EMMREG_LOWERLAYER_SUCCESS: - /* - * Data successfully delivered to the network - */ - rc = emm_proc_lowerlayer_success(); - break; - - case _EMMREG_LOWERLAYER_FAILURE: - /* - * Data failed to be delivered to the network - */ - rc = emm_proc_lowerlayer_failure(FALSE); - break; - - default: - LOG_TRACE(ERROR, "EMM-FSM - Primitive is not valid (%d)", - evt->primitive); - break; + switch (evt->primitive) { + case _EMMREG_ATTACH_INIT: + /* + * Attach procedure has to be restarted (timers T3402 or T3411 + * expired) + */ + + /* Move to the corresponding initial EMM state */ + if (evt->u.attach.is_emergency) { + rc = emm_fsm_set_status(EMM_DEREGISTERED_LIMITED_SERVICE); + } else { + rc = emm_fsm_set_status(EMM_DEREGISTERED_NORMAL_SERVICE); + } + if (rc != RETURNerror) { + /* Restart the attach procedure */ + rc = emm_proc_attach_restart(); + } + break; + + case _EMMREG_LOWERLAYER_SUCCESS: + /* + * Data successfully delivered to the network + */ + rc = emm_proc_lowerlayer_success(); + break; + + case _EMMREG_LOWERLAYER_FAILURE: + /* + * Data failed to be delivered to the network + */ + rc = emm_proc_lowerlayer_failure(FALSE); + break; + + default: + LOG_TRACE(ERROR, "EMM-FSM - Primitive is not valid (%d)", + evt->primitive); + break; } LOG_FUNC_RETURN (rc); diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmDeregisteredInitiated.c b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmDeregisteredInitiated.c index aec629cb15..9e1ec7d34e 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmDeregisteredInitiated.c +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmDeregisteredInitiated.c @@ -1,27 +1,27 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source EmmDeregisteredInitiated.c +Source EmmDeregisteredInitiated.c -Version 0.1 +Version 0.1 -Date 2012/10/03 +Date 2012/10/03 -Product NAS stack +Product NAS stack -Subsystem EPS Mobility Management +Subsystem EPS Mobility Management -Author Frederic Maurel +Author Frederic Maurel -Description Implements the EPS Mobility Management procedures executed - when the EMM-SAP is in EMM-DEREGISTERED-INITIATED state. +Description Implements the EPS Mobility Management procedures executed + when the EMM-SAP is in EMM-DEREGISTERED-INITIATED state. - In EMM-DEREGISTERED-INITIATED state, the UE has requested - release of the EMM context by starting the detach or combined - detach procedure and is waiting for a response from the MME. - The MME has started a detach procedure and is waiting for a - response from the UE. + In EMM-DEREGISTERED-INITIATED state, the UE has requested + release of the EMM context by starting the detach or combined + detach procedure and is waiting for a response from the MME. + The MME has started a detach procedure and is waiting for a + response from the UE. *****************************************************************************/ @@ -47,20 +47,20 @@ Description Implements the EPS Mobility Management procedures executed /**************************************************************************** ** ** - ** Name: EmmDeregisteredInitiated() ** + ** Name: EmmDeregisteredInitiated() ** ** ** ** Description: Handles the behaviour of the UE and the MME while the ** - ** EMM-SAP is in EMM-DEREGISTERED-INITIATED state. ** + ** EMM-SAP is in EMM-DEREGISTERED-INITIATED state. ** ** ** - ** Inputs: evt: The received EMM-SAP event ** - ** Others: emm_fsm_status ** + ** Inputs: evt: The received EMM-SAP event ** + ** Others: emm_fsm_status ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: emm_fsm_status ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: emm_fsm_status ** ** ** ***************************************************************************/ -int EmmDeregisteredInitiated(const emm_reg_t* evt) +int EmmDeregisteredInitiated(const emm_reg_t *evt) { LOG_FUNC_IN; @@ -73,50 +73,49 @@ 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: - /* - * The UE explicitly detached from the network (all EPS - * bearer contexts have been deactivated as UE initiated - * detach procedure successfully completed) - */ - rc = emm_fsm_set_status(EMM_DEREGISTERED); - break; - - case _EMMREG_DETACH_FAILED: - /* - * The detach procedure failed - */ - if (evt->u.detach.type == EMM_DETACH_TYPE_IMSI) { - rc = emm_fsm_set_status(EMM_REGISTERED_NORMAL_SERVICE); - } else { - rc = emm_fsm_set_status(EMM_DEREGISTERED); - } - break; - - case _EMMREG_LOWERLAYER_SUCCESS: - /* - * Ignore Detach Request message successful retransmission - */ - rc = RETURNok; - break; - - case _EMMREG_LOWERLAYER_FAILURE: - case _EMMREG_LOWERLAYER_RELEASE: - /* - * Lower layer failure or release of the NAS signalling connection - * before the Detach Accept is received - */ - rc = emm_proc_lowerlayer_release(); - break; + case _EMMREG_DETACH_CNF: + /* + * The UE explicitly detached from the network (all EPS + * bearer contexts have been deactivated as UE initiated + * detach procedure successfully completed) + */ + rc = emm_fsm_set_status(EMM_DEREGISTERED); + break; + + case _EMMREG_DETACH_FAILED: + /* + * The detach procedure failed + */ + if (evt->u.detach.type == EMM_DETACH_TYPE_IMSI) { + rc = emm_fsm_set_status(EMM_REGISTERED_NORMAL_SERVICE); + } else { + rc = emm_fsm_set_status(EMM_DEREGISTERED); + } + break; + + case _EMMREG_LOWERLAYER_SUCCESS: + /* + * Ignore Detach Request message successful retransmission + */ + rc = RETURNok; + break; + + case _EMMREG_LOWERLAYER_FAILURE: + case _EMMREG_LOWERLAYER_RELEASE: + /* + * Lower layer failure or release of the NAS signalling connection + * before the Detach Accept is received + */ + rc = emm_proc_lowerlayer_release(); + break; #endif - default: - LOG_TRACE(ERROR, "EMM-FSM - Primitive is not valid (%d)", - evt->primitive); - break; + default: + LOG_TRACE(ERROR, "EMM-FSM - Primitive is not valid (%d)", + evt->primitive); + break; } LOG_FUNC_RETURN (rc); diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmDeregisteredLimitedService.c b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmDeregisteredLimitedService.c index 3c43682b34..5a4b69785a 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmDeregisteredLimitedService.c +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmDeregisteredLimitedService.c @@ -1,25 +1,25 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source EmmDeregisteredLimitedService.c +Source EmmDeregisteredLimitedService.c -Version 0.1 +Version 0.1 -Date 2012/10/03 +Date 2012/10/03 -Product NAS stack +Product NAS stack -Subsystem EPS Mobility Management +Subsystem EPS Mobility Management -Author Frederic Maurel +Author Frederic Maurel -Description Implements the EPS Mobility Management procedures executed - when the EMM-SAP is in EMM-DEREGISTERED.LIMITED-SERVICE state. +Description Implements the EPS Mobility Management procedures executed + when the EMM-SAP is in EMM-DEREGISTERED.LIMITED-SERVICE state. - In EMM-DEREGISTERED.LIMITED-SERVICE state, the EPS update - status is EU3, and it is known that a selected cell is unable - to provide normal service. + In EMM-DEREGISTERED.LIMITED-SERVICE state, the EPS update + status is EU3, and it is known that a selected cell is unable + to provide normal service. *****************************************************************************/ @@ -48,25 +48,25 @@ Description Implements the EPS Mobility Management procedures executed /**************************************************************************** ** ** - ** Name: EmmDeregisteredLimitedService() ** + ** Name: EmmDeregisteredLimitedService() ** ** ** ** Description: Handles the behaviour of the UE while the EMM-SAP is in ** - ** EMM-DEREGISTERED.LIMITED-SERVICE state. ** + ** EMM-DEREGISTERED.LIMITED-SERVICE state. ** ** ** ** 3GPP TS 24.301, section 5.2.2.3.2 ** - ** The UE shall initiate an attach or combined attach proce- ** - ** dure when entering a cell which provides normal service. ** - ** It may initiate attach for emergency bearer services. ** + ** The UE shall initiate an attach or combined attach proce- ** + ** dure when entering a cell which provides normal service. ** + ** It may initiate attach for emergency bearer services. ** ** ** - ** Inputs: evt: The received EMM-SAP event ** - ** Others: emm_fsm_status ** + ** Inputs: evt: The received EMM-SAP event ** + ** Others: emm_fsm_status ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: emm_fsm_status ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: emm_fsm_status ** ** ** ***************************************************************************/ -int EmmDeregisteredLimitedService(const emm_reg_t* evt) +int EmmDeregisteredLimitedService(const emm_reg_t *evt) { LOG_FUNC_IN; @@ -74,61 +74,60 @@ int EmmDeregisteredLimitedService(const emm_reg_t* evt) assert(emm_fsm_get_status() == EMM_DEREGISTERED_LIMITED_SERVICE); - switch (evt->primitive) - { - case _EMMREG_REGISTER_REQ: - /* - * The user manually re-selected a PLMN to register to - */ - rc = emm_fsm_set_status(EMM_DEREGISTERED_PLMN_SEARCH); - if (rc != RETURNerror) { - /* Process the network registration request */ - rc = emm_fsm_process(evt); - } - break; - - case _EMMREG_ATTACH_INIT: - /* - * Initiate attach procedure for emergency bearer services - */ - rc = emm_proc_attach(EMM_ATTACH_TYPE_EMERGENCY); - break; - - case _EMMREG_ATTACH_REQ: - /* - * An attach for bearer emergency services has been requested - * (Attach Request message successfully delivered to the network); - * enter state EMM-REGISTERED-INITIATED - */ - rc = emm_fsm_set_status(EMM_REGISTERED_INITIATED); - break; - - case _EMMREG_LOWERLAYER_SUCCESS: - /* - * Initial NAS message has been successfully delivered - * to the network - */ - rc = emm_proc_lowerlayer_success(); - break; - - case _EMMREG_LOWERLAYER_FAILURE: - /* - * Initial NAS message failed to be delivered to the network - */ - rc = emm_proc_lowerlayer_failure(TRUE); - break; - - case _EMMREG_LOWERLAYER_RELEASE: - /* - * NAS signalling connection has been released - */ - rc = emm_proc_lowerlayer_release(); - break; - - default: - LOG_TRACE(ERROR, "EMM-FSM - Primitive is not valid (%d)", - evt->primitive); - break; + switch (evt->primitive) { + case _EMMREG_REGISTER_REQ: + /* + * The user manually re-selected a PLMN to register to + */ + rc = emm_fsm_set_status(EMM_DEREGISTERED_PLMN_SEARCH); + if (rc != RETURNerror) { + /* Process the network registration request */ + rc = emm_fsm_process(evt); + } + break; + + case _EMMREG_ATTACH_INIT: + /* + * Initiate attach procedure for emergency bearer services + */ + rc = emm_proc_attach(EMM_ATTACH_TYPE_EMERGENCY); + break; + + case _EMMREG_ATTACH_REQ: + /* + * An attach for bearer emergency services has been requested + * (Attach Request message successfully delivered to the network); + * enter state EMM-REGISTERED-INITIATED + */ + rc = emm_fsm_set_status(EMM_REGISTERED_INITIATED); + break; + + case _EMMREG_LOWERLAYER_SUCCESS: + /* + * Initial NAS message has been successfully delivered + * to the network + */ + rc = emm_proc_lowerlayer_success(); + break; + + case _EMMREG_LOWERLAYER_FAILURE: + /* + * Initial NAS message failed to be delivered to the network + */ + rc = emm_proc_lowerlayer_failure(TRUE); + break; + + case _EMMREG_LOWERLAYER_RELEASE: + /* + * NAS signalling connection has been released + */ + rc = emm_proc_lowerlayer_release(); + break; + + default: + LOG_TRACE(ERROR, "EMM-FSM - Primitive is not valid (%d)", + evt->primitive); + break; } LOG_FUNC_RETURN (rc); diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmDeregisteredNoCellAvailable.c b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmDeregisteredNoCellAvailable.c index 5d92edbad3..8dd6701589 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmDeregisteredNoCellAvailable.c +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmDeregisteredNoCellAvailable.c @@ -1,27 +1,27 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source EmmDeregisteredNoCellAvailable.c +Source EmmDeregisteredNoCellAvailable.c -Version 0.1 +Version 0.1 -Date 2012/10/03 +Date 2012/10/03 -Product NAS stack +Product NAS stack -Subsystem EPS Mobility Management +Subsystem EPS Mobility Management -Author Frederic Maurel +Author Frederic Maurel -Description Implements the EPS Mobility Management procedures executed - when the EMM-SAP is in EMM-DEREGISTERED.NO-CELL-AVAILABLE - state. +Description Implements the EPS Mobility Management procedures executed + when the EMM-SAP is in EMM-DEREGISTERED.NO-CELL-AVAILABLE + state. - In EMM-DEREGISTERED.NO-CELL-AVAILABLE state, no E-UTRAN cell - can be selected. A first intensive search failed when in - substate EMM_DEREGISTERED.PLMN-SEARCH. Cells are searched for - at a low rhythm. No EPS services are offered. + In EMM-DEREGISTERED.NO-CELL-AVAILABLE state, no E-UTRAN cell + can be selected. A first intensive search failed when in + substate EMM_DEREGISTERED.PLMN-SEARCH. Cells are searched for + at a low rhythm. No EPS services are offered. *****************************************************************************/ @@ -50,24 +50,24 @@ Description Implements the EPS Mobility Management procedures executed /**************************************************************************** ** ** - ** Name: EmmDeregisteredNoCellAvailable() ** + ** Name: EmmDeregisteredNoCellAvailable() ** ** ** ** Description: Handles the behaviour of the UE while the EMM-SAP is in ** - ** EMM-DEREGISTERED.NO-CELL-AVAILABLE state. ** + ** EMM-DEREGISTERED.NO-CELL-AVAILABLE state. ** ** ** ** 3GPP TS 24.301, section 5.2.2.3.7 ** - ** The UE shall perform cell selection and choose an appro- ** - ** priate substate when a cell is found. ** + ** The UE shall perform cell selection and choose an appro- ** + ** priate substate when a cell is found. ** ** ** - ** Inputs: evt: The received EMM-SAP event ** - ** Others: emm_fsm_status ** + ** Inputs: evt: The received EMM-SAP event ** + ** Others: emm_fsm_status ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: emm_fsm_status ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: emm_fsm_status ** ** ** ***************************************************************************/ -int EmmDeregisteredNoCellAvailable(const emm_reg_t* evt) +int EmmDeregisteredNoCellAvailable(const emm_reg_t *evt) { LOG_FUNC_IN; @@ -75,39 +75,38 @@ int EmmDeregisteredNoCellAvailable(const emm_reg_t* evt) assert(emm_fsm_get_status() == EMM_DEREGISTERED_NO_CELL_AVAILABLE); - 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 - * 4.2.4.1.2) */ - case _EMMREG_REGISTER_REQ: - /* - * The user manually re-selected a PLMN to register to - */ - rc = emm_fsm_set_status(EMM_DEREGISTERED_PLMN_SEARCH); - - if (rc != RETURNerror) { - /* - * Notify EMM that the MT is currently searching an operator - * to register to - */ - rc = emm_proc_registration_notify(NET_REG_STATE_ON); - if (rc != RETURNok) { - LOG_TRACE(WARNING, "EMM-FSM - " - "Failed to notify registration update"); - } - /* - * Perform network re-selection procedure - */ - rc = emm_proc_plmn_selection(evt->u.regist.index); - } - break; - - default: - LOG_TRACE(ERROR, "EMM-FSM - Primitive is not valid (%d)", - evt->primitive); - break; + 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 + * 4.2.4.1.2) */ + case _EMMREG_REGISTER_REQ: + /* + * The user manually re-selected a PLMN to register to + */ + rc = emm_fsm_set_status(EMM_DEREGISTERED_PLMN_SEARCH); + + if (rc != RETURNerror) { + /* + * Notify EMM that the MT is currently searching an operator + * to register to + */ + rc = emm_proc_registration_notify(NET_REG_STATE_ON); + if (rc != RETURNok) { + LOG_TRACE(WARNING, "EMM-FSM - " + "Failed to notify registration update"); + } + /* + * Perform network re-selection procedure + */ + rc = emm_proc_plmn_selection(evt->u.regist.index); + } + break; + + default: + LOG_TRACE(ERROR, "EMM-FSM - Primitive is not valid (%d)", + evt->primitive); + break; } LOG_FUNC_RETURN (rc); diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmDeregisteredNoImsi.c b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmDeregisteredNoImsi.c index 351e823bde..47163d7e9f 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmDeregisteredNoImsi.c +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmDeregisteredNoImsi.c @@ -1,24 +1,24 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source EmmDeregisteredNoImsi.c +Source EmmDeregisteredNoImsi.c -Version 0.1 +Version 0.1 -Date 2012/10/03 +Date 2012/10/03 -Product NAS stack +Product NAS stack -Subsystem EPS Mobility Management +Subsystem EPS Mobility Management -Author Frederic Maurel +Author Frederic Maurel -Description Implements the EPS Mobility Management procedures executed - when the EMM-SAP is in EMM-DEREGISTERED.NO-IMSI state. +Description Implements the EPS Mobility Management procedures executed + when the EMM-SAP is in EMM-DEREGISTERED.NO-IMSI state. - In EMM-DEREGISTERED.NO-IMSI state, the UE is switched on - without a valid USIM inserted. + In EMM-DEREGISTERED.NO-IMSI state, the UE is switched on + without a valid USIM inserted. *****************************************************************************/ @@ -44,24 +44,24 @@ Description Implements the EPS Mobility Management procedures executed /**************************************************************************** ** ** - ** Name: EmmDeregisteredNoImsi() ** + ** Name: EmmDeregisteredNoImsi() ** ** ** ** Description: Handles the behaviour of the UE while the EMM-SAP is in ** - ** EMM-DEREGISTERED.NO-IMSI state. ** + ** EMM-DEREGISTERED.NO-IMSI state. ** ** ** ** 3GPP TS 24.301, section 5.2.2.3.5 ** - ** The UE shall perform cell selection and may initiate ** - ** attach for emergency bearer services. ** + ** The UE shall perform cell selection and may initiate ** + ** attach for emergency bearer services. ** ** ** - ** Inputs: evt: The received EMM-SAP event ** - ** Others: emm_fsm_status ** + ** Inputs: evt: The received EMM-SAP event ** + ** Others: emm_fsm_status ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: emm_fsm_status ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: emm_fsm_status ** ** ** ***************************************************************************/ -int EmmDeregisteredNoImsi(const emm_reg_t* evt) +int EmmDeregisteredNoImsi(const emm_reg_t *evt) { LOG_FUNC_IN; diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmDeregisteredNormalService.c b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmDeregisteredNormalService.c index 7e28b8e2f3..4f85ecb87d 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmDeregisteredNormalService.c +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmDeregisteredNormalService.c @@ -1,26 +1,26 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source EmmDeregisteredNormalService.c +Source EmmDeregisteredNormalService.c -Version 0.1 +Version 0.1 -Date 2012/10/03 +Date 2012/10/03 -Product NAS stack +Product NAS stack -Subsystem EPS Mobility Management +Subsystem EPS Mobility Management -Author Frederic Maurel +Author Frederic Maurel -Description Implements the EPS Mobility Management procedures executed - when the EMM-SAP is in EMM-DEREGISTERED.NORMAL-SERVICE state. +Description Implements the EPS Mobility Management procedures executed + when the EMM-SAP is in EMM-DEREGISTERED.NORMAL-SERVICE state. - In EMM-DEREGISTERED.NORMAL-SERVICE state, the EPS update - status is EU1 or EU2, in the meantime a suitable cell has - been found and the PLMN or tracking area is not in the - forbidden list. + In EMM-DEREGISTERED.NORMAL-SERVICE state, the EPS update + status is EU1 or EU2, in the meantime a suitable cell has + been found and the PLMN or tracking area is not in the + forbidden list. *****************************************************************************/ @@ -49,24 +49,24 @@ Description Implements the EPS Mobility Management procedures executed /**************************************************************************** ** ** - ** Name: EmmDeregisteredNormalService() ** + ** Name: EmmDeregisteredNormalService() ** ** ** ** Description: Handles the behaviour of the UE while the EMM-SAP is in ** - ** EMM-DEREGISTERED.NORMAL-SERVICE state. ** + ** EMM-DEREGISTERED.NORMAL-SERVICE state. ** ** ** ** 3GPP TS 24.301, section 5.2.2.3.1 ** - ** The UE shall initiate an attach or combined attach proce- ** - ** dure. ** + ** The UE shall initiate an attach or combined attach proce- ** + ** dure. ** ** ** - ** Inputs: evt: The received EMM-SAP event ** - ** Others: emm_fsm_status ** + ** Inputs: evt: The received EMM-SAP event ** + ** Others: emm_fsm_status ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: emm_fsm_status ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: emm_fsm_status ** ** ** ***************************************************************************/ -int EmmDeregisteredNormalService(const emm_reg_t* evt) +int EmmDeregisteredNormalService(const emm_reg_t *evt) { LOG_FUNC_IN; @@ -74,56 +74,55 @@ int EmmDeregisteredNormalService(const emm_reg_t* evt) assert(emm_fsm_get_status() == EMM_DEREGISTERED_NORMAL_SERVICE); - switch (evt->primitive) - { - case _EMMREG_REGISTER_REQ: - /* - * The user manually re-selected a PLMN to register to - */ - rc = emm_fsm_set_status(EMM_DEREGISTERED_PLMN_SEARCH); - if (rc != RETURNerror) { - /* Process the network registration request */ - rc = emm_fsm_process(evt); - } - break; - - case _EMMREG_ATTACH_INIT: - /* - * Initiate the attach procedure for EPS services - */ - rc = emm_proc_attach(EMM_ATTACH_TYPE_EPS); - break; - - case _EMMREG_ATTACH_REQ: - /* - * An EPS network attach has been requested (Attach Request - * message successfully delivered to the network); - * enter state EMM-REGISTERED-INITIATED - */ - rc = emm_fsm_set_status(EMM_REGISTERED_INITIATED); - break; - - case _EMMREG_LOWERLAYER_SUCCESS: - /* - * Initial NAS message has been successfully delivered - * to the network - */ - rc = emm_proc_lowerlayer_success(); - break; - - case _EMMREG_LOWERLAYER_FAILURE: - /* - * Initial NAS message failed to be delivered to the network - */ - rc = emm_proc_lowerlayer_failure(TRUE); - break; - - case _EMMREG_LOWERLAYER_RELEASE: - /* - * NAS signalling connection has been released - */ - rc = emm_proc_lowerlayer_release(); - break; + switch (evt->primitive) { + case _EMMREG_REGISTER_REQ: + /* + * The user manually re-selected a PLMN to register to + */ + rc = emm_fsm_set_status(EMM_DEREGISTERED_PLMN_SEARCH); + if (rc != RETURNerror) { + /* Process the network registration request */ + rc = emm_fsm_process(evt); + } + break; + + case _EMMREG_ATTACH_INIT: + /* + * Initiate the attach procedure for EPS services + */ + rc = emm_proc_attach(EMM_ATTACH_TYPE_EPS); + break; + + case _EMMREG_ATTACH_REQ: + /* + * An EPS network attach has been requested (Attach Request + * message successfully delivered to the network); + * enter state EMM-REGISTERED-INITIATED + */ + rc = emm_fsm_set_status(EMM_REGISTERED_INITIATED); + break; + + case _EMMREG_LOWERLAYER_SUCCESS: + /* + * Initial NAS message has been successfully delivered + * to the network + */ + rc = emm_proc_lowerlayer_success(); + break; + + case _EMMREG_LOWERLAYER_FAILURE: + /* + * Initial NAS message failed to be delivered to the network + */ + rc = emm_proc_lowerlayer_failure(TRUE); + break; + + case _EMMREG_LOWERLAYER_RELEASE: + /* + * NAS signalling connection has been released + */ + rc = emm_proc_lowerlayer_release(); + break; case _EMMREG_ATTACH_CNF: /* @@ -134,10 +133,10 @@ int EmmDeregisteredNormalService(const emm_reg_t* evt) rc = emm_fsm_set_status(EMM_REGISTERED); break; - default: - LOG_TRACE(ERROR, "EMM-FSM - Primitive is not valid (%d)", - evt->primitive); - break; + default: + LOG_TRACE(ERROR, "EMM-FSM - Primitive is not valid (%d)", + evt->primitive); + break; } LOG_FUNC_RETURN (rc); diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmDeregisteredPlmnSearch.c b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmDeregisteredPlmnSearch.c index 5b46d691c8..551c5dcb15 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmDeregisteredPlmnSearch.c +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmDeregisteredPlmnSearch.c @@ -1,24 +1,24 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source EmmDeregisteredPlmnSearch.c +Source EmmDeregisteredPlmnSearch.c -Version 0.1 +Version 0.1 -Date 2012/10/03 +Date 2012/10/03 -Product NAS stack +Product NAS stack -Subsystem EPS Mobility Management +Subsystem EPS Mobility Management -Author Frederic Maurel +Author Frederic Maurel -Description Implements the EPS Mobility Management procedures executed - when the EMM-SAP is in EMM-DEREGISTERED.PLMN-SEARCH state. +Description Implements the EPS Mobility Management procedures executed + when the EMM-SAP is in EMM-DEREGISTERED.PLMN-SEARCH state. - In EMM-DEREGISTERED.PLMN-SEARCH state, the UE with a valid - USIM is switched on. + In EMM-DEREGISTERED.PLMN-SEARCH state, the UE with a valid + USIM is switched on. *****************************************************************************/ @@ -47,25 +47,25 @@ Description Implements the EPS Mobility Management procedures executed /**************************************************************************** ** ** - ** Name: EmmDeregisteredPlmnSearch() ** + ** Name: EmmDeregisteredPlmnSearch() ** ** ** ** Description: Handles the behaviour of the UE while the EMM-SAP is in ** - ** EMM-DEREGISTERED.PLMN-SEARCH state. ** + ** EMM-DEREGISTERED.PLMN-SEARCH state. ** ** ** ** 3GPP TS 24.301, section 5.2.2.3.4 ** - ** The UE shall perform PLMN selection. If a new PLMN is ** - ** selected, the UE shall reset the attach attempt counter ** - ** and initiate the attach or combined attach procedure. ** + ** The UE shall perform PLMN selection. If a new PLMN is ** + ** selected, the UE shall reset the attach attempt counter ** + ** and initiate the attach or combined attach procedure. ** ** ** - ** Inputs: evt: The received EMM-SAP event ** - ** Others: emm_fsm_status ** + ** Inputs: evt: The received EMM-SAP event ** + ** Others: emm_fsm_status ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: emm_fsm_status ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: emm_fsm_status ** ** ** ***************************************************************************/ -int EmmDeregisteredPlmnSearch(const emm_reg_t* evt) +int EmmDeregisteredPlmnSearch(const emm_reg_t *evt) { LOG_FUNC_IN; @@ -73,57 +73,56 @@ int EmmDeregisteredPlmnSearch(const emm_reg_t* evt) assert(emm_fsm_get_status() == EMM_DEREGISTERED_PLMN_SEARCH); - switch (evt->primitive) - { - case _EMMREG_NO_CELL: - /* - * No suitable cell of the selected PLMN has been found to camp on - */ - rc = emm_proc_registration_notify(NET_REG_STATE_DENIED); - if (rc != RETURNok) { - LOG_TRACE(WARNING, "EMM-FSM - " - "Failed to notify registration update"); - } - rc = emm_fsm_set_status(EMM_DEREGISTERED_NO_CELL_AVAILABLE); - break; - - case _EMMREG_REGISTER_REQ: - /* - * The UE has been switched on and is currently searching an - * operator to register to. The particular PLMN to be contacted - * may be selected either automatically or manually. - * Or the user manually re-selected a PLMN to register to. - */ - rc = emm_proc_registration_notify(NET_REG_STATE_ON); - if (rc != RETURNok) { - LOG_TRACE(WARNING, "EMM-FSM - " - "Failed to notify registration update"); - } - /* - * Perform network selection procedure - */ - rc = emm_proc_plmn_selection(evt->u.regist.index); - break; - - case _EMMREG_REGISTER_REJ: - /* - * The selected cell is known not to be able to provide normal - * service - */ - rc = emm_fsm_set_status(EMM_DEREGISTERED_LIMITED_SERVICE); - break; - - case _EMMREG_REGISTER_CNF: - /* - * A suitable cell of the selected PLMN has been found to camp on - */ - rc = emm_fsm_set_status(EMM_DEREGISTERED_NORMAL_SERVICE); - break; - - default: - LOG_TRACE(ERROR, "EMM-FSM - Primitive is not valid (%d)", - evt->primitive); - break; + switch (evt->primitive) { + case _EMMREG_NO_CELL: + /* + * No suitable cell of the selected PLMN has been found to camp on + */ + rc = emm_proc_registration_notify(NET_REG_STATE_DENIED); + if (rc != RETURNok) { + LOG_TRACE(WARNING, "EMM-FSM - " + "Failed to notify registration update"); + } + rc = emm_fsm_set_status(EMM_DEREGISTERED_NO_CELL_AVAILABLE); + break; + + case _EMMREG_REGISTER_REQ: + /* + * The UE has been switched on and is currently searching an + * operator to register to. The particular PLMN to be contacted + * may be selected either automatically or manually. + * Or the user manually re-selected a PLMN to register to. + */ + rc = emm_proc_registration_notify(NET_REG_STATE_ON); + if (rc != RETURNok) { + LOG_TRACE(WARNING, "EMM-FSM - " + "Failed to notify registration update"); + } + /* + * Perform network selection procedure + */ + rc = emm_proc_plmn_selection(evt->u.regist.index); + break; + + case _EMMREG_REGISTER_REJ: + /* + * The selected cell is known not to be able to provide normal + * service + */ + rc = emm_fsm_set_status(EMM_DEREGISTERED_LIMITED_SERVICE); + break; + + case _EMMREG_REGISTER_CNF: + /* + * A suitable cell of the selected PLMN has been found to camp on + */ + rc = emm_fsm_set_status(EMM_DEREGISTERED_NORMAL_SERVICE); + break; + + default: + LOG_TRACE(ERROR, "EMM-FSM - Primitive is not valid (%d)", + evt->primitive); + break; } LOG_FUNC_RETURN (rc); diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmNull.c b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmNull.c index 482ac6fccb..389dc93287 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmNull.c +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmNull.c @@ -1,24 +1,24 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source EmmNull.c +Source EmmNull.c -Version 0.1 +Version 0.1 -Date 2012/10/03 +Date 2012/10/03 -Product NAS stack +Product NAS stack -Subsystem EPS Mobility Management +Subsystem EPS Mobility Management -Author Frederic Maurel +Author Frederic Maurel -Description Implements the EPS Mobility Management procedures executed - when the EMM-SAP is in EMM-NULL state. +Description Implements the EPS Mobility Management procedures executed + when the EMM-SAP is in EMM-NULL state. - In EMM-NULL state, the EPS capability is disabled in the UE. - No EPS mobility management function shall be performed. + In EMM-NULL state, the EPS capability is disabled in the UE. + No EPS mobility management function shall be performed. *****************************************************************************/ @@ -46,20 +46,20 @@ Description Implements the EPS Mobility Management procedures executed /**************************************************************************** ** ** - ** Name: EmmNull() ** + ** Name: EmmNull() ** ** ** ** Description: Handles the behaviour of the UE while the EMM-SAP is in ** - ** EMM-NULL state. ** + ** EMM-NULL state. ** ** ** - ** Inputs: evt: The received EMM-SAP event ** - ** Others: emm_fsm_status ** + ** Inputs: evt: The received EMM-SAP event ** + ** Others: emm_fsm_status ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: emm_fsm_status ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: emm_fsm_status ** ** ** ***************************************************************************/ -int EmmNull(const emm_reg_t* evt) +int EmmNull(const emm_reg_t *evt) { LOG_FUNC_IN; @@ -70,34 +70,33 @@ int EmmNull(const emm_reg_t* evt) /* Delete the authentication data RAND and RES */ rc = emm_proc_authentication_delete(); if (rc != RETURNok) { - LOG_FUNC_RETURN (rc); + LOG_FUNC_RETURN (rc); } - switch (evt->primitive) - { - case _EMMREG_S1_ENABLED: - /* - * The EPS capability has been enabled in the UE: - * Move to the DEREGISTERED state; - */ - rc = emm_fsm_set_status(EMM_DEREGISTERED); - - /* - * And initialize the EMM procedure call manager in order to - * establish an EMM context and make the UE reachable by an MME. - */ - if (rc != RETURNerror) { - rc = emm_proc_initialize(); - } - break; - - default: - rc = RETURNerror; - LOG_TRACE(ERROR, "EMM-FSM - Primitive is not valid (%d)", - evt->primitive); - LOG_TRACE(WARNING, "EMM-FSM - Set phone functionnality to " - "enable EPS capability (+cfun=1)"); - break; + switch (evt->primitive) { + case _EMMREG_S1_ENABLED: + /* + * The EPS capability has been enabled in the UE: + * Move to the DEREGISTERED state; + */ + rc = emm_fsm_set_status(EMM_DEREGISTERED); + + /* + * And initialize the EMM procedure call manager in order to + * establish an EMM context and make the UE reachable by an MME. + */ + if (rc != RETURNerror) { + rc = emm_proc_initialize(); + } + break; + + default: + rc = RETURNerror; + LOG_TRACE(ERROR, "EMM-FSM - Primitive is not valid (%d)", + evt->primitive); + LOG_TRACE(WARNING, "EMM-FSM - Set phone functionnality to " + "enable EPS capability (+cfun=1)"); + break; } LOG_FUNC_RETURN (rc); diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmRegistered.c b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmRegistered.c index e74205f811..2aef96138d 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmRegistered.c +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmRegistered.c @@ -1,29 +1,29 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source EmmRegistered.c +Source EmmRegistered.c -Version 0.1 +Version 0.1 -Date 2012/10/03 +Date 2012/10/03 -Product NAS stack +Product NAS stack -Subsystem EPS Mobility Management +Subsystem EPS Mobility Management -Author Frederic Maurel +Author Frederic Maurel -Description Implements the EPS Mobility Management procedures executed - when the EMM-SAP is in EMM-REGISTERED state. +Description Implements the EPS Mobility Management procedures executed + when the EMM-SAP is in EMM-REGISTERED state. - In EMM-REGISTERED state, an EMM context has been established - and a default EPS bearer context has been activated in the UE - and the MME. - The UE may initiate sending and receiving user data and signal- - ling information and reply to paging. Additionally, tracking - area updating or combined tracking area updating procedure is - performed. + In EMM-REGISTERED state, an EMM context has been established + and a default EPS bearer context has been activated in the UE + and the MME. + The UE may initiate sending and receiving user data and signal- + ling information and reply to paging. Additionally, tracking + area updating or combined tracking area updating procedure is + performed. *****************************************************************************/ @@ -50,20 +50,20 @@ Description Implements the EPS Mobility Management procedures executed /**************************************************************************** ** ** - ** Name: EmmRegistered() ** + ** Name: EmmRegistered() ** ** ** ** Description: Handles the behaviour of the UE and the MME while the ** - ** EMM-SAP is in EMM-REGISTERED state. ** + ** EMM-SAP is in EMM-REGISTERED state. ** ** ** - ** Inputs: evt: The received EMM-SAP event ** - ** Others: emm_fsm_status ** + ** Inputs: evt: The received EMM-SAP event ** + ** Others: emm_fsm_status ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: emm_fsm_status ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: emm_fsm_status ** ** ** ***************************************************************************/ -int EmmRegistered(const emm_reg_t* evt) +int EmmRegistered(const emm_reg_t *evt) { LOG_FUNC_IN; @@ -76,115 +76,114 @@ 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: - /* - * Initiate detach procedure for EPS services - */ - rc = emm_proc_detach(EMM_DETACH_TYPE_EPS, evt->u.detach.switch_off); - break; - - case _EMMREG_DETACH_REQ: - /* - * Network detach has been requested (Detach Request - * message successfully delivered to the network); - * enter state EMM-DEREGISTERED-INITIATED - */ - rc = emm_fsm_set_status(EMM_DEREGISTERED_INITIATED); - break; - - case _EMMREG_DETACH_CNF: - /* - * The UE implicitly detached from the network (all EPS - * bearer contexts may have been deactivated) - */ - rc = emm_fsm_set_status(EMM_DEREGISTERED); - break; - - case _EMMREG_TAU_REQ: - /* - * TODO: Tracking Area Update has been requested - */ - LOG_TRACE(ERROR, "EMM-FSM - Tracking Area Update procedure " - "is not implemented"); - break; - - case _EMMREG_SERVICE_REQ: - /* - * TODO: Service Request has been requested - */ - LOG_TRACE(ERROR, "EMM-FSM - Service Request procedure " - "is not implemented"); - break; - - case _EMMREG_LOWERLAYER_SUCCESS: - /* - * Data transfer message has been successfully delivered - */ - rc = emm_proc_lowerlayer_success(); - break; - - case _EMMREG_LOWERLAYER_FAILURE: - /* - * Data transfer message failed to be delivered - */ - rc = emm_proc_lowerlayer_failure(FALSE); - break; - - case _EMMREG_LOWERLAYER_RELEASE: - /* - * NAS signalling connection has been released - */ - rc = emm_proc_lowerlayer_release(); - break; + case _EMMREG_DETACH_INIT: + /* + * Initiate detach procedure for EPS services + */ + rc = emm_proc_detach(EMM_DETACH_TYPE_EPS, evt->u.detach.switch_off); + break; + + case _EMMREG_DETACH_REQ: + /* + * Network detach has been requested (Detach Request + * message successfully delivered to the network); + * enter state EMM-DEREGISTERED-INITIATED + */ + rc = emm_fsm_set_status(EMM_DEREGISTERED_INITIATED); + break; + + case _EMMREG_DETACH_CNF: + /* + * The UE implicitly detached from the network (all EPS + * bearer contexts may have been deactivated) + */ + rc = emm_fsm_set_status(EMM_DEREGISTERED); + break; + + case _EMMREG_TAU_REQ: + /* + * TODO: Tracking Area Update has been requested + */ + LOG_TRACE(ERROR, "EMM-FSM - Tracking Area Update procedure " + "is not implemented"); + break; + + case _EMMREG_SERVICE_REQ: + /* + * TODO: Service Request has been requested + */ + LOG_TRACE(ERROR, "EMM-FSM - Service Request procedure " + "is not implemented"); + break; + + case _EMMREG_LOWERLAYER_SUCCESS: + /* + * Data transfer message has been successfully delivered + */ + rc = emm_proc_lowerlayer_success(); + break; + + case _EMMREG_LOWERLAYER_FAILURE: + /* + * Data transfer message failed to be delivered + */ + rc = emm_proc_lowerlayer_failure(FALSE); + break; + + case _EMMREG_LOWERLAYER_RELEASE: + /* + * NAS signalling connection has been released + */ + rc = emm_proc_lowerlayer_release(); + break; #endif #ifdef NAS_MME - case _EMMREG_DETACH_REQ: - /* - * Network detach has been requested (implicit detach); - * enter state EMM-DEREGISTERED - */ + case _EMMREG_DETACH_REQ: + /* + * Network detach has been requested (implicit detach); + * enter state EMM-DEREGISTERED + */ rc = emm_fsm_set_status(evt->ueid, evt->ctx, EMM_DEREGISTERED); - break; + break; - case _EMMREG_COMMON_PROC_REQ: - /* - * An EMM common procedure has been initiated; - * enter state EMM-COMMON-PROCEDURE-INITIATED. - */ + case _EMMREG_COMMON_PROC_REQ: + /* + * An EMM common procedure has been initiated; + * enter state EMM-COMMON-PROCEDURE-INITIATED. + */ rc = emm_fsm_set_status(evt->ueid, evt->ctx, EMM_COMMON_PROCEDURE_INITIATED); - break; - - case _EMMREG_TAU_REJ: - /* - * TODO: Tracking Area Update has been rejected - */ - LOG_TRACE(ERROR, "EMM-FSM - Tracking Area Update procedure " - "is not implemented"); - break; - - case _EMMREG_LOWERLAYER_SUCCESS: - /* - * Data successfully delivered to the network - */ - rc = RETURNok; - break; - - case _EMMREG_LOWERLAYER_FAILURE: - /* - * Data failed to be delivered to the network - */ - rc = RETURNok; - break; + break; + + case _EMMREG_TAU_REJ: + /* + * TODO: Tracking Area Update has been rejected + */ + LOG_TRACE(ERROR, "EMM-FSM - Tracking Area Update procedure " + "is not implemented"); + break; + + case _EMMREG_LOWERLAYER_SUCCESS: + /* + * Data successfully delivered to the network + */ + rc = RETURNok; + break; + + case _EMMREG_LOWERLAYER_FAILURE: + /* + * Data failed to be delivered to the network + */ + rc = RETURNok; + break; #endif - default: - LOG_TRACE(ERROR, "EMM-FSM - Primitive is not valid (%d)", - evt->primitive); - break; + default: + LOG_TRACE(ERROR, "EMM-FSM - Primitive is not valid (%d)", + evt->primitive); + break; } LOG_FUNC_RETURN (rc); diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmRegisteredAttemptingToUpdate.c b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmRegisteredAttemptingToUpdate.c index cc8f837894..236398d3ba 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmRegisteredAttemptingToUpdate.c +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmRegisteredAttemptingToUpdate.c @@ -1,29 +1,29 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source EmmRegisteredAttemptingToUpdate.c +Source EmmRegisteredAttemptingToUpdate.c -Version 0.1 +Version 0.1 -Date 2012/10/03 +Date 2012/10/03 -Product NAS stack +Product NAS stack -Subsystem EPS Mobility Management +Subsystem EPS Mobility Management -Author Frederic Maurel +Author Frederic Maurel -Description Implements the EPS Mobility Management procedures executed - when the EMM-SAP is in EMM-REGISTERED.ATTEMPTING-TO-UPDATE - state. +Description Implements the EPS Mobility Management procedures executed + when the EMM-SAP is in EMM-REGISTERED.ATTEMPTING-TO-UPDATE + state. - In EMM-REGISTERED.ATTEMPTING-TO-UPDATE state, the tracking - area updating or combined tracking area updating procedure - failed due to a missing response from the network. - No EMM procedure except the tracking area updating or com- - bined tracking area updating procedure shall be initiated - by the UE in this substate. No data shall be sent or received. + In EMM-REGISTERED.ATTEMPTING-TO-UPDATE state, the tracking + area updating or combined tracking area updating procedure + failed due to a missing response from the network. + No EMM procedure except the tracking area updating or com- + bined tracking area updating procedure shall be initiated + by the UE in this substate. No data shall be sent or received. *****************************************************************************/ @@ -49,20 +49,20 @@ Description Implements the EPS Mobility Management procedures executed /**************************************************************************** ** ** - ** Name: EmmRegisteredAttemptingToUpdate() ** + ** Name: EmmRegisteredAttemptingToUpdate() ** ** ** ** Description: Handles the behaviour of the UE while the EMM-SAP is in ** - ** EMM-REGISTERED.ATTEMPTING-TO-UPDATE state. ** + ** EMM-REGISTERED.ATTEMPTING-TO-UPDATE state. ** ** ** - ** Inputs: evt: The received EMM-SAP event ** - ** Others: emm_fsm_status ** + ** Inputs: evt: The received EMM-SAP event ** + ** Others: emm_fsm_status ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: emm_fsm_status ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: emm_fsm_status ** ** ** ***************************************************************************/ -int EmmRegisteredAttemptingToUpdate(const emm_reg_t* evt) +int EmmRegisteredAttemptingToUpdate(const emm_reg_t *evt) { LOG_FUNC_IN; diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmRegisteredImsiDetachInitiated.c b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmRegisteredImsiDetachInitiated.c index 702d2c7685..ad08d598d5 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmRegisteredImsiDetachInitiated.c +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmRegisteredImsiDetachInitiated.c @@ -1,28 +1,28 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source EmmRegisteredImsiDetachInitiated.c +Source EmmRegisteredImsiDetachInitiated.c -Version 0.1 +Version 0.1 -Date 2012/10/03 +Date 2012/10/03 -Product NAS stack +Product NAS stack -Subsystem EPS Mobility Management +Subsystem EPS Mobility Management -Author Frederic Maurel +Author Frederic Maurel -Description Implements the EPS Mobility Management procedures executed - when the EMM-SAP is in EMM-REGISTERED.IMSI-DETACH-INITIATED - state. +Description Implements the EPS Mobility Management procedures executed + when the EMM-SAP is in EMM-REGISTERED.IMSI-DETACH-INITIATED + state. - In EMM-REGISTERED.IMSI-DETACH-INITIATED state, the UE performs - a combined detach procedure for non-EPS services only. - The UE was attached for EPS and non-EPS services and wants to - detach for non-EPS services only. User data and signalling - information may be sent and received. + In EMM-REGISTERED.IMSI-DETACH-INITIATED state, the UE performs + a combined detach procedure for non-EPS services only. + The UE was attached for EPS and non-EPS services and wants to + detach for non-EPS services only. User data and signalling + information may be sent and received. *****************************************************************************/ @@ -48,20 +48,20 @@ Description Implements the EPS Mobility Management procedures executed /**************************************************************************** ** ** - ** Name: EmmRegisteredImsiDetachInitiated() ** + ** Name: EmmRegisteredImsiDetachInitiated() ** ** ** ** Description: Handles the behaviour of the UE while the EMM-SAP is in ** - ** EMM-REGISTERED.IMSI-DETACH-INITIATED state. ** + ** EMM-REGISTERED.IMSI-DETACH-INITIATED state. ** ** ** - ** Inputs: evt: The received EMM-SAP event ** - ** Others: emm_fsm_status ** + ** Inputs: evt: The received EMM-SAP event ** + ** Others: emm_fsm_status ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: emm_fsm_status ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: emm_fsm_status ** ** ** ***************************************************************************/ -int EmmRegisteredImsiDetachInitiated(const emm_reg_t* evt) +int EmmRegisteredImsiDetachInitiated(const emm_reg_t *evt) { LOG_FUNC_IN; diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmRegisteredInitiated.c b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmRegisteredInitiated.c index 8b9921d834..7d9f9ff63f 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmRegisteredInitiated.c +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmRegisteredInitiated.c @@ -1,25 +1,25 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source EmmRegisteredInitiated.c +Source EmmRegisteredInitiated.c -Version 0.1 +Version 0.1 -Date 2012/10/03 +Date 2012/10/03 -Product NAS stack +Product NAS stack -Subsystem EPS Mobility Management +Subsystem EPS Mobility Management -Author Frederic Maurel +Author Frederic Maurel -Description Implements the EPS Mobility Management procedures executed - when the EMM-SAP is in EMM-REGISTERED-INITIATED state. +Description Implements the EPS Mobility Management procedures executed + when the EMM-SAP is in EMM-REGISTERED-INITIATED state. - In EMM-REGISTERED-INITIATED state, the attach or the combined - attach procedure has been started and the UE is waiting for a - response from the MME. + In EMM-REGISTERED-INITIATED state, the attach or the combined + attach procedure has been started and the UE is waiting for a + response from the MME. *****************************************************************************/ @@ -48,20 +48,20 @@ Description Implements the EPS Mobility Management procedures executed /**************************************************************************** ** ** - ** Name: EmmRegisteredInitiated() ** + ** Name: EmmRegisteredInitiated() ** ** ** ** Description: Handles the behaviour of the UE while the EMM-SAP is in ** - ** EMM-REGISTERED-INITIATED state. ** + ** EMM-REGISTERED-INITIATED state. ** ** ** - ** Inputs: evt: The received EMM-SAP event ** - ** Others: emm_fsm_status ** + ** Inputs: evt: The received EMM-SAP event ** + ** Others: emm_fsm_status ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: emm_fsm_status ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: emm_fsm_status ** ** ** ***************************************************************************/ -int EmmRegisteredInitiated(const emm_reg_t* evt) +int EmmRegisteredInitiated(const emm_reg_t *evt) { LOG_FUNC_IN; @@ -69,165 +69,164 @@ int EmmRegisteredInitiated(const emm_reg_t* evt) assert(emm_fsm_get_status() == EMM_REGISTERED_INITIATED); - switch (evt->primitive) - { - case _EMMREG_ATTACH_INIT: - /* - * Attach procedure has to be restarted (timers T3402 or T3411 - * expired) - */ - - /* Move to the corresponding initial EMM state */ - if (evt->u.attach.is_emergency) { - rc = emm_fsm_set_status(EMM_DEREGISTERED_LIMITED_SERVICE); - } else { - rc = emm_fsm_set_status(EMM_DEREGISTERED_NORMAL_SERVICE); - } - if (rc != RETURNerror) { - /* Restart the attach procedure */ - rc = emm_proc_attach_restart(); - } - break; - - case _EMMREG_ATTACH_FAILED: - /* - * Attempt to attach to the network failed (abnormal case or - * timer T3410 expired). The network attach procedure shall be - * restarted when timer T3411 expires. - */ - rc = emm_fsm_set_status(EMM_DEREGISTERED_ATTEMPTING_TO_ATTACH); - break; - - case _EMMREG_ATTACH_EXCEEDED: - /* - * Attempt to attach to the network failed (abnormal case or - * timer T3410 expired) and the attach attempt counter reached - * its maximum value. The state is changed to EMM-DEREGISTERED. - * ATTEMPTING-TO-ATTACH or optionally to EMM-DEREGISTERED.PLMN- - * SEARCH in order to perform a PLMN selection. - */ - /* TODO: ATTEMPTING-TO-ATTACH or PLMN-SEARCH ??? */ - rc = emm_fsm_set_status(EMM_DEREGISTERED_ATTEMPTING_TO_ATTACH); - break; - - case _EMMREG_ATTACH_CNF: - /* - * EPS network attach accepted by the network; - * enter state EMM-REGISTERED. - */ - rc = emm_fsm_set_status(EMM_REGISTERED); - - if (rc != RETURNerror) { - /* - * Notify EMM that the MT is registered - */ - rc = emm_proc_registration_notify(NET_REG_STATE_HN); - if (rc != RETURNok) { - LOG_TRACE(WARNING, "EMM-FSM - " - "Failed to notify registration update"); - } - } - break; - - case _EMMREG_AUTH_REJ: - /* - * UE authentication rejected by the network; - * abort any EMM signalling procedure - */ - case _EMMREG_ATTACH_REJ: - /* - * EPS network attach rejected by the network; - * enter state EMM-DEREGISTERED. - */ - rc = emm_fsm_set_status(EMM_DEREGISTERED); - - if (rc != RETURNerror) { - /* - * Notify EMM that the MT's registration is denied - */ - rc = emm_proc_registration_notify(NET_REG_STATE_DENIED); - if (rc != RETURNok) { - LOG_TRACE(WARNING, "EMM-FSM - " - "Failed to notify registration update"); - } - } - break; - - case _EMMREG_REGISTER_REQ: - /* - * The UE has to select a new PLMN to register to - */ - rc = emm_fsm_set_status(EMM_DEREGISTERED_PLMN_SEARCH); - if (rc != RETURNerror) { - /* Process the network registration request */ - rc = emm_fsm_process(evt); - } - break; - - case _EMMREG_REGISTER_REJ: - /* - * The UE failed to register to the network for normal EPS service - */ - rc = emm_fsm_set_status(EMM_DEREGISTERED_LIMITED_SERVICE); - break; - - case _EMMREG_NO_IMSI: - /* - * The UE failed to register to the network for emergency - * bearer services - */ - rc = emm_fsm_set_status(EMM_DEREGISTERED_NO_IMSI); - break; - - case _EMMREG_DETACH_INIT: - /* - * Initiate detach procedure for EPS services - */ - rc = emm_proc_detach(EMM_DETACH_TYPE_EPS, evt->u.detach.switch_off); - break; - - case _EMMREG_DETACH_REQ: - /* - * An EPS network detach has been requested (Detach Request - * message successfully delivered to the network); - * enter state EMM-DEREGISTERED-INITIATED - */ - rc = emm_fsm_set_status(EMM_DEREGISTERED_INITIATED); - break; - - case _EMMREG_LOWERLAYER_SUCCESS: - /* - * Data transfer message has been successfully delivered; - * The NAS message may be Attach Complete, Detach Request or - * any message transfered by EMM common procedures requested - * by the network. - */ - rc = emm_proc_lowerlayer_success(); - break; - - case _EMMREG_LOWERLAYER_FAILURE: - /* - * Data transfer message failed to be delivered; - * The NAS message may be Attach Complete, Detach Request or - * any message transfered by EMM common procedures requested - * by the network. - */ - rc = emm_proc_lowerlayer_failure(FALSE); - break; - - case _EMMREG_LOWERLAYER_RELEASE: - /* - * NAS signalling connection has been released before the Attach - * Accept, Attach Reject, or any message transfered by EMM common - * procedures requested by the network, is received. - */ - rc = emm_proc_lowerlayer_release(); - break; - - default: - LOG_TRACE(ERROR, "EMM-FSM - Primitive is not valid (%d)", - evt->primitive); - break; + switch (evt->primitive) { + case _EMMREG_ATTACH_INIT: + /* + * Attach procedure has to be restarted (timers T3402 or T3411 + * expired) + */ + + /* Move to the corresponding initial EMM state */ + if (evt->u.attach.is_emergency) { + rc = emm_fsm_set_status(EMM_DEREGISTERED_LIMITED_SERVICE); + } else { + rc = emm_fsm_set_status(EMM_DEREGISTERED_NORMAL_SERVICE); + } + if (rc != RETURNerror) { + /* Restart the attach procedure */ + rc = emm_proc_attach_restart(); + } + break; + + case _EMMREG_ATTACH_FAILED: + /* + * Attempt to attach to the network failed (abnormal case or + * timer T3410 expired). The network attach procedure shall be + * restarted when timer T3411 expires. + */ + rc = emm_fsm_set_status(EMM_DEREGISTERED_ATTEMPTING_TO_ATTACH); + break; + + case _EMMREG_ATTACH_EXCEEDED: + /* + * Attempt to attach to the network failed (abnormal case or + * timer T3410 expired) and the attach attempt counter reached + * its maximum value. The state is changed to EMM-DEREGISTERED. + * ATTEMPTING-TO-ATTACH or optionally to EMM-DEREGISTERED.PLMN- + * SEARCH in order to perform a PLMN selection. + */ + /* TODO: ATTEMPTING-TO-ATTACH or PLMN-SEARCH ??? */ + rc = emm_fsm_set_status(EMM_DEREGISTERED_ATTEMPTING_TO_ATTACH); + break; + + case _EMMREG_ATTACH_CNF: + /* + * EPS network attach accepted by the network; + * enter state EMM-REGISTERED. + */ + rc = emm_fsm_set_status(EMM_REGISTERED); + + if (rc != RETURNerror) { + /* + * Notify EMM that the MT is registered + */ + rc = emm_proc_registration_notify(NET_REG_STATE_HN); + if (rc != RETURNok) { + LOG_TRACE(WARNING, "EMM-FSM - " + "Failed to notify registration update"); + } + } + break; + + case _EMMREG_AUTH_REJ: + /* + * UE authentication rejected by the network; + * abort any EMM signalling procedure + */ + case _EMMREG_ATTACH_REJ: + /* + * EPS network attach rejected by the network; + * enter state EMM-DEREGISTERED. + */ + rc = emm_fsm_set_status(EMM_DEREGISTERED); + + if (rc != RETURNerror) { + /* + * Notify EMM that the MT's registration is denied + */ + rc = emm_proc_registration_notify(NET_REG_STATE_DENIED); + if (rc != RETURNok) { + LOG_TRACE(WARNING, "EMM-FSM - " + "Failed to notify registration update"); + } + } + break; + + case _EMMREG_REGISTER_REQ: + /* + * The UE has to select a new PLMN to register to + */ + rc = emm_fsm_set_status(EMM_DEREGISTERED_PLMN_SEARCH); + if (rc != RETURNerror) { + /* Process the network registration request */ + rc = emm_fsm_process(evt); + } + break; + + case _EMMREG_REGISTER_REJ: + /* + * The UE failed to register to the network for normal EPS service + */ + rc = emm_fsm_set_status(EMM_DEREGISTERED_LIMITED_SERVICE); + break; + + case _EMMREG_NO_IMSI: + /* + * The UE failed to register to the network for emergency + * bearer services + */ + rc = emm_fsm_set_status(EMM_DEREGISTERED_NO_IMSI); + break; + + case _EMMREG_DETACH_INIT: + /* + * Initiate detach procedure for EPS services + */ + rc = emm_proc_detach(EMM_DETACH_TYPE_EPS, evt->u.detach.switch_off); + break; + + case _EMMREG_DETACH_REQ: + /* + * An EPS network detach has been requested (Detach Request + * message successfully delivered to the network); + * enter state EMM-DEREGISTERED-INITIATED + */ + rc = emm_fsm_set_status(EMM_DEREGISTERED_INITIATED); + break; + + case _EMMREG_LOWERLAYER_SUCCESS: + /* + * Data transfer message has been successfully delivered; + * The NAS message may be Attach Complete, Detach Request or + * any message transfered by EMM common procedures requested + * by the network. + */ + rc = emm_proc_lowerlayer_success(); + break; + + case _EMMREG_LOWERLAYER_FAILURE: + /* + * Data transfer message failed to be delivered; + * The NAS message may be Attach Complete, Detach Request or + * any message transfered by EMM common procedures requested + * by the network. + */ + rc = emm_proc_lowerlayer_failure(FALSE); + break; + + case _EMMREG_LOWERLAYER_RELEASE: + /* + * NAS signalling connection has been released before the Attach + * Accept, Attach Reject, or any message transfered by EMM common + * procedures requested by the network, is received. + */ + rc = emm_proc_lowerlayer_release(); + break; + + default: + LOG_TRACE(ERROR, "EMM-FSM - Primitive is not valid (%d)", + evt->primitive); + break; } LOG_FUNC_RETURN (rc); diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmRegisteredLimitedService.c b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmRegisteredLimitedService.c index 022cae3f41..208cf5bdf3 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmRegisteredLimitedService.c +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmRegisteredLimitedService.c @@ -1,24 +1,24 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source EmmRegisteredLimitedService.c +Source EmmRegisteredLimitedService.c -Version 0.1 +Version 0.1 -Date 2012/10/03 +Date 2012/10/03 -Product NAS stack +Product NAS stack -Subsystem EPS Mobility Management +Subsystem EPS Mobility Management -Author Frederic Maurel +Author Frederic Maurel -Description Implements the EPS Mobility Management procedures executed - when the EMM-SAP is in EMM-REGISTERED.LIMITED-SERVICE state. +Description Implements the EPS Mobility Management procedures executed + when the EMM-SAP is in EMM-REGISTERED.LIMITED-SERVICE state. - In EMM-REGISTERED.LIMITED-SERVICE state, the cell the UE - selected is known not to be able to provide normal service. + In EMM-REGISTERED.LIMITED-SERVICE state, the cell the UE + selected is known not to be able to provide normal service. *****************************************************************************/ @@ -44,20 +44,20 @@ Description Implements the EPS Mobility Management procedures executed /**************************************************************************** ** ** - ** Name: EmmRegisteredLimitedService() ** + ** Name: EmmRegisteredLimitedService() ** ** ** ** Description: Handles the behaviour of the UE while the EMM-SAP is in ** - ** EMM-REGISTERED.LIMITED-SERVICE state. ** + ** EMM-REGISTERED.LIMITED-SERVICE state. ** ** ** - ** Inputs: evt: The received EMM-SAP event ** - ** Others: emm_fsm_status ** + ** Inputs: evt: The received EMM-SAP event ** + ** Others: emm_fsm_status ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: emm_fsm_status ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: emm_fsm_status ** ** ** ***************************************************************************/ -int EmmRegisteredLimitedService(const emm_reg_t* evt) +int EmmRegisteredLimitedService(const emm_reg_t *evt) { LOG_FUNC_IN; diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmRegisteredNoCellAvailable.c b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmRegisteredNoCellAvailable.c index d82380ff81..a4df2eb4e5 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmRegisteredNoCellAvailable.c +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmRegisteredNoCellAvailable.c @@ -1,25 +1,25 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source EmmRegisteredNoCellAvailable.c +Source EmmRegisteredNoCellAvailable.c -Version 0.1 +Version 0.1 -Date 2012/10/03 +Date 2012/10/03 -Product NAS stack +Product NAS stack -Subsystem EPS Mobility Management +Subsystem EPS Mobility Management -Author Frederic Maurel +Author Frederic Maurel -Description Implements the EPS Mobility Management procedures executed - when the EMM-SAP is in EMM-REGISTERED.NO-CELL-AVAILABLE state. +Description Implements the EPS Mobility Management procedures executed + when the EMM-SAP is in EMM-REGISTERED.NO-CELL-AVAILABLE state. - In EMM-REGISTERED.NO-CELL-AVAILABLE state, E-UTRAN coverage - has been lost. The UE shall not initiate any EMM procedures - except for cell and PLMN reselection. + In EMM-REGISTERED.NO-CELL-AVAILABLE state, E-UTRAN coverage + has been lost. The UE shall not initiate any EMM procedures + except for cell and PLMN reselection. *****************************************************************************/ @@ -45,20 +45,20 @@ Description Implements the EPS Mobility Management procedures executed /**************************************************************************** ** ** - ** Name: EmmRegisteredNoCellAvailable() ** + ** Name: EmmRegisteredNoCellAvailable() ** ** ** ** Description: Handles the behaviour of the UE while the EMM-SAP is in ** - ** EMM-REGISTERED.NO-CELL-AVAILABLE state. ** + ** EMM-REGISTERED.NO-CELL-AVAILABLE state. ** ** ** - ** Inputs: evt: The received EMM-SAP event ** - ** Others: emm_fsm_status ** + ** Inputs: evt: The received EMM-SAP event ** + ** Others: emm_fsm_status ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: emm_fsm_status ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: emm_fsm_status ** ** ** ***************************************************************************/ -int EmmRegisteredNoCellAvailable(const emm_reg_t* evt) +int EmmRegisteredNoCellAvailable(const emm_reg_t *evt) { LOG_FUNC_IN; diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmRegisteredNormalService.c b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmRegisteredNormalService.c index 567048b8d5..78dc4a2fe5 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmRegisteredNormalService.c +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmRegisteredNormalService.c @@ -1,24 +1,24 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source EmmRegisteredNormalService.c +Source EmmRegisteredNormalService.c -Version 0.1 +Version 0.1 -Date 2012/10/03 +Date 2012/10/03 -Product NAS stack +Product NAS stack -Subsystem EPS Mobility Management +Subsystem EPS Mobility Management -Author Frederic Maurel +Author Frederic Maurel -Description Implements the EPS Mobility Management procedures executed - when the EMM-SAP is in EMM-REGISTERED.NORMAL-SERVICE state. +Description Implements the EPS Mobility Management procedures executed + when the EMM-SAP is in EMM-REGISTERED.NORMAL-SERVICE state. - The EMM-REGISTERED.NORMAL-SERVICE state is the primary - substate choosen when the UE enters the state EMM-REGISTERED. + The EMM-REGISTERED.NORMAL-SERVICE state is the primary + substate choosen when the UE enters the state EMM-REGISTERED. *****************************************************************************/ @@ -44,20 +44,20 @@ Description Implements the EPS Mobility Management procedures executed /**************************************************************************** ** ** - ** Name: EmmRegisteredNormalService() ** + ** Name: EmmRegisteredNormalService() ** ** ** ** Description: Handles the behaviour of the UE while the EMM-SAP is in ** - ** EMM-REGISTERED.NORMAL-SERVICE state. ** + ** EMM-REGISTERED.NORMAL-SERVICE state. ** ** ** - ** Inputs: evt: The received EMM-SAP event ** - ** Others: emm_fsm_status ** + ** Inputs: evt: The received EMM-SAP event ** + ** Others: emm_fsm_status ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: emm_fsm_status ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: emm_fsm_status ** ** ** ***************************************************************************/ -int EmmRegisteredNormalService(const emm_reg_t* evt) +int EmmRegisteredNormalService(const emm_reg_t *evt) { LOG_FUNC_IN; diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmRegisteredPlmnSearch.c b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmRegisteredPlmnSearch.c index afa79e6017..bb5d53dd27 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmRegisteredPlmnSearch.c +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmRegisteredPlmnSearch.c @@ -1,24 +1,24 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source EmmRegisteredPlmnSearch.c +Source EmmRegisteredPlmnSearch.c -Version 0.1 +Version 0.1 -Date 2012/10/03 +Date 2012/10/03 -Product NAS stack +Product NAS stack -Subsystem EPS Mobility Management +Subsystem EPS Mobility Management -Author Frederic Maurel +Author Frederic Maurel -Description Implements the EPS Mobility Management procedures executed - when the EMM-SAP is in EMM-REGISTERED.PLMN-SEARCH state. +Description Implements the EPS Mobility Management procedures executed + when the EMM-SAP is in EMM-REGISTERED.PLMN-SEARCH state. - In EMM-REGISTERED.PLMN-SEARCH state, the UE is searching - for PLMNs. + In EMM-REGISTERED.PLMN-SEARCH state, the UE is searching + for PLMNs. *****************************************************************************/ @@ -44,20 +44,20 @@ Description Implements the EPS Mobility Management procedures executed /**************************************************************************** ** ** - ** Name: EmmRegisteredPlmnSearch() ** + ** Name: EmmRegisteredPlmnSearch() ** ** ** ** Description: Handles the behaviour of the UE while the EMM-SAP is in ** - ** EMM-REGISTERED.PLMN-SEARCH state. ** + ** EMM-REGISTERED.PLMN-SEARCH state. ** ** ** - ** Inputs: evt: The received EMM-SAP event ** - ** Others: emm_fsm_status ** + ** Inputs: evt: The received EMM-SAP event ** + ** Others: emm_fsm_status ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: emm_fsm_status ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: emm_fsm_status ** ** ** ***************************************************************************/ -int EmmRegisteredPlmnSearch(const emm_reg_t* evt) +int EmmRegisteredPlmnSearch(const emm_reg_t *evt) { LOG_FUNC_IN; @@ -71,20 +71,20 @@ int EmmRegisteredPlmnSearch(const emm_reg_t* evt) #if 0 /**************************************************************************** ** ** - ** Name: EmmRegisteredPlmnSearch_xxx() ** + ** Name: EmmRegisteredPlmnSearch_xxx() ** ** ** ** Description: Procedure executed when xxx ** - ** while the EMM-SAP is in EMM-REGISTERED.PLMN-SEARCH state. ** + ** while the EMM-SAP is in EMM-REGISTERED.PLMN-SEARCH state. ** ** ** - ** Inputs: evt: The received EMM-SAP event ** - ** Others: emm_fsm_status ** + ** Inputs: evt: The received EMM-SAP event ** + ** Others: emm_fsm_status ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: emm_fsm_status ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: emm_fsm_status ** ** ** ***************************************************************************/ -int EmmRegisteredPlmnSearch_xxx(const emm_reg_t* evt) +int EmmRegisteredPlmnSearch_xxx(const emm_reg_t *evt) { LOG_FUNC_IN; diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmRegisteredUpdateNeeded.c b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmRegisteredUpdateNeeded.c index 3d8fcce569..e35a2d2abb 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmRegisteredUpdateNeeded.c +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmRegisteredUpdateNeeded.c @@ -1,30 +1,30 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source EmmRegisteredUpdateNeeded.c +Source EmmRegisteredUpdateNeeded.c -Version 0.1 +Version 0.1 -Date 2012/10/03 +Date 2012/10/03 -Product NAS stack +Product NAS stack -Subsystem EPS Mobility Management +Subsystem EPS Mobility Management -Author Frederic Maurel +Author Frederic Maurel -Description Implements the EPS Mobility Management procedures executed - when the EMM-SAP is in EMM-REGISTERED.UPDATE-NEEDED state. +Description Implements the EPS Mobility Management procedures executed + when the EMM-SAP is in EMM-REGISTERED.UPDATE-NEEDED state. - In EMM-REGISTERED.UPDATE-NEEDED state, the UE has to perform - a tracking area updating or combined tracking area updating - procedure, but access to the current cell is barred. The access - class may be blocked due to access class control, or the - network rejected the NAS signalling connection establishment. - No EMM procedure except tracking area updating or combined - tracking area updating or service request as a response to - paging shall be initiated by the UE in this substate. + In EMM-REGISTERED.UPDATE-NEEDED state, the UE has to perform + a tracking area updating or combined tracking area updating + procedure, but access to the current cell is barred. The access + class may be blocked due to access class control, or the + network rejected the NAS signalling connection establishment. + No EMM procedure except tracking area updating or combined + tracking area updating or service request as a response to + paging shall be initiated by the UE in this substate. *****************************************************************************/ @@ -50,20 +50,20 @@ Description Implements the EPS Mobility Management procedures executed /**************************************************************************** ** ** - ** Name: EmmRegisteredUpdateNeeded() ** + ** Name: EmmRegisteredUpdateNeeded() ** ** ** ** Description: Handles the behaviour of the UE while the EMM-SAP is in ** - ** EMM-REGISTERED.UPDATE-NEEDED state. ** + ** EMM-REGISTERED.UPDATE-NEEDED state. ** ** ** - ** Inputs: evt: The received EMM-SAP event ** - ** Others: emm_fsm_status ** + ** Inputs: evt: The received EMM-SAP event ** + ** Others: emm_fsm_status ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: emm_fsm_status ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: emm_fsm_status ** ** ** ***************************************************************************/ -int EmmRegisteredUpdateNeeded(const emm_reg_t* evt) +int EmmRegisteredUpdateNeeded(const emm_reg_t *evt) { LOG_FUNC_IN; diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmServiceRequestInitiated.c b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmServiceRequestInitiated.c index da55c61a05..76cb7e1b4b 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmServiceRequestInitiated.c +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmServiceRequestInitiated.c @@ -1,26 +1,26 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source EmmServiceRequestInitiated.c +Source EmmServiceRequestInitiated.c -Version 0.1 +Version 0.1 -Date 2012/10/03 +Date 2012/10/03 -Product NAS stack +Product NAS stack -Subsystem EPS Mobility Management +Subsystem EPS Mobility Management -Author Frederic Maurel +Author Frederic Maurel -Description Implements the EPS Mobility Management procedures executed - when the EMM-SAP is in EMM-SERVICE-REQUEST-INITIATED - state. +Description Implements the EPS Mobility Management procedures executed + when the EMM-SAP is in EMM-SERVICE-REQUEST-INITIATED + state. - In EMM-SERVICE-REQUEST-INITIATED state, the UE has started - the service request procedure and is waiting for a response - from the MME. + In EMM-SERVICE-REQUEST-INITIATED state, the UE has started + the service request procedure and is waiting for a response + from the MME. *****************************************************************************/ @@ -46,20 +46,20 @@ Description Implements the EPS Mobility Management procedures executed /**************************************************************************** ** ** - ** Name: EmmServiceRequestInitiated() ** + ** Name: EmmServiceRequestInitiated() ** ** ** ** Description: Handles the behaviour of the UE while the EMM-SAP is in ** - ** EMM-SERVICE-REQUEST-INITIATED state. ** + ** EMM-SERVICE-REQUEST-INITIATED state. ** ** ** - ** Inputs: evt: The received EMM-SAP event ** - ** Others: emm_fsm_status ** + ** Inputs: evt: The received EMM-SAP event ** + ** Others: emm_fsm_status ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: emm_fsm_status ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: emm_fsm_status ** ** ** ***************************************************************************/ -int EmmServiceRequestInitiated(const emm_reg_t* evt) +int EmmServiceRequestInitiated(const emm_reg_t *evt) { LOG_FUNC_IN; diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmTrackingAreaUpdatingInitiated.c b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmTrackingAreaUpdatingInitiated.c index 2ecdc88249..dc6aaedeaa 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmTrackingAreaUpdatingInitiated.c +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/EmmTrackingAreaUpdatingInitiated.c @@ -1,26 +1,26 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source EmmTrackingAreaUpdatingInitiated.c +Source EmmTrackingAreaUpdatingInitiated.c -Version 0.1 +Version 0.1 -Date 2012/10/03 +Date 2012/10/03 -Product NAS stack +Product NAS stack -Subsystem EPS Mobility Management +Subsystem EPS Mobility Management -Author Frederic Maurel +Author Frederic Maurel -Description Implements the EPS Mobility Management procedures executed - when the EMM-SAP is in EMM-TRACKING-AREA-UPDATING-INITIATED - state. +Description Implements the EPS Mobility Management procedures executed + when the EMM-SAP is in EMM-TRACKING-AREA-UPDATING-INITIATED + state. - In EMM-TRACKING-AREA-UPDATING-INITIATED state, the UE has - started the tracking area updating or combined tracking area - updating procedure and is waiting for a response from the MME. + In EMM-TRACKING-AREA-UPDATING-INITIATED state, the UE has + started the tracking area updating or combined tracking area + updating procedure and is waiting for a response from the MME. *****************************************************************************/ @@ -46,20 +46,20 @@ Description Implements the EPS Mobility Management procedures executed /**************************************************************************** ** ** - ** Name: EmmTrackingAreaUpdatingInitiated() ** + ** Name: EmmTrackingAreaUpdatingInitiated() ** ** ** ** Description: Handles the behaviour of the UE while the EMM-SAP is in ** - ** EMM-TRACKING-AREA-UPDATING-INITIATED state. ** + ** EMM-TRACKING-AREA-UPDATING-INITIATED state. ** ** ** - ** Inputs: evt: The received EMM-SAP event ** - ** Others: emm_fsm_status ** + ** Inputs: evt: The received EMM-SAP event ** + ** Others: emm_fsm_status ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: emm_fsm_status ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: emm_fsm_status ** ** ** ***************************************************************************/ -int EmmTrackingAreaUpdatingInitiated(const emm_reg_t* evt) +int EmmTrackingAreaUpdatingInitiated(const emm_reg_t *evt) { LOG_FUNC_IN; diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_as.c b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_as.c index f23b835491..94767e5916 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_as.c +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_as.c @@ -1,22 +1,22 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source emm_as.c +Source emm_as.c -Version 0.1 +Version 0.1 -Date 2012/10/16 +Date 2012/10/16 -Product NAS stack +Product NAS stack -Subsystem EPS Mobility Management +Subsystem EPS Mobility Management -Author Frederic Maurel +Author Frederic Maurel -Description Defines the EMMAS Service Access Point that provides - services to the EPS Mobility Management for NAS message - transfer to/from the Access Stratum sublayer. +Description Defines the EMMAS Service Access Point that provides + services to the EPS Mobility Management for NAS message + transfer to/from the Access Stratum sublayer. *****************************************************************************/ @@ -33,11 +33,11 @@ Description Defines the EMMAS Service Access Point that provides #include "emm_cause.h" #include "LowerLayer.h" -#include <string.h> // memset -#include <stdlib.h> // malloc, free +#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 ******************/ @@ -132,16 +141,16 @@ static int _emm_as_release_req(const emm_as_release_t*, nas_release_req_t*); /**************************************************************************** ** ** - ** Name: emm_as_initialize() ** + ** Name: emm_as_initialize() ** ** ** ** Description: Initializes the EMMAS Service Access Point ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: None ** - ** Others: NONE ** + ** Outputs: None ** + ** Return: None ** + ** Others: NONE ** ** ** ***************************************************************************/ void emm_as_initialize(void) @@ -155,19 +164,19 @@ void emm_as_initialize(void) /**************************************************************************** ** ** - ** Name: emm_as_send() ** + ** Name: emm_as_send() ** ** ** ** Description: Processes the EMMAS Service Access Point primitive. ** ** ** - ** Inputs: msg: The EMMAS-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The EMMAS-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ -int emm_as_send(const emm_as_t* msg) +int emm_as_send(const emm_as_t *msg) { LOG_FUNC_IN; @@ -178,85 +187,83 @@ int emm_as_send(const emm_as_t* msg) UInt32_t ueid = 0; LOG_TRACE(INFO, "EMMAS-SAP - Received primitive %s (%d)", - _emm_as_primitive_str[primitive - _EMMAS_START - 1], primitive); + _emm_as_primitive_str[primitive - _EMMAS_START - 1], primitive); - switch (primitive) - { - case _EMMAS_DATA_IND: - rc = _emm_as_data_ind(&msg->u.data, &emm_cause); - ueid = msg->u.data.ueid; - break; + switch (primitive) { + case _EMMAS_DATA_IND: + rc = _emm_as_data_ind(&msg->u.data, &emm_cause); + ueid = msg->u.data.ueid; + break; #ifdef NAS_UE - case _EMMAS_ESTABLISH_CNF: - rc = _emm_as_establish_cnf(&msg->u.establish, &emm_cause); - break; + case _EMMAS_ESTABLISH_CNF: + rc = _emm_as_establish_cnf(&msg->u.establish, &emm_cause); + break; - case _EMMAS_ESTABLISH_REJ: - rc = _emm_as_establish_rej(); - break; + case _EMMAS_ESTABLISH_REJ: + rc = _emm_as_establish_rej(); + break; - case _EMMAS_RELEASE_IND: - rc = _emm_as_release_ind(&msg->u.release); - break; + case _EMMAS_RELEASE_IND: + rc = _emm_as_release_ind(&msg->u.release); + break; - case _EMMAS_PAGE_IND: - rc = _emm_as_page_ind(&msg->u.page); - break; + case _EMMAS_PAGE_IND: + rc = _emm_as_page_ind(&msg->u.page); + break; #endif #ifdef NAS_MME - case _EMMAS_ESTABLISH_REQ: - rc = _emm_as_establish_req(&msg->u.establish, &emm_cause); - ueid = msg->u.establish.ueid; - break; + case _EMMAS_ESTABLISH_REQ: + rc = _emm_as_establish_req(&msg->u.establish, &emm_cause); + ueid = msg->u.establish.ueid; + break; #endif - case _EMMAS_CELL_INFO_RES: - rc = _emm_as_cell_info_res(&msg->u.cell_info); - break; - - case _EMMAS_CELL_INFO_IND: - rc = _emm_as_cell_info_ind(&msg->u.cell_info); - break; - - default: - /* Other primitives are forwarded to the Access Stratum */ - rc = _emm_as_send(msg); - if (rc != RETURNok) { - LOG_TRACE(ERROR, "EMMAS-SAP - " - "Failed to process primitive %s (%d)", - _emm_as_primitive_str[primitive - _EMMAS_START - 1], - primitive); - LOG_FUNC_RETURN (RETURNerror); - } - break; + case _EMMAS_CELL_INFO_RES: + rc = _emm_as_cell_info_res(&msg->u.cell_info); + break; + + case _EMMAS_CELL_INFO_IND: + rc = _emm_as_cell_info_ind(&msg->u.cell_info); + break; + + default: + /* Other primitives are forwarded to the Access Stratum */ + rc = _emm_as_send(msg); + if (rc != RETURNok) { + LOG_TRACE(ERROR, "EMMAS-SAP - " + "Failed to process primitive %s (%d)", + _emm_as_primitive_str[primitive - _EMMAS_START - 1], + primitive); + LOG_FUNC_RETURN (RETURNerror); + } + break; } /* Handle decoding errors */ if (emm_cause != EMM_CAUSE_SUCCESS) { - /* Ignore received message that is too short to contain a complete - * message type information element */ - if (rc == TLV_DECODE_BUFFER_TOO_SHORT) { - LOG_FUNC_RETURN (RETURNok); - } - /* Ignore received message that contains not supported protocol - * discriminator */ - else if (rc == TLV_DECODE_PROTOCOL_NOT_SUPPORTED) { - LOG_FUNC_RETURN (RETURNok); - } - else if (rc == TLV_DECODE_WRONG_MESSAGE_TYPE) { - emm_cause = EMM_CAUSE_MESSAGE_TYPE_NOT_IMPLEMENTED; - } - /* EMM message processing failed */ - LOG_TRACE(WARNING, "EMMAS-SAP - Received EMM message is not valid " - "(cause=%d)", emm_cause); - /* Return an EMM status message */ - rc = emm_proc_status(ueid, emm_cause); + /* Ignore received message that is too short to contain a complete + * message type information element */ + if (rc == TLV_DECODE_BUFFER_TOO_SHORT) { + LOG_FUNC_RETURN (RETURNok); + } + /* Ignore received message that contains not supported protocol + * discriminator */ + else if (rc == TLV_DECODE_PROTOCOL_NOT_SUPPORTED) { + LOG_FUNC_RETURN (RETURNok); + } else if (rc == TLV_DECODE_WRONG_MESSAGE_TYPE) { + emm_cause = EMM_CAUSE_MESSAGE_TYPE_NOT_IMPLEMENTED; + } + /* EMM message processing failed */ + LOG_TRACE(WARNING, "EMMAS-SAP - Received EMM message is not valid " + "(cause=%d)", emm_cause); + /* Return an EMM status message */ + rc = emm_proc_status(ueid, emm_cause); } if (rc != RETURNok) { - LOG_TRACE(ERROR, "EMMAS-SAP - Failed to process primitive %s (%d)", - _emm_as_primitive_str[primitive - _EMMAS_START - 1], - primitive); + LOG_TRACE(ERROR, "EMMAS-SAP - Failed to process primitive %s (%d)", + _emm_as_primitive_str[primitive - _EMMAS_START - 1], + primitive); } LOG_FUNC_RETURN (rc); @@ -275,23 +282,23 @@ int emm_as_send(const emm_as_t* msg) /**************************************************************************** ** ** - ** Name: _emm_as_recv() ** + ** Name: _emm_as_recv() ** ** ** ** Description: Decodes and processes the EPS Mobility Management message ** - ** received from the Access Stratum ** + ** received from the Access Stratum ** ** ** - ** Inputs: ueid: UE lower layer identifier ** - ** msg: The EMM message to process ** - ** len: The length of the EMM message ** - ** Others: None ** + ** Inputs: ueid: UE lower layer identifier ** + ** msg: The EMM message to process ** + ** len: The length of the EMM message ** + ** Others: None ** ** ** - ** Outputs: emm_cause: EMM cause code ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: emm_cause: EMM cause code ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ -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) { LOG_FUNC_IN; @@ -307,113 +314,112 @@ static int _emm_as_recv(unsigned int ueid, const char* msg, int len, decoder_rc = nas_message_decode(msg, &nas_msg, len); if (decoder_rc < 0) { - LOG_TRACE(WARNING, "EMMAS-SAP - Failed to decode NAS message " - "(err=%d)", decoder_rc); - *emm_cause = EMM_CAUSE_PROTOCOL_ERROR; - LOG_FUNC_RETURN (decoder_rc); + LOG_TRACE(WARNING, "EMMAS-SAP - Failed to decode NAS message " + "(err=%d)", decoder_rc); + *emm_cause = EMM_CAUSE_PROTOCOL_ERROR; + LOG_FUNC_RETURN (decoder_rc); } /* Process NAS message */ - 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; + 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; #ifdef NAS_UE - case IDENTITY_REQUEST: - rc = emm_recv_identity_request(&emm_msg->identity_request, - emm_cause); - break; - - case AUTHENTICATION_REQUEST: - rc = emm_recv_authentication_request( - &emm_msg->authentication_request, - emm_cause); - break; - - case AUTHENTICATION_REJECT: - rc = emm_recv_authentication_reject( - &emm_msg->authentication_reject, - emm_cause); - break; - - case SECURITY_MODE_COMMAND: - rc = emm_recv_security_mode_command( - &emm_msg->security_mode_command, - emm_cause); - break; - - case DETACH_ACCEPT: - rc = emm_recv_detach_accept(&emm_msg->detach_accept, emm_cause); - break; + case IDENTITY_REQUEST: + rc = emm_recv_identity_request(&emm_msg->identity_request, + emm_cause); + break; + + case AUTHENTICATION_REQUEST: + rc = emm_recv_authentication_request( + &emm_msg->authentication_request, + emm_cause); + break; + + case AUTHENTICATION_REJECT: + rc = emm_recv_authentication_reject( + &emm_msg->authentication_reject, + emm_cause); + break; + + case SECURITY_MODE_COMMAND: + rc = emm_recv_security_mode_command( + &emm_msg->security_mode_command, + emm_cause); + break; + + case DETACH_ACCEPT: + rc = emm_recv_detach_accept(&emm_msg->detach_accept, emm_cause); + break; #endif #ifdef NAS_UE - case TRACKING_AREA_UPDATE_ACCEPT: - case TRACKING_AREA_UPDATE_REJECT: - case SERVICE_REJECT: - case GUTI_REALLOCATION_COMMAND: - case EMM_INFORMATION: - case DOWNLINK_NAS_TRANSPORT: - case CS_SERVICE_NOTIFICATION: - /* TODO */ - break; + case TRACKING_AREA_UPDATE_ACCEPT: + case TRACKING_AREA_UPDATE_REJECT: + case SERVICE_REJECT: + case GUTI_REALLOCATION_COMMAND: + case EMM_INFORMATION: + case DOWNLINK_NAS_TRANSPORT: + case CS_SERVICE_NOTIFICATION: + /* TODO */ + break; #endif #ifdef NAS_MME - case IDENTITY_RESPONSE: - rc = emm_recv_identity_response(ueid, - &emm_msg->identity_response, - emm_cause); - break; - - case AUTHENTICATION_RESPONSE: - rc = emm_recv_authentication_response(ueid, - &emm_msg->authentication_response, - emm_cause); - break; - - case AUTHENTICATION_FAILURE: - rc = emm_recv_authentication_failure(ueid, - &emm_msg->authentication_failure, - emm_cause); - break; - - case SECURITY_MODE_COMPLETE: - rc = emm_recv_security_mode_complete(ueid, - &emm_msg->security_mode_complete, - emm_cause); - break; - - case SECURITY_MODE_REJECT: - rc = emm_recv_security_mode_reject(ueid, - &emm_msg->security_mode_reject, - emm_cause); - break; - - case ATTACH_COMPLETE: - rc = emm_recv_attach_complete(ueid, &emm_msg->attach_complete, - emm_cause); - break; - - case TRACKING_AREA_UPDATE_COMPLETE: - case GUTI_REALLOCATION_COMPLETE: - case UPLINK_NAS_TRANSPORT: - /* TODO */ - break; - - case DETACH_REQUEST: - rc = emm_recv_detach_request(ueid, &emm_msg->detach_request, - emm_cause); - break; + case IDENTITY_RESPONSE: + rc = emm_recv_identity_response(ueid, + &emm_msg->identity_response, + emm_cause); + break; + + case AUTHENTICATION_RESPONSE: + rc = emm_recv_authentication_response(ueid, + &emm_msg->authentication_response, + emm_cause); + break; + + case AUTHENTICATION_FAILURE: + rc = emm_recv_authentication_failure(ueid, + &emm_msg->authentication_failure, + emm_cause); + break; + + case SECURITY_MODE_COMPLETE: + rc = emm_recv_security_mode_complete(ueid, + &emm_msg->security_mode_complete, + emm_cause); + break; + + case SECURITY_MODE_REJECT: + rc = emm_recv_security_mode_reject(ueid, + &emm_msg->security_mode_reject, + emm_cause); + break; + + case ATTACH_COMPLETE: + rc = emm_recv_attach_complete(ueid, &emm_msg->attach_complete, + emm_cause); + break; + + case TRACKING_AREA_UPDATE_COMPLETE: + case GUTI_REALLOCATION_COMPLETE: + case UPLINK_NAS_TRANSPORT: + /* TODO */ + break; + + case DETACH_REQUEST: + rc = emm_recv_detach_request(ueid, &emm_msg->detach_request, + emm_cause); + break; #endif - default: - LOG_TRACE(WARNING, "EMMAS-SAP - EMM message 0x%x is not valid", - emm_msg->header.message_type); - *emm_cause = EMM_CAUSE_MESSAGE_TYPE_NOT_COMPATIBLE; - break; + default: + LOG_TRACE(WARNING, "EMMAS-SAP - EMM message 0x%x is not valid", + emm_msg->header.message_type); + *emm_cause = EMM_CAUSE_MESSAGE_TYPE_NOT_COMPATIBLE; + break; } LOG_FUNC_RETURN (rc); @@ -421,70 +427,64 @@ static int _emm_as_recv(unsigned int ueid, const char* msg, int len, /**************************************************************************** ** ** - ** Name: _emm_as_data_ind() ** + ** Name: _emm_as_data_ind() ** ** ** ** Description: Processes the EMMAS-SAP data transfer indication ** - ** primitive ** + ** primitive ** ** ** ** EMMAS-SAP - AS->EMM: DATA_IND - Data transfer procedure ** ** ** - ** Inputs: msg: The EMMAS-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The EMMAS-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: emm_cause: EMM cause code ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: emm_cause: EMM cause code ** + ** Return: RETURNok, RETURNerror ** + ** 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; int rc = RETURNerror; LOG_TRACE(INFO, "EMMAS-SAP - Received AS data transfer indication " - "(ueid=%d, delivered=%s, length=%d)", msg->ueid, - (msg->delivered)? "TRUE" : "FALSE", msg->NASmsg.length); + "(ueid=%d, delivered=%s, length=%d)", msg->ueid, + (msg->delivered)? "TRUE" : "FALSE", msg->NASmsg.length); if (msg->delivered) { - if (msg->NASmsg.length > 0) - { - /* Process the received NAS message */ - 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), - 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 == - EPS_MOBILITY_MANAGEMENT_MESSAGE) { - /* Process EMM data */ - rc = _emm_as_recv(msg->ueid, plain_msg, bytes, emm_cause); - } - else if (header.protocol_discriminator == - EPS_SESSION_MANAGEMENT_MESSAGE) { - 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 { - /* Process successfull lower layer transfer indication */ - rc = lowerlayer_success(msg->ueid); - } - } - else { - /* Process lower layer transmission failure of NAS message */ - rc = lowerlayer_failure(msg->ueid); + if (msg->NASmsg.length > 0) { + /* Process the received NAS message */ + 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), + 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 == + EPS_MOBILITY_MANAGEMENT_MESSAGE) { + /* Process EMM data */ + rc = _emm_as_recv(msg->ueid, plain_msg, bytes, emm_cause); + } else if (header.protocol_discriminator == + EPS_SESSION_MANAGEMENT_MESSAGE) { + 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 { + /* Process successfull lower layer transfer indication */ + rc = lowerlayer_success(msg->ueid); + } + } else { + /* Process lower layer transmission failure of NAS message */ + rc = lowerlayer_failure(msg->ueid); } LOG_FUNC_RETURN (rc); @@ -493,23 +493,23 @@ static int _emm_as_data_ind(const emm_as_data_t* msg, int *emm_cause) #ifdef NAS_UE /**************************************************************************** ** ** - ** Name: _emm_as_establish_cnf() ** + ** Name: _emm_as_establish_cnf() ** ** ** ** Description: Processes the EMMAS-SAP connection establish confirmation ** - ** primitive ** + ** primitive ** ** ** ** EMMAS-SAP - AS->EMM: ESTABLISH_CNF - NAS signalling connection ** ** ** - ** Inputs: msg: The EMMAS-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The EMMAS-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: emm_cause: EMM cause code ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: emm_cause: EMM cause code ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ -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) { LOG_FUNC_IN; @@ -519,51 +519,50 @@ static int _emm_as_establish_cnf(const emm_as_establish_t* msg, LOG_TRACE(INFO, "EMMAS-SAP - Received AS connection establish confirm"); if (msg->NASmsg.length > 0) { - /* The NAS signalling connection is established */ - (void) lowerlayer_establish(); + /* The NAS signalling connection is established */ + (void) lowerlayer_establish(); } else { - /* The initial NAS message has been successfully delivered to - * lower layers */ - rc = lowerlayer_success(0); - LOG_FUNC_RETURN (rc); - } + /* The initial NAS message has been successfully delivered to + * lower layers */ + rc = lowerlayer_success(0); + LOG_FUNC_RETURN (rc); + } nas_message_t nas_msg; memset(&nas_msg, 0 , sizeof(nas_message_t)); /* Decode initial NAS message */ - decoder_rc = nas_message_decode((char*)(msg->NASmsg.value), &nas_msg, - msg->NASmsg.length); + 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" - "(err=%d)", decoder_rc); - *emm_cause = EMM_CAUSE_PROTOCOL_ERROR; - LOG_FUNC_RETURN (decoder_rc); + LOG_TRACE(WARNING, "EMMAS-SAP - Failed to decode initial NAS message" + "(err=%d)", decoder_rc); + *emm_cause = EMM_CAUSE_PROTOCOL_ERROR; + LOG_FUNC_RETURN (decoder_rc); } /* Process initial NAS message */ - 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; - - case ATTACH_REJECT: - rc = emm_recv_attach_reject(&emm_msg->attach_reject, emm_cause); - break; - - case DETACH_ACCEPT: - break; - - case TRACKING_AREA_UPDATE_ACCEPT: - break; - - default: - LOG_TRACE(WARNING, "EMMAS-SAP - Initial NAS message 0x%x is " - "not valid", emm_msg->header.message_type); - *emm_cause = EMM_CAUSE_MESSAGE_TYPE_NOT_COMPATIBLE; - break; + 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; + + case ATTACH_REJECT: + rc = emm_recv_attach_reject(&emm_msg->attach_reject, emm_cause); + break; + + case DETACH_ACCEPT: + break; + + case TRACKING_AREA_UPDATE_ACCEPT: + break; + + default: + LOG_TRACE(WARNING, "EMMAS-SAP - Initial NAS message 0x%x is " + "not valid", emm_msg->header.message_type); + *emm_cause = EMM_CAUSE_MESSAGE_TYPE_NOT_COMPATIBLE; + break; } LOG_FUNC_RETURN (rc); @@ -571,19 +570,19 @@ static int _emm_as_establish_cnf(const emm_as_establish_t* msg, /**************************************************************************** ** ** - ** Name: _emm_as_establish_rej() ** + ** Name: _emm_as_establish_rej() ** ** ** ** Description: Processes the EMMAS-SAP connection establish reject ** - ** primitive ** + ** primitive ** ** ** ** EMMAS-SAP - AS->EMM: ESTABLISH_REJ - NAS signalling connection ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ static int _emm_as_establish_rej(void) @@ -593,7 +592,7 @@ static int _emm_as_establish_rej(void) int rc; LOG_TRACE(INFO, "EMMAS-SAP - Received AS initial NAS message transmission " - "failure"); + "failure"); /* Process lower layer transmission failure of initial NAS message */ rc = lowerlayer_failure(0); @@ -603,29 +602,29 @@ static int _emm_as_establish_rej(void) /**************************************************************************** ** ** - ** Name: _emm_as_release_ind() ** + ** Name: _emm_as_release_ind() ** ** ** ** Description: Processes the EMMAS-SAP connection release indication ** - ** primitive ** + ** primitive ** ** ** ** EMMAS-SAP - AS->EMM: RELEASE_IND - NAS signalling release procedure ** ** ** - ** Inputs: msg: The EMMAS-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The EMMAS-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** 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; int rc = RETURNok; LOG_TRACE(INFO, "EMMAS-SAP - Received AS connection release indication " - "(cause=%d)", msg->cause); + "(cause=%d)", msg->cause); /* Process NAS signalling connection release indication */ rc = lowerlayer_release(msg->cause); @@ -635,21 +634,21 @@ static int _emm_as_release_ind(const emm_as_release_t* msg) /**************************************************************************** ** ** - ** Name: _emm_as_page_ind() ** + ** Name: _emm_as_page_ind() ** ** ** ** Description: Processes the EMMAS-SAP paging data indication primitive ** ** ** ** EMMAS-SAP - AS->EMM: PAGE_IND - Paging data procedure ** ** ** - ** Inputs: msg: The EMMAS-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The EMMAS-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** 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; @@ -667,25 +666,25 @@ static int _emm_as_page_ind(const emm_as_page_t* msg) #ifdef NAS_MME /**************************************************************************** ** ** - ** Name: _emm_as_establish_req() ** + ** Name: _emm_as_establish_req() ** ** ** ** Description: Processes the EMMAS-SAP connection establish request ** - ** primitive ** + ** primitive ** ** ** ** EMMAS-SAP - AS->EMM: ESTABLISH_REQ - NAS signalling connection ** - ** The AS notifies the NAS that establishment of the signal- ** - ** ling connection has been requested to tranfer initial NAS ** - ** message from the UE. ** + ** The AS notifies the NAS that establishment of the signal- ** + ** ling connection has been requested to tranfer initial NAS ** + ** message from the UE. ** ** ** - ** Inputs: msg: The EMMAS-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The EMMAS-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: emm_cause: EMM cause code ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: emm_cause: EMM cause code ** + ** Return: RETURNok, RETURNerror ** + ** 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,48 +697,47 @@ 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, - msg->NASmsg.length); + decoder_rc = nas_message_decode((char *)(msg->NASmsg.value), &nas_msg, + msg->NASmsg.length); if (decoder_rc < TLV_DECODE_FATAL_ERROR) { - *emm_cause = EMM_CAUSE_PROTOCOL_ERROR; - LOG_FUNC_RETURN (decoder_rc); + *emm_cause = EMM_CAUSE_PROTOCOL_ERROR; + LOG_FUNC_RETURN (decoder_rc); } else if (decoder_rc == TLV_DECODE_UNEXPECTED_IEI) { - *emm_cause = EMM_CAUSE_IE_NOT_IMPLEMENTED; + *emm_cause = EMM_CAUSE_IE_NOT_IMPLEMENTED; } else if (decoder_rc < 0) { - *emm_cause = EMM_CAUSE_PROTOCOL_ERROR; + *emm_cause = EMM_CAUSE_PROTOCOL_ERROR; } /* Process initial NAS message */ - 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); - break; - - case DETACH_REQUEST: - rc = RETURNok; /* TODO */ - break; - - case TRACKING_AREA_UPDATE_REQUEST: - rc = RETURNok; /* TODO */ - break; - - case SERVICE_REQUEST: - rc = RETURNok; /* TODO */ - break; - - case EXTENDED_SERVICE_REQUEST: - rc = RETURNok; /* TODO */ - break; - - default: - LOG_TRACE(WARNING, "EMMAS-SAP - Initial NAS message 0x%x is " - "not valid", emm_msg->header.message_type); - *emm_cause = EMM_CAUSE_MESSAGE_TYPE_NOT_COMPATIBLE; - break; + 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); + break; + + case DETACH_REQUEST: + rc = RETURNok; /* TODO */ + break; + + case TRACKING_AREA_UPDATE_REQUEST: + rc = RETURNok; /* TODO */ + break; + + case SERVICE_REQUEST: + rc = RETURNok; /* TODO */ + break; + + case EXTENDED_SERVICE_REQUEST: + rc = RETURNok; /* TODO */ + break; + + default: + LOG_TRACE(WARNING, "EMMAS-SAP - Initial NAS message 0x%x is " + "not valid", emm_msg->header.message_type); + *emm_cause = EMM_CAUSE_MESSAGE_TYPE_NOT_COMPATIBLE; + break; } LOG_FUNC_RETURN (rc); @@ -748,26 +746,26 @@ static int _emm_as_establish_req(const emm_as_establish_t* msg, int *emm_cause) /**************************************************************************** ** ** - ** Name: _emm_as_cell_info_res() ** + ** Name: _emm_as_cell_info_res() ** ** ** ** Description: Processes the EMMAS-SAP cell information response ** - ** primitive ** + ** primitive ** ** ** ** EMMAS-SAP - AS->EMM: CELL_INFO_RES - PLMN and cell selection procedure ** - ** The NAS received a response to cell selection request pre- ** - ** viously sent to the Access-Startum. If a suitable cell is ** - ** found to serve the selected PLMN with associated Radio Ac- ** - ** cess Technologies, this cell is selected to camp on. ** + ** The NAS received a response to cell selection request pre- ** + ** viously sent to the Access-Startum. If a suitable cell is ** + ** found to serve the selected PLMN with associated Radio Ac- ** + ** cess Technologies, this cell is selected to camp on. ** ** ** - ** Inputs: msg: The EMMAS-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The EMMAS-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** 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; @@ -778,13 +776,13 @@ static int _emm_as_cell_info_res(const emm_as_cell_info_t* msg) #ifdef NAS_UE int AcT = NET_ACCESS_EUTRAN; if (msg->found == TRUE) { - /* Get the first supported access technology */ - while (AcT != NET_ACCESS_UNAVAILABLE) { - if (msg->rat & (1 << AcT)) { - break; - } - AcT -= 1; - } + /* Get the first supported access technology */ + while (AcT != NET_ACCESS_UNAVAILABLE) { + if (msg->rat & (1 << AcT)) { + break; + } + AcT -= 1; + } } /* Notify EMM that a cell has been found */ rc = emm_proc_plmn_selection_end(msg->found, msg->tac, msg->cellID, AcT); @@ -795,22 +793,22 @@ static int _emm_as_cell_info_res(const emm_as_cell_info_t* msg) /**************************************************************************** ** ** - ** Name: _emm_as_cell_info_ind() ** + ** Name: _emm_as_cell_info_ind() ** ** ** ** Description: Processes the EMMAS-SAP cell information indication ** - ** primitive ** + ** primitive ** ** ** ** EMMAS-SAP - AS->EMM: CELL_INFO_IND - PLMN and cell selection procedure ** ** ** - ** Inputs: msg: The EMMAS-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The EMMAS-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** 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; @@ -832,62 +830,60 @@ static int _emm_as_cell_info_ind(const emm_as_cell_info_t* msg) /**************************************************************************** ** ** - ** Name: _emm_as_set_header() ** + ** Name: _emm_as_set_header() ** ** ** ** Description: Setup the security header of the given NAS message ** ** ** - ** Inputs: security: The NAS security data to use ** - ** Others: None ** + ** Inputs: security: The NAS security data to use ** + ** Others: None ** ** ** - ** Outputs: msg: The NAS message ** - ** Return: Pointer to the plain NAS message to be se- ** - ** curity protected if setting of the securi- ** - ** ty header succeed; ** - ** NULL pointer otherwise ** - ** Others: None ** + ** Outputs: msg: The NAS message ** + ** Return: Pointer to the plain NAS message to be se- ** + ** curity protected if setting of the securi- ** + ** ty header succeed; ** + ** NULL pointer otherwise ** + ** 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; msg->header.protocol_discriminator = EPS_MOBILITY_MANAGEMENT_MESSAGE; if ( security && (security->ksi != EMM_AS_NO_KEY_AVAILABLE) ) { - /* A valid EPS security context exists */ - if (security->is_new) { - /* New EPS security context is taken into use */ - if (security->k_int) { - if (security->k_enc) { - /* NAS integrity and cyphering keys are available */ - msg->header.security_header_type = - SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED_CYPHERED_NEW; - } else { - /* NAS integrity key only is available */ - msg->header.security_header_type = - SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED_NEW; - } - LOG_FUNC_RETURN (&msg->protected.plain.emm); - } - } - else if (security->k_int) { - if (security->k_enc) { - /* NAS integrity and cyphering keys are available */ - msg->header.security_header_type = - SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED_CYPHERED; - } else { - /* NAS integrity key only is available */ - msg->header.security_header_type = - SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED; - } - LOG_FUNC_RETURN (&msg->protected.plain.emm); - } - } - else { - /* No valid EPS security context exists */ - msg->header.security_header_type = SECURITY_HEADER_TYPE_NOT_PROTECTED; - LOG_FUNC_RETURN (&msg->plain.emm); + /* A valid EPS security context exists */ + if (security->is_new) { + /* New EPS security context is taken into use */ + if (security->k_int) { + if (security->k_enc) { + /* NAS integrity and cyphering keys are available */ + msg->header.security_header_type = + SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED_CYPHERED_NEW; + } else { + /* NAS integrity key only is available */ + msg->header.security_header_type = + SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED_NEW; + } + LOG_FUNC_RETURN (&msg->protected.plain.emm); + } + } else if (security->k_int) { + if (security->k_enc) { + /* NAS integrity and cyphering keys are available */ + msg->header.security_header_type = + SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED_CYPHERED; + } else { + /* NAS integrity key only is available */ + msg->header.security_header_type = + SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED; + } + LOG_FUNC_RETURN (&msg->protected.plain.emm); + } + } else { + /* No valid EPS security context exists */ + msg->header.security_header_type = SECURITY_HEADER_TYPE_NOT_PROTECTED; + LOG_FUNC_RETURN (&msg->plain.emm); } /* A valid EPS security context exists but NAS integrity key @@ -897,47 +893,46 @@ static EMM_msg* _emm_as_set_header(nas_message_t* msg, /**************************************************************************** ** ** - ** Name: _emm_as_encode() ** + ** Name: _emm_as_encode() ** ** ** ** Description: Encodes NAS message into NAS information container ** ** ** - ** Inputs: msg: The NAS message to encode ** - ** length: The maximum length of the NAS message ** - ** Others: None ** + ** Inputs: msg: The NAS message to encode ** + ** length: The maximum length of the NAS message ** + ** Others: None ** ** ** - ** Outputs: info: The NAS information container ** - ** msg: The NAS message to encode ** - ** Return: The number of bytes successfully encoded ** - ** Others: None ** + ** Outputs: info: The NAS information container ** + ** msg: The NAS message to encode ** + ** Return: The number of bytes successfully encoded ** + ** 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; - /* Expand size of protected NAS message */ - length += NAS_MESSAGE_SECURITY_HEADER_SIZE; - /* Set header of plain NAS message */ - header->protocol_discriminator = EPS_MOBILITY_MANAGEMENT_MESSAGE; - header->security_header_type = SECURITY_HEADER_TYPE_NOT_PROTECTED; + 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 */ + header->protocol_discriminator = EPS_MOBILITY_MANAGEMENT_MESSAGE; + 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); - if (bytes > 0) { - info->length = bytes; - } else { - free(info->data); - info->length = 0; - info->data = NULL; - } + /* Encode the NAS message */ + bytes = nas_message_encode((char *)(info->data), msg, length); + if (bytes > 0) { + info->length = bytes; + } else { + free(info->data); + info->length = 0; + info->data = NULL; + } } LOG_FUNC_RETURN (bytes); @@ -945,44 +940,44 @@ static int _emm_as_encode(as_nas_info_t* info, nas_message_t* msg, int length) /**************************************************************************** ** ** - ** Name: _emm_as_encrypt() ** + ** Name: _emm_as_encrypt() ** ** ** ** Description: Encryts NAS message into NAS information container ** ** ** - ** Inputs: header: The Security header in used ** - ** msg: The NAS message to encrypt ** - ** length: The maximum length of the NAS message ** - ** Others: None ** + ** Inputs: header: The Security header in used ** + ** msg: The NAS message to encrypt ** + ** length: The maximum length of the NAS message ** + ** Others: None ** ** ** - ** Outputs: info: The NAS information container ** - ** Return: The number of bytes successfully encrypted ** - ** Others: None ** + ** Outputs: info: The NAS information container ** + ** Return: The number of bytes successfully encrypted ** + ** 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; int bytes = 0; if (header->security_header_type != SECURITY_HEADER_TYPE_NOT_PROTECTED) { - /* Expand size of protected NAS message */ - length += NAS_MESSAGE_SECURITY_HEADER_SIZE; + /* Expand size of protected NAS message */ + 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); - if (bytes > 0) { - info->length = bytes; - } else { - free(info->data); - info->length = 0; - info->data = NULL; - } + /* Encrypt the NAS information message */ + bytes = nas_message_encrypt(msg, (char *)(info->data), header, length); + if (bytes > 0) { + info->length = bytes; + } else { + free(info->data); + info->length = 0; + info->data = NULL; + } } LOG_FUNC_RETURN (bytes); @@ -990,126 +985,120 @@ static int _emm_as_encrypt(as_nas_info_t* info, /**************************************************************************** ** ** - ** Name: _emm_as_send() ** + ** Name: _emm_as_send() ** ** ** ** Description: Builds NAS message according to the given EMMAS Service ** - ** Access Point primitive and sends it to the Access Stratum ** - ** sublayer ** + ** Access Point primitive and sends it to the Access Stratum ** + ** sublayer ** ** ** - ** Inputs: msg: The EMMAS-SAP primitive to be sent ** - ** Others: None ** + ** Inputs: msg: The EMMAS-SAP primitive to be sent ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** 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) - { - case _EMMAS_DATA_REQ: - as_msg.msgID = _emm_as_data_req(&msg->u.data, - &as_msg.msg.ul_info_transfer_req); - break; + switch (msg->primitive) { + case _EMMAS_DATA_REQ: + as_msg.msgID = _emm_as_data_req(&msg->u.data, + &as_msg.msg.ul_info_transfer_req); + break; - case _EMMAS_STATUS_IND: - as_msg.msgID = _emm_as_status_ind(&msg->u.status, - &as_msg.msg.ul_info_transfer_req); - break; + case _EMMAS_STATUS_IND: + as_msg.msgID = _emm_as_status_ind(&msg->u.status, + &as_msg.msg.ul_info_transfer_req); + break; - case _EMMAS_RELEASE_REQ: - as_msg.msgID = _emm_as_release_req(&msg->u.release, - &as_msg.msg.nas_release_req); - break; + case _EMMAS_RELEASE_REQ: + as_msg.msgID = _emm_as_release_req(&msg->u.release, + &as_msg.msg.nas_release_req); + break; #ifdef NAS_UE - case _EMMAS_SECURITY_RES: - as_msg.msgID = _emm_as_security_res(&msg->u.security, - &as_msg.msg.ul_info_transfer_req); - break; + case _EMMAS_SECURITY_RES: + as_msg.msgID = _emm_as_security_res(&msg->u.security, + &as_msg.msg.ul_info_transfer_req); + break; - case _EMMAS_ESTABLISH_REQ: - as_msg.msgID = _emm_as_establish_req(&msg->u.establish, - &as_msg.msg.nas_establish_req); - break; + case _EMMAS_ESTABLISH_REQ: + as_msg.msgID = _emm_as_establish_req(&msg->u.establish, + &as_msg.msg.nas_establish_req); + break; #endif #ifdef NAS_MME - case _EMMAS_SECURITY_REQ: - as_msg.msgID = _emm_as_security_req(&msg->u.security, - &as_msg.msg.dl_info_transfer_req); - break; - - case _EMMAS_SECURITY_REJ: - as_msg.msgID = _emm_as_security_rej(&msg->u.security, - &as_msg.msg.dl_info_transfer_req); - break; - - case _EMMAS_ESTABLISH_CNF: - as_msg.msgID = _emm_as_establish_cnf(&msg->u.establish, - &as_msg.msg.nas_establish_rsp); - break; - - case _EMMAS_ESTABLISH_REJ: - as_msg.msgID = _emm_as_establish_rej(&msg->u.establish, - &as_msg.msg.nas_establish_rsp); - break; - - case _EMMAS_PAGE_IND: - as_msg.msgID = _emm_as_page_ind(&msg->u.page, - &as_msg.msg.paging_req); - break; + case _EMMAS_SECURITY_REQ: + as_msg.msgID = _emm_as_security_req(&msg->u.security, + &as_msg.msg.dl_info_transfer_req); + break; + + case _EMMAS_SECURITY_REJ: + as_msg.msgID = _emm_as_security_rej(&msg->u.security, + &as_msg.msg.dl_info_transfer_req); + break; + + case _EMMAS_ESTABLISH_CNF: + as_msg.msgID = _emm_as_establish_cnf(&msg->u.establish, + &as_msg.msg.nas_establish_rsp); + break; + + case _EMMAS_ESTABLISH_REJ: + as_msg.msgID = _emm_as_establish_rej(&msg->u.establish, + &as_msg.msg.nas_establish_rsp); + break; + + case _EMMAS_PAGE_IND: + as_msg.msgID = _emm_as_page_ind(&msg->u.page, + &as_msg.msg.paging_req); + break; #endif - case _EMMAS_CELL_INFO_REQ: - as_msg.msgID = _emm_as_cell_info_req(&msg->u.cell_info, - &as_msg.msg.cell_info_req); - /* - * TODO: NAS may provide a list of equivalent PLMNs, if available, - * that AS shall use for cell selection and cell reselection. - */ - break; - - default: - as_msg.msgID = 0; - break; + case _EMMAS_CELL_INFO_REQ: + as_msg.msgID = _emm_as_cell_info_req(&msg->u.cell_info, + &as_msg.msg.cell_info_req); + /* + * TODO: NAS may provide a list of equivalent PLMNs, if available, + * that AS shall use for cell selection and cell reselection. + */ + break; + + default: + as_msg.msgID = 0; + break; } /* 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; } #else - int bytes = as_message_send(&as_msg); - if (bytes > 0) { - LOG_FUNC_RETURN (RETURNok); - } + int bytes = as_message_send(&as_msg); + if (bytes > 0) { + LOG_FUNC_RETURN (RETURNok); + } #endif } LOG_FUNC_RETURN (RETURNerror); @@ -1117,23 +1106,23 @@ static int _emm_as_send(const emm_as_t* msg) /**************************************************************************** ** ** - ** Name: _emm_as_data_req() ** + ** Name: _emm_as_data_req() ** ** ** ** Description: Processes the EMMAS-SAP data transfer request ** - ** primitive ** + ** primitive ** ** ** ** EMMAS-SAP - EMM->AS: DATA_REQ - Data transfer procedure ** ** ** - ** Inputs: msg: The EMMAS-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The EMMAS-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: as_msg: The message to send to the AS ** - ** Return: The identifier of the AS message ** - ** Others: None ** + ** Outputs: as_msg: The message to send to the AS ** + ** Return: The identifier of the AS message ** + ** 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; @@ -1147,144 +1136,141 @@ static int _emm_as_data_req(const emm_as_data_t* msg, /* Setup the AS message */ if (msg->guti) { - as_msg->s_tmsi.MMEcode = msg->guti->gummei.MMEcode; - as_msg->s_tmsi.m_tmsi = msg->guti->m_tmsi; - } - else { - as_msg->UEid = msg->ueid; + as_msg->s_tmsi.MMEcode = msg->guti->gummei.MMEcode; + as_msg->s_tmsi.m_tmsi = msg->guti->m_tmsi; + } 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); - break; + case EMM_AS_NAS_DATA_ATTACH: + size = emm_send_attach_complete(msg, &emm_msg->attach_complete); + break; - case EMM_AS_NAS_DATA_DETACH: - size = emm_send_detach_request(msg, &emm_msg->detach_request); - break; + case EMM_AS_NAS_DATA_DETACH: + size = emm_send_detach_request(msg, &emm_msg->detach_request); + break; #endif #ifdef NAS_MME - case EMM_AS_NAS_DATA_DETACH: - size = emm_send_detach_accept(msg, &emm_msg->detach_accept); - break; + case EMM_AS_NAS_DATA_DETACH: + size = emm_send_detach_accept(msg, &emm_msg->detach_accept); + break; #endif - default: - /* Send other NAS messages as already encoded ESM messages */ - size = msg->NASmsg.length; - is_encoded = TRUE; - break; - } + default: + /* Send other NAS messages as already encoded ESM messages */ + size = msg->NASmsg.length; + is_encoded = TRUE; + break; + } if (size > 0) { - int bytes; - if (!is_encoded) { - /* Encode the NAS information message */ - bytes = _emm_as_encode(&as_msg->nasMsg, &nas_msg, size); - } else { - /* Encrypt the NAS information message */ - bytes = _emm_as_encrypt(&as_msg->nasMsg, &nas_msg.header, - (char*)(msg->NASmsg.value), size); - } - if (bytes > 0) { + int bytes; + if (!is_encoded) { + /* Encode the NAS information message */ + bytes = _emm_as_encode(&as_msg->nasMsg, &nas_msg, size); + } else { + /* Encrypt the NAS information message */ + bytes = _emm_as_encrypt(&as_msg->nasMsg, &nas_msg.header, + (char *)(msg->NASmsg.value), size); + } + if (bytes > 0) { #ifdef NAS_UE - LOG_FUNC_RETURN (AS_UL_INFO_TRANSFER_REQ); + LOG_FUNC_RETURN (AS_UL_INFO_TRANSFER_REQ); #endif #ifdef NAS_MME - LOG_FUNC_RETURN (AS_DL_INFO_TRANSFER_REQ); + LOG_FUNC_RETURN (AS_DL_INFO_TRANSFER_REQ); #endif - } + } } LOG_FUNC_RETURN (0); } /**************************************************************************** ** ** - ** Name: _emm_as_status_ind() ** + ** Name: _emm_as_status_ind() ** ** ** ** Description: Processes the EMMAS-SAP status indication primitive ** ** ** ** EMMAS-SAP - EMM->AS: STATUS_IND - EMM status report procedure ** ** ** - ** Inputs: msg: The EMMAS-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The EMMAS-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: as_msg: The message to send to the AS ** - ** Return: The identifier of the AS message ** - ** Others: None ** + ** Outputs: as_msg: The message to send to the AS ** + ** Return: The identifier of the AS message ** + ** 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; int size = 0; LOG_TRACE(INFO, "EMMAS-SAP - Send AS status indication (cause=%d)", - msg->emm_cause); + msg->emm_cause); nas_message_t nas_msg; memset(&nas_msg, 0 , sizeof(nas_message_t)); /* Setup the AS message */ if (msg->guti) { - as_msg->s_tmsi.MMEcode = msg->guti->gummei.MMEcode; - as_msg->s_tmsi.m_tmsi = msg->guti->m_tmsi; - } - else { - as_msg->UEid = msg->ueid; + as_msg->s_tmsi.MMEcode = msg->guti->gummei.MMEcode; + as_msg->s_tmsi.m_tmsi = msg->guti->m_tmsi; + } 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) { - size = emm_send_status(msg, &emm_msg->emm_status); + size = emm_send_status(msg, &emm_msg->emm_status); } if (size > 0) { - /* Encode the NAS information message */ - int bytes = _emm_as_encode(&as_msg->nasMsg, &nas_msg, size); - if (bytes > 0) { + /* Encode the NAS information message */ + int bytes = _emm_as_encode(&as_msg->nasMsg, &nas_msg, size); + if (bytes > 0) { #ifdef NAS_UE - LOG_FUNC_RETURN (AS_UL_INFO_TRANSFER_REQ); + LOG_FUNC_RETURN (AS_UL_INFO_TRANSFER_REQ); #endif #ifdef NAS_MME - LOG_FUNC_RETURN (AS_DL_INFO_TRANSFER_REQ); + LOG_FUNC_RETURN (AS_DL_INFO_TRANSFER_REQ); #endif - } + } } LOG_FUNC_RETURN (0); } /**************************************************************************** ** ** - ** Name: _emm_as_release_req() ** + ** Name: _emm_as_release_req() ** ** ** ** Description: Processes the EMMAS-SAP connection release request ** - ** primitive ** + ** primitive ** ** ** ** EMMAS-SAP - EMM->AS: RELEASE_REQ - NAS signalling release procedure ** ** ** - ** Inputs: msg: The EMMAS-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The EMMAS-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: as_msg: The message to send to the AS ** - ** Return: The identifier of the AS message ** - ** Others: None ** + ** Outputs: as_msg: The message to send to the AS ** + ** Return: The identifier of the AS message ** + ** 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; @@ -1292,17 +1278,16 @@ static int _emm_as_release_req(const emm_as_release_t* msg, /* Setup the AS message */ if (msg->guti) { - as_msg->s_tmsi.MMEcode = msg->guti->gummei.MMEcode; - as_msg->s_tmsi.m_tmsi = msg->guti->m_tmsi; - } - else { - as_msg->UEid = msg->ueid; + as_msg->s_tmsi.MMEcode = msg->guti->gummei.MMEcode; + as_msg->s_tmsi.m_tmsi = msg->guti->m_tmsi; + } else { + as_msg->UEid = msg->ueid; } if (msg->cause == EMM_AS_CAUSE_AUTHENTICATION) { - as_msg->cause = AS_AUTHENTICATION_FAILURE; + as_msg->cause = AS_AUTHENTICATION_FAILURE; } else if (msg->cause == EMM_AS_CAUSE_DETACH) { - as_msg->cause = AS_DETACH; + as_msg->cause = AS_DETACH; } LOG_FUNC_RETURN (AS_NAS_RELEASE_REQ); @@ -1311,22 +1296,22 @@ static int _emm_as_release_req(const emm_as_release_t* msg, #ifdef NAS_UE /**************************************************************************** ** ** - ** Name: _emm_as_security_res() ** + ** Name: _emm_as_security_res() ** ** ** ** Description: Processes the EMMAS-SAP security response primitive ** ** ** ** EMMAS-SAP - EMM->AS: SECURITY_RES - Security mode control procedure ** ** ** - ** Inputs: msg: The EMMAS-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The EMMAS-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: as_msg: The message to send to the AS ** - ** Return: The identifier of the AS message ** - ** Others: None ** + ** Outputs: as_msg: The message to send to the AS ** + ** Return: The identifier of the AS message ** + ** 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; @@ -1339,76 +1324,75 @@ static int _emm_as_security_res(const emm_as_security_t* msg, /* Setup the AS message */ if (msg->guti) { - as_msg->s_tmsi.MMEcode = msg->guti->gummei.MMEcode; - as_msg->s_tmsi.m_tmsi = msg->guti->m_tmsi; + as_msg->s_tmsi.MMEcode = msg->guti->gummei.MMEcode; + as_msg->s_tmsi.m_tmsi = msg->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 NAS security message */ - if (emm_msg != NULL) switch (msg->msgType) - { - case EMM_AS_MSG_TYPE_IDENT: - size = emm_send_identity_response(msg, &emm_msg->identity_response); - break; - - case EMM_AS_MSG_TYPE_AUTH: - if (msg->emm_cause != EMM_CAUSE_SUCCESS) { - size = emm_send_authentication_failure(msg, - &emm_msg->authentication_failure); - } else { - size = emm_send_authentication_response(msg, - &emm_msg->authentication_response); - } - break; - - case EMM_AS_MSG_TYPE_SMC: - if (msg->emm_cause != EMM_CAUSE_SUCCESS) { - size = emm_send_security_mode_reject(msg, - &emm_msg->security_mode_reject); - } else { - size = emm_send_security_mode_complete(msg, - &emm_msg->security_mode_complete); - } - break; - - default: - LOG_TRACE(WARNING, "EMMAS-SAP - Type of NAS security " - "message 0x%.2x is not valid", 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; + + case EMM_AS_MSG_TYPE_AUTH: + if (msg->emm_cause != EMM_CAUSE_SUCCESS) { + size = emm_send_authentication_failure(msg, + &emm_msg->authentication_failure); + } else { + size = emm_send_authentication_response(msg, + &emm_msg->authentication_response); + } + break; + + case EMM_AS_MSG_TYPE_SMC: + if (msg->emm_cause != EMM_CAUSE_SUCCESS) { + size = emm_send_security_mode_reject(msg, + &emm_msg->security_mode_reject); + } else { + size = emm_send_security_mode_complete(msg, + &emm_msg->security_mode_complete); + } + break; + + default: + LOG_TRACE(WARNING, "EMMAS-SAP - Type of NAS security " + "message 0x%.2x is not valid", msg->msgType); + } if (size > 0) { - /* Encode the NAS security message */ - int bytes = _emm_as_encode(&as_msg->nasMsg, &nas_msg, size); - if (bytes > 0) { - LOG_FUNC_RETURN (AS_UL_INFO_TRANSFER_REQ); - } + /* Encode the NAS security message */ + int bytes = _emm_as_encode(&as_msg->nasMsg, &nas_msg, size); + if (bytes > 0) { + LOG_FUNC_RETURN (AS_UL_INFO_TRANSFER_REQ); + } } LOG_FUNC_RETURN (0); } /**************************************************************************** ** ** - ** Name: _emm_as_establish_req() ** + ** Name: _emm_as_establish_req() ** ** ** ** Description: Processes the EMMAS-SAP connection establish request ** - ** primitive ** + ** primitive ** ** ** ** EMMAS-SAP - EMM->AS: ESTABLISH_REQ - NAS signalling connection ** - ** The NAS requests the AS to establish signalling connection ** - ** to tranfer initial NAS message to the network. ** + ** The NAS requests the AS to establish signalling connection ** + ** to tranfer initial NAS message to the network. ** ** ** - ** Inputs: msg: The EMMAS-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The EMMAS-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: as_msg: The message to send to the AS ** - ** Return: The identifier of the AS message ** - ** Others: None ** + ** Outputs: as_msg: The message to send to the AS ** + ** Return: The identifier of the AS message ** + ** 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; @@ -1425,51 +1409,50 @@ static int _emm_as_establish_req(const emm_as_establish_t* msg, as_msg->plmnID = *msg->plmnID; /* Derive the S-TMSI from the GUTI, if valid */ 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; + as_msg->s_tmsi.MMEcode = msg->UEid.guti->gummei.MMEcode; + 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) - { - case EMM_AS_NAS_INFO_ATTACH: - size = emm_send_attach_request(msg, &emm_msg->attach_request); - break; - - case EMM_AS_NAS_INFO_DETACH: - size = emm_send_initial_detach_request(msg, - &emm_msg->detach_request); - break; - - case EMM_AS_NAS_INFO_TAU: - size = emm_send_initial_tau_request(msg, - &emm_msg->tracking_area_update_request); - break; - - case EMM_AS_NAS_INFO_SR: - size = emm_send_initial_sr_request(msg, &emm_msg->service_request); - break; - - case EMM_AS_NAS_INFO_EXTSR: - size = emm_send_initial_extsr_request(msg, - &emm_msg->extended_service_request); - break; - - default: - LOG_TRACE(WARNING, "EMMAS-SAP - Type of initial NAS " - "message 0x%.2x is not valid", msg->NASinfo); - break; - } + if (emm_msg != NULL) switch (msg->NASinfo) { + case EMM_AS_NAS_INFO_ATTACH: + size = emm_send_attach_request(msg, &emm_msg->attach_request); + break; + + case EMM_AS_NAS_INFO_DETACH: + size = emm_send_initial_detach_request(msg, + &emm_msg->detach_request); + break; + + case EMM_AS_NAS_INFO_TAU: + size = emm_send_initial_tau_request(msg, + &emm_msg->tracking_area_update_request); + break; + + case EMM_AS_NAS_INFO_SR: + size = emm_send_initial_sr_request(msg, &emm_msg->service_request); + break; + + case EMM_AS_NAS_INFO_EXTSR: + size = emm_send_initial_extsr_request(msg, + &emm_msg->extended_service_request); + break; + + default: + LOG_TRACE(WARNING, "EMMAS-SAP - Type of initial NAS " + "message 0x%.2x is not valid", msg->NASinfo); + break; + } if (size > 0) { - /* Encode the initial NAS information message */ - int bytes = _emm_as_encode(&as_msg->initialNasMsg, &nas_msg, size); - if (bytes > 0) { - LOG_FUNC_RETURN (AS_NAS_ESTABLISH_REQ); - } + /* Encode the initial NAS information message */ + int bytes = _emm_as_encode(&as_msg->initialNasMsg, &nas_msg, size); + if (bytes > 0) { + LOG_FUNC_RETURN (AS_NAS_ESTABLISH_REQ); + } } LOG_FUNC_RETURN (0); } @@ -1478,22 +1461,22 @@ static int _emm_as_establish_req(const emm_as_establish_t* msg, #ifdef NAS_MME /**************************************************************************** ** ** - ** Name: _emm_as_security_req() ** + ** Name: _emm_as_security_req() ** ** ** ** Description: Processes the EMMAS-SAP security request primitive ** ** ** ** EMMAS-SAP - EMM->AS: SECURITY_REQ - Security mode control procedure ** ** ** - ** Inputs: msg: The EMMAS-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The EMMAS-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: as_msg: The message to send to the AS ** - ** Return: The identifier of the AS message ** - ** Others: None ** + ** Outputs: as_msg: The message to send to the AS ** + ** Return: The identifier of the AS message ** + ** 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; @@ -1506,66 +1489,64 @@ static int _emm_as_security_req(const emm_as_security_t* msg, /* Setup the AS message */ if (msg->guti) { - as_msg->s_tmsi.MMEcode = msg->guti->gummei.MMEcode; - as_msg->s_tmsi.m_tmsi = msg->guti->m_tmsi; - } - else { - as_msg->UEid = msg->ueid; + as_msg->s_tmsi.MMEcode = msg->guti->gummei.MMEcode; + as_msg->s_tmsi.m_tmsi = msg->guti->m_tmsi; + } 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) - { - case EMM_AS_MSG_TYPE_IDENT: - size = emm_send_identity_request(msg, &emm_msg->identity_request); - break; - - case EMM_AS_MSG_TYPE_AUTH: - size = emm_send_authentication_request(msg, - &emm_msg->authentication_request); - break; - - case EMM_AS_MSG_TYPE_SMC: - size = emm_send_security_mode_command(msg, - &emm_msg->security_mode_command); - break; - - default: - LOG_TRACE(WARNING, "EMMAS-SAP - Type of NAS security " - "message 0x%.2x is not valid", 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; + + case EMM_AS_MSG_TYPE_AUTH: + size = emm_send_authentication_request(msg, + &emm_msg->authentication_request); + break; + + case EMM_AS_MSG_TYPE_SMC: + size = emm_send_security_mode_command(msg, + &emm_msg->security_mode_command); + break; + + default: + LOG_TRACE(WARNING, "EMMAS-SAP - Type of NAS security " + "message 0x%.2x is not valid", msg->msgType); + } if (size > 0) { - /* Encode the NAS security message */ - int bytes = _emm_as_encode(&as_msg->nasMsg, &nas_msg, size); - if (bytes > 0) { - LOG_FUNC_RETURN (AS_DL_INFO_TRANSFER_REQ); - } + /* Encode the NAS security message */ + int bytes = _emm_as_encode(&as_msg->nasMsg, &nas_msg, size); + if (bytes > 0) { + LOG_FUNC_RETURN (AS_DL_INFO_TRANSFER_REQ); + } } LOG_FUNC_RETURN (0); } /**************************************************************************** ** ** - ** Name: _emm_as_security_rej() ** + ** Name: _emm_as_security_rej() ** ** ** ** Description: Processes the EMMAS-SAP security reject primitive ** ** ** ** EMMAS-SAP - EMM->AS: SECURITY_REJ - Security mode control procedure ** ** ** - ** Inputs: msg: The EMMAS-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The EMMAS-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: as_msg: The message to send to the AS ** - ** Return: The identifier of the AS message ** - ** Others: None ** + ** Outputs: as_msg: The message to send to the AS ** + ** Return: The identifier of the AS message ** + ** 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; @@ -1578,58 +1559,56 @@ static int _emm_as_security_rej(const emm_as_security_t* msg, /* Setup the AS message */ if (msg->guti) { - as_msg->s_tmsi.MMEcode = msg->guti->gummei.MMEcode; - as_msg->s_tmsi.m_tmsi = msg->guti->m_tmsi; - } - else { - as_msg->UEid = msg->ueid; + as_msg->s_tmsi.MMEcode = msg->guti->gummei.MMEcode; + as_msg->s_tmsi.m_tmsi = msg->guti->m_tmsi; + } 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) - { - case EMM_AS_MSG_TYPE_AUTH: - size = emm_send_authentication_reject( - &emm_msg->authentication_reject); - break; - - default: - LOG_TRACE(WARNING, "EMMAS-SAP - Type of NAS security " - "message 0x%.2x is not valid", msg->msgType); - } + if (emm_msg != NULL) switch (msg->msgType) { + case EMM_AS_MSG_TYPE_AUTH: + size = emm_send_authentication_reject( + &emm_msg->authentication_reject); + break; + + default: + LOG_TRACE(WARNING, "EMMAS-SAP - Type of NAS security " + "message 0x%.2x is not valid", msg->msgType); + } if (size > 0) { - /* Encode the NAS security message */ - int bytes = _emm_as_encode(&as_msg->nasMsg, &nas_msg, size); - if (bytes > 0) { - LOG_FUNC_RETURN (AS_DL_INFO_TRANSFER_REQ); - } + /* Encode the NAS security message */ + int bytes = _emm_as_encode(&as_msg->nasMsg, &nas_msg, size); + if (bytes > 0) { + LOG_FUNC_RETURN (AS_DL_INFO_TRANSFER_REQ); + } } LOG_FUNC_RETURN (0); } /**************************************************************************** ** ** - ** Name: _emm_as_establish_cnf() ** + ** Name: _emm_as_establish_cnf() ** ** ** ** Description: Processes the EMMAS-SAP connection establish confirm ** - ** primitive ** + ** primitive ** ** ** ** EMMAS-SAP - EMM->AS: ESTABLISH_CNF - NAS signalling connection ** ** ** - ** Inputs: msg: The EMMAS-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The EMMAS-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: as_msg: The message to send to the AS ** - ** Return: The identifier of the AS message ** - ** Others: None ** + ** Outputs: as_msg: The message to send to the AS ** + ** Return: The identifier of the AS message ** + ** 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; @@ -1643,57 +1622,56 @@ static int _emm_as_establish_cnf(const emm_as_establish_t* msg, /* Setup the AS message */ as_msg->UEid = msg->ueid; if (msg->UEid.guti == NULL) { - LOG_FUNC_RETURN (0); + LOG_FUNC_RETURN (0); } as_msg->s_tmsi.MMEcode = msg->UEid.guti->gummei.MMEcode; 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) - { - case EMM_AS_NAS_INFO_ATTACH: - size = emm_send_attach_accept(msg, &emm_msg->attach_accept); - break; - - default: - LOG_TRACE(WARNING, "EMMAS-SAP - Type of initial NAS " - "message 0x%.2x is not valid", msg->NASinfo); - break; - } + if (emm_msg != NULL) switch (msg->NASinfo) { + case EMM_AS_NAS_INFO_ATTACH: + size = emm_send_attach_accept(msg, &emm_msg->attach_accept); + break; + + default: + LOG_TRACE(WARNING, "EMMAS-SAP - Type of initial NAS " + "message 0x%.2x is not valid", msg->NASinfo); + break; + } if (size > 0) { - /* Encode the initial NAS information message */ - int bytes = _emm_as_encode(&as_msg->nasMsg, &nas_msg, size); - if (bytes > 0) { - as_msg->errCode = AS_SUCCESS; - LOG_FUNC_RETURN (AS_NAS_ESTABLISH_RSP); - } + /* Encode the initial NAS information message */ + int bytes = _emm_as_encode(&as_msg->nasMsg, &nas_msg, size); + if (bytes > 0) { + as_msg->errCode = AS_SUCCESS; + LOG_FUNC_RETURN (AS_NAS_ESTABLISH_RSP); + } } LOG_FUNC_RETURN (0); } /**************************************************************************** ** ** - ** Name: _emm_as_establish_rej() ** + ** Name: _emm_as_establish_rej() ** ** ** ** Description: Processes the EMMAS-SAP connection establish reject ** - ** primitive ** + ** primitive ** ** ** ** EMMAS-SAP - EMM->AS: ESTABLISH_REJ - NAS signalling connection ** ** ** - ** Inputs: msg: The EMMAS-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The EMMAS-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: as_msg: The message to send to the AS ** - ** Return: The identifier of the AS message ** - ** Others: None ** + ** Outputs: as_msg: The message to send to the AS ** + ** Return: The identifier of the AS message ** + ** 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; @@ -1706,57 +1684,55 @@ static int _emm_as_establish_rej(const emm_as_establish_t* msg, /* Setup the AS message */ 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 { - as_msg->UEid = msg->ueid; + as_msg->s_tmsi.MMEcode = msg->UEid.guti->gummei.MMEcode; + as_msg->s_tmsi.m_tmsi = msg->UEid.guti->m_tmsi; + } 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) - { - case EMM_AS_NAS_INFO_ATTACH: - size = emm_send_attach_reject(msg, &emm_msg->attach_reject); - break; - - default: - LOG_TRACE(WARNING, "EMMAS-SAP - Type of initial NAS " - "message 0x%.2x is not valid", msg->NASinfo); - break; - } + if (emm_msg != NULL) switch (msg->NASinfo) { + case EMM_AS_NAS_INFO_ATTACH: + size = emm_send_attach_reject(msg, &emm_msg->attach_reject); + break; + + default: + LOG_TRACE(WARNING, "EMMAS-SAP - Type of initial NAS " + "message 0x%.2x is not valid", msg->NASinfo); + break; + } if (size > 0) { - /* Encode the initial NAS information message */ - int bytes = _emm_as_encode(&as_msg->nasMsg, &nas_msg, size); - if (bytes > 0) { - as_msg->errCode = AS_TERMINATED_NAS; - LOG_FUNC_RETURN (AS_NAS_ESTABLISH_RSP); - } + /* Encode the initial NAS information message */ + int bytes = _emm_as_encode(&as_msg->nasMsg, &nas_msg, size); + if (bytes > 0) { + as_msg->errCode = AS_TERMINATED_NAS; + LOG_FUNC_RETURN (AS_NAS_ESTABLISH_RSP); + } } LOG_FUNC_RETURN (0); } /**************************************************************************** ** ** - ** Name: _emm_as_page_ind() ** + ** Name: _emm_as_page_ind() ** ** ** ** Description: Processes the EMMAS-SAP paging data indication primitive ** ** ** ** EMMAS-SAP - EMM->AS: PAGE_IND - Paging data procedure ** ** ** - ** Inputs: msg: The EMMAS-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The EMMAS-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: as_msg: The message to send to the AS ** - ** Return: The identifier of the AS message ** - ** Others: None ** + ** Outputs: as_msg: The message to send to the AS ** + ** Return: The identifier of the AS message ** + ** 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; @@ -1767,7 +1743,7 @@ static int _emm_as_page_ind(const emm_as_page_t* msg, paging_req_t* as_msg) /* TODO */ if (bytes > 0) { - LOG_FUNC_RETURN (AS_PAGING_IND); + LOG_FUNC_RETURN (AS_PAGING_IND); } LOG_FUNC_RETURN (0); } @@ -1776,25 +1752,25 @@ static int _emm_as_page_ind(const emm_as_page_t* msg, paging_req_t* as_msg) /**************************************************************************** ** ** - ** Name: _emm_as_cell_info_req() ** + ** Name: _emm_as_cell_info_req() ** ** ** ** Description: Processes the EMMAS-SAP cell information request ** - ** primitive ** + ** primitive ** ** ** ** EMMAS-SAP - EMM->AS: CELL_INFO_REQ - PLMN and cell selection procedure ** - ** The NAS requests the AS to select a cell belonging to the ** - ** selected PLMN with associated Radio Access Technologies. ** + ** The NAS requests the AS to select a cell belonging to the ** + ** selected PLMN with associated Radio Access Technologies. ** ** ** - ** Inputs: msg: The EMMAS-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The EMMAS-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: as_msg: The message to send to the AS ** - ** Return: The identifier of the AS message ** - ** Others: None ** + ** Outputs: as_msg: The message to send to the AS ** + ** Return: The identifier of the AS message ** + ** 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; diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_as.h b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_as.h index 69985720ce..adc6928c73 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_as.h +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_as.h @@ -1,22 +1,22 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source emm_as.h +Source emm_as.h -Version 0.1 +Version 0.1 -Date 2012/10/16 +Date 2012/10/16 -Product NAS stack +Product NAS stack -Subsystem EPS Mobility Management +Subsystem EPS Mobility Management -Author Frederic Maurel +Author Frederic Maurel -Description Defines the EMMAS Service Access Point that provides - services to the EPS Mobility Management for NAS message - transfer to/from the Access Stratum sublayer. +Description Defines the EMMAS Service Access Point that provides + services to the EPS Mobility Management for NAS message + transfer to/from the Access Stratum sublayer. *****************************************************************************/ #ifndef __EMM_AS_H__ @@ -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__*/ diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_asDef.h b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_asDef.h index 064d67bf77..b5171339da 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_asDef.h +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_asDef.h @@ -1,22 +1,22 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source emm_asDef.h +Source emm_asDef.h -Version 0.1 +Version 0.1 -Date 2012/10/16 +Date 2012/10/16 -Product NAS stack +Product NAS stack -Subsystem EPS Mobility Management +Subsystem EPS Mobility Management -Author Frederic Maurel +Author Frederic Maurel -Description Defines the EMM primitives available at the EMMAS Service - Access Point to transfer NAS messages to/from the Access - Stratum sublayer. +Description Defines the EMM primitives available at the EMMAS Service + Access Point to transfer NAS messages to/from the Access + Stratum sublayer. *****************************************************************************/ #ifndef __EMM_ASDEF_H__ @@ -34,34 +34,34 @@ Description Defines the EMM primitives available at the EMMAS Service */ typedef enum { _EMMAS_START = 200, - _EMMAS_SECURITY_REQ, /* EMM->AS: Security request */ - _EMMAS_SECURITY_IND, /* AS->EMM: Security indication */ - _EMMAS_SECURITY_RES, /* EMM->AS: Security response */ - _EMMAS_SECURITY_REJ, /* EMM->AS: Security reject */ - _EMMAS_ESTABLISH_REQ, /* EMM->AS: Connection establish request */ - _EMMAS_ESTABLISH_CNF, /* AS->EMM: Connection establish confirm */ - _EMMAS_ESTABLISH_REJ, /* AS->EMM: Connection establish reject */ - _EMMAS_RELEASE_REQ, /* EMM->AS: Connection release request */ - _EMMAS_RELEASE_IND, /* AS->EMM: Connection release indication */ - _EMMAS_DATA_REQ, /* EMM->AS: Data transfer request */ - _EMMAS_DATA_IND, /* AS->EMM: Data transfer indication */ - _EMMAS_PAGE_IND, /* AS->EMM: Paging data indication */ - _EMMAS_STATUS_IND, /* AS->EMM: Status indication */ - _EMMAS_CELL_INFO_REQ, /* EMM->AS: Cell information request */ - _EMMAS_CELL_INFO_RES, /* AS->EMM: Cell information response */ - _EMMAS_CELL_INFO_IND, /* AS->EMM: Cell information indication */ + _EMMAS_SECURITY_REQ, /* EMM->AS: Security request */ + _EMMAS_SECURITY_IND, /* AS->EMM: Security indication */ + _EMMAS_SECURITY_RES, /* EMM->AS: Security response */ + _EMMAS_SECURITY_REJ, /* EMM->AS: Security reject */ + _EMMAS_ESTABLISH_REQ, /* EMM->AS: Connection establish request */ + _EMMAS_ESTABLISH_CNF, /* AS->EMM: Connection establish confirm */ + _EMMAS_ESTABLISH_REJ, /* AS->EMM: Connection establish reject */ + _EMMAS_RELEASE_REQ, /* EMM->AS: Connection release request */ + _EMMAS_RELEASE_IND, /* AS->EMM: Connection release indication */ + _EMMAS_DATA_REQ, /* EMM->AS: Data transfer request */ + _EMMAS_DATA_IND, /* AS->EMM: Data transfer indication */ + _EMMAS_PAGE_IND, /* AS->EMM: Paging data indication */ + _EMMAS_STATUS_IND, /* AS->EMM: Status indication */ + _EMMAS_CELL_INFO_REQ, /* EMM->AS: Cell information request */ + _EMMAS_CELL_INFO_RES, /* AS->EMM: Cell information response */ + _EMMAS_CELL_INFO_IND, /* AS->EMM: Cell information indication */ _EMMAS_END } emm_as_primitive_t; /* Data used to setup EPS NAS security */ typedef struct { - UInt8_t is_new; /* New security data indicator */ -#define EMM_AS_NO_KEY_AVAILABLE 0xff - 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 */ + UInt8_t is_new; /* New security data indicator */ +#define EMM_AS_NO_KEY_AVAILABLE 0xff + 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 */ } emm_as_security_data_t; /****************************************************************************/ @@ -73,35 +73,35 @@ typedef struct { * ---------------------------- */ typedef struct { - UInt32_t ueid; /* UE lower layer identifier */ - const GUTI_t *guti; /* GUTI temporary mobile identity */ - emm_as_security_data_t sctx;/* EPS NAS security context */ - int emm_cause; /* EMM failure cause code */ + UInt32_t ueid; /* UE lower layer identifier */ + const GUTI_t *guti; /* GUTI temporary mobile identity */ + emm_as_security_data_t sctx;/* EPS NAS security context */ + int emm_cause; /* EMM failure cause code */ /* * Identity request/response */ - UInt8_t identType; /* Type of requested UE's identity */ - const imsi_t *imsi; /* The requested IMSI of the UE */ - const imei_t *imei; /* The requested IMEI of the UE */ - UInt32_t tmsi; /* The requested TMSI of the UE */ + UInt8_t identType; /* Type of requested UE's identity */ + const imsi_t *imsi; /* The requested IMSI of the UE */ + const imei_t *imei; /* The requested IMEI of the UE */ + UInt32_t tmsi; /* The requested TMSI of the UE */ /* * 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 */ + 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 */ /* * Security Mode Command */ - UInt8_t eea; /* Replayed EPS encryption algorithms */ - UInt8_t eia; /* Replayed EPS integrity algorithms */ + UInt8_t eea; /* Replayed EPS encryption algorithms */ + UInt8_t eia; /* Replayed EPS integrity algorithms */ -#define EMM_AS_MSG_TYPE_IDENT 0x01 /* Identification message */ -#define EMM_AS_MSG_TYPE_AUTH 0x02 /* Authentication message */ -#define EMM_AS_MSG_TYPE_SMC 0x03 /* Security Mode Command */ - UInt8_t msgType; /* Type of NAS security message to transfer */ +#define EMM_AS_MSG_TYPE_IDENT 0x01 /* Identification message */ +#define EMM_AS_MSG_TYPE_AUTH 0x02 /* Authentication message */ +#define EMM_AS_MSG_TYPE_SMC 0x03 /* Security Mode Command */ + UInt8_t msgType; /* Type of NAS security message to transfer */ } emm_as_security_t; /* @@ -109,39 +109,39 @@ typedef struct { * -------------------------------------------- */ typedef struct { - const GUTI_t *guti; /* The GUTI, if valid */ - const tai_t *tai; /* The last visited registered Tracking - * Area Identity, if available */ - const imsi_t *imsi; /* IMSI in case of "AttachWithImsi" */ - const imei_t *imei; /* UE's IMEI for emergency bearer services */ + const GUTI_t *guti; /* The GUTI, if valid */ + const tai_t *tai; /* The last visited registered Tracking + * Area Identity, if available */ + const imsi_t *imsi; /* IMSI in case of "AttachWithImsi" */ + const imei_t *imei; /* UE's IMEI for emergency bearer services */ } emm_as_EPS_identity_t; typedef struct { - UInt32_t ueid; /* UE lower layer identifier */ - emm_as_EPS_identity_t UEid; /* UE's EPS mobile identity */ - emm_as_security_data_t sctx;/* EPS NAS security context */ - int switch_off; /* TRUE if the UE is switched off */ - 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 */ - UInt8_t ksi; /* NAS key set identifier */ - UInt8_t encryption:4; /* Ciphering algorithm */ - UInt8_t integrity:4; /* Integrity protection algorithm */ - int emm_cause; /* EMM failure cause code */ - const GUTI_t *new_guti; /* New GUTI, if re-allocated */ - int n_tacs; /* Number of concecutive tracking areas - * the UE is registered to */ - tac_t tac; /* Code of the first tracking area the UE - * is registered to */ -#define EMM_AS_NAS_INFO_ATTACH 0x01 /* Attach request */ -#define EMM_AS_NAS_INFO_DETACH 0x02 /* Detach request */ -#define EMM_AS_NAS_INFO_TAU 0x03 /* Tracking Area Update request */ -#define EMM_AS_NAS_INFO_SR 0x04 /* Service Request */ -#define EMM_AS_NAS_INFO_EXTSR 0x05 /* Extended Service Request */ - UInt8_t NASinfo; /* Type of initial NAS information to transfer */ - OctetString NASmsg; /* NAS message to be transfered within - * initial NAS information message */ + UInt32_t ueid; /* UE lower layer identifier */ + emm_as_EPS_identity_t UEid; /* UE's EPS mobile identity */ + emm_as_security_data_t sctx;/* EPS NAS security context */ + int switch_off; /* TRUE if the UE is switched off */ + 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 */ + UInt8_t ksi; /* NAS key set identifier */ + UInt8_t encryption:4; /* Ciphering algorithm */ + UInt8_t integrity:4; /* Integrity protection algorithm */ + int emm_cause; /* EMM failure cause code */ + const GUTI_t *new_guti; /* New GUTI, if re-allocated */ + int n_tacs; /* Number of concecutive tracking areas + * the UE is registered to */ + tac_t tac; /* Code of the first tracking area the UE + * is registered to */ +#define EMM_AS_NAS_INFO_ATTACH 0x01 /* Attach request */ +#define EMM_AS_NAS_INFO_DETACH 0x02 /* Detach request */ +#define EMM_AS_NAS_INFO_TAU 0x03 /* Tracking Area Update request */ +#define EMM_AS_NAS_INFO_SR 0x04 /* Service Request */ +#define EMM_AS_NAS_INFO_EXTSR 0x05 /* Extended Service Request */ + UInt8_t NASinfo; /* Type of initial NAS information to transfer */ + OctetString NASmsg; /* NAS message to be transfered within + * initial NAS information message */ } emm_as_establish_t; /* @@ -149,11 +149,11 @@ typedef struct { * -------------------------------------- */ typedef struct { - UInt32_t ueid; /* UE lower layer identifier */ - const GUTI_t *guti; /* GUTI temporary mobile identity */ -#define EMM_AS_CAUSE_AUTHENTICATION 0x01 /* Authentication failure */ -#define EMM_AS_CAUSE_DETACH 0x02 /* Detach requested */ - UInt8_t cause; /* Release cause */ + UInt32_t ueid; /* UE lower layer identifier */ + const GUTI_t *guti; /* GUTI temporary mobile identity */ +#define EMM_AS_CAUSE_AUTHENTICATION 0x01 /* Authentication failure */ +#define EMM_AS_CAUSE_DETACH 0x02 /* Detach requested */ + UInt8_t cause; /* Release cause */ } emm_as_release_t; /* @@ -161,16 +161,16 @@ typedef struct { * --------------------------------- */ typedef struct { - UInt32_t ueid; /* UE lower layer identifier */ - const GUTI_t *guti; /* GUTI temporary mobile identity */ - emm_as_security_data_t sctx;/* EPS NAS security context */ - int switch_off; /* TRUE if the UE is switched off */ - UInt8_t type; /* Network detach type */ - UInt8_t delivered; /* Data message delivery indicator */ -#define EMM_AS_NAS_DATA_ATTACH 0x01 /* Attach complete */ -#define EMM_AS_NAS_DATA_DETACH 0x02 /* Detach request */ - UInt8_t NASinfo; /* Type of NAS information to transfer */ - OctetString NASmsg; /* NAS message to be transfered */ + UInt32_t ueid; /* UE lower layer identifier */ + const GUTI_t *guti; /* GUTI temporary mobile identity */ + emm_as_security_data_t sctx;/* EPS NAS security context */ + int switch_off; /* TRUE if the UE is switched off */ + UInt8_t type; /* Network detach type */ + UInt8_t delivered; /* Data message delivery indicator */ +#define EMM_AS_NAS_DATA_ATTACH 0x01 /* Attach complete */ +#define EMM_AS_NAS_DATA_DETACH 0x02 /* Detach request */ + UInt8_t NASinfo; /* Type of NAS information to transfer */ + OctetString NASmsg; /* NAS message to be transfered */ } emm_as_data_t; /* @@ -184,10 +184,10 @@ typedef struct {} emm_as_page_t; * ------------------------------------- */ typedef struct { - UInt32_t ueid; /* UE lower layer identifier */ - const GUTI_t *guti; /* GUTI temporary mobile identity */ - emm_as_security_data_t sctx;/* EPS NAS security context */ - int emm_cause; /* EMM failure cause code */ + UInt32_t ueid; /* UE lower layer identifier */ + const GUTI_t *guti; /* GUTI temporary mobile identity */ + emm_as_security_data_t sctx;/* EPS NAS security context */ + int emm_cause; /* EMM failure cause code */ } emm_as_status_t; /* @@ -195,13 +195,13 @@ typedef struct { * ------------------------------------ */ typedef struct { - UInt8_t found; /* Indicates whether a suitable cell is found */ -#define EMM_AS_PLMN_LIST_SIZE 6 + UInt8_t found; /* Indicates whether a suitable cell is found */ +#define EMM_AS_PLMN_LIST_SIZE 6 PLMN_LIST_T(EMM_AS_PLMN_LIST_SIZE) plmnIDs; - /* List of identifiers of available PLMNs */ - Byte_t rat; /* Bitmap of Radio Access Technologies */ - tac_t tac; /* Tracking Area Code */ - ci_t cellID; /* cell identity */ + /* List of identifiers of available PLMNs */ + Byte_t rat; /* Bitmap of Radio Access Technologies */ + tac_t tac; /* Tracking Area Code */ + ci_t cellID; /* cell identity */ } emm_as_cell_info_t; /* @@ -212,13 +212,13 @@ typedef struct { typedef struct { emm_as_primitive_t primitive; union { - emm_as_security_t security; - emm_as_establish_t establish; - emm_as_release_t release; - emm_as_data_t data; - emm_as_page_t page; - emm_as_status_t status; - emm_as_cell_info_t cell_info; + emm_as_security_t security; + emm_as_establish_t establish; + emm_as_release_t release; + emm_as_data_t data; + emm_as_page_t page; + emm_as_status_t status; + emm_as_cell_info_t cell_info; } u; } emm_as_t; @@ -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, - int is_new, int is_ciphered); +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__*/ diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_esm.c b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_esm.c index 571ac088ed..fd33b02c82 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_esm.c +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_esm.c @@ -1,23 +1,23 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source emm_esm.c +Source emm_esm.c -Version 0.1 +Version 0.1 -Date 2012/10/16 +Date 2012/10/16 -Product NAS stack +Product NAS stack -Subsystem EPS Mobility Management +Subsystem EPS Mobility Management -Author Frederic Maurel +Author Frederic Maurel -Description Defines the EMMESM Service Access Point that provides - interlayer services to the EPS Session Management sublayer - for service registration and activate/deactivate PDN - connections. +Description Defines the EMMESM Service Access Point that provides + interlayer services to the EPS Session Management sublayer + for service registration and activate/deactivate PDN + connections. *****************************************************************************/ @@ -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", @@ -59,16 +59,16 @@ static const char* _emm_esm_primitive_str[] = { /**************************************************************************** ** ** - ** Name: emm_esm_initialize() ** + ** Name: emm_esm_initialize() ** ** ** ** Description: Initializes the EMMESM Service Access Point ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: None ** - ** Others: NONE ** + ** Outputs: None ** + ** Return: None ** + ** Others: NONE ** ** ** ***************************************************************************/ void emm_esm_initialize(void) @@ -82,19 +82,19 @@ void emm_esm_initialize(void) /**************************************************************************** ** ** - ** Name: emm_esm_send() ** + ** Name: emm_esm_send() ** ** ** ** Description: Processes the EMMESM Service Access Point primitive ** ** ** - ** Inputs: msg: The EMMESM-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The EMMESM-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ -int emm_esm_send(const emm_esm_t* msg) +int emm_esm_send(const emm_esm_t *msg) { LOG_FUNC_IN; @@ -102,51 +102,49 @@ int emm_esm_send(const emm_esm_t* msg) emm_esm_primitive_t primitive = msg->primitive; LOG_TRACE(INFO, "EMMESM-SAP - Received primitive %s (%d)", - _emm_esm_primitive_str[primitive - _EMMESM_START - 1], primitive); + _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 - * requesting subsequent connectivity to additional PDNs */ - rc = emm_proc_attach_restart(); - break; - - case _EMMESM_ESTABLISH_CNF: - /* ESM notifies EMM that PDN connectivity procedure successfully - * processed */ - if (msg->u.establish.is_attached) { - if (msg->u.establish.is_emergency) { - /* Consider the UE attached for emergency bearer services - * only */ - rc = emm_proc_attach_set_emergency(); - } - } - else { - /* Consider the UE locally detached from the network */ - rc = emm_proc_attach_set_detach(); - } - break; - - case _EMMESM_ESTABLISH_REJ: - /* ESM notifies EMM that PDN connectivity procedure failed */ - break; + case _EMMESM_ESTABLISH_REQ: + /* ESM requests EMM to initiate an attach procedure before + * requesting subsequent connectivity to additional PDNs */ + rc = emm_proc_attach_restart(); + break; + + case _EMMESM_ESTABLISH_CNF: + /* ESM notifies EMM that PDN connectivity procedure successfully + * processed */ + if (msg->u.establish.is_attached) { + if (msg->u.establish.is_emergency) { + /* Consider the UE attached for emergency bearer services + * only */ + rc = emm_proc_attach_set_emergency(); + } + } else { + /* Consider the UE locally detached from the network */ + rc = emm_proc_attach_set_detach(); + } + break; + + case _EMMESM_ESTABLISH_REJ: + /* ESM notifies EMM that PDN connectivity procedure failed */ + break; #endif - case _EMMESM_UNITDATA_REQ: - /* ESM requests EMM to transfer ESM data unit to lower layer */ - rc = lowerlayer_data_req(msg->ueid, &msg->u.data.msg); - break; + case _EMMESM_UNITDATA_REQ: + /* ESM requests EMM to transfer ESM data unit to lower layer */ + rc = lowerlayer_data_req(msg->ueid, &msg->u.data.msg); + break; - default: - break; + default: + break; } if (rc != RETURNok) { - LOG_TRACE(WARNING, "EMMESM-SAP - Failed to process primitive %s (%d)", - _emm_esm_primitive_str[primitive - _EMMESM_START - 1], - primitive); + LOG_TRACE(WARNING, "EMMESM-SAP - Failed to process primitive %s (%d)", + _emm_esm_primitive_str[primitive - _EMMESM_START - 1], + primitive); } LOG_FUNC_RETURN (rc); diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_esm.h b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_esm.h index 17b991341e..f3aaf1144c 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_esm.h +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_esm.h @@ -1,22 +1,22 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source emm_esm.h +Source emm_esm.h -Version 0.1 +Version 0.1 -Date 2012/10/16 +Date 2012/10/16 -Product NAS stack +Product NAS stack -Subsystem EPS Mobility Management +Subsystem EPS Mobility Management -Author Frederic Maurel +Author Frederic Maurel -Description Defines the EMMESM Service Access Point that provides - interlayer services to the EPS Session Management sublayer - for service registration and activate/deactivate PDP context. +Description Defines the EMMESM Service Access Point that provides + interlayer services to the EPS Session Management sublayer + for service registration and activate/deactivate PDP context. *****************************************************************************/ #ifndef __EMM_ESM_H__ @@ -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__*/ diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_esmDef.h b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_esmDef.h index 3577a0d40e..e90514d759 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_esmDef.h +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_esmDef.h @@ -1,23 +1,23 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source emm_esmDef.h +Source emm_esmDef.h -Version 0.1 +Version 0.1 -Date 2012/10/16 +Date 2012/10/16 -Product NAS stack +Product NAS stack -Subsystem EPS Mobility Management +Subsystem EPS Mobility Management -Author Frederic Maurel +Author Frederic Maurel -Description Defines the EMMESM Service Access Point that provides - interlayer services to the EPS Session Management sublayer - for service registration and activate/deactivate PDN - connections. +Description Defines the EMMESM Service Access Point that provides + interlayer services to the EPS Session Management sublayer + for service registration and activate/deactivate PDN + connections. *****************************************************************************/ #ifndef __EMM_ESMDEF_H__ @@ -54,10 +54,10 @@ typedef enum { * --------------------------------------------- */ typedef struct { - int is_emergency; /* Indicates whether the PDN connection is established - * for emergency bearer services only */ - int is_attached; /* Indicates whether the UE remains attached to the - * network */ + int is_emergency; /* Indicates whether the PDN connection is established + * for emergency bearer services only */ + int is_attached; /* Indicates whether the UE remains attached to the + * network */ } emm_esm_establish_t; /* @@ -65,7 +65,7 @@ typedef struct { * ---------------------------------- */ typedef struct { - OctetString msg; /* ESM message to be transfered */ + OctetString msg; /* ESM message to be transfered */ } emm_esm_data_t; /* @@ -77,8 +77,8 @@ typedef struct { emm_esm_primitive_t primitive; unsigned int ueid; union { - emm_esm_establish_t establish; - emm_esm_data_t data; + emm_esm_establish_t establish; + emm_esm_data_t data; } u; /* TODO: complete emm_esm_t structure definition */ } emm_esm_t; diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_fsm.c b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_fsm.c index 17bbf0de4d..2ea5629732 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_fsm.c +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_fsm.c @@ -1,21 +1,21 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source emm_fsm.c +Source emm_fsm.c -Version 0.1 +Version 0.1 -Date 2012/10/03 +Date 2012/10/03 -Product NAS stack +Product NAS stack -Subsystem EPS Mobility Management +Subsystem EPS Mobility Management -Author Frederic Maurel +Author Frederic Maurel -Description Defines the EPS Mobility Management procedures executed at - the EMMREG Service Access Point. +Description Defines the EPS Mobility Management procedures executed at + the EMMREG Service Access Point. *****************************************************************************/ @@ -35,10 +35,10 @@ Description Defines the EPS Mobility Management procedures executed at /****************************************************************************/ #ifdef NAS_UE -#define EMM_FSM_NB_UE_MAX 1 +#define EMM_FSM_NB_UE_MAX 1 #endif #ifdef NAS_MME -#define EMM_FSM_NB_UE_MAX (MME_API_NB_UE_MAX + 1) +#define EMM_FSM_NB_UE_MAX (MME_API_NB_UE_MAX + 1) #endif /****************************************************************************/ @@ -47,12 +47,12 @@ Description Defines the EPS Mobility Management procedures executed at /* * ----------------------------------------------------------------------------- - * Data used for trace logging + * Data used for trace logging * ----------------------------------------------------------------------------- */ /* 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 @@ -126,46 +125,45 @@ static const char* _emm_fsm_status_str[EMM_STATE_MAX] = /* * ----------------------------------------------------------------------------- - * EPS Mobility Management state machine handlers + * EPS Mobility Management state machine handlers * ----------------------------------------------------------------------------- */ /* 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 @@ -199,7 +197,7 @@ static const emm_fsm_handler_t _emm_fsm_handlers[EMM_STATE_MAX] = /* * ----------------------------------------------------------------------------- - * Current EPS Mobility Management status + * Current EPS Mobility Management status * ----------------------------------------------------------------------------- */ @@ -213,16 +211,16 @@ emm_fsm_state_t _emm_fsm_status[EMM_FSM_NB_UE_MAX]; /**************************************************************************** ** ** - ** Name: emm_fsm_initialize() ** + ** Name: emm_fsm_initialize() ** ** ** ** Description: Initializes the EMM state machine ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: None ** - ** Others: _emm_fsm_status ** + ** Outputs: None ** + ** Return: None ** + ** Others: _emm_fsm_status ** ** ** ***************************************************************************/ void emm_fsm_initialize(void) @@ -236,7 +234,7 @@ void emm_fsm_initialize(void) #if defined(NAS_MME) && !defined(EPC_BUILD) for (ueid = 0; ueid < EMM_FSM_NB_UE_MAX; ueid++) { - _emm_fsm_status[ueid] = EMM_DEREGISTERED; + _emm_fsm_status[ueid] = EMM_DEREGISTERED; } #endif @@ -245,25 +243,25 @@ void emm_fsm_initialize(void) /**************************************************************************** ** ** - ** Name: emm_fsm_set_status() ** + ** Name: emm_fsm_set_status() ** ** ** ** Description: Set the EPS Mobility Management status to the given state ** ** ** - ** Inputs: ueid: Lower layers UE identifier ** - ** status: The new EMM status ** - ** Others: None ** + ** Inputs: ueid: Lower layers UE identifier ** + ** status: The new EMM status ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: _emm_fsm_status ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: _emm_fsm_status ** ** ** ***************************************************************************/ int emm_fsm_set_status( #ifdef NAS_MME - unsigned int ueid, - void *ctx, + unsigned int ueid, + void *ctx, #endif - emm_fsm_state_t status) + emm_fsm_state_t status) { LOG_FUNC_IN; @@ -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); @@ -287,13 +285,13 @@ int emm_fsm_set_status( } #else if ( (status < EMM_STATE_MAX) && (ueid < EMM_FSM_NB_UE_MAX) ) { - LOG_TRACE(INFO, "EMM-FSM - Status changed: %s ===> %s", - _emm_fsm_status_str[_emm_fsm_status[ueid]], - _emm_fsm_status_str[status]); - if (status != _emm_fsm_status[ueid]) { - _emm_fsm_status[ueid] = status; - } - LOG_FUNC_RETURN (RETURNok); + LOG_TRACE(INFO, "EMM-FSM - Status changed: %s ===> %s", + _emm_fsm_status_str[_emm_fsm_status[ueid]], + _emm_fsm_status_str[status]); + if (status != _emm_fsm_status[ueid]) { + _emm_fsm_status[ueid] = status; + } + LOG_FUNC_RETURN (RETURNok); } #endif @@ -302,17 +300,17 @@ int emm_fsm_set_status( /**************************************************************************** ** ** - ** Name: emm_fsm_get_status() ** + ** Name: emm_fsm_get_status() ** ** ** ** Description: Get the current value of the EPS Mobility Management ** - ** status ** + ** status ** ** ** - ** Inputs: ueid: Lower layers UE identifier ** - ** Others: _emm_fsm_status ** + ** Inputs: ueid: Lower layers UE identifier ** + ** Others: _emm_fsm_status ** ** ** - ** Outputs: None ** - ** Return: The current value of the EMM status ** - ** Others: None ** + ** Outputs: None ** + ** Return: The current value of the EMM status ** + ** Others: None ** ** ** ***************************************************************************/ #ifdef NAS_UE @@ -326,14 +324,14 @@ 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; } # else if (ueid < EMM_FSM_NB_UE_MAX) { - return (_emm_fsm_status[ueid]); + return (_emm_fsm_status[ueid]); } #endif return EMM_STATE_MAX; @@ -342,19 +340,19 @@ emm_fsm_state_t emm_fsm_get_status(unsigned int ueid, void *ctx) /**************************************************************************** ** ** - ** Name: emm_fsm_process() ** + ** Name: emm_fsm_process() ** ** ** ** Description: Executes the EMM state machine ** ** ** - ** Inputs: evt: The EMMREG-SAP event to process ** - ** Others: _emm_fsm_status ** + ** Inputs: evt: The EMMREG-SAP event to process ** + ** Others: _emm_fsm_status ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** 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,22 +366,22 @@ 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); status = emm_ctx->_emm_fsm_status; # else if (evt->ueid >= EMM_FSM_NB_UE_MAX) { - LOG_FUNC_RETURN (RETURNerror); + LOG_FUNC_RETURN (RETURNerror); } status = _emm_fsm_status[evt->ueid]; # endif #endif LOG_TRACE(INFO, "EMM-FSM - Received event %s (%d) in state %s", - _emm_fsm_event_str[primitive - _EMMREG_START - 1], primitive, - _emm_fsm_status_str[status]); + _emm_fsm_event_str[primitive - _EMMREG_START - 1], primitive, + _emm_fsm_status_str[status]); /* Execute the EMM state machine */ rc = (_emm_fsm_handlers[status])(evt); diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_fsm.h b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_fsm.h index fa7cee6629..00b893dca7 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_fsm.h +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_fsm.h @@ -1,21 +1,21 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source emm_fsm.h +Source emm_fsm.h -Version 0.1 +Version 0.1 -Date 2012/10/03 +Date 2012/10/03 -Product NAS stack +Product NAS stack -Subsystem EPS Mobility Management +Subsystem EPS Mobility Management -Author Frederic Maurel +Author Frederic Maurel -Description Defines the EPS Mobility Management procedures executed at - the EMMREG Service Access Point. +Description Defines the EPS Mobility Management procedures executed at + the EMMREG Service Access Point. *****************************************************************************/ #ifndef __EMM_FSM_H__ @@ -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__*/ diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_recv.c b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_recv.c index bf7374954c..641e4be278 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_recv.c +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_recv.c @@ -1,22 +1,22 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source emm_recv.c +Source emm_recv.c -Version 0.1 +Version 0.1 -Date 2013/01/30 +Date 2013/01/30 -Product NAS stack +Product NAS stack -Subsystem EPS Mobility Management +Subsystem EPS Mobility Management -Author Frederic Maurel +Author Frederic Maurel -Description Defines functions executed at the EMMAS Service Access - Point upon receiving EPS Mobility Management messages - from the Access Stratum sublayer. +Description Defines functions executed at the EMMAS Service Access + Point upon receiving EPS Mobility Management messages + from the Access Stratum sublayer. *****************************************************************************/ @@ -28,7 +28,7 @@ Description Defines functions executed at the EMMAS Service Access #include "emm_cause.h" #include "emm_proc.h" -#include <string.h> // memcpy +#include <string.h> // memcpy /****************************************************************************/ /**************** E X T E R N A L D E F I N I T I O N S ****************/ @@ -53,27 +53,27 @@ Description Defines functions executed at the EMMAS Service Access */ /**************************************************************************** ** ** - ** Name: emm_recv_status() ** + ** Name: emm_recv_status() ** ** ** ** Description: Processes EMM status message ** ** ** - ** Inputs: ueid: UE lower layer identifier ** - ** msg: The received EMM message ** - ** Others: None ** + ** Inputs: ueid: UE lower layer identifier ** + ** msg: The received EMM message ** + ** Others: None ** ** ** - ** Outputs: emm_cause: EMM cause code ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: emm_cause: EMM cause code ** + ** Return: RETURNok, RETURNerror ** + ** 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; int rc; LOG_TRACE(INFO, "EMMAS-SAP - Received EMM Status message (cause=%d)", - msg->emmcause); + msg->emmcause); /* * Message checking @@ -95,19 +95,19 @@ int emm_recv_status(unsigned int ueid, emm_status_msg* msg, int* emm_cause) #ifdef NAS_UE /**************************************************************************** ** ** - ** Name: emm_recv_attach_accept() ** + ** Name: emm_recv_attach_accept() ** ** ** ** Description: Processes Attach Accept message ** ** ** - ** Inputs: msg: The received EMM message ** - ** Others: None ** + ** Inputs: msg: The received EMM message ** + ** Others: None ** ** ** - ** Outputs: emm_cause: EMM cause code ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: emm_cause: EMM cause code ** + ** Return: RETURNok, RETURNerror ** + ** 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; @@ -119,24 +119,22 @@ int emm_recv_attach_accept(attach_accept_msg* msg, int* emm_cause) * Message checking */ if (msg->tailist.typeoflist != - TRACKING_AREA_IDENTITY_LIST_ONE_PLMN_CONSECUTIVE_TACS) { - /* 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) { - /* 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) && - (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; + TRACKING_AREA_IDENTITY_LIST_ONE_PLMN_CONSECUTIVE_TACS) { + /* 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) { + /* 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) && + (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; } /* Handle message checking error */ if (*emm_cause != EMM_CAUSE_SUCCESS) { - LOG_FUNC_RETURN (RETURNerror); + LOG_FUNC_RETURN (RETURNerror); } /* @@ -146,107 +144,107 @@ int emm_recv_attach_accept(attach_accept_msg* msg, int* emm_cause) long T3412, T3402 = -1, T3423 = -1; T3412 = gprs_timer_value(&msg->t3412value); if (msg->presencemask & ATTACH_ACCEPT_T3402_VALUE_PRESENT) { - T3402 = gprs_timer_value(&msg->t3402value); + T3402 = gprs_timer_value(&msg->t3402value); } if (msg->presencemask & ATTACH_ACCEPT_T3423_VALUE_PRESENT) { - T3423 = gprs_timer_value(&msg->t3423value); + T3423 = gprs_timer_value(&msg->t3423value); } /* Get the tracking area list the UE is registered to */ int n_tais = msg->tailist.numberofelements; tai_t tai[n_tais]; for (int i = 0; i < n_tais; i++) { - tai[i].plmn.MCCdigit1 = msg->tailist.mccdigit1; - tai[i].plmn.MCCdigit2 = msg->tailist.mccdigit2; - tai[i].plmn.MCCdigit3 = msg->tailist.mccdigit3; - tai[i].plmn.MNCdigit1 = msg->tailist.mncdigit1; - tai[i].plmn.MNCdigit2 = msg->tailist.mncdigit2; - tai[i].plmn.MNCdigit3 = msg->tailist.mncdigit3; - tai[i].tac = msg->tailist.tac + i; + tai[i].plmn.MCCdigit1 = msg->tailist.mccdigit1; + tai[i].plmn.MCCdigit2 = msg->tailist.mccdigit2; + tai[i].plmn.MCCdigit3 = msg->tailist.mccdigit3; + tai[i].plmn.MNCdigit1 = msg->tailist.mncdigit1; + tai[i].plmn.MNCdigit2 = msg->tailist.mncdigit2; + tai[i].plmn.MNCdigit3 = msg->tailist.mncdigit3; + 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; - guti.gummei.plmn.MCCdigit1 = msg->guti.guti.mccdigit1; - guti.gummei.plmn.MCCdigit2 = msg->guti.guti.mccdigit2; - guti.gummei.plmn.MCCdigit3 = msg->guti.guti.mccdigit3; - guti.gummei.plmn.MNCdigit1 = msg->guti.guti.mncdigit1; - guti.gummei.plmn.MNCdigit2 = msg->guti.guti.mncdigit2; - guti.gummei.plmn.MNCdigit3 = msg->guti.guti.mncdigit3; - guti.gummei.MMEgid = msg->guti.guti.mmegroupid; - guti.gummei.MMEcode = msg->guti.guti.mmecode; - guti.m_tmsi = msg->guti.guti.mtmsi; + pguti = &guti; + guti.gummei.plmn.MCCdigit1 = msg->guti.guti.mccdigit1; + guti.gummei.plmn.MCCdigit2 = msg->guti.guti.mccdigit2; + guti.gummei.plmn.MCCdigit3 = msg->guti.guti.mccdigit3; + guti.gummei.plmn.MNCdigit1 = msg->guti.guti.mncdigit1; + guti.gummei.plmn.MNCdigit2 = msg->guti.guti.mncdigit2; + guti.gummei.plmn.MNCdigit3 = msg->guti.guti.mncdigit3; + guti.gummei.MMEgid = msg->guti.guti.mmegroupid; + guti.gummei.MMEcode = msg->guti.guti.mmecode; + guti.m_tmsi = msg->guti.guti.mtmsi; } /* Get the list of equivalent PLMNs */ int n_eplmns = 0; plmn_t eplmn; if (msg->presencemask & ATTACH_ACCEPT_EQUIVALENT_PLMNS_PRESENT) { - n_eplmns = 1; - eplmn.MCCdigit1 = msg->equivalentplmns.mccdigit1; - eplmn.MCCdigit2 = msg->equivalentplmns.mccdigit2; - eplmn.MCCdigit3 = msg->equivalentplmns.mccdigit3; - eplmn.MNCdigit1 = msg->equivalentplmns.mncdigit1; - eplmn.MNCdigit2 = msg->equivalentplmns.mncdigit2; - eplmn.MNCdigit3 = msg->equivalentplmns.mncdigit3; + n_eplmns = 1; + eplmn.MCCdigit1 = msg->equivalentplmns.mccdigit1; + eplmn.MCCdigit2 = msg->equivalentplmns.mccdigit2; + eplmn.MCCdigit3 = msg->equivalentplmns.mccdigit3; + eplmn.MNCdigit1 = msg->equivalentplmns.mncdigit1; + eplmn.MNCdigit2 = msg->equivalentplmns.mncdigit2; + eplmn.MNCdigit3 = msg->equivalentplmns.mncdigit3; } /* Execute attach procedure accepted by the network */ rc = emm_proc_attach_accept(T3412, T3402, T3423, n_tais, tai, pguti, - n_eplmns, &eplmn, - &msg->esmmessagecontainer.esmmessagecontainercontents); + n_eplmns, &eplmn, + &msg->esmmessagecontainer.esmmessagecontainercontents); LOG_FUNC_RETURN (rc); } /**************************************************************************** ** ** - ** Name: emm_recv_attach_reject() ** + ** Name: emm_recv_attach_reject() ** ** ** ** Description: Processes Attach Reject message ** ** ** - ** Inputs: msg: The received EMM message ** - ** Others: None ** + ** Inputs: msg: The received EMM message ** + ** Others: None ** ** ** - ** Outputs: emm_cause: EMM cause code ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: emm_cause: EMM cause code ** + ** Return: RETURNok, RETURNerror ** + ** 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; int rc; LOG_TRACE(INFO, "EMMAS-SAP - Received Attach Reject message (cause=%d)", - msg->emmcause); + msg->emmcause); /* * Message checking */ if ( (msg->emmcause == EMM_CAUSE_ESM_FAILURE) && - !(msg->presencemask & ATTACH_REJECT_ESM_MESSAGE_CONTAINER_PRESENT) ) { - /* The ATTACH REJECT message shall be combined with a PDN - * CONNECTIVITY REJECT message contained in the ESM message - * container information element */ - *emm_cause = EMM_CAUSE_INVALID_MANDATORY_INFO; + !(msg->presencemask & ATTACH_REJECT_ESM_MESSAGE_CONTAINER_PRESENT) ) { + /* The ATTACH REJECT message shall be combined with a PDN + * CONNECTIVITY REJECT message contained in the ESM message + * container information element */ + *emm_cause = EMM_CAUSE_INVALID_MANDATORY_INFO; } /* Handle message checking error */ if (*emm_cause != EMM_CAUSE_SUCCESS) { - LOG_FUNC_RETURN (RETURNerror); + LOG_FUNC_RETURN (RETURNerror); } /* * Message processing */ if (msg->presencemask & ATTACH_REJECT_ESM_MESSAGE_CONTAINER_PRESENT) { - /* Execute attach procedure rejected by the network */ - rc = emm_proc_attach_reject(msg->emmcause, - &msg->esmmessagecontainer.esmmessagecontainercontents); + /* Execute attach procedure rejected by the network */ + rc = emm_proc_attach_reject(msg->emmcause, + &msg->esmmessagecontainer.esmmessagecontainercontents); } else { - /* Execute attach procedure rejected by the network */ - rc = emm_proc_attach_reject(msg->emmcause, NULL); + /* Execute attach procedure rejected by the network */ + rc = emm_proc_attach_reject(msg->emmcause, NULL); } LOG_FUNC_RETURN (rc); @@ -254,19 +252,19 @@ int emm_recv_attach_reject(attach_reject_msg* msg, int* emm_cause) /**************************************************************************** ** ** - ** Name: emm_recv_detach_accept() ** + ** Name: emm_recv_detach_accept() ** ** ** ** Description: Processes Detach Accept message ** ** ** - ** Inputs: msg: The received EMM message ** - ** Others: None ** + ** Inputs: msg: The received EMM message ** + ** Others: None ** ** ** - ** Outputs: emm_cause: EMM cause code ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: emm_cause: EMM cause code ** + ** Return: RETURNok, RETURNerror ** + ** 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; @@ -285,19 +283,19 @@ int emm_recv_detach_accept(detach_accept_msg* msg, int* emm_cause) /**************************************************************************** ** ** - ** Name: emm_recv_identity_request() ** + ** Name: emm_recv_identity_request() ** ** ** ** Description: Processes Identity Request message ** ** ** - ** Inputs: msg: The received EMM message ** - ** Others: None ** + ** Inputs: msg: The received EMM message ** + ** Others: None ** ** ** - ** Outputs: emm_cause: EMM cause code ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: emm_cause: EMM cause code ** + ** Return: RETURNok, RETURNerror ** + ** 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; @@ -311,16 +309,16 @@ int emm_recv_identity_request(identity_request_msg* msg, int* emm_cause) /* Get the requested identity type */ emm_proc_identity_type_t type; if (msg->identitytype == IDENTITY_TYPE_2_IMSI) { - type = EMM_IDENT_TYPE_IMSI; + type = EMM_IDENT_TYPE_IMSI; } else if (msg->identitytype == IDENTITY_TYPE_2_IMEI) { - type = EMM_IDENT_TYPE_IMEI; + type = EMM_IDENT_TYPE_IMEI; } else if (msg->identitytype == IDENTITY_TYPE_2_IMEISV) { - type = EMM_IDENT_TYPE_IMEISV; + type = EMM_IDENT_TYPE_IMEISV; } else if (msg->identitytype == IDENTITY_TYPE_2_TMSI) { - type = EMM_IDENT_TYPE_TMSI; + type = EMM_IDENT_TYPE_TMSI; } else { - /* All other values are interpreted as IMSI */ - type = EMM_IDENT_TYPE_IMSI; + /* All other values are interpreted as IMSI */ + type = EMM_IDENT_TYPE_IMSI; } /* Execute the identification procedure initiated by the network */ @@ -331,20 +329,20 @@ int emm_recv_identity_request(identity_request_msg* msg, int* emm_cause) /**************************************************************************** ** ** - ** Name: emm_recv_authentication_request() ** + ** Name: emm_recv_authentication_request() ** ** ** ** Description: Processes Authentication Request message ** ** ** - ** Inputs: msg: The received EMM message ** - ** Others: None ** + ** Inputs: msg: The received EMM message ** + ** Others: None ** ** ** - ** Outputs: emm_cause: EMM cause code ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: emm_cause: EMM cause code ** + ** Return: RETURNok, RETURNerror ** + ** 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; @@ -356,43 +354,43 @@ int emm_recv_authentication_request(authentication_request_msg* msg, * Message checking */ if ( (msg->authenticationparameterrand.rand.length == 0) || - (msg->authenticationparameterautn.autn.length == 0) ) { - /* RAND and AUTN parameters shall not be null */ - *emm_cause = EMM_CAUSE_INVALID_MANDATORY_INFO; + (msg->authenticationparameterautn.autn.length == 0) ) { + /* RAND and AUTN parameters shall not be null */ + *emm_cause = EMM_CAUSE_INVALID_MANDATORY_INFO; } /* Handle message checking error */ if (*emm_cause != EMM_CAUSE_SUCCESS) { - LOG_FUNC_RETURN (RETURNerror); + LOG_FUNC_RETURN (RETURNerror); } /* * Message processing */ /* Execute the authentication procedure initiated by the network */ rc = emm_proc_authentication_request( - msg->naskeysetidentifierasme.tsc != NAS_KEY_SET_IDENTIFIER_MAPPED, - msg->naskeysetidentifierasme.naskeysetidentifier, - &msg->authenticationparameterrand.rand, - &msg->authenticationparameterautn.autn); + msg->naskeysetidentifierasme.tsc != NAS_KEY_SET_IDENTIFIER_MAPPED, + msg->naskeysetidentifierasme.naskeysetidentifier, + &msg->authenticationparameterrand.rand, + &msg->authenticationparameterautn.autn); LOG_FUNC_RETURN (rc); } /**************************************************************************** ** ** - ** Name: emm_recv_authentication_reject() ** + ** Name: emm_recv_authentication_reject() ** ** ** ** Description: Processes Authentication Reject message ** ** ** - ** Inputs: msg: The received EMM message ** - ** Others: None ** + ** Inputs: msg: The received EMM message ** + ** Others: None ** ** ** - ** Outputs: emm_cause: EMM cause code ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: emm_cause: EMM cause code ** + ** Return: RETURNok, RETURNerror ** + ** 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; @@ -411,20 +409,20 @@ int emm_recv_authentication_reject(authentication_reject_msg* msg, /**************************************************************************** ** ** - ** Name: emm_recv_security_mode_command() ** + ** Name: emm_recv_security_mode_command() ** ** ** ** Description: Processes Security Mode Command message ** ** ** - ** Inputs: msg: The received EMM message ** - ** Others: None ** + ** Inputs: msg: The received EMM message ** + ** Others: None ** ** ** - ** Outputs: emm_cause: EMM cause code ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: emm_cause: EMM cause code ** + ** Return: RETURNok, RETURNerror ** + ** 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; @@ -437,17 +435,17 @@ int emm_recv_security_mode_command(security_mode_command_msg* msg, */ /* Execute the security mode control procedure initiated by the network */ rc = emm_proc_security_mode_command( - msg->naskeysetidentifier.tsc != NAS_KEY_SET_IDENTIFIER_MAPPED, - msg->naskeysetidentifier.naskeysetidentifier, - msg->selectednassecurityalgorithms.typeofcipheringalgorithm, - msg->selectednassecurityalgorithms.typeofintegrityalgorithm, - msg->replayeduesecuritycapabilities.eea, - msg->replayeduesecuritycapabilities.eia); + msg->naskeysetidentifier.tsc != NAS_KEY_SET_IDENTIFIER_MAPPED, + msg->naskeysetidentifier.naskeysetidentifier, + msg->selectednassecurityalgorithms.typeofcipheringalgorithm, + msg->selectednassecurityalgorithms.typeofintegrityalgorithm, + msg->replayeduesecuritycapabilities.eea, + msg->replayeduesecuritycapabilities.eia); LOG_FUNC_RETURN (rc); } -#endif // NAS_UE +#endif // NAS_UE /* * -------------------------------------------------------------------------- @@ -457,21 +455,21 @@ int emm_recv_security_mode_command(security_mode_command_msg* msg, #ifdef NAS_MME /**************************************************************************** ** ** - ** Name: emm_recv_attach_request() ** + ** Name: emm_recv_attach_request() ** ** ** ** Description: Processes Attach Request message ** ** ** - ** Inputs: ueid: UE lower layer identifier ** - ** msg: The received EMM message ** - ** Others: None ** + ** Inputs: ueid: UE lower layer identifier ** + ** msg: The received EMM message ** + ** Others: None ** ** ** - ** Outputs: emm_cause: EMM cause code ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: emm_cause: EMM cause code ** + ** Return: RETURNok, RETURNerror ** + ** 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; @@ -486,149 +484,143 @@ int emm_recv_attach_request(unsigned int ueid, const attach_request_msg* msg, #if !defined(UPDATE_RELEASE_9) /* SR: In releases 9 and beyond the mandatory ie (old GUTI) has been removed */ if ( (msg->oldgutiorimsi.guti.typeofidentity == EPS_MOBILE_IDENTITY_GUTI) && - !(msg->presencemask & ATTACH_REQUEST_OLD_GUTI_TYPE_PRESENT) ) { - /* The Old GUTI type IE shall be included if the type of identity - * in the EPS mobile identity IE is set to "GUTI" */ - *emm_cause = EMM_CAUSE_INVALID_MANDATORY_INFO; + !(msg->presencemask & ATTACH_REQUEST_OLD_GUTI_TYPE_PRESENT) ) { + /* The Old GUTI type IE shall be included if the type of identity + * in the EPS mobile identity IE is set to "GUTI" */ + *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 */ - *emm_cause = EMM_CAUSE_PROTOCOL_ERROR; - LOG_TRACE(WARNING, "EMMAS-SAP - [%08x] - Non zero spare bits is suspicious", - ueid); - } + if (msg->uenetworkcapability.spare != 0b000) { + /* Spare bits shall be coded as zero */ + *emm_cause = EMM_CAUSE_PROTOCOL_ERROR; + LOG_TRACE(WARNING, "EMMAS-SAP - [%08x] - Non zero spare bits is suspicious", + ueid); + } /* Handle message checking error */ if (*emm_cause != EMM_CAUSE_SUCCESS) { - /* 3GPP TS 24.301, section 5.5.1.2.7, case b - * Perform protocol error abnormal case on the network side */ - rc = emm_proc_attach_reject(ueid, *emm_cause); - *emm_cause = EMM_CAUSE_SUCCESS; - LOG_FUNC_RETURN (rc); + /* 3GPP TS 24.301, section 5.5.1.2.7, case b + * Perform protocol error abnormal case on the network side */ + rc = emm_proc_attach_reject(ueid, *emm_cause); + *emm_cause = EMM_CAUSE_SUCCESS; + LOG_FUNC_RETURN (rc); } /* * Message processing */ /* Get the EPS attach type */ if (msg->epsattachtype == EPS_ATTACH_TYPE_EPS) { - type = EMM_ATTACH_TYPE_EPS; + type = EMM_ATTACH_TYPE_EPS; } else if (msg->epsattachtype == EPS_ATTACH_TYPE_IMSI) { - type = EMM_ATTACH_TYPE_IMSI; + type = EMM_ATTACH_TYPE_IMSI; } else if (msg->epsattachtype == EPS_ATTACH_TYPE_EMERGENCY) { - type = EMM_ATTACH_TYPE_EMERGENCY; + type = EMM_ATTACH_TYPE_EMERGENCY; } else if (msg->epsattachtype == EPS_ATTACH_TYPE_RESERVED) { - type = EMM_ATTACH_TYPE_RESERVED; + type = EMM_ATTACH_TYPE_RESERVED; } else { - /* All other values shall be interpreted as "EPS attach" */ - type = EMM_ATTACH_TYPE_EPS; + /* All other values shall be interpreted as "EPS attach" */ + type = EMM_ATTACH_TYPE_EPS; } /* Get the EPS mobile identity */ 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) - { - /* Get the GUTI */ - p_guti = &guti; - guti.gummei.plmn.MCCdigit1 = msg->oldgutiorimsi.guti.mccdigit1; - guti.gummei.plmn.MCCdigit2 = msg->oldgutiorimsi.guti.mccdigit2; - guti.gummei.plmn.MCCdigit3 = msg->oldgutiorimsi.guti.mccdigit3; - guti.gummei.plmn.MNCdigit1 = msg->oldgutiorimsi.guti.mncdigit1; - guti.gummei.plmn.MNCdigit2 = msg->oldgutiorimsi.guti.mncdigit2; - guti.gummei.plmn.MNCdigit3 = msg->oldgutiorimsi.guti.mncdigit3; - 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) - { - /* Get the IMSI */ - p_imsi = &imsi; - imsi.u.num.digit1 = msg->oldgutiorimsi.imsi.digit1; - imsi.u.num.digit2 = msg->oldgutiorimsi.imsi.digit2; - imsi.u.num.digit3 = msg->oldgutiorimsi.imsi.digit3; - imsi.u.num.digit4 = msg->oldgutiorimsi.imsi.digit4; - imsi.u.num.digit5 = msg->oldgutiorimsi.imsi.digit5; - imsi.u.num.digit6 = msg->oldgutiorimsi.imsi.digit6; - imsi.u.num.digit7 = msg->oldgutiorimsi.imsi.digit7; - imsi.u.num.digit8 = msg->oldgutiorimsi.imsi.digit8; - imsi.u.num.digit9 = msg->oldgutiorimsi.imsi.digit9; - imsi.u.num.digit10 = msg->oldgutiorimsi.imsi.digit10; - imsi.u.num.digit11 = msg->oldgutiorimsi.imsi.digit11; - imsi.u.num.digit12 = msg->oldgutiorimsi.imsi.digit12; - imsi.u.num.digit13 = msg->oldgutiorimsi.imsi.digit13; - 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) - { - /* Get the IMEI */ - p_imei = &imei; - imei.u.num.digit1 = msg->oldgutiorimsi.imei.digit1; - imei.u.num.digit2 = msg->oldgutiorimsi.imei.digit2; - imei.u.num.digit3 = msg->oldgutiorimsi.imei.digit3; - imei.u.num.digit4 = msg->oldgutiorimsi.imei.digit4; - imei.u.num.digit5 = msg->oldgutiorimsi.imei.digit5; - imei.u.num.digit6 = msg->oldgutiorimsi.imei.digit6; - imei.u.num.digit7 = msg->oldgutiorimsi.imei.digit7; - imei.u.num.digit8 = msg->oldgutiorimsi.imei.digit8; - imei.u.num.digit9 = msg->oldgutiorimsi.imei.digit9; - imei.u.num.digit10 = msg->oldgutiorimsi.imei.digit10; - imei.u.num.digit11 = msg->oldgutiorimsi.imei.digit11; - imei.u.num.digit12 = msg->oldgutiorimsi.imei.digit12; - imei.u.num.digit13 = msg->oldgutiorimsi.imei.digit13; - imei.u.num.digit14 = msg->oldgutiorimsi.imei.digit14; - imei.u.num.digit15 = msg->oldgutiorimsi.imei.digit15; - imei.u.num.parity = msg->oldgutiorimsi.imei.oddeven; + if (msg->oldgutiorimsi.guti.typeofidentity == EPS_MOBILE_IDENTITY_GUTI) { + /* Get the GUTI */ + p_guti = &guti; + guti.gummei.plmn.MCCdigit1 = msg->oldgutiorimsi.guti.mccdigit1; + guti.gummei.plmn.MCCdigit2 = msg->oldgutiorimsi.guti.mccdigit2; + guti.gummei.plmn.MCCdigit3 = msg->oldgutiorimsi.guti.mccdigit3; + guti.gummei.plmn.MNCdigit1 = msg->oldgutiorimsi.guti.mncdigit1; + guti.gummei.plmn.MNCdigit2 = msg->oldgutiorimsi.guti.mncdigit2; + guti.gummei.plmn.MNCdigit3 = msg->oldgutiorimsi.guti.mncdigit3; + 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) { + /* Get the IMSI */ + p_imsi = &imsi; + imsi.u.num.digit1 = msg->oldgutiorimsi.imsi.digit1; + imsi.u.num.digit2 = msg->oldgutiorimsi.imsi.digit2; + imsi.u.num.digit3 = msg->oldgutiorimsi.imsi.digit3; + imsi.u.num.digit4 = msg->oldgutiorimsi.imsi.digit4; + imsi.u.num.digit5 = msg->oldgutiorimsi.imsi.digit5; + imsi.u.num.digit6 = msg->oldgutiorimsi.imsi.digit6; + imsi.u.num.digit7 = msg->oldgutiorimsi.imsi.digit7; + imsi.u.num.digit8 = msg->oldgutiorimsi.imsi.digit8; + imsi.u.num.digit9 = msg->oldgutiorimsi.imsi.digit9; + imsi.u.num.digit10 = msg->oldgutiorimsi.imsi.digit10; + imsi.u.num.digit11 = msg->oldgutiorimsi.imsi.digit11; + imsi.u.num.digit12 = msg->oldgutiorimsi.imsi.digit12; + imsi.u.num.digit13 = msg->oldgutiorimsi.imsi.digit13; + 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) { + /* Get the IMEI */ + p_imei = &imei; + imei.u.num.digit1 = msg->oldgutiorimsi.imei.digit1; + imei.u.num.digit2 = msg->oldgutiorimsi.imei.digit2; + imei.u.num.digit3 = msg->oldgutiorimsi.imei.digit3; + imei.u.num.digit4 = msg->oldgutiorimsi.imei.digit4; + imei.u.num.digit5 = msg->oldgutiorimsi.imei.digit5; + imei.u.num.digit6 = msg->oldgutiorimsi.imei.digit6; + imei.u.num.digit7 = msg->oldgutiorimsi.imei.digit7; + imei.u.num.digit8 = msg->oldgutiorimsi.imei.digit8; + imei.u.num.digit9 = msg->oldgutiorimsi.imei.digit9; + imei.u.num.digit10 = msg->oldgutiorimsi.imei.digit10; + imei.u.num.digit11 = msg->oldgutiorimsi.imei.digit11; + imei.u.num.digit12 = msg->oldgutiorimsi.imei.digit12; + imei.u.num.digit13 = msg->oldgutiorimsi.imei.digit13; + imei.u.num.digit14 = msg->oldgutiorimsi.imei.digit14; + imei.u.num.digit15 = msg->oldgutiorimsi.imei.digit15; + imei.u.num.parity = msg->oldgutiorimsi.imei.oddeven; } /* TODO: Get the UE network capabilities */ /* Get the Last visited registered TAI */ tai_t tai, *p_tai = NULL; if (msg->presencemask & ATTACH_REQUEST_LAST_VISITED_REGISTERED_TAI_PRESENT) { - p_tai = &tai; - tai.plmn.MCCdigit1 = msg->lastvisitedregisteredtai.mccdigit1; - tai.plmn.MCCdigit2 = msg->lastvisitedregisteredtai.mccdigit2; - tai.plmn.MCCdigit3 = msg->lastvisitedregisteredtai.mccdigit3; - tai.plmn.MNCdigit1 = msg->lastvisitedregisteredtai.mncdigit1; - tai.plmn.MNCdigit2 = msg->lastvisitedregisteredtai.mncdigit2; - tai.plmn.MNCdigit3 = msg->lastvisitedregisteredtai.mncdigit3; - tai.tac = msg->lastvisitedregisteredtai.tac; + p_tai = &tai; + tai.plmn.MCCdigit1 = msg->lastvisitedregisteredtai.mccdigit1; + tai.plmn.MCCdigit2 = msg->lastvisitedregisteredtai.mccdigit2; + tai.plmn.MCCdigit3 = msg->lastvisitedregisteredtai.mccdigit3; + tai.plmn.MNCdigit1 = msg->lastvisitedregisteredtai.mncdigit1; + tai.plmn.MNCdigit2 = msg->lastvisitedregisteredtai.mncdigit2; + tai.plmn.MNCdigit3 = msg->lastvisitedregisteredtai.mncdigit3; + tai.tac = msg->lastvisitedregisteredtai.tac; } /* Execute the requested UE attach procedure */ rc = emm_proc_attach_request(ueid, type, - msg->naskeysetidentifier.tsc != NAS_KEY_SET_IDENTIFIER_MAPPED, - msg->naskeysetidentifier.naskeysetidentifier, - msg->oldgutitype != GUTI_MAPPED, p_guti, p_imsi, p_imei, p_tai, - msg->uenetworkcapability.eea, msg->uenetworkcapability.eia, - &msg->esmmessagecontainer.esmmessagecontainercontents); + msg->naskeysetidentifier.tsc != NAS_KEY_SET_IDENTIFIER_MAPPED, + msg->naskeysetidentifier.naskeysetidentifier, + msg->oldgutitype != GUTI_MAPPED, p_guti, p_imsi, p_imei, p_tai, + msg->uenetworkcapability.eea, msg->uenetworkcapability.eia, + &msg->esmmessagecontainer.esmmessagecontainercontents); LOG_FUNC_RETURN (rc); } /**************************************************************************** ** ** - ** Name: emm_recv_attach_complete() ** + ** Name: emm_recv_attach_complete() ** ** ** ** Description: Processes Attach Complete message ** ** ** - ** Inputs: ueid: UE lower layer identifier ** - ** msg: The received EMM message ** - ** Others: None ** + ** Inputs: ueid: UE lower layer identifier ** + ** msg: The received EMM message ** + ** Others: None ** ** ** - ** Outputs: emm_cause: EMM cause code ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: emm_cause: EMM cause code ** + ** Return: RETURNok, RETURNerror ** + ** 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; @@ -638,28 +630,28 @@ int emm_recv_attach_complete(unsigned int ueid, const attach_complete_msg* msg, /* Execute the attach procedure completion */ rc = emm_proc_attach_complete(ueid, - &msg->esmmessagecontainer.esmmessagecontainercontents); + &msg->esmmessagecontainer.esmmessagecontainercontents); LOG_FUNC_RETURN (rc); } /**************************************************************************** ** ** - ** Name: emm_recv_detach_request() ** + ** Name: emm_recv_detach_request() ** ** ** ** Description: Processes Detach Request message ** ** ** - ** Inputs: ueid: UE lower layer identifier ** - ** msg: The received EMM message ** - ** Others: None ** + ** Inputs: ueid: UE lower layer identifier ** + ** msg: The received EMM message ** + ** Others: None ** ** ** - ** Outputs: emm_cause: EMM cause code ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: emm_cause: EMM cause code ** + ** Return: RETURNok, RETURNerror ** + ** 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; @@ -673,108 +665,103 @@ int emm_recv_detach_request(unsigned int ueid, const detach_request_msg* msg, /* Get the detach type */ emm_proc_detach_type_t type; if (msg->detachtype.typeofdetach == DETACH_TYPE_EPS) { - type = EMM_DETACH_TYPE_EPS; + type = EMM_DETACH_TYPE_EPS; } else if (msg->detachtype.typeofdetach == DETACH_TYPE_IMSI) { - type = EMM_DETACH_TYPE_IMSI; + type = EMM_DETACH_TYPE_IMSI; } else if (msg->detachtype.typeofdetach == DETACH_TYPE_EPS_IMSI) { - type = EMM_DETACH_TYPE_EPS_IMSI; + type = EMM_DETACH_TYPE_EPS_IMSI; } else if (msg->detachtype.typeofdetach == DETACH_TYPE_RESERVED_1) { - type = EMM_DETACH_TYPE_RESERVED; + type = EMM_DETACH_TYPE_RESERVED; } else if (msg->detachtype.typeofdetach == DETACH_TYPE_RESERVED_2) { - type = EMM_DETACH_TYPE_RESERVED; + type = EMM_DETACH_TYPE_RESERVED; } else { - /* All other values are interpreted as "combined EPS/IMSI detach" */ - type = DETACH_TYPE_EPS_IMSI; + /* All other values are interpreted as "combined EPS/IMSI detach" */ + type = DETACH_TYPE_EPS_IMSI; } /* Get the EPS mobile identity */ 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) - { - /* Get the GUTI */ - p_guti = &guti; - guti.gummei.plmn.MCCdigit1 = msg->gutiorimsi.guti.mccdigit1; - guti.gummei.plmn.MCCdigit2 = msg->gutiorimsi.guti.mccdigit2; - guti.gummei.plmn.MCCdigit3 = msg->gutiorimsi.guti.mccdigit3; - guti.gummei.plmn.MNCdigit1 = msg->gutiorimsi.guti.mncdigit1; - guti.gummei.plmn.MNCdigit2 = msg->gutiorimsi.guti.mncdigit2; - guti.gummei.plmn.MNCdigit3 = msg->gutiorimsi.guti.mncdigit3; - 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) - { - /* Get the IMSI */ - p_imsi = &imsi; - imsi.u.num.digit1 = msg->gutiorimsi.imsi.digit1; - imsi.u.num.digit2 = msg->gutiorimsi.imsi.digit2; - imsi.u.num.digit3 = msg->gutiorimsi.imsi.digit3; - imsi.u.num.digit4 = msg->gutiorimsi.imsi.digit4; - imsi.u.num.digit5 = msg->gutiorimsi.imsi.digit5; - imsi.u.num.digit6 = msg->gutiorimsi.imsi.digit6; - imsi.u.num.digit7 = msg->gutiorimsi.imsi.digit7; - imsi.u.num.digit8 = msg->gutiorimsi.imsi.digit8; - imsi.u.num.digit9 = msg->gutiorimsi.imsi.digit9; - imsi.u.num.digit10 = msg->gutiorimsi.imsi.digit10; - imsi.u.num.digit11 = msg->gutiorimsi.imsi.digit11; - imsi.u.num.digit12 = msg->gutiorimsi.imsi.digit12; - imsi.u.num.digit13 = msg->gutiorimsi.imsi.digit13; - 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) - { - /* Get the IMEI */ - p_imei = &imei; - imei.u.num.digit1 = msg->gutiorimsi.imei.digit1; - imei.u.num.digit2 = msg->gutiorimsi.imei.digit2; - imei.u.num.digit3 = msg->gutiorimsi.imei.digit3; - imei.u.num.digit4 = msg->gutiorimsi.imei.digit4; - imei.u.num.digit5 = msg->gutiorimsi.imei.digit5; - imei.u.num.digit6 = msg->gutiorimsi.imei.digit6; - imei.u.num.digit7 = msg->gutiorimsi.imei.digit7; - imei.u.num.digit8 = msg->gutiorimsi.imei.digit8; - imei.u.num.digit9 = msg->gutiorimsi.imei.digit9; - imei.u.num.digit10 = msg->gutiorimsi.imei.digit10; - imei.u.num.digit11 = msg->gutiorimsi.imei.digit11; - imei.u.num.digit12 = msg->gutiorimsi.imei.digit12; - imei.u.num.digit13 = msg->gutiorimsi.imei.digit13; - imei.u.num.digit14 = msg->gutiorimsi.imei.digit14; - imei.u.num.digit15 = msg->gutiorimsi.imei.digit15; - imei.u.num.parity = msg->gutiorimsi.imei.oddeven; + if (msg->gutiorimsi.guti.typeofidentity == EPS_MOBILE_IDENTITY_GUTI) { + /* Get the GUTI */ + p_guti = &guti; + guti.gummei.plmn.MCCdigit1 = msg->gutiorimsi.guti.mccdigit1; + guti.gummei.plmn.MCCdigit2 = msg->gutiorimsi.guti.mccdigit2; + guti.gummei.plmn.MCCdigit3 = msg->gutiorimsi.guti.mccdigit3; + guti.gummei.plmn.MNCdigit1 = msg->gutiorimsi.guti.mncdigit1; + guti.gummei.plmn.MNCdigit2 = msg->gutiorimsi.guti.mncdigit2; + guti.gummei.plmn.MNCdigit3 = msg->gutiorimsi.guti.mncdigit3; + 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) { + /* Get the IMSI */ + p_imsi = &imsi; + imsi.u.num.digit1 = msg->gutiorimsi.imsi.digit1; + imsi.u.num.digit2 = msg->gutiorimsi.imsi.digit2; + imsi.u.num.digit3 = msg->gutiorimsi.imsi.digit3; + imsi.u.num.digit4 = msg->gutiorimsi.imsi.digit4; + imsi.u.num.digit5 = msg->gutiorimsi.imsi.digit5; + imsi.u.num.digit6 = msg->gutiorimsi.imsi.digit6; + imsi.u.num.digit7 = msg->gutiorimsi.imsi.digit7; + imsi.u.num.digit8 = msg->gutiorimsi.imsi.digit8; + imsi.u.num.digit9 = msg->gutiorimsi.imsi.digit9; + imsi.u.num.digit10 = msg->gutiorimsi.imsi.digit10; + imsi.u.num.digit11 = msg->gutiorimsi.imsi.digit11; + imsi.u.num.digit12 = msg->gutiorimsi.imsi.digit12; + imsi.u.num.digit13 = msg->gutiorimsi.imsi.digit13; + 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) { + /* Get the IMEI */ + p_imei = &imei; + imei.u.num.digit1 = msg->gutiorimsi.imei.digit1; + imei.u.num.digit2 = msg->gutiorimsi.imei.digit2; + imei.u.num.digit3 = msg->gutiorimsi.imei.digit3; + imei.u.num.digit4 = msg->gutiorimsi.imei.digit4; + imei.u.num.digit5 = msg->gutiorimsi.imei.digit5; + imei.u.num.digit6 = msg->gutiorimsi.imei.digit6; + imei.u.num.digit7 = msg->gutiorimsi.imei.digit7; + imei.u.num.digit8 = msg->gutiorimsi.imei.digit8; + imei.u.num.digit9 = msg->gutiorimsi.imei.digit9; + imei.u.num.digit10 = msg->gutiorimsi.imei.digit10; + imei.u.num.digit11 = msg->gutiorimsi.imei.digit11; + imei.u.num.digit12 = msg->gutiorimsi.imei.digit12; + imei.u.num.digit13 = msg->gutiorimsi.imei.digit13; + imei.u.num.digit14 = msg->gutiorimsi.imei.digit14; + imei.u.num.digit15 = msg->gutiorimsi.imei.digit15; + imei.u.num.parity = msg->gutiorimsi.imei.oddeven; } /* Execute the UE initiated detach procedure completion by the network */ rc = emm_proc_detach_request(ueid, type, - msg->detachtype.switchoff != DETACH_TYPE_NORMAL_DETACH, - msg->naskeysetidentifier.tsc != NAS_KEY_SET_IDENTIFIER_MAPPED, - msg->naskeysetidentifier.naskeysetidentifier, - p_guti, p_imsi, p_imei); + msg->detachtype.switchoff != DETACH_TYPE_NORMAL_DETACH, + msg->naskeysetidentifier.tsc != NAS_KEY_SET_IDENTIFIER_MAPPED, + msg->naskeysetidentifier.naskeysetidentifier, + p_guti, p_imsi, p_imei); LOG_FUNC_RETURN (rc); } /**************************************************************************** ** ** - ** Name: emm_recv_identity_response() ** + ** Name: emm_recv_identity_response() ** ** ** ** Description: Processes Identity Response message ** ** ** - ** Inputs: ueid: UE lower layer identifier ** - ** msg: The received EMM message ** - ** Others: None ** + ** Inputs: ueid: UE lower layer identifier ** + ** msg: The received EMM message ** + ** Others: None ** ** ** - ** Outputs: emm_cause: EMM cause code ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: emm_cause: EMM cause code ** + ** Return: RETURNok, RETURNerror ** + ** 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; @@ -789,95 +776,91 @@ int emm_recv_identity_response(unsigned int ueid, identity_response_msg* msg, imsi_t imsi, *p_imsi = NULL; imei_t imei, *p_imei = NULL; struct tmsi_struct_t { - uint8_t digit1:4; - uint8_t digit2:4; - uint8_t digit3:4; - uint8_t digit4:4; - uint8_t digit5:4; - uint8_t digit6:4; - uint8_t digit7:4; - uint8_t digit8:4; + uint8_t digit1:4; + uint8_t digit2:4; + uint8_t digit3:4; + uint8_t digit4:4; + uint8_t digit5:4; + uint8_t digit6:4; + uint8_t digit7:4; + uint8_t digit8:4; } tmsi, *p_tmsi = NULL; if (msg->mobileidentity.imsi.typeofidentity == MOBILE_IDENTITY_IMSI) { - /* Get the IMSI */ - p_imsi = &imsi; - imsi.u.num.digit1 = msg->mobileidentity.imsi.digit1; - imsi.u.num.digit2 = msg->mobileidentity.imsi.digit2; - imsi.u.num.digit3 = msg->mobileidentity.imsi.digit3; - imsi.u.num.digit4 = msg->mobileidentity.imsi.digit4; - imsi.u.num.digit5 = msg->mobileidentity.imsi.digit5; - imsi.u.num.digit6 = msg->mobileidentity.imsi.digit6; - imsi.u.num.digit7 = msg->mobileidentity.imsi.digit7; - imsi.u.num.digit8 = msg->mobileidentity.imsi.digit8; - imsi.u.num.digit9 = msg->mobileidentity.imsi.digit9; - imsi.u.num.digit10 = msg->mobileidentity.imsi.digit10; - imsi.u.num.digit11 = msg->mobileidentity.imsi.digit11; - imsi.u.num.digit12 = msg->mobileidentity.imsi.digit12; - imsi.u.num.digit13 = msg->mobileidentity.imsi.digit13; - 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)) - { - /* Get the IMEI */ - p_imei = &imei; - imei.u.num.digit1 = msg->mobileidentity.imei.digit1; - imei.u.num.digit2 = msg->mobileidentity.imei.digit2; - imei.u.num.digit3 = msg->mobileidentity.imei.digit3; - imei.u.num.digit4 = msg->mobileidentity.imei.digit4; - imei.u.num.digit5 = msg->mobileidentity.imei.digit5; - imei.u.num.digit6 = msg->mobileidentity.imei.digit6; - imei.u.num.digit7 = msg->mobileidentity.imei.digit7; - imei.u.num.digit8 = msg->mobileidentity.imei.digit8; - imei.u.num.digit9 = msg->mobileidentity.imei.digit9; - imei.u.num.digit10 = msg->mobileidentity.imei.digit10; - imei.u.num.digit11 = msg->mobileidentity.imei.digit11; - imei.u.num.digit12 = msg->mobileidentity.imei.digit12; - imei.u.num.digit13 = msg->mobileidentity.imei.digit13; - 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) - { - /* Get the TMSI */ - p_tmsi = &tmsi; - tmsi.digit1 = msg->mobileidentity.tmsi.digit2; - tmsi.digit2 = msg->mobileidentity.tmsi.digit3; - tmsi.digit3 = msg->mobileidentity.tmsi.digit4; - tmsi.digit4 = msg->mobileidentity.tmsi.digit5; - tmsi.digit5 = msg->mobileidentity.tmsi.digit6; - tmsi.digit6 = msg->mobileidentity.tmsi.digit7; - tmsi.digit7 = msg->mobileidentity.tmsi.digit8; - tmsi.digit8 = msg->mobileidentity.tmsi.digit9; + /* Get the IMSI */ + p_imsi = &imsi; + imsi.u.num.digit1 = msg->mobileidentity.imsi.digit1; + imsi.u.num.digit2 = msg->mobileidentity.imsi.digit2; + imsi.u.num.digit3 = msg->mobileidentity.imsi.digit3; + imsi.u.num.digit4 = msg->mobileidentity.imsi.digit4; + imsi.u.num.digit5 = msg->mobileidentity.imsi.digit5; + imsi.u.num.digit6 = msg->mobileidentity.imsi.digit6; + imsi.u.num.digit7 = msg->mobileidentity.imsi.digit7; + imsi.u.num.digit8 = msg->mobileidentity.imsi.digit8; + imsi.u.num.digit9 = msg->mobileidentity.imsi.digit9; + imsi.u.num.digit10 = msg->mobileidentity.imsi.digit10; + imsi.u.num.digit11 = msg->mobileidentity.imsi.digit11; + imsi.u.num.digit12 = msg->mobileidentity.imsi.digit12; + imsi.u.num.digit13 = msg->mobileidentity.imsi.digit13; + 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)) { + /* Get the IMEI */ + p_imei = &imei; + imei.u.num.digit1 = msg->mobileidentity.imei.digit1; + imei.u.num.digit2 = msg->mobileidentity.imei.digit2; + imei.u.num.digit3 = msg->mobileidentity.imei.digit3; + imei.u.num.digit4 = msg->mobileidentity.imei.digit4; + imei.u.num.digit5 = msg->mobileidentity.imei.digit5; + imei.u.num.digit6 = msg->mobileidentity.imei.digit6; + imei.u.num.digit7 = msg->mobileidentity.imei.digit7; + imei.u.num.digit8 = msg->mobileidentity.imei.digit8; + imei.u.num.digit9 = msg->mobileidentity.imei.digit9; + imei.u.num.digit10 = msg->mobileidentity.imei.digit10; + imei.u.num.digit11 = msg->mobileidentity.imei.digit11; + imei.u.num.digit12 = msg->mobileidentity.imei.digit12; + imei.u.num.digit13 = msg->mobileidentity.imei.digit13; + 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) { + /* Get the TMSI */ + p_tmsi = &tmsi; + tmsi.digit1 = msg->mobileidentity.tmsi.digit2; + tmsi.digit2 = msg->mobileidentity.tmsi.digit3; + tmsi.digit3 = msg->mobileidentity.tmsi.digit4; + tmsi.digit4 = msg->mobileidentity.tmsi.digit5; + tmsi.digit5 = msg->mobileidentity.tmsi.digit6; + tmsi.digit6 = msg->mobileidentity.tmsi.digit7; + tmsi.digit7 = msg->mobileidentity.tmsi.digit8; + tmsi.digit8 = msg->mobileidentity.tmsi.digit9; } /* 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); } /**************************************************************************** ** ** - ** Name: emm_recv_authentication_response() ** + ** Name: emm_recv_authentication_response() ** ** ** ** Description: Processes Authentication Response message ** ** ** - ** Inputs: ueid: UE lower layer identifier ** - ** msg: The received EMM message ** - ** Others: None ** + ** Inputs: ueid: UE lower layer identifier ** + ** msg: The received EMM message ** + ** Others: None ** ** ** - ** Outputs: emm_cause: EMM cause code ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: emm_cause: EMM cause code ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ 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; @@ -889,40 +872,40 @@ int emm_recv_authentication_response(unsigned int ueid, * Message checking */ if (msg->authenticationresponseparameter.res.length == 0) { - /* RES parameter shall not be null */ - *emm_cause = EMM_CAUSE_INVALID_MANDATORY_INFO; + /* RES parameter shall not be null */ + *emm_cause = EMM_CAUSE_INVALID_MANDATORY_INFO; } /* Handle message checking error */ if (*emm_cause != EMM_CAUSE_SUCCESS) { - LOG_FUNC_RETURN (RETURNerror); + LOG_FUNC_RETURN (RETURNerror); } /* * Message processing */ /* Execute the authentication completion procedure */ rc = emm_proc_authentication_complete(ueid, EMM_CAUSE_SUCCESS, - &msg->authenticationresponseparameter.res); + &msg->authenticationresponseparameter.res); LOG_FUNC_RETURN (rc); } /**************************************************************************** ** ** - ** Name: emm_recv_authentication_failure() ** + ** Name: emm_recv_authentication_failure() ** ** ** ** Description: Processes Authentication Failure message ** ** ** - ** Inputs: ueid: UE lower layer identifier ** - ** msg: The received EMM message ** - ** Others: None ** + ** Inputs: ueid: UE lower layer identifier ** + ** msg: The received EMM message ** + ** Others: None ** ** ** - ** Outputs: emm_cause: EMM cause code ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: emm_cause: EMM cause code ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ 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; @@ -934,45 +917,44 @@ int emm_recv_authentication_failure(unsigned int ueid, * Message checking */ 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) ) - { - /* AUTS parameter shall be present in case of "synch failure" */ - *emm_cause = EMM_CAUSE_INVALID_MANDATORY_INFO; + *emm_cause = EMM_CAUSE_INVALID_MANDATORY_INFO; + } 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; } /* Handle message checking error */ if (*emm_cause != EMM_CAUSE_SUCCESS) { - LOG_FUNC_RETURN (RETURNerror); + LOG_FUNC_RETURN (RETURNerror); } /* * Message processing */ /* Execute the authentication completion procedure */ rc = emm_proc_authentication_complete(ueid, msg->emmcause, - &msg->authenticationfailureparameter.auts); + &msg->authenticationfailureparameter.auts); LOG_FUNC_RETURN (rc); } /**************************************************************************** ** ** - ** Name: emm_recv_security_mode_complete() ** + ** Name: emm_recv_security_mode_complete() ** ** ** ** Description: Processes Security Mode Complete message ** ** ** - ** Inputs: ueid: UE lower layer identifier ** - ** msg: The received EMM message ** - ** Others: None ** + ** Inputs: ueid: UE lower layer identifier ** + ** msg: The received EMM message ** + ** Others: None ** ** ** - ** Outputs: emm_cause: EMM cause code ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: emm_cause: EMM cause code ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ 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; @@ -991,39 +973,39 @@ int emm_recv_security_mode_complete(unsigned int ueid, /**************************************************************************** ** ** - ** Name: emm_recv_security_mode_reject() ** + ** Name: emm_recv_security_mode_reject() ** ** ** ** Description: Processes Security Mode Reject message ** ** ** - ** Inputs: ueid: UE lower layer identifier ** - ** msg: The received EMM message ** - ** Others: None ** + ** Inputs: ueid: UE lower layer identifier ** + ** msg: The received EMM message ** + ** Others: None ** ** ** - ** Outputs: emm_cause: EMM cause code ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: emm_cause: EMM cause code ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ 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; int rc = RETURNok; LOG_TRACE(INFO, "EMMAS-SAP - Received Security Mode Reject message " - "(cause=%d)", msg->emmcause); + "(cause=%d)", msg->emmcause); /* * Message checking */ if (msg->emmcause == EMM_CAUSE_SUCCESS) { - *emm_cause = EMM_CAUSE_INVALID_MANDATORY_INFO; + *emm_cause = EMM_CAUSE_INVALID_MANDATORY_INFO; } /* Handle message checking error */ if (*emm_cause != EMM_CAUSE_SUCCESS) { - LOG_FUNC_RETURN (RETURNerror); + LOG_FUNC_RETURN (RETURNerror); } /* @@ -1034,4 +1016,4 @@ int emm_recv_security_mode_reject(unsigned int ueid, LOG_FUNC_RETURN (rc); } -#endif // NAS_MME +#endif // NAS_MME diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_recv.h b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_recv.h index 6bbc3ba21b..60fa19d72f 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_recv.h +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_recv.h @@ -1,22 +1,22 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source emm_recv.h +Source emm_recv.h -Version 0.1 +Version 0.1 -Date 2013/01/30 +Date 2013/01/30 -Product NAS stack +Product NAS stack -Subsystem EPS Mobility Management +Subsystem EPS Mobility Management -Author Frederic Maurel +Author Frederic Maurel -Description Defines functions executed at the EMMAS Service Access - Point upon receiving EPS Mobility Management messages - from the Access Stratum sublayer. +Description Defines functions executed at the EMMAS Service Access + Point upon receiving EPS Mobility Management messages + from the Access Stratum sublayer. *****************************************************************************/ #ifndef __EMM_RECV_H__ @@ -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__*/ diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_reg.c b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_reg.c index 92c433e6f7..f340fab1ea 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_reg.c +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_reg.c @@ -1,22 +1,22 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source emm_reg.c +Source emm_reg.c -Version 0.1 +Version 0.1 -Date 2012/10/16 +Date 2012/10/16 -Product NAS stack +Product NAS stack -Subsystem EPS Mobility Management +Subsystem EPS Mobility Management -Author Frederic Maurel +Author Frederic Maurel -Description Defines the EMMREG Service Access Point that provides - registration services for location updating and attach/detach - procedures. +Description Defines the EMMREG Service Access Point that provides + registration services for location updating and attach/detach + procedures. *****************************************************************************/ @@ -42,16 +42,16 @@ Description Defines the EMMREG Service Access Point that provides /**************************************************************************** ** ** - ** Name: emm_reg_initialize() ** + ** Name: emm_reg_initialize() ** ** ** ** Description: Initializes the EMMREG Service Access Point ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: None ** - ** Others: NONE ** + ** Outputs: None ** + ** Return: None ** + ** Others: NONE ** ** ** ***************************************************************************/ void emm_reg_initialize(void) @@ -66,19 +66,19 @@ void emm_reg_initialize(void) /**************************************************************************** ** ** - ** Name: emm_reg_send() ** + ** Name: emm_reg_send() ** ** ** ** Description: Processes the EMMREG Service Access Point primitive ** ** ** - ** Inputs: msg: The EMMREG-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The EMMREG-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ -int emm_reg_send(const emm_reg_t* msg) +int emm_reg_send(const emm_reg_t *msg) { LOG_FUNC_IN; diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_reg.h b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_reg.h index 7419f7eafe..6837b38015 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_reg.h +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_reg.h @@ -1,22 +1,22 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source emm_reg.h +Source emm_reg.h -Version 0.1 +Version 0.1 -Date 2012/10/16 +Date 2012/10/16 -Product NAS stack +Product NAS stack -Subsystem EPS Mobility Management +Subsystem EPS Mobility Management -Author Frederic Maurel +Author Frederic Maurel -Description Defines the EMMREG Service Access Point that provides - registration services for location updating and attach/detach - procedures. +Description Defines the EMMREG Service Access Point that provides + registration services for location updating and attach/detach + procedures. *****************************************************************************/ #ifndef __EMM_REG_H__ @@ -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__*/ diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_regDef.h b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_regDef.h index a73876e34c..7fd5fc232c 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_regDef.h +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_regDef.h @@ -1,22 +1,22 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source emm_regDef.h +Source emm_regDef.h -Version 0.1 +Version 0.1 -Date 2012/10/16 +Date 2012/10/16 -Product NAS stack +Product NAS stack -Subsystem EPS Mobility Management +Subsystem EPS Mobility Management -Author Frederic Maurel +Author Frederic Maurel -Description Defines the EMMREG Service Access Point that provides - registration services for location updating and attach/detach - procedures. +Description Defines the EMMREG Service Access Point that provides + registration services for location updating and attach/detach + procedures. *****************************************************************************/ #ifndef __EMM_REGDEF_H__ @@ -34,40 +34,40 @@ Description Defines the EMMREG Service Access Point that provides typedef enum { _EMMREG_START = 0, #ifdef NAS_UE - _EMMREG_S1_ENABLED, /* S1 mode is enabled */ - _EMMREG_S1_DISABLED, /* S1 mode is disabled */ - _EMMREG_NO_IMSI, /* The UE is powered on without a valid USIM */ - _EMMREG_NO_CELL, /* No available cell has been found */ - _EMMREG_REGISTER_REQ, /* Network registration procedure requested */ - _EMMREG_REGISTER_CNF, /* Network registration procedure succeed */ - _EMMREG_REGISTER_REJ, /* Network registration procedure rejected */ - _EMMREG_ATTACH_INIT, /* EPS network attach initiated */ - _EMMREG_ATTACH_REQ, /* EPS network attach requested */ - _EMMREG_ATTACH_FAILED, /* Attach attempt failed */ - _EMMREG_ATTACH_EXCEEDED, /* Attach attempt exceeded */ - _EMMREG_AUTH_REJ, /* Authentication rejected */ + _EMMREG_S1_ENABLED, /* S1 mode is enabled */ + _EMMREG_S1_DISABLED, /* S1 mode is disabled */ + _EMMREG_NO_IMSI, /* The UE is powered on without a valid USIM */ + _EMMREG_NO_CELL, /* No available cell has been found */ + _EMMREG_REGISTER_REQ, /* Network registration procedure requested */ + _EMMREG_REGISTER_CNF, /* Network registration procedure succeed */ + _EMMREG_REGISTER_REJ, /* Network registration procedure rejected */ + _EMMREG_ATTACH_INIT, /* EPS network attach initiated */ + _EMMREG_ATTACH_REQ, /* EPS network attach requested */ + _EMMREG_ATTACH_FAILED, /* Attach attempt failed */ + _EMMREG_ATTACH_EXCEEDED, /* Attach attempt exceeded */ + _EMMREG_AUTH_REJ, /* Authentication rejected */ #endif #ifdef NAS_MME - _EMMREG_COMMON_PROC_REQ, /* EMM common procedure requested */ - _EMMREG_COMMON_PROC_CNF, /* EMM common procedure successful */ - _EMMREG_COMMON_PROC_REJ, /* EMM common procedure failed */ - _EMMREG_PROC_ABORT, /* EMM procedure aborted */ + _EMMREG_COMMON_PROC_REQ, /* EMM common procedure requested */ + _EMMREG_COMMON_PROC_CNF, /* EMM common procedure successful */ + _EMMREG_COMMON_PROC_REJ, /* EMM common procedure failed */ + _EMMREG_PROC_ABORT, /* EMM procedure aborted */ #endif - _EMMREG_ATTACH_CNF, /* EPS network attach accepted */ - _EMMREG_ATTACH_REJ, /* EPS network attach rejected */ - _EMMREG_DETACH_INIT, /* Network detach initiated */ - _EMMREG_DETACH_REQ, /* Network detach requested */ - _EMMREG_DETACH_FAILED, /* Network detach attempt failed */ - _EMMREG_DETACH_CNF, /* Network detach accepted */ + _EMMREG_ATTACH_CNF, /* EPS network attach accepted */ + _EMMREG_ATTACH_REJ, /* EPS network attach rejected */ + _EMMREG_DETACH_INIT, /* Network detach initiated */ + _EMMREG_DETACH_REQ, /* Network detach requested */ + _EMMREG_DETACH_FAILED, /* Network detach attempt failed */ + _EMMREG_DETACH_CNF, /* Network detach accepted */ _EMMREG_TAU_REQ, _EMMREG_TAU_CNF, _EMMREG_TAU_REJ, _EMMREG_SERVICE_REQ, _EMMREG_SERVICE_CNF, _EMMREG_SERVICE_REJ, - _EMMREG_LOWERLAYER_SUCCESS, /* Data successfully delivered */ - _EMMREG_LOWERLAYER_FAILURE, /* Lower layer failure indication */ - _EMMREG_LOWERLAYER_RELEASE, /* NAS signalling connection released */ + _EMMREG_LOWERLAYER_SUCCESS, /* Data successfully delivered */ + _EMMREG_LOWERLAYER_FAILURE, /* Lower layer failure indication */ + _EMMREG_LOWERLAYER_RELEASE, /* NAS signalling connection released */ _EMMREG_END } emm_reg_primitive_t; @@ -81,8 +81,8 @@ typedef enum { * ---------------------------------------------------- */ typedef struct { - int index; /* Index of the currently selected PLMN in the ordered - * list of available PLMNs */ + int index; /* Index of the currently selected PLMN in the ordered + * list of available PLMNs */ } emm_reg_register_t; #endif @@ -91,8 +91,8 @@ typedef struct { * ------------------------------------- */ typedef struct { - int is_emergency; /* TRUE if the UE was attempting to register to - * the network for emergency services only */ + int is_emergency; /* TRUE if the UE was attempting to register to + * the network for emergency services only */ } emm_reg_attach_t; /* @@ -100,8 +100,8 @@ typedef struct { * ------------------------------------- */ typedef struct { - int switch_off; /* TRUE if the UE is switched off */ - int type; /* Network detach type */ + int switch_off; /* TRUE if the UE is switched off */ + int type; /* Network detach type */ } emm_reg_detach_t; #ifdef NAS_MME @@ -110,7 +110,7 @@ typedef struct { * ------------------------------------------ */ typedef struct { - int is_attached; /* UE context attach indicator */ + int is_attached; /* UE context attach indicator */ } emm_reg_common_t; #endif @@ -123,13 +123,13 @@ typedef struct { void *ctx; union { - emm_reg_attach_t attach; - emm_reg_detach_t detach; + emm_reg_attach_t attach; + emm_reg_detach_t detach; #ifdef NAS_UE - emm_reg_register_t regist; + emm_reg_register_t regist; #endif #ifdef NAS_MME - emm_reg_common_t common; + emm_reg_common_t common; #endif } u; } emm_reg_t; diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_sap.c b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_sap.c index 9ba72138d7..b02b82d87e 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_sap.c +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_sap.c @@ -1,23 +1,23 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source emm_sap.c +Source emm_sap.c -Version 0.1 +Version 0.1 -Date 2012/10/01 +Date 2012/10/01 -Product NAS stack +Product NAS stack -Subsystem EPS Mobility Management +Subsystem EPS Mobility Management -Author Frederic Maurel +Author Frederic Maurel -Description Defines the EMM Service Access Points at which the EPS - Mobility Management sublayer provides procedures for the - control of security and mobility when the User Equipment - is using the Evolved UTRA Network. +Description Defines the EMM Service Access Points at which the EPS + Mobility Management sublayer provides procedures for the + control of security and mobility when the User Equipment + is using the Evolved UTRA Network. *****************************************************************************/ @@ -43,16 +43,16 @@ Description Defines the EMM Service Access Points at which the EPS /**************************************************************************** ** ** - ** Name: emm_sap_initialize() ** + ** Name: emm_sap_initialize() ** ** ** ** Description: Initializes the EMM Service Access Points ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: None ** - ** Others: NONE ** + ** Outputs: None ** + ** Return: None ** + ** Others: NONE ** ** ** ***************************************************************************/ void emm_sap_initialize(void) @@ -68,19 +68,19 @@ void emm_sap_initialize(void) /**************************************************************************** ** ** - ** Name: emm_sap_send() ** + ** Name: emm_sap_send() ** ** ** ** Description: Processes the EMM Service Access Point primitive ** ** ** - ** Inputs: msg: The EMM-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The EMM-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: msg: The EMM-SAP primitive to process ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: msg: The EMM-SAP primitive to process ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ -int emm_sap_send(emm_sap_t* msg) +int emm_sap_send(emm_sap_t *msg) { LOG_FUNC_IN; @@ -90,26 +90,23 @@ int emm_sap_send(emm_sap_t* msg) /* Check the EMM-SAP primitive */ if ( (primitive > EMMREG_PRIMITIVE_MIN) && - (primitive < EMMREG_PRIMITIVE_MAX) ) { - /* Forward to the EMMREG-SAP */ - msg->u.emm_reg.primitive = primitive; - rc = emm_reg_send(&msg->u.emm_reg); + (primitive < EMMREG_PRIMITIVE_MAX) ) { + /* 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) && + (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) && + (primitive < EMMAS_PRIMITIVE_MAX) ) { + /* Forward to the EMMAS-SAP */ + msg->u.emm_as.primitive = primitive; + rc = emm_as_send(&msg->u.emm_as); + } else { + LOG_TRACE(WARNING, "EMM-SAP - Out of range primitive (%d)", primitive); } - 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) && - (primitive < EMMAS_PRIMITIVE_MAX) ) { - /* Forward to the EMMAS-SAP */ - msg->u.emm_as.primitive = primitive; - rc = emm_as_send(&msg->u.emm_as); - } - else { - LOG_TRACE(WARNING, "EMM-SAP - Out of range primitive (%d)", primitive); - } LOG_FUNC_RETURN (rc); } diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_sap.h b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_sap.h index 09bedaf3c4..12a43bc3c3 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_sap.h +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_sap.h @@ -1,23 +1,23 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source emm_sap.h +Source emm_sap.h -Version 0.1 +Version 0.1 -Date 2012/10/01 +Date 2012/10/01 -Product NAS stack +Product NAS stack -Subsystem EPS Mobility Management +Subsystem EPS Mobility Management -Author Frederic Maurel +Author Frederic Maurel -Description Defines the EMM Service Access Points at which the EPS - Mobility Management sublayer provides procedures for the - control of security and mobility when the User Equipment - is using the Evolved UTRA Network. +Description Defines the EMM Service Access Points at which the EPS + Mobility Management sublayer provides procedures for the + control of security and mobility when the User Equipment + is using the Evolved UTRA Network. *****************************************************************************/ #ifndef __EMM_SAP_H__ @@ -44,81 +44,81 @@ Description Defines the EMM Service Access Points at which the EPS typedef enum { /* EMMREG-SAP */ #ifdef NAS_UE - EMMREG_S1_ENABLED = _EMMREG_S1_ENABLED, - EMMREG_S1_DISABLED = _EMMREG_S1_DISABLED, - EMMREG_NO_IMSI = _EMMREG_NO_IMSI, - EMMREG_NO_CELL = _EMMREG_NO_CELL, - EMMREG_REGISTER_REQ = _EMMREG_REGISTER_REQ, - EMMREG_REGISTER_CNF = _EMMREG_REGISTER_CNF, - EMMREG_REGISTER_REJ = _EMMREG_REGISTER_REJ, - EMMREG_ATTACH_INIT = _EMMREG_ATTACH_INIT, - EMMREG_ATTACH_REQ = _EMMREG_ATTACH_REQ, - EMMREG_ATTACH_FAILED = _EMMREG_ATTACH_FAILED, - EMMREG_ATTACH_EXCEEDED = _EMMREG_ATTACH_EXCEEDED, - EMMREG_AUTH_REJ = _EMMREG_AUTH_REJ, + EMMREG_S1_ENABLED = _EMMREG_S1_ENABLED, + EMMREG_S1_DISABLED = _EMMREG_S1_DISABLED, + EMMREG_NO_IMSI = _EMMREG_NO_IMSI, + EMMREG_NO_CELL = _EMMREG_NO_CELL, + EMMREG_REGISTER_REQ = _EMMREG_REGISTER_REQ, + EMMREG_REGISTER_CNF = _EMMREG_REGISTER_CNF, + EMMREG_REGISTER_REJ = _EMMREG_REGISTER_REJ, + EMMREG_ATTACH_INIT = _EMMREG_ATTACH_INIT, + EMMREG_ATTACH_REQ = _EMMREG_ATTACH_REQ, + EMMREG_ATTACH_FAILED = _EMMREG_ATTACH_FAILED, + EMMREG_ATTACH_EXCEEDED = _EMMREG_ATTACH_EXCEEDED, + EMMREG_AUTH_REJ = _EMMREG_AUTH_REJ, #endif #ifdef NAS_MME - EMMREG_COMMON_PROC_REQ = _EMMREG_COMMON_PROC_REQ, - EMMREG_COMMON_PROC_CNF = _EMMREG_COMMON_PROC_CNF, - EMMREG_COMMON_PROC_REJ = _EMMREG_COMMON_PROC_REJ, - EMMREG_PROC_ABORT = _EMMREG_PROC_ABORT, + EMMREG_COMMON_PROC_REQ = _EMMREG_COMMON_PROC_REQ, + EMMREG_COMMON_PROC_CNF = _EMMREG_COMMON_PROC_CNF, + EMMREG_COMMON_PROC_REJ = _EMMREG_COMMON_PROC_REJ, + EMMREG_PROC_ABORT = _EMMREG_PROC_ABORT, #endif - EMMREG_ATTACH_CNF = _EMMREG_ATTACH_CNF, - EMMREG_ATTACH_REJ = _EMMREG_ATTACH_REJ, - EMMREG_DETACH_INIT = _EMMREG_DETACH_INIT, - EMMREG_DETACH_REQ = _EMMREG_DETACH_REQ, - EMMREG_DETACH_FAILED = _EMMREG_DETACH_FAILED, - EMMREG_DETACH_CNF = _EMMREG_DETACH_CNF, - EMMREG_TAU_REQ = _EMMREG_TAU_REQ, - EMMREG_TAU_CNF = _EMMREG_TAU_CNF, - EMMREG_TAU_REJ = _EMMREG_TAU_REJ, - EMMREG_SERVICE_REQ = _EMMREG_SERVICE_REQ, - EMMREG_SERVICE_CNF = _EMMREG_SERVICE_CNF, - EMMREG_SERVICE_REJ = _EMMREG_SERVICE_REJ, - EMMREG_LOWERLAYER_SUCCESS = _EMMREG_LOWERLAYER_SUCCESS, - EMMREG_LOWERLAYER_FAILURE = _EMMREG_LOWERLAYER_FAILURE, - EMMREG_LOWERLAYER_RELEASE = _EMMREG_LOWERLAYER_RELEASE, + EMMREG_ATTACH_CNF = _EMMREG_ATTACH_CNF, + EMMREG_ATTACH_REJ = _EMMREG_ATTACH_REJ, + EMMREG_DETACH_INIT = _EMMREG_DETACH_INIT, + EMMREG_DETACH_REQ = _EMMREG_DETACH_REQ, + EMMREG_DETACH_FAILED = _EMMREG_DETACH_FAILED, + EMMREG_DETACH_CNF = _EMMREG_DETACH_CNF, + EMMREG_TAU_REQ = _EMMREG_TAU_REQ, + EMMREG_TAU_CNF = _EMMREG_TAU_CNF, + EMMREG_TAU_REJ = _EMMREG_TAU_REJ, + EMMREG_SERVICE_REQ = _EMMREG_SERVICE_REQ, + EMMREG_SERVICE_CNF = _EMMREG_SERVICE_CNF, + EMMREG_SERVICE_REJ = _EMMREG_SERVICE_REJ, + EMMREG_LOWERLAYER_SUCCESS = _EMMREG_LOWERLAYER_SUCCESS, + EMMREG_LOWERLAYER_FAILURE = _EMMREG_LOWERLAYER_FAILURE, + EMMREG_LOWERLAYER_RELEASE = _EMMREG_LOWERLAYER_RELEASE, /* EMMESM-SAP */ #ifdef NAS_UE - EMMESM_ESTABLISH_REQ = _EMMESM_ESTABLISH_REQ, - EMMESM_ESTABLISH_CNF = _EMMESM_ESTABLISH_CNF, - EMMESM_ESTABLISH_REJ = _EMMESM_ESTABLISH_REJ, + EMMESM_ESTABLISH_REQ = _EMMESM_ESTABLISH_REQ, + EMMESM_ESTABLISH_CNF = _EMMESM_ESTABLISH_CNF, + EMMESM_ESTABLISH_REJ = _EMMESM_ESTABLISH_REJ, #endif - EMMESM_RELEASE_IND = _EMMESM_RELEASE_IND, - EMMESM_UNITDATA_REQ = _EMMESM_UNITDATA_REQ, - EMMESM_UNITDATA_IND = _EMMESM_UNITDATA_IND, + EMMESM_RELEASE_IND = _EMMESM_RELEASE_IND, + EMMESM_UNITDATA_REQ = _EMMESM_UNITDATA_REQ, + EMMESM_UNITDATA_IND = _EMMESM_UNITDATA_IND, /* EMMAS-SAP */ - EMMAS_SECURITY_REQ = _EMMAS_SECURITY_REQ, - EMMAS_SECURITY_IND = _EMMAS_SECURITY_IND, - EMMAS_SECURITY_RES = _EMMAS_SECURITY_RES, - EMMAS_SECURITY_REJ = _EMMAS_SECURITY_REJ, - EMMAS_ESTABLISH_REQ = _EMMAS_ESTABLISH_REQ, - EMMAS_ESTABLISH_CNF = _EMMAS_ESTABLISH_CNF, - EMMAS_ESTABLISH_REJ = _EMMAS_ESTABLISH_REJ, - EMMAS_RELEASE_REQ = _EMMAS_RELEASE_REQ, - EMMAS_RELEASE_IND = _EMMAS_RELEASE_IND, - EMMAS_DATA_REQ = _EMMAS_DATA_REQ, - EMMAS_DATA_IND = _EMMAS_DATA_IND, - EMMAS_PAGE_IND = _EMMAS_PAGE_IND, - EMMAS_STATUS_IND = _EMMAS_STATUS_IND, - EMMAS_CELL_INFO_REQ = _EMMAS_CELL_INFO_REQ, - EMMAS_CELL_INFO_RES = _EMMAS_CELL_INFO_RES, - EMMAS_CELL_INFO_IND = _EMMAS_CELL_INFO_IND, + EMMAS_SECURITY_REQ = _EMMAS_SECURITY_REQ, + EMMAS_SECURITY_IND = _EMMAS_SECURITY_IND, + EMMAS_SECURITY_RES = _EMMAS_SECURITY_RES, + EMMAS_SECURITY_REJ = _EMMAS_SECURITY_REJ, + EMMAS_ESTABLISH_REQ = _EMMAS_ESTABLISH_REQ, + EMMAS_ESTABLISH_CNF = _EMMAS_ESTABLISH_CNF, + EMMAS_ESTABLISH_REJ = _EMMAS_ESTABLISH_REJ, + EMMAS_RELEASE_REQ = _EMMAS_RELEASE_REQ, + EMMAS_RELEASE_IND = _EMMAS_RELEASE_IND, + EMMAS_DATA_REQ = _EMMAS_DATA_REQ, + EMMAS_DATA_IND = _EMMAS_DATA_IND, + EMMAS_PAGE_IND = _EMMAS_PAGE_IND, + EMMAS_STATUS_IND = _EMMAS_STATUS_IND, + EMMAS_CELL_INFO_REQ = _EMMAS_CELL_INFO_REQ, + EMMAS_CELL_INFO_RES = _EMMAS_CELL_INFO_RES, + EMMAS_CELL_INFO_IND = _EMMAS_CELL_INFO_IND, } emm_primitive_t; /* * Minimal identifier for EMM-SAP primitives */ -#define EMMREG_PRIMITIVE_MIN _EMMREG_START -#define EMMESM_PRIMITIVE_MIN _EMMESM_START -#define EMMAS_PRIMITIVE_MIN _EMMAS_START +#define EMMREG_PRIMITIVE_MIN _EMMREG_START +#define EMMESM_PRIMITIVE_MIN _EMMESM_START +#define EMMAS_PRIMITIVE_MIN _EMMAS_START /* * Maximal identifier for EMM-SAP primitives */ -#define EMMREG_PRIMITIVE_MAX _EMMREG_END -#define EMMESM_PRIMITIVE_MAX _EMMESM_END -#define EMMAS_PRIMITIVE_MAX _EMMAS_END +#define EMMREG_PRIMITIVE_MAX _EMMREG_END +#define EMMESM_PRIMITIVE_MAX _EMMESM_END +#define EMMAS_PRIMITIVE_MAX _EMMAS_END /****************************************************************************/ /************************ G L O B A L T Y P E S ************************/ @@ -130,9 +130,9 @@ typedef enum { typedef struct { emm_primitive_t primitive; union { - emm_reg_t emm_reg; /* EMMREG-SAP primitives */ - emm_esm_t emm_esm; /* EMMESM-SAP primitives */ - emm_as_t emm_as; /* EMMAS-SAP primitives */ + emm_reg_t emm_reg; /* EMMREG-SAP primitives */ + emm_esm_t emm_esm; /* EMMESM-SAP primitives */ + emm_as_t emm_as; /* EMMAS-SAP primitives */ } u; } emm_sap_t; @@ -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__*/ diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_send.c b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_send.c index dfe9cfa7e8..a92d0b7fa7 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_send.c +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_send.c @@ -1,22 +1,22 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source emm_send.c +Source emm_send.c -Version 0.1 +Version 0.1 -Date 2013/01/30 +Date 2013/01/30 -Product NAS stack +Product NAS stack -Subsystem EPS Mobility Management +Subsystem EPS Mobility Management -Author Frederic Maurel +Author Frederic Maurel -Description Defines functions executed at the EMMAS Service Access - Point to send EPS Mobility Management messages to the - Access Stratum sublayer. +Description Defines functions executed at the EMMAS Service Access + Point to send EPS Mobility Management messages to the + Access Stratum sublayer. *****************************************************************************/ @@ -27,7 +27,7 @@ Description Defines functions executed at the EMMAS Service Access #include "emm_msgDef.h" #include "emm_proc.h" -#include <string.h> // strlen +#include <string.h> // strlen /****************************************************************************/ /**************** E X T E R N A L D E F I N I T I O N S ****************/ @@ -48,29 +48,29 @@ Description Defines functions executed at the EMMAS Service Access */ /**************************************************************************** ** ** - ** Name: emm_send_status() ** + ** Name: emm_send_status() ** ** ** ** Description: Builds EMM status message ** ** ** - ** The EMM status message is sent by the UE or the network ** - ** at any time to report certain error conditions. ** + ** The EMM status message is sent by the UE or the network ** + ** at any time to report certain error conditions. ** ** ** - ** Inputs: emm_cause: EMM cause code ** - ** Others: None ** + ** Inputs: emm_cause: EMM cause code ** + ** Others: None ** ** ** - ** Outputs: emm_msg: The EMM message to be sent ** - ** Return: The size of the EMM message ** - ** Others: None ** + ** Outputs: emm_msg: The EMM message to be sent ** + ** Return: The size of the EMM message ** + ** 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; int size = EMM_HEADER_MAXIMUM_LENGTH; LOG_TRACE(WARNING, "EMMAS-SAP - Send EMM Status message (cause=%d)", - msg->emm_cause); + msg->emm_cause); /* Mandatory - Message type */ emm_msg->messagetype = EMM_STATUS; @@ -84,24 +84,24 @@ int emm_send_status(const emm_as_status_t* msg, emm_status_msg* emm_msg) /**************************************************************************** ** ** - ** Name: emm_send_detach_accept() ** + ** Name: emm_send_detach_accept() ** ** ** ** Description: Builds Detach Accept message ** ** ** - ** The Detach Accept message is sent by the UE or the net- ** - ** work to indicate that the detach procedure has been com- ** - ** pleted. ** + ** The Detach Accept message is sent by the UE or the net- ** + ** work to indicate that the detach procedure has been com- ** + ** pleted. ** ** ** - ** Inputs: msg: The EMMAS-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The EMMAS-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: emm_msg: The EMM message to be sent ** - ** Return: The size of the EMM message ** - ** Others: None ** + ** Outputs: emm_msg: The EMM message to be sent ** + ** Return: The size of the EMM message ** + ** 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; @@ -123,23 +123,23 @@ int emm_send_detach_accept(const emm_as_data_t* msg, #ifdef NAS_UE /**************************************************************************** ** ** - ** Name: emm_send_attach_request() ** + ** Name: emm_send_attach_request() ** ** ** ** Description: Builds Attach Request message ** ** ** - ** The Attach Request message is sent by the UE to the net- ** - ** work in order to perform an attach procedure. ** + ** The Attach Request message is sent by the UE to the net- ** + ** work in order to perform an attach procedure. ** ** ** - ** Inputs: msg: The EMMAS-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The EMMAS-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: emm_msg: The EMM message to be sent ** - ** Return: The size of the EMM message ** - ** Others: None ** + ** Outputs: emm_msg: The EMM message to be sent ** + ** Return: The size of the EMM message ** + ** 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; @@ -153,83 +153,83 @@ int emm_send_attach_request(const emm_as_establish_t* msg, /* Mandatory - EPS attach type */ size += EPS_ATTACH_TYPE_MAXIMUM_LENGTH; if (msg->type == EMM_ATTACH_TYPE_EPS) { - emm_msg->epsattachtype = EPS_ATTACH_TYPE_EPS; + emm_msg->epsattachtype = EPS_ATTACH_TYPE_EPS; } else if (msg->type == EMM_ATTACH_TYPE_IMSI) { - emm_msg->epsattachtype = EPS_ATTACH_TYPE_IMSI; + emm_msg->epsattachtype = EPS_ATTACH_TYPE_IMSI; } else if (msg->type == EMM_ATTACH_TYPE_EMERGENCY) { - emm_msg->epsattachtype = EPS_ATTACH_TYPE_EMERGENCY; + emm_msg->epsattachtype = EPS_ATTACH_TYPE_EMERGENCY; } else if (msg->type == EMM_ATTACH_TYPE_RESERVED) { - emm_msg->epsattachtype = EPS_ATTACH_TYPE_RESERVED; + emm_msg->epsattachtype = EPS_ATTACH_TYPE_RESERVED; } else { - /* All other values shall be interpreted as "EPS attach" */ - emm_msg->epsattachtype = EPS_ATTACH_TYPE_EPS; + /* All other values shall be interpreted as "EPS attach" */ + emm_msg->epsattachtype = EPS_ATTACH_TYPE_EPS; } /* Mandatory - NAS key set identifier */ size += NAS_KEY_SET_IDENTIFIER_MAXIMUM_LENGTH; if (msg->ksi != EMM_AS_NO_KEY_AVAILABLE) { - emm_msg->naskeysetidentifier.naskeysetidentifier = msg->ksi; + emm_msg->naskeysetidentifier.naskeysetidentifier = msg->ksi; } else { - emm_msg->naskeysetidentifier.naskeysetidentifier = - NAS_KEY_SET_IDENTIFIER_NOT_AVAILABLE; + emm_msg->naskeysetidentifier.naskeysetidentifier = + NAS_KEY_SET_IDENTIFIER_NOT_AVAILABLE; } /* Mandatory - EPS mobile identity */ size += EPS_MOBILE_IDENTITY_MAXIMUM_LENGTH; if (msg->UEid.guti) { - /* Set GUTI mobile identity */ - 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; - guti->mmecode = msg->UEid.guti->gummei.MMEcode; - guti->mtmsi = msg->UEid.guti->m_tmsi; - guti->mccdigit1 = msg->UEid.guti->gummei.plmn.MCCdigit1; - guti->mccdigit2 = msg->UEid.guti->gummei.plmn.MCCdigit2; - guti->mccdigit3 = msg->UEid.guti->gummei.plmn.MCCdigit3; - guti->mncdigit1 = msg->UEid.guti->gummei.plmn.MNCdigit1; - guti->mncdigit2 = msg->UEid.guti->gummei.plmn.MNCdigit2; - guti->mncdigit3 = msg->UEid.guti->gummei.plmn.MNCdigit3; + /* Set GUTI mobile identity */ + 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; + guti->mmecode = msg->UEid.guti->gummei.MMEcode; + guti->mtmsi = msg->UEid.guti->m_tmsi; + guti->mccdigit1 = msg->UEid.guti->gummei.plmn.MCCdigit1; + guti->mccdigit2 = msg->UEid.guti->gummei.plmn.MCCdigit2; + guti->mccdigit3 = msg->UEid.guti->gummei.plmn.MCCdigit3; + guti->mncdigit1 = msg->UEid.guti->gummei.plmn.MNCdigit1; + guti->mncdigit2 = msg->UEid.guti->gummei.plmn.MNCdigit2; + guti->mncdigit3 = msg->UEid.guti->gummei.plmn.MNCdigit3; } else if (msg->UEid.imsi) { - /* Set IMSI mobile identity */ - 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; - imsi->digit2 = msg->UEid.imsi->u.num.digit2; - imsi->digit3 = msg->UEid.imsi->u.num.digit3; - imsi->digit4 = msg->UEid.imsi->u.num.digit4; - imsi->digit5 = msg->UEid.imsi->u.num.digit5; - imsi->digit6 = msg->UEid.imsi->u.num.digit6; - imsi->digit7 = msg->UEid.imsi->u.num.digit7; - imsi->digit8 = msg->UEid.imsi->u.num.digit8; - imsi->digit9 = msg->UEid.imsi->u.num.digit9; - imsi->digit10 = msg->UEid.imsi->u.num.digit10; - imsi->digit11 = msg->UEid.imsi->u.num.digit11; - imsi->digit12 = msg->UEid.imsi->u.num.digit12; - imsi->digit13 = msg->UEid.imsi->u.num.digit13; - imsi->digit14 = msg->UEid.imsi->u.num.digit14; - imsi->digit15 = msg->UEid.imsi->u.num.digit15; + /* Set IMSI mobile identity */ + 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; + imsi->digit2 = msg->UEid.imsi->u.num.digit2; + imsi->digit3 = msg->UEid.imsi->u.num.digit3; + imsi->digit4 = msg->UEid.imsi->u.num.digit4; + imsi->digit5 = msg->UEid.imsi->u.num.digit5; + imsi->digit6 = msg->UEid.imsi->u.num.digit6; + imsi->digit7 = msg->UEid.imsi->u.num.digit7; + imsi->digit8 = msg->UEid.imsi->u.num.digit8; + imsi->digit9 = msg->UEid.imsi->u.num.digit9; + imsi->digit10 = msg->UEid.imsi->u.num.digit10; + imsi->digit11 = msg->UEid.imsi->u.num.digit11; + imsi->digit12 = msg->UEid.imsi->u.num.digit12; + imsi->digit13 = msg->UEid.imsi->u.num.digit13; + imsi->digit14 = msg->UEid.imsi->u.num.digit14; + imsi->digit15 = msg->UEid.imsi->u.num.digit15; } else if (msg->UEid.imei) { - /* Set IMEI mobile identity */ - 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; - imei->digit2 = msg->UEid.imei->u.num.digit2; - imei->digit3 = msg->UEid.imei->u.num.digit3; - imei->digit4 = msg->UEid.imei->u.num.digit4; - imei->digit5 = msg->UEid.imei->u.num.digit5; - imei->digit6 = msg->UEid.imei->u.num.digit6; - imei->digit7 = msg->UEid.imei->u.num.digit7; - imei->digit8 = msg->UEid.imei->u.num.digit8; - imei->digit9 = msg->UEid.imei->u.num.digit9; - imei->digit10 = msg->UEid.imei->u.num.digit10; - imei->digit11 = msg->UEid.imei->u.num.digit11; - imei->digit12 = msg->UEid.imei->u.num.digit12; - imei->digit13 = msg->UEid.imei->u.num.digit13; - imei->digit14 = msg->UEid.imei->u.num.digit14; - imei->digit15 = msg->UEid.imei->u.num.digit15; + /* Set IMEI mobile identity */ + 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; + imei->digit2 = msg->UEid.imei->u.num.digit2; + imei->digit3 = msg->UEid.imei->u.num.digit3; + imei->digit4 = msg->UEid.imei->u.num.digit4; + imei->digit5 = msg->UEid.imei->u.num.digit5; + imei->digit6 = msg->UEid.imei->u.num.digit6; + imei->digit7 = msg->UEid.imei->u.num.digit7; + imei->digit8 = msg->UEid.imei->u.num.digit8; + imei->digit9 = msg->UEid.imei->u.num.digit9; + imei->digit10 = msg->UEid.imei->u.num.digit10; + imei->digit11 = msg->UEid.imei->u.num.digit11; + imei->digit12 = msg->UEid.imei->u.num.digit12; + imei->digit13 = msg->UEid.imei->u.num.digit13; + imei->digit14 = msg->UEid.imei->u.num.digit14; + imei->digit15 = msg->UEid.imei->u.num.digit15; } /* Mandatory - UE network capability */ @@ -244,35 +244,35 @@ int emm_send_attach_request(const emm_as_establish_t* msg, emm_msg->uenetworkcapability.lcs = 0; emm_msg->uenetworkcapability.srvcc = 0; emm_msg->uenetworkcapability.nf = 0; - + /* Mandatory - ESM message container */ size += ESM_MESSAGE_CONTAINER_MINIMUM_LENGTH + msg->NASmsg.length; emm_msg->esmmessagecontainer.esmmessagecontainercontents = msg->NASmsg; /* Optional - Last visited registered TAI */ if (msg->UEid.tai) { - size += TRACKING_AREA_IDENTITY_MAXIMUM_LENGTH; - emm_msg->presencemask |= ATTACH_REQUEST_LAST_VISITED_REGISTERED_TAI_PRESENT; - emm_msg->lastvisitedregisteredtai.mccdigit2 = - msg->UEid.tai->plmn.MCCdigit2; - emm_msg->lastvisitedregisteredtai.mccdigit1 = - msg->UEid.tai->plmn.MCCdigit1; - emm_msg->lastvisitedregisteredtai.mncdigit3 = - msg->UEid.tai->plmn.MNCdigit3; - emm_msg->lastvisitedregisteredtai.mccdigit3 = - msg->UEid.tai->plmn.MCCdigit3; - emm_msg->lastvisitedregisteredtai.mncdigit2 = - msg->UEid.tai->plmn.MNCdigit2; - emm_msg->lastvisitedregisteredtai.mncdigit1 = - msg->UEid.tai->plmn.MNCdigit1; - emm_msg->lastvisitedregisteredtai.tac = msg->UEid.tai->tac; + size += TRACKING_AREA_IDENTITY_MAXIMUM_LENGTH; + emm_msg->presencemask |= ATTACH_REQUEST_LAST_VISITED_REGISTERED_TAI_PRESENT; + emm_msg->lastvisitedregisteredtai.mccdigit2 = + msg->UEid.tai->plmn.MCCdigit2; + emm_msg->lastvisitedregisteredtai.mccdigit1 = + msg->UEid.tai->plmn.MCCdigit1; + emm_msg->lastvisitedregisteredtai.mncdigit3 = + msg->UEid.tai->plmn.MNCdigit3; + emm_msg->lastvisitedregisteredtai.mccdigit3 = + msg->UEid.tai->plmn.MCCdigit3; + emm_msg->lastvisitedregisteredtai.mncdigit2 = + msg->UEid.tai->plmn.MNCdigit2; + emm_msg->lastvisitedregisteredtai.mncdigit1 = + msg->UEid.tai->plmn.MNCdigit1; + emm_msg->lastvisitedregisteredtai.tac = msg->UEid.tai->tac; } /* Optional - Old GUTI type */ if (msg->UEid.guti) { - size += GUTI_TYPE_MAXIMUM_LENGTH; - emm_msg->presencemask |= ATTACH_REQUEST_OLD_GUTI_TYPE_PRESENT; - emm_msg->oldgutitype = GUTI_NATIVE; + size += GUTI_TYPE_MAXIMUM_LENGTH; + emm_msg->presencemask |= ATTACH_REQUEST_OLD_GUTI_TYPE_PRESENT; + emm_msg->oldgutitype = GUTI_NATIVE; } LOG_FUNC_RETURN (size); @@ -280,23 +280,23 @@ int emm_send_attach_request(const emm_as_establish_t* msg, /**************************************************************************** ** ** - ** Name: emm_send_attach_complete() ** + ** Name: emm_send_attach_complete() ** ** ** ** Description: Builds Attach Complete message ** ** ** - ** The Attach Complete message is sent by the UE to the net- ** - ** work in response to an Attach Accept message. ** + ** The Attach Complete message is sent by the UE to the net- ** + ** work in response to an Attach Accept message. ** ** ** - ** Inputs: msg: The EMMAS-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The EMMAS-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: emm_msg: The EMM message to be sent ** - ** Return: The size of the EMM message ** - ** Others: None ** + ** Outputs: emm_msg: The EMM message to be sent ** + ** Return: The size of the EMM message ** + ** 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; @@ -316,23 +316,23 @@ int emm_send_attach_complete(const emm_as_data_t* msg, /**************************************************************************** ** ** - ** Name: emm_send_initial_detach_request() ** + ** Name: emm_send_initial_detach_request() ** ** ** ** Description: Builds Detach Request message ** ** ** - ** The Detach Request message is sent by the UE to request ** - ** the release of an EMM context. ** + ** The Detach Request message is sent by the UE to request ** + ** the release of an EMM context. ** ** ** - ** Inputs: msg: The EMMAS-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The EMMAS-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: emm_msg: The EMM message to be sent ** - ** Return: The size of the EMM message ** - ** Others: None ** + ** Outputs: emm_msg: The EMM message to be sent ** + ** Return: The size of the EMM message ** + ** 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; @@ -346,88 +346,88 @@ int emm_send_initial_detach_request(const emm_as_establish_t* msg, /* Mandatory - Detach type */ size += DETACH_TYPE_MAXIMUM_LENGTH; if (msg->switch_off) { - emm_msg->detachtype.switchoff = DETACH_TYPE_SWITCH_OFF; + emm_msg->detachtype.switchoff = DETACH_TYPE_SWITCH_OFF; } else { - emm_msg->detachtype.switchoff = DETACH_TYPE_NORMAL_DETACH; + emm_msg->detachtype.switchoff = DETACH_TYPE_NORMAL_DETACH; } if (msg->type == EMM_DETACH_TYPE_EPS) { - emm_msg->detachtype.typeofdetach = DETACH_TYPE_EPS; + emm_msg->detachtype.typeofdetach = DETACH_TYPE_EPS; } else if (msg->type == EMM_DETACH_TYPE_IMSI) { - emm_msg->detachtype.typeofdetach = DETACH_TYPE_IMSI; + emm_msg->detachtype.typeofdetach = DETACH_TYPE_IMSI; } else if (msg->type == EMM_DETACH_TYPE_EPS_IMSI) { - emm_msg->detachtype.typeofdetach = DETACH_TYPE_EPS_IMSI; + emm_msg->detachtype.typeofdetach = DETACH_TYPE_EPS_IMSI; } else if (msg->type == EMM_DETACH_TYPE_RESERVED) { - emm_msg->detachtype.typeofdetach = DETACH_TYPE_RESERVED_1; + emm_msg->detachtype.typeofdetach = DETACH_TYPE_RESERVED_1; } else { - /* All other values are interpreted as "combined EPS/IMSI detach" */ - emm_msg->detachtype.typeofdetach = DETACH_TYPE_EPS_IMSI; + /* All other values are interpreted as "combined EPS/IMSI detach" */ + emm_msg->detachtype.typeofdetach = DETACH_TYPE_EPS_IMSI; } /* Mandatory - NAS key set identifier */ size += NAS_KEY_SET_IDENTIFIER_MAXIMUM_LENGTH; if (msg->ksi != EMM_AS_NO_KEY_AVAILABLE) { - emm_msg->naskeysetidentifier.naskeysetidentifier = msg->ksi; + emm_msg->naskeysetidentifier.naskeysetidentifier = msg->ksi; } else { - emm_msg->naskeysetidentifier.naskeysetidentifier = - NAS_KEY_SET_IDENTIFIER_NOT_AVAILABLE; + emm_msg->naskeysetidentifier.naskeysetidentifier = + NAS_KEY_SET_IDENTIFIER_NOT_AVAILABLE; } /* Mandatory - EPS mobile identity */ size += EPS_MOBILE_IDENTITY_MAXIMUM_LENGTH; if (msg->UEid.guti) { - /* Set GUTI mobile identity */ - 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; - guti->mmecode = msg->UEid.guti->gummei.MMEcode; - guti->mtmsi = msg->UEid.guti->m_tmsi; - guti->mccdigit1 = msg->UEid.guti->gummei.plmn.MCCdigit1; - guti->mccdigit2 = msg->UEid.guti->gummei.plmn.MCCdigit2; - guti->mccdigit3 = msg->UEid.guti->gummei.plmn.MCCdigit3; - guti->mncdigit1 = msg->UEid.guti->gummei.plmn.MNCdigit1; - guti->mncdigit2 = msg->UEid.guti->gummei.plmn.MNCdigit2; - guti->mncdigit3 = msg->UEid.guti->gummei.plmn.MNCdigit3; + /* Set GUTI mobile identity */ + 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; + guti->mmecode = msg->UEid.guti->gummei.MMEcode; + guti->mtmsi = msg->UEid.guti->m_tmsi; + guti->mccdigit1 = msg->UEid.guti->gummei.plmn.MCCdigit1; + guti->mccdigit2 = msg->UEid.guti->gummei.plmn.MCCdigit2; + guti->mccdigit3 = msg->UEid.guti->gummei.plmn.MCCdigit3; + guti->mncdigit1 = msg->UEid.guti->gummei.plmn.MNCdigit1; + guti->mncdigit2 = msg->UEid.guti->gummei.plmn.MNCdigit2; + guti->mncdigit3 = msg->UEid.guti->gummei.plmn.MNCdigit3; } else if (msg->UEid.imsi) { - /* Set IMSI mobile identity */ - 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; - imsi->digit2 = msg->UEid.imsi->u.num.digit2; - imsi->digit3 = msg->UEid.imsi->u.num.digit3; - imsi->digit4 = msg->UEid.imsi->u.num.digit4; - imsi->digit5 = msg->UEid.imsi->u.num.digit5; - imsi->digit6 = msg->UEid.imsi->u.num.digit6; - imsi->digit7 = msg->UEid.imsi->u.num.digit7; - imsi->digit8 = msg->UEid.imsi->u.num.digit8; - imsi->digit9 = msg->UEid.imsi->u.num.digit9; - imsi->digit10 = msg->UEid.imsi->u.num.digit10; - imsi->digit11 = msg->UEid.imsi->u.num.digit11; - imsi->digit12 = msg->UEid.imsi->u.num.digit12; - imsi->digit13 = msg->UEid.imsi->u.num.digit13; - imsi->digit14 = msg->UEid.imsi->u.num.digit14; - imsi->digit15 = msg->UEid.imsi->u.num.digit15; + /* Set IMSI mobile identity */ + 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; + imsi->digit2 = msg->UEid.imsi->u.num.digit2; + imsi->digit3 = msg->UEid.imsi->u.num.digit3; + imsi->digit4 = msg->UEid.imsi->u.num.digit4; + imsi->digit5 = msg->UEid.imsi->u.num.digit5; + imsi->digit6 = msg->UEid.imsi->u.num.digit6; + imsi->digit7 = msg->UEid.imsi->u.num.digit7; + imsi->digit8 = msg->UEid.imsi->u.num.digit8; + imsi->digit9 = msg->UEid.imsi->u.num.digit9; + imsi->digit10 = msg->UEid.imsi->u.num.digit10; + imsi->digit11 = msg->UEid.imsi->u.num.digit11; + imsi->digit12 = msg->UEid.imsi->u.num.digit12; + imsi->digit13 = msg->UEid.imsi->u.num.digit13; + imsi->digit14 = msg->UEid.imsi->u.num.digit14; + imsi->digit15 = msg->UEid.imsi->u.num.digit15; } else if (msg->UEid.imei) { - /* Set IMEI mobile identity */ - 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; - imei->digit2 = msg->UEid.imei->u.num.digit2; - imei->digit3 = msg->UEid.imei->u.num.digit3; - imei->digit4 = msg->UEid.imei->u.num.digit4; - imei->digit5 = msg->UEid.imei->u.num.digit5; - imei->digit6 = msg->UEid.imei->u.num.digit6; - imei->digit7 = msg->UEid.imei->u.num.digit7; - imei->digit8 = msg->UEid.imei->u.num.digit8; - imei->digit9 = msg->UEid.imei->u.num.digit9; - imei->digit10 = msg->UEid.imei->u.num.digit10; - imei->digit11 = msg->UEid.imei->u.num.digit11; - imei->digit12 = msg->UEid.imei->u.num.digit12; - imei->digit13 = msg->UEid.imei->u.num.digit13; - imei->digit14 = msg->UEid.imei->u.num.digit14; - imei->digit15 = msg->UEid.imei->u.num.digit15; + /* Set IMEI mobile identity */ + 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; + imei->digit2 = msg->UEid.imei->u.num.digit2; + imei->digit3 = msg->UEid.imei->u.num.digit3; + imei->digit4 = msg->UEid.imei->u.num.digit4; + imei->digit5 = msg->UEid.imei->u.num.digit5; + imei->digit6 = msg->UEid.imei->u.num.digit6; + imei->digit7 = msg->UEid.imei->u.num.digit7; + imei->digit8 = msg->UEid.imei->u.num.digit8; + imei->digit9 = msg->UEid.imei->u.num.digit9; + imei->digit10 = msg->UEid.imei->u.num.digit10; + imei->digit11 = msg->UEid.imei->u.num.digit11; + imei->digit12 = msg->UEid.imei->u.num.digit12; + imei->digit13 = msg->UEid.imei->u.num.digit13; + imei->digit14 = msg->UEid.imei->u.num.digit14; + imei->digit15 = msg->UEid.imei->u.num.digit15; } LOG_FUNC_RETURN (size); @@ -435,23 +435,23 @@ int emm_send_initial_detach_request(const emm_as_establish_t* msg, /**************************************************************************** ** ** - ** Name: emm_send_detach_request() ** + ** Name: emm_send_detach_request() ** ** ** ** Description: Builds Detach Request message ** ** ** - ** The Detach Request message is sent by the UE to request ** - ** the release of an EMM context. ** + ** The Detach Request message is sent by the UE to request ** + ** the release of an EMM context. ** ** ** - ** Inputs: msg: The EMMAS-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The EMMAS-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: emm_msg: The EMM message to be sent ** - ** Return: The size of the EMM message ** - ** Others: None ** + ** Outputs: emm_msg: The EMM message to be sent ** + ** Return: The size of the EMM message ** + ** 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; @@ -465,48 +465,48 @@ int emm_send_detach_request(const emm_as_data_t* msg, /* Mandatory - Detach type */ size += DETACH_TYPE_MAXIMUM_LENGTH; if (msg->switch_off) { - emm_msg->detachtype.switchoff = DETACH_TYPE_SWITCH_OFF; + emm_msg->detachtype.switchoff = DETACH_TYPE_SWITCH_OFF; } else { - emm_msg->detachtype.switchoff = DETACH_TYPE_NORMAL_DETACH; + emm_msg->detachtype.switchoff = DETACH_TYPE_NORMAL_DETACH; } if (msg->type == EMM_DETACH_TYPE_EPS) { - emm_msg->detachtype.typeofdetach = DETACH_TYPE_EPS; + emm_msg->detachtype.typeofdetach = DETACH_TYPE_EPS; } else if (msg->type == EMM_DETACH_TYPE_IMSI) { - emm_msg->detachtype.typeofdetach = DETACH_TYPE_IMSI; + emm_msg->detachtype.typeofdetach = DETACH_TYPE_IMSI; } else if (msg->type == EMM_DETACH_TYPE_EPS_IMSI) { - emm_msg->detachtype.typeofdetach = DETACH_TYPE_EPS_IMSI; + emm_msg->detachtype.typeofdetach = DETACH_TYPE_EPS_IMSI; } else if (msg->type == EMM_DETACH_TYPE_RESERVED) { - emm_msg->detachtype.typeofdetach = DETACH_TYPE_RESERVED_1; + emm_msg->detachtype.typeofdetach = DETACH_TYPE_RESERVED_1; } else { - /* All other values are interpreted as "combined EPS/IMSI detach" */ - emm_msg->detachtype.typeofdetach = DETACH_TYPE_EPS_IMSI; + /* All other values are interpreted as "combined EPS/IMSI detach" */ + emm_msg->detachtype.typeofdetach = DETACH_TYPE_EPS_IMSI; } /* Mandatory - NAS key set identifier */ size += NAS_KEY_SET_IDENTIFIER_MAXIMUM_LENGTH; if (msg->sctx.ksi != EMM_AS_NO_KEY_AVAILABLE) { - emm_msg->naskeysetidentifier.naskeysetidentifier = msg->sctx.ksi; + emm_msg->naskeysetidentifier.naskeysetidentifier = msg->sctx.ksi; } else { - emm_msg->naskeysetidentifier.naskeysetidentifier = - NAS_KEY_SET_IDENTIFIER_NOT_AVAILABLE; + emm_msg->naskeysetidentifier.naskeysetidentifier = + NAS_KEY_SET_IDENTIFIER_NOT_AVAILABLE; } /* Mandatory - EPS mobile identity */ size += EPS_MOBILE_IDENTITY_MAXIMUM_LENGTH; if (msg->guti) { - /* Set GUTI mobile identity */ - 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; - guti->mmecode = msg->guti->gummei.MMEcode; - guti->mtmsi = msg->guti->m_tmsi; - guti->mccdigit1 = msg->guti->gummei.plmn.MCCdigit1; - guti->mccdigit2 = msg->guti->gummei.plmn.MCCdigit2; - guti->mccdigit3 = msg->guti->gummei.plmn.MCCdigit3; - guti->mncdigit1 = msg->guti->gummei.plmn.MNCdigit1; - guti->mncdigit2 = msg->guti->gummei.plmn.MNCdigit2; - guti->mncdigit3 = msg->guti->gummei.plmn.MNCdigit3; + /* Set GUTI mobile identity */ + 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; + guti->mmecode = msg->guti->gummei.MMEcode; + guti->mtmsi = msg->guti->m_tmsi; + guti->mccdigit1 = msg->guti->gummei.plmn.MCCdigit1; + guti->mccdigit2 = msg->guti->gummei.plmn.MCCdigit2; + guti->mccdigit3 = msg->guti->gummei.plmn.MCCdigit3; + guti->mncdigit1 = msg->guti->gummei.plmn.MNCdigit1; + guti->mncdigit2 = msg->guti->gummei.plmn.MNCdigit2; + guti->mncdigit3 = msg->guti->gummei.plmn.MNCdigit3; } LOG_FUNC_RETURN (size); @@ -514,25 +514,25 @@ int emm_send_detach_request(const emm_as_data_t* msg, /**************************************************************************** ** ** - ** Name: emm_send_initial_tau_request() ** + ** Name: emm_send_initial_tau_request() ** ** ** ** Description: Builds Tracking Area Update Request message ** ** ** - ** The Tracking Area Update Request message is sent by the ** - ** UE to the network to update the registration of the ac- ** - ** tual tracking area of a UE in the network and to periodi- ** - ** cally notify the availability of the UE to the network. ** + ** The Tracking Area Update Request message is sent by the ** + ** UE to the network to update the registration of the ac- ** + ** tual tracking area of a UE in the network and to periodi- ** + ** cally notify the availability of the UE to the network. ** ** ** - ** Inputs: msg: The EMMAS-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The EMMAS-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: emm_msg: The EMM message to be sent ** - ** Return: The size of the EMM message ** - ** Others: None ** + ** Outputs: emm_msg: The EMM message to be sent ** + ** Return: The size of the EMM message ** + ** 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; @@ -548,24 +548,24 @@ int emm_send_initial_tau_request(const emm_as_establish_t* msg, /**************************************************************************** ** ** - ** Name: emm_send_initial_sr_request() ** + ** Name: emm_send_initial_sr_request() ** ** ** ** Description: Build the Service Request message ** ** ** - ** The Service Request message is sent by the UE to the ** - ** network to request the establishment of a NAS signalling ** - ** connection and of the radio and S1 bearers. ** + ** The Service Request message is sent by the UE to the ** + ** network to request the establishment of a NAS signalling ** + ** connection and of the radio and S1 bearers. ** ** ** - ** Inputs: msg: The EMMAS-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The EMMAS-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: emm_msg: The EMM message to be sent ** - ** Return: The size of the EMM message ** - ** Others: None ** + ** Outputs: emm_msg: The EMM message to be sent ** + ** Return: The size of the EMM message ** + ** 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; @@ -578,27 +578,27 @@ int emm_send_initial_sr_request(const emm_as_establish_t* msg, /**************************************************************************** ** ** - ** Name: emm_send_initial_extsr_request() ** + ** Name: emm_send_initial_extsr_request() ** ** ** ** Description: Build the Extended Service Request message ** ** ** - ** The Extended Service Request message is sent by the UE to ** - ** the network to request the establishment of a NAS signal- ** - ** ling connection and of the radio and S1 bearers for pa- ** - ** cket services, if the UE needs to provide additional in- ** - ** formation that cannot be provided via a SERVICE REQUEST ** - ** message. + ** The Extended Service Request message is sent by the UE to ** + ** the network to request the establishment of a NAS signal- ** + ** ling connection and of the radio and S1 bearers for pa- ** + ** cket services, if the UE needs to provide additional in- ** + ** formation that cannot be provided via a SERVICE REQUEST ** + ** message. ** ** - ** Inputs: msg: The EMMAS-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The EMMAS-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: emm_msg: The EMM message to be sent ** - ** Return: The size of the EMM message ** - ** Others: None ** + ** Outputs: emm_msg: The EMM message to be sent ** + ** Return: The size of the EMM message ** + ** 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; @@ -614,24 +614,24 @@ int emm_send_initial_extsr_request(const emm_as_establish_t* msg, /**************************************************************************** ** ** - ** Name: emm_send_identity_response() ** + ** Name: emm_send_identity_response() ** ** ** ** Description: Builds Identity Response message ** ** ** - ** The Identity Response message is sent by the UE to the ** - ** network in response to an Identity Request message and ** - ** provides the requested identity. ** + ** The Identity Response message is sent by the UE to the ** + ** network in response to an Identity Request message and ** + ** provides the requested identity. ** ** ** - ** Inputs: msg: The EMMAS-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The EMMAS-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: emm_msg: The EMM message to be sent ** - ** Return: The size of the EMM message ** - ** Others: None ** + ** Outputs: emm_msg: The EMM message to be sent ** + ** Return: The size of the EMM message ** + ** 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; @@ -645,69 +645,69 @@ int emm_send_identity_response(const emm_as_security_t* msg, /* Mandatory - Mobile identity */ size += MOBILE_IDENTITY_MAXIMUM_LENGTH; if (msg->identType == EMM_IDENT_TYPE_IMSI) { - if (msg->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; - imsi->digit2 = msg->imsi->u.num.digit2; - imsi->digit3 = msg->imsi->u.num.digit3; - imsi->digit4 = msg->imsi->u.num.digit4; - imsi->digit5 = msg->imsi->u.num.digit5; - imsi->digit6 = msg->imsi->u.num.digit6; - imsi->digit7 = msg->imsi->u.num.digit7; - imsi->digit8 = msg->imsi->u.num.digit8; - imsi->digit9 = msg->imsi->u.num.digit9; - imsi->digit10 = msg->imsi->u.num.digit10; - imsi->digit11 = msg->imsi->u.num.digit11; - imsi->digit12 = msg->imsi->u.num.digit12; - imsi->digit13 = msg->imsi->u.num.digit13; - imsi->digit14 = msg->imsi->u.num.digit14; - imsi->digit15 = msg->imsi->u.num.digit15; - } + if (msg->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; + imsi->digit2 = msg->imsi->u.num.digit2; + imsi->digit3 = msg->imsi->u.num.digit3; + imsi->digit4 = msg->imsi->u.num.digit4; + imsi->digit5 = msg->imsi->u.num.digit5; + imsi->digit6 = msg->imsi->u.num.digit6; + imsi->digit7 = msg->imsi->u.num.digit7; + imsi->digit8 = msg->imsi->u.num.digit8; + imsi->digit9 = msg->imsi->u.num.digit9; + imsi->digit10 = msg->imsi->u.num.digit10; + imsi->digit11 = msg->imsi->u.num.digit11; + imsi->digit12 = msg->imsi->u.num.digit12; + imsi->digit13 = msg->imsi->u.num.digit13; + imsi->digit14 = msg->imsi->u.num.digit14; + imsi->digit15 = msg->imsi->u.num.digit15; + } } 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; - tmsi->typeofidentity = MOBILE_IDENTITY_TMSI; - tmsi->oddeven = MOBILE_IDENTITY_EVEN; - tmsi->digit1 = 0xf; - tmsi->digit2 = (*p_tmsi & 0xf); - tmsi->digit3 = ((*p_tmsi >> 4) & 0xf); - p_tmsi++; - tmsi->digit4 = (*p_tmsi & 0xf); - tmsi->digit5 = ((*p_tmsi >> 4) & 0xf); - p_tmsi++; - tmsi->digit6 = (*p_tmsi & 0xf); - tmsi->digit7 = ((*p_tmsi >> 4) & 0xf); - p_tmsi++; - tmsi->digit8 = (*p_tmsi & 0xf); - tmsi->digit9 = ((*p_tmsi >> 4) & 0xf); - } + if (msg->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; + tmsi->digit2 = (*p_tmsi & 0xf); + tmsi->digit3 = ((*p_tmsi >> 4) & 0xf); + p_tmsi++; + tmsi->digit4 = (*p_tmsi & 0xf); + tmsi->digit5 = ((*p_tmsi >> 4) & 0xf); + p_tmsi++; + tmsi->digit6 = (*p_tmsi & 0xf); + tmsi->digit7 = ((*p_tmsi >> 4) & 0xf); + p_tmsi++; + tmsi->digit8 = (*p_tmsi & 0xf); + tmsi->digit9 = ((*p_tmsi >> 4) & 0xf); + } } else if (msg->identType == EMM_IDENT_TYPE_IMEI) { - if (msg->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; - imei->digit2 = msg->imei->u.num.digit2; - imei->digit3 = msg->imei->u.num.digit3; - imei->digit4 = msg->imei->u.num.digit4; - imei->digit5 = msg->imei->u.num.digit5; - imei->digit6 = msg->imei->u.num.digit6; - imei->digit7 = msg->imei->u.num.digit7; - imei->digit8 = msg->imei->u.num.digit8; - imei->digit9 = msg->imei->u.num.digit9; - imei->digit10 = msg->imei->u.num.digit10; - imei->digit11 = msg->imei->u.num.digit11; - imei->digit12 = msg->imei->u.num.digit12; - imei->digit13 = msg->imei->u.num.digit13; - imei->digit14 = msg->imei->u.num.digit14; - imei->digit15 = msg->imei->u.num.digit15; - } + if (msg->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; + imei->digit2 = msg->imei->u.num.digit2; + imei->digit3 = msg->imei->u.num.digit3; + imei->digit4 = msg->imei->u.num.digit4; + imei->digit5 = msg->imei->u.num.digit5; + imei->digit6 = msg->imei->u.num.digit6; + imei->digit7 = msg->imei->u.num.digit7; + imei->digit8 = msg->imei->u.num.digit8; + imei->digit9 = msg->imei->u.num.digit9; + imei->digit10 = msg->imei->u.num.digit10; + imei->digit11 = msg->imei->u.num.digit11; + imei->digit12 = msg->imei->u.num.digit12; + imei->digit13 = msg->imei->u.num.digit13; + imei->digit14 = msg->imei->u.num.digit14; + 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; - no_id->typeofidentity = MOBILE_IDENTITY_NOT_AVAILABLE; + NoMobileIdentity_t *no_id = &emm_msg->mobileidentity.no_id; + no_id->typeofidentity = MOBILE_IDENTITY_NOT_AVAILABLE; } LOG_FUNC_RETURN (size); @@ -715,24 +715,24 @@ int emm_send_identity_response(const emm_as_security_t* msg, /**************************************************************************** ** ** - ** Name: emm_send_authentication_response() ** + ** Name: emm_send_authentication_response() ** ** ** ** Description: Builds Authentication Response message ** ** ** - ** The Authentication Response message is sent by the UE to ** - ** the network to deliver a calculated authentication res- ** - ** ponse to the network. ** + ** The Authentication Response message is sent by the UE to ** + ** the network to deliver a calculated authentication res- ** + ** ponse to the network. ** ** ** - ** Inputs: msg: The EMMAS-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The EMMAS-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: emm_msg: The EMM message to be sent ** - ** Return: The size of the EMM message ** - ** Others: None ** + ** Outputs: emm_msg: The EMM message to be sent ** + ** Return: The size of the EMM message ** + ** 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; @@ -750,29 +750,29 @@ int emm_send_authentication_response(const emm_as_security_t* msg, /**************************************************************************** ** ** - ** Name: emm_send_authentication_failure() ** + ** Name: emm_send_authentication_failure() ** ** ** ** Description: Builds Authentication Failure message ** ** ** - ** The Authentication Failure message is sent by the UE to ** - ** the network to indicate that authentication of the net- ** - ** work has failed ** + ** The Authentication Failure message is sent by the UE to ** + ** the network to indicate that authentication of the net- ** + ** work has failed ** ** ** - ** Inputs: msg: The EMMAS-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The EMMAS-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: emm_msg: The EMM message to be sent ** - ** Return: The size of the EMM message ** - ** Others: None ** + ** Outputs: emm_msg: The EMM message to be sent ** + ** Return: The size of the EMM message ** + ** 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; LOG_TRACE(INFO, "EMMAS-SAP - Send Authentication Failure message (cause=%d)", - msg->emm_cause); + msg->emm_cause); /* Mandatory - Message type */ emm_msg->messagetype = AUTHENTICATION_FAILURE; @@ -783,9 +783,10 @@ 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->authenticationfailureparameter.auts = *msg->auts; + size += AUTHENTICATION_RESPONSE_PARAMETER_MAXIMUM_LENGTH; + emm_msg->presencemask |= + AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_PRESENT; + emm_msg->authenticationfailureparameter.auts = *msg->auts; } LOG_FUNC_RETURN (size); @@ -793,24 +794,24 @@ int emm_send_authentication_failure(const emm_as_security_t* msg, /**************************************************************************** ** ** - ** Name: emm_send_security_mode_complete() ** + ** Name: emm_send_security_mode_complete() ** ** ** ** Description: Builds Security Mode Complete message ** ** ** - ** The Security Mode Complete message is sent by the UE to ** - ** the network in response to a Security Mode Command mes- ** - ** sage. ** + ** The Security Mode Complete message is sent by the UE to ** + ** the network in response to a Security Mode Command mes- ** + ** sage. ** ** ** - ** Inputs: msg: The EMMAS-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The EMMAS-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: emm_msg: The EMM message to be sent ** - ** Return: The size of the EMM message ** - ** Others: None ** + ** Outputs: emm_msg: The EMM message to be sent ** + ** Return: The size of the EMM message ** + ** 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; @@ -826,31 +827,31 @@ int emm_send_security_mode_complete(const emm_as_security_t* msg, /**************************************************************************** ** ** - ** Name: emm_send_security_mode_reject() ** + ** Name: emm_send_security_mode_reject() ** ** ** ** Description: Builds Security Mode Reject message ** ** ** - ** The Security Mode Reject message is sent by the UE to the ** - ** network to indicate that the corresponding security mode ** - ** command has been rejected. ** + ** The Security Mode Reject message is sent by the UE to the ** + ** network to indicate that the corresponding security mode ** + ** command has been rejected. ** ** ** - ** Inputs: msg: The EMMAS-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The EMMAS-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: emm_msg: The EMM message to be sent ** - ** Return: The size of the EMM message ** - ** Others: None ** + ** Outputs: emm_msg: The EMM message to be sent ** + ** Return: The size of the EMM message ** + ** 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; int size = EMM_HEADER_MAXIMUM_LENGTH; LOG_TRACE(INFO, "EMMAS-SAP - Send Security Mode Reject message (cause=%d)", - msg->emm_cause); + msg->emm_cause); /* Mandatory - Message type */ emm_msg->messagetype = SECURITY_MODE_REJECT; @@ -872,24 +873,24 @@ int emm_send_security_mode_reject(const emm_as_security_t* msg, #ifdef NAS_MME /**************************************************************************** ** ** - ** Name: emm_send_attach_accept() ** + ** Name: emm_send_attach_accept() ** ** ** ** Description: Builds Attach Accept message ** ** ** - ** The Attach Accept message is sent by the network to the ** - ** UE to indicate that the corresponding attach request has ** - ** been accepted. ** + ** The Attach Accept message is sent by the network to the ** + ** UE to indicate that the corresponding attach request has ** + ** been accepted. ** ** ** - ** Inputs: msg: The EMMAS-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The EMMAS-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: emm_msg: The EMM message to be sent ** - ** Return: The size of the EMM message ** - ** Others: None ** + ** Outputs: emm_msg: The EMM message to be sent ** + ** Return: The size of the EMM message ** + ** 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; @@ -911,7 +912,7 @@ int emm_send_attach_accept(const emm_as_establish_t* msg, /* Mandatory - Tracking area identity list */ size += TRACKING_AREA_IDENTITY_LIST_MINIMUM_LENGTH; emm_msg->tailist.typeoflist = - TRACKING_AREA_IDENTITY_LIST_ONE_PLMN_CONSECUTIVE_TACS; + TRACKING_AREA_IDENTITY_LIST_ONE_PLMN_CONSECUTIVE_TACS; emm_msg->tailist.numberofelements = msg->n_tacs; emm_msg->tailist.mccdigit1 = msg->UEid.guti->gummei.plmn.MCCdigit1; emm_msg->tailist.mccdigit2 = msg->UEid.guti->gummei.plmn.MCCdigit2; @@ -927,50 +928,50 @@ int emm_send_attach_accept(const emm_as_establish_t* msg, /* Optional - GUTI */ if (msg->new_guti) { - size += EPS_MOBILE_IDENTITY_MAXIMUM_LENGTH; - emm_msg->presencemask |= ATTACH_ACCEPT_GUTI_PRESENT; - emm_msg->guti.guti.typeofidentity = EPS_MOBILE_IDENTITY_GUTI; - emm_msg->guti.guti.oddeven = EPS_MOBILE_IDENTITY_EVEN; - emm_msg->guti.guti.mmegroupid = msg->new_guti->gummei.MMEgid; - emm_msg->guti.guti.mmecode = msg->new_guti->gummei.MMEcode; - emm_msg->guti.guti.mtmsi = msg->new_guti->m_tmsi; - emm_msg->guti.guti.mccdigit1 = msg->new_guti->gummei.plmn.MCCdigit1; - emm_msg->guti.guti.mccdigit2 = msg->new_guti->gummei.plmn.MCCdigit2; - emm_msg->guti.guti.mccdigit3 = msg->new_guti->gummei.plmn.MCCdigit3; - emm_msg->guti.guti.mncdigit1 = msg->new_guti->gummei.plmn.MNCdigit1; - emm_msg->guti.guti.mncdigit2 = msg->new_guti->gummei.plmn.MNCdigit2; - emm_msg->guti.guti.mncdigit3 = msg->new_guti->gummei.plmn.MNCdigit3; + size += EPS_MOBILE_IDENTITY_MAXIMUM_LENGTH; + emm_msg->presencemask |= ATTACH_ACCEPT_GUTI_PRESENT; + emm_msg->guti.guti.typeofidentity = EPS_MOBILE_IDENTITY_GUTI; + emm_msg->guti.guti.oddeven = EPS_MOBILE_IDENTITY_EVEN; + emm_msg->guti.guti.mmegroupid = msg->new_guti->gummei.MMEgid; + emm_msg->guti.guti.mmecode = msg->new_guti->gummei.MMEcode; + emm_msg->guti.guti.mtmsi = msg->new_guti->m_tmsi; + emm_msg->guti.guti.mccdigit1 = msg->new_guti->gummei.plmn.MCCdigit1; + emm_msg->guti.guti.mccdigit2 = msg->new_guti->gummei.plmn.MCCdigit2; + emm_msg->guti.guti.mccdigit3 = msg->new_guti->gummei.plmn.MCCdigit3; + emm_msg->guti.guti.mncdigit1 = msg->new_guti->gummei.plmn.MNCdigit1; + emm_msg->guti.guti.mncdigit2 = msg->new_guti->gummei.plmn.MNCdigit2; + emm_msg->guti.guti.mncdigit3 = msg->new_guti->gummei.plmn.MNCdigit3; } LOG_FUNC_RETURN (size); } /**************************************************************************** ** ** - ** Name: emm_send_attach_reject() ** + ** Name: emm_send_attach_reject() ** ** ** ** Description: Builds Attach Reject message ** ** ** - ** The Attach Reject message is sent by the network to the ** - ** UE to indicate that the corresponding attach request has ** - ** been rejected. ** + ** The Attach Reject message is sent by the network to the ** + ** UE to indicate that the corresponding attach request has ** + ** been rejected. ** ** ** - ** Inputs: msg: The EMMAS-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The EMMAS-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: emm_msg: The EMM message to be sent ** - ** Return: The size of the EMM message ** - ** Others: None ** + ** Outputs: emm_msg: The EMM message to be sent ** + ** Return: The size of the EMM message ** + ** 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; int size = EMM_HEADER_MAXIMUM_LENGTH; LOG_TRACE(INFO, "EMMAS-SAP - Send Attach Reject message (cause=%d)", - msg->emm_cause); + msg->emm_cause); /* Mandatory - Message type */ emm_msg->messagetype = ATTACH_REJECT; @@ -981,9 +982,9 @@ int emm_send_attach_reject(const emm_as_establish_t* msg, /* Optional - ESM message container */ if (msg->NASmsg.length > 0) { - size += ESM_MESSAGE_CONTAINER_MINIMUM_LENGTH + msg->NASmsg.length; - emm_msg->presencemask |= ATTACH_REJECT_ESM_MESSAGE_CONTAINER_PRESENT; - emm_msg->esmmessagecontainer.esmmessagecontainercontents = msg->NASmsg; + size += ESM_MESSAGE_CONTAINER_MINIMUM_LENGTH + msg->NASmsg.length; + emm_msg->presencemask |= ATTACH_REJECT_ESM_MESSAGE_CONTAINER_PRESENT; + emm_msg->esmmessagecontainer.esmmessagecontainercontents = msg->NASmsg; } LOG_FUNC_RETURN (size); @@ -991,24 +992,24 @@ int emm_send_attach_reject(const emm_as_establish_t* msg, /**************************************************************************** ** ** - ** Name: emm_send_identity_request() ** + ** Name: emm_send_identity_request() ** ** ** ** Description: Builds Identity Request message ** ** ** - ** The Identity Request message is sent by the network to ** - ** the UE to request the UE to provide the specified identi- ** - ** ty. ** + ** The Identity Request message is sent by the network to ** + ** the UE to request the UE to provide the specified identi- ** + ** ty. ** ** ** - ** Inputs: msg: The EMMAS-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The EMMAS-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: emm_msg: The EMM message to be sent ** - ** Return: The size of the EMM message ** - ** Others: None ** + ** Outputs: emm_msg: The EMM message to be sent ** + ** Return: The size of the EMM message ** + ** 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; @@ -1022,14 +1023,14 @@ int emm_send_identity_request(const emm_as_security_t* msg, /* Mandatory - Identity type 2 */ size += IDENTITY_TYPE_2_MAXIMUM_LENGTH; if (msg->identType == EMM_IDENT_TYPE_IMSI) { - emm_msg->identitytype = IDENTITY_TYPE_2_IMSI; + emm_msg->identitytype = IDENTITY_TYPE_2_IMSI; } else if (msg->identType == EMM_IDENT_TYPE_TMSI) { - emm_msg->identitytype = IDENTITY_TYPE_2_TMSI; + emm_msg->identitytype = IDENTITY_TYPE_2_TMSI; } else if (msg->identType == EMM_IDENT_TYPE_IMEI) { - emm_msg->identitytype = IDENTITY_TYPE_2_IMEI; + emm_msg->identitytype = IDENTITY_TYPE_2_IMEI; } else { - /* All other values are interpreted as "IMSI" */ - emm_msg->identitytype = IDENTITY_TYPE_2_IMSI; + /* All other values are interpreted as "IMSI" */ + emm_msg->identitytype = IDENTITY_TYPE_2_IMSI; } LOG_FUNC_RETURN (size); @@ -1037,23 +1038,23 @@ int emm_send_identity_request(const emm_as_security_t* msg, /**************************************************************************** ** ** - ** Name: emm_send_authentication_request() ** + ** Name: emm_send_authentication_request() ** ** ** ** Description: Builds Authentication Request message ** ** ** - ** The Authentication Request message is sent by the network ** - ** to the UE to initiate authentication of the UE identity. ** + ** The Authentication Request message is sent by the network ** + ** to the UE to initiate authentication of the UE identity. ** ** ** - ** Inputs: msg: The EMMAS-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The EMMAS-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: emm_msg: The EMM message to be sent ** - ** Return: The size of the EMM message ** - ** Others: None ** + ** Outputs: emm_msg: The EMM message to be sent ** + ** Return: The size of the EMM message ** + ** 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; @@ -1082,23 +1083,23 @@ int emm_send_authentication_request(const emm_as_security_t* msg, /**************************************************************************** ** ** - ** Name: emm_send_authentication_reject() ** + ** Name: emm_send_authentication_reject() ** ** ** ** Description: Builds Authentication Reject message ** ** ** - ** The Authentication Reject message is sent by the network ** - ** to the UE to indicate that the authentication procedure ** - ** has failed and that the UE shall abort all activities. ** + ** The Authentication Reject message is sent by the network ** + ** to the UE to indicate that the authentication procedure ** + ** has failed and that the UE shall abort all activities. ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: emm_msg: The EMM message to be sent ** - ** Return: The size of the EMM message ** - ** Others: None ** + ** Outputs: emm_msg: The EMM message to be sent ** + ** Return: The size of the EMM message ** + ** 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; @@ -1114,23 +1115,23 @@ int emm_send_authentication_reject(authentication_reject_msg* emm_msg) /**************************************************************************** ** ** - ** Name: emm_send_security_mode_command() ** + ** Name: emm_send_security_mode_command() ** ** ** ** Description: Builds Security Mode Command message ** ** ** - ** The Security Mode Command message is sent by the network ** - ** to the UE to establish NAS signalling security. ** + ** The Security Mode Command message is sent by the network ** + ** to the UE to establish NAS signalling security. ** ** ** - ** Inputs: msg: The EMMAS-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The EMMAS-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: emm_msg: The EMM message to be sent ** - ** Return: The size of the EMM message ** - ** Others: None ** + ** Outputs: emm_msg: The EMM message to be sent ** + ** Return: The size of the EMM message ** + ** 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; @@ -1144,9 +1145,9 @@ int emm_send_security_mode_command(const emm_as_security_t* msg, /* Selected NAS security algorithms */ size += NAS_SECURITY_ALGORITHMS_MAXIMUM_LENGTH; emm_msg->selectednassecurityalgorithms.typeofcipheringalgorithm = - NAS_SECURITY_ALGORITHMS_EEA0; + NAS_SECURITY_ALGORITHMS_EEA0; emm_msg->selectednassecurityalgorithms.typeofintegrityalgorithm = - NAS_SECURITY_ALGORITHMS_EIA0; + NAS_SECURITY_ALGORITHMS_EIA0; /* NAS key set identifier */ size += NAS_KEY_SET_IDENTIFIER_MAXIMUM_LENGTH; diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_send.h b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_send.h index 7b4f263b7e..735f167b94 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_send.h +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_send.h @@ -1,22 +1,22 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source emm_send.h +Source emm_send.h -Version 0.1 +Version 0.1 -Date 2013/01/30 +Date 2013/01/30 -Product NAS stack +Product NAS stack -Subsystem EPS Mobility Management +Subsystem EPS Mobility Management -Author Frederic Maurel +Author Frederic Maurel -Description Defines functions executed at the EMMAS Service Access - Point to send EPS Mobility Management messages to the - Access Stratum sublayer. +Description Defines functions executed at the EMMAS Service Access + Point to send EPS Mobility Management messages to the + Access Stratum sublayer. *****************************************************************************/ #ifndef __EMM_SEND_H__ @@ -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__*/ diff --git a/openair-cn/NAS/EURECOM-NAS/src/esm/DedicatedEpsBearerContextActivation.c b/openair-cn/NAS/EURECOM-NAS/src/esm/DedicatedEpsBearerContextActivation.c index 39902ebe16..920bc851e4 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/esm/DedicatedEpsBearerContextActivation.c +++ b/openair-cn/NAS/EURECOM-NAS/src/esm/DedicatedEpsBearerContextActivation.c @@ -1,33 +1,33 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source DedicatedEpsBearerContextActivation.c +Source DedicatedEpsBearerContextActivation.c -Version 0.1 +Version 0.1 -Date 2013/07/16 +Date 2013/07/16 -Product NAS stack +Product NAS stack -Subsystem EPS Session Management +Subsystem EPS Session Management -Author Frederic Maurel +Author Frederic Maurel -Description Defines the dedicated EPS bearer context activation ESM - procedure executed by the Non-Access Stratum. +Description Defines the dedicated EPS bearer context activation ESM + procedure executed by the Non-Access Stratum. - The purpose of the dedicated EPS bearer context activation - procedure is to establish an EPS bearer context with specific - QoS and TFT between the UE and the EPC. + The purpose of the dedicated EPS bearer context activation + procedure is to establish an EPS bearer context with specific + QoS and TFT between the UE and the EPC. - The procedure is initiated by the network, but may be requested - by the UE by means of the UE requested bearer resource alloca- - tion procedure or the UE requested bearer resource modification - procedure. - It can be part of the attach procedure or be initiated together - with the default EPS bearer context activation procedure when - the UE initiated stand-alone PDN connectivity procedure. + The procedure is initiated by the network, but may be requested + by the UE by means of the UE requested bearer resource alloca- + tion procedure or the UE requested bearer resource modification + procedure. + It can be part of the attach procedure or be initiated together + with the default EPS bearer context activation procedure when + the UE initiated stand-alone PDN connectivity procedure. *****************************************************************************/ @@ -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 +#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 /****************************************************************************/ @@ -81,53 +81,53 @@ static int _dedicated_eps_bearer_activate(unsigned int ueid, int ebi, #ifdef NAS_MME /**************************************************************************** ** ** - ** Name: esm_proc_dedicated_eps_bearer_context() ** + ** Name: esm_proc_dedicated_eps_bearer_context() ** ** ** ** Description: Allocates resources required for activation of a dedica- ** - ** ted EPS bearer context. ** - ** ** - ** Inputs: ueid: UE local identifier ** - ** pid: PDN connection identifier ** - ** esm_qos: EPS bearer level QoS parameters ** - ** tft: Traffic flow template parameters ** - ** Others: None ** - ** ** - ** Outputs: ebi: EPS bearer identity assigned to the new ** - ** dedicated bearer context ** - ** default_ebi: EPS bearer identity of the associated de- ** - ** fault EPS bearer context ** - ** esm_cause: Cause code returned upon ESM procedure ** - ** failure ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** ted EPS bearer context. ** + ** ** + ** Inputs: ueid: UE local identifier ** + ** pid: PDN connection identifier ** + ** esm_qos: EPS bearer level QoS parameters ** + ** tft: Traffic flow template parameters ** + ** Others: None ** + ** ** + ** Outputs: ebi: EPS bearer identity assigned to the new ** + ** dedicated bearer context ** + ** default_ebi: EPS bearer identity of the associated de- ** + ** fault EPS bearer context ** + ** esm_cause: Cause code returned upon ESM procedure ** + ** failure ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ 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; LOG_TRACE(INFO, "ESM-PROC - Dedicated EPS bearer context activation " - "(ueid=%u, pid=%d)", ueid, pid); + "(ueid=%u, pid=%d)", ueid, pid); /* Assign new EPS bearer context */ *ebi = esm_ebr_assign(ueid, ESM_EBI_UNASSIGNED); if (*ebi != ESM_EBI_UNASSIGNED) { - /* Create dedicated EPS bearer context */ - *default_ebi = esm_ebr_context_create(ueid, pid, *ebi, FALSE, qos, tft); - if (*default_ebi == ESM_EBI_UNASSIGNED) { - /* No resource available */ - LOG_TRACE(WARNING, "ESM-PROC - Failed to create dedicated EPS " - "bearer context (ebi=%d)", *ebi); - *esm_cause = ESM_CAUSE_INSUFFICIENT_RESOURCES; - LOG_FUNC_RETURN (RETURNerror); - } - LOG_FUNC_RETURN (RETURNok); + /* Create dedicated EPS bearer context */ + *default_ebi = esm_ebr_context_create(ueid, pid, *ebi, FALSE, qos, tft); + if (*default_ebi == ESM_EBI_UNASSIGNED) { + /* No resource available */ + LOG_TRACE(WARNING, "ESM-PROC - Failed to create dedicated EPS " + "bearer context (ebi=%d)", *ebi); + *esm_cause = ESM_CAUSE_INSUFFICIENT_RESOURCES; + LOG_FUNC_RETURN (RETURNerror); + } + LOG_FUNC_RETURN (RETURNok); } LOG_TRACE(WARNING, "ESM-PROC - Failed to assign new EPS bearer context"); @@ -137,53 +137,53 @@ int esm_proc_dedicated_eps_bearer_context(unsigned int ueid, int pid, /**************************************************************************** ** ** - ** Name: esm_proc_dedicated_eps_bearer_context_request() ** + ** Name: esm_proc_dedicated_eps_bearer_context_request() ** ** ** ** Description: Initiates the dedicated EPS bearer context activation pro-** - ** cedure ** - ** ** - ** 3GPP TS 24.301, section 6.4.2.2 ** - ** The MME initiates the dedicated EPS bearer context activa-** - ** tion procedure by sending an ACTIVATE DEDICATED EPS BEA- ** - ** RER CONTEXT REQUEST message, starting timer T3485 and en- ** - ** tering state BEARER CONTEXT ACTIVE PENDING. ** - ** ** - ** Inputs: is_standalone: Not used (always TRUE) ** - ** ueid: UE lower layer identifier ** - ** ebi: EPS bearer identity ** - ** msg: Encoded ESM message to be sent ** - ** ue_triggered: TRUE if the EPS bearer context procedure ** - ** was triggered by the UE ** - ** Others: None ** - ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** cedure ** + ** ** + ** 3GPP TS 24.301, section 6.4.2.2 ** + ** The MME initiates the dedicated EPS bearer context activa-** + ** tion procedure by sending an ACTIVATE DEDICATED EPS BEA- ** + ** RER CONTEXT REQUEST message, starting timer T3485 and en- ** + ** tering state BEARER CONTEXT ACTIVE PENDING. ** + ** ** + ** Inputs: is_standalone: Not used (always TRUE) ** + ** ueid: UE lower layer identifier ** + ** ebi: EPS bearer identity ** + ** msg: Encoded ESM message to be sent ** + ** ue_triggered: TRUE if the EPS bearer context procedure ** + ** was triggered by the UE ** + ** Others: None ** + ** ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ int esm_proc_dedicated_eps_bearer_context_request(int is_standalone, - unsigned int ueid, int ebi, - OctetString* msg, int ue_triggered) + unsigned int ueid, int ebi, + OctetString *msg, int ue_triggered) { LOG_FUNC_IN; int rc = RETURNok; LOG_TRACE(INFO,"ESM-PROC - Initiate dedicated EPS bearer context " - "activation (ueid=%d, ebi=%d)", ueid, ebi); + "activation (ueid=%d, ebi=%d)", ueid, ebi); /* Send activate dedicated EPS bearer context request message and * start timer T3485 */ rc = _dedicated_eps_bearer_activate(ueid, ebi, msg); if (rc != RETURNerror) { - /* Set the EPS bearer context state to ACTIVE PENDING */ - rc = esm_ebr_set_status(ueid, ebi, ESM_EBR_ACTIVE_PENDING, ue_triggered); - if (rc != RETURNok) { - /* The EPS bearer context was already in ACTIVE PENDING state */ - LOG_TRACE(WARNING, "ESM-PROC - EBI %d was already ACTIVE PENDING", - ebi); - } + /* Set the EPS bearer context state to ACTIVE PENDING */ + rc = esm_ebr_set_status(ueid, ebi, ESM_EBR_ACTIVE_PENDING, ue_triggered); + if (rc != RETURNok) { + /* The EPS bearer context was already in ACTIVE PENDING state */ + LOG_TRACE(WARNING, "ESM-PROC - EBI %d was already ACTIVE PENDING", + ebi); + } } LOG_FUNC_RETURN (rc); @@ -191,46 +191,46 @@ int esm_proc_dedicated_eps_bearer_context_request(int is_standalone, /**************************************************************************** ** ** - ** Name: esm_proc_dedicated_eps_bearer_context_accept() ** + ** Name: esm_proc_dedicated_eps_bearer_context_accept() ** ** ** ** Description: Performs dedicated EPS bearer context activation procedu- ** - ** re accepted by the UE. ** + ** re accepted by the UE. ** ** ** - ** 3GPP TS 24.301, section 6.4.2.3 ** - ** Upon receipt of the ACTIVATE DEDICATED EPS BEARER CONTEXT ** - ** ACCEPT message, the MME shall stop the timer T3485 and ** - ** enter the state BEARER CONTEXT ACTIVE. ** + ** 3GPP TS 24.301, section 6.4.2.3 ** + ** Upon receipt of the ACTIVATE DEDICATED EPS BEARER CONTEXT ** + ** ACCEPT message, the MME shall stop the timer T3485 and ** + ** enter the state BEARER CONTEXT ACTIVE. ** ** ** - ** Inputs: ueid: UE local identifier ** - ** ebi: EPS bearer identity ** - ** Others: None ** + ** Inputs: ueid: UE local identifier ** + ** ebi: EPS bearer identity ** + ** Others: None ** ** ** - ** Outputs: esm_cause: Cause code returned upon ESM procedure ** - ** failure ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: esm_cause: Cause code returned upon ESM procedure ** + ** failure ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ int esm_proc_dedicated_eps_bearer_context_accept(unsigned int ueid, int ebi, - int* esm_cause) + int *esm_cause) { LOG_FUNC_IN; int rc; LOG_TRACE(INFO, "ESM-PROC - Dedicated EPS bearer context activation " - "accepted by the UE (ueid=%u, ebi=%d)", ueid, ebi); + "accepted by the UE (ueid=%u, ebi=%d)", ueid, ebi); /* Stop T3485 timer */ rc = esm_ebr_stop_timer(ueid, ebi); if (rc != RETURNerror) { - /* Set the EPS bearer context state to ACTIVE */ - rc = esm_ebr_set_status(ueid, ebi, ESM_EBR_ACTIVE, FALSE); - if (rc != RETURNok) { - /* The EPS bearer context was already in ACTIVE state */ - LOG_TRACE(WARNING, "ESM-PROC - EBI %d was already ACTIVE", ebi); - *esm_cause = ESM_CAUSE_PROTOCOL_ERROR; - } + /* Set the EPS bearer context state to ACTIVE */ + rc = esm_ebr_set_status(ueid, ebi, ESM_EBR_ACTIVE, FALSE); + if (rc != RETURNok) { + /* The EPS bearer context was already in ACTIVE state */ + LOG_TRACE(WARNING, "ESM-PROC - EBI %d was already ACTIVE", ebi); + *esm_cause = ESM_CAUSE_PROTOCOL_ERROR; + } } LOG_FUNC_RETURN (rc); @@ -238,51 +238,51 @@ int esm_proc_dedicated_eps_bearer_context_accept(unsigned int ueid, int ebi, /**************************************************************************** ** ** - ** Name: esm_proc_dedicated_eps_bearer_context_reject() ** + ** Name: esm_proc_dedicated_eps_bearer_context_reject() ** ** ** ** Description: Performs dedicated EPS bearer context activation procedu- ** - ** re not accepted by the UE. ** - ** ** - ** 3GPP TS 24.301, section 6.4.2.4 ** - ** Upon receipt of the ACTIVATE DEDICATED EPS BEARER CONTEXT ** - ** REJECT message, the MME shall stop the timer T3485, enter ** - ** the state BEARER CONTEXT INACTIVE and abort the dedicated ** - ** EPS bearer context activation procedure. ** - ** The MME also requests the lower layer to release the ra- ** - ** dio resources that were established during the dedicated ** - ** EPS bearer context activation. ** - ** ** - ** Inputs: ueid: UE local identifier ** - ** ebi: EPS bearer identity ** - ** Others: None ** - ** ** - ** Outputs: esm_cause: Cause code returned upon ESM procedure ** - ** failure ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** re not accepted by the UE. ** + ** ** + ** 3GPP TS 24.301, section 6.4.2.4 ** + ** Upon receipt of the ACTIVATE DEDICATED EPS BEARER CONTEXT ** + ** REJECT message, the MME shall stop the timer T3485, enter ** + ** the state BEARER CONTEXT INACTIVE and abort the dedicated ** + ** EPS bearer context activation procedure. ** + ** The MME also requests the lower layer to release the ra- ** + ** dio resources that were established during the dedicated ** + ** EPS bearer context activation. ** + ** ** + ** Inputs: ueid: UE local identifier ** + ** ebi: EPS bearer identity ** + ** Others: None ** + ** ** + ** Outputs: esm_cause: Cause code returned upon ESM procedure ** + ** failure ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ int esm_proc_dedicated_eps_bearer_context_reject(unsigned int ueid, int ebi, - int* esm_cause) + int *esm_cause) { LOG_FUNC_IN; int rc; LOG_TRACE(WARNING, "ESM-PROC - Dedicated EPS bearer context activation " - "not accepted by the UE (ueid=%u, ebi=%d)", ueid, ebi); + "not accepted by the UE (ueid=%u, ebi=%d)", ueid, ebi); /* Stop T3485 timer if running */ rc = esm_ebr_stop_timer(ueid, ebi); if (rc != RETURNerror) { - int pid, bid; - /* Release the dedicated EPS bearer context and enter state INACTIVE */ - rc = esm_proc_eps_bearer_context_deactivate(ueid, TRUE, ebi, - &pid, &bid, NULL); - if (rc != RETURNok) { - /* Failed to release the dedicated EPS bearer context */ - *esm_cause = ESM_CAUSE_PROTOCOL_ERROR; - } + int pid, bid; + /* Release the dedicated EPS bearer context and enter state INACTIVE */ + rc = esm_proc_eps_bearer_context_deactivate(ueid, TRUE, ebi, + &pid, &bid, NULL); + if (rc != RETURNok) { + /* Failed to release the dedicated EPS bearer context */ + *esm_cause = ESM_CAUSE_PROTOCOL_ERROR; + } } LOG_FUNC_RETURN (rc); @@ -297,96 +297,93 @@ int esm_proc_dedicated_eps_bearer_context_reject(unsigned int ueid, int ebi, #ifdef NAS_UE /**************************************************************************** ** ** - ** Name: esm_proc_dedicated_eps_bearer_context_request() ** + ** Name: esm_proc_dedicated_eps_bearer_context_request() ** ** ** ** Description: Creates local dedicated EPS bearer context upon receipt ** - ** of the ACTIVATE DEDICATED EPS BEARER CONTEXT REQUEST ** - ** message. ** + ** of the ACTIVATE DEDICATED EPS BEARER CONTEXT REQUEST ** + ** message. ** ** ** - ** Inputs: ebi: EPS bearer identity ** - ** default_ebi: EPS bearer identity of the associated de- ** - ** fault EPS bearer context ** - ** esm_qos: EPS bearer level QoS parameters ** - ** tft: Traffic flow template parameters ** - ** Others: None ** + ** Inputs: ebi: EPS bearer identity ** + ** default_ebi: EPS bearer identity of the associated de- ** + ** fault EPS bearer context ** + ** esm_qos: EPS bearer level QoS parameters ** + ** tft: Traffic flow template parameters ** + ** Others: None ** ** ** - ** Outputs: esm_cause: Cause code returned upon ESM procedure ** - ** failure ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: esm_cause: Cause code returned upon ESM procedure ** + ** failure ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ 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; int rc = RETURNerror; LOG_TRACE(INFO, "ESM-PROC - Dedicated EPS bearer context activation " - "requested by the network (ebi=%d)", ebi); + "requested by the network (ebi=%d)", ebi); /* Get the PDN connection the dedicated EPS bearer is linked to */ int pid = esm_ebr_context_get_pid(default_ebi); if (pid < 0) { - /* 3GPP TS 24.301, section 6.4.2.5, abnormal case c - * No default EPS bearer context with linked EPS bearer identity - * activated - */ - LOG_TRACE(WARNING, "ESM-PROC - Failed to get PDN connection the " - "dedicated EPS bearer is linked to (ebi=%d)", default_ebi); - *esm_cause = ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY; - LOG_FUNC_RETURN (RETURNerror); + /* 3GPP TS 24.301, section 6.4.2.5, abnormal case c + * No default EPS bearer context with linked EPS bearer identity + * activated + */ + LOG_TRACE(WARNING, "ESM-PROC - Failed to get PDN connection the " + "dedicated EPS bearer is linked to (ebi=%d)", default_ebi); + *esm_cause = ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY; + LOG_FUNC_RETURN (RETURNerror); } /* Assign dedicated EPS bearer context */ int new_ebi = esm_ebr_assign(ebi, pid+1, FALSE); if (new_ebi == ESM_EBI_UNASSIGNED) { - /* 3GPP TS 24.301, section 6.4.2.5, abnormal cases a and b - * Dedicated EPS bearer context activation request for an already - * activated default or dedicated EPS bearer context - */ - int old_pid, old_bid; - /* Locally deactivate the existing EPS bearer context and proceed - * with the requested dedicated EPS bearer context activation */ - rc = esm_proc_eps_bearer_context_deactivate(TRUE, ebi, - &old_pid, &old_bid); - if (rc != RETURNok) { - /* Failed to release EPS bearer context */ - *esm_cause = ESM_CAUSE_PROTOCOL_ERROR; - } - else { - /* Assign new dedicated EPS bearer context */ - ebi = esm_ebr_assign(ebi, pid+1, FALSE); - } + /* 3GPP TS 24.301, section 6.4.2.5, abnormal cases a and b + * Dedicated EPS bearer context activation request for an already + * activated default or dedicated EPS bearer context + */ + int old_pid, old_bid; + /* Locally deactivate the existing EPS bearer context and proceed + * with the requested dedicated EPS bearer context activation */ + rc = esm_proc_eps_bearer_context_deactivate(TRUE, ebi, + &old_pid, &old_bid); + if (rc != RETURNok) { + /* Failed to release EPS bearer context */ + *esm_cause = ESM_CAUSE_PROTOCOL_ERROR; + } else { + /* Assign new dedicated EPS bearer context */ + ebi = esm_ebr_assign(ebi, pid+1, FALSE); + } } if (ebi != ESM_EBI_UNASSIGNED) { - /* Check syntactical errors in packet filters */ - rc = esm_ebr_context_check_tft(pid, ebi, tft, - ESM_EBR_CONTEXT_TFT_CREATE); - if (rc != RETURNok) { - /* Syntactical errors in packet filters */ - LOG_TRACE(WARNING, "ESM-PROC - Syntactical errors in packet " - "filters"); - *esm_cause = ESM_CAUSE_SYNTACTICAL_ERROR_IN_PACKET_FILTER; - } - 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 { - /* No resource available */ - LOG_TRACE(WARNING, "ESM-PROC - Failed to create new dedicated " - "EPS bearer context"); - *esm_cause = ESM_CAUSE_INSUFFICIENT_RESOURCES; - } - } + /* Check syntactical errors in packet filters */ + rc = esm_ebr_context_check_tft(pid, ebi, tft, + ESM_EBR_CONTEXT_TFT_CREATE); + if (rc != RETURNok) { + /* Syntactical errors in packet filters */ + LOG_TRACE(WARNING, "ESM-PROC - Syntactical errors in packet " + "filters"); + *esm_cause = ESM_CAUSE_SYNTACTICAL_ERROR_IN_PACKET_FILTER; + } 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 { + /* No resource available */ + LOG_TRACE(WARNING, "ESM-PROC - Failed to create new dedicated " + "EPS bearer context"); + *esm_cause = ESM_CAUSE_INSUFFICIENT_RESOURCES; + } + } } LOG_FUNC_RETURN (rc); @@ -394,37 +391,37 @@ int esm_proc_dedicated_eps_bearer_context_request(int ebi, int default_ebi, /**************************************************************************** ** ** - ** Name: esm_proc_dedicated_eps_bearer_context_accept() ** + ** Name: esm_proc_dedicated_eps_bearer_context_accept() ** ** ** ** Description: Performs dedicated EPS bearer context activation proce- ** - ** dure accepted by the UE. ** + ** dure accepted by the UE. ** ** ** - ** 3GPP TS 24.301, section 6.4.2.3 ** - ** The UE accepts dedicated EPS bearer context activation by ** - ** sending ACTIVATE DEDICATED EPS BEARER CONTEXT ACCEPT mes- ** - ** sage and entering the state BEARER CONTEXT ACTIVE. ** + ** 3GPP TS 24.301, section 6.4.2.3 ** + ** The UE accepts dedicated EPS bearer context activation by ** + ** sending ACTIVATE DEDICATED EPS BEARER CONTEXT ACCEPT mes- ** + ** sage and entering the state BEARER CONTEXT ACTIVE. ** ** ** - ** Inputs: is_standalone: Not used ** - ** ebi: EPS bearer identity ** - ** msg: Encoded ESM message to be sent ** - ** ue_triggered: TRUE if the EPS bearer context procedure ** - ** was triggered by the UE ** - ** Others: None ** + ** Inputs: is_standalone: Not used ** + ** ebi: EPS bearer identity ** + ** msg: Encoded ESM message to be sent ** + ** ue_triggered: TRUE if the EPS bearer context procedure ** + ** was triggered by the UE ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ 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; int rc; LOG_TRACE(INFO,"ESM-PROC - Dedicated EPS bearer context activation " - "accepted by the UE (ebi=%d)", ebi); + "accepted by the UE (ebi=%d)", ebi); emm_sap_t emm_sap; emm_esm_data_t *emm_esm = &emm_sap.u.emm_esm.u.data; @@ -438,15 +435,15 @@ int esm_proc_dedicated_eps_bearer_context_accept(int is_standalone, int ebi, rc = emm_sap_send(&emm_sap); if (rc != RETURNerror) { - /* Set the EPS bearer context state to ACTIVE */ - rc = esm_ebr_set_status(ebi, ESM_EBR_ACTIVE, ue_triggered); - if (rc != RETURNok) { - /* The EPS bearer context was already in ACTIVE state */ - LOG_TRACE(WARNING, "ESM-PROC - EBI %d was already ACTIVE", ebi); - /* Accept network retransmission of already accepted activate - * dedicated EPS bearer context request */ - LOG_FUNC_RETURN (RETURNok); - } + /* Set the EPS bearer context state to ACTIVE */ + rc = esm_ebr_set_status(ebi, ESM_EBR_ACTIVE, ue_triggered); + if (rc != RETURNok) { + /* The EPS bearer context was already in ACTIVE state */ + LOG_TRACE(WARNING, "ESM-PROC - EBI %d was already ACTIVE", ebi); + /* Accept network retransmission of already accepted activate + * dedicated EPS bearer context request */ + LOG_FUNC_RETURN (RETURNok); + } } LOG_FUNC_RETURN (rc); @@ -454,56 +451,55 @@ int esm_proc_dedicated_eps_bearer_context_accept(int is_standalone, int ebi, /**************************************************************************** ** ** - ** Name: esm_proc_dedicated_eps_bearer_context_reject() ** + ** Name: esm_proc_dedicated_eps_bearer_context_reject() ** ** ** ** Description: Performs dedicated EPS bearer context activation proce- ** - ** dure not accepted by the UE. ** + ** dure not accepted by the UE. ** ** ** - ** 3GPP TS 24.301, section 6.4.2.4 ** - ** The UE rejects dedicated EPS bearer context activation by ** - ** sending ACTIVATE DEDICATED EPS BEARER CONTEXT REJECT mes- ** - ** sage. ** + ** 3GPP TS 24.301, section 6.4.2.4 ** + ** The UE rejects dedicated EPS bearer context activation by ** + ** sending ACTIVATE DEDICATED EPS BEARER CONTEXT REJECT mes- ** + ** sage. ** ** ** - ** Inputs: is_standalone: Not used ** - ** ebi: EPS bearer identity ** - ** msg: Encoded ESM message to be sent ** - ** ue_triggered: Not used ** - ** Others: None ** + ** Inputs: is_standalone: Not used ** + ** ebi: EPS bearer identity ** + ** msg: Encoded ESM message to be sent ** + ** ue_triggered: Not used ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ 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; int rc = RETURNok; LOG_TRACE(WARNING, "ESM-PROC - Dedicated EPS bearer context activation " - "not accepted by the UE (ebi=%d)", ebi); + "not accepted by the UE (ebi=%d)", ebi); if ( !esm_ebr_is_not_in_use(ebi) ) { - /* Release EPS bearer data currently in use */ - rc = esm_ebr_release(ebi); + /* Release EPS bearer data currently in use */ + rc = esm_ebr_release(ebi); } if (rc != RETURNok) { - LOG_TRACE(WARNING, "ESM-PROC - Failed to release EPS bearer data"); - } - else { - emm_sap_t emm_sap; - emm_esm_data_t *emm_esm = &emm_sap.u.emm_esm.u.data; - /* - * Notity EMM that ESM PDU has to be forwarded to lower layers - */ - emm_sap.primitive = EMMESM_UNITDATA_REQ; - emm_sap.u.emm_esm.ueid = 0; - emm_esm->msg.length = msg->length; - emm_esm->msg.value = msg->value; - rc = emm_sap_send(&emm_sap); + LOG_TRACE(WARNING, "ESM-PROC - Failed to release EPS bearer data"); + } else { + emm_sap_t emm_sap; + emm_esm_data_t *emm_esm = &emm_sap.u.emm_esm.u.data; + /* + * Notity EMM that ESM PDU has to be forwarded to lower layers + */ + emm_sap.primitive = EMMESM_UNITDATA_REQ; + emm_sap.u.emm_esm.ueid = 0; + emm_esm->msg.length = msg->length; + emm_esm->msg.value = msg->value; + rc = emm_sap_send(&emm_sap); } LOG_FUNC_RETURN (rc); @@ -516,68 +512,67 @@ int esm_proc_dedicated_eps_bearer_context_reject(int is_standalone, int ebi, /* * -------------------------------------------------------------------------- - * Timer handlers + * Timer handlers * -------------------------------------------------------------------------- */ #ifdef NAS_MME /**************************************************************************** ** ** - ** Name: _dedicated_eps_bearer_activate_t3485_handler() ** + ** Name: _dedicated_eps_bearer_activate_t3485_handler() ** ** ** ** Description: T3485 timeout handler ** ** ** ** 3GPP TS 24.301, section 6.4.2.6, case a ** - ** On the first expiry of the timer T3485, the MME shall re- ** - ** send the ACTIVATE DEDICATED EPS BEARER CONTEXT REQUEST ** - ** and shall reset and restart timer T3485. This retransmis- ** - ** sion is repeated four times, i.e. on the fifth expiry of ** - ** timer T3485, the MME shall abort the procedure, release ** - ** any resources allocated for this activation and enter the ** - ** state BEARER CONTEXT INACTIVE. ** + ** On the first expiry of the timer T3485, the MME shall re- ** + ** send the ACTIVATE DEDICATED EPS BEARER CONTEXT REQUEST ** + ** and shall reset and restart timer T3485. This retransmis- ** + ** sion is repeated four times, i.e. on the fifth expiry of ** + ** timer T3485, the MME shall abort the procedure, release ** + ** any resources allocated for this activation and enter the ** + ** state BEARER CONTEXT INACTIVE. ** ** ** - ** Inputs: args: handler parameters ** - ** Others: None ** + ** Inputs: args: handler parameters ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: None ** - ** Others: None ** + ** Outputs: None ** + ** Return: None ** + ** 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; LOG_TRACE(WARNING, "ESM-PROC - T3485 timer expired (ueid=%d, ebi=%d), " - "retransmission counter = %d", - data->ueid, data->ebi, data->count); + "retransmission counter = %d", + data->ueid, data->ebi, data->count); if (data->count < DEDICATED_EPS_BEARER_ACTIVATE_COUNTER_MAX) { - /* Re-send activate dedicated EPS bearer context request message - * to the UE */ - rc = _dedicated_eps_bearer_activate(data->ueid, data->ebi, &data->msg); - } - else { - /* - * The maximum number of activate dedicated EPS bearer context request - * message retransmission has exceed - */ - int pid, bid; - /* Release the dedicated EPS bearer context and enter state INACTIVE */ - rc = esm_proc_eps_bearer_context_deactivate(data->ueid, TRUE, - data->ebi, &pid, &bid, - NULL); - if (rc != RETURNerror) { - /* Stop timer T3485 */ - rc = esm_ebr_stop_timer(data->ueid, data->ebi); - } + /* Re-send activate dedicated EPS bearer context request message + * to the UE */ + rc = _dedicated_eps_bearer_activate(data->ueid, data->ebi, &data->msg); + } else { + /* + * The maximum number of activate dedicated EPS bearer context request + * message retransmission has exceed + */ + int pid, bid; + /* Release the dedicated EPS bearer context and enter state INACTIVE */ + rc = esm_proc_eps_bearer_context_deactivate(data->ueid, TRUE, + data->ebi, &pid, &bid, + NULL); + if (rc != RETURNerror) { + /* Stop timer T3485 */ + rc = esm_ebr_stop_timer(data->ueid, data->ebi); + } } LOG_FUNC_RETURN (NULL); @@ -585,29 +580,29 @@ static void* _dedicated_eps_bearer_activate_t3485_handler(void* args) /* * -------------------------------------------------------------------------- - * MME specific local functions + * MME specific local functions * -------------------------------------------------------------------------- */ /**************************************************************************** ** ** - ** Name: _dedicated_eps_bearer_activate() ** + ** Name: _dedicated_eps_bearer_activate() ** ** ** ** Description: Sends ACTIVATE DEDICATED EPS BEREAR CONTEXT REQUEST mes- ** - ** sage and starts timer T3485 ** + ** sage and starts timer T3485 ** ** ** - ** Inputs: ueid: UE local identifier ** - ** ebi: EPS bearer identity ** - ** msg: Encoded ESM message to be sent ** - ** Others: None ** + ** Inputs: ueid: UE local identifier ** + ** ebi: EPS bearer identity ** + ** msg: Encoded ESM message to be sent ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: T3485 ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: T3485 ** ** ** ***************************************************************************/ static int _dedicated_eps_bearer_activate(unsigned int ueid, int ebi, - const OctetString* msg) + const OctetString *msg) { LOG_FUNC_IN; @@ -625,9 +620,9 @@ static int _dedicated_eps_bearer_activate(unsigned int ueid, int ebi, rc = emm_sap_send(&emm_sap); if (rc != RETURNerror) { - /* Start T3485 retransmission timer */ - rc = esm_ebr_start_timer(ueid, ebi, msg, T3485_DEFAULT_VALUE, - _dedicated_eps_bearer_activate_t3485_handler); + /* Start T3485 retransmission timer */ + rc = esm_ebr_start_timer(ueid, ebi, msg, T3485_DEFAULT_VALUE, + _dedicated_eps_bearer_activate_t3485_handler); } LOG_FUNC_RETURN (rc); diff --git a/openair-cn/NAS/EURECOM-NAS/src/esm/DefaultEpsBearerContextActivation.c b/openair-cn/NAS/EURECOM-NAS/src/esm/DefaultEpsBearerContextActivation.c index 50f9f684ec..e0d305132b 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/esm/DefaultEpsBearerContextActivation.c +++ b/openair-cn/NAS/EURECOM-NAS/src/esm/DefaultEpsBearerContextActivation.c @@ -1,29 +1,29 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source DefaultEpsBearerContextActivation.c +Source DefaultEpsBearerContextActivation.c -Version 0.1 +Version 0.1 -Date 2013/01/28 +Date 2013/01/28 -Product NAS stack +Product NAS stack -Subsystem EPS Session Management +Subsystem EPS Session Management -Author Frederic Maurel +Author Frederic Maurel -Description Defines the default EPS bearer context activation ESM - procedure executed by the Non-Access Stratum. +Description Defines the default EPS bearer context activation ESM + procedure executed by the Non-Access Stratum. - The purpose of the default bearer context activation procedure - is to establish a default EPS bearer context between the UE - and the EPC. + The purpose of the default bearer context activation procedure + is to establish a default EPS bearer context between the UE + and the EPC. - The procedure is initiated by the network as a response to - the PDN CONNECTIVITY REQUEST message received from the UE. - It can be part of the attach procedure. + The procedure is initiated by the network as a response to + the PDN CONNECTIVITY REQUEST message received from the UE. + It can be part of the attach procedure. *****************************************************************************/ @@ -53,8 +53,8 @@ Description Defines the default EPS bearer context activation ESM */ #ifdef NAS_UE static struct { - int ebi; /* EPS bearer identity of the default EPS bearer associated - * to the PDN connection to be activated */ + int ebi; /* EPS bearer identity of the default EPS bearer associated + * to the PDN connection to be activated */ } _default_eps_bearer_context_data = {ESM_EBI_UNASSIGNED}; #endif // NAS_UE @@ -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 +#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 /****************************************************************************/ @@ -91,48 +91,48 @@ static int _default_eps_bearer_activate(unsigned int ueid, int ebi, #ifdef NAS_MME /**************************************************************************** ** ** - ** Name: esm_proc_default_eps_bearer_context() ** + ** Name: esm_proc_default_eps_bearer_context() ** ** ** ** Description: Allocates resources required for activation of a default ** - ** EPS bearer context. ** + ** EPS bearer context. ** ** ** - ** Inputs: ueid: UE local identifier ** - ** pid: PDN connection identifier ** - ** qos: EPS bearer level QoS parameters ** - ** Others: None ** + ** Inputs: ueid: UE local identifier ** + ** pid: PDN connection identifier ** + ** qos: EPS bearer level QoS parameters ** + ** Others: None ** ** ** - ** Outputs: ebi: EPS bearer identity assigned to the de- ** - ** fault EPS bearer context ** - ** esm_cause: Cause code returned upon ESM procedure ** - ** failure ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: ebi: EPS bearer identity assigned to the de- ** + ** fault EPS bearer context ** + ** esm_cause: Cause code returned upon ESM procedure ** + ** failure ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ 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; LOG_TRACE(INFO, "ESM-PROC - Default EPS bearer context activation " - "(ueid=%u, pid=%d)", ueid, pid); + "(ueid=%u, pid=%d)", ueid, pid); /* Assign new EPS bearer context */ *ebi = esm_ebr_assign(ueid, ESM_EBI_UNASSIGNED); if (*ebi != ESM_EBI_UNASSIGNED) { - /* Create default EPS bearer context */ - *ebi = esm_ebr_context_create(ueid, pid, *ebi, TRUE, qos, NULL); - if (*ebi == ESM_EBI_UNASSIGNED) { - /* No resource available */ - LOG_TRACE(WARNING, "ESM-PROC - Failed to create new default EPS " - "bearer context (ebi=%d)", *ebi); - *esm_cause = ESM_CAUSE_INSUFFICIENT_RESOURCES; - LOG_FUNC_RETURN (RETURNerror); - } - LOG_FUNC_RETURN (RETURNok); + /* Create default EPS bearer context */ + *ebi = esm_ebr_context_create(ueid, pid, *ebi, TRUE, qos, NULL); + if (*ebi == ESM_EBI_UNASSIGNED) { + /* No resource available */ + LOG_TRACE(WARNING, "ESM-PROC - Failed to create new default EPS " + "bearer context (ebi=%d)", *ebi); + *esm_cause = ESM_CAUSE_INSUFFICIENT_RESOURCES; + LOG_FUNC_RETURN (RETURNerror); + } + LOG_FUNC_RETURN (RETURNok); } LOG_TRACE(WARNING, "ESM-PROC - Failed to assign new EPS bearer context"); @@ -142,58 +142,58 @@ int esm_proc_default_eps_bearer_context(unsigned int ueid, int pid, /**************************************************************************** ** ** - ** Name: esm_proc_default_eps_bearer_context_request() ** + ** Name: esm_proc_default_eps_bearer_context_request() ** ** ** ** Description: Initiates the default EPS bearer context activation pro- ** - ** cedure ** - ** ** - ** 3GPP TS 24.301, section 6.4.1.2 ** - ** The MME initiates the default EPS bearer context activa- ** - ** tion procedure by sending an ACTIVATE DEFAULT EPS BEARER ** - ** CONTEXT REQUEST message, starting timer T3485 and ente- ** - ** ring state BEARER CONTEXT ACTIVE PENDING. ** - ** ** - ** Inputs: is_standalone: Indicate whether the default bearer is ** - ** activated as part of the attach procedure ** - ** or as the response to a stand-alone PDN ** - ** CONNECTIVITY REQUEST message ** - ** ueid: UE lower layer identifier ** - ** ebi: EPS bearer identity ** - ** msg: Encoded ESM message to be sent ** - ** ue_triggered: TRUE if the EPS bearer context procedure ** - ** was triggered by the UE ** - ** Others: None ** - ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** cedure ** + ** ** + ** 3GPP TS 24.301, section 6.4.1.2 ** + ** The MME initiates the default EPS bearer context activa- ** + ** tion procedure by sending an ACTIVATE DEFAULT EPS BEARER ** + ** CONTEXT REQUEST message, starting timer T3485 and ente- ** + ** ring state BEARER CONTEXT ACTIVE PENDING. ** + ** ** + ** Inputs: is_standalone: Indicate whether the default bearer is ** + ** activated as part of the attach procedure ** + ** or as the response to a stand-alone PDN ** + ** CONNECTIVITY REQUEST message ** + ** ueid: UE lower layer identifier ** + ** ebi: EPS bearer identity ** + ** msg: Encoded ESM message to be sent ** + ** ue_triggered: TRUE if the EPS bearer context procedure ** + ** was triggered by the UE ** + ** Others: None ** + ** ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ int esm_proc_default_eps_bearer_context_request(int is_standalone, - unsigned int ueid, int ebi, - OctetString* msg, int ue_triggered) + unsigned int ueid, int ebi, + OctetString *msg, int ue_triggered) { LOG_FUNC_IN; int rc = RETURNok; LOG_TRACE(INFO,"ESM-PROC - Initiate default EPS bearer context activation " - "(ueid=%d, ebi=%d)", ueid, ebi); + "(ueid=%d, ebi=%d)", ueid, ebi); if (is_standalone) { - /* Send activate default EPS bearer context request message and - * start timer T3485 */ - rc = _default_eps_bearer_activate(ueid, ebi, msg); + /* Send activate default EPS bearer context request message and + * start timer T3485 */ + rc = _default_eps_bearer_activate(ueid, ebi, msg); } if (rc != RETURNerror) { - /* Set the EPS bearer context state to ACTIVE PENDING */ - rc = esm_ebr_set_status(ueid, ebi, ESM_EBR_ACTIVE_PENDING, ue_triggered); - if (rc != RETURNok) { - /* The EPS bearer context was already in ACTIVE PENDING state */ - LOG_TRACE(WARNING, "ESM-PROC - EBI %d was already ACTIVE PENDING", - ebi); - } + /* Set the EPS bearer context state to ACTIVE PENDING */ + rc = esm_ebr_set_status(ueid, ebi, ESM_EBR_ACTIVE_PENDING, ue_triggered); + if (rc != RETURNok) { + /* The EPS bearer context was already in ACTIVE PENDING state */ + LOG_TRACE(WARNING, "ESM-PROC - EBI %d was already ACTIVE PENDING", + ebi); + } } LOG_FUNC_RETURN (rc); @@ -201,46 +201,46 @@ int esm_proc_default_eps_bearer_context_request(int is_standalone, /**************************************************************************** ** ** - ** Name: esm_proc_default_eps_bearer_context_accept() ** + ** Name: esm_proc_default_eps_bearer_context_accept() ** ** ** ** Description: Performs default EPS bearer context activation procedure ** - ** accepted by the UE. ** + ** accepted by the UE. ** ** ** - ** 3GPP TS 24.301, section 6.4.1.3 ** - ** Upon receipt of the ACTIVATE DEFAULT EPS BEARER CONTEXT ** - ** ACCEPT message, the MME shall enter the state BEARER CON- ** - ** TEXT ACTIVE and stop the timer T3485, if it is running. ** + ** 3GPP TS 24.301, section 6.4.1.3 ** + ** Upon receipt of the ACTIVATE DEFAULT EPS BEARER CONTEXT ** + ** ACCEPT message, the MME shall enter the state BEARER CON- ** + ** TEXT ACTIVE and stop the timer T3485, if it is running. ** ** ** - ** Inputs: ueid: UE local identifier ** - ** ebi: EPS bearer identity ** - ** Others: None ** + ** Inputs: ueid: UE local identifier ** + ** ebi: EPS bearer identity ** + ** Others: None ** ** ** - ** Outputs: esm_cause: Cause code returned upon ESM procedure ** - ** failure ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: esm_cause: Cause code returned upon ESM procedure ** + ** failure ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ int esm_proc_default_eps_bearer_context_accept(unsigned int ueid, int ebi, - int* esm_cause) + int *esm_cause) { LOG_FUNC_IN; int rc; LOG_TRACE(INFO, "ESM-PROC - Default EPS bearer context activation " - "accepted by the UE (ueid=%u, ebi=%d)", ueid, ebi); + "accepted by the UE (ueid=%u, ebi=%d)", ueid, ebi); /* Stop T3485 timer if running */ rc = esm_ebr_stop_timer(ueid, ebi); if (rc != RETURNerror) { - /* Set the EPS bearer context state to ACTIVE */ - rc = esm_ebr_set_status(ueid, ebi, ESM_EBR_ACTIVE, FALSE); - if (rc != RETURNok) { - /* The EPS bearer context was already in ACTIVE state */ - LOG_TRACE(WARNING, "ESM-PROC - EBI %d was already ACTIVE", ebi); - *esm_cause = ESM_CAUSE_PROTOCOL_ERROR; - } + /* Set the EPS bearer context state to ACTIVE */ + rc = esm_ebr_set_status(ueid, ebi, ESM_EBR_ACTIVE, FALSE); + if (rc != RETURNok) { + /* The EPS bearer context was already in ACTIVE state */ + LOG_TRACE(WARNING, "ESM-PROC - EBI %d was already ACTIVE", ebi); + *esm_cause = ESM_CAUSE_PROTOCOL_ERROR; + } } LOG_FUNC_RETURN (rc); @@ -248,47 +248,47 @@ int esm_proc_default_eps_bearer_context_accept(unsigned int ueid, int ebi, /**************************************************************************** ** ** - ** Name: esm_proc_default_eps_bearer_context_reject() ** + ** Name: esm_proc_default_eps_bearer_context_reject() ** ** ** ** Description: Performs default EPS bearer context activation procedure ** - ** not accepted by the UE. ** + ** not accepted by the UE. ** ** ** - ** 3GPP TS 24.301, section 6.4.1.4 ** - ** Upon receipt of the ACTIVATE DEFAULT EPS BEARER CONTEXT ** - ** REJECT message, the MME shall enter the state BEARER CON- ** - ** TEXT INACTIVE and stop the timer T3485, if it is running. ** + ** 3GPP TS 24.301, section 6.4.1.4 ** + ** Upon receipt of the ACTIVATE DEFAULT EPS BEARER CONTEXT ** + ** REJECT message, the MME shall enter the state BEARER CON- ** + ** TEXT INACTIVE and stop the timer T3485, if it is running. ** ** ** - ** Inputs: ueid: UE local identifier ** - ** ebi: EPS bearer identity ** - ** Others: None ** + ** Inputs: ueid: UE local identifier ** + ** ebi: EPS bearer identity ** + ** Others: None ** ** ** - ** Outputs: esm_cause: Cause code returned upon ESM procedure ** - ** failure ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: esm_cause: Cause code returned upon ESM procedure ** + ** failure ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ int esm_proc_default_eps_bearer_context_reject(unsigned int ueid, int ebi, - int* esm_cause) + int *esm_cause) { LOG_FUNC_IN; int rc; LOG_TRACE(WARNING, "ESM-PROC - Default EPS bearer context activation " - "not accepted by the UE (ueid=%u, ebi=%d)", ueid, ebi); + "not accepted by the UE (ueid=%u, ebi=%d)", ueid, ebi); /* Stop T3485 timer if running */ rc = esm_ebr_stop_timer(ueid, ebi); if (rc != RETURNerror) { - int pid, bid; - /* Release the default EPS bearer context and enter state INACTIVE */ - rc = esm_proc_eps_bearer_context_deactivate(ueid, TRUE, ebi, - &pid, &bid, NULL); - if (rc != RETURNok) { - /* Failed to release the default EPS bearer context */ - *esm_cause = ESM_CAUSE_PROTOCOL_ERROR; - } + int pid, bid; + /* Release the default EPS bearer context and enter state INACTIVE */ + rc = esm_proc_eps_bearer_context_deactivate(ueid, TRUE, ebi, + &pid, &bid, NULL); + if (rc != RETURNok) { + /* Failed to release the default EPS bearer context */ + *esm_cause = ESM_CAUSE_PROTOCOL_ERROR; + } } LOG_FUNC_RETURN (rc); @@ -296,26 +296,26 @@ int esm_proc_default_eps_bearer_context_reject(unsigned int ueid, int ebi, /**************************************************************************** ** ** - ** Name: esm_proc_default_eps_bearer_context_failure() ** + ** Name: esm_proc_default_eps_bearer_context_failure() ** ** ** ** Description: Performs default EPS bearer context activation procedure ** - ** upon receiving notification from the EPS Mobility Manage- ** - ** ment sublayer that EMM procedure that initiated EPS de- ** - ** fault bearer context activation locally failed. ** + ** upon receiving notification from the EPS Mobility Manage- ** + ** ment sublayer that EMM procedure that initiated EPS de- ** + ** fault bearer context activation locally failed. ** ** ** - ** The MME releases the default EPS bearer context previous- ** - ** ly allocated when ACTIVATE DEFAULT EPS BEARER CONTEXT RE- ** - ** QUEST message was received. ** + ** The MME releases the default EPS bearer context previous- ** + ** ly allocated when ACTIVATE DEFAULT EPS BEARER CONTEXT RE- ** + ** QUEST message was received. ** ** ** - ** Inputs: ueid: UE local identifier ** - ** Others: None ** + ** Inputs: ueid: UE local identifier ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: The identifier of the PDN connection the ** - ** default EPS bearer context belongs to if ** - ** successfully released; ** - ** RETURNerror otherwise. ** - ** Others: None ** + ** Outputs: None ** + ** Return: The identifier of the PDN connection the ** + ** default EPS bearer context belongs to if ** + ** successfully released; ** + ** RETURNerror otherwise. ** + ** Others: None ** ** ** ***************************************************************************/ int esm_proc_default_eps_bearer_context_failure(unsigned int ueid) @@ -326,20 +326,20 @@ int esm_proc_default_eps_bearer_context_failure(unsigned int ueid) int pid; LOG_TRACE(WARNING, "ESM-PROC - Default EPS bearer context activation " - "failure (ueid=%u)", ueid); + "failure (ueid=%u)", ueid); /* Get the EPS bearer identity of the EPS bearer context which is still * pending in the active pending state */ int ebi = esm_ebr_get_pending_ebi(ueid, ESM_EBR_ACTIVE_PENDING); if (ebi != ESM_EBI_UNASSIGNED) { - int bid; - /* Release the default EPS bearer context and enter state INACTIVE */ - rc = esm_proc_eps_bearer_context_deactivate(ueid, TRUE, ebi, - &pid, &bid, NULL); + int bid; + /* Release the default EPS bearer context and enter state INACTIVE */ + rc = esm_proc_eps_bearer_context_deactivate(ueid, TRUE, ebi, + &pid, &bid, NULL); } if (rc != RETURNerror) { - LOG_FUNC_RETURN (pid); + LOG_FUNC_RETURN (pid); } LOG_FUNC_RETURN (RETURNerror); } @@ -354,69 +354,67 @@ int esm_proc_default_eps_bearer_context_failure(unsigned int ueid) #ifdef NAS_UE /**************************************************************************** ** ** - ** Name: esm_proc_default_eps_bearer_context_request() ** + ** Name: esm_proc_default_eps_bearer_context_request() ** ** ** ** Description: Creates local default EPS bearer context upon receipt of ** - ** the ACTIVATE DEFAULT EPS BEARER CONTEXT REQUEST message. ** + ** the ACTIVATE DEFAULT EPS BEARER CONTEXT REQUEST message. ** ** ** - ** Inputs: pid: PDN connection identifier ** - ** ebi: EPS bearer identity ** - ** qos: EPS bearer level QoS parameters ** - ** Others: None ** + ** Inputs: pid: PDN connection identifier ** + ** ebi: EPS bearer identity ** + ** qos: EPS bearer level QoS parameters ** + ** Others: None ** ** ** - ** Outputs: esm_cause: Cause code returned upon ESM procedure ** - ** failure ** - ** Return: RETURNok, RETURNerror ** - ** Others: _default_eps_bearer_context_data ** + ** Outputs: esm_cause: Cause code returned upon ESM procedure ** + ** failure ** + ** Return: RETURNok, RETURNerror ** + ** Others: _default_eps_bearer_context_data ** ** ** ***************************************************************************/ 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; int rc = RETURNerror; LOG_TRACE(INFO, "ESM-PROC - Default EPS bearer context activation " - "requested by the network (ebi=%d)", ebi); + "requested by the network (ebi=%d)", ebi); /* Assign default EPS bearer context */ int new_ebi = esm_ebr_assign(ebi, pid+1, TRUE); if (new_ebi == ESM_EBI_UNASSIGNED) { - /* 3GPP TS 24.301, section 6.4.1.5, abnormal cases a and b - * Default EPS bearer context activation request for an already - * activated default or dedicated EPS bearer context - */ - int old_pid, old_bid; - /* Locally deactivate the existing EPS bearer context and proceed - * with the requested default EPS bearer context activation */ - rc = esm_proc_eps_bearer_context_deactivate(TRUE, ebi, - &old_pid, &old_bid); - if (rc != RETURNok) { - /* Failed to release EPS bearer context */ - *esm_cause = ESM_CAUSE_PROTOCOL_ERROR; - } - else { - /* Assign new default EPS bearer context */ - ebi = esm_ebr_assign(ebi, pid+1, TRUE); - } + /* 3GPP TS 24.301, section 6.4.1.5, abnormal cases a and b + * Default EPS bearer context activation request for an already + * activated default or dedicated EPS bearer context + */ + int old_pid, old_bid; + /* Locally deactivate the existing EPS bearer context and proceed + * with the requested default EPS bearer context activation */ + rc = esm_proc_eps_bearer_context_deactivate(TRUE, ebi, + &old_pid, &old_bid); + if (rc != RETURNok) { + /* Failed to release EPS bearer context */ + *esm_cause = ESM_CAUSE_PROTOCOL_ERROR; + } else { + /* Assign new default EPS bearer context */ + ebi = esm_ebr_assign(ebi, pid+1, TRUE); + } } if (ebi != ESM_EBI_UNASSIGNED) { - /* Create new default EPS bearer context */ - ebi = esm_ebr_context_create(pid, ebi, TRUE, qos, NULL); - if (ebi != ESM_EBI_UNASSIGNED) { - /* Default EPS bearer contextx successfully created */ - _default_eps_bearer_context_data.ebi = ebi; - rc = RETURNok; - } - else { - /* No resource available */ - LOG_TRACE(WARNING, "ESM-PROC - Failed to create new default EPS " - "bearer context"); - *esm_cause = ESM_CAUSE_INSUFFICIENT_RESOURCES; - } + /* Create new default EPS bearer context */ + ebi = esm_ebr_context_create(pid, ebi, TRUE, qos, NULL); + if (ebi != ESM_EBI_UNASSIGNED) { + /* Default EPS bearer contextx successfully created */ + _default_eps_bearer_context_data.ebi = ebi; + rc = RETURNok; + } else { + /* No resource available */ + LOG_TRACE(WARNING, "ESM-PROC - Failed to create new default EPS " + "bearer context"); + *esm_cause = ESM_CAUSE_INSUFFICIENT_RESOURCES; + } } LOG_FUNC_RETURN (rc); @@ -424,68 +422,68 @@ int esm_proc_default_eps_bearer_context_request(int pid, int ebi, /**************************************************************************** ** ** - ** Name: esm_proc_default_eps_bearer_context_accept() ** + ** Name: esm_proc_default_eps_bearer_context_accept() ** ** ** ** Description: Performs default EPS bearer context activation procedure ** - ** accepted by the UE. ** - ** ** - ** 3GPP TS 24.301, section 6.4.1.3 ** - ** The UE accepts default EPS bearer context activation by ** - ** sending ACTIVATE DEFAULT EPS BEARER CONTEXT ACCEPT mes- ** - ** sage and entering the state BEARER CONTEXT ACTIVE. ** - ** If the default bearer is activated as part of the attach ** - ** procedure, the UE shall send the accept message together ** - ** with ATTACH COMPLETE message. ** - ** ** - ** Inputs: is_standalone: Indicates whether the activate default EPS ** - ** bearer context accept has to be sent stand-** - ** alone or together within an attach comple- ** - ** te message ** - ** ebi: EPS bearer identity ** - ** msg: Encoded ESM message to be sent ** - ** ue_triggered: TRUE if the EPS bearer context procedure ** - ** was triggered by the UE (should be always ** - ** TRUE) ** - ** Others: None ** - ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** accepted by the UE. ** + ** ** + ** 3GPP TS 24.301, section 6.4.1.3 ** + ** The UE accepts default EPS bearer context activation by ** + ** sending ACTIVATE DEFAULT EPS BEARER CONTEXT ACCEPT mes- ** + ** sage and entering the state BEARER CONTEXT ACTIVE. ** + ** If the default bearer is activated as part of the attach ** + ** procedure, the UE shall send the accept message together ** + ** with ATTACH COMPLETE message. ** + ** ** + ** Inputs: is_standalone: Indicates whether the activate default EPS ** + ** bearer context accept has to be sent stand-** + ** alone or together within an attach comple- ** + ** te message ** + ** ebi: EPS bearer identity ** + ** msg: Encoded ESM message to be sent ** + ** ue_triggered: TRUE if the EPS bearer context procedure ** + ** was triggered by the UE (should be always ** + ** TRUE) ** + ** Others: None ** + ** ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ 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; int rc = RETURNok; LOG_TRACE(INFO,"ESM-PROC - Default EPS bearer context activation " - "accepted by the UE (ebi=%d)", ebi); + "accepted by the UE (ebi=%d)", ebi); if (is_standalone) { - emm_sap_t emm_sap; - emm_esm_data_t *emm_esm = &emm_sap.u.emm_esm.u.data; - /* - * Notity EMM that ESM PDU has to be forwarded to lower layers - */ - emm_sap.primitive = EMMESM_UNITDATA_REQ; - emm_sap.u.emm_esm.ueid = 0; - emm_esm->msg.length = msg->length; - emm_esm->msg.value = msg->value; - rc = emm_sap_send(&emm_sap); + emm_sap_t emm_sap; + emm_esm_data_t *emm_esm = &emm_sap.u.emm_esm.u.data; + /* + * Notity EMM that ESM PDU has to be forwarded to lower layers + */ + emm_sap.primitive = EMMESM_UNITDATA_REQ; + emm_sap.u.emm_esm.ueid = 0; + emm_esm->msg.length = msg->length; + emm_esm->msg.value = msg->value; + rc = emm_sap_send(&emm_sap); } if (rc != RETURNerror) { - /* Set the EPS bearer context state to ACTIVE */ - rc = esm_ebr_set_status(ebi, ESM_EBR_ACTIVE, ue_triggered); - if (rc != RETURNok) { - /* The EPS bearer context was already in ACTIVE state */ - LOG_TRACE(WARNING, "ESM-PROC - EBI %d was already ACTIVE", ebi); - /* Accept network retransmission of already accepted activate - * default EPS bearer context request */ - LOG_FUNC_RETURN (RETURNok); - } + /* Set the EPS bearer context state to ACTIVE */ + rc = esm_ebr_set_status(ebi, ESM_EBR_ACTIVE, ue_triggered); + if (rc != RETURNok) { + /* The EPS bearer context was already in ACTIVE state */ + LOG_TRACE(WARNING, "ESM-PROC - EBI %d was already ACTIVE", ebi); + /* Accept network retransmission of already accepted activate + * default EPS bearer context request */ + LOG_FUNC_RETURN (RETURNok); + } } LOG_FUNC_RETURN (rc); @@ -493,69 +491,67 @@ int esm_proc_default_eps_bearer_context_accept(int is_standalone, int ebi, /**************************************************************************** ** ** - ** Name: esm_proc_default_eps_bearer_context_reject() ** + ** Name: esm_proc_default_eps_bearer_context_reject() ** ** ** ** Description: Performs default EPS bearer context activation procedure ** - ** not accepted by the UE. ** - ** ** - ** 3GPP TS 24.301, section 6.4.1.4 ** - ** The UE rejects default EPS bearer context activation by ** - ** sending ACTIVATE DEFAULT EPS BEARER CONTEXT REJECT mes- ** - ** sage and entering the state BEARER CONTEXT INACTIVE. ** - ** If the default EPS bearer context activation is part of ** - ** the attach procedure, the ESM sublayer shall notify the ** - ** EMM sublayer of an ESM failure. ** - ** ** - ** Inputs: is_standalone: Indicates whether the activate default EPS ** - ** bearer context accept has to be sent stand-** - ** alone or together within an attach comple- ** - ** te message ** - ** ebi: EPS bearer identity ** - ** msg: Encoded ESM message to be sent ** - ** ue_triggered: Not used ** - ** Others: None ** - ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** not accepted by the UE. ** + ** ** + ** 3GPP TS 24.301, section 6.4.1.4 ** + ** The UE rejects default EPS bearer context activation by ** + ** sending ACTIVATE DEFAULT EPS BEARER CONTEXT REJECT mes- ** + ** sage and entering the state BEARER CONTEXT INACTIVE. ** + ** If the default EPS bearer context activation is part of ** + ** the attach procedure, the ESM sublayer shall notify the ** + ** EMM sublayer of an ESM failure. ** + ** ** + ** Inputs: is_standalone: Indicates whether the activate default EPS ** + ** bearer context accept has to be sent stand-** + ** alone or together within an attach comple- ** + ** te message ** + ** ebi: EPS bearer identity ** + ** msg: Encoded ESM message to be sent ** + ** ue_triggered: Not used ** + ** Others: None ** + ** ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ 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; int rc = RETURNok; LOG_TRACE(WARNING, "ESM-PROC - Default EPS bearer context activation " - "not accepted by the UE (ebi=%d)", ebi); + "not accepted by the UE (ebi=%d)", ebi); if ( !esm_ebr_is_not_in_use(ebi) ) { - /* Release EPS bearer data currently in use */ - rc = esm_ebr_release(ebi); + /* Release EPS bearer data currently in use */ + rc = esm_ebr_release(ebi); } if (rc != RETURNok) { - LOG_TRACE(WARNING, "ESM-PROC - Failed to release EPS bearer data"); - } - else if (is_standalone) { - emm_sap_t emm_sap; - emm_esm_data_t *emm_esm = &emm_sap.u.emm_esm.u.data; - /* - * Notity EMM that ESM PDU has to be forwarded to lower layers - */ - emm_sap.primitive = EMMESM_UNITDATA_REQ; - emm_sap.u.emm_esm.ueid = 0; - emm_esm->msg.length = msg->length; - emm_esm->msg.value = msg->value; - rc = emm_sap_send(&emm_sap); - } - 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 - */ - rc = RETURNerror; + LOG_TRACE(WARNING, "ESM-PROC - Failed to release EPS bearer data"); + } else if (is_standalone) { + emm_sap_t emm_sap; + emm_esm_data_t *emm_esm = &emm_sap.u.emm_esm.u.data; + /* + * Notity EMM that ESM PDU has to be forwarded to lower layers + */ + emm_sap.primitive = EMMESM_UNITDATA_REQ; + emm_sap.u.emm_esm.ueid = 0; + emm_esm->msg.length = msg->length; + emm_esm->msg.value = msg->value; + rc = emm_sap_send(&emm_sap); + } 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 + */ + rc = RETURNerror; } LOG_FUNC_RETURN (rc); @@ -563,20 +559,20 @@ int esm_proc_default_eps_bearer_context_reject(int is_standalone, int ebi, /**************************************************************************** ** ** - ** Name: esm_proc_default_eps_bearer_context_complete() ** + ** Name: esm_proc_default_eps_bearer_context_complete() ** ** ** ** Description: Terminates the default EPS bearer context activation pro- ** - ** cedure upon receiving indication from the EPS Mobility ** - ** Management sublayer that the ACTIVATE DEFAULT EPS BEARER ** - ** CONTEXT ACCEPT message has been successfully delivered to ** - ** the MME. ** + ** cedure upon receiving indication from the EPS Mobility ** + ** Management sublayer that the ACTIVATE DEFAULT EPS BEARER ** + ** CONTEXT ACCEPT message has been successfully delivered to ** + ** the MME. ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: _default_eps_bearer_context_data ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: _default_eps_bearer_context_data ** ** ** ***************************************************************************/ int esm_proc_default_eps_bearer_context_complete(void) @@ -584,7 +580,7 @@ int esm_proc_default_eps_bearer_context_complete(void) LOG_FUNC_IN; LOG_TRACE(INFO, - "ESM-PROC - Default EPS bearer context activation complete"); + "ESM-PROC - Default EPS bearer context activation complete"); /* Reset default EPS bearer context internal data */ _default_eps_bearer_context_data.ebi = ESM_EBI_UNASSIGNED; @@ -594,22 +590,22 @@ int esm_proc_default_eps_bearer_context_complete(void) /**************************************************************************** ** ** - ** Name: esm_proc_default_eps_bearer_context_failure() ** + ** Name: esm_proc_default_eps_bearer_context_failure() ** ** ** ** Description: Performs default EPS bearer context activation procedure ** - ** upon receiving transmission failure of ESM message indi- ** - ** cation from the EPS Mobility Management sublayer ** + ** upon receiving transmission failure of ESM message indi- ** + ** cation from the EPS Mobility Management sublayer ** ** ** - ** The UE releases the default EPS bearer context previously ** - ** allocated before the ACTIVATE DEFAULT EPS BEARER CONTEXT ** - ** ACCEPT message was sent. ** + ** The UE releases the default EPS bearer context previously ** + ** allocated before the ACTIVATE DEFAULT EPS BEARER CONTEXT ** + ** ACCEPT message was sent. ** ** ** - ** Inputs: None ** - ** Others: _default_eps_bearer_context_data ** + ** Inputs: None ** + ** Others: _default_eps_bearer_context_data ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: _default_eps_bearer_context_data ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: _default_eps_bearer_context_data ** ** ** ***************************************************************************/ int esm_proc_default_eps_bearer_context_failure(void) @@ -620,13 +616,13 @@ int esm_proc_default_eps_bearer_context_failure(void) int pid, bid; LOG_TRACE(WARNING, - "ESM-PROC - Default EPS bearer context activation failure"); + "ESM-PROC - Default EPS bearer context activation failure"); /* Release the default EPS bearer context and enter state INACTIVE */ int rc = esm_proc_eps_bearer_context_deactivate(TRUE, ebi, &pid, &bid); if (rc != RETURNerror) { - /* Reset default EPS bearer context internal data */ - _default_eps_bearer_context_data.ebi = ESM_EBI_UNASSIGNED; + /* Reset default EPS bearer context internal data */ + _default_eps_bearer_context_data.ebi = ESM_EBI_UNASSIGNED; } LOG_FUNC_RETURN (rc); @@ -639,67 +635,66 @@ int esm_proc_default_eps_bearer_context_failure(void) /* * -------------------------------------------------------------------------- - * Timer handlers + * Timer handlers * -------------------------------------------------------------------------- */ #ifdef NAS_MME /**************************************************************************** ** ** - ** Name: _default_eps_bearer_activate_t3485_handler() ** + ** Name: _default_eps_bearer_activate_t3485_handler() ** ** ** ** Description: T3485 timeout handler ** ** ** ** 3GPP TS 24.301, section 6.4.1.6, case a ** - ** On the first expiry of the timer T3485, the MME shall re- ** - ** send the ACTIVATE DEFAULT EPS BEARER CONTEXT REQUEST and ** - ** shall reset and restart timer T3485. This retransmission ** - ** is repeated four times, i.e. on the fifth expiry of timer ** - ** T3485, the MME shall release possibly allocated resources ** - ** for this activation and shall abort the procedure. ** + ** On the first expiry of the timer T3485, the MME shall re- ** + ** send the ACTIVATE DEFAULT EPS BEARER CONTEXT REQUEST and ** + ** shall reset and restart timer T3485. This retransmission ** + ** is repeated four times, i.e. on the fifth expiry of timer ** + ** T3485, the MME shall release possibly allocated resources ** + ** for this activation and shall abort the procedure. ** ** ** - ** Inputs: args: handler parameters ** - ** Others: None ** + ** Inputs: args: handler parameters ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: None ** - ** Others: None ** + ** Outputs: None ** + ** Return: None ** + ** 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; LOG_TRACE(WARNING, "ESM-PROC - T3485 timer expired (ueid=%d, ebi=%d), " - "retransmission counter = %d", - data->ueid, data->ebi, data->count); + "retransmission counter = %d", + data->ueid, data->ebi, data->count); if (data->count < DEFAULT_EPS_BEARER_ACTIVATE_COUNTER_MAX) { - /* Re-send activate default EPS bearer context request message - * to the UE */ - rc = _default_eps_bearer_activate(data->ueid, data->ebi, &data->msg); - } - else { - /* - * The maximum number of activate default EPS bearer context request - * message retransmission has exceed - */ - int pid, bid; - /* Release the default EPS bearer context and enter state INACTIVE */ - rc = esm_proc_eps_bearer_context_deactivate(data->ueid, TRUE, - data->ebi, &pid, &bid, - NULL); - if (rc != RETURNerror) { - /* Stop timer T3485 */ - rc = esm_ebr_stop_timer(data->ueid, data->ebi); - } + /* Re-send activate default EPS bearer context request message + * to the UE */ + rc = _default_eps_bearer_activate(data->ueid, data->ebi, &data->msg); + } else { + /* + * The maximum number of activate default EPS bearer context request + * message retransmission has exceed + */ + int pid, bid; + /* Release the default EPS bearer context and enter state INACTIVE */ + rc = esm_proc_eps_bearer_context_deactivate(data->ueid, TRUE, + data->ebi, &pid, &bid, + NULL); + if (rc != RETURNerror) { + /* Stop timer T3485 */ + rc = esm_ebr_stop_timer(data->ueid, data->ebi); + } } LOG_FUNC_RETURN (NULL); @@ -707,29 +702,29 @@ static void* _default_eps_bearer_activate_t3485_handler(void* args) /* * -------------------------------------------------------------------------- - * MME specific local functions + * MME specific local functions * -------------------------------------------------------------------------- */ /**************************************************************************** ** ** - ** Name: _default_eps_bearer_activate() ** + ** Name: _default_eps_bearer_activate() ** ** ** ** Description: Sends ACTIVATE DEFAULT EPS BEREAR CONTEXT REQUEST message ** - ** and starts timer T3485 ** + ** and starts timer T3485 ** ** ** - ** Inputs: ueid: UE local identifier ** - ** ebi: EPS bearer identity ** - ** msg: Encoded ESM message to be sent ** - ** Others: None ** + ** Inputs: ueid: UE local identifier ** + ** ebi: EPS bearer identity ** + ** msg: Encoded ESM message to be sent ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: T3485 ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: T3485 ** ** ** ***************************************************************************/ static int _default_eps_bearer_activate(unsigned int ueid, int ebi, - const OctetString* msg) + const OctetString *msg) { LOG_FUNC_IN; @@ -747,9 +742,9 @@ static int _default_eps_bearer_activate(unsigned int ueid, int ebi, rc = emm_sap_send(&emm_sap); if (rc != RETURNerror) { - /* Start T3485 retransmission timer */ - rc = esm_ebr_start_timer(ueid, ebi, msg, T3485_DEFAULT_VALUE, - _default_eps_bearer_activate_t3485_handler); + /* Start T3485 retransmission timer */ + rc = esm_ebr_start_timer(ueid, ebi, msg, T3485_DEFAULT_VALUE, + _default_eps_bearer_activate_t3485_handler); } LOG_FUNC_RETURN (rc); diff --git a/openair-cn/NAS/EURECOM-NAS/src/esm/EpsBearerContextDeactivation.c b/openair-cn/NAS/EURECOM-NAS/src/esm/EpsBearerContextDeactivation.c index 2e534a58ef..e78582cf5c 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/esm/EpsBearerContextDeactivation.c +++ b/openair-cn/NAS/EURECOM-NAS/src/esm/EpsBearerContextDeactivation.c @@ -1,29 +1,29 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source EpsBearerContextDeactivation.c +Source EpsBearerContextDeactivation.c -Version 0.1 +Version 0.1 -Date 2013/05/22 +Date 2013/05/22 -Product NAS stack +Product NAS stack -Subsystem EPS Session Management +Subsystem EPS Session Management -Author Frederic Maurel +Author Frederic Maurel -Description Defines the EPS bearer context deactivation ESM procedure - executed by the Non-Access Stratum. +Description Defines the EPS bearer context deactivation ESM procedure + executed by the Non-Access Stratum. - The purpose of the EPS bearer context deactivation procedure - is to deactivate an EPS bearer context or disconnect from a - PDN by deactivating all EPS bearer contexts to the PDN. - The EPS bearer context deactivation procedure is initiated - by the network, and it may be triggered by the UE by means - of the UE requested bearer resource modification procedure - or UE requested PDN disconnect procedure. + The purpose of the EPS bearer context deactivation procedure + is to deactivate an EPS bearer context or disconnect from a + PDN by deactivating all EPS bearer contexts to the PDN. + The EPS bearer context deactivation procedure is initiated + by the network, and it may be triggered by the UE by means + of the UE requested bearer resource modification procedure + or UE requested PDN disconnect procedure. *****************************************************************************/ @@ -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 +#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 @@ -89,96 +89,95 @@ static int _eps_bearer_release(unsigned int ueid, int ebi, int* pid, int* bid); /* * -------------------------------------------------------------------------- - * EPS bearer context deactivation procedure executed by the MME + * EPS bearer context deactivation procedure executed by the MME * -------------------------------------------------------------------------- */ #ifdef NAS_MME /**************************************************************************** ** ** - ** Name: esm_proc_eps_bearer_context_deactivate() ** + ** Name: esm_proc_eps_bearer_context_deactivate() ** ** ** ** Description: Locally releases the EPS bearer context identified by the ** - ** given EPS bearer identity, without peer-to-peer signal- ** - ** ling between the UE and the MME, or checks whether an EPS ** - ** bearer context with specified EPS bearer identity has ** - ** been activated for the given UE. ** - ** ** - ** Inputs: ueid: UE lower layer identifier ** - ** is local: TRUE if the EPS bearer context has to be ** - ** locally released without peer-to-peer si- ** - ** gnalling between the UE and the MME ** - ** ebi: EPS bearer identity of the EPS bearer con- ** - ** text to be deactivated ** - ** Others: _esm_data ** - ** ** - ** Outputs: pid: Identifier of the PDN connection the EPS ** - ** bearer belongs to ** - ** bid: Identifier of the released EPS bearer con- ** - ** text entry ** - ** esm_cause: Cause code returned upon ESM procedure ** - ** failure ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** given EPS bearer identity, without peer-to-peer signal- ** + ** ling between the UE and the MME, or checks whether an EPS ** + ** bearer context with specified EPS bearer identity has ** + ** been activated for the given UE. ** + ** ** + ** Inputs: ueid: UE lower layer identifier ** + ** is local: TRUE if the EPS bearer context has to be ** + ** locally released without peer-to-peer si- ** + ** gnalling between the UE and the MME ** + ** ebi: EPS bearer identity of the EPS bearer con- ** + ** text to be deactivated ** + ** Others: _esm_data ** + ** ** + ** Outputs: pid: Identifier of the PDN connection the EPS ** + ** bearer belongs to ** + ** bid: Identifier of the released EPS bearer con- ** + ** text entry ** + ** esm_cause: Cause code returned upon ESM procedure ** + ** failure ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ 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; int rc = RETURNerror; if (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] ) { - /* 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; - } - } - } - LOG_FUNC_RETURN (rc); + 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] ) { + /* 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; + } + } + } + } + LOG_FUNC_RETURN (rc); } LOG_TRACE(INFO, "ESM-PROC - EPS bearer context deactivation " - "(ueid=%u, ebi=%d)", ueid, ebi); + "(ueid=%u, ebi=%d)", ueid, ebi); if ( (ueid < ESM_DATA_NB_UE_MAX) && (_esm_data.ctx[ueid] != NULL) && - (*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) { - 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) { - LOG_TRACE(WARNING, "ESM-PROC - PDN connection %d is not active", - *pid); - *esm_cause = ESM_CAUSE_PROTOCOL_ERROR; - } - else { + (*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) { + 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) { + LOG_TRACE(WARNING, "ESM-PROC - PDN connection %d is not active", + *pid); + *esm_cause = ESM_CAUSE_PROTOCOL_ERROR; + } else { int i; - *esm_cause = ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY; - 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; - /* The EPS bearer context to be released is valid */ - rc = RETURNok; - } - } + *esm_cause = ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY; + 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; + } + /* The EPS bearer context to be released is valid */ + rc = RETURNok; + } + } } LOG_FUNC_RETURN (rc); @@ -186,53 +185,53 @@ int esm_proc_eps_bearer_context_deactivate(unsigned int ueid, int is_local, /**************************************************************************** ** ** - ** Name: esm_proc_eps_bearer_context_deactivate_request() ** + ** Name: esm_proc_eps_bearer_context_deactivate_request() ** ** ** ** Description: Initiates the EPS bearer context deactivation procedure ** ** ** - ** 3GPP TS 24.301, section 6.4.4.2 ** - ** If a NAS signalling connection exists, the MME initiates ** - ** the EPS bearer context deactivation procedure by sending ** - ** a DEACTIVATE EPS BEARER CONTEXT REQUEST message to the ** - ** UE, starting timer T3495 and entering state BEARER CON- ** - ** TEXT INACTIVE PENDING. ** + ** 3GPP TS 24.301, section 6.4.4.2 ** + ** If a NAS signalling connection exists, the MME initiates ** + ** the EPS bearer context deactivation procedure by sending ** + ** a DEACTIVATE EPS BEARER CONTEXT REQUEST message to the ** + ** UE, starting timer T3495 and entering state BEARER CON- ** + ** TEXT INACTIVE PENDING. ** ** ** - ** Inputs: is_standalone: Not used - Always TRUE ** - ** ueid: UE lower layer identifier ** - ** ebi: EPS bearer identity ** - ** msg: Encoded ESM message to be sent ** - ** ue_triggered: TRUE if the EPS bearer context procedure ** - ** was triggered by the UE (not used) ** + ** Inputs: is_standalone: Not used - Always TRUE ** + ** ueid: UE lower layer identifier ** + ** ebi: EPS bearer identity ** + ** msg: Encoded ESM message to be sent ** + ** ue_triggered: TRUE if the EPS bearer context procedure ** + ** was triggered by the UE (not used) ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ int esm_proc_eps_bearer_context_deactivate_request(int is_standalone, - unsigned int ueid, int ebi, - OctetString* msg, int ue_triggered) + unsigned int ueid, int ebi, + OctetString *msg, int ue_triggered) { LOG_FUNC_IN; int rc; LOG_TRACE(INFO,"ESM-PROC - Initiate EPS bearer context deactivation " - "(ueid=%d, ebi=%d)", ueid, ebi); + "(ueid=%d, ebi=%d)", ueid, ebi); /* Send deactivate EPS bearer context request message and * start timer T3495 */ rc = _eps_bearer_deactivate(ueid, ebi, msg); if (rc != RETURNerror) { - /* Set the EPS bearer context state to ACTIVE PENDING */ - rc = esm_ebr_set_status(ueid, ebi, ESM_EBR_INACTIVE_PENDING, - ue_triggered); - if (rc != RETURNok) { - /* The EPS bearer context was already in ACTIVE state */ - LOG_TRACE(WARNING, "ESM-PROC - EBI %d was already INACTIVE PENDING", - ebi); - } + /* Set the EPS bearer context state to ACTIVE PENDING */ + rc = esm_ebr_set_status(ueid, ebi, ESM_EBR_INACTIVE_PENDING, + ue_triggered); + if (rc != RETURNok) { + /* The EPS bearer context was already in ACTIVE state */ + LOG_TRACE(WARNING, "ESM-PROC - EBI %d was already INACTIVE PENDING", + ebi); + } } LOG_FUNC_RETURN (rc); @@ -240,30 +239,30 @@ int esm_proc_eps_bearer_context_deactivate_request(int is_standalone, /**************************************************************************** ** ** - ** Name: esm_proc_eps_bearer_context_deactivate_accept() ** + ** Name: esm_proc_eps_bearer_context_deactivate_accept() ** ** ** ** Description: Performs EPS bearer context deactivation procedure accep- ** - ** ted by the UE. ** + ** ted by the UE. ** ** ** - ** 3GPP TS 24.301, section 6.4.4.3 ** - ** Upon receipt of the DEACTIVATE EPS BEARER CONTEXT ACCEPT ** - ** message, the MME shall enter the state BEARER CONTEXT ** - ** INACTIVE and stop the timer T3495. ** + ** 3GPP TS 24.301, section 6.4.4.3 ** + ** Upon receipt of the DEACTIVATE EPS BEARER CONTEXT ACCEPT ** + ** message, the MME shall enter the state BEARER CONTEXT ** + ** INACTIVE and stop the timer T3495. ** ** ** - ** Inputs: ueid: UE local identifier ** - ** ebi: EPS bearer identity ** - ** Others: None ** + ** Inputs: ueid: UE local identifier ** + ** ebi: EPS bearer identity ** + ** Others: None ** ** ** - ** Outputs: esm_cause: Cause code returned upon ESM procedure ** - ** failure ** - ** Return: The identifier of the PDN connection to be ** - ** released, if it exists; ** - ** RETURNerror otherwise. ** - ** Others: T3495 ** + ** Outputs: esm_cause: Cause code returned upon ESM procedure ** + ** failure ** + ** Return: The identifier of the PDN connection to be ** + ** released, if it exists; ** + ** RETURNerror otherwise. ** + ** Others: T3495 ** ** ** ***************************************************************************/ int esm_proc_eps_bearer_context_deactivate_accept(unsigned int ueid, int ebi, - int* esm_cause) + int *esm_cause) { LOG_FUNC_IN; @@ -271,19 +270,19 @@ int esm_proc_eps_bearer_context_deactivate_accept(unsigned int ueid, int ebi, int pid = RETURNerror; LOG_TRACE(INFO, "ESM-PROC - EPS bearer context deactivation " - "accepted by the UE (ueid=%u, ebi=%d)", ueid, ebi); + "accepted by the UE (ueid=%u, ebi=%d)", ueid, ebi); /* Stop T3495 timer if running */ rc = esm_ebr_stop_timer(ueid, ebi); if (rc != RETURNerror) { - int bid; - /* Release the EPS bearer context */ - rc = _eps_bearer_release(ueid, ebi, &pid, &bid); - if (rc != RETURNok) { - /* Failed to release the EPS bearer context */ - *esm_cause = ESM_CAUSE_PROTOCOL_ERROR; - pid = RETURNerror; - } + int bid; + /* Release the EPS bearer context */ + rc = _eps_bearer_release(ueid, ebi, &pid, &bid); + if (rc != RETURNok) { + /* Failed to release the EPS bearer context */ + *esm_cause = ESM_CAUSE_PROTOCOL_ERROR; + pid = RETURNerror; + } } LOG_FUNC_RETURN (pid); @@ -293,84 +292,84 @@ int esm_proc_eps_bearer_context_deactivate_accept(unsigned int ueid, int ebi, /* * -------------------------------------------------------------------------- - * EPS bearer context deactivation procedure executed by the UE + * EPS bearer context deactivation procedure executed by the UE * -------------------------------------------------------------------------- */ #ifdef NAS_UE /**************************************************************************** ** ** - ** Name: esm_proc_eps_bearer_context_deactivate() ** + ** Name: esm_proc_eps_bearer_context_deactivate() ** ** ** ** Description: Locally releases the EPS bearer context identified by the ** - ** given EPS bearer identity, without peer-to-peer signal- ** - ** ling between the UE and the MME, or checks whether the UE ** - ** has an EPS bearer context with specified EPS bearer iden- ** - ** tity activated. ** - ** ** - ** Inputs: is local: TRUE if the EPS bearer context has to be ** - ** locally released without peer-to-peer si- ** - ** gnalling between the UE and the MME ** - ** ebi: EPS bearer identity of the EPS bearer con- ** - ** text to be deactivated ** - ** Others: _esm_data ** - ** ** - ** Outputs: pid: Identifier of the PDN connection the EPS ** - ** bearer belongs to ** - ** bid: Identifier of the released EPS bearer con- ** - ** text entry ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** given EPS bearer identity, without peer-to-peer signal- ** + ** ling between the UE and the MME, or checks whether the UE ** + ** has an EPS bearer context with specified EPS bearer iden- ** + ** tity activated. ** + ** ** + ** Inputs: is local: TRUE if the EPS bearer context has to be ** + ** locally released without peer-to-peer si- ** + ** gnalling between the UE and the MME ** + ** ebi: EPS bearer identity of the EPS bearer con- ** + ** text to be deactivated ** + ** Others: _esm_data ** + ** ** + ** Outputs: pid: Identifier of the PDN connection the EPS ** + ** bearer belongs to ** + ** bid: Identifier of the released EPS bearer con- ** + ** text entry ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ int esm_proc_eps_bearer_context_deactivate(int is_local, int ebi, - int* pid, int* bid) + int *pid, int *bid) { LOG_FUNC_IN; int rc = RETURNerror; if (is_local) { - if (ebi != ESM_SAP_ALL_EBI) { - /* Locally release the EPS bearer context */ - rc = _eps_bearer_release(ebi, pid, bid); - } - 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; - } - } - } - LOG_FUNC_RETURN (rc); + if (ebi != ESM_SAP_ALL_EBI) { + /* Locally release the EPS bearer context */ + rc = _eps_bearer_release(ebi, pid, bid); + } 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; + } + } + } + } + LOG_FUNC_RETURN (rc); } LOG_TRACE(WARNING, "ESM-PROC - EPS bearer context deactivation (ebi=%d)", - ebi); + ebi); if (*pid < ESM_DATA_PDN_MAX) { - 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) { - LOG_TRACE(ERROR, "ESM-PROC - PDN connection %d has not been " - "allocated", *pid); - } - 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; - for (int i = 0; i < pdn->n_bearers; i++) { - if (pdn->bearer[i]->ebi != ebi) continue; - /* The EPS bearer context to be released is valid */ - rc = RETURNok; - } - } + 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) { + LOG_TRACE(ERROR, "ESM-PROC - PDN connection %d has not been " + "allocated", *pid); + } 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; + for (int i = 0; i < pdn->n_bearers; i++) { + if (pdn->bearer[i]->ebi != ebi) { + continue; + } + /* The EPS bearer context to be released is valid */ + rc = RETURNok; + } + } } LOG_FUNC_RETURN (rc); @@ -378,22 +377,22 @@ int esm_proc_eps_bearer_context_deactivate(int is_local, int ebi, /**************************************************************************** ** ** - ** Name: esm_proc_eps_bearer_context_deactivate_request() ** + ** Name: esm_proc_eps_bearer_context_deactivate_request() ** ** ** ** Description: Deletes the EPS bearer context identified by the EPS bea- ** - ** rer identity upon receipt of the DEACTIVATE EPS BEARER ** - ** CONTEXT REQUEST message. ** + ** rer identity upon receipt of the DEACTIVATE EPS BEARER ** + ** CONTEXT REQUEST message. ** ** ** - ** Inputs: ebi: EPS bearer identity ** - ** Others: None ** + ** Inputs: ebi: EPS bearer identity ** + ** Others: None ** ** ** - ** Outputs: esm_cause: Cause code returned upon ESM procedure ** - ** failure ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: esm_cause: Cause code returned upon ESM procedure ** + ** failure ** + ** Return: RETURNok, RETURNerror ** + ** 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; @@ -401,54 +400,53 @@ int esm_proc_eps_bearer_context_deactivate_request(int ebi, int* esm_cause) int rc = RETURNok; LOG_TRACE(INFO, "ESM-PROC - EPS bearer context deactivation " - "requested by the network (ebi=%d)", ebi); + "requested by the network (ebi=%d)", ebi); /* Release the EPS bearer context entry */ if (esm_ebr_context_release(ebi, &pid, &bid) == ESM_EBI_UNASSIGNED) { - LOG_TRACE(WARNING, "ESM-PROC - Failed to release EPS bearer context"); - *esm_cause = ESM_CAUSE_PROTOCOL_ERROR; - LOG_FUNC_RETURN (RETURNerror); + LOG_TRACE(WARNING, "ESM-PROC - Failed to release EPS bearer context"); + *esm_cause = ESM_CAUSE_PROTOCOL_ERROR; + LOG_FUNC_RETURN (RETURNerror); } 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) - { - esm_sap_t esm_sap; - int active = FALSE; - - /* 3GPP TS 24.301, section 6.4.4.3 - * The UE should re-initiate the UE requested PDN connectivity - * procedure for the APN associated to the PDN it was connected - * to in order to reactivate the EPS bearer context - */ - LOG_TRACE(WARNING, "ESM-PROC - The network requests PDN " - "connection reactivation"); - - /* Get PDN context parameters */ - rc = esm_main_get_pdn(pid + 1, &esm_sap.data.pdn_connect.pdn_type, - &esm_sap.data.pdn_connect.apn, - &esm_sap.data.pdn_connect.is_emergency, - &active); - if (rc != RETURNerror) { - if (active) { - LOG_TRACE(ERROR, "ESM-PROC - Connectivity to APN %s " - "has not been deactivated", - esm_sap.data.pdn_connect.apn); - *esm_cause = ESM_CAUSE_REQUEST_REJECTED_UNSPECIFIED; - LOG_FUNC_RETURN (RETURNerror); - } - /* - * Notify ESM to re-initiate PDN connectivity procedure - */ - esm_sap.primitive = ESM_PDN_CONNECTIVITY_REQ; - esm_sap.is_standalone = TRUE; - esm_sap.data.pdn_connect.is_defined = TRUE; - esm_sap.data.pdn_connect.cid = pid + 1; - rc = esm_sap_send(&esm_sap); - } - } + /* The EPS bearer identity is that of the default bearer assigned to + * the PDN connection */ + if (*esm_cause == ESM_CAUSE_REACTIVATION_REQUESTED) { + esm_sap_t esm_sap; + int active = FALSE; + + /* 3GPP TS 24.301, section 6.4.4.3 + * The UE should re-initiate the UE requested PDN connectivity + * procedure for the APN associated to the PDN it was connected + * to in order to reactivate the EPS bearer context + */ + LOG_TRACE(WARNING, "ESM-PROC - The network requests PDN " + "connection reactivation"); + + /* Get PDN context parameters */ + rc = esm_main_get_pdn(pid + 1, &esm_sap.data.pdn_connect.pdn_type, + &esm_sap.data.pdn_connect.apn, + &esm_sap.data.pdn_connect.is_emergency, + &active); + if (rc != RETURNerror) { + if (active) { + LOG_TRACE(ERROR, "ESM-PROC - Connectivity to APN %s " + "has not been deactivated", + esm_sap.data.pdn_connect.apn); + *esm_cause = ESM_CAUSE_REQUEST_REJECTED_UNSPECIFIED; + LOG_FUNC_RETURN (RETURNerror); + } + /* + * Notify ESM to re-initiate PDN connectivity procedure + */ + esm_sap.primitive = ESM_PDN_CONNECTIVITY_REQ; + esm_sap.is_standalone = TRUE; + esm_sap.data.pdn_connect.is_defined = TRUE; + esm_sap.data.pdn_connect.cid = pid + 1; + rc = esm_sap_send(&esm_sap); + } + } } LOG_FUNC_RETURN (rc); @@ -456,30 +454,30 @@ int esm_proc_eps_bearer_context_deactivate_request(int ebi, int* esm_cause) /**************************************************************************** ** ** - ** Name: esm_proc_eps_bearer_context_deactivate_accept() ** + ** Name: esm_proc_eps_bearer_context_deactivate_accept() ** ** ** ** Description: Performs EPS bearer context deactivation procedure accep- ** - ** ted by the UE. ** + ** ted by the UE. ** ** ** - ** 3GPP TS 24.301, section 6.4.4.3 ** - ** The UE accepts EPS bearer context deactivation by sending ** - ** DEACTIVATE EPS BEARER CONTEXT ACCEPT message and entering ** - ** the state BEARER CONTEXT INACTIVE. ** + ** 3GPP TS 24.301, section 6.4.4.3 ** + ** The UE accepts EPS bearer context deactivation by sending ** + ** DEACTIVATE EPS BEARER CONTEXT ACCEPT message and entering ** + ** the state BEARER CONTEXT INACTIVE. ** ** ** - ** Inputs: is_standalone: Should be always TRUE ** - ** ebi: EPS bearer identity ** - ** msg: Encoded ESM message to be sent ** - ** ue_triggered: TRUE if the EPS bearer context procedure ** - ** was triggered by the UE ** - ** Others: None ** + ** Inputs: is_standalone: Should be always TRUE ** + ** ebi: EPS bearer identity ** + ** msg: Encoded ESM message to be sent ** + ** ue_triggered: TRUE if the EPS bearer context procedure ** + ** was triggered by the UE ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ 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; @@ -488,29 +486,29 @@ int esm_proc_eps_bearer_context_deactivate_accept(int is_standalone, int ebi, LOG_TRACE(INFO,"ESM-PROC - EPS bearer context deactivation accepted"); if (is_standalone) { - emm_sap_t emm_sap; - /* - * Notity EMM that ESM PDU has to be forwarded to lower layers - */ - emm_sap.primitive = EMMESM_UNITDATA_REQ; - emm_sap.u.emm_esm.ueid = 0; - emm_sap.u.emm_esm.u.data.msg.length = msg->length; - emm_sap.u.emm_esm.u.data.msg.value = msg->value; - rc = emm_sap_send(&emm_sap); + emm_sap_t emm_sap; + /* + * Notity EMM that ESM PDU has to be forwarded to lower layers + */ + emm_sap.primitive = EMMESM_UNITDATA_REQ; + emm_sap.u.emm_esm.ueid = 0; + emm_sap.u.emm_esm.u.data.msg.length = msg->length; + emm_sap.u.emm_esm.u.data.msg.value = msg->value; + rc = emm_sap_send(&emm_sap); } if (rc != RETURNerror) { - /* Set the EPS bearer context state to INACTIVE */ - rc = esm_ebr_set_status(ebi, ESM_EBR_INACTIVE, ue_triggered); - if (rc != RETURNok) { - /* The EPS bearer context was already in INACTIVE state */ - LOG_TRACE(WARNING, "ESM-PROC - EBI %d was already INACTIVE", ebi); - /* Accept network retransmission of already accepted deactivate - * EPS bearer context request */ - LOG_FUNC_RETURN (RETURNok); - } - /* Release EPS bearer data */ - rc = esm_ebr_release(ebi); + /* Set the EPS bearer context state to INACTIVE */ + rc = esm_ebr_set_status(ebi, ESM_EBR_INACTIVE, ue_triggered); + if (rc != RETURNok) { + /* The EPS bearer context was already in INACTIVE state */ + LOG_TRACE(WARNING, "ESM-PROC - EBI %d was already INACTIVE", ebi); + /* Accept network retransmission of already accepted deactivate + * EPS bearer context request */ + LOG_FUNC_RETURN (RETURNok); + } + /* Release EPS bearer data */ + rc = esm_ebr_release(ebi); } LOG_FUNC_RETURN (rc); @@ -524,65 +522,64 @@ int esm_proc_eps_bearer_context_deactivate_accept(int is_standalone, int ebi, /* * -------------------------------------------------------------------------- - * Timer handlers + * Timer handlers * -------------------------------------------------------------------------- */ #ifdef NAS_MME /**************************************************************************** ** ** - ** Name: _eps_bearer_deactivate_t3495_handler() ** + ** Name: _eps_bearer_deactivate_t3495_handler() ** ** ** ** Description: T3495 timeout handler ** ** ** ** 3GPP TS 24.301, section 6.4.4.5, case a ** - ** On the first expiry of the timer T3495, the MME shall re- ** - ** send the DEACTIVATE EPS BEARER CONTEXT REQUEST and shall ** - ** reset and restart timer T3495. This retransmission is ** - ** repeated four times, i.e. on the fifth expiry of timer ** - ** T3495, the MME shall abort the procedure and deactivate ** - ** the EPS bearer context locally. ** + ** On the first expiry of the timer T3495, the MME shall re- ** + ** send the DEACTIVATE EPS BEARER CONTEXT REQUEST and shall ** + ** reset and restart timer T3495. This retransmission is ** + ** repeated four times, i.e. on the fifth expiry of timer ** + ** T3495, the MME shall abort the procedure and deactivate ** + ** the EPS bearer context locally. ** ** ** - ** Inputs: args: handler parameters ** - ** Others: None ** + ** Inputs: args: handler parameters ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: None ** - ** Others: None ** + ** Outputs: None ** + ** Return: None ** + ** 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; LOG_TRACE(WARNING, "ESM-PROC - T3495 timer expired (ueid=%d, ebi=%d), " - "retransmission counter = %d", - data->ueid, data->ebi, data->count); + "retransmission counter = %d", + data->ueid, data->ebi, data->count); 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 { - /* - * The maximum number of deactivate EPS bearer context request - * message retransmission has exceed - */ - int pid, bid; - /* Deactivate the EPS bearer context locally without peer-to-peer - * signalling between the UE and the MME */ - rc = _eps_bearer_release(data->ueid, data->ebi, &pid, &bid); - if (rc != RETURNerror) { - /* Stop timer T3495 */ - rc = esm_ebr_stop_timer(data->ueid, data->ebi); - } + /* Re-send deactivate EPS bearer context request message to the UE */ + rc = _eps_bearer_deactivate(data->ueid, data->ebi, &data->msg); + } else { + /* + * The maximum number of deactivate EPS bearer context request + * message retransmission has exceed + */ + int pid, bid; + /* Deactivate the EPS bearer context locally without peer-to-peer + * signalling between the UE and the MME */ + rc = _eps_bearer_release(data->ueid, data->ebi, &pid, &bid); + if (rc != RETURNerror) { + /* Stop timer T3495 */ + rc = esm_ebr_stop_timer(data->ueid, data->ebi); + } } LOG_FUNC_RETURN (NULL); @@ -591,30 +588,30 @@ static void* _eps_bearer_deactivate_t3495_handler(void* args) /* * -------------------------------------------------------------------------- - * MME specific local functions + * MME specific local functions * -------------------------------------------------------------------------- */ #ifdef NAS_MME /**************************************************************************** ** ** - ** Name: _eps_bearer_deactivate() ** + ** Name: _eps_bearer_deactivate() ** ** ** ** Description: Sends DEACTIVATE EPS BEREAR CONTEXT REQUEST message and ** - ** starts timer T3495 ** + ** starts timer T3495 ** ** ** - ** Inputs: ueid: UE local identifier ** - ** ebi: EPS bearer identity ** - ** msg: Encoded ESM message to be sent ** - ** Others: None ** + ** Inputs: ueid: UE local identifier ** + ** ebi: EPS bearer identity ** + ** msg: Encoded ESM message to be sent ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: T3495 ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: T3495 ** ** ** ***************************************************************************/ static int _eps_bearer_deactivate(unsigned int ueid, int ebi, - const OctetString* msg) + const OctetString *msg) { LOG_FUNC_IN; @@ -632,9 +629,9 @@ static int _eps_bearer_deactivate(unsigned int ueid, int ebi, rc = emm_sap_send(&emm_sap); if (rc != RETURNerror) { - /* Start T3495 retransmission timer */ - rc = esm_ebr_start_timer(ueid, ebi, msg, T3495_DEFAULT_VALUE, - _eps_bearer_deactivate_t3495_handler); + /* Start T3495 retransmission timer */ + rc = esm_ebr_start_timer(ueid, ebi, msg, T3495_DEFAULT_VALUE, + _eps_bearer_deactivate_t3495_handler); } LOG_FUNC_RETURN (rc); @@ -642,24 +639,24 @@ static int _eps_bearer_deactivate(unsigned int ueid, int ebi, /**************************************************************************** ** ** - ** Name: _eps_bearer_release() ** + ** Name: _eps_bearer_release() ** ** ** ** Description: Releases the EPS bearer context identified by the given ** - ** EPS bearer identity and enters state INACTIVE. ** + ** EPS bearer identity and enters state INACTIVE. ** ** ** - ** Inputs: ueid: UE local identifier ** - ** ebi: EPS bearer identity ** - ** Others: None ** + ** Inputs: ueid: UE local identifier ** + ** ebi: EPS bearer identity ** + ** Others: None ** ** ** - ** Outputs: pid: Identifier of the PDN connection the EPS ** - ** bearer belongs to ** - ** bid: Identifier of the released EPS bearer con- ** - ** text entry ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: pid: Identifier of the PDN connection the EPS ** + ** bearer belongs to ** + ** bid: Identifier of the released EPS bearer con- ** + ** text entry ** + ** Return: RETURNok, RETURNerror ** + ** 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; @@ -668,23 +665,21 @@ static int _eps_bearer_release(unsigned int ueid, int ebi, int* pid, int* bid) /* Release the EPS bearer context entry */ 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 { - /* 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 { - /* Release EPS bearer data */ - rc = esm_ebr_release(ueid, ebi); - if (rc != RETURNok) { - LOG_TRACE(WARNING, - "ESM-PROC - Failed to release EPS bearer data"); - } - } + LOG_TRACE(WARNING, "ESM-PROC - Failed to release EPS bearer context"); + } 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 { + /* Release EPS bearer data */ + rc = esm_ebr_release(ueid, ebi); + if (rc != RETURNok) { + LOG_TRACE(WARNING, + "ESM-PROC - Failed to release EPS bearer data"); + } + } } LOG_FUNC_RETURN (rc); @@ -693,55 +688,53 @@ static int _eps_bearer_release(unsigned int ueid, int ebi, int* pid, int* bid) /* * -------------------------------------------------------------------------- - * UE specific local functions + * UE specific local functions * -------------------------------------------------------------------------- */ #ifdef NAS_UE /**************************************************************************** ** ** - ** Name: _eps_bearer_release() ** + ** Name: _eps_bearer_release() ** ** ** ** Description: Releases the EPS bearer context identified by the given ** - ** EPS bearer identity and enters state INACTIVE. ** + ** EPS bearer identity and enters state INACTIVE. ** ** ** - ** Inputs: ebi: EPS bearer identity ** - ** Others: None ** + ** Inputs: ebi: EPS bearer identity ** + ** Others: None ** ** ** - ** Outputs: pid: Identifier of the PDN connection the EPS ** - ** bearer belongs to ** - ** bid: Identifier of the released EPS bearer con- ** - ** text entry ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: pid: Identifier of the PDN connection the EPS ** + ** bearer belongs to ** + ** bid: Identifier of the released EPS bearer con- ** + ** text entry ** + ** Return: RETURNok, RETURNerror ** + ** 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; int rc = RETURNerror; - /* Release the EPS bearer context entry */ + /* Release the EPS bearer context entry */ 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 { - /* 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 { - /* Release EPS bearer data */ - rc = esm_ebr_release(ebi); - if (rc != RETURNok) { - LOG_TRACE(WARNING, - "ESM-PROC - Failed to release EPS bearer data"); - } - } + LOG_TRACE(WARNING, "ESM-PROC - Failed to release EPS bearer context"); + } 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 { + /* Release EPS bearer data */ + rc = esm_ebr_release(ebi); + if (rc != RETURNok) { + LOG_TRACE(WARNING, + "ESM-PROC - Failed to release EPS bearer data"); + } + } } LOG_FUNC_RETURN (rc); diff --git a/openair-cn/NAS/EURECOM-NAS/src/esm/EsmStatusHdl.c b/openair-cn/NAS/EURECOM-NAS/src/esm/EsmStatusHdl.c index 4117ecea7d..12e3ecfb3b 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/esm/EsmStatusHdl.c +++ b/openair-cn/NAS/EURECOM-NAS/src/esm/EsmStatusHdl.c @@ -1,29 +1,29 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source EsmStatus.c +Source EsmStatus.c -Version 0.1 +Version 0.1 -Date 2013/06/17 +Date 2013/06/17 -Product NAS stack +Product NAS stack -Subsystem EPS Session Management +Subsystem EPS Session Management -Author Frederic Maurel +Author Frederic Maurel -Description Defines the ESM status procedure executed by the Non-Access - Stratum. +Description Defines the ESM status procedure executed by the Non-Access + Stratum. - ESM status procedure can be related to an EPS bearer context - or to a procedure transaction. + ESM status procedure can be related to an EPS bearer context + or to a procedure transaction. - The purpose of the sending of the ESM STATUS message is to - report at any time certain error conditions detected upon - receipt of ESM protocol data. The ESM STATUS message can be - sent by both the MME and the UE. + The purpose of the sending of the ESM STATUS message is to + report at any time certain error conditions detected upon + receipt of ESM protocol data. The ESM STATUS message can be + sent by both the MME and the UE. *****************************************************************************/ @@ -49,81 +49,80 @@ Description Defines the ESM status procedure executed by the Non-Access /**************************************************************************** ** ** - ** Name: esm_proc_status_ind() ** + ** Name: esm_proc_status_ind() ** ** ** ** Description: Processes received ESM status message. ** ** ** - ** 3GPP TS 24.301, section 6.7 ** - ** Upon receiving ESM Status message the UE/MME shall take ** - ** different actions depending on the received ESM cause ** - ** value. ** + ** 3GPP TS 24.301, section 6.7 ** + ** Upon receiving ESM Status message the UE/MME shall take ** + ** different actions depending on the received ESM cause ** + ** value. ** ** ** - ** Inputs: ueid: UE lower layer identifier ** - ** pti: Procedure transaction identity ** - ** ebi: EPS bearer identity ** - ** esm_cause: Received ESM cause code ** - ** failure ** - ** Others: None ** + ** Inputs: ueid: UE lower layer identifier ** + ** pti: Procedure transaction identity ** + ** ebi: EPS bearer identity ** + ** esm_cause: Received ESM cause code ** + ** failure ** + ** Others: None ** ** ** - ** Outputs: esm_cause: Cause code returned upon ESM procedure ** - ** failure ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: esm_cause: Cause code returned upon ESM procedure ** + ** failure ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ int esm_proc_status_ind( #ifdef NAS_MME - unsigned int ueid, + unsigned int ueid, #endif - int pti, int ebi, int* esm_cause) + int pti, int ebi, int *esm_cause) { LOG_FUNC_IN; int rc; LOG_TRACE(INFO,"ESM-PROC - ESM status procedure requested (cause=%d)", - *esm_cause); + *esm_cause); LOG_TRACE(DEBUG, "ESM-PROC - To be implemented"); - switch (*esm_cause) - { - case ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY: - /* - * Abort any ongoing ESM procedure related to the received EPS - * bearer identity, stop any related timer, and deactivate the - * corresponding EPS bearer context locally - */ - /* TODO */ - rc = RETURNok; - break; - - case ESM_CAUSE_INVALID_PTI_VALUE: - /* - * Abort any ongoing ESM procedure related to the received PTI - * value and stop any related timer - */ - /* TODO */ - rc = RETURNok; - break; - - case ESM_CAUSE_MESSAGE_TYPE_NOT_IMPLEMENTED: - /* - * Abort any ongoing ESM procedure related to the PTI or - * EPS bearer identity and stop any related timer - */ - /* TODO */ - rc = RETURNok; - break; - - default: - /* - * No state transition and no specific action shall be taken; - * local actions are possible - */ - /* TODO */ - rc = RETURNok; - break; + switch (*esm_cause) { + case ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY: + /* + * Abort any ongoing ESM procedure related to the received EPS + * bearer identity, stop any related timer, and deactivate the + * corresponding EPS bearer context locally + */ + /* TODO */ + rc = RETURNok; + break; + + case ESM_CAUSE_INVALID_PTI_VALUE: + /* + * Abort any ongoing ESM procedure related to the received PTI + * value and stop any related timer + */ + /* TODO */ + rc = RETURNok; + break; + + case ESM_CAUSE_MESSAGE_TYPE_NOT_IMPLEMENTED: + /* + * Abort any ongoing ESM procedure related to the PTI or + * EPS bearer identity and stop any related timer + */ + /* TODO */ + rc = RETURNok; + break; + + default: + /* + * No state transition and no specific action shall be taken; + * local actions are possible + */ + /* TODO */ + rc = RETURNok; + break; } LOG_FUNC_RETURN (rc); @@ -131,28 +130,28 @@ int esm_proc_status_ind( /**************************************************************************** ** ** - ** Name: esm_proc_status() ** + ** Name: esm_proc_status() ** ** ** ** Description: Initiates ESM status procedure. ** ** ** - ** Inputs: is_standalone: Not used - Always TRUE ** - ** ueid: UE lower layer identifier ** - ** ebi: Not used ** - ** msg: Encoded ESM status message to be sent ** - ** ue_triggered: Not used ** - ** Others: None ** + ** Inputs: is_standalone: Not used - Always TRUE ** + ** ueid: UE lower layer identifier ** + ** ebi: Not used ** + ** msg: Encoded ESM status message to be sent ** + ** ue_triggered: Not used ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ int esm_proc_status(int is_standalone, #ifdef NAS_MME - unsigned int ueid, + unsigned int ueid, #endif - int ebi, OctetString* msg, - int ue_triggered) + int ebi, OctetString *msg, + int ue_triggered) { LOG_FUNC_IN; diff --git a/openair-cn/NAS/EURECOM-NAS/src/esm/PdnConnectivity.c b/openair-cn/NAS/EURECOM-NAS/src/esm/PdnConnectivity.c index 9bc33756c9..d7690bcdba 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/esm/PdnConnectivity.c +++ b/openair-cn/NAS/EURECOM-NAS/src/esm/PdnConnectivity.c @@ -1,31 +1,31 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source PdnConnectivity.c +Source PdnConnectivity.c -Version 0.1 +Version 0.1 -Date 2013/01/02 +Date 2013/01/02 -Product NAS stack +Product NAS stack -Subsystem EPS Session Management +Subsystem EPS Session Management -Author Frederic Maurel +Author Frederic Maurel -Description Defines the PDN connectivity ESM procedure executed by the - Non-Access Stratum. +Description Defines the PDN connectivity ESM procedure executed by the + Non-Access Stratum. - The PDN connectivity procedure is used by the UE to request - the setup of a default EPS bearer to a PDN. + The PDN connectivity procedure is used by the UE to request + the setup of a default EPS bearer to a PDN. - The procedure is used either to establish the 1st default - bearer by including the PDN CONNECTIVITY REQUEST message - into the initial attach message, or to establish subsequent - default bearers to additional PDNs in order to allow the UE - simultaneous access to multiple PDNs by sending the message - stand-alone. + The procedure is used either to establish the 1st default + bearer by including the PDN CONNECTIVITY REQUEST message + into the initial attach message, or to establish subsequent + default bearers to additional PDNs in order to allow the UE + simultaneous access to multiple PDNs by sending the message + stand-alone. *****************************************************************************/ @@ -43,8 +43,8 @@ Description Defines the PDN connectivity ESM procedure executed by the #include "emm_sap.h" -#include <stdlib.h> // malloc, free -#include <string.h> // memset, memcpy, memcmp +#include <stdlib.h> // malloc, free +#include <string.h> // memset, memcpy, memcmp /****************************************************************************/ /**************** E X T E R N A L D E F I N I T I O N S ****************/ @@ -56,25 +56,28 @@ Description Defines the PDN connectivity ESM procedure executed by the /* * -------------------------------------------------------------------------- - * Internal data handled by the PDN connectivity procedure in the UE + * Internal data handled by the PDN connectivity procedure in the UE * -------------------------------------------------------------------------- */ #ifdef NAS_UE /* * 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 @@ -83,14 +86,16 @@ static void* _pdn_connectivity_t3482_handler(void*); /* * -------------------------------------------------------------------------- - * Internal data handled by the PDN connectivity procedure in the MME + * Internal data handled by the PDN connectivity procedure in the MME * -------------------------------------------------------------------------- */ #ifdef NAS_MME /* * 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 @@ -101,38 +106,38 @@ int _pdn_connectivity_delete(unsigned int ueid, int pid); /* * -------------------------------------------------------------------------- - * PDN connectivity procedure executed by the UE + * PDN connectivity procedure executed by the UE * -------------------------------------------------------------------------- */ #ifdef NAS_UE /**************************************************************************** ** ** - ** Name: esm_proc_pdn_connectivity() ** + ** Name: esm_proc_pdn_connectivity() ** ** ** ** Description: Defines a new PDN connection for the specified Access ** - ** Point Name or undefines the PDN connection with the given ** - ** identifier ** - ** ** - ** Inputs: cid: PDN connection identifier ** - ** is_to_define: Indicates whether the PDN connection has ** - ** to be defined or undefined ** - ** pdn_type: PDN connection type (IPv4, IPv6, IPv4v6) ** - ** apn: Access Point logical Name to be used ** - ** is_emergency: TRUE if the PDN connection has to be esta- ** - ** blished for emergency bearer services ** - ** Others: None ** - ** ** - ** Outputs: pti: Procedure transaction identity assigned to ** - ** the new PDN connection or the released PDN ** - ** connection ** - ** Return: RETURNok, RETURNerror ** - ** Others: _esm_data ** + ** Point Name or undefines the PDN connection with the given ** + ** identifier ** + ** ** + ** Inputs: cid: PDN connection identifier ** + ** is_to_define: Indicates whether the PDN connection has ** + ** to be defined or undefined ** + ** pdn_type: PDN connection type (IPv4, IPv6, IPv4v6) ** + ** apn: Access Point logical Name to be used ** + ** is_emergency: TRUE if the PDN connection has to be esta- ** + ** blished for emergency bearer services ** + ** Others: None ** + ** ** + ** Outputs: pti: Procedure transaction identity assigned to ** + ** the new PDN connection or the released PDN ** + ** connection ** + ** Return: RETURNok, RETURNerror ** + ** Others: _esm_data ** ** ** ***************************************************************************/ 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) + esm_proc_pdn_type_t pdn_type, + const OctetString *apn, int is_emergency, + unsigned int *pti) { LOG_FUNC_IN; @@ -140,95 +145,91 @@ int esm_proc_pdn_connectivity(int cid, int is_to_define, int pid = cid - 1; if (!is_to_define) { - LOG_TRACE(INFO, "ESM-PROC - Undefine PDN connection (cid=%d)", cid); - /* Delete the PDN connection entry */ - int pti = _pdn_connectivity_delete(pid); - if (pti != ESM_PT_UNASSIGNED) { - /* Release the procedure transaction data */ - rc = esm_pt_release(pti); - } - LOG_FUNC_RETURN(rc); - } - else if (pti != NULL) { - LOG_TRACE(INFO, "ESM-PROC - Assign new procedure transaction identity " - "(cid=%d)", cid); - /* Assign new procedure transaction identity */ - *pti = esm_pt_assign(); - if (*pti == ESM_PT_UNASSIGNED) { - LOG_TRACE(WARNING, "ESM-PROC - Failed to assign new procedure " - "transaction identity"); - LOG_FUNC_RETURN (RETURNerror); - } - /* Update the PDN connection data */ - rc = _pdn_connectivity_set_pti(pid, *pti); - if (rc != RETURNok) { - LOG_TRACE(WARNING, "ESM-PROC - Failed to update PDN connection"); - } - LOG_FUNC_RETURN (rc); + LOG_TRACE(INFO, "ESM-PROC - Undefine PDN connection (cid=%d)", cid); + /* Delete the PDN connection entry */ + int pti = _pdn_connectivity_delete(pid); + if (pti != ESM_PT_UNASSIGNED) { + /* Release the procedure transaction data */ + rc = esm_pt_release(pti); + } + LOG_FUNC_RETURN(rc); + } else if (pti != NULL) { + LOG_TRACE(INFO, "ESM-PROC - Assign new procedure transaction identity " + "(cid=%d)", cid); + /* Assign new procedure transaction identity */ + *pti = esm_pt_assign(); + if (*pti == ESM_PT_UNASSIGNED) { + LOG_TRACE(WARNING, "ESM-PROC - Failed to assign new procedure " + "transaction identity"); + LOG_FUNC_RETURN (RETURNerror); + } + /* Update the PDN connection data */ + rc = _pdn_connectivity_set_pti(pid, *pti); + if (rc != RETURNok) { + LOG_TRACE(WARNING, "ESM-PROC - Failed to update PDN connection"); + } + LOG_FUNC_RETURN (rc); } LOG_TRACE(INFO,"ESM-PROC - Define new %s PDN connection to APN %s (cid=%d)", - (pdn_type == ESM_PDN_TYPE_IPV4)? "IPv4" : - (pdn_type == ESM_PDN_TYPE_IPV6)? "IPv6" : "IPv4v6", - apn->value, cid); + (pdn_type == ESM_PDN_TYPE_IPV4)? "IPv4" : + (pdn_type == ESM_PDN_TYPE_IPV6)? "IPv6" : "IPv4v6", + apn->value, cid); if (is_emergency && _esm_data.emergency) { - /* The UE shall not request additional PDN connection for - * emergency bearer services */ - 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) { - 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 { - LOG_TRACE(WARNING, "ESM-PROC - PDN connection identifier is not valid"); - LOG_FUNC_RETURN (RETURNerror); + /* The UE shall not request additional PDN connection for + * emergency bearer services */ + 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) { + 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 { + LOG_TRACE(WARNING, "ESM-PROC - PDN connection identifier is not valid"); + LOG_FUNC_RETURN (RETURNerror); } if (apn && apn->length > 0) { - /* The UE requested subsequent connectivity to additionnal PDNs */ - int pid = _pdn_connectivity_find_apn(apn); - if ( (pid >= 0) && _esm_data.pdn[pid].is_active ) { - /* An active PDN connection to this APN already exists */ - if ( (_esm_data.pdn[pid].data->type != ESM_PDN_TYPE_IPV4V6) && - (_esm_data.pdn[pid].data->type != pdn_type) ) { - /* The UE is requesting PDN connection for other IP version - * than the one already activated */ - if (!_esm_data.pdn[pid].data->addr_realloc) { - /* The network does not allow PDN connectivity using - * IPv4 and IPv6 address versions to the same APN */ - if (pdn_type != ESM_PDN_TYPE_IPV4V6) { - LOG_TRACE(WARNING, "ESM-PROC - %s PDN connectivity to " - "%s is not allowed by the network", - (pdn_type != ESM_PDN_TYPE_IPV4)? "IPv6" : - "IPv4", apn->value); - } else { - LOG_TRACE(WARNING, "ESM-PROC - %s PDN connection to %s " - "already exists", - (_esm_data.pdn[pid].data->type != - ESM_PDN_TYPE_IPV4)? "IPv6" : "IPv4", - apn->value); - } - LOG_FUNC_RETURN (RETURNerror); - } - } - 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 " - "already exists", - (_esm_data.pdn[pid].data->type != ESM_PDN_TYPE_IPV4)? - (_esm_data.pdn[pid].data->type != ESM_PDN_TYPE_IPV6)? - "IPv4v6" : "IPv6" : "IPv4", apn->value); - LOG_FUNC_RETURN (RETURNerror); - } - } + /* The UE requested subsequent connectivity to additionnal PDNs */ + int pid = _pdn_connectivity_find_apn(apn); + if ( (pid >= 0) && _esm_data.pdn[pid].is_active ) { + /* An active PDN connection to this APN already exists */ + if ( (_esm_data.pdn[pid].data->type != ESM_PDN_TYPE_IPV4V6) && + (_esm_data.pdn[pid].data->type != pdn_type) ) { + /* The UE is requesting PDN connection for other IP version + * than the one already activated */ + if (!_esm_data.pdn[pid].data->addr_realloc) { + /* The network does not allow PDN connectivity using + * IPv4 and IPv6 address versions to the same APN */ + if (pdn_type != ESM_PDN_TYPE_IPV4V6) { + LOG_TRACE(WARNING, "ESM-PROC - %s PDN connectivity to " + "%s is not allowed by the network", + (pdn_type != ESM_PDN_TYPE_IPV4)? "IPv6" : + "IPv4", apn->value); + } else { + LOG_TRACE(WARNING, "ESM-PROC - %s PDN connection to %s " + "already exists", + (_esm_data.pdn[pid].data->type != + ESM_PDN_TYPE_IPV4)? "IPv6" : "IPv4", + apn->value); + } + LOG_FUNC_RETURN (RETURNerror); + } + } 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 " + "already exists", + (_esm_data.pdn[pid].data->type != ESM_PDN_TYPE_IPV4)? + (_esm_data.pdn[pid].data->type != ESM_PDN_TYPE_IPV6)? + "IPv4v6" : "IPv6" : "IPv4", apn->value); + LOG_FUNC_RETURN (RETURNerror); + } + } } /* @@ -245,33 +246,33 @@ int esm_proc_pdn_connectivity(int cid, int is_to_define, /**************************************************************************** ** ** - ** Name: esm_proc_pdn_connectivity_request() ** + ** Name: esm_proc_pdn_connectivity_request() ** ** ** ** Description: Initiates PDN connectivity procedure to request setup of ** - ** a default EPS bearer to a PDN. ** + ** a default EPS bearer to a PDN. ** ** ** ** 3GPP TS 24.301, section 6.5.1.2 ** - ** The UE requests connectivity to an additional PDN by sen- ** - ** ding a PDN CONNECTIVITY REQUEST message to the MME, star- ** - ** ting timer T3482 and entering state PROCEDURE TRANSACTION ** - ** PENDING. ** - ** ** - ** Inputs: is_standalone: Indicates whether the PDN connectivity ** - ** procedure is initiated as part of the at- ** - ** tach procedure ** - ** pti: Procedure transaction identity ** - ** msg: Encoded PDN connectivity request message ** - ** to be sent ** - ** sent_by_ue: Not used - Always TRUE ** - ** Others: None ** - ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** The UE requests connectivity to an additional PDN by sen- ** + ** ding a PDN CONNECTIVITY REQUEST message to the MME, star- ** + ** ting timer T3482 and entering state PROCEDURE TRANSACTION ** + ** PENDING. ** + ** ** + ** Inputs: is_standalone: Indicates whether the PDN connectivity ** + ** procedure is initiated as part of the at- ** + ** tach procedure ** + ** pti: Procedure transaction identity ** + ** msg: Encoded PDN connectivity request message ** + ** to be sent ** + ** sent_by_ue: Not used - Always TRUE ** + ** Others: None ** + ** ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ 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,66 +280,65 @@ 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) - { - emm_sap_t emm_sap; - emm_esm_data_t *emm_esm = &emm_sap.u.emm_esm.u.data; - /* - * Notity EMM that ESM PDU has to be forwarded to lower layers - */ - emm_sap.primitive = EMMESM_UNITDATA_REQ; - emm_sap.u.emm_esm.ueid = 0; - emm_esm->msg.length = msg->length; - emm_esm->msg.value = msg->value; - rc = emm_sap_send(&emm_sap); - - if (rc != RETURNerror) { - /* Start T3482 retransmission timer */ - rc = esm_pt_start_timer(pti, msg, T3482_DEFAULT_VALUE, - _pdn_connectivity_t3482_handler); - } + if (is_standalone) { + emm_sap_t emm_sap; + emm_esm_data_t *emm_esm = &emm_sap.u.emm_esm.u.data; + /* + * Notity EMM that ESM PDU has to be forwarded to lower layers + */ + emm_sap.primitive = EMMESM_UNITDATA_REQ; + emm_sap.u.emm_esm.ueid = 0; + emm_esm->msg.length = msg->length; + emm_esm->msg.value = msg->value; + rc = emm_sap_send(&emm_sap); + + if (rc != RETURNerror) { + /* Start T3482 retransmission timer */ + rc = esm_pt_start_timer(pti, msg, T3482_DEFAULT_VALUE, + _pdn_connectivity_t3482_handler); + } } if (rc != RETURNerror) { - /* Set the procedure transaction state to PENDING */ - rc = esm_pt_set_status(pti, ESM_PT_PENDING); - if (rc != RETURNok) { - /* The procedure transaction was already in PENDING state */ - LOG_TRACE(WARNING, "ESM-PROC - PTI %d was already PENDING", pti); - } + /* Set the procedure transaction state to PENDING */ + rc = esm_pt_set_status(pti, ESM_PT_PENDING); + if (rc != RETURNok) { + /* The procedure transaction was already in PENDING state */ + LOG_TRACE(WARNING, "ESM-PROC - PTI %d was already PENDING", pti); + } } LOG_FUNC_RETURN(rc); } /**************************************************************************** ** ** - ** Name: esm_proc_pdn_connectivity_accept() ** + ** Name: esm_proc_pdn_connectivity_accept() ** ** ** ** Description: Performs PDN connectivity procedure accepted by the net- ** - ** work. ** + ** work. ** ** ** ** 3GPP TS 24.301, section 6.5.1.3 ** - ** The UE shall stop timer T3482 and enter the state PROCE- ** - ** DURE TRANSACTION INACTIVE. ** - ** ** - ** Inputs: pti: Identifies the UE requested PDN connecti- ** - ** vity procedure accepted by the network ** - ** pdn_type: PDN type value (IPv4, IPv6, IPv4v6) ** - ** pdn_addr: PDN address ** - ** apn: Access Point Name of the PDN connection ** - ** Others: None ** - ** ** - ** Outputs: esm_cause: Cause code returned upon ESM procedure ** - ** failure ** - ** Return: The identifier of the PDN connection when ** - ** successfully updated; ** - ** RETURNerror otherwise. ** - ** Others: None ** + ** The UE shall stop timer T3482 and enter the state PROCE- ** + ** DURE TRANSACTION INACTIVE. ** + ** ** + ** Inputs: pti: Identifies the UE requested PDN connecti- ** + ** vity procedure accepted by the network ** + ** pdn_type: PDN type value (IPv4, IPv6, IPv4v6) ** + ** pdn_addr: PDN address ** + ** apn: Access Point Name of the PDN connection ** + ** Others: None ** + ** ** + ** Outputs: esm_cause: Cause code returned upon ESM procedure ** + ** failure ** + ** Return: The identifier of the PDN connection when ** + ** successfully updated; ** + ** RETURNerror otherwise. ** + ** Others: None ** ** ** ***************************************************************************/ 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; @@ -346,53 +346,52 @@ int esm_proc_pdn_connectivity_accept(int pti, esm_proc_pdn_type_t pdn_type, int pid = RETURNerror; LOG_TRACE(INFO, "ESM-PROC - PDN connectivity accepted by the network " - "(pti=%d) APN = %s, IP address = %s", pti, apn->value, - (pdn_type == ESM_PDN_TYPE_IPV4)? esm_data_get_ipv4_addr(pdn_addr) : - (pdn_type == ESM_PDN_TYPE_IPV6)? esm_data_get_ipv6_addr(pdn_addr) : - esm_data_get_ipv4v6_addr(pdn_addr)); + "(pti=%d) APN = %s, IP address = %s", pti, apn->value, + (pdn_type == ESM_PDN_TYPE_IPV4)? esm_data_get_ipv4_addr(pdn_addr) : + (pdn_type == ESM_PDN_TYPE_IPV6)? esm_data_get_ipv6_addr(pdn_addr) : + esm_data_get_ipv4v6_addr(pdn_addr)); /* Stop T3482 timer if running */ (void) esm_pt_stop_timer(pti); /* Set the procedure transaction state to INACTIVE */ rc = esm_pt_set_status(pti, ESM_PT_INACTIVE); if (rc != RETURNok) { - /* The procedure transaction was already in INACTIVE state - * as the request may have already been accepted; consider - * this request message with same PTI as a network re- - * transmission */ - LOG_TRACE(WARNING, "ESM-PROC - PTI %d network retransmission", pti); - *esm_cause = ESM_CAUSE_PTI_ALREADY_IN_USE; - } - 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. - * While the PTI value is not released, the UE regards any received - * ACTIVATE DEFAULT EPS BEARER CONTEXT REQUEST message with the same - * PTI value as a network retransmission. - * The way to achieve this is implementation dependent. - */ - - /* Check whether a PDN connection exists to this APN */ - pid = _pdn_connectivity_find_pdn(apn, pdn_type); - - if (pid < 0) { - /* No any PDN connection has been defined to establish connectivity - * to this APN */ - LOG_TRACE(WARNING, "ESM-PROC - PDN connection entry for " - "APN \"%s\" (type=%d) not found", apn->value, pdn_type); - *esm_cause = ESM_CAUSE_UNKNOWN_ACCESS_POINT_NAME; - LOG_FUNC_RETURN(RETURNerror); - } - - /* Update the PDN connection */ - rc = _pdn_connectivity_update(pid, apn, pdn_type, pdn_addr, *esm_cause); - if (rc != RETURNok) { - LOG_TRACE(WARNING, "ESM-PROC - Failed to update PDN connection " - "(pid=%d)", pid); - *esm_cause = ESM_CAUSE_REQUEST_REJECTED_UNSPECIFIED; - LOG_FUNC_RETURN(RETURNerror); - } + /* The procedure transaction was already in INACTIVE state + * as the request may have already been accepted; consider + * this request message with same PTI as a network re- + * transmission */ + LOG_TRACE(WARNING, "ESM-PROC - PTI %d network retransmission", pti); + *esm_cause = ESM_CAUSE_PTI_ALREADY_IN_USE; + } 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. + * While the PTI value is not released, the UE regards any received + * ACTIVATE DEFAULT EPS BEARER CONTEXT REQUEST message with the same + * PTI value as a network retransmission. + * The way to achieve this is implementation dependent. + */ + + /* Check whether a PDN connection exists to this APN */ + pid = _pdn_connectivity_find_pdn(apn, pdn_type); + + if (pid < 0) { + /* No any PDN connection has been defined to establish connectivity + * to this APN */ + LOG_TRACE(WARNING, "ESM-PROC - PDN connection entry for " + "APN \"%s\" (type=%d) not found", apn->value, pdn_type); + *esm_cause = ESM_CAUSE_UNKNOWN_ACCESS_POINT_NAME; + LOG_FUNC_RETURN(RETURNerror); + } + + /* Update the PDN connection */ + rc = _pdn_connectivity_update(pid, apn, pdn_type, pdn_addr, *esm_cause); + if (rc != RETURNok) { + LOG_TRACE(WARNING, "ESM-PROC - Failed to update PDN connection " + "(pid=%d)", pid); + *esm_cause = ESM_CAUSE_REQUEST_REJECTED_UNSPECIFIED; + LOG_FUNC_RETURN(RETURNerror); + } } LOG_FUNC_RETURN (pid); @@ -400,51 +399,50 @@ int esm_proc_pdn_connectivity_accept(int pti, esm_proc_pdn_type_t pdn_type, /**************************************************************************** ** ** - ** Name: esm_proc_pdn_connectivity_reject() ** + ** Name: esm_proc_pdn_connectivity_reject() ** ** ** ** Description: Performs PDN connectivity procedure not accepted by the ** - ** network. ** + ** network. ** ** ** ** 3GPP TS 24.301, section 6.5.1.4 ** - ** Upon receipt of the PDN CONNECTIVITY REJECT message, the ** - ** UE shall stop timer T3482 and enter the state PROCEDURE ** - ** TRANSACTION INACTIVE. ** + ** Upon receipt of the PDN CONNECTIVITY REJECT message, the ** + ** UE shall stop timer T3482 and enter the state PROCEDURE ** + ** TRANSACTION INACTIVE. ** ** ** - ** Inputs: pti: Identifies the UE requested PDN connecti- ** - ** vity procedure rejected by the network ** - ** Others: None ** + ** Inputs: pti: Identifies the UE requested PDN connecti- ** + ** vity procedure rejected by the network ** + ** Others: None ** ** ** - ** Outputs: esm_cause: Cause code returned upon ESM procedure ** - ** failure ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: esm_cause: Cause code returned upon ESM procedure ** + ** failure ** + ** Return: RETURNok, RETURNerror ** + ** 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; int rc; LOG_TRACE(WARNING, "ESM-PROC - PDN connectivity rejected by " - "the network (pti=%d), ESM cause = %d", pti, *esm_cause); + "the network (pti=%d), ESM cause = %d", pti, *esm_cause); /* Stop T3482 timer if running */ (void) esm_pt_stop_timer(pti); /* Set the procedure transaction state to INACTIVE */ rc = esm_pt_set_status(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", pti); - *esm_cause = ESM_CAUSE_MESSAGE_TYPE_NOT_COMPATIBLE; - } - else { - /* Release the procedure transaction identity */ - 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; - } + /* 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 { + /* Release the procedure transaction identity */ + 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; + } } LOG_FUNC_RETURN(rc); @@ -452,22 +450,22 @@ int esm_proc_pdn_connectivity_reject(int pti, int* esm_cause) /**************************************************************************** ** ** - ** Name: esm_proc_pdn_connectivity_complete() ** + ** Name: esm_proc_pdn_connectivity_complete() ** ** ** ** Description: Terminates the PDN connectivity procedure upon receiving ** - ** indication from the EPS Mobility Management sublayer that ** - ** the ACTIVATE DEFAULT EPS BEARER CONTEXT ACCEPT message ** - ** has been successfully delivered to the MME. ** + ** indication from the EPS Mobility Management sublayer that ** + ** the ACTIVATE DEFAULT EPS BEARER CONTEXT ACCEPT message ** + ** has been successfully delivered to the MME. ** ** ** - ** The UE releases the transaction identity assigned to this ** - ** PDN connectivity procedure. ** + ** The UE releases the transaction identity assigned to this ** + ** PDN connectivity procedure. ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ int esm_proc_pdn_connectivity_complete(void) @@ -482,8 +480,8 @@ int esm_proc_pdn_connectivity_complete(void) * entry which is still pending in the inactive state */ int pti = esm_pt_get_pending_pti(ESM_PT_INACTIVE); if (pti != ESM_PT_UNASSIGNED) { - /* Release the procedure transaction identity */ - rc = esm_pt_release(pti); + /* Release the procedure transaction identity */ + rc = esm_pt_release(pti); } LOG_FUNC_RETURN(rc); @@ -491,23 +489,23 @@ int esm_proc_pdn_connectivity_complete(void) /**************************************************************************** ** ** - ** Name: esm_proc_pdn_connectivity_failure() ** + ** Name: esm_proc_pdn_connectivity_failure() ** ** ** ** Description: Performs PDN connectivity procedure upon receiving trans- ** - ** mission failure of ESM message indication from the EPS ** - ** Mobility Management sublayer ** + ** mission failure of ESM message indication from the EPS ** + ** Mobility Management sublayer ** ** ** - ** The UE releases the transaction identity allocated to the ** - ** PDN connectivity procedure which is still pending in the ** - ** PROCEDURE TRANSACTION INACTIVE or PENDING state. ** + ** The UE releases the transaction identity allocated to the ** + ** PDN connectivity procedure which is still pending in the ** + ** PROCEDURE TRANSACTION INACTIVE or PENDING state. ** ** ** - ** Inputs: is_pending: TRUE if this PDN connectivity procedure ** - ** transaction is in the PENDING state ** - ** Others: None ** + ** Inputs: is_pending: TRUE if this PDN connectivity procedure ** + ** transaction is in the PENDING state ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ int esm_proc_pdn_connectivity_failure(int is_pending) @@ -518,30 +516,28 @@ int esm_proc_pdn_connectivity_failure(int is_pending) int pti; LOG_TRACE(WARNING, "ESM-PROC - PDN connectivity failure in state %s", - (is_pending)? "PENDING" : "INACTIVE"); - - if (is_pending) - { - /* Get the procedure transaction identity assigned to the pending PDN - * connection entry */ - pti = esm_pt_get_pending_pti(ESM_PT_PENDING); - if (pti == ESM_PT_UNASSIGNED) { - LOG_TRACE(ERROR, "ESM-PROC - No procedure transaction is PENDING"); - return (RETURNerror); - } - /* Set the procedure transaction state to INACTIVE */ - (void) esm_pt_set_status(pti, ESM_PT_INACTIVE); - } - 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); + (is_pending)? "PENDING" : "INACTIVE"); + + if (is_pending) { + /* Get the procedure transaction identity assigned to the pending PDN + * connection entry */ + pti = esm_pt_get_pending_pti(ESM_PT_PENDING); + if (pti == ESM_PT_UNASSIGNED) { + LOG_TRACE(ERROR, "ESM-PROC - No procedure transaction is PENDING"); + return (RETURNerror); + } + /* Set the procedure transaction state to INACTIVE */ + (void) esm_pt_set_status(pti, ESM_PT_INACTIVE); + } 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); } /* Release the procedure transaction identity */ rc = esm_pt_release(pti); if (rc != RETURNok) { - LOG_TRACE(WARNING, "ESM-PROC - Failed to release PTI %d", pti); + LOG_TRACE(WARNING, "ESM-PROC - Failed to release PTI %d", pti); } LOG_FUNC_RETURN(rc); @@ -551,54 +547,54 @@ int esm_proc_pdn_connectivity_failure(int is_pending) /* * -------------------------------------------------------------------------- - * PDN connectivity procedure executed by the MME + * PDN connectivity procedure executed by the MME * -------------------------------------------------------------------------- */ #ifdef NAS_MME /**************************************************************************** ** ** - ** Name: esm_proc_pdn_connectivity_request() ** + ** Name: esm_proc_pdn_connectivity_request() ** ** ** ** Description: Performs PDN connectivity procedure requested by the UE. ** ** ** ** 3GPP TS 24.301, section 6.5.1.3 ** - ** Upon receipt of the PDN CONNECTIVITY REQUEST message, the ** - ** MME checks if connectivity with the requested PDN can be ** - ** established. If no requested APN is provided the MME ** - ** shall use the default APN as the requested APN if the ** - ** request type is different from "emergency", or the APN ** - ** configured for emergency bearer services if the request ** - ** type is "emergency". ** - ** If connectivity with the requested PDN is accepted by the ** - ** network, the MME shall initiate the default EPS bearer ** - ** context activation procedure. ** - ** ** - ** Inputs: ueid: UE local identifier ** - ** pti: Identifies the PDN connectivity procedure ** - ** requested by the UE ** - ** request_type: Type of the PDN request ** - ** pdn_type: PDN type value (IPv4, IPv6, IPv4v6) ** - ** apn: Requested Access Point Name ** - ** Others: _esm_data ** - ** ** - ** Outputs: apn: Default Access Point Name ** - ** pdn_addr: Assigned IPv4 address and/or IPv6 suffix ** - ** esm_qos: EPS bearer level QoS parameters ** - ** esm_cause: Cause code returned upon ESM procedure ** - ** failure ** - ** Return: The identifier of the PDN connection if ** - ** successfully created; ** - ** RETURNerror otherwise. ** - ** Others: _esm_data ** + ** Upon receipt of the PDN CONNECTIVITY REQUEST message, the ** + ** MME checks if connectivity with the requested PDN can be ** + ** established. If no requested APN is provided the MME ** + ** shall use the default APN as the requested APN if the ** + ** request type is different from "emergency", or the APN ** + ** configured for emergency bearer services if the request ** + ** type is "emergency". ** + ** If connectivity with the requested PDN is accepted by the ** + ** network, the MME shall initiate the default EPS bearer ** + ** context activation procedure. ** + ** ** + ** Inputs: ueid: UE local identifier ** + ** pti: Identifies the PDN connectivity procedure ** + ** requested by the UE ** + ** request_type: Type of the PDN request ** + ** pdn_type: PDN type value (IPv4, IPv6, IPv4v6) ** + ** apn: Requested Access Point Name ** + ** Others: _esm_data ** + ** ** + ** Outputs: apn: Default Access Point Name ** + ** pdn_addr: Assigned IPv4 address and/or IPv6 suffix ** + ** esm_qos: EPS bearer level QoS parameters ** + ** esm_cause: Cause code returned upon ESM procedure ** + ** failure ** + ** Return: The identifier of the PDN connection if ** + ** successfully created; ** + ** RETURNerror otherwise. ** + ** Others: _esm_data ** ** ** ***************************************************************************/ 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) + 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) { LOG_FUNC_IN; @@ -606,90 +602,88 @@ int esm_proc_pdn_connectivity_request(unsigned int ueid, int pti, int pid = RETURNerror; LOG_TRACE(INFO, "ESM-PROC - PDN connectivity requested by the UE " - "(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"); + "(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"); /* UE identifier sanity check */ if (ueid >= ESM_DATA_NB_UE_MAX) { - LOG_TRACE(WARNING, "ESM-PROC - Number of connected UEs exceeded"); - LOG_FUNC_RETURN (RETURNerror); + LOG_TRACE(WARNING, "ESM-PROC - Number of connected UEs exceeded"); + LOG_FUNC_RETURN (RETURNerror); } /* * Check network IP capabilities */ *esm_cause = ESM_CAUSE_SUCCESS; - 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) && - (_esm_data.conf.features & MME_API_SINGLE_ADDR_BEARERS) ) { - /* The network supports single IP version bearers only */ - *esm_cause = ESM_CAUSE_SINGLE_ADDRESS_BEARERS_ONLY_ALLOWED; - } - rc = RETURNok; - break; - - case MME_API_IPV6: - /* The network supports connection to IPv6 only */ - *esm_cause = ESM_CAUSE_PDN_TYPE_IPV6_ONLY_ALLOWED; - if (pdn_type != ESM_PDN_TYPE_IPV4) { - rc = RETURNok; - } - break; - - case MME_API_IPV4: - /* The network supports connection to IPv4 only */ - *esm_cause = ESM_CAUSE_PDN_TYPE_IPV4_ONLY_ALLOWED; - if (pdn_type != ESM_PDN_TYPE_IPV6) { - rc = RETURNok; - } - break; + 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) && + (_esm_data.conf.features & MME_API_SINGLE_ADDR_BEARERS) ) { + /* The network supports single IP version bearers only */ + *esm_cause = ESM_CAUSE_SINGLE_ADDRESS_BEARERS_ONLY_ALLOWED; + } + rc = RETURNok; + break; + + case MME_API_IPV6: + /* The network supports connection to IPv6 only */ + *esm_cause = ESM_CAUSE_PDN_TYPE_IPV6_ONLY_ALLOWED; + if (pdn_type != ESM_PDN_TYPE_IPV4) { + rc = RETURNok; + } + break; + + case MME_API_IPV4: + /* The network supports connection to IPv4 only */ + *esm_cause = ESM_CAUSE_PDN_TYPE_IPV4_ONLY_ALLOWED; + if (pdn_type != ESM_PDN_TYPE_IPV6) { + rc = RETURNok; + } + break; } - if (rc != RETURNerror) - { - int is_emergency = (request_type == ESM_PDN_REQUEST_EMERGENCY); - mme_api_qos_t qos; - - /* Check if connectivity with the requested PDN can be established */ - rc = mme_api_subscribe(apn, pdn_addr, is_emergency, &qos); - - if (rc != RETURNok) { - LOG_TRACE(WARNING, "ESM-PROC - Connectivity to the requested PDN " - "cannot be established"); - *esm_cause = ESM_CAUSE_REQUEST_REJECTED_UNSPECIFIED; - LOG_FUNC_RETURN (RETURNerror); - } - - /* 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)); - memset(_esm_data.ctx[ueid], 0 , sizeof(esm_data_context_t)); - } - if (_esm_data.ctx[ueid]) { - /* Create new PDN connection */ - pid = _pdn_connectivity_create(ueid, pti, apn, pdn_type, - pdn_addr, is_emergency); - /* Setup ESM QoS parameters */ - if (esm_qos) { - esm_qos->gbrUL = qos.gbr[MME_API_UPLINK]; - esm_qos->gbrDL = qos.gbr[MME_API_DOWNLINK]; - esm_qos->mbrUL = qos.mbr[MME_API_UPLINK]; - esm_qos->mbrDL = qos.mbr[MME_API_DOWNLINK]; - esm_qos->qci = qos.qci; - } - } - - if (pid < 0) { - LOG_TRACE(WARNING, "ESM-PROC - Failed to create PDN connection"); - *esm_cause = ESM_CAUSE_INSUFFICIENT_RESOURCES; - LOG_FUNC_RETURN(RETURNerror); - } + if (rc != RETURNerror) { + int is_emergency = (request_type == ESM_PDN_REQUEST_EMERGENCY); + mme_api_qos_t qos; + + /* Check if connectivity with the requested PDN can be established */ + rc = mme_api_subscribe(apn, pdn_addr, is_emergency, &qos); + + if (rc != RETURNok) { + LOG_TRACE(WARNING, "ESM-PROC - Connectivity to the requested PDN " + "cannot be established"); + *esm_cause = ESM_CAUSE_REQUEST_REJECTED_UNSPECIFIED; + LOG_FUNC_RETURN (RETURNerror); + } + + /* 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)); + memset(_esm_data.ctx[ueid], 0 , sizeof(esm_data_context_t)); + } + if (_esm_data.ctx[ueid]) { + /* Create new PDN connection */ + pid = _pdn_connectivity_create(ueid, pti, apn, pdn_type, + pdn_addr, is_emergency); + /* Setup ESM QoS parameters */ + if (esm_qos) { + esm_qos->gbrUL = qos.gbr[MME_API_UPLINK]; + esm_qos->gbrDL = qos.gbr[MME_API_DOWNLINK]; + esm_qos->mbrUL = qos.mbr[MME_API_UPLINK]; + esm_qos->mbrDL = qos.mbr[MME_API_DOWNLINK]; + esm_qos->qci = qos.qci; + } + } + + if (pid < 0) { + LOG_TRACE(WARNING, "ESM-PROC - Failed to create PDN connection"); + *esm_cause = ESM_CAUSE_INSUFFICIENT_RESOURCES; + LOG_FUNC_RETURN(RETURNerror); + } } LOG_FUNC_RETURN(pid); @@ -697,51 +691,51 @@ int esm_proc_pdn_connectivity_request(unsigned int ueid, int pti, /**************************************************************************** ** ** - ** Name: esm_proc_pdn_connectivity_reject() ** + ** Name: esm_proc_pdn_connectivity_reject() ** ** ** ** Description: Performs PDN connectivity procedure not accepted by the ** - ** network. ** + ** network. ** ** ** ** 3GPP TS 24.301, section 6.5.1.4 ** - ** If connectivity with the requested PDN cannot be accepted ** - ** by the network, the MME shall send a PDN CONNECTIVITY RE- ** - ** JECT message to the UE. ** - ** ** - ** Inputs: is_standalone: Indicates whether the PDN connectivity ** - ** procedure was initiated as part of the at- ** - ** tach procedure ** - ** ueid: UE lower layer identifier ** - ** ebi: Not used ** - ** msg: Encoded PDN connectivity reject message to ** - ** be sent ** - ** ue_triggered: Not used ** - ** Others: None ** - ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** If connectivity with the requested PDN cannot be accepted ** + ** by the network, the MME shall send a PDN CONNECTIVITY RE- ** + ** JECT message to the UE. ** + ** ** + ** Inputs: is_standalone: Indicates whether the PDN connectivity ** + ** procedure was initiated as part of the at- ** + ** tach procedure ** + ** ueid: UE lower layer identifier ** + ** ebi: Not used ** + ** msg: Encoded PDN connectivity reject message to ** + ** be sent ** + ** ue_triggered: Not used ** + ** Others: None ** + ** ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ 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; int rc = RETURNerror; LOG_TRACE(WARNING, "ESM-PROC - PDN connectivity not accepted by the " - "network (ueid=%d)", ueid); + "network (ueid=%d)", ueid); if (is_standalone) { - emm_sap_t emm_sap; - /* - * Notity EMM that ESM PDU has to be forwarded to lower layers - */ - emm_sap.primitive = EMMESM_UNITDATA_REQ; - emm_sap.u.emm_esm.ueid = ueid; - emm_sap.u.emm_esm.u.data.msg.length = msg->length; - emm_sap.u.emm_esm.u.data.msg.value = msg->value; - rc = emm_sap_send(&emm_sap); + emm_sap_t emm_sap; + /* + * Notity EMM that ESM PDU has to be forwarded to lower layers + */ + emm_sap.primitive = EMMESM_UNITDATA_REQ; + emm_sap.u.emm_esm.ueid = ueid; + emm_sap.u.emm_esm.u.data.msg.length = msg->length; + emm_sap.u.emm_esm.u.data.msg.value = msg->value; + rc = emm_sap_send(&emm_sap); } /* If the PDN connectivity procedure initiated as part of the initial @@ -752,24 +746,24 @@ int esm_proc_pdn_connectivity_reject(int is_standalone, unsigned int ueid, /**************************************************************************** ** ** - ** Name: esm_proc_pdn_connectivity_failure() ** + ** Name: esm_proc_pdn_connectivity_failure() ** ** ** ** Description: Performs PDN connectivity procedure upon receiving noti- ** - ** fication from the EPS Mobility Management sublayer that ** - ** EMM procedure that initiated PDN connectivity activation ** - ** locally failed. ** + ** fication from the EPS Mobility Management sublayer that ** + ** EMM procedure that initiated PDN connectivity activation ** + ** locally failed. ** ** ** - ** The MME releases the PDN connection entry allocated when ** - ** the PDN connectivity procedure was requested by the UE. ** + ** The MME releases the PDN connection entry allocated when ** + ** the PDN connectivity procedure was requested by the UE. ** ** ** - ** Inputs: ueid: UE local identifier ** - ** pid: Identifier of the PDN connection to be ** - ** released ** - ** Others: None ** + ** Inputs: ueid: UE local identifier ** + ** pid: Identifier of the PDN connection to be ** + ** released ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ int esm_proc_pdn_connectivity_failure(unsigned int ueid, int pid) @@ -777,12 +771,12 @@ int esm_proc_pdn_connectivity_failure(unsigned int ueid, int pid) LOG_FUNC_IN; LOG_TRACE(WARNING, "ESM-PROC - PDN connectivity failure (ueid=%u, pid=%d)", - ueid, pid); + ueid, pid); /* Delete the PDN connection entry */ int pti = _pdn_connectivity_delete(ueid, pid); if (pti != ESM_PT_UNASSIGNED) { - LOG_FUNC_RETURN (RETURNok); + LOG_FUNC_RETURN (RETURNok); } LOG_FUNC_RETURN (RETURNerror); } @@ -795,83 +789,81 @@ int esm_proc_pdn_connectivity_failure(unsigned int ueid, int pid) #ifdef NAS_UE /* *--------------------------------------------------------------------------- - * Timer handlers + * Timer handlers *--------------------------------------------------------------------------- */ /**************************************************************************** ** ** - ** Name: _pdn_connectivity_t3482_handler() ** + ** Name: _pdn_connectivity_t3482_handler() ** ** ** ** Description: T3482 timeout handler ** ** ** ** 3GPP TS 24.301, section 6.5.1.5, case a ** - ** On the first expiry of the timer T3482, the UE shall re- ** - ** send the PDN CONNECTIVITY REQUEST and shall reset and re- ** - ** start timer T3482. This retransmission is repeated four ** - ** times, i.e. on the fifth expiry of timer T3482, the UE ** - ** shall abort the procedure, release the PTI allocated for ** - ** this invocation and enter the state PROCEDURE TRANSACTION ** - ** INACTIVE. ** + ** On the first expiry of the timer T3482, the UE shall re- ** + ** send the PDN CONNECTIVITY REQUEST and shall reset and re- ** + ** start timer T3482. This retransmission is repeated four ** + ** times, i.e. on the fifth expiry of timer T3482, the UE ** + ** shall abort the procedure, release the PTI allocated for ** + ** this invocation and enter the state PROCEDURE TRANSACTION ** + ** INACTIVE. ** ** ** - ** Inputs: args: handler parameters ** - ** Others: None ** + ** Inputs: args: handler parameters ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: None ** - ** Others: None ** + ** Outputs: None ** + ** Return: None ** + ** 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; LOG_TRACE(WARNING, "ESM-PROC - T3482 timer expired (pti=%d), " - "retransmission counter = %d", data->pti, data->count); + "retransmission counter = %d", data->pti, data->count); if (data->count < ESM_PDN_CONNECTIVITY_COUNTER_MAX) { - emm_sap_t emm_sap; - emm_esm_data_t *emm_esm = &emm_sap.u.emm_esm.u.data; - /* - * Notify EMM that the PDN connectivity request message - * has to be sent again - */ - emm_sap.primitive = EMMESM_UNITDATA_REQ; - emm_sap.u.emm_esm.ueid = 0; - emm_esm->msg.length = data->msg.length; - emm_esm->msg.value = data->msg.value; - rc = emm_sap_send(&emm_sap); - - if (rc != RETURNerror) { - /* Restart the timer T3482 */ - rc = esm_pt_start_timer(data->pti, &data->msg, T3482_DEFAULT_VALUE, - _pdn_connectivity_t3482_handler); - } - } - 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 { - /* 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); - } - } + emm_sap_t emm_sap; + emm_esm_data_t *emm_esm = &emm_sap.u.emm_esm.u.data; + /* + * Notify EMM that the PDN connectivity request message + * has to be sent again + */ + emm_sap.primitive = EMMESM_UNITDATA_REQ; + emm_sap.u.emm_esm.ueid = 0; + emm_esm->msg.length = data->msg.length; + emm_esm->msg.value = data->msg.value; + rc = emm_sap_send(&emm_sap); + + if (rc != RETURNerror) { + /* Restart the timer T3482 */ + rc = esm_pt_start_timer(data->pti, &data->msg, T3482_DEFAULT_VALUE, + _pdn_connectivity_t3482_handler); + } + } 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 { + /* 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); + } + } } LOG_FUNC_RETURN(NULL); @@ -879,80 +871,79 @@ static void* _pdn_connectivity_t3482_handler(void* args) /* *--------------------------------------------------------------------------- - * PDN connection handlers + * PDN connection handlers *--------------------------------------------------------------------------- */ /**************************************************************************** ** ** - ** Name: _pdn_connectivity_create() ** + ** Name: _pdn_connectivity_create() ** ** ** ** Description: Creates a new PDN connection entry or updates existing ** - ** non-active PDN connection entry ** + ** non-active PDN connection entry ** ** ** - ** Inputs: pid: Identifier of the PDN connection entry ** - ** apn: Access Point Name of the PDN connection ** - ** pdn_type: PDN type (IPv4, IPv6, IPv4v6) ** - ** is_emergency: TRUE if the PDN connection has to be esta- ** - ** blished for emergency bearer services ** - ** Others: _esm_data ** + ** Inputs: pid: Identifier of the PDN connection entry ** + ** apn: Access Point Name of the PDN connection ** + ** pdn_type: PDN type (IPv4, IPv6, IPv4v6) ** + ** is_emergency: TRUE if the PDN connection has to be esta- ** + ** blished for emergency bearer services ** + ** Others: _esm_data ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: _esm_data ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: _esm_data ** ** ** ***************************************************************************/ -static int _pdn_connectivity_create(int pid, const OctetString* apn, - esm_proc_pdn_type_t pdn_type, - int is_emergency) +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) { - LOG_TRACE(ERROR, "ESM-PROC - PDN connection is active"); - return (RETURNerror); + return (RETURNerror); + } else if (_esm_data.pdn[pid].is_active) { + LOG_TRACE(ERROR, "ESM-PROC - PDN connection is active"); + return (RETURNerror); } if (_esm_data.pdn[pid].data != NULL) { - /* Update existing non-active PDN connection */ - pdn = _esm_data.pdn[pid].data; + /* Update existing non-active PDN connection */ + pdn = _esm_data.pdn[pid].data; } else { - /* Create new PDN connection */ - pdn = (esm_pdn_t*)malloc(sizeof(esm_pdn_t)); - if (pdn == NULL) { - LOG_TRACE(WARNING, "ESM-PROC - " - "Failed to create new PDN connection"); - return (RETURNerror); - } - memset(pdn, 0, sizeof(esm_pdn_t)); - /* Increment the number of PDN connections */ - _esm_data.n_pdns += 1; - /* Set the PDN connection identifier */ - _esm_data.pdn[pid].pid = pid; - /* Reset the PDN connection active indicator */ - _esm_data.pdn[pid].is_active = FALSE; - /* Setup the PDN connection data */ - _esm_data.pdn[pid].data = pdn; + /* Create new PDN connection */ + pdn = (esm_pdn_t *)malloc(sizeof(esm_pdn_t)); + if (pdn == NULL) { + LOG_TRACE(WARNING, "ESM-PROC - " + "Failed to create new PDN connection"); + return (RETURNerror); + } + memset(pdn, 0, sizeof(esm_pdn_t)); + /* Increment the number of PDN connections */ + _esm_data.n_pdns += 1; + /* Set the PDN connection identifier */ + _esm_data.pdn[pid].pid = pid; + /* Reset the PDN connection active indicator */ + _esm_data.pdn[pid].is_active = FALSE; + /* Setup the PDN connection data */ + _esm_data.pdn[pid].data = pdn; } /* Update the PDN connection data */ pdn->is_emergency = is_emergency; 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); - if (pdn->apn.value) { - pdn->apn.length = apn->length; - memcpy(pdn->apn.value, apn->value, apn->length); - pdn->apn.value[pdn->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); + if (pdn->apn.value) { + pdn->apn.length = apn->length; + memcpy(pdn->apn.value, apn->value, apn->length); + pdn->apn.value[pdn->apn.length] = '\0'; + } } pdn->type = pdn_type; pdn->addr_realloc = FALSE; @@ -962,92 +953,87 @@ static int _pdn_connectivity_create(int pid, const OctetString* apn, /**************************************************************************** ** ** - ** Name: _pdn_connectivity_update() ** + ** Name: _pdn_connectivity_update() ** ** ** ** Description: Updates PDN connection entry with the given identifier ** ** ** - ** Inputs: pid: Identifier of the PDN connection entry ** - ** pdn_type: PDN type (IPv4, IPv6, IPv4v6) ** - ** pdn_addr: Network allocated PDN IPv4 or IPv6 address ** - ** esm_cause: ESM cause code ** - ** Others: None ** + ** Inputs: pid: Identifier of the PDN connection entry ** + ** pdn_type: PDN type (IPv4, IPv6, IPv4v6) ** + ** pdn_addr: Network allocated PDN IPv4 or IPv6 address ** + ** esm_cause: ESM cause code ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: _esm_data ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: _esm_data ** ** ** ***************************************************************************/ -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_update(int pid, const OctetString *apn, + esm_proc_pdn_type_t pdn_type, + 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) { - LOG_TRACE(ERROR, "ESM-PROC - PDN connection identifier is not valid"); - return (RETURNerror); - } - 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) { - 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); - return (RETURNerror); + return (RETURNerror); + } 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) { + LOG_TRACE(ERROR, "ESM-PROC - PDN connection has not been allocated"); + return (RETURNerror); + } 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); + return (RETURNerror); } /* 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); - if (pdn->apn.value) { - pdn->apn.length = apn->length; - memcpy(pdn->apn.value, apn->value, apn->length); - pdn->apn.value[pdn->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); + if (pdn->apn.value) { + pdn->apn.length = apn->length; + memcpy(pdn->apn.value, apn->value, apn->length); + pdn->apn.value[pdn->apn.length] = '\0'; + } } /* Setup the IP address allocated by the network */ if ( pdn_addr && (pdn_addr->length > 0) ) { - int length = ((pdn_addr->length < ESM_DATA_IP_ADDRESS_SIZE) ? - pdn_addr->length : ESM_DATA_IP_ADDRESS_SIZE); - memcpy(pdn->ip_addr, pdn_addr->value, length); - pdn->type = pdn_type; + int length = ((pdn_addr->length < ESM_DATA_IP_ADDRESS_SIZE) ? + pdn_addr->length : ESM_DATA_IP_ADDRESS_SIZE); + memcpy(pdn->ip_addr, pdn_addr->value, length); + pdn->type = pdn_type; } /* * 3GPP TS 24.301, section 6.2.2 * Update the address re-allocation indicator */ if (esm_cause == ESM_CAUSE_SINGLE_ADDRESS_BEARERS_ONLY_ALLOWED) { - /* The UE requested IPv4 or IPv6 address and the network allows - * single addressing per bearer: - * The UE should subsequently request another PDN connection for - * the other IP version using the UE requested PDN connectivity - * 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) || - (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: - * The UE shall not subsequently initiate another UE requested - * 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) { - pdn->addr_realloc = TRUE; + /* The UE requested IPv4 or IPv6 address and the network allows + * single addressing per bearer: + * The UE should subsequently request another PDN connection for + * the other IP version using the UE requested PDN connectivity + * 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) || + (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: + * The UE shall not subsequently initiate another UE requested + * 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) { + pdn->addr_realloc = TRUE; } return (RETURNok); @@ -1055,58 +1041,54 @@ static int _pdn_connectivity_update(int pid, const OctetString* apn, /**************************************************************************** ** ** - ** Name: _pdn_connectivity_delete() ** + ** Name: _pdn_connectivity_delete() ** ** ** ** Description: Deletes the PDN connection entry with given identifier ** ** ** - ** Inputs: pid: Identifier of the PDN connection to be ** - ** released ** - ** Others: _esm_data ** + ** Inputs: pid: Identifier of the PDN connection to be ** + ** released ** + ** Others: _esm_data ** ** ** - ** Outputs: None ** - ** Return: The identity of the procedure transaction ** - ** assigned to the PDN connection when suc- ** - ** cessfully released; ** - ** UNASSIGNED value otherwise. ** - ** Others: _esm_data ** + ** Outputs: None ** + ** Return: The identity of the procedure transaction ** + ** assigned to the PDN connection when suc- ** + ** cessfully released; ** + ** UNASSIGNED value otherwise. ** + ** Others: _esm_data ** ** ** ***************************************************************************/ static int _pdn_connectivity_delete(int pid) { int pti = ESM_PT_UNASSIGNED; - 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) { - LOG_TRACE(ERROR, - "ESM-PROC - PDN connection has not been allocated"); - } - else if (_esm_data.pdn[pid].is_active) { - LOG_TRACE(ERROR, "ESM-PROC - PDN connection is active"); - } - else { - /* Get the identity of the procedure transaction that created - * the PDN connection */ - pti = _esm_data.pdn[pid].data->pti; - } + 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) { + LOG_TRACE(ERROR, + "ESM-PROC - PDN connection has not been allocated"); + } else if (_esm_data.pdn[pid].is_active) { + LOG_TRACE(ERROR, "ESM-PROC - PDN connection is active"); + } else { + /* Get the identity of the procedure transaction that created + * the PDN connection */ + pti = _esm_data.pdn[pid].data->pti; + } } if (pti != ESM_PT_UNASSIGNED) { - /* Decrement the number of PDN connections */ - _esm_data.n_pdns -= 1; - /* Set the PDN connection as available */ - _esm_data.pdn[pid].pid = -1; - /* Release allocated PDN connection data */ - if (_esm_data.pdn[pid].data->apn.length > 0) { - free(_esm_data.pdn[pid].data->apn.value); - } - free(_esm_data.pdn[pid].data); - _esm_data.pdn[pid].data = NULL; - LOG_TRACE(WARNING, "ESM-PROC - PDN connection %d released", pid); + /* Decrement the number of PDN connections */ + _esm_data.n_pdns -= 1; + /* Set the PDN connection as available */ + _esm_data.pdn[pid].pid = -1; + /* Release allocated PDN connection data */ + if (_esm_data.pdn[pid].data->apn.length > 0) { + free(_esm_data.pdn[pid].data->apn.value); + } + free(_esm_data.pdn[pid].data); + _esm_data.pdn[pid].data = NULL; + LOG_TRACE(WARNING, "ESM-PROC - PDN connection %d released", pid); } /* Return the procedure transaction identity */ @@ -1115,41 +1097,37 @@ static int _pdn_connectivity_delete(int pid) /**************************************************************************** ** ** - ** Name: _pdn_connectivity_set_pti() ** + ** Name: _pdn_connectivity_set_pti() ** ** ** ** Description: Update the procedure transaction identity assigned to the ** - ** PDN connection entry with the given identifier ** + ** PDN connection entry with the given identifier ** ** ** - ** Inputs: pid: PDN connection identifier ** - ** pti: Procedure transaction identity ** - ** Others: None ** + ** Inputs: pid: PDN connection identifier ** + ** pti: Procedure transaction identity ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: _esm_data ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: _esm_data ** ** ** ***************************************************************************/ static int _pdn_connectivity_set_pti(int pid, int pti) { - 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) { - LOG_TRACE(ERROR, - "ESM-PROC - PDN connection has not been allocated"); - } - else if (_esm_data.pdn[pid].is_active) { - LOG_TRACE(ERROR, "ESM-PROC - PDN connection is active"); - } - else { - /* Update the identity of the procedure transaction assigned to - * the PDN connection */ - _esm_data.pdn[pid].data->pti = pti; - return (RETURNok); - } + 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) { + LOG_TRACE(ERROR, + "ESM-PROC - PDN connection has not been allocated"); + } else if (_esm_data.pdn[pid].is_active) { + LOG_TRACE(ERROR, "ESM-PROC - PDN connection is active"); + } else { + /* Update the identity of the procedure transaction assigned to + * the PDN connection */ + _esm_data.pdn[pid].data->pti = pti; + return (RETURNok); + } } return (RETURNerror); @@ -1157,37 +1135,36 @@ static int _pdn_connectivity_set_pti(int pid, int pti) /**************************************************************************** ** ** - ** Name: _pdn_connectivity_find_apn() ** + ** Name: _pdn_connectivity_find_apn() ** ** ** ** Description: Search the list of PDN connections for an entry defined ** - ** for the specified APN ** + ** for the specified APN ** ** ** - ** Inputs: apn: Access Point Name of the PDN connection ** - ** Others: _esm_data ** + ** Inputs: apn: Access Point Name of the PDN connection ** + ** Others: _esm_data ** ** ** - ** Outputs: None ** - ** Return: The identifier of the PDN connection if ** - ** found in the list; -1 otherwise. ** - ** Others: None ** + ** Outputs: None ** + ** Return: The identifier of the PDN connection if ** + ** found in the list; -1 otherwise. ** + ** 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++) - { - if ( (_esm_data.pdn[i].pid != -1) && _esm_data.pdn[i].data ) { - if (_esm_data.pdn[i].data->apn.length != apn->length) { - continue; - } - if (memcmp(_esm_data.pdn[i].data->apn.value, - apn->value, apn->length) != 0) { - continue; - } - /* PDN entry found */ - break; - } + 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; + } + if (memcmp(_esm_data.pdn[i].data->apn.value, + apn->value, apn->length) != 0) { + continue; + } + /* PDN entry found */ + break; + } } /* Return the identifier of the PDN connection */ @@ -1196,48 +1173,47 @@ static int _pdn_connectivity_find_apn(const OctetString* apn) /**************************************************************************** ** ** - ** Name: _pdn_connectivity_find_pdn() ** + ** Name: _pdn_connectivity_find_pdn() ** ** ** ** Description: Search the list of PDN connections for an entry defined ** - ** for the specified APN with the same PDN type ** + ** for the specified APN with the same PDN type ** ** ** - ** Inputs: apn: Access Point Name of the PDN connection ** - ** pdn_type: PDN address type ** - ** Others: _esm_data ** + ** Inputs: apn: Access Point Name of the PDN connection ** + ** pdn_type: PDN address type ** + ** Others: _esm_data ** ** ** - ** Outputs: None ** - ** Return: The identifier of the PDN connection if ** - ** found in the list; -1 otherwise. ** - ** Others: None ** + ** Outputs: None ** + ** Return: The identifier of the PDN connection if ** + ** found in the list; -1 otherwise. ** + ** Others: None ** ** ** ***************************************************************************/ -static int _pdn_connectivity_find_pdn(const OctetString* apn, - const esm_proc_pdn_type_t pdn_type) +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++) - { - 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) { - break; - } - /* Subsequent PDN connection established for the specified APN */ - if (_esm_data.pdn[i].data->apn.length != apn->length) { - continue; - } - if (memcmp(_esm_data.pdn[i].data->apn.value, - apn->value, apn->length) != 0) { - continue; - } - if (_esm_data.pdn[i].data->type == ESM_PDN_TYPE_IPV4V6) { - break; - } - if (_esm_data.pdn[i].data->type == pdn_type) { - break; - } - } + 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) { + break; + } + /* Subsequent PDN connection established for the specified APN */ + if (_esm_data.pdn[i].data->apn.length != apn->length) { + continue; + } + if (memcmp(_esm_data.pdn[i].data->apn.value, + apn->value, apn->length) != 0) { + continue; + } + if (_esm_data.pdn[i].data->type == ESM_PDN_TYPE_IPV4V6) { + break; + } + if (_esm_data.pdn[i].data->type == pdn_type) { + break; + } + } } /* Return the identifier of the PDN connection */ @@ -1248,106 +1224,103 @@ static int _pdn_connectivity_find_pdn(const OctetString* apn, #ifdef NAS_MME /* *--------------------------------------------------------------------------- - * PDN connection handlers + * PDN connection handlers *--------------------------------------------------------------------------- */ /**************************************************************************** ** ** - ** Name: _pdn_connectivity_create() ** + ** Name: _pdn_connectivity_create() ** ** ** ** Description: Creates a new PDN connection entry for the specified UE ** ** ** - ** Inputs: ueid: UE local identifier ** - ** pti: Procedure transaction identity ** - ** apn: Access Point Name of the PDN connection ** - ** pdn_type: PDN type (IPv4, IPv6, IPv4v6) ** - ** pdn_addr: Network allocated PDN IPv4 or IPv6 address ** - ** is_emergency: TRUE if the PDN connection has to be esta- ** - ** blished for emergency bearer services ** - ** Others: _esm_data ** + ** Inputs: ueid: UE local identifier ** + ** pti: Procedure transaction identity ** + ** apn: Access Point Name of the PDN connection ** + ** pdn_type: PDN type (IPv4, IPv6, IPv4v6) ** + ** pdn_addr: Network allocated PDN IPv4 or IPv6 address ** + ** is_emergency: TRUE if the PDN connection has to be esta- ** + ** blished for emergency bearer services ** + ** Others: _esm_data ** ** ** - ** Outputs: None ** - ** Return: The identifier of the PDN connection if ** - ** successfully created; -1 otherwise. ** - ** Others: _esm_data ** + ** Outputs: None ** + ** Return: The identifier of the PDN connection if ** + ** successfully created; -1 otherwise. ** + ** Others: _esm_data ** ** ** ***************************************************************************/ 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) + const OctetString *apn, + esm_proc_pdn_type_t pdn_type, + const OctetString *pdn_addr, + int is_emergency) { int pid = ESM_DATA_PDN_MAX; LOG_TRACE(INFO, "ESM-PROC - Create new PDN connection " - "(pti=%d) APN = %s, IP address = %s (ueid=%u)", pti, apn->value, - (pdn_type == ESM_PDN_TYPE_IPV4)? esm_data_get_ipv4_addr(pdn_addr) : - (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 (_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) { - LOG_TRACE(WARNING, "ESM-PROC - Number of PDN connection exceeded"); - } - else if (_esm_data.ctx[ueid]->emergency && is_emergency) { - LOG_TRACE(WARNING, "ESM-PROC - PDN connection for emergency bearer " - "services already established"); - } - 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; - break; - } - } + "(pti=%d) APN = %s, IP address = %s (ueid=%u)", pti, apn->value, + (pdn_type == ESM_PDN_TYPE_IPV4)? esm_data_get_ipv4_addr(pdn_addr) : + (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 (_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) { + LOG_TRACE(WARNING, "ESM-PROC - Number of PDN connection exceeded"); + } else if (_esm_data.ctx[ueid]->emergency && is_emergency) { + LOG_TRACE(WARNING, "ESM-PROC - PDN connection for emergency bearer " + "services already established"); + } 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; + } + break; + } + } } - if (pid < ESM_DATA_PDN_MAX) - { - /* Create new PDN connection */ - 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 */ - _esm_data.ctx[ueid]->n_pdns += 1; - /* Set the PDN connection identifier */ - _esm_data.ctx[ueid]->pdn[pid].pid = pid; - /* Reset the PDN connection active indicator */ - _esm_data.ctx[ueid]->pdn[pid].is_active = FALSE; - /* Setup the PDN connection data */ - _esm_data.ctx[ueid]->pdn[pid].data = pdn; - - /* Set the procedure transaction identity */ - pdn->pti = pti; - /* Set the emergency bearer services indicator */ - pdn->is_emergency = is_emergency; - /* Setup the Access Point Name */ - if ( apn && (apn->length > 0) ) { - 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); - pdn->apn.value[pdn->apn.length] = '\0'; - } - } - /* Setup the IP address allocated by the network */ - if ( pdn_addr && (pdn_addr->length > 0) ) { - int length = - ((pdn_addr->length < ESM_DATA_IP_ADDRESS_SIZE) ? - pdn_addr->length : ESM_DATA_IP_ADDRESS_SIZE); - memcpy(pdn->ip_addr, pdn_addr->value, length); - pdn->type = pdn_type; - } - /* Return the identifier of the new PDN connection */ - return (_esm_data.ctx[ueid]->pdn[pid].pid); - } - LOG_TRACE(WARNING, "ESM-PROC - Failed to create new PDN connection " - "(pid=%d)", pid); + if (pid < ESM_DATA_PDN_MAX) { + /* Create new PDN connection */ + 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 */ + _esm_data.ctx[ueid]->n_pdns += 1; + /* Set the PDN connection identifier */ + _esm_data.ctx[ueid]->pdn[pid].pid = pid; + /* Reset the PDN connection active indicator */ + _esm_data.ctx[ueid]->pdn[pid].is_active = FALSE; + /* Setup the PDN connection data */ + _esm_data.ctx[ueid]->pdn[pid].data = pdn; + + /* Set the procedure transaction identity */ + pdn->pti = pti; + /* Set the emergency bearer services indicator */ + pdn->is_emergency = is_emergency; + /* Setup the Access Point Name */ + if ( apn && (apn->length > 0) ) { + 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); + pdn->apn.value[pdn->apn.length] = '\0'; + } + } + /* Setup the IP address allocated by the network */ + if ( pdn_addr && (pdn_addr->length > 0) ) { + int length = + ((pdn_addr->length < ESM_DATA_IP_ADDRESS_SIZE) ? + pdn_addr->length : ESM_DATA_IP_ADDRESS_SIZE); + memcpy(pdn->ip_addr, pdn_addr->value, length); + pdn->type = pdn_type; + } + /* Return the identifier of the new PDN connection */ + return (_esm_data.ctx[ueid]->pdn[pid].pid); + } + LOG_TRACE(WARNING, "ESM-PROC - Failed to create new PDN connection " + "(pid=%d)", pid); } return (-1); @@ -1355,66 +1328,60 @@ static int _pdn_connectivity_create(unsigned int ueid, int pti, /**************************************************************************** ** ** - ** Name: _pdn_connectivity_delete() ** + ** Name: _pdn_connectivity_delete() ** ** ** ** Description: Deletes PDN connection to the specified UE associated to ** - ** PDN connection entry with given identifier ** + ** PDN connection entry with given identifier ** ** ** - ** Inputs: ueid: UE local identifier ** - ** pid: Identifier of the PDN connection to be ** - ** released ** - ** Others: _esm_data ** + ** Inputs: ueid: UE local identifier ** + ** pid: Identifier of the PDN connection to be ** + ** released ** + ** Others: _esm_data ** ** ** - ** Outputs: None ** - ** Return: The identity of the procedure transaction ** - ** assigned to the PDN connection when suc- ** - ** cessfully released; ** - ** UNASSIGNED value otherwise. ** - ** Others: _esm_data ** + ** Outputs: None ** + ** Return: The identity of the procedure transaction ** + ** assigned to the PDN connection when suc- ** + ** cessfully released; ** + ** UNASSIGNED value otherwise. ** + ** Others: _esm_data ** ** ** ***************************************************************************/ int _pdn_connectivity_delete(unsigned int ueid, int pid) { int pti = ESM_PT_UNASSIGNED; - 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) { - 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) { - LOG_TRACE(ERROR, - "ESM-PROC - PDN connection has not been allocated"); - } - else if (_esm_data.ctx[ueid]->pdn[pid].is_active) { - LOG_TRACE(ERROR, "ESM-PROC - PDN connection is active"); - } - else { - /* Get the identity of the procedure transaction that created - * the PDN connection */ - pti = _esm_data.ctx[ueid]->pdn[pid].data->pti; - } - } + 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) { + 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) { + LOG_TRACE(ERROR, + "ESM-PROC - PDN connection has not been allocated"); + } else if (_esm_data.ctx[ueid]->pdn[pid].is_active) { + LOG_TRACE(ERROR, "ESM-PROC - PDN connection is active"); + } else { + /* Get the identity of the procedure transaction that created + * the PDN connection */ + pti = _esm_data.ctx[ueid]->pdn[pid].data->pti; + } + } } - if (pti != ESM_PT_UNASSIGNED) - { - /* Decrement the number of PDN connections */ - _esm_data.ctx[ueid]->n_pdns -= 1; - /* Set the PDN connection as available */ - _esm_data.ctx[ueid]->pdn[pid].pid = -1; - /* Release allocated PDN connection data */ - if (_esm_data.ctx[ueid]->pdn[pid].data->apn.length > 0) { - free(_esm_data.ctx[ueid]->pdn[pid].data->apn.value); - } - free(_esm_data.ctx[ueid]->pdn[pid].data); - _esm_data.ctx[ueid]->pdn[pid].data = NULL; - LOG_TRACE(WARNING, "ESM-PROC - PDN connection %d released", pid); + if (pti != ESM_PT_UNASSIGNED) { + /* Decrement the number of PDN connections */ + _esm_data.ctx[ueid]->n_pdns -= 1; + /* Set the PDN connection as available */ + _esm_data.ctx[ueid]->pdn[pid].pid = -1; + /* Release allocated PDN connection data */ + if (_esm_data.ctx[ueid]->pdn[pid].data->apn.length > 0) { + free(_esm_data.ctx[ueid]->pdn[pid].data->apn.value); + } + free(_esm_data.ctx[ueid]->pdn[pid].data); + _esm_data.ctx[ueid]->pdn[pid].data = NULL; + LOG_TRACE(WARNING, "ESM-PROC - PDN connection %d released", pid); } /* Return the procedure transaction identity */ diff --git a/openair-cn/NAS/EURECOM-NAS/src/esm/PdnDisconnect.c b/openair-cn/NAS/EURECOM-NAS/src/esm/PdnDisconnect.c index 6feb909a03..8b22b7b63e 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/esm/PdnDisconnect.c +++ b/openair-cn/NAS/EURECOM-NAS/src/esm/PdnDisconnect.c @@ -1,27 +1,27 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source PdnDisconnect.c +Source PdnDisconnect.c -Version 0.1 +Version 0.1 -Date 2013/05/15 +Date 2013/05/15 -Product NAS stack +Product NAS stack -Subsystem EPS Session Management +Subsystem EPS Session Management -Author Frederic Maurel +Author Frederic Maurel -Description Defines the PDN disconnect ESM procedure executed by the - Non-Access Stratum. +Description Defines the PDN disconnect ESM procedure executed by the + Non-Access Stratum. - The PDN disconnect procedure is used by the UE to request - disconnection from one PDN. + The PDN disconnect procedure is used by the UE to request + disconnection from one PDN. - All EPS bearer contexts established towards this PDN, inclu- - ding the default EPS bearer context, are released. + All EPS bearer contexts established towards this PDN, inclu- + ding the default EPS bearer context, are released. *****************************************************************************/ @@ -53,7 +53,7 @@ extern int _pdn_connectivity_delete(unsigned int ueid, int pid); /* * -------------------------------------------------------------------------- - * Internal data handled by the PDN disconnect procedure in the UE + * Internal data handled by the PDN disconnect procedure in the UE * -------------------------------------------------------------------------- */ #ifdef NAS_UE @@ -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 @@ -74,7 +74,7 @@ static void* _pdn_disconnect_t3492_handler(void*); /* * -------------------------------------------------------------------------- - * Internal data handled by the PDN disconnect procedure in the MME + * Internal data handled by the PDN disconnect procedure in the MME * -------------------------------------------------------------------------- */ #ifdef NAS_MME @@ -91,31 +91,31 @@ static int _pdn_disconnect_get_pid(unsigned int ueid, int pti); /* * -------------------------------------------------------------------------- - * PDN disconnect procedure executed by the UE + * PDN disconnect procedure executed by the UE * -------------------------------------------------------------------------- */ #ifdef NAS_UE /**************************************************************************** ** ** - ** Name: esm_proc_pdn_disconnect() ** + ** Name: esm_proc_pdn_disconnect() ** ** ** ** Description: Return the procedure transaction identity assigned to the ** - ** PDN connection and the EPS bearer identity of the default ** - ** bearer associated to the PDN context with specified iden- ** - ** tifier ** + ** PDN connection and the EPS bearer identity of the default ** + ** bearer associated to the PDN context with specified iden- ** + ** tifier ** ** ** - ** Inputs: cid: PDN context identifier ** - ** Others: _esm_data ** + ** Inputs: cid: PDN context identifier ** + ** Others: _esm_data ** ** ** - ** Outputs: pti: Procedure transaction identity assigned to ** - ** the PDN connection to be released ** - ** ebi: EPS bearer identity of the default bearer ** - ** associated to the specified PDN context ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: pti: Procedure transaction identity assigned to ** + ** the PDN connection to be released ** + ** ebi: EPS bearer identity of the default bearer ** + ** associated to the specified PDN context ** + ** Return: RETURNok, RETURNerror ** + ** 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; @@ -123,26 +123,23 @@ int esm_proc_pdn_disconnect(int cid, unsigned int* pti, unsigned int* ebi) int pid = cid - 1; if (pid < ESM_DATA_PDN_MAX) { - 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) { - LOG_TRACE(ERROR, "ESM-PROC - PDN connection %d has not been " - "allocated", pid); - } - else if (!_esm_data.pdn[pid].is_active) { - LOG_TRACE(WARNING, "ESM-PROC - PDN connection is not active"); - } - else { - /* Get the procedure transaction identity assigned to the PDN - * connection to be released */ - *pti = _esm_data.pdn[pid].data->pti; - /* Get the EPS bearer identity of the default bearer associated - * with the PDN to disconnect from */ - *ebi = _esm_data.pdn[pid].data->bearer[0]->ebi; - rc = RETURNok; - } + 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) { + LOG_TRACE(ERROR, "ESM-PROC - PDN connection %d has not been " + "allocated", pid); + } else if (!_esm_data.pdn[pid].is_active) { + LOG_TRACE(WARNING, "ESM-PROC - PDN connection is not active"); + } else { + /* Get the procedure transaction identity assigned to the PDN + * connection to be released */ + *pti = _esm_data.pdn[pid].data->pti; + /* Get the EPS bearer identity of the default bearer associated + * with the PDN to disconnect from */ + *ebi = _esm_data.pdn[pid].data->bearer[0]->ebi; + rc = RETURNok; + } } LOG_FUNC_RETURN(rc); @@ -150,30 +147,30 @@ int esm_proc_pdn_disconnect(int cid, unsigned int* pti, unsigned int* ebi) /**************************************************************************** ** ** - ** Name: esm_proc_pdn_disconnect_request() ** + ** Name: esm_proc_pdn_disconnect_request() ** ** ** ** Description: Initiates PDN disconnection procedure in order to request ** - ** disconnection from a PDN. ** + ** disconnection from a PDN. ** ** ** ** 3GPP TS 24.301, section 6.5.2.2 ** - ** The UE requests PDN disconnection from a PDN by sending a ** - ** PDN DISCONNECT REQUEST message to the MME, starting timer ** - ** T3492 and entering state PROCEDURE TRANSACTION PENDING. ** + ** The UE requests PDN disconnection from a PDN by sending a ** + ** PDN DISCONNECT REQUEST message to the MME, starting timer ** + ** T3492 and entering state PROCEDURE TRANSACTION PENDING. ** ** ** - ** Inputs: is_standalone: Should be always TRUE ** - ** pti: Procedure transaction identity ** - ** msg: Encoded PDN disconnect request message to ** - ** be sent ** - ** sent_by_ue: Not used ** - ** Others: None ** + ** Inputs: is_standalone: Should be always TRUE ** + ** pti: Procedure transaction identity ** + ** msg: Encoded PDN disconnect request message to ** + ** be sent ** + ** sent_by_ue: Not used ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ 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,83 +178,81 @@ 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) - { - emm_sap_t emm_sap; - emm_esm_data_t *emm_esm = &emm_sap.u.emm_esm.u.data; - /* - * Notity EMM that ESM PDU has to be forwarded to lower layers - */ - emm_sap.primitive = EMMESM_UNITDATA_REQ; - emm_sap.u.emm_esm.ueid = 0; - emm_esm->msg.length = msg->length; - emm_esm->msg.value = msg->value; - rc = emm_sap_send(&emm_sap); - - if (rc != RETURNerror) { - /* Start T3482 retransmission timer */ - rc = esm_pt_start_timer(pti, msg, T3492_DEFAULT_VALUE, - _pdn_disconnect_t3492_handler); - } + if (is_standalone) { + emm_sap_t emm_sap; + emm_esm_data_t *emm_esm = &emm_sap.u.emm_esm.u.data; + /* + * Notity EMM that ESM PDU has to be forwarded to lower layers + */ + emm_sap.primitive = EMMESM_UNITDATA_REQ; + emm_sap.u.emm_esm.ueid = 0; + emm_esm->msg.length = msg->length; + emm_esm->msg.value = msg->value; + rc = emm_sap_send(&emm_sap); + + if (rc != RETURNerror) { + /* Start T3482 retransmission timer */ + rc = esm_pt_start_timer(pti, msg, T3492_DEFAULT_VALUE, + _pdn_disconnect_t3492_handler); + } } if (rc != RETURNerror) { - /* Set the procedure transaction state to PENDING */ - rc = esm_pt_set_status(pti, ESM_PT_PENDING); - if (rc != RETURNok) { - /* The procedure transaction was already in PENDING state */ - LOG_TRACE(WARNING, "ESM-PROC - PTI %d was already PENDING", pti); - } + /* Set the procedure transaction state to PENDING */ + rc = esm_pt_set_status(pti, ESM_PT_PENDING); + if (rc != RETURNok) { + /* The procedure transaction was already in PENDING state */ + LOG_TRACE(WARNING, "ESM-PROC - PTI %d was already PENDING", pti); + } } LOG_FUNC_RETURN(rc); } /**************************************************************************** ** ** - ** Name: esm_proc_pdn_disconnect_accept() ** + ** Name: esm_proc_pdn_disconnect_accept() ** ** ** ** Description: Performs PDN disconnection procedure accepted by the net- ** - ** work. ** + ** work. ** ** ** ** 3GPP TS 24.301, section 6.5.2.3 ** - ** The shall stop timer T3492 and enter the state PROCEDURE ** - ** TRANSACTION INACTIVE. ** + ** The shall stop timer T3492 and enter the state PROCEDURE ** + ** TRANSACTION INACTIVE. ** ** ** - ** Inputs: pti: Identifies the UE requested PDN disconnect ** - ** procedure accepted by the network ** - ** Others: None ** + ** Inputs: pti: Identifies the UE requested PDN disconnect ** + ** procedure accepted by the network ** + ** Others: None ** ** ** - ** Outputs: esm_cause: Cause code returned upon ESM procedure ** - ** failure ** - ** Return: The identifier of the PDN context to de- ** - ** activate when successfully found; ** - ** RETURNerror otherwise. ** - ** Others: None ** + ** Outputs: esm_cause: Cause code returned upon ESM procedure ** + ** failure ** + ** Return: The identifier of the PDN context to de- ** + ** activate when successfully found; ** + ** RETURNerror otherwise. ** + ** 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; LOG_TRACE(INFO, "ESM-PROC - PDN disconnection accepted by the network " - "(pti=%d)", pti); + "(pti=%d)", pti); /* Stop T3492 timer if running */ (void) esm_pt_stop_timer(pti); /* Set the procedure transaction state to INACTIVE */ int rc = esm_pt_set_status(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", pti); - *esm_cause = ESM_CAUSE_MESSAGE_TYPE_NOT_COMPATIBLE; - } - else { - /* Immediately 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); - } + /* 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 { + /* Immediately 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); + } } LOG_FUNC_RETURN (rc); @@ -265,79 +260,76 @@ int esm_proc_pdn_disconnect_accept(int pti, int* esm_cause) /**************************************************************************** ** ** - ** Name: esm_proc_pdn_disconnect_reject() ** + ** Name: esm_proc_pdn_disconnect_reject() ** ** ** ** Description: Performs PDN disconnection procedure not accepted by the ** - ** network. ** + ** network. ** ** ** ** 3GPP TS 24.301, section 6.5.2.4 ** - ** Upon receipt of the PDN DISCONNECT REJECT message, the UE ** - ** shall stop timer T3492 and enter the state PROCEDURE ** - ** TRANSACTION INACTIVE and abort the PDN disconnection pro- ** - ** cedure. ** + ** Upon receipt of the PDN DISCONNECT REJECT message, the UE ** + ** shall stop timer T3492 and enter the state PROCEDURE ** + ** TRANSACTION INACTIVE and abort the PDN disconnection pro- ** + ** cedure. ** ** ** - ** Inputs: pti: Identifies the UE requested PDN disconnec- ** - ** tion procedure rejected by the network ** - ** Others: None ** + ** Inputs: pti: Identifies the UE requested PDN disconnec- ** + ** tion procedure rejected by the network ** + ** Others: None ** ** ** - ** Outputs: esm_cause: Cause code returned upon ESM procedure ** - ** failure ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: esm_cause: Cause code returned upon ESM procedure ** + ** failure ** + ** Return: RETURNok, RETURNerror ** + ** 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; int rc; LOG_TRACE(WARNING, "ESM-PROC - PDN disconnection rejected by the network " - "(pti=%d), ESM cause = %d", pti, *esm_cause); + "(pti=%d), ESM cause = %d", pti, *esm_cause); /* Stop T3492 timer if running */ (void) esm_pt_stop_timer(pti); /* Set the procedure transaction state to INACTIVE */ rc = esm_pt_set_status(pti, ESM_PT_INACTIVE); if (rc != RETURNok) { - /* The procedure transaction was already in INACTIVE state - * 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 { - /* 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) - { - /* 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); - if (ebi < 0) { - LOG_TRACE(ERROR, "ESM-PROC - No default EPS bearer found"); - *esm_cause = ESM_CAUSE_PROTOCOL_ERROR; - LOG_FUNC_RETURN (RETURNerror); - } - /* - * Notify ESM that all EPS bearer contexts to this PDN have to be - * locally deactivated - */ - esm_sap_t esm_sap; - esm_sap.primitive = ESM_EPS_BEARER_CONTEXT_DEACTIVATE_REQ; - esm_sap.is_standalone = TRUE; - esm_sap.recv = NULL; - esm_sap.send.length = 0; - esm_sap.data.eps_bearer_context_deactivate.ebi = ebi; - rc = esm_sap_send(&esm_sap); - - if (rc != RETURNok) { - *esm_cause = ESM_CAUSE_PROTOCOL_ERROR; - } - } + /* The procedure transaction was already in INACTIVE state + * 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 { + /* 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) { + /* 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); + if (ebi < 0) { + LOG_TRACE(ERROR, "ESM-PROC - No default EPS bearer found"); + *esm_cause = ESM_CAUSE_PROTOCOL_ERROR; + LOG_FUNC_RETURN (RETURNerror); + } + /* + * Notify ESM that all EPS bearer contexts to this PDN have to be + * locally deactivated + */ + esm_sap_t esm_sap; + esm_sap.primitive = ESM_EPS_BEARER_CONTEXT_DEACTIVATE_REQ; + esm_sap.is_standalone = TRUE; + esm_sap.recv = NULL; + esm_sap.send.length = 0; + esm_sap.data.eps_bearer_context_deactivate.ebi = ebi; + rc = esm_sap_send(&esm_sap); + + if (rc != RETURNok) { + *esm_cause = ESM_CAUSE_PROTOCOL_ERROR; + } + } } LOG_FUNC_RETURN(rc); @@ -348,67 +340,64 @@ int esm_proc_pdn_disconnect_reject(int pti, int* esm_cause) /* * -------------------------------------------------------------------------- - * PDN disconnect procedure executed by the MME + * PDN disconnect procedure executed by the MME * -------------------------------------------------------------------------- */ #ifdef NAS_MME /**************************************************************************** ** ** - ** Name: esm_proc_pdn_disconnect_request() ** + ** Name: esm_proc_pdn_disconnect_request() ** ** ** ** Description: Performs PDN disconnect procedure requested by the UE. ** ** ** ** 3GPP TS 24.301, section 6.5.2.3 ** - ** Upon receipt of the PDN DISCONNECT REQUEST message, if it ** - ** is accepted by the network, the MME shall initiate the ** - ** bearer context deactivation procedure. ** - ** ** - ** Inputs: ueid: UE lower layer identifier ** - ** pti: Identifies the PDN disconnect procedure ** - ** requested by the UE ** - ** Others: _esm_data ** - ** ** - ** Outputs: esm_cause: Cause code returned upon ESM procedure ** - ** failure ** - ** Return: The identifier of the PDN connection to be ** - ** released, if it exists; ** - ** RETURNerror otherwise. ** - ** Others: None ** + ** Upon receipt of the PDN DISCONNECT REQUEST message, if it ** + ** is accepted by the network, the MME shall initiate the ** + ** bearer context deactivation procedure. ** + ** ** + ** Inputs: ueid: UE lower layer identifier ** + ** pti: Identifies the PDN disconnect procedure ** + ** requested by the UE ** + ** Others: _esm_data ** + ** ** + ** Outputs: esm_cause: Cause code returned upon ESM procedure ** + ** failure ** + ** Return: The identifier of the PDN connection to be ** + ** released, if it exists; ** + ** RETURNerror otherwise. ** + ** 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; int pid = RETURNerror; LOG_TRACE(INFO, "ESM-PROC - PDN disconnect requested by the UE " - "(ueid=%d, pti=%d)", ueid, pti); - - if (ueid < ESM_DATA_NB_UE_MAX) - { - /* Get UE's ESM context */ - 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) { - /* Get the identifier of the PDN connection entry assigned to the - * procedure transaction identity */ - pid = _pdn_disconnect_get_pid(ueid, pti); - if (pid < 0) { - LOG_TRACE(ERROR, "ESM-PROC - No PDN connection found (pti=%d)", - pti); - *esm_cause = ESM_CAUSE_PROTOCOL_ERROR; - LOG_FUNC_RETURN (RETURNerror); - } - } - else { - /* Attempt to disconnect from the last PDN disconnection - * is not allowed */ - *esm_cause = ESM_CAUSE_LAST_PDN_DISCONNECTION_NOT_ALLOWED; - } + "(ueid=%d, pti=%d)", ueid, pti); + + if (ueid < ESM_DATA_NB_UE_MAX) { + /* Get UE's ESM context */ + 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) { + /* Get the identifier of the PDN connection entry assigned to the + * procedure transaction identity */ + pid = _pdn_disconnect_get_pid(ueid, pti); + if (pid < 0) { + LOG_TRACE(ERROR, "ESM-PROC - No PDN connection found (pti=%d)", + pti); + *esm_cause = ESM_CAUSE_PROTOCOL_ERROR; + LOG_FUNC_RETURN (RETURNerror); + } + } else { + /* Attempt to disconnect from the last PDN disconnection + * is not allowed */ + *esm_cause = ESM_CAUSE_LAST_PDN_DISCONNECTION_NOT_ALLOWED; + } } LOG_FUNC_RETURN(pid); @@ -416,41 +405,41 @@ int esm_proc_pdn_disconnect_request(unsigned int ueid, int pti, int* esm_cause) /**************************************************************************** ** ** - ** Name: esm_proc_pdn_disconnect_accept() ** + ** Name: esm_proc_pdn_disconnect_accept() ** ** ** ** Description: Performs PDN disconnect procedure accepted by the UE. ** ** ** ** 3GPP TS 24.301, section 6.5.2.3 ** - ** On reception of DEACTIVATE EPS BEARER CONTEXT ACCEPT mes- ** - ** sage from the UE, the MME releases all the resources re- ** - ** served for the PDN in the network. ** + ** On reception of DEACTIVATE EPS BEARER CONTEXT ACCEPT mes- ** + ** sage from the UE, the MME releases all the resources re- ** + ** served for the PDN in the network. ** ** ** - ** Inputs: ueid: UE lower layer identifier ** - ** pid: Identifier of the PDN connection to be ** - ** released ** - ** Others: _esm_data ** + ** Inputs: ueid: UE lower layer identifier ** + ** pid: Identifier of the PDN connection to be ** + ** released ** + ** Others: _esm_data ** ** ** - ** Outputs: esm_cause: Cause code returned upon ESM procedure ** - ** failure ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: esm_cause: Cause code returned upon ESM procedure ** + ** failure ** + ** Return: RETURNok, RETURNerror ** + ** 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; LOG_TRACE(INFO, "ESM-PROC - PDN disconnect accepted by the UE " - "(ueid=%d, pid=%d)", ueid, pid); + "(ueid=%d, pid=%d)", ueid, pid); /* Release the connectivity with the requested PDN */ int rc = mme_api_unsubscribe(NULL); if (rc != RETURNerror) { - /* Delete the PDN connection entry */ - int pti = _pdn_connectivity_delete(ueid, pid); - if (pti != ESM_PT_UNASSIGNED) { - LOG_FUNC_RETURN (RETURNok); - } + /* Delete the PDN connection entry */ + int pti = _pdn_connectivity_delete(ueid, pid); + if (pti != ESM_PT_UNASSIGNED) { + LOG_FUNC_RETURN (RETURNok); + } } *esm_cause = ESM_CAUSE_PROTOCOL_ERROR; LOG_FUNC_RETURN (RETURNerror); @@ -458,31 +447,31 @@ int esm_proc_pdn_disconnect_accept(unsigned int ueid, int pid, int* esm_cause) /**************************************************************************** ** ** - ** Name: esm_proc_pdn_disconnect_reject() ** + ** Name: esm_proc_pdn_disconnect_reject() ** ** ** ** Description: Performs PDN disconnect procedure not accepted by the ** - ** network. ** + ** network. ** ** ** ** 3GPP TS 24.301, section 6.5.2.4 ** - ** Upon receipt of the PDN DISCONNECT REQUEST message, if it ** - ** is not accepted by the network, the MME shall send a PDN ** - ** DISCONNECT REJECT message to the UE. ** - ** ** - ** Inputs: is_standalone: Not used - Always TRUE ** - ** ueid: UE lower layer identifier ** - ** ebi: Not used ** - ** msg: Encoded PDN disconnect reject message to ** - ** be sent ** - ** ue_triggered: Not used ** - ** Others: None ** - ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Upon receipt of the PDN DISCONNECT REQUEST message, if it ** + ** is not accepted by the network, the MME shall send a PDN ** + ** DISCONNECT REJECT message to the UE. ** + ** ** + ** Inputs: is_standalone: Not used - Always TRUE ** + ** ueid: UE lower layer identifier ** + ** ebi: Not used ** + ** msg: Encoded PDN disconnect reject message to ** + ** be sent ** + ** ue_triggered: Not used ** + ** Others: None ** + ** ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ 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; @@ -490,7 +479,7 @@ int esm_proc_pdn_disconnect_reject(int is_standalone, unsigned int ueid, emm_sap_t emm_sap; LOG_TRACE(WARNING, "ESM-PROC - PDN disconnect not accepted by the network " - "(ueid=%d)", ueid); + "(ueid=%d)", ueid); /* * Notity EMM that ESM PDU has to be forwarded to lower layers @@ -511,106 +500,103 @@ int esm_proc_pdn_disconnect_reject(int is_standalone, unsigned int ueid, /* * -------------------------------------------------------------------------- - * Timer handlers + * Timer handlers * -------------------------------------------------------------------------- */ #ifdef NAS_UE /**************************************************************************** ** ** - ** Name: _pdn_disconnect_t3492_handler() ** + ** Name: _pdn_disconnect_t3492_handler() ** ** ** ** Description: T3492 timeout handler ** ** ** ** 3GPP TS 24.301, section 6.5.2.5, case a ** - ** On the first expiry of the timer T3492, the UE shall re- ** - ** send the PDN DISCONNECT REQUEST and shall reset and re- ** - ** start timer T3492. This retransmission is repeated four ** - ** times, i.e. on the fifth expiry of timer T3492, the UE ** - ** shall abort the procedure, deactivate all EPS bearer con- ** - ** texts for this PDN connection locally, release the PTI ** - ** allocated for this invocation and enter the state PROCE- ** - ** DURE TRANSACTION INACTIVE. ** - ** ** - ** Inputs: args: handler parameters ** - ** Others: None ** - ** ** - ** Outputs: None ** - ** Return: None ** - ** Others: None ** + ** On the first expiry of the timer T3492, the UE shall re- ** + ** send the PDN DISCONNECT REQUEST and shall reset and re- ** + ** start timer T3492. This retransmission is repeated four ** + ** times, i.e. on the fifth expiry of timer T3492, the UE ** + ** shall abort the procedure, deactivate all EPS bearer con- ** + ** texts for this PDN connection locally, release the PTI ** + ** allocated for this invocation and enter the state PROCE- ** + ** DURE TRANSACTION INACTIVE. ** + ** ** + ** Inputs: args: handler parameters ** + ** Others: None ** + ** ** + ** Outputs: None ** + ** Return: None ** + ** 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; LOG_TRACE(WARNING, "ESM-PROC - T3492 timer expired (pti=%d), " - "retransmission counter = %d", data->pti, data->count); + "retransmission counter = %d", data->pti, data->count); if (data->count < ESM_PDN_DISCONNECT_COUNTER_MAX) { - emm_sap_t emm_sap; - emm_esm_data_t *emm_esm = &emm_sap.u.emm_esm.u.data; - /* - * Notify EMM that the PDN connectivity request message - * has to be sent again - */ - emm_sap.primitive = EMMESM_UNITDATA_REQ; - emm_sap.u.emm_esm.ueid = 0; - emm_esm->msg.length = data->msg.length; - emm_esm->msg.value = data->msg.value; - rc = emm_sap_send(&emm_sap); - - if (rc != RETURNerror) { - /* Restart the timer T3492 */ - rc = esm_pt_start_timer(data->pti, &data->msg, T3492_DEFAULT_VALUE, - _pdn_disconnect_t3492_handler); - } - } - 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 { - /* 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 { - /* 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(data->pti); - if (ebi < 0) { - LOG_TRACE(ERROR, "ESM-PROC - No default EPS bearer found"); - LOG_FUNC_RETURN (NULL); - } - /* - * Notify ESM that all EPS bearer contexts to this PDN have - * to be locally deactivated - */ - esm_sap_t esm_sap; - esm_sap.primitive = ESM_EPS_BEARER_CONTEXT_DEACTIVATE_REQ; - esm_sap.is_standalone = TRUE; - esm_sap.recv = NULL; - esm_sap.send.length = 0; - esm_sap.data.eps_bearer_context_deactivate.ebi = ebi; - rc = esm_sap_send(&esm_sap); - } - } + emm_sap_t emm_sap; + emm_esm_data_t *emm_esm = &emm_sap.u.emm_esm.u.data; + /* + * Notify EMM that the PDN connectivity request message + * has to be sent again + */ + emm_sap.primitive = EMMESM_UNITDATA_REQ; + emm_sap.u.emm_esm.ueid = 0; + emm_esm->msg.length = data->msg.length; + emm_esm->msg.value = data->msg.value; + rc = emm_sap_send(&emm_sap); + + if (rc != RETURNerror) { + /* Restart the timer T3492 */ + rc = esm_pt_start_timer(data->pti, &data->msg, T3492_DEFAULT_VALUE, + _pdn_disconnect_t3492_handler); + } + } 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 { + /* 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 { + /* 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(data->pti); + if (ebi < 0) { + LOG_TRACE(ERROR, "ESM-PROC - No default EPS bearer found"); + LOG_FUNC_RETURN (NULL); + } + /* + * Notify ESM that all EPS bearer contexts to this PDN have + * to be locally deactivated + */ + esm_sap_t esm_sap; + esm_sap.primitive = ESM_EPS_BEARER_CONTEXT_DEACTIVATE_REQ; + esm_sap.is_standalone = TRUE; + esm_sap.recv = NULL; + esm_sap.send.length = 0; + esm_sap.data.eps_bearer_context_deactivate.ebi = ebi; + rc = esm_sap_send(&esm_sap); + } + } } LOG_FUNC_RETURN(NULL); @@ -619,26 +605,26 @@ static void* _pdn_disconnect_t3492_handler(void* args) /* *--------------------------------------------------------------------------- - * PDN disconnection handlers + * PDN disconnection handlers *--------------------------------------------------------------------------- */ #ifdef NAS_UE /**************************************************************************** ** ** - ** Name: _pdn_disconnect_get_default_ebi() ** + ** Name: _pdn_disconnect_get_default_ebi() ** ** ** ** Description: Returns the EPS bearer identity of the default EPS bearer ** - ** context allocated to the PDN connection to which the gi- ** - ** ven procedure transaction identity has been assigned ** + ** context allocated to the PDN connection to which the gi- ** + ** ven procedure transaction identity has been assigned ** ** ** - ** Inputs: pti: The procedure transaction identity ** - ** Others: _esm_data ** + ** Inputs: pti: The procedure transaction identity ** + ** Others: _esm_data ** ** ** - ** Outputs: None ** - ** Return: The EPS bearer identity of the default EPS ** - ** bearer context, if it exists; -1 otherwise ** - ** Others: None ** + ** Outputs: None ** + ** Return: The EPS bearer identity of the default EPS ** + ** bearer context, if it exists; -1 otherwise ** + ** Others: None ** ** ** ***************************************************************************/ static int _pdn_disconnect_get_default_ebi(int pti) @@ -646,16 +632,18 @@ static int _pdn_disconnect_get_default_ebi(int pti) int ebi = -1; 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; - /* PDN entry found */ - if (_esm_data.pdn[i].data->bearer[0] != NULL) { - /* Get the EPS bearer identity of the default EPS bearer - * context associated to the PDN connection */ - ebi = _esm_data.pdn[i].data->bearer[0]->ebi; - } - break; - } + if ( (_esm_data.pdn[i].pid != -1) && _esm_data.pdn[i].data ) { + 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 + * context associated to the PDN connection */ + ebi = _esm_data.pdn[i].data->bearer[0]->ebi; + } + break; + } } return (ebi); @@ -665,20 +653,20 @@ static int _pdn_disconnect_get_default_ebi(int pti) #ifdef NAS_MME /**************************************************************************** ** ** - ** Name: _pdn_disconnect_get_pid() ** + ** Name: _pdn_disconnect_get_pid() ** ** ** ** Description: Returns the identifier of the PDN connection to which the ** - ** given procedure transaction identity has been assigned ** - ** to establish connectivity to the specified UE ** + ** given procedure transaction identity has been assigned ** + ** to establish connectivity to the specified UE ** ** ** - ** Inputs: ueid: UE local identifier ** - ** pti: The procedure transaction identity ** - ** Others: _esm_data ** + ** Inputs: ueid: UE local identifier ** + ** pti: The procedure transaction identity ** + ** Others: _esm_data ** ** ** - ** Outputs: None ** - ** Return: The identifier of the PDN connection if ** - ** found in the list; -1 otherwise. ** - ** Others: None ** + ** Outputs: None ** + ** Return: The identifier of the PDN connection if ** + ** found in the list; -1 otherwise. ** + ** Others: None ** ** ** ***************************************************************************/ static int _pdn_disconnect_get_pid(unsigned int ueid, int pti) @@ -686,14 +674,16 @@ static int _pdn_disconnect_get_pid(unsigned int ueid, int pti) int i = ESM_DATA_PDN_MAX; if ( (ueid < ESM_DATA_NB_UE_MAX) && (_esm_data.ctx[ueid] != NULL) ) { - 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; - /* PDN entry found */ - break; - } - } + 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; + } + /* PDN entry found */ + break; + } + } } /* Return the identifier of the PDN connection */ diff --git a/openair-cn/NAS/EURECOM-NAS/src/esm/esmData.h b/openair-cn/NAS/EURECOM-NAS/src/esm/esmData.h index 1136e6dac3..3773933495 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/esm/esmData.h +++ b/openair-cn/NAS/EURECOM-NAS/src/esm/esmData.h @@ -1,21 +1,21 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source esmData.h +Source esmData.h -Version 0.1 +Version 0.1 -Date 2012/12/04 +Date 2012/12/04 -Product NAS stack +Product NAS stack -Subsystem EPS Session Management +Subsystem EPS Session Management -Author Frederic Maurel +Author Frederic Maurel -Description Defines internal private data handled by EPS Session - Management sublayer. +Description Defines internal private data handled by EPS Session + Management sublayer. *****************************************************************************/ #ifndef __ESMDATA_H__ @@ -28,14 +28,14 @@ Description Defines internal private data handled by EPS Session #include "mme_api.h" #endif -#include <stdio.h> // sprintf +#include <stdio.h> // sprintf /****************************************************************************/ /********************* G L O B A L C O N S T A N T S *******************/ /****************************************************************************/ /* Total number of active EPS bearers */ -#define ESM_DATA_EPS_BEARER_TOTAL 11 +#define ESM_DATA_EPS_BEARER_TOTAL 11 /****************************************************************************/ /************************ G L O B A L T Y P E S ************************/ @@ -57,10 +57,10 @@ Description Defines internal private data handled by EPS Session * applied within the EPC and E-UTRAN. */ typedef struct { - int bid; /* Identifier of the EPS bearer */ - unsigned int ebi; /* EPS bearer identity */ - network_qos_t qos; /* EPS bearer level QoS parameters */ - network_tft_t tft; /* Traffic Flow Template for packet filtering */ + int bid; /* Identifier of the EPS bearer */ + unsigned int ebi; /* EPS bearer identity */ + network_qos_t qos; /* EPS bearer level QoS parameters */ + network_tft_t tft; /* Traffic Flow Template for packet filtering */ } esm_bearer_t; /* @@ -71,26 +71,26 @@ typedef struct { * an Access Point Name (APN). */ typedef struct { - unsigned int pti; /* Identity of the procedure transaction executed - * to activate the PDN connection entry */ - int is_emergency; /* Emergency bearer services indicator */ - OctetString apn; /* Access Point Name currently in used */ - int ambr; /* Aggregate Maximum Bit Rate of this APN */ - int type; /* Address PDN type (IPv4, IPv6, IPv4v6) */ -#define ESM_DATA_IPV4_ADDRESS_SIZE 4 -#define ESM_DATA_IPV6_ADDRESS_SIZE 8 -#define ESM_DATA_IP_ADDRESS_SIZE (ESM_DATA_IPV4_ADDRESS_SIZE + \ - ESM_DATA_IPV6_ADDRESS_SIZE) - /* IPv4 PDN address and/or IPv6 prefix */ + unsigned int pti; /* Identity of the procedure transaction executed + * to activate the PDN connection entry */ + int is_emergency; /* Emergency bearer services indicator */ + OctetString apn; /* Access Point Name currently in used */ + int ambr; /* Aggregate Maximum Bit Rate of this APN */ + int type; /* Address PDN type (IPv4, IPv6, IPv4v6) */ +#define ESM_DATA_IPV4_ADDRESS_SIZE 4 +#define ESM_DATA_IPV6_ADDRESS_SIZE 8 +#define ESM_DATA_IP_ADDRESS_SIZE (ESM_DATA_IPV4_ADDRESS_SIZE + \ + ESM_DATA_IPV6_ADDRESS_SIZE) + /* IPv4 PDN address and/or IPv6 prefix */ char ip_addr[ESM_DATA_IP_ADDRESS_SIZE+1]; - int addr_realloc; /* Indicates whether the UE is allowed to subsequently - * request another PDN connectivity to the same APN - * using an address PDN type (IPv4 or IPv6) other - * than the one already activated */ - 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]; + int addr_realloc; /* Indicates whether the UE is allowed to subsequently + * request another PDN connectivity to the same APN + * using an address PDN type (IPv4 or IPv6) other + * than the one already activated */ + 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_pdn_t; /* @@ -102,17 +102,17 @@ typedef struct { * a PDN connection. */ typedef struct { - int n_ebrs; /* Total number of active EPS bearer contexts */ - int n_pdns; /* Number of active PDN connections */ - int emergency; /* Indicates whether a PDN connection for emergency - * bearer services is established */ -#define ESM_DATA_PDN_MAX 4 + int n_ebrs; /* Total number of active EPS bearer contexts */ + int n_pdns; /* Number of active PDN connections */ + int emergency; /* Indicates whether a PDN connection for emergency + * bearer services is established */ +#define ESM_DATA_PDN_MAX 4 struct { - int pid; /* Identifier of the PDN connection */ - 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 */ + int pid; /* Identifier of the PDN connection */ + 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 */ } pdn[ESM_DATA_PDN_MAX+1]; } esm_data_context_t; @@ -149,8 +149,8 @@ typedef struct { * ESM contexts * ------------ */ -#define ESM_DATA_NB_UE_MAX (MME_API_NB_UE_MAX + 1) - esm_data_context_t* ctx[ESM_DATA_NB_UE_MAX]; +#define ESM_DATA_NB_UE_MAX (MME_API_NB_UE_MAX + 1) + 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__*/ diff --git a/openair-cn/NAS/EURECOM-NAS/src/esm/esm_ebr.c b/openair-cn/NAS/EURECOM-NAS/src/esm/esm_ebr.c index 55cc629dfd..dfb25e745b 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/esm/esm_ebr.c +++ b/openair-cn/NAS/EURECOM-NAS/src/esm/esm_ebr.c @@ -1,21 +1,21 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source esm_ebr.c +Source esm_ebr.c -Version 0.1 +Version 0.1 -Date 2013/01/29 +Date 2013/01/29 -Product NAS stack +Product NAS stack -Subsystem EPS Session Management +Subsystem EPS Session Management -Author Frederic Maurel +Author Frederic Maurel -Description Defines functions used to handle state of EPS bearer contexts - and manage ESM messages re-transmission. +Description Defines functions used to handle state of EPS bearer contexts + and manage ESM messages re-transmission. *****************************************************************************/ @@ -25,8 +25,8 @@ Description Defines functions used to handle state of EPS bearer contexts #include "mme_api.h" -#include <stdlib.h> // malloc, free -#include <string.h> // memcpy +#include <stdlib.h> // malloc, free +#include <string.h> // memcpy /****************************************************************************/ /**************** E X T E R N A L D E F I N I T I O N S ****************/ @@ -36,14 +36,14 @@ Description Defines functions used to handle state of EPS bearer contexts * Minimal and maximal value of an EPS bearer identity: * The EPS Bearer Identity (EBI) identifies a message flow */ -#define ESM_EBI_MIN (EPS_BEARER_IDENTITY_FIRST) -#define ESM_EBI_MAX (EPS_BEARER_IDENTITY_LAST) +#define ESM_EBI_MIN (EPS_BEARER_IDENTITY_FIRST) +#define ESM_EBI_MAX (EPS_BEARER_IDENTITY_LAST) #ifdef NAS_UE -#define ESM_EBR_NB_UE_MAX 1 +#define ESM_EBR_NB_UE_MAX 1 #endif #ifdef NAS_MME -#define ESM_EBR_NB_UE_MAX (MME_API_NB_UE_MAX + 1) +#define ESM_EBR_NB_UE_MAX (MME_API_NB_UE_MAX + 1) #endif /****************************************************************************/ @@ -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 @@ -67,17 +67,17 @@ static const char* _esm_ebr_state_str[ESM_EBR_STATE_MAX] = { * ----------------------- */ typedef struct { - unsigned char ebi; /* EPS bearer identity */ - esm_ebr_state status; /* EPS bearer context status */ + unsigned char ebi; /* EPS bearer identity */ + esm_ebr_state status; /* EPS bearer context status */ #ifdef NAS_UE - int is_default_ebr; /* TRUE if the bearer context is associated - * to a default EPS bearer */ - char cid; /* Identifier of the PDN context the EPS - * bearer context has been assigned to */ + int is_default_ebr; /* TRUE if the bearer context is associated + * to a default EPS bearer */ + char cid; /* Identifier of the PDN context the EPS + * bearer context has been assigned to */ #endif #ifdef NAS_MME - struct nas_timer_t timer; /* Retransmission timer */ - esm_ebr_timer_data_t* args; /* Retransmission timer parameters data */ + struct nas_timer_t timer; /* Retransmission timer */ + esm_ebr_timer_data_t *args; /* Retransmission timer parameters data */ #endif } esm_ebr_context_t; @@ -87,10 +87,10 @@ typedef struct { * ---------------------------------- */ static struct { - unsigned char index; /* Index of the next EPS bearer context - * identity to be used */ + 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]; /* @@ -106,17 +106,17 @@ static esm_indication_callback_t _esm_ebr_callback; static const network_pdn_state_t _esm_ebr_pdn_state[2][2][2] = { /* Status modification triggerer by the network */ { - /* Dedicated EPS bearer */ - {NET_PDN_NW_DEDICATED_DEACT, NET_PDN_NW_DEDICATED_ACT}, - /* Default EPS bearer */ - {NET_PDN_NW_DEFAULT_DEACT, 0} + /* Dedicated EPS bearer */ + {NET_PDN_NW_DEDICATED_DEACT, NET_PDN_NW_DEDICATED_ACT}, + /* Default EPS bearer */ + {NET_PDN_NW_DEFAULT_DEACT, 0} }, /* Status modification triggered by the UE */ { - /* Dedicated EPS bearer */ - {NET_PDN_MT_DEDICATED_DEACT, NET_PDN_MT_DEDICATED_ACT}, - /* Default EPS bearer */ - {NET_PDN_MT_DEFAULT_DEACT, NET_PDN_MT_DEFAULT_ACT} + /* Dedicated EPS bearer */ + {NET_PDN_MT_DEDICATED_DEACT, NET_PDN_MT_DEDICATED_ACT}, + /* Default EPS bearer */ + {NET_PDN_MT_DEFAULT_DEACT, NET_PDN_MT_DEFAULT_ACT} } }; #endif @@ -131,33 +131,33 @@ static int _esm_ebr_get_available_entry(unsigned int ueid); /**************************************************************************** ** ** - ** Name: esm_ebr_initialize() ** + ** Name: esm_ebr_initialize() ** ** ** ** Description: Initialize EPS bearer context data ** ** ** - ** Inputs: cb: User notification callback ** - ** Others: None ** + ** Inputs: cb: User notification callback ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: None ** - ** Others: _esm_ebr_data ** + ** Outputs: None ** + ** Return: None ** + ** Others: _esm_ebr_data ** ** ** ***************************************************************************/ void esm_ebr_initialize( #ifdef NAS_UE - esm_indication_callback_t cb + esm_indication_callback_t cb #endif - ) +) { int ueid, i; LOG_FUNC_IN; for (ueid = 0; ueid < ESM_EBR_NB_UE_MAX; ueid++) { - _esm_ebr_data[ueid].index = 0; - /* Initialize EPS bearer context data */ - for (i = 0; i < ESM_EBR_DATA_SIZE + 1; i++) { - _esm_ebr_data[ueid].context[i] = NULL; - } + _esm_ebr_data[ueid].index = 0; + /* Initialize EPS bearer context data */ + for (i = 0; i < ESM_EBR_DATA_SIZE + 1; i++) { + _esm_ebr_data[ueid].context[i] = NULL; + } } #ifdef NAS_UE /* Initialize the user notification callback */ @@ -169,23 +169,23 @@ void esm_ebr_initialize( /**************************************************************************** ** ** - ** Name: esm_ebr_assign() ** + ** Name: esm_ebr_assign() ** ** ** ** Description: Assigns a new EPS bearer context ** ** ** - ** Inputs: ueid: Lower layers UE identifier ** - ** ebi: Identity of the new EPS bearer context ** - ** cid: Identifier of the PDN context the EPS bea- ** - ** rer context is associated to ** - ** default_ebr TRUE if the new bearer context is associa- ** - ** ted to a default EPS bearer ** - ** Others: None ** + ** Inputs: ueid: Lower layers UE identifier ** + ** ebi: Identity of the new EPS bearer context ** + ** cid: Identifier of the PDN context the EPS bea- ** + ** rer context is associated to ** + ** default_ebr TRUE if the new bearer context is associa- ** + ** ted to a default EPS bearer ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: The identity of the new EPS bearer context ** - ** if successfully assigned; ** - ** the not assigned EBI (0) otherwise. ** - ** Others: _esm_ebr_data ** + ** Outputs: None ** + ** Return: The identity of the new EPS bearer context ** + ** if successfully assigned; ** + ** the not assigned EBI (0) otherwise. ** + ** Others: _esm_ebr_data ** ** ** ***************************************************************************/ #ifdef NAS_UE @@ -204,37 +204,34 @@ int esm_ebr_assign(unsigned int ueid, int ebi) int i; if (ueid >= ESM_EBR_NB_UE_MAX) { - LOG_FUNC_RETURN (ESM_EBI_UNASSIGNED); + LOG_FUNC_RETURN (ESM_EBI_UNASSIGNED); } 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) { - 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 - { - /* Search for an available EPS bearer identity */ - i = _esm_ebr_get_available_entry(ueid); - if (i < 0) { - LOG_FUNC_RETURN(ESM_EBI_UNASSIGNED); - } - /* An available EPS bearer context is found */ - ebi = i + ESM_EBI_MIN; + 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) { + 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 { + /* Search for an available EPS bearer identity */ + i = _esm_ebr_get_available_entry(ueid); + if (i < 0) { + LOG_FUNC_RETURN(ESM_EBI_UNASSIGNED); + } + /* An available EPS bearer context is found */ + ebi = i + ESM_EBI_MIN; } /* 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); + LOG_FUNC_RETURN(ESM_EBI_UNASSIGNED); } /* Store the index of the next available EPS bearer identity */ _esm_ebr_data[ueid].index = i + 1; @@ -262,27 +259,27 @@ int esm_ebr_assign(unsigned int ueid, int ebi) /**************************************************************************** ** ** - ** Name: esm_ebr_release() ** + ** Name: esm_ebr_release() ** ** ** ** Description: Release the given EPS bearer identity ** ** ** - ** Inputs: ueid: Lower layers UE identifier ** - ** ebi: The identity of the EPS bearer context to ** - ** be released ** - ** Others: None ** + ** Inputs: ueid: Lower layers UE identifier ** + ** ebi: The identity of the EPS bearer context to ** + ** be released ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok if the EPS bearer context has ** - ** been successfully released; ** - ** RETURNerror otherwise. ** - ** Others: _esm_ebr_data ** + ** Outputs: None ** + ** Return: RETURNok if the EPS bearer context has ** + ** been successfully released; ** + ** RETURNerror otherwise. ** + ** Others: _esm_ebr_data ** ** ** ***************************************************************************/ int esm_ebr_release( #ifdef NAS_MME - unsigned int ueid, + unsigned int ueid, #endif - int ebi) + int ebi) { LOG_FUNC_IN; @@ -291,38 +288,38 @@ int esm_ebr_release( #endif if (ueid >= ESM_EBR_NB_UE_MAX) { - LOG_FUNC_RETURN (RETURNerror); + LOG_FUNC_RETURN (RETURNerror); } if ( (ebi < ESM_EBI_MIN) || (ebi > ESM_EBI_MAX) ) { - LOG_FUNC_RETURN (RETURNerror); + LOG_FUNC_RETURN (RETURNerror); } /* 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); + /* EPS bearer context not assigned */ + LOG_FUNC_RETURN (RETURNerror); } /* Do not release active EPS bearer context */ if (ctx->status != ESM_EBR_INACTIVE) { - LOG_TRACE(ERROR, "ESM-FSM - EPS bearer context is not INACTIVE"); - LOG_FUNC_RETURN (RETURNerror); + LOG_TRACE(ERROR, "ESM-FSM - EPS bearer context is not INACTIVE"); + LOG_FUNC_RETURN (RETURNerror); } #ifdef NAS_MME /* Stop the retransmission timer if still running */ if (ctx->timer.id != NAS_TIMER_INACTIVE_ID) { - LOG_TRACE(INFO, "ESM-FSM - Stop retransmission timer %d", - ctx->timer.id); - ctx->timer.id = nas_timer_stop(ctx->timer.id); + LOG_TRACE(INFO, "ESM-FSM - Stop retransmission timer %d", + ctx->timer.id); + ctx->timer.id = nas_timer_stop(ctx->timer.id); } /* Release the retransmisison timer parameters */ if (ctx->args) { - if (ctx->args->msg.length > 0) { - free(ctx->args->msg.value); - } - free(ctx->args); - ctx->args = NULL; + if (ctx->args->msg.length > 0) { + free(ctx->args->msg.value); + } + free(ctx->args); + ctx->args = NULL; } #endif @@ -337,96 +334,95 @@ int esm_ebr_release( #ifdef NAS_MME /**************************************************************************** ** ** - ** Name: esm_ebr_start_timer() ** + ** Name: esm_ebr_start_timer() ** ** ** ** Description: Start the timer of the specified EPS bearer context to ** - ** expire after a given time interval. Timer expiration will ** - ** schedule execution of the callback function where stored ** - ** ESM message should be re-transmit. ** + ** expire after a given time interval. Timer expiration will ** + ** schedule execution of the callback function where stored ** + ** ESM message should be re-transmit. ** ** ** - ** Inputs: ueid: Lower layers UE identifier ** - ** ebi: The identity of the EPS bearer ** - ** msg: The encoded ESM message to be stored ** - ** sec: The value of the time interval in seconds ** - ** cb: Function executed upon timer expiration ** - ** Others: None ** + ** Inputs: ueid: Lower layers UE identifier ** + ** ebi: The identity of the EPS bearer ** + ** msg: The encoded ESM message to be stored ** + ** sec: The value of the time interval in seconds ** + ** cb: Function executed upon timer expiration ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: _esm_ebr_data ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: _esm_ebr_data ** ** ** ***************************************************************************/ -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) { LOG_FUNC_IN; if (ueid >= ESM_EBR_NB_UE_MAX) { - LOG_FUNC_RETURN (RETURNerror); + LOG_FUNC_RETURN (RETURNerror); } if ( (ebi < ESM_EBI_MIN) || (ebi > ESM_EBI_MAX) ) { - LOG_FUNC_RETURN (RETURNerror); + LOG_FUNC_RETURN (RETURNerror); } /* 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); + /* EPS bearer context not assigned */ + LOG_FUNC_RETURN (RETURNerror); } if (ctx->timer.id != NAS_TIMER_INACTIVE_ID) { - if (ctx->args) { - /* Re-start the retransmission timer */ - ctx->timer.id = nas_timer_restart(ctx->timer.id); - } - } - else { - /* Setup the retransmission timer parameters */ - 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; - /* Set the EPS bearer identity */ - ctx->args->ebi = ebi; - /* 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.length = 0; - if (ctx->args->msg.value) { - memcpy(ctx->args->msg.value, msg->value, msg->length); - ctx->args->msg.length = msg->length; - } - /* Setup the retransmission timer to expire at the given - * time interval */ - ctx->timer.id = nas_timer_start(sec, cb, ctx->args); - ctx->timer.sec = sec; - } - } - + if (ctx->args) { + /* Re-start the retransmission timer */ + ctx->timer.id = nas_timer_restart(ctx->timer.id); + } + } else { + /* Setup the retransmission timer parameters */ + 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; + /* Set the EPS bearer identity */ + ctx->args->ebi = ebi; + /* 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.length = 0; + if (ctx->args->msg.value) { + memcpy(ctx->args->msg.value, msg->value, msg->length); + ctx->args->msg.length = msg->length; + } + /* Setup the retransmission timer to expire at the given + * time interval */ + ctx->timer.id = nas_timer_start(sec, cb, ctx->args); + ctx->timer.sec = sec; + } + } + if ( (ctx->args != NULL) && (ctx->timer.id != NAS_TIMER_INACTIVE_ID) ) { - LOG_TRACE(INFO, "ESM-FSM - Retransmission timer %d expires in " - "%ld seconds", ctx->timer.id, ctx->timer.sec); - LOG_FUNC_RETURN (RETURNok); + LOG_TRACE(INFO, "ESM-FSM - Retransmission timer %d expires in " + "%ld seconds", ctx->timer.id, ctx->timer.sec); + LOG_FUNC_RETURN (RETURNok); } LOG_FUNC_RETURN (RETURNerror); } /**************************************************************************** ** ** - ** Name: esm_ebr_stop_timer() ** + ** Name: esm_ebr_stop_timer() ** ** ** ** Description: Stop the timer previously started for the given EPS bea- ** - ** rer context ** + ** rer context ** ** ** - ** Inputs: ueid: Lower layers UE identifier ** - ** ebi: The identity of the EPS bearer ** - ** Others: None ** + ** Inputs: ueid: Lower layers UE identifier ** + ** ebi: The identity of the EPS bearer ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: _esm_ebr_data ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: _esm_ebr_data ** ** ** ***************************************************************************/ int esm_ebr_stop_timer( unsigned int ueid, int ebi) @@ -434,33 +430,33 @@ int esm_ebr_stop_timer( unsigned int ueid, int ebi) LOG_FUNC_IN; if (ueid >= ESM_EBR_NB_UE_MAX) { - LOG_FUNC_RETURN (RETURNerror); + LOG_FUNC_RETURN (RETURNerror); } if ( (ebi < ESM_EBI_MIN) || (ebi > ESM_EBI_MAX) ) { - LOG_FUNC_RETURN (RETURNerror); + LOG_FUNC_RETURN (RETURNerror); } /* 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); + /* EPS bearer context not assigned */ + LOG_FUNC_RETURN (RETURNerror); } /* Stop the retransmission timer if still running */ if (ctx->timer.id != NAS_TIMER_INACTIVE_ID) { - LOG_TRACE(INFO, "ESM-FSM - Stop retransmission timer %d", - ctx->timer.id); - ctx->timer.id = nas_timer_stop(ctx->timer.id); + LOG_TRACE(INFO, "ESM-FSM - Stop retransmission timer %d", + ctx->timer.id); + ctx->timer.id = nas_timer_stop(ctx->timer.id); } /* Release the retransmisison timer parameters */ if (ctx->args) { - if (ctx->args->msg.length > 0) { - free(ctx->args->msg.value); - } - free(ctx->args); - ctx->args = NULL; + if (ctx->args->msg.length > 0) { + free(ctx->args->msg.value); + } + free(ctx->args); + ctx->args = NULL; } LOG_FUNC_RETURN (RETURNok); @@ -468,20 +464,20 @@ int esm_ebr_stop_timer( unsigned int ueid, int ebi) /**************************************************************************** ** ** - ** Name: esm_ebr_get_pending_ebi() ** + ** Name: esm_ebr_get_pending_ebi() ** ** ** ** Description: Returns the EPS bearer identity assigned to the first EPS ** - ** bearer context entry which is pending in the given state ** + ** bearer context entry which is pending in the given state ** ** ** - ** Inputs: ueid: Lower layers UE identifier ** - ** status: The EPS bearer context status ** - ** Others: _esm_ebr_data ** + ** Inputs: ueid: Lower layers UE identifier ** + ** status: The EPS bearer context status ** + ** Others: _esm_ebr_data ** ** ** - ** Outputs: None ** - ** Return: The EPS bearer identity of the EPS bearer ** - ** context entry if it exists; ** - ** the not assigned EBI (0) otherwise. ** - ** Others: None ** + ** Outputs: None ** + ** Return: The EPS bearer identity of the EPS bearer ** + ** context entry if it exists; ** + ** the not assigned EBI (0) otherwise. ** + ** Others: None ** ** ** ***************************************************************************/ int esm_ebr_get_pending_ebi(unsigned int ueid, esm_ebr_state status) @@ -490,14 +486,18 @@ 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; - /* EPS bearer context entry found */ - break; + 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; } if (i < ESM_EBR_DATA_SIZE) { - LOG_FUNC_RETURN (_esm_ebr_data[ueid].context[i]->ebi); + LOG_FUNC_RETURN (_esm_ebr_data[ueid].context[i]->ebi); } /* EPS bearer context entry not found */ LOG_FUNC_RETURN (ESM_EBI_UNASSIGNED); @@ -506,29 +506,29 @@ int esm_ebr_get_pending_ebi(unsigned int ueid, esm_ebr_state status) /**************************************************************************** ** ** - ** Name: esm_ebr_set_status() ** + ** Name: esm_ebr_set_status() ** ** ** ** Description: Set the status of the specified EPS bearer context to the ** - ** given state ** + ** given state ** ** ** - ** Inputs: ueid: Lower layers UE identifier ** - ** ebi: The identity of the EPS bearer ** - ** status: The new EPS bearer context status ** - ** ue_requested: TRUE/FALSE if the modification of the EPS ** - ** bearer context status was requested by the ** - ** UE/network ** - ** Others: None ** + ** Inputs: ueid: Lower layers UE identifier ** + ** ebi: The identity of the EPS bearer ** + ** status: The new EPS bearer context status ** + ** ue_requested: TRUE/FALSE if the modification of the EPS ** + ** bearer context status was requested by the ** + ** UE/network ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: _esm_ebr_data ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: _esm_ebr_data ** ** ** ***************************************************************************/ int esm_ebr_set_status( #ifdef NAS_MME - unsigned int ueid, + unsigned int ueid, #endif - int ebi, esm_ebr_state status, int ue_requested) + int ebi, esm_ebr_state status, int ue_requested) { LOG_FUNC_IN; @@ -539,37 +539,37 @@ int esm_ebr_set_status( #endif if (ueid >= ESM_EBR_NB_UE_MAX) { - LOG_FUNC_RETURN (RETURNerror); + LOG_FUNC_RETURN (RETURNerror); } if ( (ebi < ESM_EBI_MIN) || (ebi > ESM_EBI_MAX) ) { - LOG_FUNC_RETURN (RETURNerror); + LOG_FUNC_RETURN (RETURNerror); } /* 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 " - "(ebi=%d)", ebi); - LOG_FUNC_RETURN (RETURNerror); + /* EPS bearer context not assigned */ + LOG_TRACE(ERROR, "ESM-FSM - EPS bearer context not assigned " + "(ebi=%d)", ebi); + LOG_FUNC_RETURN (RETURNerror); } old_status = ctx->status; if (status < ESM_EBR_STATE_MAX) { - LOG_TRACE(INFO, "ESM-FSM - Status of EPS bearer context %d changed:" - " %s ===> %s", ebi, - _esm_ebr_state_str[old_status], _esm_ebr_state_str[status]); - if (status != old_status) { - ctx->status = status; + LOG_TRACE(INFO, "ESM-FSM - Status of EPS bearer context %d changed:" + " %s ===> %s", ebi, + _esm_ebr_state_str[old_status], _esm_ebr_state_str[status]); + if (status != old_status) { + ctx->status = status; #ifdef NAS_UE - /* - * Notify the user that the state of the EPS bearer has changed - */ - (*_esm_ebr_callback)(ctx->cid, - _esm_ebr_pdn_state[ue_requested][ctx->is_default_ebr][status]); + /* + * Notify the user that the state of the EPS bearer has changed + */ + (*_esm_ebr_callback)(ctx->cid, + _esm_ebr_pdn_state[ue_requested][ctx->is_default_ebr][status]); #endif - LOG_FUNC_RETURN (RETURNok); - } + LOG_FUNC_RETURN (RETURNok); + } } LOG_FUNC_RETURN (RETURNerror); @@ -577,58 +577,58 @@ int esm_ebr_set_status( /**************************************************************************** ** ** - ** Name: esm_ebr_get_status() ** + ** Name: esm_ebr_get_status() ** ** ** ** Description: Get the current status value of the specified EPS bearer ** - ** context ** + ** context ** ** ** - ** Inputs: ueid: Lower layers UE identifier ** - ** ebi: The identity of the EPS bearer ** - ** Others: _esm_ebr_data ** + ** Inputs: ueid: Lower layers UE identifier ** + ** ebi: The identity of the EPS bearer ** + ** Others: _esm_ebr_data ** ** ** - ** Outputs: None ** - ** Return: The current value of the EPS bearer con- ** - ** text status ** - ** Others: None ** + ** Outputs: None ** + ** Return: The current value of the EPS bearer con- ** + ** text status ** + ** Others: None ** ** ** ***************************************************************************/ esm_ebr_state esm_ebr_get_status( #ifdef NAS_MME - unsigned int ueid, + unsigned int ueid, #endif - int ebi) + int ebi) { #ifdef NAS_UE unsigned int ueid = 0; #endif if ( (ebi < ESM_EBI_MIN) || (ebi > ESM_EBI_MAX) ) { - return (ESM_EBR_INACTIVE); + return (ESM_EBR_INACTIVE); } if (_esm_ebr_data[ueid].context[ebi - ESM_EBI_MIN] == NULL) { - /* EPS bearer context not allocated */ - return (ESM_EBR_INACTIVE); + /* EPS bearer context not allocated */ + return (ESM_EBR_INACTIVE); } if (_esm_ebr_data[ueid].context[ebi - ESM_EBI_MIN]->ebi != ebi) { - /* EPS bearer context not assigned */ - return (ESM_EBR_INACTIVE); + /* EPS bearer context not assigned */ + return (ESM_EBR_INACTIVE); } return (_esm_ebr_data[ueid].context[ebi - ESM_EBI_MIN]->status); } /**************************************************************************** ** ** - ** Name: esm_ebr_is_reserved() ** + ** Name: esm_ebr_is_reserved() ** ** ** ** Description: Check whether the given EPS bearer identity is a reserved ** - ** value ** + ** value ** ** ** - ** Inputs: ebi: The identity of the EPS bearer ** - ** Others: None ** + ** Inputs: ebi: The identity of the EPS bearer ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: TRUE, FALSE ** - ** Others: None ** + ** Outputs: None ** + ** Return: TRUE, FALSE ** + ** Others: None ** ** ** ***************************************************************************/ int esm_ebr_is_reserved(int ebi) @@ -638,33 +638,33 @@ int esm_ebr_is_reserved(int ebi) /**************************************************************************** ** ** - ** Name: esm_ebr_is_not_in_use() ** + ** Name: esm_ebr_is_not_in_use() ** ** ** ** Description: Check whether the given EPS bearer identity does not ** - ** match an assigned EBI value currently in use ** + ** match an assigned EBI value currently in use ** ** ** - ** Inputs: ueid: Lower layers UE identifier ** - ** ebi: The identity of the EPS bearer ** - ** Others: _esm_ebr_data ** + ** Inputs: ueid: Lower layers UE identifier ** + ** ebi: The identity of the EPS bearer ** + ** Others: _esm_ebr_data ** ** ** - ** Outputs: None ** - ** Return: TRUE, FALSE ** - ** Others: None ** + ** Outputs: None ** + ** Return: TRUE, FALSE ** + ** Others: None ** ** ** ***************************************************************************/ int esm_ebr_is_not_in_use( #ifdef NAS_MME - unsigned int ueid, + unsigned int ueid, #endif - int ebi) + int ebi) { #ifdef NAS_UE unsigned int ueid = 0; #endif return ( (ebi == ESM_EBI_UNASSIGNED) || - (_esm_ebr_data[ueid].context[ebi - ESM_EBI_MIN] == NULL) || - (_esm_ebr_data[ueid].context[ebi - ESM_EBI_MIN]->ebi) != ebi); + (_esm_ebr_data[ueid].context[ebi - ESM_EBI_MIN] == NULL) || + (_esm_ebr_data[ueid].context[ebi - ESM_EBI_MIN]->ebi) != ebi); } /****************************************************************************/ @@ -673,32 +673,36 @@ int esm_ebr_is_not_in_use( /**************************************************************************** ** ** - ** Name: _esm_ebr_get_available_entry() ** + ** Name: _esm_ebr_get_available_entry() ** ** ** ** Description: Returns the index of the next available entry in the list ** - ** of EPS bearer context data ** + ** of EPS bearer context data ** ** ** - ** Inputs: ueid: Lower layers UE identifier ** - ** Others: _esm_ebr_data ** + ** Inputs: ueid: Lower layers UE identifier ** + ** Others: _esm_ebr_data ** ** ** - ** Outputs: None ** - ** Return: The index of the next available EPS bearer ** - ** context data entry; -1 if no any entry is ** - ** available. ** - ** Others: None ** + ** Outputs: None ** + ** Return: The index of the next available EPS bearer ** + ** context data entry; -1 if no any entry is ** + ** available. ** + ** Others: None ** ** ** ***************************************************************************/ 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; - return i; + 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; - return i; + if (_esm_ebr_data[ueid].context[i] != NULL) { + continue; + } + return i; } /* No available EBI entry found */ return (-1); - } +} diff --git a/openair-cn/NAS/EURECOM-NAS/src/esm/esm_ebr.h b/openair-cn/NAS/EURECOM-NAS/src/esm/esm_ebr.h index f3943c2b3a..2a17ad035a 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/esm/esm_ebr.h +++ b/openair-cn/NAS/EURECOM-NAS/src/esm/esm_ebr.h @@ -1,21 +1,21 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source esm_ebr.h +Source esm_ebr.h -Version 0.1 +Version 0.1 -Date 2013/01/29 +Date 2013/01/29 -Product NAS stack +Product NAS stack -Subsystem EPS Session Management +Subsystem EPS Session Management -Author Frederic Maurel +Author Frederic Maurel -Description Defines functions used to handle state of EPS bearer contexts - and manage ESM messages re-transmission. +Description Defines functions used to handle state of EPS bearer contexts + and manage ESM messages re-transmission. *****************************************************************************/ #ifndef __ESM_EBR_H__ @@ -35,7 +35,7 @@ Description Defines functions used to handle state of EPS bearer contexts /****************************************************************************/ /* Unassigned EPS bearer identity value */ -#define ESM_EBI_UNASSIGNED (EPS_BEARER_IDENTITY_UNASSIGNED) +#define ESM_EBI_UNASSIGNED (EPS_BEARER_IDENTITY_UNASSIGNED) /****************************************************************************/ /************************ G L O B A L T Y P E S ************************/ @@ -43,16 +43,16 @@ Description Defines functions used to handle state of EPS bearer contexts /* EPS bearer context states */ typedef enum { - ESM_EBR_INACTIVE, /* No EPS bearer context exists */ - ESM_EBR_ACTIVE, /* The EPS bearer context is active, - * in the UE, in the network */ + ESM_EBR_INACTIVE, /* No EPS bearer context exists */ + ESM_EBR_ACTIVE, /* The EPS bearer context is active, + * in the UE, in the network */ #ifdef NAS_MME - ESM_EBR_INACTIVE_PENDING, /* The network has initiated an EPS bearer - * context deactivation towards the UE */ - ESM_EBR_MODIFY_PENDING, /* The network has initiated an EPS bearer - * context modification towards the UE */ - ESM_EBR_ACTIVE_PENDING, /* The network has initiated an EPS bearer - * context activation towards the UE */ + ESM_EBR_INACTIVE_PENDING, /* The network has initiated an EPS bearer + * context deactivation towards the UE */ + ESM_EBR_MODIFY_PENDING, /* The network has initiated an EPS bearer + * context modification towards the UE */ + ESM_EBR_ACTIVE_PENDING, /* The network has initiated an EPS bearer + * context activation towards the UE */ #endif ESM_EBR_STATE_MAX } esm_ebr_state; @@ -60,10 +60,10 @@ typedef enum { #ifdef NAS_MME /* ESM message timer retransmission data */ typedef struct { - unsigned int ueid; /* Lower layers UE identifier */ - unsigned int ebi; /* EPS bearer identity */ - unsigned int count; /* Retransmission counter */ - OctetString msg; /* Encoded ESM message to re-transmit */ + unsigned int ueid; /* Lower layers UE identifier */ + unsigned int ebi; /* EPS bearer identity */ + unsigned int count; /* Retransmission counter */ + OctetString msg; /* Encoded ESM message to re-transmit */ } esm_ebr_timer_data_t; #endif @@ -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); diff --git a/openair-cn/NAS/EURECOM-NAS/src/esm/esm_ebr_context.c b/openair-cn/NAS/EURECOM-NAS/src/esm/esm_ebr_context.c index 500bb1e04a..f78572c57a 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/esm/esm_ebr_context.c +++ b/openair-cn/NAS/EURECOM-NAS/src/esm/esm_ebr_context.c @@ -1,20 +1,20 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source esm_ebr_context.h +Source esm_ebr_context.h -Version 0.1 +Version 0.1 -Date 2013/05/28 +Date 2013/05/28 -Product NAS stack +Product NAS stack -Subsystem EPS Session Management +Subsystem EPS Session Management -Author Frederic Maurel +Author Frederic Maurel -Description Defines functions used to handle EPS bearer contexts. +Description Defines functions used to handle EPS bearer contexts. *****************************************************************************/ @@ -27,8 +27,8 @@ Description Defines functions used to handle EPS bearer contexts. #include "emm_sap.h" -#include <stdlib.h> // malloc, free -#include <string.h> // memset +#include <stdlib.h> // malloc, free +#include <string.h> // memset /****************************************************************************/ /**************** E X T E R N A L D E F I N I T I O N S ****************/ @@ -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 /****************************************************************************/ @@ -49,139 +51,137 @@ static int _esm_ebr_context_check_precedence(const network_tft_t*, const network /**************************************************************************** ** ** - ** Name: esm_ebr_context_create() ** + ** Name: esm_ebr_context_create() ** ** ** ** Description: Creates a new EPS bearer context to the PDN with the spe- ** - ** cified PDN connection identifier ** + ** cified PDN connection identifier ** ** ** - ** Inputs: ueid: UE identifier ** - ** pid: PDN connection identifier ** - ** ebi: EPS bearer identity ** - ** is_default: TRUE if the new bearer is a default EPS ** - ** bearer context ** - ** esm_qos: EPS bearer level QoS parameters ** - ** tft: Traffic flow template parameters ** - ** Others: _esm_data ** + ** Inputs: ueid: UE identifier ** + ** pid: PDN connection identifier ** + ** ebi: EPS bearer identity ** + ** is_default: TRUE if the new bearer is a default EPS ** + ** bearer context ** + ** esm_qos: EPS bearer level QoS parameters ** + ** tft: Traffic flow template parameters ** + ** Others: _esm_data ** ** ** - ** Outputs: None ** - ** Return: The EPS bearer identity of the default EPS ** - ** bearer associated to the new EPS bearer ** - ** context if successfully created; ** - ** UNASSIGN EPS bearer value otherwise. ** - ** Others: _esm_data ** + ** Outputs: None ** + ** Return: The EPS bearer identity of the default EPS ** + ** bearer associated to the new EPS bearer ** + ** context if successfully created; ** + ** UNASSIGN EPS bearer value otherwise. ** + ** Others: _esm_data ** ** ** ***************************************************************************/ int esm_ebr_context_create( #ifdef NAS_MME - unsigned int ueid, + unsigned int ueid, #endif - int pid, int ebi, int is_default, - const network_qos_t* qos, const network_tft_t* tft) + int pid, int ebi, int is_default, + 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; #endif #ifdef NAS_MME if (ueid < ESM_DATA_NB_UE_MAX) { - ctx = _esm_data.ctx[ueid]; + ctx = _esm_data.ctx[ueid]; } else { - LOG_FUNC_RETURN (ESM_EBI_UNASSIGNED); + LOG_FUNC_RETURN (ESM_EBI_UNASSIGNED); } #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)", - (is_default)? "default" : "dedicated", ebi, pid); + "for PDN connection (pid=%d)", + (is_default)? "default" : "dedicated", ebi, pid); if (pid < ESM_DATA_PDN_MAX) { - 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) { - LOG_TRACE(ERROR, "ESM-PROC - PDN connection %d has not been " - "allocated", pid); - } - /* Check the total number of active EPS bearers */ - 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 { - /* Get the PDN connection entry */ - pdn = ctx->pdn[pid].data; - if (is_default) { - /* Default EPS bearer entry is defined at index 0 */ - bid = 0; - if (pdn->bearer[bid] != NULL) { - LOG_TRACE(ERROR, "ESM-PROC - A default EPS bearer context " - "is already allocated"); - LOG_FUNC_RETURN (ESM_EBI_UNASSIGNED); - } - } - 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; - break; - } - } - } + 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) { + LOG_TRACE(ERROR, "ESM-PROC - PDN connection %d has not been " + "allocated", pid); + } + /* Check the total number of active EPS bearers */ + 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 { + /* Get the PDN connection entry */ + pdn = ctx->pdn[pid].data; + if (is_default) { + /* Default EPS bearer entry is defined at index 0 */ + bid = 0; + if (pdn->bearer[bid] != NULL) { + LOG_TRACE(ERROR, "ESM-PROC - A default EPS bearer context " + "is already allocated"); + LOG_FUNC_RETURN (ESM_EBI_UNASSIGNED); + } + } 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; + } + break; + } + } + } } if (bid < ESM_DATA_EPS_BEARER_MAX) { - /* Create new EPS bearer context */ - 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 */ - ctx->n_ebrs += 1; - /* Increment the number of EPS bearer for this PDN connection */ - pdn->n_bearers += 1; - /* Setup the EPS bearer data */ - pdn->bearer[bid] = ebr; - ebr->bid = bid; - ebr->ebi = ebi; - if (qos != NULL) { - /* EPS bearer level QoS parameters */ - ebr->qos = *qos; - } - if ( (tft != NULL) && (tft->n_pkfs < NET_PACKET_FILTER_MAX) ) { + /* Create new EPS bearer context */ + 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 */ + ctx->n_ebrs += 1; + /* Increment the number of EPS bearer for this PDN connection */ + pdn->n_bearers += 1; + /* Setup the EPS bearer data */ + pdn->bearer[bid] = ebr; + ebr->bid = bid; + ebr->ebi = ebi; + if (qos != NULL) { + /* EPS bearer level QoS parameters */ + ebr->qos = *qos; + } + if ( (tft != NULL) && (tft->n_pkfs < NET_PACKET_FILTER_MAX) ) { int i; - /* Traffic flow template parameters */ - for (i = 0; i < tft->n_pkfs; i++) - { - ebr->tft.pkf[i] = - (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; - } - } - } - - if (is_default) { - /* Set the PDN connection activation indicator */ - ctx->pdn[pid].is_active = TRUE; - /* Update the emergency bearer services indicator */ - if (pdn->is_emergency) { - ctx->emergency = TRUE; - } - } - - /* Return the EPS bearer identity of the default EPS bearer - * associated to the new EPS bearer context */ - LOG_FUNC_RETURN (pdn->bearer[0]->ebi); - } - LOG_TRACE(WARNING, "ESM-PROC - Failed to create new EPS bearer " - "context (ebi=%d)", ebi); + /* Traffic flow template parameters */ + for (i = 0; i < tft->n_pkfs; i++) { + ebr->tft.pkf[i] = + (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; + } + } + } + + if (is_default) { + /* Set the PDN connection activation indicator */ + ctx->pdn[pid].is_active = TRUE; + /* Update the emergency bearer services indicator */ + if (pdn->is_emergency) { + ctx->emergency = TRUE; + } + } + + /* Return the EPS bearer identity of the default EPS bearer + * associated to the new EPS bearer context */ + LOG_FUNC_RETURN (pdn->bearer[0]->ebi); + } + LOG_TRACE(WARNING, "ESM-PROC - Failed to create new EPS bearer " + "context (ebi=%d)", ebi); } LOG_FUNC_RETURN (ESM_EBI_UNASSIGNED); @@ -189,218 +189,220 @@ int esm_ebr_context_create( /**************************************************************************** ** ** - ** Name: esm_ebr_context_release() ** + ** Name: esm_ebr_context_release() ** ** ** ** Description: Releases EPS bearer context entry previously allocated ** - ** to the EPS bearer with the specified EPS bearer identity ** + ** to the EPS bearer with the specified EPS bearer identity ** ** ** - ** Inputs: ueid: UE identifier ** - ** ebi: EPS bearer identity ** - ** Others: _esm_data ** + ** Inputs: ueid: UE identifier ** + ** ebi: EPS bearer identity ** + ** Others: _esm_data ** ** ** - ** Outputs: pid: Identifier of the PDN connection entry the ** - ** EPS bearer context belongs to ** - ** bid: Identifier of the released EPS bearer con- ** - ** text entry ** - ** Return: The EPS bearer identity associated to the ** - ** EPS bearer context if successfully relea- ** - ** sed; UNASSIGN EPS bearer value otherwise. ** - ** Others: _esm_data ** + ** Outputs: pid: Identifier of the PDN connection entry the ** + ** EPS bearer context belongs to ** + ** bid: Identifier of the released EPS bearer con- ** + ** text entry ** + ** Return: The EPS bearer identity associated to the ** + ** EPS bearer context if successfully relea- ** + ** sed; UNASSIGN EPS bearer value otherwise. ** + ** Others: _esm_data ** ** ** ***************************************************************************/ int esm_ebr_context_release( #ifdef NAS_MME - unsigned int ueid, + 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; #endif #ifdef NAS_MME if (ueid < ESM_DATA_NB_UE_MAX) { - ctx = _esm_data.ctx[ueid]; + ctx = _esm_data.ctx[ueid]; } else { - LOG_FUNC_RETURN (ESM_EBI_UNASSIGNED); + LOG_FUNC_RETURN (ESM_EBI_UNASSIGNED); } #endif int found = FALSE; - esm_pdn_t* pdn = NULL; + esm_pdn_t *pdn = NULL; if (ebi != ESM_EBI_UNASSIGNED) { - /* - * The identity of the EPS bearer to released is given; - * Release the EPS bearer context entry that match the specified EPS - * bearer identity - */ - - /* Search for active PDN connection */ - for (*pid = 0; *pid < ESM_DATA_PDN_MAX; (*pid)++) { - 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; - /* The EPS bearer context entry is found */ - found = TRUE; - break; - } - } - } - if (found) break; - } - } - else { - /* - * The identity of the EPS bearer to released is not given; - * Release the EPS bearer context entry allocated with the EPS - * bearer context identifier (bid) to establish connectivity to - * the PDN identified by the PDN connection identifier (pid). - * Default EPS bearer to a given PDN is always identified by the - * first EPS bearer context entry at index bid = 0 - */ - if (*pid < ESM_DATA_PDN_MAX) { - 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) { - LOG_TRACE(WARNING,"ESM-PROC - PDN connection %d is not active", - *pid); - } - else if (ctx->pdn[*pid].data == NULL) { - LOG_TRACE(ERROR, "ESM-PROC - PDN connection %d has not been " - "allocated", *pid); - } - else { - pdn = ctx->pdn[*pid].data; - if (pdn->bearer[*bid] != NULL) { - ebi = pdn->bearer[*bid]->ebi; - found = TRUE; - } - } - } + /* + * The identity of the EPS bearer to released is given; + * Release the EPS bearer context entry that match the specified EPS + * bearer identity + */ + + /* Search for active PDN connection */ + for (*pid = 0; *pid < ESM_DATA_PDN_MAX; (*pid)++) { + 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; + } + /* The EPS bearer context entry is found */ + found = TRUE; + break; + } + } + } + if (found) { + break; + } + } + } else { + /* + * The identity of the EPS bearer to released is not given; + * Release the EPS bearer context entry allocated with the EPS + * bearer context identifier (bid) to establish connectivity to + * the PDN identified by the PDN connection identifier (pid). + * Default EPS bearer to a given PDN is always identified by the + * first EPS bearer context entry at index bid = 0 + */ + if (*pid < ESM_DATA_PDN_MAX) { + 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) { + LOG_TRACE(WARNING,"ESM-PROC - PDN connection %d is not active", + *pid); + } else if (ctx->pdn[*pid].data == NULL) { + LOG_TRACE(ERROR, "ESM-PROC - PDN connection %d has not been " + "allocated", *pid); + } else { + pdn = ctx->pdn[*pid].data; + if (pdn->bearer[*bid] != NULL) { + ebi = pdn->bearer[*bid]->ebi; + found = TRUE; + } + } + } } if (found) { int i, j; - /* - * Delete the specified EPS bearer context entry - */ - if (pdn->bearer[*bid]->bid != *bid) { - LOG_TRACE(ERROR, "ESM-PROC - EPS bearer identifier %d is " - "not valid", *bid); - LOG_FUNC_RETURN (ESM_EBI_UNASSIGNED); - } - - LOG_TRACE(WARNING, "ESM-PROC - Release EPS bearer context " - "(ebi=%d)", ebi); - - /* Delete the TFT */ - for (i = 0; i < pdn->bearer[*bid]->tft.n_pkfs; i++) { - free(pdn->bearer[*bid]->tft.pkf[i]); - } - /* Release the specified EPS bearer data */ - free(pdn->bearer[*bid]); - pdn->bearer[*bid] = NULL; - /* Decrement the number of EPS bearer context allocated - * to the PDN connection */ - pdn->n_bearers -= 1; - /* Decrement the total number of active EPS bearers */ - ctx->n_ebrs -= 1; - - if (*bid == 0) { - /* 3GPP TS 24.301, section 6.4.4.3, 6.4.4.6 - * If the EPS bearer identity is that of the default bearer to a - * PDN, the UE shall delete all EPS bearer contexts associated to - * that PDN connection. - */ - for (i = 1; pdn->n_bearers > 0; i++) { - if (pdn->bearer[i]) { - - LOG_TRACE(WARNING, "ESM-PROC - Release EPS bearer context " - "(ebi=%d)", pdn->bearer[i]->ebi); - - /* Delete the TFT */ - for (j = 0; j < pdn->bearer[i]->tft.n_pkfs; j++) { - free(pdn->bearer[i]->tft.pkf[j]); - } - /* Set the EPS bearer context state to INACTIVE */ + /* + * Delete the specified EPS bearer context entry + */ + if (pdn->bearer[*bid]->bid != *bid) { + LOG_TRACE(ERROR, "ESM-PROC - EPS bearer identifier %d is " + "not valid", *bid); + LOG_FUNC_RETURN (ESM_EBI_UNASSIGNED); + } + + LOG_TRACE(WARNING, "ESM-PROC - Release EPS bearer context " + "(ebi=%d)", ebi); + + /* Delete the TFT */ + for (i = 0; i < pdn->bearer[*bid]->tft.n_pkfs; i++) { + free(pdn->bearer[*bid]->tft.pkf[i]); + } + /* Release the specified EPS bearer data */ + free(pdn->bearer[*bid]); + pdn->bearer[*bid] = NULL; + /* Decrement the number of EPS bearer context allocated + * to the PDN connection */ + pdn->n_bearers -= 1; + /* Decrement the total number of active EPS bearers */ + ctx->n_ebrs -= 1; + + if (*bid == 0) { + /* 3GPP TS 24.301, section 6.4.4.3, 6.4.4.6 + * If the EPS bearer identity is that of the default bearer to a + * PDN, the UE shall delete all EPS bearer contexts associated to + * that PDN connection. + */ + for (i = 1; pdn->n_bearers > 0; i++) { + if (pdn->bearer[i]) { + + LOG_TRACE(WARNING, "ESM-PROC - Release EPS bearer context " + "(ebi=%d)", pdn->bearer[i]->ebi); + + /* Delete the TFT */ + for (j = 0; j < pdn->bearer[i]->tft.n_pkfs; j++) { + free(pdn->bearer[i]->tft.pkf[j]); + } + /* Set the EPS bearer context state to INACTIVE */ #ifdef NAS_UE - (void) esm_ebr_set_status(pdn->bearer[i]->ebi, - ESM_EBR_INACTIVE, TRUE); + (void) esm_ebr_set_status(pdn->bearer[i]->ebi, + ESM_EBR_INACTIVE, TRUE); #endif #ifdef NAS_MME - (void) esm_ebr_set_status(ueid, pdn->bearer[i]->ebi, - ESM_EBR_INACTIVE, TRUE); + (void) esm_ebr_set_status(ueid, pdn->bearer[i]->ebi, + ESM_EBR_INACTIVE, TRUE); #endif - /* Release EPS bearer data */ + /* Release EPS bearer data */ #ifdef NAS_UE - (void) esm_ebr_release(pdn->bearer[i]->ebi); + (void) esm_ebr_release(pdn->bearer[i]->ebi); #endif #ifdef NAS_MME - (void) esm_ebr_release(ueid, pdn->bearer[i]->ebi); + (void) esm_ebr_release(ueid, pdn->bearer[i]->ebi); #endif - // esm_ebr_release() - /* Release dedicated EPS bearer data */ - free(pdn->bearer[i]); - pdn->bearer[i] = NULL; - /* Decrement the number of EPS bearer context allocated - * to the PDN connection */ - pdn->n_bearers -= 1; - /* Decrement the total number of active EPS bearers */ - ctx->n_ebrs -= 1; - } - } - /* Reset the PDN connection activation indicator */ - ctx->pdn[*pid].is_active = FALSE; - /* Update the emergency bearer services indicator */ - if (pdn->is_emergency) { - ctx->emergency = FALSE; - } - } + // esm_ebr_release() + /* Release dedicated EPS bearer data */ + free(pdn->bearer[i]); + pdn->bearer[i] = NULL; + /* Decrement the number of EPS bearer context allocated + * to the PDN connection */ + pdn->n_bearers -= 1; + /* Decrement the total number of active EPS bearers */ + ctx->n_ebrs -= 1; + } + } + /* Reset the PDN connection activation indicator */ + ctx->pdn[*pid].is_active = FALSE; + /* Update the emergency bearer services indicator */ + if (pdn->is_emergency) { + ctx->emergency = FALSE; + } + } #ifdef NAS_UE - /* 3GPP TS 24.301, section 6.4.4.6 - * If the UE locally deactivated all EPS bearer contexts, the UE - * shall perform a local detach and enter state EMM-DEREGISTERED. - */ - if (ctx->n_ebrs == 0) { - emm_sap_t emm_sap; - emm_sap.primitive = EMMESM_ESTABLISH_CNF; - emm_sap.u.emm_esm.u.establish.is_attached = FALSE; - (void) emm_sap_send(&emm_sap); - } - /* 3GPP TS 24.301, section 6.4.4.3, 6.4.4.6 - * If due to the EPS bearer context deactivation only the PDN - * connection for emergency bearer services remains established, - * the UE shall consider itself attached for emergency bearer - * services only. - */ - else if ( ctx->emergency && (ctx->n_ebrs == 1) ) { - emm_sap_t emm_sap; - emm_sap.primitive = EMMESM_ESTABLISH_CNF; - emm_sap.u.emm_esm.u.establish.is_attached = TRUE; - emm_sap.u.emm_esm.u.establish.is_emergency = TRUE; - (void) emm_sap_send(&emm_sap); - } + /* 3GPP TS 24.301, section 6.4.4.6 + * If the UE locally deactivated all EPS bearer contexts, the UE + * shall perform a local detach and enter state EMM-DEREGISTERED. + */ + if (ctx->n_ebrs == 0) { + emm_sap_t emm_sap; + emm_sap.primitive = EMMESM_ESTABLISH_CNF; + emm_sap.u.emm_esm.u.establish.is_attached = FALSE; + (void) emm_sap_send(&emm_sap); + } + /* 3GPP TS 24.301, section 6.4.4.3, 6.4.4.6 + * If due to the EPS bearer context deactivation only the PDN + * connection for emergency bearer services remains established, + * the UE shall consider itself attached for emergency bearer + * services only. + */ + else if ( ctx->emergency && (ctx->n_ebrs == 1) ) { + emm_sap_t emm_sap; + emm_sap.primitive = EMMESM_ESTABLISH_CNF; + emm_sap.u.emm_esm.u.establish.is_attached = TRUE; + emm_sap.u.emm_esm.u.establish.is_emergency = TRUE; + (void) emm_sap_send(&emm_sap); + } #endif // NAS_UE #ifdef NAS_MME - if (ctx->n_ebrs == 0) { - /* TODO: Release the PDN connection and marked the UE as inactive - * in the network for EPS services (is_attached = FALSE) */ - } + if (ctx->n_ebrs == 0) { + /* TODO: Release the PDN connection and marked the UE as inactive + * in the network for EPS services (is_attached = FALSE) */ + } #endif - LOG_FUNC_RETURN (ebi); + LOG_FUNC_RETURN (ebi); } LOG_FUNC_RETURN (ESM_EBI_UNASSIGNED); @@ -409,21 +411,21 @@ int esm_ebr_context_release( #ifdef NAS_UE /**************************************************************************** ** ** - ** Name: esm_ebr_context_get_pid() ** + ** Name: esm_ebr_context_get_pid() ** ** ** ** Description: Returns the identifier of the PDN connection entry the ** - ** default EPS bearer context with the specified EPS bearer ** - ** identity belongs to ** + ** default EPS bearer context with the specified EPS bearer ** + ** identity belongs to ** ** ** - ** Inputs: ebi: The EPS bearer identity of the default EPS ** - ** bearer context ** - ** Others: _esm_data ** + ** Inputs: ebi: The EPS bearer identity of the default EPS ** + ** bearer context ** + ** Others: _esm_data ** ** ** - ** Outputs: None ** - ** Return: The identifier of the PDN connection entry ** - ** associated to the specified default EPS ** - ** bearer context if it exists; -1 otherwise. ** - ** Others: None ** + ** Outputs: None ** + ** Return: The identifier of the PDN connection entry ** + ** associated to the specified default EPS ** + ** bearer context if it exists; -1 otherwise. ** + ** Others: None ** ** ** ***************************************************************************/ int esm_ebr_context_get_pid(int ebi) @@ -433,75 +435,83 @@ 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) { - LOG_FUNC_RETURN (pid); + LOG_FUNC_RETURN (pid); } - LOG_FUNC_RETURN (-1); + LOG_FUNC_RETURN (-1); } /**************************************************************************** ** ** - ** Name: esm_ebr_context_check_tft() ** + ** Name: esm_ebr_context_check_tft() ** ** ** ** Description: Checks syntactical errors in packet filters associated to ** - ** the EPS bearer context with the specified EPS bearer ** - ** identity for the PDN connection entry with the given ** - ** identifier ** + ** the EPS bearer context with the specified EPS bearer ** + ** identity for the PDN connection entry with the given ** + ** identifier ** ** ** - ** Inputs: pid: Identifier of the PDN connection entry the ** - ** EPS bearer context belongs to ** - ** ebi: The EPS bearer identity of the EPS bearer ** - ** context with associated packet filter list ** - ** tft: The traffic flow template (set of packet ** - ** filters) to be checked ** - ** operation: Traffic flow template operation ** - ** Others: _esm_data ** + ** Inputs: pid: Identifier of the PDN connection entry the ** + ** EPS bearer context belongs to ** + ** ebi: The EPS bearer identity of the EPS bearer ** + ** context with associated packet filter list ** + ** tft: The traffic flow template (set of packet ** + ** filters) to be checked ** + ** operation: Traffic flow template operation ** + ** Others: _esm_data ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ int esm_ebr_context_check_tft(int pid, int ebi, - const network_tft_t* tft, - esm_ebr_context_tft_t operation) + const network_tft_t *tft, + esm_ebr_context_tft_t operation) { LOG_FUNC_IN; int rc = RETURNerror; if (pid < ESM_DATA_PDN_MAX) { - 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) { - 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; - /* For each EPS bearer context associated to the PDN connection */ - for (int i = 0; i < pdn->n_bearers; i++) { - if (pdn->bearer[i]) { - if (pdn->bearer[i]->ebi == ebi) { - /* Check the packet filter identifiers */ - rc = _esm_ebr_context_check_identifiers(tft, - &pdn->bearer[i]->tft); - 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 (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) { + 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; + /* For each EPS bearer context associated to the PDN connection */ + for (int i = 0; i < pdn->n_bearers; i++) { + if (pdn->bearer[i]) { + if (pdn->bearer[i]->ebi == ebi) { + /* Check the packet filter identifiers */ + rc = _esm_ebr_context_check_identifiers(tft, + &pdn->bearer[i]->tft); + 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; + } + } + } + } } LOG_FUNC_RETURN (rc); @@ -515,78 +525,78 @@ int esm_ebr_context_check_tft(int pid, int ebi, #ifdef NAS_UE /**************************************************************************** ** ** - ** Name: _esm_ebr_context_check_identifiers() ** + ** Name: _esm_ebr_context_check_identifiers() ** ** ** ** Description: Compares traffic flow templates to check whether two or ** - ** more packet filters have identical packet filter identi- ** - ** fiers ** + ** more packet filters have identical packet filter identi- ** + ** fiers ** ** ** - ** Inputs: tft1: The first set of packet filters ** - ** tft2: The second set of packet filters ** - ** Others: None ** + ** Inputs: tft1: The first set of packet filters ** + ** tft2: The second set of packet filters ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNerror if at least one packet filter ** - ** has same identifier in both traffic flow ** - ** templates; RETURNok otherwise. ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNerror if at least one packet filter ** + ** has same identifier in both traffic flow ** + ** templates; RETURNok otherwise. ** + ** 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); + return (RETURNok); } for (int i = 0; i < tft1->n_pkfs; i++) { - for (int j = 0; j < tft2->n_pkfs; j++) { - /* Packet filters should have been allocated */ - if (tft1->pkf[i]->id == tft2->pkf[i]->id) { - /* 3GPP TS 24.301, section 6.4.2.5, abnormal cases d.1 - * Packet filters have same identifier */ - return (RETURNerror); - } - } + for (int j = 0; j < tft2->n_pkfs; j++) { + /* Packet filters should have been allocated */ + if (tft1->pkf[i]->id == tft2->pkf[i]->id) { + /* 3GPP TS 24.301, section 6.4.2.5, abnormal cases d.1 + * Packet filters have same identifier */ + return (RETURNerror); + } + } } return (RETURNok); } /**************************************************************************** ** ** - ** Name: _esm_ebr_context_check_precedence() ** + ** Name: _esm_ebr_context_check_precedence() ** ** ** ** Description: Compares traffic flow templates to check whether two or ** - ** more packet filters have identical precedence values ** + ** more packet filters have identical precedence values ** ** ** - ** Inputs: tft1: The first set of packet filters ** - ** tft2: The second set of packet filters ** - ** Others: None ** + ** Inputs: tft1: The first set of packet filters ** + ** tft2: The second set of packet filters ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNerror if at least one packet filter ** - ** has same precedence value in both traffic ** - ** flow templates; RETURNerror otherwise. ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNerror if at least one packet filter ** + ** has same precedence value in both traffic ** + ** flow templates; RETURNerror otherwise. ** + ** 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); + return (RETURNok); } for (int i = 0; i < tft1->n_pkfs; i++) { - for (int j = 0; j < tft2->n_pkfs; j++) { - /* Packet filters should have been allocated */ - if (tft1->pkf[i]->precedence == tft2->pkf[i]->precedence) { - /* 3GPP TS 24.301, section 6.4.2.5, abnormal cases d.2 - * Packet filters have same precedence value */ - /* TODO: Actually if the old packet filters do not belong - * to the default EPS bearer context, the UE shall not - * diagnose an error (see 6.4.2.5, abnormal cases d.2) */ - return (RETURNerror); - } - } + for (int j = 0; j < tft2->n_pkfs; j++) { + /* Packet filters should have been allocated */ + if (tft1->pkf[i]->precedence == tft2->pkf[i]->precedence) { + /* 3GPP TS 24.301, section 6.4.2.5, abnormal cases d.2 + * Packet filters have same precedence value */ + /* TODO: Actually if the old packet filters do not belong + * to the default EPS bearer context, the UE shall not + * diagnose an error (see 6.4.2.5, abnormal cases d.2) */ + return (RETURNerror); + } + } } return (RETURNok); } diff --git a/openair-cn/NAS/EURECOM-NAS/src/esm/esm_ebr_context.h b/openair-cn/NAS/EURECOM-NAS/src/esm/esm_ebr_context.h index 543335c8b5..d35ab470cd 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/esm/esm_ebr_context.h +++ b/openair-cn/NAS/EURECOM-NAS/src/esm/esm_ebr_context.h @@ -1,20 +1,20 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source esm_ebr_context.h +Source esm_ebr_context.h -Version 0.1 +Version 0.1 -Date 2013/05/28 +Date 2013/05/28 -Product NAS stack +Product NAS stack -Subsystem EPS Session Management +Subsystem EPS Session Management -Author Frederic Maurel +Author Frederic Maurel -Description Defines functions used to handle EPS bearer contexts. +Description Defines functions used to handle EPS bearer contexts. *****************************************************************************/ #ifndef __ESM_EBR_CONTEXT_H__ @@ -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__ */ diff --git a/openair-cn/NAS/EURECOM-NAS/src/esm/esm_ip.c b/openair-cn/NAS/EURECOM-NAS/src/esm/esm_ip.c index 1c158a8a6b..420d1c291c 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/esm/esm_ip.c +++ b/openair-cn/NAS/EURECOM-NAS/src/esm/esm_ip.c @@ -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", diff --git a/openair-cn/NAS/EURECOM-NAS/src/esm/esm_main.c b/openair-cn/NAS/EURECOM-NAS/src/esm/esm_main.c index 85b9e72d84..6ec1f8f448 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/esm/esm_main.c +++ b/openair-cn/NAS/EURECOM-NAS/src/esm/esm_main.c @@ -1,21 +1,21 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source esm_main.c +Source esm_main.c -Version 0.1 +Version 0.1 -Date 2012/12/04 +Date 2012/12/04 -Product NAS stack +Product NAS stack -Subsystem EPS Session Management +Subsystem EPS Session Management -Author Frederic Maurel +Author Frederic Maurel -Description Defines the EPS Session Management procedure call manager, - the main entry point for elementary ESM processing. +Description Defines the EPS Session Management procedure call manager, + the main entry point for elementary ESM processing. *****************************************************************************/ @@ -42,16 +42,16 @@ Description Defines the EPS Session Management procedure call manager, #ifdef NAS_UE /**************************************************************************** ** ** - ** Name: esm_main_initialize() ** + ** Name: esm_main_initialize() ** ** ** ** Description: Initializes ESM internal data ** ** ** - ** Inputs: cb: The user notification callback ** - ** Others: None ** + ** Inputs: cb: The user notification callback ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: None ** - ** Others: _esm_data ** + ** Outputs: None ** + ** Return: None ** + ** Others: _esm_data ** ** ** ***************************************************************************/ void esm_main_initialize(esm_indication_callback_t cb) @@ -63,9 +63,9 @@ void esm_main_initialize(esm_indication_callback_t cb) /* List of active PDN connections */ _esm_data.n_pdns = 0; for (int i = 0; i < ESM_DATA_PDN_MAX + 1; i++) { - _esm_data.pdn[i].pid = -1; - _esm_data.pdn[i].is_active = FALSE; - _esm_data.pdn[i].data = NULL; + _esm_data.pdn[i].pid = -1; + _esm_data.pdn[i].is_active = FALSE; + _esm_data.pdn[i].data = NULL; } /* Emergency bearer services indicator */ _esm_data.emergency = FALSE; @@ -82,16 +82,16 @@ void esm_main_initialize(esm_indication_callback_t cb) #ifdef NAS_MME /**************************************************************************** ** ** - ** Name: esm_main_initialize() ** + ** Name: esm_main_initialize() ** ** ** ** Description: Initializes ESM internal data ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: None ** - ** Others: None ** + ** Outputs: None ** + ** Return: None ** + ** Others: None ** ** ** ***************************************************************************/ void esm_main_initialize(void) @@ -102,12 +102,12 @@ void esm_main_initialize(void) /* Retreive MME supported configuration data */ if (mme_api_get_esm_config(&_esm_data.conf) != RETURNok) { - LOG_TRACE(ERROR, "ESM-MAIN - Failed to get MME configuration data"); + LOG_TRACE(ERROR, "ESM-MAIN - Failed to get MME configuration data"); } /* Initialize ESM contexts */ for (i = 0; i < ESM_DATA_NB_UE_MAX; i++) { - _esm_data.ctx[i] = NULL; + _esm_data.ctx[i] = NULL; } /* Initialize the EPS bearer context manager */ @@ -119,16 +119,16 @@ void esm_main_initialize(void) /**************************************************************************** ** ** - ** Name: esm_main_cleanup() ** + ** Name: esm_main_cleanup() ** ** ** ** Description: Performs the EPS Session Management clean up procedure ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: None ** - ** Others: None ** + ** Outputs: None ** + ** Return: None ** + ** Others: None ** ** ** ***************************************************************************/ void esm_main_cleanup(void) @@ -138,28 +138,28 @@ void esm_main_cleanup(void) #ifdef NAS_UE /* 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; - if (pdn->apn.length > 0) { - free(pdn->apn.value); - } - /* Release EPS bearer contexts */ - for (int bid = 0; bid < pdn->n_bearers; bid++) { - if (pdn->bearer[bid]) { - LOG_TRACE(WARNING, "ESM-MAIN - Release EPS bearer " - "context (ebi=%d)", pdn->bearer[bid]->ebi); - /* Delete the TFT */ - for (int i = 0; i < pdn->bearer[bid]->tft.n_pkfs; i++) { - if (pdn->bearer[bid]->tft.pkf[i]) { - free(pdn->bearer[bid]->tft.pkf[i]); - } - } - free(pdn->bearer[bid]); - } - } - /* Release the PDN connection */ - free(_esm_data.pdn[pid].data); - } + if (_esm_data.pdn[pid].data) { + esm_pdn_t *pdn = _esm_data.pdn[pid].data; + if (pdn->apn.length > 0) { + free(pdn->apn.value); + } + /* Release EPS bearer contexts */ + for (int bid = 0; bid < pdn->n_bearers; bid++) { + if (pdn->bearer[bid]) { + LOG_TRACE(WARNING, "ESM-MAIN - Release EPS bearer " + "context (ebi=%d)", pdn->bearer[bid]->ebi); + /* Delete the TFT */ + for (int i = 0; i < pdn->bearer[bid]->tft.n_pkfs; i++) { + if (pdn->bearer[bid]->tft.pkf[i]) { + free(pdn->bearer[bid]->tft.pkf[i]); + } + } + free(pdn->bearer[bid]); + } + } + /* Release the PDN connection */ + free(_esm_data.pdn[pid].data); + } } #endif @@ -169,18 +169,18 @@ void esm_main_cleanup(void) #ifdef NAS_UE /**************************************************************************** ** ** - ** Name: esm_main_get_nb_pdn_max() ** + ** Name: esm_main_get_nb_pdn_max() ** ** ** ** Description: Get the maximum number of PDN connections that may be in ** - ** a defined state at the same time ** + ** a defined state at the same time ** ** ** - ** Inputs: None ** - ** Others: _esm_data ** + ** Inputs: None ** + ** Others: _esm_data ** ** ** - ** Outputs: None ** - ** Return: The maximum number of PDN connections that ** - ** may be defined ** - ** Others: None ** + ** Outputs: None ** + ** Return: The maximum number of PDN connections that ** + ** may be defined ** + ** Others: None ** ** ** ***************************************************************************/ int esm_main_get_nb_pdns_max(void) @@ -192,16 +192,16 @@ int esm_main_get_nb_pdns_max(void) /**************************************************************************** ** ** - ** Name: esm_main_get_nb_pdns() ** + ** Name: esm_main_get_nb_pdns() ** ** ** ** Description: Get the number of active PDN connections ** ** ** - ** Inputs: None ** - ** Others: _esm_data ** + ** Inputs: None ** + ** Others: _esm_data ** ** ** - ** Outputs: None ** - ** Return: The number of active PDN connections ** - ** Others: None ** + ** Outputs: None ** + ** Return: The number of active PDN connections ** + ** Others: None ** ** ** ***************************************************************************/ int esm_main_get_nb_pdns(void) @@ -213,18 +213,18 @@ int esm_main_get_nb_pdns(void) /**************************************************************************** ** ** - ** Name: esm_main_has_emergency() ** + ** Name: esm_main_has_emergency() ** ** ** ** Description: Check whether a PDN connection for emergency bearer ser- ** - ** vices is established ** + ** vices is established ** ** ** - ** Inputs: None ** - ** Others: _esm_data ** + ** Inputs: None ** + ** Others: _esm_data ** ** ** - ** Outputs: None ** - ** Return: TRUE if a PDN connection for emergency ** - ** bearer services is established ** - ** Others: None ** + ** Outputs: None ** + ** Return: TRUE if a PDN connection for emergency ** + ** bearer services is established ** + ** Others: None ** ** ** ***************************************************************************/ int esm_main_has_emergency(void) @@ -236,46 +236,44 @@ int esm_main_has_emergency(void) /**************************************************************************** ** ** - ** Name: esm_main_get_pdn_status() ** + ** Name: esm_main_get_pdn_status() ** ** ** ** Description: Get the status of the specified PDN connection ** ** ** - ** Inputs: cid: PDN connection identifier ** - ** Others: _esm_data ** + ** Inputs: cid: PDN connection identifier ** + ** Others: _esm_data ** ** ** - ** Outputs: state: TRUE if the current state of the PDN con- ** - ** nection is ACTIVE; FALSE otherwise. ** - ** Return: TRUE if the specified PDN connection has a ** - ** PDN context defined; FALSE if no any PDN ** - ** context has been defined for the specified ** - ** connection. ** - ** Others: None ** + ** Outputs: state: TRUE if the current state of the PDN con- ** + ** nection is ACTIVE; FALSE otherwise. ** + ** Return: TRUE if the specified PDN connection has a ** + ** PDN context defined; FALSE if no any PDN ** + ** context has been defined for the specified ** + ** connection. ** + ** 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; unsigned int pid = cid - 1; if (pid >= ESM_DATA_PDN_MAX) { - return (FALSE); - } - 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) { - LOG_TRACE(ERROR, "ESM-MAIN - PDN connection %d has not been allocated", - cid); - return (FALSE); + return (FALSE); + } 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) { + LOG_TRACE(ERROR, "ESM-MAIN - PDN connection %d has not been allocated", + cid); + return (FALSE); } if (_esm_data.pdn[pid].data->bearer[0] != NULL) { - /* The status of a PDN connection is the status of the default EPS bearer - * that has been assigned to this PDN connection at activation time */ - int ebi = _esm_data.pdn[pid].data->bearer[0]->ebi; - *state = (esm_ebr_get_status(ebi) == ESM_EBR_ACTIVE); + /* The status of a PDN connection is the status of the default EPS bearer + * that has been assigned to this PDN connection at activation time */ + int ebi = _esm_data.pdn[pid].data->bearer[0]->ebi; + *state = (esm_ebr_get_status(ebi) == ESM_EBR_ACTIVE); } /* The PDN connection has not been activated yet */ LOG_FUNC_RETURN (TRUE); @@ -283,48 +281,46 @@ int esm_main_get_pdn_status(int cid, int* state) /**************************************************************************** ** ** - ** Name: esm_main_get_pdn() ** + ** Name: esm_main_get_pdn() ** ** ** ** Description: Get parameters defined for the specified PDN connection ** ** ** - ** Inputs: cid: PDN connection identifier ** - ** Others: _esm_data ** + ** Inputs: cid: PDN connection identifier ** + ** Others: _esm_data ** ** ** - ** Outputs: type: PDN connection type (IPv4, IPv6, IPv4v6) ** - ** apn: Access Point logical Name in used ** - ** is_emergency: Emergency bearer services indicator ** - ** is_active: Active PDN connection indicator ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: type: PDN connection type (IPv4, IPv6, IPv4v6) ** + ** apn: Access Point logical Name in used ** + ** is_emergency: Emergency bearer services indicator ** + ** is_active: Active PDN connection indicator ** + ** Return: RETURNok, RETURNerror ** + ** 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; unsigned int pid = cid - 1; if (pid >= ESM_DATA_PDN_MAX) { - return (RETURNerror); - } - 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) { - LOG_TRACE(ERROR, "ESM-MAIN - PDN connection %d has not been allocated", - cid); - return (RETURNerror); + return (RETURNerror); + } 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) { + LOG_TRACE(ERROR, "ESM-MAIN - PDN connection %d has not been allocated", + cid); + return (RETURNerror); } /* Get the PDN type */ *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; + *apn = NULL; } /* Get the emergency bearer services indicator */ *is_emergency = _esm_data.pdn[pid].data->is_emergency; @@ -336,55 +332,50 @@ int esm_main_get_pdn(int cid, int* type, const char** apn, /**************************************************************************** ** ** - ** Name: esm_main_get_pdn_addr() ** + ** Name: esm_main_get_pdn_addr() ** ** ** ** Description: Get IP address(es) assigned to the specified PDN connec- ** - ** tion ** + ** tion ** ** ** - ** Inputs: cid: PDN connection identifier ** - ** Others: _esm_data ** + ** Inputs: cid: PDN connection identifier ** + ** Others: _esm_data ** ** ** - ** Outputs: ipv4adddr: IPv4 address ** - ** ipv6adddr: IPv6 address ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: ipv4adddr: IPv4 address ** + ** ipv6adddr: IPv6 address ** + ** Return: RETURNok, RETURNerror ** + ** 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; unsigned int pid = cid - 1; if (pid >= ESM_DATA_PDN_MAX) { - return (RETURNerror); - } - 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) { - LOG_TRACE(ERROR, "ESM-MAIN - PDN connection %d has not been allocated", - cid); - return (RETURNerror); - } - else if (!_esm_data.pdn[pid].is_active) { - /* No any IP address has been assigned to this PDN connection */ - return (RETURNok); + return (RETURNerror); + } 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) { + LOG_TRACE(ERROR, "ESM-MAIN - PDN connection %d has not been allocated", + cid); + return (RETURNerror); + } else if (!_esm_data.pdn[pid].is_active) { + /* No any IP address has been assigned to this PDN connection */ + return (RETURNok); } 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) { - /* Get IPv6 address */ - *ipv6addr = _esm_data.pdn[pid].data->ip_addr; - } - 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; + /* Get IPv4 address */ + *ipv4addr = _esm_data.pdn[pid].data->ip_addr; + } else if (_esm_data.pdn[pid].data->type == NET_PDN_TYPE_IPV6) { + /* Get IPv6 address */ + *ipv6addr = _esm_data.pdn[pid].data->ip_addr; + } 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; } LOG_FUNC_RETURN (RETURNok); diff --git a/openair-cn/NAS/EURECOM-NAS/src/esm/esm_main.h b/openair-cn/NAS/EURECOM-NAS/src/esm/esm_main.h index 16c058cf04..b43cd7c2b2 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/esm/esm_main.h +++ b/openair-cn/NAS/EURECOM-NAS/src/esm/esm_main.h @@ -1,21 +1,21 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source esm_main.h +Source esm_main.h -Version 0.1 +Version 0.1 -Date 2012/12/04 +Date 2012/12/04 -Product NAS stack +Product NAS stack -Subsystem EPS Session Management +Subsystem EPS Session Management -Author Frederic Maurel +Author Frederic Maurel -Description Defines the EPS Session Management procedure call manager, - the main entry point for elementary ESM processing. +Description Defines the EPS Session Management procedure call manager, + the main entry point for elementary ESM processing. *****************************************************************************/ @@ -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 diff --git a/openair-cn/NAS/EURECOM-NAS/src/esm/esm_proc.h b/openair-cn/NAS/EURECOM-NAS/src/esm/esm_proc.h index f9c7dc181a..0865c1dc3f 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/esm/esm_proc.h +++ b/openair-cn/NAS/EURECOM-NAS/src/esm/esm_proc.h @@ -1,21 +1,21 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source esm_proc.h +Source esm_proc.h -Version 0.1 +Version 0.1 -Date 2013/01/02 +Date 2013/01/02 -Product NAS stack +Product NAS stack -Subsystem EPS Session Management +Subsystem EPS Session Management -Author Frederic Maurel +Author Frederic Maurel -Description Defines the EPS Session Management procedures executed at - the ESM Service Access Points. +Description Defines the EPS Session Management procedures executed at + the ESM Service Access Points. *****************************************************************************/ #ifndef __ESM_PROC_H__ @@ -33,13 +33,13 @@ Description Defines the EPS Session Management procedures executed at * ------------------------- */ #ifdef NAS_UE -#define T3482_DEFAULT_VALUE 8 /* PDN connectivity request */ -#define T3492_DEFAULT_VALUE 6 /* PDN disconnect request */ +#define T3482_DEFAULT_VALUE 8 /* PDN connectivity request */ +#define T3492_DEFAULT_VALUE 6 /* PDN disconnect request */ #endif #ifdef NAS_MME -#define T3485_DEFAULT_VALUE 8 /* Activate EPS bearer request */ -#define T3495_DEFAULT_VALUE 8 /* Deactivate EPS bearer request */ +#define T3485_DEFAULT_VALUE 8 /* Activate EPS bearer request */ +#define T3495_DEFAULT_VALUE 8 /* Deactivate EPS bearer request */ #endif /* Type of PDN address */ @@ -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 */ @@ -96,121 +96,153 @@ typedef struct { /* * -------------------------------------------------------------------------- - * ESM status procedure + * ESM status procedure * -------------------------------------------------------------------------- */ #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 /* * -------------------------------------------------------------------------- - * PDN connectivity procedure + * PDN connectivity procedure * -------------------------------------------------------------------------- */ #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 /* * -------------------------------------------------------------------------- - * PDN disconnect procedure + * PDN disconnect procedure * -------------------------------------------------------------------------- */ #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 /* * -------------------------------------------------------------------------- - * Default EPS bearer context activation procedure + * Default EPS bearer context activation procedure * -------------------------------------------------------------------------- */ #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 /* * -------------------------------------------------------------------------- - * Dedicated EPS bearer context activation procedure + * Dedicated EPS bearer context activation procedure * -------------------------------------------------------------------------- */ #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 /* * -------------------------------------------------------------------------- - * EPS bearer context deactivation procedure + * EPS bearer context deactivation procedure * -------------------------------------------------------------------------- */ #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__*/ diff --git a/openair-cn/NAS/EURECOM-NAS/src/esm/esm_pt.c b/openair-cn/NAS/EURECOM-NAS/src/esm/esm_pt.c index ff325fb9ff..d080bf5e0f 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/esm/esm_pt.c +++ b/openair-cn/NAS/EURECOM-NAS/src/esm/esm_pt.c @@ -1,20 +1,20 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source esm_pt.c +Source esm_pt.c -Version 0.1 +Version 0.1 -Date 2013/01/03 +Date 2013/01/03 -Product NAS stack +Product NAS stack -Subsystem EPS Session Management +Subsystem EPS Session Management -Author Frederic Maurel +Author Frederic Maurel -Description Defines functions used to handle ESM procedure transactions. +Description Defines functions used to handle ESM procedure transactions. *****************************************************************************/ @@ -24,8 +24,8 @@ Description Defines functions used to handle ESM procedure transactions. #include "commonDef.h" #include "nas_log.h" -#include <stdlib.h> // malloc, free -#include <string.h> // memcpy +#include <stdlib.h> // malloc, free +#include <string.h> // memcpy #endif // NAS_UE /****************************************************************************/ @@ -37,8 +37,8 @@ Description Defines functions used to handle ESM procedure transactions. * The Procedure Transaction Identity (PTI) identifies bi-directional * messages flows */ -#define ESM_PTI_MIN (PROCEDURE_TRANSACTION_IDENTITY_FIRST) -#define ESM_PTI_MAX (PROCEDURE_TRANSACTION_IDENTITY_LAST) +#define ESM_PTI_MIN (PROCEDURE_TRANSACTION_IDENTITY_FIRST) +#define ESM_PTI_MAX (PROCEDURE_TRANSACTION_IDENTITY_LAST) /****************************************************************************/ /******************* L O C A L D E F I N I T I O N S *******************/ @@ -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" }; @@ -57,10 +57,10 @@ static const char* _esm_pt_state_str[ESM_PT_STATE_MAX] = { * -------------------------- */ 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 */ + 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_context_t; /* @@ -69,10 +69,10 @@ typedef struct { * ------------------------------ */ static struct { - unsigned char index; /* Index of the next procedure transaction - * identity to be used */ + 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 @@ -87,16 +87,16 @@ static int _esm_pt_get_available_entry(void); #ifdef NAS_UE /**************************************************************************** ** ** - ** Name: esm_pt_initialize() ** + ** Name: esm_pt_initialize() ** ** ** ** Description: Initialize ESM procedure transaction data ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: None ** - ** Others: _esm_pt_data ** + ** Outputs: None ** + ** Return: None ** + ** Others: _esm_pt_data ** ** ** ***************************************************************************/ void esm_pt_initialize(void) @@ -105,7 +105,7 @@ void esm_pt_initialize(void) _esm_pt_data.index = 0; for (int i = 0; i < ESM_PT_DATA_SIZE + 1; i++) { - _esm_pt_data.context[i] = NULL; + _esm_pt_data.context[i] = NULL; } LOG_FUNC_OUT; @@ -113,18 +113,18 @@ void esm_pt_initialize(void) /**************************************************************************** ** ** - ** Name: esm_pt_assign() ** + ** Name: esm_pt_assign() ** ** ** ** Description: Assigns a new procedure transaction identity ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: The identity of the new procedure transac- ** - ** tion when successfully assigned; ** - ** the unassigned PTI (0) otherwise. ** - ** Others: _esm_pt_data ** + ** Outputs: None ** + ** Return: The identity of the new procedure transac- ** + ** tion when successfully assigned; ** + ** the unassigned PTI (0) otherwise. ** + ** Others: _esm_pt_data ** ** ** ***************************************************************************/ int esm_pt_assign(void) @@ -134,14 +134,14 @@ int esm_pt_assign(void) /* Search for an available procedure transaction identity */ int i = _esm_pt_get_available_entry(); if (i < 0) { - LOG_FUNC_RETURN (ESM_PT_UNASSIGNED); + LOG_FUNC_RETURN (ESM_PT_UNASSIGNED); } /* 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); + LOG_FUNC_RETURN (ESM_PT_UNASSIGNED); } /* Store the index of the next available procedure transaction identity */ @@ -157,25 +157,25 @@ int esm_pt_assign(void) _esm_pt_data.context[i]->args = NULL; LOG_TRACE(INFO, "ESM-FSM - Procedure transaction identity %d assigned", - _esm_pt_data.context[i]->pti); + _esm_pt_data.context[i]->pti); LOG_FUNC_RETURN (_esm_pt_data.context[i]->pti); } /**************************************************************************** ** ** - ** Name: esm_pt_release() ** + ** Name: esm_pt_release() ** ** ** ** Description: Release the given procedure transaction identity ** ** ** - ** Inputs: pti: The identity of the procedure transaction ** - ** to release ** - ** Others: None ** + ** Inputs: pti: The identity of the procedure transaction ** + ** to release ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok if the procedure transaction iden-** - ** tity has been successfully released; ** - ** RETURNerror otherwise. ** - ** Others: _esm_pt_data ** + ** Outputs: None ** + ** Return: RETURNok if the procedure transaction iden-** + ** tity has been successfully released; ** + ** RETURNerror otherwise. ** + ** Others: _esm_pt_data ** ** ** ***************************************************************************/ int esm_pt_release(int pti) @@ -183,34 +183,34 @@ int esm_pt_release(int pti) LOG_FUNC_IN; if ( (pti < ESM_PTI_MIN) || (pti > ESM_PTI_MAX) ) { - LOG_FUNC_RETURN (RETURNerror); + LOG_FUNC_RETURN (RETURNerror); } /* 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); + /* Procedure transaction not assigned */ + LOG_FUNC_RETURN (RETURNerror); } /* Do not release active procedure transaction */ if (ctx->status != ESM_PT_INACTIVE) { - LOG_TRACE(ERROR, "ESM-FSM - Procedure transaction is not INACTIVE"); - LOG_FUNC_RETURN (RETURNerror); + LOG_TRACE(ERROR, "ESM-FSM - Procedure transaction is not INACTIVE"); + LOG_FUNC_RETURN (RETURNerror); } /* Stop the retransmission timer if still running */ if (ctx->timer.id != NAS_TIMER_INACTIVE_ID) { - LOG_TRACE(INFO, "ESM-FSM - Stop retransmission timer %d", - ctx->timer.id); - ctx->timer.id = nas_timer_stop(ctx->timer.id); + LOG_TRACE(INFO, "ESM-FSM - Stop retransmission timer %d", + ctx->timer.id); + ctx->timer.id = nas_timer_stop(ctx->timer.id); } /* Release the retransmisison timer parameters */ if (ctx->args) { - if (ctx->args->msg.length > 0) { - free(ctx->args->msg.value); - } - free(ctx->args); - ctx->args = NULL; + if (ctx->args->msg.length > 0) { + free(ctx->args->msg.value); + } + free(ctx->args); + ctx->args = NULL; } /* Release transaction procedure data */ @@ -224,89 +224,88 @@ int esm_pt_release(int pti) /**************************************************************************** ** ** - ** Name: esm_pt_start_timer() ** + ** Name: esm_pt_start_timer() ** ** ** ** Description: Start the timer of the specified procedure transaction to ** - ** expire after a given time interval. Timer expiration will ** - ** schedule execution of the callback function where stored ** - ** ESM message should be re-transmit. ** + ** expire after a given time interval. Timer expiration will ** + ** schedule execution of the callback function where stored ** + ** ESM message should be re-transmit. ** ** ** - ** Inputs: pti: The identity of the procedure transaction ** - ** msg: The encoded ESM message to be stored ** - ** sec: The value of the time interval in seconds ** - ** cb: Function executed upon timer expiration ** - ** Others: None ** + ** Inputs: pti: The identity of the procedure transaction ** + ** msg: The encoded ESM message to be stored ** + ** sec: The value of the time interval in seconds ** + ** cb: Function executed upon timer expiration ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: _esm_pt_data ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: _esm_pt_data ** ** ** ***************************************************************************/ -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) { LOG_FUNC_IN; if ( (pti < ESM_PTI_MIN) || (pti > ESM_PTI_MAX) ) { - LOG_FUNC_RETURN (RETURNerror); + LOG_FUNC_RETURN (RETURNerror); } /* 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); + /* Procedure transaction not assigned */ + LOG_FUNC_RETURN (RETURNerror); } if (ctx->timer.id != NAS_TIMER_INACTIVE_ID) { - if (ctx->args) { - /* Re-start the retransmission timer */ - ctx->timer.id = nas_timer_restart(ctx->timer.id); - } - } - else { - /* Setup the retransmission timer parameters */ - 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.length = 0; - if (ctx->args->msg.value) { - memcpy(ctx->args->msg.value, msg->value, msg->length); - ctx->args->msg.length = msg->length; - } - /* Setup the retransmission timer to expire at the given - * time interval */ - ctx->timer.id = nas_timer_start(sec, cb, ctx->args); - ctx->timer.sec = sec; - } + if (ctx->args) { + /* Re-start the retransmission timer */ + ctx->timer.id = nas_timer_restart(ctx->timer.id); + } + } else { + /* Setup the retransmission timer parameters */ + 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.length = 0; + if (ctx->args->msg.value) { + memcpy(ctx->args->msg.value, msg->value, msg->length); + ctx->args->msg.length = msg->length; + } + /* Setup the retransmission timer to expire at the given + * time interval */ + ctx->timer.id = nas_timer_start(sec, cb, ctx->args); + ctx->timer.sec = sec; + } } if ( (ctx->args != NULL) && (ctx->timer.id != NAS_TIMER_INACTIVE_ID) ) { - LOG_TRACE(INFO, "ESM-FSM - Retransmission timer %d expires in " - "%ld seconds", ctx->timer.id, ctx->timer.sec); - LOG_FUNC_RETURN (RETURNok); + LOG_TRACE(INFO, "ESM-FSM - Retransmission timer %d expires in " + "%ld seconds", ctx->timer.id, ctx->timer.sec); + LOG_FUNC_RETURN (RETURNok); } LOG_FUNC_RETURN (RETURNerror); } /**************************************************************************** ** ** - ** Name: esm_pt_stop_timer() ** + ** Name: esm_pt_stop_timer() ** ** ** ** Description: Stop the timer previously started for the given procedure ** - ** transaction ** + ** transaction ** ** ** - ** Inputs: pti: The identity of the procedure transaction ** - ** Others: None ** + ** Inputs: pti: The identity of the procedure transaction ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: _esm_pt_data ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: _esm_pt_data ** ** ** ***************************************************************************/ int esm_pt_stop_timer(int pti) @@ -314,30 +313,30 @@ int esm_pt_stop_timer(int pti) LOG_FUNC_IN; if ( (pti < ESM_PTI_MIN) || (pti > ESM_PTI_MAX) ) { - LOG_FUNC_RETURN (RETURNerror); + LOG_FUNC_RETURN (RETURNerror); } /* 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); + /* Procedure transaction not assigned */ + LOG_FUNC_RETURN (RETURNerror); } /* Stop the retransmission timer if still running */ if (ctx->timer.id != NAS_TIMER_INACTIVE_ID) { - LOG_TRACE(INFO, "ESM-FSM - Stop retransmission timer %d", - ctx->timer.id); - ctx->timer.id = nas_timer_stop(ctx->timer.id); + LOG_TRACE(INFO, "ESM-FSM - Stop retransmission timer %d", + ctx->timer.id); + ctx->timer.id = nas_timer_stop(ctx->timer.id); } /* Release the retransmisison timer parameters */ if (ctx->args) { - if (ctx->args->msg.length > 0) { - free(ctx->args->msg.value); - } - free(ctx->args); - ctx->args = NULL; + if (ctx->args->msg.length > 0) { + free(ctx->args->msg.value); + } + free(ctx->args); + ctx->args = NULL; } LOG_FUNC_RETURN (RETURNok); @@ -345,18 +344,18 @@ int esm_pt_stop_timer(int pti) /**************************************************************************** ** ** - ** Name: esm_pt_set_status() ** + ** Name: esm_pt_set_status() ** ** ** ** Description: Set the status of the specified procedure transaction to ** - ** the given state ** + ** the given state ** ** ** - ** Inputs: pti: The identity of the procedure transaction ** - ** status: The new ESM procedure transaction status ** - ** Others: None ** + ** Inputs: pti: The identity of the procedure transaction ** + ** status: The new ESM procedure transaction status ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: _esm_pt_data ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: _esm_pt_data ** ** ** ***************************************************************************/ int esm_pt_set_status(int pti, esm_pt_state status) @@ -366,27 +365,27 @@ int esm_pt_set_status(int pti, esm_pt_state status) esm_pt_state old_status; if ( (pti < ESM_PTI_MIN) || (pti > ESM_PTI_MAX) ) { - LOG_FUNC_RETURN (RETURNerror); + LOG_FUNC_RETURN (RETURNerror); } /* 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 " - "(pti=%d)", pti); - LOG_FUNC_RETURN (RETURNerror); + /* Procedure transaction not assigned */ + LOG_TRACE(ERROR, "ESM-FSM - Procedure transaction not assigned " + "(pti=%d)", pti); + LOG_FUNC_RETURN (RETURNerror); } old_status = ctx->status; if (status < ESM_PT_STATE_MAX) { - LOG_TRACE(INFO, "ESM-FSM - Status of procedure transaction %d changed:" - " %s ===> %s", pti, - _esm_pt_state_str[old_status], _esm_pt_state_str[status]); - if (status != old_status) { - ctx->status = status; - LOG_FUNC_RETURN (RETURNok); - } + LOG_TRACE(INFO, "ESM-FSM - Status of procedure transaction %d changed:" + " %s ===> %s", pti, + _esm_pt_state_str[old_status], _esm_pt_state_str[status]); + if (status != old_status) { + ctx->status = status; + LOG_FUNC_RETURN (RETURNok); + } } LOG_FUNC_RETURN (RETURNerror); @@ -394,52 +393,52 @@ int esm_pt_set_status(int pti, esm_pt_state status) /**************************************************************************** ** ** - ** Name: esm_pt_get_status() ** + ** Name: esm_pt_get_status() ** ** ** ** Description: Get the current status value of the specified procedure ** - ** transaction ** + ** transaction ** ** ** - ** Inputs: pti: The identity of the procedure transaction ** - ** Others: _esm_pt_data ** + ** Inputs: pti: The identity of the procedure transaction ** + ** Others: _esm_pt_data ** ** ** - ** Outputs: None ** - ** Return: The current value of the ESM procedure ** - ** transaction status ** - ** Others: None ** + ** Outputs: None ** + ** Return: The current value of the ESM procedure ** + ** transaction status ** + ** Others: None ** ** ** ***************************************************************************/ esm_pt_state esm_pt_get_status(int pti) { if ( (pti < ESM_PTI_MIN) || (pti > ESM_PTI_MAX) ) { - return (ESM_PT_INACTIVE); + return (ESM_PT_INACTIVE); } if (_esm_pt_data.context[pti - ESM_PTI_MIN] == NULL) { - /* Procedure transaction not allocated */ - return (ESM_PT_INACTIVE); + /* Procedure transaction not allocated */ + return (ESM_PT_INACTIVE); } if (_esm_pt_data.context[pti - ESM_PTI_MIN]->pti != pti) { - /* Procedure transaction not assigned */ - return (ESM_PT_INACTIVE); + /* Procedure transaction not assigned */ + return (ESM_PT_INACTIVE); } return (_esm_pt_data.context[pti - ESM_PTI_MIN]->status); } /**************************************************************************** ** ** - ** Name: esm_pt_get_pending_pti() ** + ** Name: esm_pt_get_pending_pti() ** ** ** ** Description: Returns the procedure transaction identity assigned to ** - ** the first PDN connection entry which is pending in the ** - ** given state ** + ** the first PDN connection entry which is pending in the ** + ** given state ** ** ** - ** Inputs: status: The PDN connection status ** - ** Others: _esm_pt_data ** + ** Inputs: status: The PDN connection status ** + ** Others: _esm_pt_data ** ** ** - ** Outputs: None ** - ** Return: The procedure transaction identity of the ** - ** PDN connection entry if it exists; ** - ** the unassigned PTI (0) otherwise. ** - ** Others: None ** + ** Outputs: None ** + ** Return: The procedure transaction identity of the ** + ** PDN connection entry if it exists; ** + ** the unassigned PTI (0) otherwise. ** + ** Others: None ** ** ** ***************************************************************************/ int esm_pt_get_pending_pti(esm_pt_state status) @@ -448,14 +447,18 @@ 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; - /* PDN connection entry found */ - break; + if (_esm_pt_data.context[i] == NULL) { + continue; + } + if (_esm_pt_data.context[i]->status != status) { + continue; + } + /* PDN connection entry found */ + break; } if (i < ESM_PT_DATA_SIZE) { - LOG_FUNC_RETURN (_esm_pt_data.context[i]->pti); + LOG_FUNC_RETURN (_esm_pt_data.context[i]->pti); } /* PDN connection entry not found */ LOG_FUNC_RETURN (ESM_PT_UNASSIGNED); @@ -463,40 +466,40 @@ int esm_pt_get_pending_pti(esm_pt_state status) /**************************************************************************** ** ** - ** Name: esm_pt_is_not_in_use() ** + ** Name: esm_pt_is_not_in_use() ** ** ** ** Description: Check whether the given procedure transaction identity ** - ** does not match an assigned PTI value currently in use ** + ** does not match an assigned PTI value currently in use ** ** ** - ** Inputs: pti: The identity of the procedure transaction ** - ** Others: _esm_pt_data ** + ** Inputs: pti: The identity of the procedure transaction ** + ** Others: _esm_pt_data ** ** ** - ** Outputs: None ** - ** Return: TRUE, FALSE ** - ** Others: None ** + ** Outputs: None ** + ** Return: TRUE, FALSE ** + ** Others: None ** ** ** ***************************************************************************/ int esm_pt_is_not_in_use(int pti) { return ( (pti == ESM_PT_UNASSIGNED) || - (_esm_pt_data.context[pti - ESM_PTI_MIN] == NULL) || - (_esm_pt_data.context[pti - ESM_PTI_MIN]->pti) != pti); + (_esm_pt_data.context[pti - ESM_PTI_MIN] == NULL) || + (_esm_pt_data.context[pti - ESM_PTI_MIN]->pti) != pti); } #endif // NAS_UE /**************************************************************************** ** ** - ** Name: esm_pt_is_reserved() ** + ** Name: esm_pt_is_reserved() ** ** ** ** Description: Check whether the given procedure transaction identity is ** - ** a reserved value ** + ** a reserved value ** ** ** - ** Inputs: pti: The identity of the procedure transaction ** - ** Others: None ** + ** Inputs: pti: The identity of the procedure transaction ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: TRUE, FALSE ** - ** Others: None ** + ** Outputs: None ** + ** Return: TRUE, FALSE ** + ** Others: None ** ** ** ***************************************************************************/ int esm_pt_is_reserved(int pti) @@ -511,33 +514,37 @@ int esm_pt_is_reserved(int pti) #ifdef NAS_UE /**************************************************************************** ** ** - ** Name: _esm_pt_get_available_entry() ** + ** Name: _esm_pt_get_available_entry() ** ** ** ** Description: Returns the index of the next available entry in the list ** - ** of procedure transaction data ** + ** of procedure transaction data ** ** ** - ** Inputs: None ** - ** Others: _esm_pt_data ** + ** Inputs: None ** + ** Others: _esm_pt_data ** ** ** - ** Outputs: None ** - ** Return: The index of the next available procedure ** - ** transaction data entry; -1 if no any entry ** - ** is available. ** - ** Others: None ** + ** Outputs: None ** + ** Return: The index of the next available procedure ** + ** transaction data entry; -1 if no any entry ** + ** is available. ** + ** Others: None ** ** ** ***************************************************************************/ 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; - return i; + 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; - return i; + if (_esm_pt_data.context[i] != NULL) { + continue; + } + return i; } /* No available PTI entry found */ return (-1); - } +} #endif // NAS_UE diff --git a/openair-cn/NAS/EURECOM-NAS/src/esm/esm_pt.h b/openair-cn/NAS/EURECOM-NAS/src/esm/esm_pt.h index 5cae104e34..2716181ba9 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/esm/esm_pt.h +++ b/openair-cn/NAS/EURECOM-NAS/src/esm/esm_pt.h @@ -1,20 +1,20 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source esm_pt.h +Source esm_pt.h -Version 0.1 +Version 0.1 -Date 2013/01/03 +Date 2013/01/03 -Product NAS stack +Product NAS stack -Subsystem EPS Session Management +Subsystem EPS Session Management -Author Frederic Maurel +Author Frederic Maurel -Description Defines functions used to handle ESM procedure transactions. +Description Defines functions used to handle ESM procedure transactions. *****************************************************************************/ #ifndef __ESM_PT_H__ @@ -32,7 +32,7 @@ Description Defines functions used to handle ESM procedure transactions. /****************************************************************************/ /* Unassigned procedure transaction identity value */ -#define ESM_PT_UNASSIGNED (PROCEDURE_TRANSACTION_IDENTITY_UNASSIGNED) +#define ESM_PT_UNASSIGNED (PROCEDURE_TRANSACTION_IDENTITY_UNASSIGNED) /****************************************************************************/ /************************ G L O B A L T Y P E S ************************/ @@ -41,17 +41,17 @@ Description Defines functions used to handle ESM procedure transactions. #ifdef NAS_UE /* Procedure transaction states */ typedef enum { - ESM_PT_INACTIVE, /* No procedure transaction exists */ - ESM_PT_PENDING, /* The UE has initiated a procedure transaction - * towards the network */ + ESM_PT_INACTIVE, /* No procedure transaction exists */ + ESM_PT_PENDING, /* The UE has initiated a procedure transaction + * towards the network */ ESM_PT_STATE_MAX } esm_pt_state; /* ESM message timer retransmission data */ typedef struct { - unsigned char pti; /* Procedure transaction identity */ - unsigned int count; /* Retransmission counter */ - OctetString msg; /* Encoded ESM message to re-transmit */ + unsigned char pti; /* Procedure transaction identity */ + unsigned int count; /* Retransmission counter */ + OctetString msg; /* Encoded ESM message to re-transmit */ } esm_pt_timer_data_t; #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); diff --git a/openair-cn/NAS/EURECOM-NAS/src/esm/sap/esm_recv.c b/openair-cn/NAS/EURECOM-NAS/src/esm/sap/esm_recv.c index af3d072d65..0501b36eb9 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/esm/sap/esm_recv.c +++ b/openair-cn/NAS/EURECOM-NAS/src/esm/sap/esm_recv.c @@ -1,22 +1,22 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source esm_recv.c +Source esm_recv.c -Version 0.1 +Version 0.1 -Date 2013/02/06 +Date 2013/02/06 -Product NAS stack +Product NAS stack -Subsystem EPS Session Management +Subsystem EPS Session Management -Author Frederic Maurel +Author Frederic Maurel -Description Defines functions executed at the ESM Service Access - Point upon receiving EPS Session Management messages - from the EPS Mobility Management sublayer. +Description Defines functions executed at the ESM Service Access + Point upon receiving EPS Session Management messages + from the EPS Mobility Management sublayer. *****************************************************************************/ @@ -31,8 +31,8 @@ Description Defines functions executed at the ESM Service Access #include "esm_cause.h" #ifdef NAS_UE -#include <stdlib.h> // malloc, free -#include <string.h> // memset +#include <stdlib.h> // malloc, free +#include <string.h> // memset #endif /****************************************************************************/ @@ -54,28 +54,28 @@ Description Defines functions executed at the ESM Service Access */ /**************************************************************************** ** ** - ** Name: esm_recv_status() ** + ** Name: esm_recv_status() ** ** ** ** Description: Processes ESM status message ** ** ** - ** Inputs: ueid: UE local identifier ** - ** pti: Procedure transaction identity ** - ** ebi: EPS bearer identity ** - ** msg: The received ESM message ** - ** Others: None ** + ** Inputs: ueid: UE local identifier ** + ** pti: Procedure transaction identity ** + ** ebi: EPS bearer identity ** + ** msg: The received ESM message ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: ESM cause code whenever the processing of ** - ** the ESM message fails ** - ** Others: None ** + ** Outputs: None ** + ** Return: ESM cause code whenever the processing of ** + ** the ESM message fails ** + ** Others: None ** ** ** ***************************************************************************/ #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; @@ -84,7 +84,7 @@ int esm_recv_status(unsigned int ueid, int pti, int ebi, int rc; LOG_TRACE(INFO, "ESM-SAP - Received ESM status message (pti=%d, ebi=%d)", - pti, ebi); + pti, ebi); /* * Message processing @@ -92,7 +92,7 @@ int esm_recv_status(unsigned int ueid, int pti, int ebi, /* Get the ESM cause */ esm_cause = msg->esmcause; - /* Execute the ESM status procedure */ + /* Execute the ESM status procedure */ #ifdef NAS_UE rc = esm_proc_status_ind(pti, ebi, &esm_cause); #endif @@ -100,7 +100,7 @@ int esm_recv_status(unsigned int ueid, int pti, int ebi, rc = esm_proc_status_ind(ueid, pti, ebi, &esm_cause); #endif if (rc != RETURNerror) { - esm_cause = ESM_CAUSE_SUCCESS; + esm_cause = ESM_CAUSE_SUCCESS; } /* Return the ESM cause value */ @@ -115,57 +115,56 @@ int esm_recv_status(unsigned int ueid, int pti, int ebi, #ifdef NAS_UE /**************************************************************************** ** ** - ** Name: esm_recv_pdn_connectivity_reject() ** + ** Name: esm_recv_pdn_connectivity_reject() ** ** ** ** Description: Processes PDN Connectivity Reject message ** ** ** - ** Inputs: pti: Procedure transaction identity ** - ** ebi: EPS bearer identity ** - ** msg: The received ESM message ** - ** Others: None ** + ** Inputs: pti: Procedure transaction identity ** + ** ebi: EPS bearer identity ** + ** msg: The received ESM message ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: ESM cause code whenever the processing of ** - ** the ESM message fails ** - ** Others: None ** + ** Outputs: None ** + ** Return: ESM cause code whenever the processing of ** + ** the ESM message fails ** + ** Others: None ** ** ** ***************************************************************************/ 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; int esm_cause; LOG_TRACE(INFO, "ESM-SAP - Received PDN Connectivity Reject message " - "(pti=%d, ebi=%d, cause=%d)", pti, ebi, msg->esmcause); + "(pti=%d, ebi=%d, cause=%d)", pti, ebi, msg->esmcause); /* * Procedure transaction identity checking */ if ( (pti == ESM_PT_UNASSIGNED) || esm_pt_is_reserved(pti) ) { - /* 3GPP TS 24.301, section 7.3.1, case a - * Reserved or unassigned PTI value - */ - 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) ) { - /* 3GPP TS 24.301, section 7.3.1, case a - * Assigned value that does not match any PTI in use - */ - LOG_TRACE(WARNING, "ESM-SAP - PTI mismatch (pti=%d)", pti); - LOG_FUNC_RETURN (ESM_CAUSE_PTI_MISMATCH); + /* 3GPP TS 24.301, section 7.3.1, case a + * Reserved or unassigned PTI value + */ + 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) ) { + /* 3GPP TS 24.301, section 7.3.1, case a + * Assigned value that does not match any PTI in use + */ + LOG_TRACE(WARNING, "ESM-SAP - PTI mismatch (pti=%d)", pti); + LOG_FUNC_RETURN (ESM_CAUSE_PTI_MISMATCH); } /* * EPS bearer identity checking */ else if ( (ebi != ESM_EBI_UNASSIGNED) || esm_ebr_is_reserved(ebi) ) { - /* 3GPP TS 24.301, section 7.3.2, case a - * Assigned or reserved EPS bearer identity value */ - LOG_TRACE(WARNING, "ESM-SAP - Invalid EPS bearer identity (ebi=%d)", - ebi); - LOG_FUNC_RETURN (ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY); + /* 3GPP TS 24.301, section 7.3.2, case a + * Assigned or reserved EPS bearer identity value */ + LOG_TRACE(WARNING, "ESM-SAP - Invalid EPS bearer identity (ebi=%d)", + ebi); + LOG_FUNC_RETURN (ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY); } /* @@ -177,7 +176,7 @@ int esm_recv_pdn_connectivity_reject(int pti, int ebi, /* Execute the PDN connectivity procedure not accepted by the network */ int rc = esm_proc_pdn_connectivity_reject(pti, &esm_cause); if (rc != RETURNerror) { - esm_cause = ESM_CAUSE_SUCCESS; + esm_cause = ESM_CAUSE_SUCCESS; } /* Return the ESM cause value */ @@ -186,57 +185,56 @@ int esm_recv_pdn_connectivity_reject(int pti, int ebi, /**************************************************************************** ** ** - ** Name: esm_recv_pdn_disconnect_reject() ** + ** Name: esm_recv_pdn_disconnect_reject() ** ** ** ** Description: Processes PDN Disconnect Reject message ** ** ** - ** Inputs: pti: Procedure transaction identity ** - ** ebi: EPS bearer identity ** - ** msg: The received ESM message ** - ** Others: None ** + ** Inputs: pti: Procedure transaction identity ** + ** ebi: EPS bearer identity ** + ** msg: The received ESM message ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: ESM cause code whenever the processing of ** - ** the ESM message fails ** - ** Others: None ** + ** Outputs: None ** + ** Return: ESM cause code whenever the processing of ** + ** the ESM message fails ** + ** Others: None ** ** ** ***************************************************************************/ 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; int esm_cause; LOG_TRACE(INFO, "ESM-SAP - Received PDN Disconnect Reject message " - "(pti=%d, ebi=%d, cause=%d)", pti, ebi, msg->esmcause); + "(pti=%d, ebi=%d, cause=%d)", pti, ebi, msg->esmcause); /* * Procedure transaction identity checking */ if ( (pti == ESM_PT_UNASSIGNED) || esm_pt_is_reserved(pti) ) { - /* 3GPP TS 24.301, section 7.3.1, case b - * Reserved or unassigned PTI value - */ - 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) ) { - /* 3GPP TS 24.301, section 7.3.1, case b - * Assigned value that does not match any PTI in use - */ - LOG_TRACE(WARNING, "ESM-SAP - PTI mismatch (pti=%d)", pti); - LOG_FUNC_RETURN (ESM_CAUSE_PTI_MISMATCH); + /* 3GPP TS 24.301, section 7.3.1, case b + * Reserved or unassigned PTI value + */ + 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) ) { + /* 3GPP TS 24.301, section 7.3.1, case b + * Assigned value that does not match any PTI in use + */ + LOG_TRACE(WARNING, "ESM-SAP - PTI mismatch (pti=%d)", pti); + LOG_FUNC_RETURN (ESM_CAUSE_PTI_MISMATCH); } /* * EPS bearer identity checking */ else if ( (ebi != ESM_EBI_UNASSIGNED) || esm_ebr_is_reserved(ebi) ) { - /* 3GPP TS 24.301, section 7.3.2, case b - * Assigned or reserved EPS bearer identity value */ - LOG_TRACE(WARNING, "ESM-SAP - Invalid EPS bearer identity (ebi=%d)", - ebi); - LOG_FUNC_RETURN (ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY); + /* 3GPP TS 24.301, section 7.3.2, case b + * Assigned or reserved EPS bearer identity value */ + LOG_TRACE(WARNING, "ESM-SAP - Invalid EPS bearer identity (ebi=%d)", + ebi); + LOG_FUNC_RETURN (ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY); } /* @@ -248,7 +246,7 @@ int esm_recv_pdn_disconnect_reject(int pti, int ebi, /* Execute the PDN disconnect procedure not accepted by the network */ int rc = esm_proc_pdn_disconnect_reject(pti, &esm_cause); if (rc != RETURNerror) { - esm_cause = ESM_CAUSE_SUCCESS; + esm_cause = ESM_CAUSE_SUCCESS; } /* Return the ESM cause value */ @@ -257,59 +255,58 @@ int esm_recv_pdn_disconnect_reject(int pti, int ebi, /**************************************************************************** ** ** - ** Name: esm_recv_activate_default_eps_bearer_context_request() ** + ** Name: esm_recv_activate_default_eps_bearer_context_request() ** ** ** ** Description: Processes Activate Default EPS Bearer Context Request ** - ** message ** + ** message ** ** ** - ** Inputs: pti: Procedure transaction identity ** - ** ebi: EPS bearer identity ** - ** msg: The received ESM message ** - ** Others: None ** + ** Inputs: pti: Procedure transaction identity ** + ** ebi: EPS bearer identity ** + ** msg: The received ESM message ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: ESM cause code whenever the processing of ** - ** the ESM message fails ** - ** Others: None ** + ** Outputs: None ** + ** Return: ESM cause code whenever the processing of ** + ** the ESM message fails ** + ** Others: None ** ** ** ***************************************************************************/ 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; int esm_cause = ESM_CAUSE_SUCCESS; LOG_TRACE(INFO, "ESM-SAP - Received Activate Default EPS Bearer Context " - "Request message (pti=%d, ebi=%d)", pti, ebi); + "Request message (pti=%d, ebi=%d)", pti, ebi); /* * Procedure transaction identity checking */ if ( (pti == ESM_PT_UNASSIGNED) || esm_pt_is_reserved(pti) ) { - /* 3GPP TS 24.301, section 7.3.1, case h - * Reserved or unassigned PTI value - */ - 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) ) { - /* 3GPP TS 24.301, section 7.3.1, case g - * Assigned value that does not match any PTI in use - */ - LOG_TRACE(WARNING, "ESM-SAP - PTI mismatch (pti=%d)", pti); - LOG_FUNC_RETURN (ESM_CAUSE_PTI_MISMATCH); + /* 3GPP TS 24.301, section 7.3.1, case h + * Reserved or unassigned PTI value + */ + 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) ) { + /* 3GPP TS 24.301, section 7.3.1, case g + * Assigned value that does not match any PTI in use + */ + LOG_TRACE(WARNING, "ESM-SAP - PTI mismatch (pti=%d)", pti); + LOG_FUNC_RETURN (ESM_CAUSE_PTI_MISMATCH); } /* * EPS bearer identity checking */ else if ( (ebi == ESM_EBI_UNASSIGNED) || esm_ebr_is_reserved(ebi) ) { - /* 3GPP TS 24.301, section 7.3.2, case g - * Reserved or unassigned EPS bearer identity value - */ - LOG_TRACE(WARNING, "ESM-SAP - Invalid EPS bearer identity (ebi=%d)", - ebi); - LOG_FUNC_RETURN (ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY); + /* 3GPP TS 24.301, section 7.3.2, case g + * Reserved or unassigned EPS bearer identity value + */ + LOG_TRACE(WARNING, "ESM-SAP - Invalid EPS bearer identity (ebi=%d)", + ebi); + LOG_FUNC_RETURN (ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY); } /* @@ -318,61 +315,60 @@ int esm_recv_activate_default_eps_bearer_context_request(int pti, int ebi, esm_proc_qos_t qos = {-1, -1, -1, -1, -1}; /* Get the maximum bit rate for uplink and downlink */ if (msg->epsqos.bitRatesExtPresent) { - qos.mbrUL = - 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) { - qos.mbrUL = - eps_qos_bit_rate_value(msg->epsqos.bitRates.maxBitRateForUL); - qos.mbrDL = - eps_qos_bit_rate_value(msg->epsqos.bitRates.maxBitRateForDL); + qos.mbrUL = + 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) { + qos.mbrUL = + eps_qos_bit_rate_value(msg->epsqos.bitRates.maxBitRateForUL); + qos.mbrDL = + eps_qos_bit_rate_value(msg->epsqos.bitRates.maxBitRateForDL); } /* Get the guaranteed bit rate for uplink and downlink */ if (msg->epsqos.bitRatesExtPresent) { - qos.gbrUL = - 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) { - qos.gbrUL = - eps_qos_bit_rate_value(msg->epsqos.bitRates.guarBitRateForUL); - qos.gbrDL = - eps_qos_bit_rate_value(msg->epsqos.bitRates.guarBitRateForDL); + qos.gbrUL = + 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) { + qos.gbrUL = + eps_qos_bit_rate_value(msg->epsqos.bitRates.guarBitRateForUL); + qos.gbrDL = + eps_qos_bit_rate_value(msg->epsqos.bitRates.guarBitRateForDL); } /* Get the QoS Class Identifier */ qos.qci = msg->epsqos.qci; /* Get the value of the PDN type indicator */ int pdn_type = -1; if (msg->pdnaddress.pdntypevalue == PDN_VALUE_TYPE_IPV4) { - pdn_type = ESM_PDN_TYPE_IPV4; + pdn_type = ESM_PDN_TYPE_IPV4; } else if (msg->pdnaddress.pdntypevalue == PDN_VALUE_TYPE_IPV6) { - pdn_type = ESM_PDN_TYPE_IPV6; + pdn_type = ESM_PDN_TYPE_IPV6; } else if (msg->pdnaddress.pdntypevalue == PDN_VALUE_TYPE_IPV4V6) { - pdn_type = ESM_PDN_TYPE_IPV4V6; + pdn_type = ESM_PDN_TYPE_IPV4V6; } /* Get the ESM cause */ - 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; + 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; } /* Execute the PDN connectivity procedure accepted by the network */ int pid = esm_proc_pdn_connectivity_accept(pti, pdn_type, - &msg->pdnaddress.pdnaddressinformation, - &msg->accesspointname.accesspointnamevalue, - &esm_cause); + &msg->pdnaddress.pdnaddressinformation, + &msg->accesspointname.accesspointnamevalue, + &esm_cause); if (pid != RETURNerror) { - /* Create local default EPS bearer context */ - int rc = esm_proc_default_eps_bearer_context_request(pid, ebi, &qos, - &esm_cause); - if (rc != RETURNerror) { - esm_cause = ESM_CAUSE_SUCCESS; - } + /* Create local default EPS bearer context */ + int rc = esm_proc_default_eps_bearer_context_request(pid, ebi, &qos, + &esm_cause); + if (rc != RETURNerror) { + esm_cause = ESM_CAUSE_SUCCESS; + } } /* Return the ESM cause value */ @@ -381,74 +377,72 @@ int esm_recv_activate_default_eps_bearer_context_request(int pti, int ebi, /**************************************************************************** ** ** - ** Name: esm_recv_activate_dedicated_eps_bearer_context_request() ** + ** Name: esm_recv_activate_dedicated_eps_bearer_context_request() ** ** ** ** Description: Processes Activate Dedicated EPS Bearer Context Request ** - ** message ** + ** message ** ** ** - ** Inputs: pti: Procedure transaction identity ** - ** ebi: EPS bearer identity ** - ** msg: The received ESM message ** - ** Others: None ** + ** Inputs: pti: Procedure transaction identity ** + ** ebi: EPS bearer identity ** + ** msg: The received ESM message ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: ESM cause code whenever the processing of ** - ** the ESM message fails ** - ** Others: None ** + ** Outputs: None ** + ** Return: ESM cause code whenever the processing of ** + ** the ESM message fails ** + ** Others: None ** ** ** ***************************************************************************/ 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; int esm_cause = ESM_CAUSE_SUCCESS; LOG_TRACE(INFO, "ESM-SAP - Received Activate Dedicated EPS Bearer " - "Context Request message (pti=%d, ebi=%d)", pti, ebi); + "Context Request message (pti=%d, ebi=%d)", pti, ebi); /* * Procedure transaction identity checking */ if ( esm_pt_is_reserved(pti) ) { - /* 3GPP TS 24.301, section 7.3.1, case j - * Reserved PTI value - */ - 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) ) { - /* 3GPP TS 24.301, section 7.3.1, case i - * Assigned value that does not match any PTI in use - */ - LOG_TRACE(WARNING, "ESM-SAP - PTI mismatch (pti=%d)", pti); - LOG_FUNC_RETURN (ESM_CAUSE_PTI_MISMATCH); + /* 3GPP TS 24.301, section 7.3.1, case j + * Reserved PTI value + */ + 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) ) { + /* 3GPP TS 24.301, section 7.3.1, case i + * Assigned value that does not match any PTI in use + */ + LOG_TRACE(WARNING, "ESM-SAP - PTI mismatch (pti=%d)", pti); + LOG_FUNC_RETURN (ESM_CAUSE_PTI_MISMATCH); } /* * EPS bearer identity checking */ else if ( (ebi == ESM_EBI_UNASSIGNED) || esm_ebr_is_reserved(ebi) ) { - /* 3GPP TS 24.301, section 7.3.2, case h - * Reserved or unassigned EPS bearer identity value - */ - LOG_TRACE(WARNING, "ESM-SAP - Invalid EPS bearer identity (ebi=%d)", - ebi); - LOG_FUNC_RETURN (ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY); + /* 3GPP TS 24.301, section 7.3.2, case h + * Reserved or unassigned EPS bearer identity value + */ + LOG_TRACE(WARNING, "ESM-SAP - Invalid EPS bearer identity (ebi=%d)", + ebi); + LOG_FUNC_RETURN (ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY); } /* * TFT checking */ else if (msg->tft.tftoperationcode != TRAFFIC_FLOW_TEMPLATE_OPCODE_CREATE) { - /* 3GPP TS 24.301, section 6.4.2.4, case a1 - * Semantic errors in TFT operations - */ - LOG_FUNC_RETURN (ESM_CAUSE_SEMANTIC_ERROR_IN_THE_TFT_OPERATION); - } - else if (msg->tft.numberofpacketfilters == 0) { - /* 3GPP TS 24.301, section 6.4.2.4, case b1 - * Syntactical errors in TFT operations - */ - LOG_FUNC_RETURN (ESM_CAUSE_SYNTACTICAL_ERROR_IN_THE_TFT_OPERATION); + /* 3GPP TS 24.301, section 6.4.2.4, case a1 + * Semantic errors in TFT operations + */ + LOG_FUNC_RETURN (ESM_CAUSE_SEMANTIC_ERROR_IN_THE_TFT_OPERATION); + } else if (msg->tft.numberofpacketfilters == 0) { + /* 3GPP TS 24.301, section 6.4.2.4, case b1 + * Syntactical errors in TFT operations + */ + LOG_FUNC_RETURN (ESM_CAUSE_SYNTACTICAL_ERROR_IN_THE_TFT_OPERATION); } /* @@ -458,29 +452,27 @@ int esm_recv_activate_dedicated_eps_bearer_context_request(int pti, int ebi, esm_proc_qos_t qos = {-1, -1, -1, -1, -1}; /* Get the maximum bit rate for uplink and downlink */ if (msg->epsqos.bitRatesExtPresent) { - qos.mbrUL = - 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) { - qos.mbrUL = - eps_qos_bit_rate_value(msg->epsqos.bitRates.maxBitRateForUL); - qos.mbrDL = - eps_qos_bit_rate_value(msg->epsqos.bitRates.maxBitRateForDL); + qos.mbrUL = + 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) { + qos.mbrUL = + eps_qos_bit_rate_value(msg->epsqos.bitRates.maxBitRateForUL); + qos.mbrDL = + eps_qos_bit_rate_value(msg->epsqos.bitRates.maxBitRateForDL); } /* Get the guaranteed bit rate for uplink and downlink */ if (msg->epsqos.bitRatesExtPresent) { - qos.gbrUL = - 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) { - qos.gbrUL = - eps_qos_bit_rate_value(msg->epsqos.bitRates.guarBitRateForUL); - qos.gbrDL = - eps_qos_bit_rate_value(msg->epsqos.bitRates.guarBitRateForDL); + qos.gbrUL = + 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) { + qos.gbrUL = + eps_qos_bit_rate_value(msg->epsqos.bitRates.guarBitRateForUL); + qos.gbrDL = + eps_qos_bit_rate_value(msg->epsqos.bitRates.guarBitRateForDL); } /* Get the QoS Class Identifier */ qos.qci = msg->epsqos.qci; @@ -488,92 +480,88 @@ 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++) - { - /* Create new temporary packet filter */ - 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 */ - tft.n_pkfs += 1; - /* Packet filter identifier */ - tft.pkf[i]->id = pkfs[i]->identifier; - /* Packet filter direction */ - tft.pkf[i]->dir = pkfs[i]->direction; - /* Evaluation precedence */ - tft.pkf[i]->precedence = pkfs[i]->eval_precedence; - - /* Get the packet filter components */ - 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++) - { - 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) { - /* IPv6 remote address component */ - 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; - } - } - if (pkf->flags & TRAFFIC_FLOW_TEMPLATE_PROTOCOL_NEXT_HEADER_FLAG) { - /* Protocol identifier/Next header component */ - tft.pkf[i]->data.ipv4.protocol = - pkf->protocolidentifier_nextheader; - } - 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) { - /* Local port range component */ - /* TODO: Add port range type to network_pkf_t in networkDef.h */ - tft.pkf[i]->lport = pkf->localportrange.lowlimit; - } - 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) - { - /* Remote port range component */ - /* TODO: Add port range type to network_pkf_t in networkDef.h */ - tft.pkf[i]->rport = pkf->remoteportrange.lowlimit; - } - if (pkf->flags & TRAFFIC_FLOW_TEMPLATE_SECURITY_PARAMETER_INDEX) { - /* Security parameter index component */ - tft.pkf[i]->data.ipv6.ipsec = pkf->securityparameterindex; - } - if (pkf->flags & TRAFFIC_FLOW_TEMPLATE_TYPE_OF_SERVICE_TRAFFIC_CLASS) { - /* Type of service/Traffic class component */ - tft.pkf[i]->data.ipv4.tos = - pkf->typdeofservice_trafficclass.value; - } - if (pkf->flags & TRAFFIC_FLOW_TEMPLATE_FLOW_LABEL) { - /* Flow label component */ - tft.pkf[i]->data.ipv6.fl = pkf->flowlabel; - } - } + 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) { + /* Initialize the temporary packet filter */ + memset(tft.pkf[i], 0, sizeof(network_pkf_t)); + /* Increment the number of packet filters contained in the TFT */ + tft.n_pkfs += 1; + /* Packet filter identifier */ + tft.pkf[i]->id = pkfs[i]->identifier; + /* Packet filter direction */ + tft.pkf[i]->dir = pkfs[i]->direction; + /* Evaluation precedence */ + tft.pkf[i]->precedence = pkfs[i]->eval_precedence; + + /* Get the packet filter components */ + 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++) { + 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) { + /* IPv6 remote address component */ + 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; + } + } + if (pkf->flags & TRAFFIC_FLOW_TEMPLATE_PROTOCOL_NEXT_HEADER_FLAG) { + /* Protocol identifier/Next header component */ + tft.pkf[i]->data.ipv4.protocol = + pkf->protocolidentifier_nextheader; + } + 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) { + /* Local port range component */ + /* TODO: Add port range type to network_pkf_t in networkDef.h */ + tft.pkf[i]->lport = pkf->localportrange.lowlimit; + } + 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) { + /* Remote port range component */ + /* TODO: Add port range type to network_pkf_t in networkDef.h */ + tft.pkf[i]->rport = pkf->remoteportrange.lowlimit; + } + if (pkf->flags & TRAFFIC_FLOW_TEMPLATE_SECURITY_PARAMETER_INDEX) { + /* Security parameter index component */ + tft.pkf[i]->data.ipv6.ipsec = pkf->securityparameterindex; + } + if (pkf->flags & TRAFFIC_FLOW_TEMPLATE_TYPE_OF_SERVICE_TRAFFIC_CLASS) { + /* Type of service/Traffic class component */ + tft.pkf[i]->data.ipv4.tos = + pkf->typdeofservice_trafficclass.value; + } + if (pkf->flags & TRAFFIC_FLOW_TEMPLATE_FLOW_LABEL) { + /* Flow label component */ + tft.pkf[i]->data.ipv6.fl = pkf->flowlabel; + } + } } - + /* Execute the dedicated EPS bearer context activation procedure */ int rc = esm_proc_dedicated_eps_bearer_context_request(ebi, - msg->linkedepsbeareridentity, - &qos, &tft, &esm_cause); + msg->linkedepsbeareridentity, + &qos, &tft, &esm_cause); if (rc != RETURNerror) { - esm_cause = ESM_CAUSE_SUCCESS; + esm_cause = ESM_CAUSE_SUCCESS; } /* Release temporary traffic flow template data */ for (int i = 0; i < tft.n_pkfs; i++) { - free(tft.pkf[i]); + free(tft.pkf[i]); } /* Return the ESM cause value */ LOG_FUNC_RETURN (esm_cause); @@ -581,23 +569,23 @@ int esm_recv_activate_dedicated_eps_bearer_context_request(int pti, int ebi, /**************************************************************************** ** ** - ** Name: esm_recv_deactivate_eps_bearer_context_request() ** + ** Name: esm_recv_deactivate_eps_bearer_context_request() ** ** ** ** Description: Processes Deactivate EPS Bearer Context Request message ** ** ** - ** Inputs: pti: Procedure transaction identity ** - ** ebi: EPS bearer identity ** - ** msg: The received ESM message ** - ** Others: None ** + ** Inputs: pti: Procedure transaction identity ** + ** ebi: EPS bearer identity ** + ** msg: The received ESM message ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: ESM cause code whenever the processing of ** - ** the ESM message fails ** - ** Others: None ** + ** Outputs: None ** + ** Return: ESM cause code whenever the processing of ** + ** the ESM message fails ** + ** Others: None ** ** ** ***************************************************************************/ 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; @@ -605,39 +593,38 @@ int esm_recv_deactivate_eps_bearer_context_request(int pti, int ebi, int esm_cause; LOG_TRACE(INFO, "ESM-SAP - Received Deactivate EPS Bearer Context " - "Request message (pti=%d, ebi=%d)", pti, ebi); + "Request message (pti=%d, ebi=%d)", pti, ebi); /* * Procedure transaction identity checking */ if ( esm_pt_is_reserved(pti) ) { - /* 3GPP TS 24.301, section 7.3.1, case m - * Reserved PTI value - */ - 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) ) { - /* 3GPP TS 24.301, section 7.3.1, case m - * Assigned value does not match any PTI in use - */ - LOG_TRACE(WARNING, "ESM-SAP - PTI mismatch (pti=%d)", pti); - LOG_FUNC_RETURN (ESM_CAUSE_PTI_MISMATCH); + /* 3GPP TS 24.301, section 7.3.1, case m + * Reserved PTI value + */ + 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) ) { + /* 3GPP TS 24.301, section 7.3.1, case m + * Assigned value does not match any PTI in use + */ + LOG_TRACE(WARNING, "ESM-SAP - PTI mismatch (pti=%d)", pti); + LOG_FUNC_RETURN (ESM_CAUSE_PTI_MISMATCH); } /* * EPS bearer identity checking */ else if ( (ebi == ESM_EBI_UNASSIGNED) || esm_ebr_is_reserved(ebi) || - esm_ebr_is_not_in_use(ebi) ) { - /* 3GPP TS 24.301, section 7.3.2, case j - * Reserved or unassigned EPS bearer identity value or, - * assigned value that does not match an existing EPS bearer context - */ - LOG_TRACE(WARNING, "ESM-SAP - Invalid EPS bearer identity (ebi=%d)", - ebi); - /* Respond with a DEACTIVATE EPS BEARER CONTEXT ACCEPT message with - * the EPS bearer identity set to the received EPS bearer identity */ - LOG_FUNC_RETURN (ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY); + esm_ebr_is_not_in_use(ebi) ) { + /* 3GPP TS 24.301, section 7.3.2, case j + * Reserved or unassigned EPS bearer identity value or, + * assigned value that does not match an existing EPS bearer context + */ + LOG_TRACE(WARNING, "ESM-SAP - Invalid EPS bearer identity (ebi=%d)", + ebi); + /* Respond with a DEACTIVATE EPS BEARER CONTEXT ACCEPT message with + * the EPS bearer identity set to the received EPS bearer identity */ + LOG_FUNC_RETURN (ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY); } /* @@ -648,15 +635,15 @@ int esm_recv_deactivate_eps_bearer_context_request(int pti, int ebi, /* Execute the PDN disconnect procedure accepted by the network */ if (pti != ESM_PT_UNASSIGNED) { - rc = esm_proc_pdn_disconnect_accept(pti, &esm_cause); + rc = esm_proc_pdn_disconnect_accept(pti, &esm_cause); } if (rc != RETURNerror) { - /* Execute the EPS bearer context deactivation procedure */ - rc = esm_proc_eps_bearer_context_deactivate_request(ebi, &esm_cause); - if (rc != RETURNerror) { - esm_cause = ESM_CAUSE_SUCCESS; - } + /* Execute the EPS bearer context deactivation procedure */ + rc = esm_proc_eps_bearer_context_deactivate_request(ebi, &esm_cause); + if (rc != RETURNerror) { + esm_cause = ESM_CAUSE_SUCCESS; + } } /* Return the ESM cause value */ @@ -672,126 +659,125 @@ int esm_recv_deactivate_eps_bearer_context_request(int pti, int ebi, #ifdef NAS_MME /**************************************************************************** ** ** - ** Name: esm_recv_pdn_connectivity_request() ** + ** Name: esm_recv_pdn_connectivity_request() ** ** ** ** Description: Processes PDN connectivity request message ** ** ** - ** Inputs: ueid: UE local identifier ** - ** pti: Procedure transaction identity ** - ** ebi: EPS bearer identity ** - ** msg: The received ESM message ** - ** Others: None ** + ** Inputs: ueid: UE local identifier ** + ** pti: Procedure transaction identity ** + ** ebi: EPS bearer identity ** + ** msg: The received ESM message ** + ** Others: None ** ** ** - ** Outputs: new_ebi: New assigned EPS bearer identity ** - ** data: PDN connection and EPS bearer context data ** - ** Return: ESM cause code whenever the processing of ** - ** the ESM message fails ** - ** Others: None ** + ** Outputs: new_ebi: New assigned EPS bearer identity ** + ** data: PDN connection and EPS bearer context data ** + ** Return: ESM cause code whenever the processing of ** + ** the ESM message fails ** + ** Others: None ** ** ** ***************************************************************************/ 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; int esm_cause = ESM_CAUSE_SUCCESS; LOG_TRACE(INFO, "ESM-SAP - Received PDN Connectivity Request message " - "(ueid=%d, pti=%d, ebi=%d)", ueid, pti, ebi); + "(ueid=%d, pti=%d, ebi=%d)", ueid, pti, ebi); /* * Procedure transaction identity checking */ if ( (pti == ESM_PT_UNASSIGNED) || esm_pt_is_reserved(pti) ) { - /* 3GPP TS 24.301, section 7.3.1, case a - * Reserved or unassigned PTI value - */ - LOG_TRACE(WARNING, "ESM-SAP - Invalid PTI value (pti=%d)", pti); - LOG_FUNC_RETURN (ESM_CAUSE_INVALID_PTI_VALUE); + /* 3GPP TS 24.301, section 7.3.1, case a + * Reserved or unassigned PTI value + */ + LOG_TRACE(WARNING, "ESM-SAP - Invalid PTI value (pti=%d)", pti); + LOG_FUNC_RETURN (ESM_CAUSE_INVALID_PTI_VALUE); } /* * EPS bearer identity checking */ else if ( ebi != ESM_EBI_UNASSIGNED ) { - /* 3GPP TS 24.301, section 7.3.2, case a - * Reserved or assigned EPS bearer identity value */ - LOG_TRACE(WARNING, "ESM-SAP - Invalid EPS bearer identity (ebi=%d)", - ebi); - LOG_FUNC_RETURN (ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY); + /* 3GPP TS 24.301, section 7.3.2, case a + * Reserved or assigned EPS bearer identity value */ + LOG_TRACE(WARNING, "ESM-SAP - Invalid EPS bearer identity (ebi=%d)", + ebi); + LOG_FUNC_RETURN (ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY); } /* * 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); + LOG_TRACE(ERROR, "ESM-SAP - Invalid ESM data structure"); + LOG_FUNC_RETURN (ESM_CAUSE_PROTOCOL_ERROR); } /* Get the PDN connectivity request type */ int request_type = -1; if (msg->requesttype == REQUEST_TYPE_INITIAL_REQUEST) { - request_type = ESM_PDN_REQUEST_INITIAL; + request_type = ESM_PDN_REQUEST_INITIAL; } else if (msg->requesttype == REQUEST_TYPE_HANDOVER) { - request_type = ESM_PDN_REQUEST_HANDOVER; + request_type = ESM_PDN_REQUEST_HANDOVER; } else if (msg->requesttype == REQUEST_TYPE_EMERGENCY) { - request_type = ESM_PDN_REQUEST_EMERGENCY; + request_type = ESM_PDN_REQUEST_EMERGENCY; } else { - /* Unkown PDN request type */ - LOG_FUNC_RETURN (ESM_CAUSE_INVALID_MANDATORY_INFO); + /* Unkown PDN request type */ + LOG_FUNC_RETURN (ESM_CAUSE_INVALID_MANDATORY_INFO); } /* Get the value of the PDN type indicator */ if (msg->pdntype == PDN_TYPE_IPV4) { - esm_data->pdn_type = ESM_PDN_TYPE_IPV4; + esm_data->pdn_type = ESM_PDN_TYPE_IPV4; } else if (msg->pdntype == PDN_TYPE_IPV6) { - esm_data->pdn_type = ESM_PDN_TYPE_IPV6; + esm_data->pdn_type = ESM_PDN_TYPE_IPV6; } else if (msg->pdntype == PDN_TYPE_IPV4V6) { - esm_data->pdn_type = ESM_PDN_TYPE_IPV4V6; + esm_data->pdn_type = ESM_PDN_TYPE_IPV4V6; } else { - /* Unkown PDN type */ - LOG_FUNC_RETURN (ESM_CAUSE_UNKNOWN_PDN_TYPE); + /* Unkown PDN type */ + LOG_FUNC_RETURN (ESM_CAUSE_UNKNOWN_PDN_TYPE); } /* Get the Access Point Name, if provided */ - if (msg->presencemask & PDN_CONNECTIVITY_REQUEST_ACCESS_POINT_NAME_PRESENT) - { - esm_data->apn = msg->accesspointname.accesspointnamevalue; + 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) - { - /* 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 - * between the UE and the MME. - * - * The MME then at a later stage in the PDN connectivity procedure - * initiates the ESM information request procedure in which the UE - * can provide the MME with protocol configuration options or APN - * or both. - * The MME waits for completion of the ESM information request - * procedure before proceeding with the PDN connectivity procedure. - */ - //TODO: rc = esm_proc_information_request(); + 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 + * between the UE and the MME. + * + * The MME then at a later stage in the PDN connectivity procedure + * initiates the ESM information request procedure in which the UE + * can provide the MME with protocol configuration options or APN + * or both. + * The MME waits for completion of the ESM information request + * procedure before proceeding with the PDN connectivity procedure. + */ + //TODO: rc = esm_proc_information_request(); } /* Execute the PDN connectivity procedure requested by the UE */ int pid = esm_proc_pdn_connectivity_request(ueid, pti, request_type, - &esm_data->apn, - esm_data->pdn_type, - &esm_data->pdn_addr, - &esm_data->qos, - &esm_cause); + &esm_data->apn, + esm_data->pdn_type, + &esm_data->pdn_addr, + &esm_data->qos, + &esm_cause); if (pid != RETURNerror) { - /* Create local default EPS bearer context */ - int rc = esm_proc_default_eps_bearer_context(ueid, pid, new_ebi, - &esm_data->qos, &esm_cause); - if (rc != RETURNerror) { - esm_cause = ESM_CAUSE_SUCCESS; - } + /* Create local default EPS bearer context */ + int rc = esm_proc_default_eps_bearer_context(ueid, pid, new_ebi, + &esm_data->qos, &esm_cause); + if (rc != RETURNerror) { + esm_cause = ESM_CAUSE_SUCCESS; + } } /* Return the ESM cause value */ @@ -800,54 +786,54 @@ int esm_recv_pdn_connectivity_request(unsigned int ueid, int pti, int ebi, /**************************************************************************** ** ** - ** Name: esm_recv_pdn_disconnect_request() ** + ** Name: esm_recv_pdn_disconnect_request() ** ** ** ** Description: Processes PDN disconnect request message ** ** ** - ** Inputs: ueid: UE local identifier ** - ** pti: Procedure transaction identity ** - ** ebi: EPS bearer identity ** - ** msg: The received ESM message ** - ** Others: None ** + ** Inputs: ueid: UE local identifier ** + ** pti: Procedure transaction identity ** + ** ebi: EPS bearer identity ** + ** msg: The received ESM message ** + ** Others: None ** ** ** - ** Outputs: linked_ebi: Linked EPS bearer identity of the default ** - ** bearer associated with the PDN to discon- ** - ** nect from ** - ** Return: ESM cause code whenever the processing of ** - ** the ESM message fails ** - ** Others: None ** + ** Outputs: linked_ebi: Linked EPS bearer identity of the default ** + ** bearer associated with the PDN to discon- ** + ** nect from ** + ** Return: ESM cause code whenever the processing of ** + ** the ESM message fails ** + ** Others: None ** ** ** ***************************************************************************/ 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; int esm_cause = ESM_CAUSE_SUCCESS; LOG_TRACE(INFO, "ESM-SAP - Received PDN Disconnect Request message " - "(ueid=%d, pti=%d, ebi=%d)", ueid, pti, ebi); + "(ueid=%d, pti=%d, ebi=%d)", ueid, pti, ebi); /* * Procedure transaction identity checking */ if ( (pti == ESM_PT_UNASSIGNED) || esm_pt_is_reserved(pti) ) { - /* 3GPP TS 24.301, section 7.3.1, case b - * Reserved or unassigned PTI value - */ - LOG_TRACE(WARNING, "ESM-SAP - Invalid PTI value (pti=%d)", pti); - LOG_FUNC_RETURN (ESM_CAUSE_INVALID_PTI_VALUE); + /* 3GPP TS 24.301, section 7.3.1, case b + * Reserved or unassigned PTI value + */ + LOG_TRACE(WARNING, "ESM-SAP - Invalid PTI value (pti=%d)", pti); + LOG_FUNC_RETURN (ESM_CAUSE_INVALID_PTI_VALUE); } /* * EPS bearer identity checking */ else if ( ebi != ESM_EBI_UNASSIGNED ) { - /* 3GPP TS 24.301, section 7.3.2, case b - * Reserved or assigned EPS bearer identity value */ - LOG_TRACE(WARNING, "ESM-SAP - Invalid EPS bearer identity (ebi=%d)", - ebi); - LOG_FUNC_RETURN (ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY); + /* 3GPP TS 24.301, section 7.3.2, case b + * Reserved or assigned EPS bearer identity value */ + LOG_TRACE(WARNING, "ESM-SAP - Invalid EPS bearer identity (ebi=%d)", + ebi); + LOG_FUNC_RETURN (ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY); } /* @@ -856,17 +842,17 @@ int esm_recv_pdn_disconnect_request(unsigned int ueid, int pti, int ebi, /* Execute the PDN disconnect procedure requested by the UE */ int pid = esm_proc_pdn_disconnect_request(ueid, pti, &esm_cause); if (pid != RETURNerror) { - /* Get the identity of the default EPS bearer context assigned to - * the PDN connection to disconnect from */ - *linked_ebi = msg->linkedepsbeareridentity; - /* Release the associated default EPS bearer context */ - int bid = 0; - int rc = esm_proc_eps_bearer_context_deactivate(ueid, FALSE, - *linked_ebi, - &pid, &bid, &esm_cause); - if (rc != RETURNerror) { - esm_cause = ESM_CAUSE_SUCCESS; - } + /* Get the identity of the default EPS bearer context assigned to + * the PDN connection to disconnect from */ + *linked_ebi = msg->linkedepsbeareridentity; + /* Release the associated default EPS bearer context */ + int bid = 0; + int rc = esm_proc_eps_bearer_context_deactivate(ueid, FALSE, + *linked_ebi, + &pid, &bid, &esm_cause); + if (rc != RETURNerror) { + esm_cause = ESM_CAUSE_SUCCESS; + } } /* Return the ESM cause value */ @@ -875,64 +861,64 @@ int esm_recv_pdn_disconnect_request(unsigned int ueid, int pti, int ebi, /**************************************************************************** ** ** - ** Name: esm_recv_activate_default_eps_bearer_context_accept() ** + ** Name: esm_recv_activate_default_eps_bearer_context_accept() ** ** ** ** Description: Processes Activate Default EPS Bearer Context Accept ** - ** message ** + ** message ** ** ** - ** Inputs: ueid: UE local identifier ** - ** pti: Procedure transaction identity ** - ** ebi: EPS bearer identity ** - ** msg: The received ESM message ** - ** Others: None ** + ** Inputs: ueid: UE local identifier ** + ** pti: Procedure transaction identity ** + ** ebi: EPS bearer identity ** + ** msg: The received ESM message ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: ESM cause code whenever the processing of ** - ** the ESM message fails ** - ** Others: None ** + ** Outputs: None ** + ** Return: ESM cause code whenever the processing of ** + ** the ESM message fails ** + ** Others: None ** ** ** ***************************************************************************/ 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 pti, int ebi, + const activate_default_eps_bearer_context_accept_msg *msg) { LOG_FUNC_IN; int esm_cause = ESM_CAUSE_SUCCESS; LOG_TRACE(INFO, "ESM-SAP - Received Activate Default EPS Bearer Context " - "Accept message (ueid=%d, pti=%d, ebi=%d)", ueid, pti, ebi); + "Accept message (ueid=%d, pti=%d, ebi=%d)", ueid, pti, ebi); /* * Procedure transaction identity checking */ if (esm_pt_is_reserved(pti)) { - /* 3GPP TS 24.301, section 7.3.1, case f - * Reserved PTI value - */ - LOG_TRACE(WARNING, "ESM-SAP - Invalid PTI value (pti=%d)", pti); - LOG_FUNC_RETURN (ESM_CAUSE_INVALID_PTI_VALUE); + /* 3GPP TS 24.301, section 7.3.1, case f + * Reserved PTI value + */ + LOG_TRACE(WARNING, "ESM-SAP - Invalid PTI value (pti=%d)", pti); + LOG_FUNC_RETURN (ESM_CAUSE_INVALID_PTI_VALUE); } /* * EPS bearer identity checking */ else if ( esm_ebr_is_reserved(ebi) || esm_ebr_is_not_in_use(ueid, ebi) ) { - /* 3GPP TS 24.301, section 7.3.2, case f - * Reserved or assigned value that does not match an existing EPS - * bearer context - */ - LOG_TRACE(WARNING, "ESM-SAP - Invalid EPS bearer identity (ebi=%d)", - ebi); - LOG_FUNC_RETURN (ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY); + /* 3GPP TS 24.301, section 7.3.2, case f + * Reserved or assigned value that does not match an existing EPS + * bearer context + */ + LOG_TRACE(WARNING, "ESM-SAP - Invalid EPS bearer identity (ebi=%d)", + ebi); + LOG_FUNC_RETURN (ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY); } /* * Message processing */ - /* Execute the default EPS bearer context activation procedure accepted - * by the UE */ + /* Execute the default EPS bearer context activation procedure accepted + * by the UE */ int rc = esm_proc_default_eps_bearer_context_accept(ueid, ebi, &esm_cause); if (rc != RETURNerror) { - esm_cause = ESM_CAUSE_SUCCESS; + esm_cause = ESM_CAUSE_SUCCESS; } /* Return the ESM cause value */ @@ -941,64 +927,64 @@ int esm_recv_activate_default_eps_bearer_context_accept(unsigned int ueid, /**************************************************************************** ** ** - ** Name: esm_recv_activate_default_eps_bearer_context_reject() ** + ** Name: esm_recv_activate_default_eps_bearer_context_reject() ** ** ** ** Description: Processes Activate Default EPS Bearer Context Reject ** - ** message ** + ** message ** ** ** - ** Inputs: ueid: UE local identifier ** - ** pti: Procedure transaction identity ** - ** ebi: EPS bearer identity ** - ** msg: The received ESM message ** - ** Others: None ** + ** Inputs: ueid: UE local identifier ** + ** pti: Procedure transaction identity ** + ** ebi: EPS bearer identity ** + ** msg: The received ESM message ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: ESM cause code whenever the processing of ** - ** the ESM message fail ** - ** Others: None ** + ** Outputs: None ** + ** Return: ESM cause code whenever the processing of ** + ** the ESM message fail ** + ** Others: None ** ** ** ***************************************************************************/ 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 pti, int ebi, + const activate_default_eps_bearer_context_reject_msg *msg) { LOG_FUNC_IN; int esm_cause = ESM_CAUSE_SUCCESS; LOG_TRACE(INFO, "ESM-SAP - Received Activate Default EPS Bearer Context " - "Reject message (ueid=%d, pti=%d, ebi=%d)", ueid, pti, ebi); + "Reject message (ueid=%d, pti=%d, ebi=%d)", ueid, pti, ebi); /* * Procedure transaction identity checking */ if (esm_pt_is_reserved(pti)) { - /* 3GPP TS 24.301, section 7.3.1, case f - * Reserved PTI value - */ - LOG_TRACE(WARNING, "ESM-SAP - Invalid PTI value (pti=%d)", pti); - LOG_FUNC_RETURN (ESM_CAUSE_INVALID_PTI_VALUE); + /* 3GPP TS 24.301, section 7.3.1, case f + * Reserved PTI value + */ + LOG_TRACE(WARNING, "ESM-SAP - Invalid PTI value (pti=%d)", pti); + LOG_FUNC_RETURN (ESM_CAUSE_INVALID_PTI_VALUE); } /* * EPS bearer identity checking */ else if ( esm_ebr_is_reserved(ebi) || esm_ebr_is_not_in_use(ueid, ebi) ) { - /* 3GPP TS 24.301, section 7.3.2, case f - * Reserved or assigned value that does not match an existing EPS - * bearer context - */ - LOG_TRACE(WARNING, "ESM-SAP - Invalid EPS bearer identity (ebi=%d)", - ebi); - LOG_FUNC_RETURN (ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY); + /* 3GPP TS 24.301, section 7.3.2, case f + * Reserved or assigned value that does not match an existing EPS + * bearer context + */ + LOG_TRACE(WARNING, "ESM-SAP - Invalid EPS bearer identity (ebi=%d)", + ebi); + LOG_FUNC_RETURN (ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY); } /* * Message processing */ - /* Execute the default EPS bearer context activation procedure not accepted - * by the UE */ + /* Execute the default EPS bearer context activation procedure not accepted + * by the UE */ int rc = esm_proc_default_eps_bearer_context_reject(ueid, ebi, &esm_cause); if (rc != RETURNerror) { - esm_cause = ESM_CAUSE_SUCCESS; + esm_cause = ESM_CAUSE_SUCCESS; } /* Return the ESM cause value */ @@ -1007,66 +993,66 @@ int esm_recv_activate_default_eps_bearer_context_reject(unsigned int ueid, /**************************************************************************** ** ** - ** Name: esm_recv_activate_dedicated_eps_bearer_context_accept() ** + ** Name: esm_recv_activate_dedicated_eps_bearer_context_accept() ** ** ** ** Description: Processes Activate Dedicated EPS Bearer Context Accept ** - ** message ** + ** message ** ** ** - ** Inputs: ueid: UE local identifier ** - ** pti: Procedure transaction identity ** - ** ebi: EPS bearer identity ** - ** msg: The received ESM message ** - ** Others: None ** + ** Inputs: ueid: UE local identifier ** + ** pti: Procedure transaction identity ** + ** ebi: EPS bearer identity ** + ** msg: The received ESM message ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: ESM cause code whenever the processing of ** - ** the ESM message fails ** - ** Others: None ** + ** Outputs: None ** + ** Return: ESM cause code whenever the processing of ** + ** the ESM message fails ** + ** Others: None ** ** ** ***************************************************************************/ 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 pti, int ebi, + const activate_dedicated_eps_bearer_context_accept_msg *msg) { LOG_FUNC_IN; int esm_cause = ESM_CAUSE_SUCCESS; LOG_TRACE(INFO, "ESM-SAP - Received Activate Dedicated EPS Bearer " - "Context Accept message (ueid=%d, pti=%d, ebi=%d)", - ueid, pti, ebi); + "Context Accept message (ueid=%d, pti=%d, ebi=%d)", + ueid, pti, ebi); /* * Procedure transaction identity checking */ if (esm_pt_is_reserved(pti)) { - /* 3GPP TS 24.301, section 7.3.1, case f - * Reserved PTI value - */ - LOG_TRACE(WARNING, "ESM-SAP - Invalid PTI value (pti=%d)", pti); - LOG_FUNC_RETURN (ESM_CAUSE_INVALID_PTI_VALUE); + /* 3GPP TS 24.301, section 7.3.1, case f + * Reserved PTI value + */ + LOG_TRACE(WARNING, "ESM-SAP - Invalid PTI value (pti=%d)", pti); + LOG_FUNC_RETURN (ESM_CAUSE_INVALID_PTI_VALUE); } /* * EPS bearer identity checking */ else if ( esm_ebr_is_reserved(ebi) || esm_ebr_is_not_in_use(ueid, ebi) ) { - /* 3GPP TS 24.301, section 7.3.2, case f - * Reserved or assigned value that does not match an existing EPS - * bearer context - */ - LOG_TRACE(WARNING, "ESM-SAP - Invalid EPS bearer identity (ebi=%d)", - ebi); - LOG_FUNC_RETURN (ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY); + /* 3GPP TS 24.301, section 7.3.2, case f + * Reserved or assigned value that does not match an existing EPS + * bearer context + */ + LOG_TRACE(WARNING, "ESM-SAP - Invalid EPS bearer identity (ebi=%d)", + ebi); + LOG_FUNC_RETURN (ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY); } /* * Message processing */ - /* Execute the dedicated EPS bearer context activation procedure accepted - * by the UE */ + /* Execute the dedicated EPS bearer context activation procedure accepted + * by the UE */ int rc = esm_proc_dedicated_eps_bearer_context_accept(ueid, ebi, - &esm_cause); + &esm_cause); if (rc != RETURNerror) { - esm_cause = ESM_CAUSE_SUCCESS; + esm_cause = ESM_CAUSE_SUCCESS; } /* Return the ESM cause value */ @@ -1075,66 +1061,66 @@ int esm_recv_activate_dedicated_eps_bearer_context_accept(unsigned int ueid, /**************************************************************************** ** ** - ** Name: esm_recv_activate_dedicated_eps_bearer_context_reject() ** + ** Name: esm_recv_activate_dedicated_eps_bearer_context_reject() ** ** ** ** Description: Processes Activate Dedicated EPS Bearer Context Reject ** - ** message ** + ** message ** ** ** - ** Inputs: ueid: UE local identifier ** - ** pti: Procedure transaction identity ** - ** ebi: EPS bearer identity ** - ** msg: The received ESM message ** - ** Others: None ** + ** Inputs: ueid: UE local identifier ** + ** pti: Procedure transaction identity ** + ** ebi: EPS bearer identity ** + ** msg: The received ESM message ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: ESM cause code whenever the processing of ** - ** the ESM message fail ** - ** Others: None ** + ** Outputs: None ** + ** Return: ESM cause code whenever the processing of ** + ** the ESM message fail ** + ** Others: None ** ** ** ***************************************************************************/ 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 pti, int ebi, + const activate_dedicated_eps_bearer_context_reject_msg *msg) { LOG_FUNC_IN; int esm_cause = ESM_CAUSE_SUCCESS; LOG_TRACE(INFO, "ESM-SAP - Received Activate Dedicated EPS Bearer " - "Context Reject message (ueid=%d, pti=%d, ebi=%d)", - ueid, pti, ebi); + "Context Reject message (ueid=%d, pti=%d, ebi=%d)", + ueid, pti, ebi); /* * Procedure transaction identity checking */ if (esm_pt_is_reserved(pti)) { - /* 3GPP TS 24.301, section 7.3.1, case f - * Reserved PTI value - */ - LOG_TRACE(WARNING, "ESM-SAP - Invalid PTI value (pti=%d)", pti); - LOG_FUNC_RETURN (ESM_CAUSE_INVALID_PTI_VALUE); + /* 3GPP TS 24.301, section 7.3.1, case f + * Reserved PTI value + */ + LOG_TRACE(WARNING, "ESM-SAP - Invalid PTI value (pti=%d)", pti); + LOG_FUNC_RETURN (ESM_CAUSE_INVALID_PTI_VALUE); } /* * EPS bearer identity checking */ else if ( esm_ebr_is_reserved(ebi) || esm_ebr_is_not_in_use(ueid, ebi) ) { - /* 3GPP TS 24.301, section 7.3.2, case f - * Reserved or assigned value that does not match an existing EPS - * bearer context - */ - LOG_TRACE(WARNING, "ESM-SAP - Invalid EPS bearer identity (ebi=%d)", - ebi); - LOG_FUNC_RETURN (ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY); + /* 3GPP TS 24.301, section 7.3.2, case f + * Reserved or assigned value that does not match an existing EPS + * bearer context + */ + LOG_TRACE(WARNING, "ESM-SAP - Invalid EPS bearer identity (ebi=%d)", + ebi); + LOG_FUNC_RETURN (ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY); } /* * Message processing */ - /* Execute the dedicated EPS bearer context activation procedure not - * accepted by the UE */ + /* Execute the dedicated EPS bearer context activation procedure not + * accepted by the UE */ int rc = esm_proc_dedicated_eps_bearer_context_reject(ueid, ebi, - &esm_cause); + &esm_cause); if (rc != RETURNerror) { - esm_cause = ESM_CAUSE_SUCCESS; + esm_cause = ESM_CAUSE_SUCCESS; } /* Return the ESM cause value */ @@ -1143,69 +1129,69 @@ int esm_recv_activate_dedicated_eps_bearer_context_reject(unsigned int ueid, /**************************************************************************** ** ** - ** Name: esm_recv_deactivate_eps_bearer_context_accept() ** + ** Name: esm_recv_deactivate_eps_bearer_context_accept() ** ** ** ** Description: Processes Deactivate EPS Bearer Context Accept message ** ** ** - ** Inputs: ueid: UE local identifier ** - ** pti: Procedure transaction identity ** - ** ebi: EPS bearer identity ** - ** msg: The received ESM message ** - ** Others: None ** + ** Inputs: ueid: UE local identifier ** + ** pti: Procedure transaction identity ** + ** ebi: EPS bearer identity ** + ** msg: The received ESM message ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: ESM cause code whenever the processing of ** - ** the ESM message fails ** - ** Others: None ** + ** Outputs: None ** + ** Return: ESM cause code whenever the processing of ** + ** the ESM message fails ** + ** Others: None ** ** ** ***************************************************************************/ int esm_recv_deactivate_eps_bearer_context_accept(unsigned int ueid, - int pti, int ebi, - const deactivate_eps_bearer_context_accept_msg* msg) + int pti, int ebi, + const deactivate_eps_bearer_context_accept_msg *msg) { LOG_FUNC_IN; int esm_cause = ESM_CAUSE_SUCCESS; LOG_TRACE(INFO, "ESM-SAP - Received Deactivate EPS Bearer Context " - "Accept message (ueid=%d, pti=%d, ebi=%d)", ueid, pti, ebi); + "Accept message (ueid=%d, pti=%d, ebi=%d)", ueid, pti, ebi); /* * Procedure transaction identity checking */ if (esm_pt_is_reserved(pti)) { - /* 3GPP TS 24.301, section 7.3.1, case f - * Reserved PTI value - */ - LOG_TRACE(WARNING, "ESM-SAP - Invalid PTI value (pti=%d)", pti); - LOG_FUNC_RETURN (ESM_CAUSE_INVALID_PTI_VALUE); + /* 3GPP TS 24.301, section 7.3.1, case f + * Reserved PTI value + */ + LOG_TRACE(WARNING, "ESM-SAP - Invalid PTI value (pti=%d)", pti); + LOG_FUNC_RETURN (ESM_CAUSE_INVALID_PTI_VALUE); } /* * EPS bearer identity checking */ else if ( esm_ebr_is_reserved(ebi) || esm_ebr_is_not_in_use(ueid, ebi) ) { - /* 3GPP TS 24.301, section 7.3.2, case f - * Reserved or assigned value that does not match an existing EPS - * bearer context - */ - LOG_TRACE(WARNING, "ESM-SAP - Invalid EPS bearer identity (ebi=%d)", - ebi); - LOG_FUNC_RETURN (ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY); + /* 3GPP TS 24.301, section 7.3.2, case f + * Reserved or assigned value that does not match an existing EPS + * bearer context + */ + LOG_TRACE(WARNING, "ESM-SAP - Invalid EPS bearer identity (ebi=%d)", + ebi); + LOG_FUNC_RETURN (ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY); } /* * Message processing */ - /* Execute the default EPS bearer context activation procedure accepted - * by the UE */ + /* Execute the default EPS bearer context activation procedure accepted + * by the UE */ int pid = esm_proc_eps_bearer_context_deactivate_accept(ueid, ebi, - &esm_cause); + &esm_cause); if (pid != RETURNerror) { - /* Release all the resources reserved for the PDN */ - int rc = esm_proc_pdn_disconnect_accept(ueid, pid, &esm_cause); + /* Release all the resources reserved for the PDN */ + int rc = esm_proc_pdn_disconnect_accept(ueid, pid, &esm_cause); - if (rc != RETURNerror) { - esm_cause = ESM_CAUSE_SUCCESS; - } + if (rc != RETURNerror) { + esm_cause = ESM_CAUSE_SUCCESS; + } } /* Return the ESM cause value */ diff --git a/openair-cn/NAS/EURECOM-NAS/src/esm/sap/esm_recv.h b/openair-cn/NAS/EURECOM-NAS/src/esm/sap/esm_recv.h index b30d45bd21..cd471f0136 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/esm/sap/esm_recv.h +++ b/openair-cn/NAS/EURECOM-NAS/src/esm/sap/esm_recv.h @@ -1,22 +1,22 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source esm_recv.h +Source esm_recv.h -Version 0.1 +Version 0.1 -Date 2013/02/06 +Date 2013/02/06 -Product NAS stack +Product NAS stack -Subsystem EPS Session Management +Subsystem EPS Session Management -Author Frederic Maurel +Author Frederic Maurel -Description Defines functions executed at the ESM Service Access - Point upon receiving EPS Session Management messages - from the EPS Mobility Management sublayer. +Description Defines functions executed at the ESM Service Access + Point upon receiving EPS Session Management messages + from the EPS Mobility Management sublayer. *****************************************************************************/ #ifndef __ESM_RECV_H__ @@ -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__*/ diff --git a/openair-cn/NAS/EURECOM-NAS/src/esm/sap/esm_sap.c b/openair-cn/NAS/EURECOM-NAS/src/esm/sap/esm_sap.c index 76846a4e3d..5f7ef038e2 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/esm/sap/esm_sap.c +++ b/openair-cn/NAS/EURECOM-NAS/src/esm/sap/esm_sap.c @@ -1,22 +1,22 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source esm_sap.c +Source esm_sap.c -Version 0.1 +Version 0.1 -Date 2012/11/22 +Date 2012/11/22 -Product NAS stack +Product NAS stack -Subsystem EPS Session Management +Subsystem EPS Session Management -Author Frederic Maurel +Author Frederic Maurel -Description Defines the ESM Service Access Points at which the EPS - Session Management sublayer provides procedures for the - EPS bearer context handling and resources allocation. +Description Defines the ESM Service Access Points at which the EPS + Session Management sublayer provides procedures for the + EPS bearer context handling and resources allocation. *****************************************************************************/ @@ -34,7 +34,7 @@ Description Defines the ESM Service Access Points at which the EPS #include "esm_cause.h" #include "esm_proc.h" -#include <string.h> // memset, strlen +#include <string.h> // memset, strlen #include <assert.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", @@ -85,7 +89,7 @@ static const char* _esm_sap_primitive_str[] = { * Buffer used to encode ESM messages before being returned to the EPS * Mobility Management sublayer in order to be sent onto the network */ -#define ESM_SAP_BUFFER_SIZE 4096 +#define ESM_SAP_BUFFER_SIZE 4096 static char _esm_sap_buffer[ESM_SAP_BUFFER_SIZE]; /****************************************************************************/ @@ -94,16 +98,16 @@ static char _esm_sap_buffer[ESM_SAP_BUFFER_SIZE]; /**************************************************************************** ** ** - ** Name: esm_sap_initialize() ** + ** Name: esm_sap_initialize() ** ** ** ** Description: Initializes the ESM Service Access Point state machine ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: None ** - ** Others: NONE ** + ** Outputs: None ** + ** Return: None ** + ** Others: NONE ** ** ** ***************************************************************************/ void esm_sap_initialize(void) @@ -118,19 +122,19 @@ void esm_sap_initialize(void) /**************************************************************************** ** ** - ** Name: esm_sap_send() ** + ** Name: esm_sap_send() ** ** ** ** Description: Processes the ESM Service Access Point primitive ** ** ** - ** Inputs: msg: The ESM-SAP primitive to process ** - ** Others: None ** + ** Inputs: msg: The ESM-SAP primitive to process ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ -int esm_sap_send(esm_sap_t* msg) +int esm_sap_send(esm_sap_t *msg) { LOG_FUNC_IN; @@ -142,221 +146,214 @@ int esm_sap_send(esm_sap_t* msg) assert( (primitive > ESM_START) && (primitive < ESM_END)); LOG_TRACE(INFO, "ESM-SAP - Received primitive %s (%d)", - _esm_sap_primitive_str[primitive - ESM_START - 1], primitive); + _esm_sap_primitive_str[primitive - ESM_START - 1], primitive); - switch (primitive) - { - case ESM_PDN_CONNECTIVITY_REQ: + 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 ) - { - OctetString apn = {0, NULL}; - if (pdn_connect->apn) { - apn.length = strlen(pdn_connect->apn); - apn.value = (uint8_t*)pdn_connect->apn; - } - /* Define new PDN context */ - rc = esm_proc_pdn_connectivity(pdn_connect->cid, TRUE, - pdn_connect->pdn_type, &apn, - pdn_connect->is_emergency, NULL); - if ( msg->is_standalone || (rc != RETURNok) ) { - break; - } - } - if (pdn_connect->is_defined) - { - unsigned int pti; - /* Assign new procedure transaction identity */ - rc = esm_proc_pdn_connectivity(pdn_connect->cid, TRUE, - pdn_connect->pdn_type, NULL, - pdn_connect->is_emergency, &pti); - if (rc != RETURNerror) { - /* Send PDN connectivity request */ - rc = _esm_sap_send(PDN_CONNECTIVITY_REQUEST, - msg->is_standalone, - pti, EPS_BEARER_IDENTITY_UNASSIGNED, - &msg->data, &msg->send); - } - } - } + { + 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; + } + /* Define new PDN context */ + rc = esm_proc_pdn_connectivity(pdn_connect->cid, TRUE, + pdn_connect->pdn_type, &apn, + pdn_connect->is_emergency, NULL); + if ( msg->is_standalone || (rc != RETURNok) ) { + break; + } + } + if (pdn_connect->is_defined) { + unsigned int pti; + /* Assign new procedure transaction identity */ + rc = esm_proc_pdn_connectivity(pdn_connect->cid, TRUE, + pdn_connect->pdn_type, NULL, + pdn_connect->is_emergency, &pti); + if (rc != RETURNerror) { + /* Send PDN connectivity request */ + rc = _esm_sap_send(PDN_CONNECTIVITY_REQUEST, + msg->is_standalone, + pti, EPS_BEARER_IDENTITY_UNASSIGNED, + &msg->data, &msg->send); + } + } + } #endif #ifdef NAS_MME - /* The MME received a PDN connectivity request message */ - rc = _esm_sap_recv(PDN_CONNECTIVITY_REQUEST, msg->is_standalone, - msg->ueid, msg->recv, &msg->send, &msg->err); + /* The MME received a PDN connectivity request message */ + rc = _esm_sap_recv(PDN_CONNECTIVITY_REQUEST, msg->is_standalone, + msg->ueid, msg->recv, &msg->send, &msg->err); #endif - break; + break; - case ESM_PDN_CONNECTIVITY_REJ: + case ESM_PDN_CONNECTIVITY_REJ: #ifdef NAS_MME - /* PDN connectivity locally failed */ - pid = esm_proc_default_eps_bearer_context_failure(msg->ueid); - if (pid != RETURNerror) { - rc = esm_proc_pdn_connectivity_failure(msg->ueid, pid); - } + /* PDN connectivity locally failed */ + pid = esm_proc_default_eps_bearer_context_failure(msg->ueid); + if (pid != RETURNerror) { + rc = esm_proc_pdn_connectivity_failure(msg->ueid, pid); + } #endif #ifdef NAS_UE - { - 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) { - /* 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 { - /* The PDN connectivity procedure locally failed */ - rc = esm_proc_pdn_connectivity_failure(TRUE); - } - } + { + 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) { + /* 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 { + /* The PDN connectivity procedure locally failed */ + rc = esm_proc_pdn_connectivity_failure(TRUE); + } + } #endif - break; + break; - case ESM_PDN_DISCONNECT_REQ: + case ESM_PDN_DISCONNECT_REQ: #ifdef NAS_UE - { - unsigned int pti, ebi; - /* Get the procedure transaction identity and the EPS bearer - * identity of the default bearer assigned to the PDN to - * disconnect from */ - rc = esm_proc_pdn_disconnect(msg->data.pdn_disconnect.cid, - &pti, &ebi); - if (rc != RETURNerror) { - /* Send PDN disconnect request */ - rc = _esm_sap_send(PDN_DISCONNECT_REQUEST, TRUE, pti, ebi, - &msg->data, &msg->send); - } - } + { + unsigned int pti, ebi; + /* Get the procedure transaction identity and the EPS bearer + * identity of the default bearer assigned to the PDN to + * disconnect from */ + rc = esm_proc_pdn_disconnect(msg->data.pdn_disconnect.cid, + &pti, &ebi); + if (rc != RETURNerror) { + /* Send PDN disconnect request */ + rc = _esm_sap_send(PDN_DISCONNECT_REQUEST, TRUE, pti, ebi, + &msg->data, &msg->send); + } + } #endif - break; + break; - case ESM_PDN_DISCONNECT_REJ: - break; + case ESM_PDN_DISCONNECT_REJ: + break; - case ESM_BEARER_RESOURCE_ALLOCATE_REQ: - break; + case ESM_BEARER_RESOURCE_ALLOCATE_REQ: + break; - case ESM_BEARER_RESOURCE_ALLOCATE_REJ: - break; + case ESM_BEARER_RESOURCE_ALLOCATE_REJ: + break; - case ESM_BEARER_RESOURCE_MODIFY_REQ: - break; + case ESM_BEARER_RESOURCE_MODIFY_REQ: + break; - case ESM_BEARER_RESOURCE_MODIFY_REJ: - break; + case ESM_BEARER_RESOURCE_MODIFY_REJ: + break; - case ESM_DEFAULT_EPS_BEARER_CONTEXT_ACTIVATE_REQ: + case ESM_DEFAULT_EPS_BEARER_CONTEXT_ACTIVATE_REQ: #ifdef NAS_UE - /* The UE received activate default ESP bearer context request */ - rc = _esm_sap_recv(ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST, - msg->is_standalone, - msg->recv, &msg->send, &msg->err); + /* The UE received activate default ESP bearer context request */ + rc = _esm_sap_recv(ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST, + msg->is_standalone, + msg->recv, &msg->send, &msg->err); #endif - break; + break; - case ESM_DEFAULT_EPS_BEARER_CONTEXT_ACTIVATE_CNF: + case ESM_DEFAULT_EPS_BEARER_CONTEXT_ACTIVATE_CNF: #ifdef NAS_MME - /* The MME received activate default ESP bearer context accept */ - rc = _esm_sap_recv(ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_ACCEPT, - msg->is_standalone, msg->ueid, - msg->recv, &msg->send, &msg->err); + /* The MME received activate default ESP bearer context accept */ + rc = _esm_sap_recv(ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_ACCEPT, + msg->is_standalone, msg->ueid, + msg->recv, &msg->send, &msg->err); #endif #ifdef NAS_UE - /* - * The activate default ESP bearer context accept message - * has been successfully delivered to the other side - */ - rc = esm_proc_default_eps_bearer_context_complete(); - if (rc != RETURNerror) { - rc = esm_proc_pdn_connectivity_complete(); - } + /* + * The activate default ESP bearer context accept message + * has been successfully delivered to the other side + */ + rc = esm_proc_default_eps_bearer_context_complete(); + if (rc != RETURNerror) { + rc = esm_proc_pdn_connectivity_complete(); + } #endif - break; + break; - case ESM_DEFAULT_EPS_BEARER_CONTEXT_ACTIVATE_REJ: + case ESM_DEFAULT_EPS_BEARER_CONTEXT_ACTIVATE_REJ: #ifdef NAS_MME - /* The MME received activate default ESP bearer context reject */ - rc = _esm_sap_recv(ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REJECT, - msg->is_standalone, msg->ueid, - msg->recv, &msg->send, &msg->err); + /* The MME received activate default ESP bearer context reject */ + rc = _esm_sap_recv(ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REJECT, + msg->is_standalone, msg->ueid, + msg->recv, &msg->send, &msg->err); #endif #ifdef NAS_UE - /* - * Default ESP bearer context activation procedure locally failed - */ - rc = esm_proc_default_eps_bearer_context_failure(); - if (rc != RETURNerror) { - rc = esm_proc_pdn_connectivity_failure(FALSE); - } + /* + * Default ESP bearer context activation procedure locally failed + */ + rc = esm_proc_default_eps_bearer_context_failure(); + if (rc != RETURNerror) { + rc = esm_proc_pdn_connectivity_failure(FALSE); + } #endif - break; + break; - case ESM_DEDICATED_EPS_BEARER_CONTEXT_ACTIVATE_REQ: - break; + case ESM_DEDICATED_EPS_BEARER_CONTEXT_ACTIVATE_REQ: + break; - case ESM_DEDICATED_EPS_BEARER_CONTEXT_ACTIVATE_CNF: - break; + case ESM_DEDICATED_EPS_BEARER_CONTEXT_ACTIVATE_CNF: + break; - case ESM_DEDICATED_EPS_BEARER_CONTEXT_ACTIVATE_REJ: - break; + case ESM_DEDICATED_EPS_BEARER_CONTEXT_ACTIVATE_REJ: + break; - case ESM_EPS_BEARER_CONTEXT_MODIFY_REQ: - break; + case ESM_EPS_BEARER_CONTEXT_MODIFY_REQ: + break; - case ESM_EPS_BEARER_CONTEXT_MODIFY_CNF: - break; + case ESM_EPS_BEARER_CONTEXT_MODIFY_CNF: + break; - case ESM_EPS_BEARER_CONTEXT_MODIFY_REJ: - break; + case ESM_EPS_BEARER_CONTEXT_MODIFY_REJ: + break; - case ESM_EPS_BEARER_CONTEXT_DEACTIVATE_REQ: - { - int bid; - /* - * Locally deactivate EPS bearer context - */ + case ESM_EPS_BEARER_CONTEXT_DEACTIVATE_REQ: { + int bid; + /* + * Locally deactivate EPS bearer context + */ #ifdef NAS_UE - rc = esm_proc_eps_bearer_context_deactivate(TRUE, - msg->data.eps_bearer_context_deactivate.ebi, &pid, &bid); + rc = esm_proc_eps_bearer_context_deactivate(TRUE, + msg->data.eps_bearer_context_deactivate.ebi, &pid, &bid); #endif #ifdef NAS_MME - rc = esm_proc_eps_bearer_context_deactivate(msg->ueid, TRUE, - msg->data.eps_bearer_context_deactivate.ebi, - &pid, &bid, NULL); + rc = esm_proc_eps_bearer_context_deactivate(msg->ueid, TRUE, + msg->data.eps_bearer_context_deactivate.ebi, + &pid, &bid, NULL); #endif - } - break; + } + break; - case ESM_EPS_BEARER_CONTEXT_DEACTIVATE_CNF: - break; + case ESM_EPS_BEARER_CONTEXT_DEACTIVATE_CNF: + break; - case ESM_UNITDATA_IND: + case ESM_UNITDATA_IND: #ifdef NAS_UE - rc = _esm_sap_recv(-1, msg->is_standalone, msg->recv, - &msg->send, &msg->err); + rc = _esm_sap_recv(-1, msg->is_standalone, msg->recv, + &msg->send, &msg->err); #endif #ifdef NAS_MME - rc = _esm_sap_recv(-1, msg->is_standalone, msg->ueid, - msg->recv, &msg->send, &msg->err); + rc = _esm_sap_recv(-1, msg->is_standalone, msg->ueid, + msg->recv, &msg->send, &msg->err); #endif - break; + break; - default: - break; + default: + break; } #ifdef NAS_MME - if (rc != RETURNok) { - LOG_TRACE(ERROR, "ESM-SAP - Failed to process primitive %s (%d)", - _esm_sap_primitive_str[primitive - ESM_START - 1], primitive); + if (rc != RETURNok) { + LOG_TRACE(ERROR, "ESM-SAP - Failed to process primitive %s (%d)", + _esm_sap_primitive_str[primitive - ESM_START - 1], primitive); } #endif @@ -369,40 +366,40 @@ int esm_sap_send(esm_sap_t* msg) /**************************************************************************** ** ** - ** Name: _esm_sap_recv() ** + ** Name: _esm_sap_recv() ** ** ** ** Description: Processes ESM messages received from the network: Decodes ** - ** the message and checks whether it is of the expected ty- ** - ** pe, checks the validity of the procedure transaction iden-** - ** tity, checks the validity of the EPS bearer identity, and ** - ** parses the message content. ** - ** If no protocol error is found the ESM response message is ** - ** returned in order to be sent back onto the network upon ** - ** the relevant ESM procedure completion. ** - ** If a protocol error is found the ESM status message is ** - ** returned including the value of the ESM cause code. ** + ** the message and checks whether it is of the expected ty- ** + ** pe, checks the validity of the procedure transaction iden-** + ** tity, checks the validity of the EPS bearer identity, and ** + ** parses the message content. ** + ** If no protocol error is found the ESM response message is ** + ** returned in order to be sent back onto the network upon ** + ** the relevant ESM procedure completion. ** + ** If a protocol error is found the ESM status message is ** + ** returned including the value of the ESM cause code. ** ** ** - ** Inputs: msg_type: Expected type of the received ESM message ** - ** is_standalone: Indicates whether the ESM message has been ** - ** received standalone or together within EMM ** - ** attach related message ** - ** ueid: UE identifier within the MME ** - ** req: The encoded ESM request message to process ** - ** Others: None ** + ** Inputs: msg_type: Expected type of the received ESM message ** + ** is_standalone: Indicates whether the ESM message has been ** + ** received standalone or together within EMM ** + ** attach related message ** + ** ueid: UE identifier within the MME ** + ** req: The encoded ESM request message to process ** + ** Others: None ** ** ** - ** Outputs: rsp: The encoded ESM response message to be re- ** - ** turned upon ESM procedure completion ** - ** err: Error code of the ESM procedure ** - ** Return: RETURNok, RETURNerror ** - ** Others: _esm_sap_buffer ** + ** Outputs: rsp: The encoded ESM response message to be re- ** + ** turned upon ESM procedure completion ** + ** err: Error code of the ESM procedure ** + ** Return: RETURNok, RETURNerror ** + ** Others: _esm_sap_buffer ** ** ** ***************************************************************************/ static int _esm_sap_recv(int msg_type, int is_standalone, #ifdef NAS_MME - unsigned int ueid, + 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; @@ -418,39 +415,38 @@ static int _esm_sap_recv(int msg_type, int is_standalone, /* Process decoding errors */ if (decoder_rc < 0) { - /* 3GPP TS 24.301, section 7.2 - * Ignore received message that is too short to contain a complete - * message type information element */ - if (decoder_rc == TLV_DECODE_BUFFER_TOO_SHORT) { - LOG_TRACE(WARNING, "ESM-SAP - Discard message too short to " - "contain a complete message type IE"); - /* Return indication that received message has been discarded */ - *err = ESM_SAP_DISCARDED; - LOG_FUNC_RETURN (RETURNok); - } - /* 3GPP TS 24.301, section 7.2 - * Unknown or unforeseen message type */ - else if (decoder_rc == TLV_DECODE_WRONG_MESSAGE_TYPE) { - esm_cause = ESM_CAUSE_MESSAGE_TYPE_NOT_IMPLEMENTED; - } - /* 3GPP TS 24.301, section 7.7.2 - * Conditional IE errors */ - else if (decoder_rc == TLV_DECODE_UNEXPECTED_IEI) { - esm_cause = ESM_CAUSE_CONDITIONAL_IE_ERROR; - } - else { - esm_cause = ESM_CAUSE_PROTOCOL_ERROR; - } + /* 3GPP TS 24.301, section 7.2 + * Ignore received message that is too short to contain a complete + * message type information element */ + if (decoder_rc == TLV_DECODE_BUFFER_TOO_SHORT) { + LOG_TRACE(WARNING, "ESM-SAP - Discard message too short to " + "contain a complete message type IE"); + /* Return indication that received message has been discarded */ + *err = ESM_SAP_DISCARDED; + LOG_FUNC_RETURN (RETURNok); + } + /* 3GPP TS 24.301, section 7.2 + * Unknown or unforeseen message type */ + else if (decoder_rc == TLV_DECODE_WRONG_MESSAGE_TYPE) { + esm_cause = ESM_CAUSE_MESSAGE_TYPE_NOT_IMPLEMENTED; + } + /* 3GPP TS 24.301, section 7.7.2 + * Conditional IE errors */ + else if (decoder_rc == TLV_DECODE_UNEXPECTED_IEI) { + esm_cause = ESM_CAUSE_CONDITIONAL_IE_ERROR; + } else { + esm_cause = ESM_CAUSE_PROTOCOL_ERROR; + } } /* Check the type of the ESM message actually received */ else if ( (msg_type > 0) && (msg_type != esm_msg.header.message_type) ) { - if (esm_msg.header.message_type != ESM_STATUS) { - /* Semantically incorrect ESM message */ - LOG_TRACE(ERROR, "ESM-SAP - Received ESM message 0x%x is not " - "of the expected type (0x%x)", - esm_msg.header.message_type, msg_type); - esm_cause = ESM_CAUSE_SEMANTICALLY_INCORRECT; - } + if (esm_msg.header.message_type != ESM_STATUS) { + /* Semantically incorrect ESM message */ + LOG_TRACE(ERROR, "ESM-SAP - Received ESM message 0x%x is not " + "of the expected type (0x%x)", + esm_msg.header.message_type, msg_type); + esm_cause = ESM_CAUSE_SEMANTICALLY_INCORRECT; + } } /* Get the procedure transaction identity */ @@ -465,514 +461,493 @@ static int _esm_sap_recv(int msg_type, int is_standalone, int is_discarded = FALSE; if (esm_cause != ESM_CAUSE_SUCCESS) { - LOG_TRACE(ERROR, "ESM-SAP - Failed to decode expected ESM message " - "0x%x", msg_type); + LOG_TRACE(ERROR, "ESM-SAP - Failed to decode expected ESM message " + "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: - /* - * Process activate default EPS bearer context request message - * received from the MME - */ - esm_cause = esm_recv_activate_default_eps_bearer_context_request( - pti, ebi, - &esm_msg.activate_default_eps_bearer_context_request); - - if ( (esm_cause == ESM_CAUSE_SUCCESS) || - (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); - /* Setup the callback function used to send activate default - * EPS bearer context accept message onto the network */ - esm_procedure = esm_proc_default_eps_bearer_context_accept; - if (esm_cause == ESM_CAUSE_PTI_ALREADY_IN_USE) { - /* 3GPP TS 24.301, section 7.3.1, case g - * Return accept message, even to network retransmission - * of already accepted activate default EPS bearer context - * request message - */ - is_discarded = TRUE; - } - } - else { - /* Return reject message */ - rc = esm_send_activate_default_eps_bearer_context_reject(ebi, - &esm_msg.activate_default_eps_bearer_context_reject, - esm_cause); - /* Setup the callback function used to send activate default - * EPS bearer context reject message onto the network */ - esm_procedure = esm_proc_default_eps_bearer_context_reject; - } - break; - - case ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST: - /* - * Process activate dedicated EPS bearer context request message - * received from the MME - */ - esm_cause = esm_recv_activate_dedicated_eps_bearer_context_request( - pti, ebi, - &esm_msg.activate_dedicated_eps_bearer_context_request); - - if ( (esm_cause == ESM_CAUSE_SUCCESS) || - (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); - /* Setup the callback function used to send activate dedicated - * EPS bearer context accept message onto the network */ - esm_procedure = esm_proc_dedicated_eps_bearer_context_accept; - if (esm_cause == ESM_CAUSE_PTI_ALREADY_IN_USE) { - /* 3GPP TS 24.301, section 7.3.1, case i - * Return accept message, even to network retransmission - * of already accepted activate dedicated EPS bearer context - * request message - */ - is_discarded = TRUE; - } - } - else { - /* Return reject message */ - rc = esm_send_activate_dedicated_eps_bearer_context_reject(ebi, - &esm_msg.activate_dedicated_eps_bearer_context_reject, - esm_cause); - /* Setup the callback function used to send activate dedicated - * EPS bearer context reject message onto the network */ - esm_procedure = esm_proc_dedicated_eps_bearer_context_reject; - } - break; - - case MODIFY_EPS_BEARER_CONTEXT_REQUEST: - break; - - case DEACTIVATE_EPS_BEARER_CONTEXT_REQUEST: - /* - * Process deactivate EPS bearer context request message - * received from the MME - */ - esm_cause = esm_recv_deactivate_eps_bearer_context_request(pti, ebi, - &esm_msg.deactivate_eps_bearer_context_request); - - if ( (esm_cause == ESM_CAUSE_INVALID_PTI_VALUE) || - (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) ) - { - /* Return accept message */ - rc = esm_send_deactivate_eps_bearer_context_accept(ebi, - &esm_msg.deactivate_eps_bearer_context_accept); - /* Setup the callback function used to send deactivate - * EPS bearer context accept message onto the network */ - esm_procedure = esm_proc_eps_bearer_context_deactivate_accept; - if (esm_cause == ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY) { - /* 3GPP TS 24.301, section 7.3.2, case j - * Respond with a deactivate EPS bearer context accept - * message with the EPS bearer identity set to the received - * EPS bearer identity - */ - is_discarded = TRUE; - } - } - break; - - case PDN_CONNECTIVITY_REJECT: - /* - * Process PDN connectivity reject message received from the MME - */ - esm_cause = esm_recv_pdn_connectivity_reject(pti, ebi, - &esm_msg.pdn_connectivity_reject); - - if ( (esm_cause == ESM_CAUSE_INVALID_PTI_VALUE) || - (esm_cause == ESM_CAUSE_PTI_MISMATCH) || - (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 - * does not match any PTI in use - * 3GPP TS 24.301, section 7.3.2, case a - * Ignore PDN connectivity reject message received with - * reserved or unassigned EPS bearer identity value - */ - is_discarded = TRUE; - } - break; - - case PDN_DISCONNECT_REJECT: - /* - * Process PDN disconnect reject message received from the MME - */ - esm_cause = esm_recv_pdn_disconnect_reject(pti, ebi, - &esm_msg.pdn_disconnect_reject); - - if ( (esm_cause == ESM_CAUSE_INVALID_PTI_VALUE) || - (esm_cause == ESM_CAUSE_PTI_MISMATCH) || - (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 - * does not match any PTI in use - * 3GPP TS 24.301, section 7.3.2, case b - * Ignore PDN disconnect reject message received with - * reserved or unassigned EPS bearer identity value - */ - is_discarded = TRUE; - } - break; - - case BEARER_RESOURCE_ALLOCATION_REJECT: - break; - - case BEARER_RESOURCE_MODIFICATION_REJECT: - break; - - case ESM_INFORMATION_REQUEST: - break; - - case ESM_STATUS: - /* - * Process received ESM status message - */ - esm_cause = esm_recv_status(pti, ebi, &esm_msg.esm_status); - break; + case ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST: + /* + * Process activate default EPS bearer context request message + * received from the MME + */ + esm_cause = esm_recv_activate_default_eps_bearer_context_request( + pti, ebi, + &esm_msg.activate_default_eps_bearer_context_request); + + if ( (esm_cause == ESM_CAUSE_SUCCESS) || + (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); + /* Setup the callback function used to send activate default + * EPS bearer context accept message onto the network */ + esm_procedure = esm_proc_default_eps_bearer_context_accept; + if (esm_cause == ESM_CAUSE_PTI_ALREADY_IN_USE) { + /* 3GPP TS 24.301, section 7.3.1, case g + * Return accept message, even to network retransmission + * of already accepted activate default EPS bearer context + * request message + */ + is_discarded = TRUE; + } + } else { + /* Return reject message */ + rc = esm_send_activate_default_eps_bearer_context_reject(ebi, + &esm_msg.activate_default_eps_bearer_context_reject, + esm_cause); + /* Setup the callback function used to send activate default + * EPS bearer context reject message onto the network */ + esm_procedure = esm_proc_default_eps_bearer_context_reject; + } + break; + + case ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST: + /* + * Process activate dedicated EPS bearer context request message + * received from the MME + */ + esm_cause = esm_recv_activate_dedicated_eps_bearer_context_request( + pti, ebi, + &esm_msg.activate_dedicated_eps_bearer_context_request); + + if ( (esm_cause == ESM_CAUSE_SUCCESS) || + (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); + /* Setup the callback function used to send activate dedicated + * EPS bearer context accept message onto the network */ + esm_procedure = esm_proc_dedicated_eps_bearer_context_accept; + if (esm_cause == ESM_CAUSE_PTI_ALREADY_IN_USE) { + /* 3GPP TS 24.301, section 7.3.1, case i + * Return accept message, even to network retransmission + * of already accepted activate dedicated EPS bearer context + * request message + */ + is_discarded = TRUE; + } + } else { + /* Return reject message */ + rc = esm_send_activate_dedicated_eps_bearer_context_reject(ebi, + &esm_msg.activate_dedicated_eps_bearer_context_reject, + esm_cause); + /* Setup the callback function used to send activate dedicated + * EPS bearer context reject message onto the network */ + esm_procedure = esm_proc_dedicated_eps_bearer_context_reject; + } + break; + + case MODIFY_EPS_BEARER_CONTEXT_REQUEST: + break; + + case DEACTIVATE_EPS_BEARER_CONTEXT_REQUEST: + /* + * Process deactivate EPS bearer context request message + * received from the MME + */ + esm_cause = esm_recv_deactivate_eps_bearer_context_request(pti, ebi, + &esm_msg.deactivate_eps_bearer_context_request); + + if ( (esm_cause == ESM_CAUSE_INVALID_PTI_VALUE) || + (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) ) { + /* Return accept message */ + rc = esm_send_deactivate_eps_bearer_context_accept(ebi, + &esm_msg.deactivate_eps_bearer_context_accept); + /* Setup the callback function used to send deactivate + * EPS bearer context accept message onto the network */ + esm_procedure = esm_proc_eps_bearer_context_deactivate_accept; + if (esm_cause == ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY) { + /* 3GPP TS 24.301, section 7.3.2, case j + * Respond with a deactivate EPS bearer context accept + * message with the EPS bearer identity set to the received + * EPS bearer identity + */ + is_discarded = TRUE; + } + } + break; + + case PDN_CONNECTIVITY_REJECT: + /* + * Process PDN connectivity reject message received from the MME + */ + esm_cause = esm_recv_pdn_connectivity_reject(pti, ebi, + &esm_msg.pdn_connectivity_reject); + + if ( (esm_cause == ESM_CAUSE_INVALID_PTI_VALUE) || + (esm_cause == ESM_CAUSE_PTI_MISMATCH) || + (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 + * does not match any PTI in use + * 3GPP TS 24.301, section 7.3.2, case a + * Ignore PDN connectivity reject message received with + * reserved or unassigned EPS bearer identity value + */ + is_discarded = TRUE; + } + break; + + case PDN_DISCONNECT_REJECT: + /* + * Process PDN disconnect reject message received from the MME + */ + esm_cause = esm_recv_pdn_disconnect_reject(pti, ebi, + &esm_msg.pdn_disconnect_reject); + + if ( (esm_cause == ESM_CAUSE_INVALID_PTI_VALUE) || + (esm_cause == ESM_CAUSE_PTI_MISMATCH) || + (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 + * does not match any PTI in use + * 3GPP TS 24.301, section 7.3.2, case b + * Ignore PDN disconnect reject message received with + * reserved or unassigned EPS bearer identity value + */ + is_discarded = TRUE; + } + break; + + case BEARER_RESOURCE_ALLOCATION_REJECT: + break; + + case BEARER_RESOURCE_MODIFICATION_REJECT: + break; + + case ESM_INFORMATION_REQUEST: + break; + + case ESM_STATUS: + /* + * Process received ESM status message + */ + esm_cause = esm_recv_status(pti, ebi, &esm_msg.esm_status); + break; #endif #ifdef NAS_MME - case ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_ACCEPT: - /* - * Process activate default EPS bearer context accept message - * received from the UE - */ - esm_cause = esm_recv_activate_default_eps_bearer_context_accept( - ueid, pti, ebi, - &esm_msg.activate_default_eps_bearer_context_accept); - - if ( (esm_cause == ESM_CAUSE_INVALID_PTI_VALUE) || - (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 - * Ignore ESM message received with reserved or assigned - * value that does not match an existing EPS bearer context - */ - is_discarded = TRUE; - } - break; - - case ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REJECT: - /* - * Process activate default EPS bearer context reject message - * received from the UE - */ - esm_cause = esm_recv_activate_default_eps_bearer_context_reject( - ueid, pti, ebi, - &esm_msg.activate_default_eps_bearer_context_reject); - - if ( (esm_cause == ESM_CAUSE_INVALID_PTI_VALUE) || - (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 - * Ignore ESM message received with reserved or assigned - * value that does not match an existing EPS bearer context - */ - is_discarded = TRUE; - } - break; - - case DEACTIVATE_EPS_BEARER_CONTEXT_ACCEPT: - /* - * Process deactivate EPS bearer context accept message - * received from the UE - */ - esm_cause = esm_recv_deactivate_eps_bearer_context_accept( - ueid, pti, ebi, - &esm_msg.deactivate_eps_bearer_context_accept); - - if ( (esm_cause == ESM_CAUSE_INVALID_PTI_VALUE) || - (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 - * Ignore ESM message received with reserved or assigned - * value that does not match an existing EPS bearer context - */ - is_discarded = TRUE; - } - break; - - case ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_ACCEPT: - /* - * Process activate dedicated EPS bearer context accept message - * received from the UE - */ - esm_cause = esm_recv_activate_dedicated_eps_bearer_context_accept( - ueid, pti, ebi, - &esm_msg.activate_dedicated_eps_bearer_context_accept); - - if ( (esm_cause == ESM_CAUSE_INVALID_PTI_VALUE) || - (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 - * Ignore ESM message received with reserved or assigned - * value that does not match an existing EPS bearer context - */ - is_discarded = TRUE; - } - break; - - case ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REJECT: - /* - * Process activate dedicated EPS bearer context reject message - * received from the UE - */ - esm_cause = esm_recv_activate_dedicated_eps_bearer_context_reject( - ueid, pti, ebi, - &esm_msg.activate_dedicated_eps_bearer_context_reject); - - if ( (esm_cause == ESM_CAUSE_INVALID_PTI_VALUE) || - (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 - * Ignore ESM message received with reserved or assigned - * value that does not match an existing EPS bearer context - */ - is_discarded = TRUE; - } - break; - - case MODIFY_EPS_BEARER_CONTEXT_ACCEPT: - break; - - case MODIFY_EPS_BEARER_CONTEXT_REJECT: - break; - - case PDN_CONNECTIVITY_REQUEST: - { - esm_proc_data_t data; - memset(&data, 0, sizeof(esm_proc_data_t)); - - /* - * Process PDN connectivity request message received from the UE - */ - esm_cause = esm_recv_pdn_connectivity_request(ueid, pti, ebi, - &esm_msg.pdn_connectivity_request, - &ebi, &data); - - if (esm_cause != ESM_CAUSE_SUCCESS) { - /* Return reject message */ - rc = esm_send_pdn_connectivity_reject(pti, - &esm_msg.pdn_connectivity_reject, esm_cause); - /* Setup the callback function used to send PDN connectivity - * reject message onto the network */ - esm_procedure = esm_proc_pdn_connectivity_reject; - /* No ESM status message should be returned */ - esm_cause = ESM_CAUSE_SUCCESS; - } - else { - /* Setup PDN type */ - int pdn_type = -1; - if (data.pdn_type == ESM_PDN_TYPE_IPV4) { - pdn_type = PDN_VALUE_TYPE_IPV4; - } else if (data.pdn_type == ESM_PDN_TYPE_IPV6) { - pdn_type = PDN_VALUE_TYPE_IPV6; - } else if (data.pdn_type == ESM_PDN_TYPE_IPV4V6) { - pdn_type = PDN_VALUE_TYPE_IPV4V6; - } - /* Setup EPS bearer level Quality of Service */ - EpsQualityOfService qos; - qos.bitRatesPresent = 1; - qos.bitRatesExtPresent = 0; - qos.qci = data.qos.qci; - qos.bitRates.maxBitRateForUL = data.qos.mbrUL; - qos.bitRates.maxBitRateForDL = data.qos.mbrDL; - qos.bitRates.guarBitRateForUL = data.qos.gbrUL; - qos.bitRates.guarBitRateForDL = data.qos.gbrDL; - - /* Return default EPS bearer context request message */ - rc = esm_send_activate_default_eps_bearer_context_request( - pti, ebi, - &esm_msg.activate_default_eps_bearer_context_request, - &data.apn, pdn_type, &data.pdn_addr, &qos, esm_cause); + case ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_ACCEPT: + /* + * Process activate default EPS bearer context accept message + * received from the UE + */ + esm_cause = esm_recv_activate_default_eps_bearer_context_accept( + ueid, pti, ebi, + &esm_msg.activate_default_eps_bearer_context_accept); + + if ( (esm_cause == ESM_CAUSE_INVALID_PTI_VALUE) || + (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 + * Ignore ESM message received with reserved or assigned + * value that does not match an existing EPS bearer context + */ + is_discarded = TRUE; + } + break; + + case ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REJECT: + /* + * Process activate default EPS bearer context reject message + * received from the UE + */ + esm_cause = esm_recv_activate_default_eps_bearer_context_reject( + ueid, pti, ebi, + &esm_msg.activate_default_eps_bearer_context_reject); + + if ( (esm_cause == ESM_CAUSE_INVALID_PTI_VALUE) || + (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 + * Ignore ESM message received with reserved or assigned + * value that does not match an existing EPS bearer context + */ + is_discarded = TRUE; + } + break; + + case DEACTIVATE_EPS_BEARER_CONTEXT_ACCEPT: + /* + * Process deactivate EPS bearer context accept message + * received from the UE + */ + esm_cause = esm_recv_deactivate_eps_bearer_context_accept( + ueid, pti, ebi, + &esm_msg.deactivate_eps_bearer_context_accept); + + if ( (esm_cause == ESM_CAUSE_INVALID_PTI_VALUE) || + (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 + * Ignore ESM message received with reserved or assigned + * value that does not match an existing EPS bearer context + */ + is_discarded = TRUE; + } + break; + + case ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_ACCEPT: + /* + * Process activate dedicated EPS bearer context accept message + * received from the UE + */ + esm_cause = esm_recv_activate_dedicated_eps_bearer_context_accept( + ueid, pti, ebi, + &esm_msg.activate_dedicated_eps_bearer_context_accept); + + if ( (esm_cause == ESM_CAUSE_INVALID_PTI_VALUE) || + (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 + * Ignore ESM message received with reserved or assigned + * value that does not match an existing EPS bearer context + */ + is_discarded = TRUE; + } + break; + + case ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REJECT: + /* + * Process activate dedicated EPS bearer context reject message + * received from the UE + */ + esm_cause = esm_recv_activate_dedicated_eps_bearer_context_reject( + ueid, pti, ebi, + &esm_msg.activate_dedicated_eps_bearer_context_reject); + + if ( (esm_cause == ESM_CAUSE_INVALID_PTI_VALUE) || + (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 + * Ignore ESM message received with reserved or assigned + * value that does not match an existing EPS bearer context + */ + is_discarded = TRUE; + } + break; + + case MODIFY_EPS_BEARER_CONTEXT_ACCEPT: + break; + + case MODIFY_EPS_BEARER_CONTEXT_REJECT: + break; + + case PDN_CONNECTIVITY_REQUEST: { + esm_proc_data_t data; + memset(&data, 0, sizeof(esm_proc_data_t)); + + /* + * Process PDN connectivity request message received from the UE + */ + esm_cause = esm_recv_pdn_connectivity_request(ueid, pti, ebi, + &esm_msg.pdn_connectivity_request, + &ebi, &data); + + if (esm_cause != ESM_CAUSE_SUCCESS) { + /* Return reject message */ + rc = esm_send_pdn_connectivity_reject(pti, + &esm_msg.pdn_connectivity_reject, esm_cause); + /* Setup the callback function used to send PDN connectivity + * reject message onto the network */ + esm_procedure = esm_proc_pdn_connectivity_reject; + /* No ESM status message should be returned */ + esm_cause = ESM_CAUSE_SUCCESS; + } else { + /* Setup PDN type */ + int pdn_type = -1; + if (data.pdn_type == ESM_PDN_TYPE_IPV4) { + pdn_type = PDN_VALUE_TYPE_IPV4; + } else if (data.pdn_type == ESM_PDN_TYPE_IPV6) { + pdn_type = PDN_VALUE_TYPE_IPV6; + } else if (data.pdn_type == ESM_PDN_TYPE_IPV4V6) { + pdn_type = PDN_VALUE_TYPE_IPV4V6; + } + /* Setup EPS bearer level Quality of Service */ + EpsQualityOfService qos; + qos.bitRatesPresent = 1; + qos.bitRatesExtPresent = 0; + qos.qci = data.qos.qci; + qos.bitRates.maxBitRateForUL = data.qos.mbrUL; + qos.bitRates.maxBitRateForDL = data.qos.mbrDL; + qos.bitRates.guarBitRateForUL = data.qos.gbrUL; + qos.bitRates.guarBitRateForDL = data.qos.gbrDL; + + /* Return default EPS bearer context request message */ + rc = esm_send_activate_default_eps_bearer_context_request( + pti, ebi, + &esm_msg.activate_default_eps_bearer_context_request, + &data.apn, pdn_type, &data.pdn_addr, &qos, esm_cause); #if 0 - PacketFilters pkfs; - pkfs[0].identifier = 1; - pkfs[0].direction = TRAFFIC_FLOW_TEMPLATE_DOWNLINK_ONLY; - pkfs[0].eval_precedence = 2; - pkfs[0].packetfilter.flags = - (TRAFFIC_FLOW_TEMPLATE_IPV4_REMOTE_ADDR_FLAG | - TRAFFIC_FLOW_TEMPLATE_PROTOCOL_NEXT_HEADER_FLAG | - TRAFFIC_FLOW_TEMPLATE_SINGLE_LOCAL_PORT_FLAG | - TRAFFIC_FLOW_TEMPLATE_SINGLE_REMOTE_PORT_FLAG); - pkfs[0].packetfilter.ipv4remoteaddr[0].addr = 192; - pkfs[0].packetfilter.ipv4remoteaddr[1].addr = 168; - pkfs[0].packetfilter.ipv4remoteaddr[2].addr = 12; - pkfs[0].packetfilter.ipv4remoteaddr[3].addr = 1; - pkfs[0].packetfilter.ipv4remoteaddr[0].mask = 255; - pkfs[0].packetfilter.ipv4remoteaddr[1].mask = 255; - pkfs[0].packetfilter.ipv4remoteaddr[2].mask = 255; - pkfs[0].packetfilter.ipv4remoteaddr[3].mask = 0; - pkfs[0].packetfilter.protocolidentifier_nextheader = 17; - pkfs[0].packetfilter.singlelocalport = 10001; - pkfs[0].packetfilter.singleremoteport = 12001; - pkfs[1].identifier = 2; - pkfs[1].direction = TRAFFIC_FLOW_TEMPLATE_UPLINK_ONLY; - pkfs[1].eval_precedence = 3; - pkfs[1].packetfilter.flags = - (TRAFFIC_FLOW_TEMPLATE_IPV4_REMOTE_ADDR_FLAG | - TRAFFIC_FLOW_TEMPLATE_PROTOCOL_NEXT_HEADER_FLAG | - TRAFFIC_FLOW_TEMPLATE_SINGLE_LOCAL_PORT_FLAG | - TRAFFIC_FLOW_TEMPLATE_SINGLE_REMOTE_PORT_FLAG); - pkfs[1].packetfilter.ipv4remoteaddr[0].addr = 192; - pkfs[1].packetfilter.ipv4remoteaddr[1].addr = 168; - pkfs[1].packetfilter.ipv4remoteaddr[2].addr = 12; - pkfs[1].packetfilter.ipv4remoteaddr[3].addr = 1; - pkfs[1].packetfilter.ipv4remoteaddr[0].mask = 255; - pkfs[1].packetfilter.ipv4remoteaddr[1].mask = 255; - pkfs[1].packetfilter.ipv4remoteaddr[2].mask = 255; - pkfs[1].packetfilter.ipv4remoteaddr[3].mask = 0; - pkfs[1].packetfilter.protocolidentifier_nextheader = 17; - pkfs[1].packetfilter.singlelocalport = 10002; - pkfs[1].packetfilter.singleremoteport = 12002; - /* Return dedicated EPS bearer context request message */ - rc = esm_send_activate_dedicated_eps_bearer_context_request( - pti, ebi, - &esm_msg.activate_dedicated_eps_bearer_context_request, - ebi, &qos, &pkfs, 2); + PacketFilters pkfs; + pkfs[0].identifier = 1; + pkfs[0].direction = TRAFFIC_FLOW_TEMPLATE_DOWNLINK_ONLY; + pkfs[0].eval_precedence = 2; + pkfs[0].packetfilter.flags = + (TRAFFIC_FLOW_TEMPLATE_IPV4_REMOTE_ADDR_FLAG | + TRAFFIC_FLOW_TEMPLATE_PROTOCOL_NEXT_HEADER_FLAG | + TRAFFIC_FLOW_TEMPLATE_SINGLE_LOCAL_PORT_FLAG | + TRAFFIC_FLOW_TEMPLATE_SINGLE_REMOTE_PORT_FLAG); + pkfs[0].packetfilter.ipv4remoteaddr[0].addr = 192; + pkfs[0].packetfilter.ipv4remoteaddr[1].addr = 168; + pkfs[0].packetfilter.ipv4remoteaddr[2].addr = 12; + pkfs[0].packetfilter.ipv4remoteaddr[3].addr = 1; + pkfs[0].packetfilter.ipv4remoteaddr[0].mask = 255; + pkfs[0].packetfilter.ipv4remoteaddr[1].mask = 255; + pkfs[0].packetfilter.ipv4remoteaddr[2].mask = 255; + pkfs[0].packetfilter.ipv4remoteaddr[3].mask = 0; + pkfs[0].packetfilter.protocolidentifier_nextheader = 17; + pkfs[0].packetfilter.singlelocalport = 10001; + pkfs[0].packetfilter.singleremoteport = 12001; + pkfs[1].identifier = 2; + pkfs[1].direction = TRAFFIC_FLOW_TEMPLATE_UPLINK_ONLY; + pkfs[1].eval_precedence = 3; + pkfs[1].packetfilter.flags = + (TRAFFIC_FLOW_TEMPLATE_IPV4_REMOTE_ADDR_FLAG | + TRAFFIC_FLOW_TEMPLATE_PROTOCOL_NEXT_HEADER_FLAG | + TRAFFIC_FLOW_TEMPLATE_SINGLE_LOCAL_PORT_FLAG | + TRAFFIC_FLOW_TEMPLATE_SINGLE_REMOTE_PORT_FLAG); + pkfs[1].packetfilter.ipv4remoteaddr[0].addr = 192; + pkfs[1].packetfilter.ipv4remoteaddr[1].addr = 168; + pkfs[1].packetfilter.ipv4remoteaddr[2].addr = 12; + pkfs[1].packetfilter.ipv4remoteaddr[3].addr = 1; + pkfs[1].packetfilter.ipv4remoteaddr[0].mask = 255; + pkfs[1].packetfilter.ipv4remoteaddr[1].mask = 255; + pkfs[1].packetfilter.ipv4remoteaddr[2].mask = 255; + pkfs[1].packetfilter.ipv4remoteaddr[3].mask = 0; + pkfs[1].packetfilter.protocolidentifier_nextheader = 17; + pkfs[1].packetfilter.singlelocalport = 10002; + pkfs[1].packetfilter.singleremoteport = 12002; + /* Return dedicated EPS bearer context request message */ + rc = esm_send_activate_dedicated_eps_bearer_context_request( + pti, ebi, + &esm_msg.activate_dedicated_eps_bearer_context_request, + ebi, &qos, &pkfs, 2); #endif - /* Setup the callback function used to send default EPS bearer - * context request message onto the network */ - esm_procedure = esm_proc_default_eps_bearer_context_request; - } - break; - } - - case PDN_DISCONNECT_REQUEST: - /* - * Process PDN disconnect request message received from the UE - */ - esm_cause = esm_recv_pdn_disconnect_request(ueid, pti, ebi, - &esm_msg.pdn_disconnect_request, &ebi); - - if (esm_cause != ESM_CAUSE_SUCCESS) { - /* Return reject message */ - rc = esm_send_pdn_disconnect_reject(pti, - &esm_msg.pdn_disconnect_reject, esm_cause); - /* Setup the callback function used to send PDN connectivity - * reject message onto the network */ - esm_procedure = esm_proc_pdn_disconnect_reject; - /* No ESM status message should be returned */ - esm_cause = ESM_CAUSE_SUCCESS; - } - 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, - ESM_CAUSE_REGULAR_DEACTIVATION); - /* Setup the callback function used to send deactivate EPS - * bearer context request message onto the network */ - esm_procedure = esm_proc_eps_bearer_context_deactivate_request; - } - break; - - case BEARER_RESOURCE_ALLOCATION_REQUEST: - break; - - case BEARER_RESOURCE_MODIFICATION_REQUEST: - break; - - case ESM_INFORMATION_RESPONSE: - break; - - case ESM_STATUS: - /* - * Process received ESM status message - */ - esm_cause = esm_recv_status(ueid, pti, ebi, &esm_msg.esm_status); - break; + /* Setup the callback function used to send default EPS bearer + * context request message onto the network */ + esm_procedure = esm_proc_default_eps_bearer_context_request; + } + break; + } + + case PDN_DISCONNECT_REQUEST: + /* + * Process PDN disconnect request message received from the UE + */ + esm_cause = esm_recv_pdn_disconnect_request(ueid, pti, ebi, + &esm_msg.pdn_disconnect_request, &ebi); + + if (esm_cause != ESM_CAUSE_SUCCESS) { + /* Return reject message */ + rc = esm_send_pdn_disconnect_reject(pti, + &esm_msg.pdn_disconnect_reject, esm_cause); + /* Setup the callback function used to send PDN connectivity + * reject message onto the network */ + esm_procedure = esm_proc_pdn_disconnect_reject; + /* No ESM status message should be returned */ + esm_cause = ESM_CAUSE_SUCCESS; + } 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, + ESM_CAUSE_REGULAR_DEACTIVATION); + /* Setup the callback function used to send deactivate EPS + * bearer context request message onto the network */ + esm_procedure = esm_proc_eps_bearer_context_deactivate_request; + } + break; + + case BEARER_RESOURCE_ALLOCATION_REQUEST: + break; + + case BEARER_RESOURCE_MODIFICATION_REQUEST: + break; + + case ESM_INFORMATION_RESPONSE: + break; + + case ESM_STATUS: + /* + * Process received ESM status message + */ + esm_cause = esm_recv_status(ueid, pti, ebi, &esm_msg.esm_status); + break; #endif - default: - LOG_TRACE(WARNING, "ESM-SAP - Received unexpected ESM message " - "0x%x", esm_msg.header.message_type); - esm_cause = ESM_CAUSE_MESSAGE_TYPE_NOT_IMPLEMENTED; - break; - } + default: + LOG_TRACE(WARNING, "ESM-SAP - Received unexpected ESM message " + "0x%x", esm_msg.header.message_type); + esm_cause = ESM_CAUSE_MESSAGE_TYPE_NOT_IMPLEMENTED; + break; + } if ( (esm_cause != ESM_CAUSE_SUCCESS) && (esm_procedure == NULL) ) { - /* ESM message processing failed */ - if (!is_discarded) { - /* 3GPP TS 24.301, section 7.1 - * Handling of unknown, unforeseen, and erroneous protocol data */ - LOG_TRACE(WARNING, "ESM-SAP - Received ESM message is not valid " - "(cause=%d)", esm_cause); - /* Return an ESM status message */ - rc = esm_send_status(pti, ebi, &esm_msg.esm_status, esm_cause); - /* Setup the callback function used to send ESM status message - * onto the network */ - esm_procedure = esm_proc_status; - /* Discard received ESM message */ - is_discarded = TRUE; - } - } - else { - /* ESM message processing succeed */ - *err = ESM_SAP_SUCCESS; - rc = RETURNok; + /* ESM message processing failed */ + if (!is_discarded) { + /* 3GPP TS 24.301, section 7.1 + * Handling of unknown, unforeseen, and erroneous protocol data */ + LOG_TRACE(WARNING, "ESM-SAP - Received ESM message is not valid " + "(cause=%d)", esm_cause); + /* Return an ESM status message */ + rc = esm_send_status(pti, ebi, &esm_msg.esm_status, esm_cause); + /* Setup the callback function used to send ESM status message + * onto the network */ + esm_procedure = esm_proc_status; + /* Discard received ESM message */ + is_discarded = TRUE; + } + } else { + /* ESM message processing succeed */ + *err = ESM_SAP_SUCCESS; + rc = RETURNok; } if ( (rc != RETURNerror) && (esm_procedure != NULL) ) { - /* Encode the returned ESM response message */ - 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); - } - /* Complete the relevant ESM procedure */ + /* Encode the returned ESM response message */ + 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); + } + /* Complete the relevant ESM procedure */ #ifdef NAS_UE - rc = (*esm_procedure)(is_standalone, ebi, rsp, triggered_by_ue); + rc = (*esm_procedure)(is_standalone, ebi, rsp, triggered_by_ue); #endif #ifdef NAS_MME - rc = (*esm_procedure)(is_standalone, ueid, ebi, rsp, triggered_by_ue); + rc = (*esm_procedure)(is_standalone, ueid, ebi, rsp, triggered_by_ue); #endif - if (is_discarded) { - /* Return indication that received message has been discarded */ - *err = ESM_SAP_DISCARDED; - } - else if (rc != RETURNok) { - /* Return indication that ESM procedure failed */ - *err = ESM_SAP_FAILED; - } - } - 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 */ - *err = ESM_SAP_DISCARDED; - rc = RETURNok; + if (is_discarded) { + /* Return indication that received message has been discarded */ + *err = ESM_SAP_DISCARDED; + } else if (rc != RETURNok) { + /* Return indication that ESM procedure failed */ + *err = ESM_SAP_FAILED; + } + } 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 */ + *err = ESM_SAP_DISCARDED; + rc = RETURNok; } LOG_FUNC_RETURN(rc); @@ -980,33 +955,33 @@ static int _esm_sap_recv(int msg_type, int is_standalone, /**************************************************************************** ** ** - ** Name: _esm_sap_send() ** + ** Name: _esm_sap_send() ** ** ** ** Description: Processes ESM messages to send onto the network: Encoded ** - ** the message and execute the relevant ESM procedure. ** + ** the message and execute the relevant ESM procedure. ** ** ** - ** Inputs: msg_type: Type of the ESM message to be sent ** - ** is_standalone: Indicates whether the ESM message has to ** - ** be sent standalone or together within EMM ** - ** attach related message ** - ** ueid: UE identifier within the MME ** - ** pti: Procedure transaction identity ** - ** ebi: EPS bearer identity ** - ** data: Data required to build the message ** - ** Others: None ** + ** Inputs: msg_type: Type of the ESM message to be sent ** + ** is_standalone: Indicates whether the ESM message has to ** + ** be sent standalone or together within EMM ** + ** attach related message ** + ** ueid: UE identifier within the MME ** + ** pti: Procedure transaction identity ** + ** ebi: EPS bearer identity ** + ** data: Data required to build the message ** + ** Others: None ** ** ** - ** Outputs: rsp: The encoded ESM response message to be re- ** - ** turned upon ESM procedure completion ** - ** Return: RETURNok, RETURNerror ** - ** Others: _esm_sap_buffer ** + ** Outputs: rsp: The encoded ESM response message to be re- ** + ** turned upon ESM procedure completion ** + ** Return: RETURNok, RETURNerror ** + ** Others: _esm_sap_buffer ** ** ** ***************************************************************************/ static int _esm_sap_send(int msg_type, int is_standalone, #ifdef NAS_MME - unsigned int ueid, + 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,112 +1000,110 @@ 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; - - case ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REJECT: - break; - - case ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_ACCEPT: - break; - - case ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REJECT: - break; - - case MODIFY_EPS_BEARER_CONTEXT_ACCEPT: - break; - - case MODIFY_EPS_BEARER_CONTEXT_REJECT: - break; - - case DEACTIVATE_EPS_BEARER_CONTEXT_ACCEPT: - break; - - case PDN_CONNECTIVITY_REQUEST: - { - /* - * Process PDN connectivity request message to send to the MME - */ - 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); - /* Setup callback function used to send PDN connectivity request - * message onto the network */ - esm_procedure = esm_proc_pdn_connectivity_request; - break; - } - - case PDN_DISCONNECT_REQUEST: - /* - * Process PDN disconnect request message to send to the MME - */ - rc = esm_send_pdn_disconnect_request(pti, ebi, - &esm_msg.pdn_disconnect_request); - /* Setup callback function used to send PDN disconnect request - * message onto the network */ - esm_procedure = esm_proc_pdn_disconnect_request; - break; - - case BEARER_RESOURCE_ALLOCATION_REQUEST: - break; - - case BEARER_RESOURCE_MODIFICATION_REQUEST: - break; + case ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_ACCEPT: + break; + + case ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REJECT: + break; + + case ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_ACCEPT: + break; + + case ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REJECT: + break; + + case MODIFY_EPS_BEARER_CONTEXT_ACCEPT: + break; + + case MODIFY_EPS_BEARER_CONTEXT_REJECT: + break; + + case DEACTIVATE_EPS_BEARER_CONTEXT_ACCEPT: + break; + + case PDN_CONNECTIVITY_REQUEST: { + /* + * Process PDN connectivity request message to send to the MME + */ + 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); + /* Setup callback function used to send PDN connectivity request + * message onto the network */ + esm_procedure = esm_proc_pdn_connectivity_request; + break; + } + + case PDN_DISCONNECT_REQUEST: + /* + * Process PDN disconnect request message to send to the MME + */ + rc = esm_send_pdn_disconnect_request(pti, ebi, + &esm_msg.pdn_disconnect_request); + /* Setup callback function used to send PDN disconnect request + * message onto the network */ + esm_procedure = esm_proc_pdn_disconnect_request; + break; + + case BEARER_RESOURCE_ALLOCATION_REQUEST: + break; + + case BEARER_RESOURCE_MODIFICATION_REQUEST: + break; #endif #ifdef NAS_MME - case ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST: - break; + case ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST: + break; - case ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST: - break; + case ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST: + break; - case MODIFY_EPS_BEARER_CONTEXT_REQUEST: - break; + case MODIFY_EPS_BEARER_CONTEXT_REQUEST: + break; - case DEACTIVATE_EPS_BEARER_CONTEXT_REQUEST: - break; + case DEACTIVATE_EPS_BEARER_CONTEXT_REQUEST: + break; - case PDN_CONNECTIVITY_REJECT: - break; + case PDN_CONNECTIVITY_REJECT: + break; - case PDN_DISCONNECT_REJECT: - break; + case PDN_DISCONNECT_REJECT: + break; - case BEARER_RESOURCE_ALLOCATION_REJECT: - break; + case BEARER_RESOURCE_ALLOCATION_REJECT: + break; - case BEARER_RESOURCE_MODIFICATION_REJECT: - break; + case BEARER_RESOURCE_MODIFICATION_REJECT: + break; #endif - default: - LOG_TRACE(WARNING, "ESM-SAP - Send unexpected ESM message 0x%x", - msg_type); - break; + default: + LOG_TRACE(WARNING, "ESM-SAP - Send unexpected ESM message 0x%x", + msg_type); + break; } if (rc != RETURNerror) { - /* Encode the returned ESM response message */ - 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); - } - /* Execute the relevant ESM procedure */ - if (esm_procedure) { + /* Encode the returned ESM response message */ + 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); + } + /* Execute the relevant ESM procedure */ + if (esm_procedure) { #ifdef NAS_UE - rc = (*esm_procedure)(is_standalone, pti, rsp, sent_by_ue); + rc = (*esm_procedure)(is_standalone, pti, rsp, sent_by_ue); #endif #ifdef NAS_MME - rc = (*esm_procedure)(is_standalone, ueid, pti, rsp, sent_by_ue); + rc = (*esm_procedure)(is_standalone, ueid, pti, rsp, sent_by_ue); #endif - } + } } LOG_FUNC_RETURN(rc); diff --git a/openair-cn/NAS/EURECOM-NAS/src/esm/sap/esm_sap.h b/openair-cn/NAS/EURECOM-NAS/src/esm/sap/esm_sap.h index e69196800d..ec364491e5 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/esm/sap/esm_sap.h +++ b/openair-cn/NAS/EURECOM-NAS/src/esm/sap/esm_sap.h @@ -1,22 +1,22 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source esm_sap.h +Source esm_sap.h -Version 0.1 +Version 0.1 -Date 2012/11/22 +Date 2012/11/22 -Product NAS stack +Product NAS stack -Subsystem EPS Session Management +Subsystem EPS Session Management -Author Frederic Maurel +Author Frederic Maurel -Description Defines the ESM Service Access Points at which the EPS - Session Management sublayer provides procedures for the - EPS bearer context handling and resources allocation. +Description Defines the ESM Service Access Points at which the EPS + Session Management sublayer provides procedures for the + EPS bearer context handling and resources allocation. *****************************************************************************/ #ifndef __ESM_SAP_H__ @@ -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__*/ diff --git a/openair-cn/NAS/EURECOM-NAS/src/esm/sap/esm_sapDef.h b/openair-cn/NAS/EURECOM-NAS/src/esm/sap/esm_sapDef.h index 99b27659c2..8615db810a 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/esm/sap/esm_sapDef.h +++ b/openair-cn/NAS/EURECOM-NAS/src/esm/sap/esm_sapDef.h @@ -1,21 +1,21 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source esm_sapDef.h +Source esm_sapDef.h -Version 0.1 +Version 0.1 -Date 2012/11/21 +Date 2012/11/21 -Product NAS stack +Product NAS stack -Subsystem EPS Session Management +Subsystem EPS Session Management -Author Frederic Maurel +Author Frederic Maurel -Description Defines the ESM Service Access Point that provides EPS - bearer context handling and resources allocation procedures. +Description Defines the ESM Service Access Point that provides EPS + bearer context handling and resources allocation procedures. *****************************************************************************/ #ifndef __ESM_SAPDEF_H__ @@ -67,12 +67,12 @@ typedef enum { * Error code returned upon processing ESM-SAP primitive */ typedef enum { - ESM_SAP_SUCCESS = 1, /* ESM-SAP primitive succeed */ - ESM_SAP_DISCARDED, /* ESM-SAP primitive failed, the caller should - * ignore the error */ - ESM_SAP_FAILED /* ESM-SAP primitive failed, the caller should - * take specific action and state transition may - * occurs */ + ESM_SAP_SUCCESS = 1, /* ESM-SAP primitive succeed */ + ESM_SAP_DISCARDED, /* ESM-SAP primitive failed, the caller should + * ignore the error */ + ESM_SAP_FAILED /* ESM-SAP primitive failed, the caller should + * take specific action and state transition may + * occurs */ } esm_sap_error_t; /* @@ -87,14 +87,14 @@ typedef struct { * -------------------------------------------- */ typedef struct { - int cid; /* PDN connection local identifier */ - 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 */ - int is_emergency; /* Indicates whether the PDN context has been - * defined to establish connection for emergency - * bearer services */ + int cid; /* PDN connection local identifier */ + 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 */ + int is_emergency; /* Indicates whether the PDN context has been + * defined to establish connection for emergency + * bearer services */ } esm_pdn_connectivity_t; /* @@ -102,7 +102,7 @@ typedef struct { * ------------------------------------------ */ typedef struct { - int cid; /* PDN connection local identifier */ + int cid; /* PDN connection local identifier */ } esm_pdn_disconnect_t; /* @@ -110,9 +110,9 @@ typedef struct { * --------------------------------------------------------- */ typedef struct { -#define ESM_SAP_ALL_EBI 0xff - unsigned int ebi; /* EPS bearer identity of the EPS bearer context - * to be deactivated */ +#define ESM_SAP_ALL_EBI 0xff + unsigned int ebi; /* EPS bearer identity of the EPS bearer context + * to be deactivated */ } esm_eps_bearer_context_deactivate_t; /* @@ -127,16 +127,16 @@ typedef union { } esm_sap_data_t; typedef struct { - esm_primitive_t primitive; /* ESM-SAP primitive to process */ - int is_standalone; /* Indicates whether the ESM message handled - * within this primitive has to be sent/received - * standalone or together within an EMM related - * message */ - unsigned int ueid; /* Local UE identifier */ - esm_sap_error_t err; /* ESM-SAP error code */ - 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_primitive_t primitive; /* ESM-SAP primitive to process */ + int is_standalone; /* Indicates whether the ESM message handled + * within this primitive has to be sent/received + * standalone or together within an EMM related + * message */ + unsigned int ueid; /* Local UE identifier */ + esm_sap_error_t err; /* ESM-SAP error code */ + 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; /****************************************************************************/ diff --git a/openair-cn/NAS/EURECOM-NAS/src/esm/sap/esm_send.c b/openair-cn/NAS/EURECOM-NAS/src/esm/sap/esm_send.c index 8a58c31ef5..e130fcad67 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/esm/sap/esm_send.c +++ b/openair-cn/NAS/EURECOM-NAS/src/esm/sap/esm_send.c @@ -1,22 +1,22 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source esm_send.c +Source esm_send.c -Version 0.1 +Version 0.1 -Date 2013/02/11 +Date 2013/02/11 -Product NAS stack +Product NAS stack -Subsystem EPS Session Management +Subsystem EPS Session Management -Author Frederic Maurel +Author Frederic Maurel -Description Defines functions executed at the ESM Service Access - Point to send EPS Session Management messages to the - EPS Mobility Management sublayer. +Description Defines functions executed at the ESM Service Access + Point to send EPS Session Management messages to the + EPS Mobility Management sublayer. *****************************************************************************/ @@ -31,7 +31,7 @@ Description Defines functions executed at the ESM Service Access #include "esm_msgDef.h" #include "esm_cause.h" -#include <string.h> // strlen +#include <string.h> // strlen /****************************************************************************/ /**************** E X T E R N A L D E F I N I T I O N S ****************/ @@ -52,25 +52,25 @@ Description Defines functions executed at the ESM Service Access */ /**************************************************************************** ** ** - ** Name: esm_send_status() ** + ** Name: esm_send_status() ** ** ** ** Description: Builds ESM status message ** ** ** - ** The ESM status message is sent by the network or the UE ** - ** to pass information on the status of the indicated EPS ** - ** bearer context and report certain error conditions. ** + ** The ESM status message is sent by the network or the UE ** + ** to pass information on the status of the indicated EPS ** + ** bearer context and report certain error conditions. ** ** ** - ** Inputs: pti: Procedure transaction identity ** - ** ebi: EPS bearer identity ** - ** esm_cause: ESM cause code ** - ** Others: None ** + ** Inputs: pti: Procedure transaction identity ** + ** ebi: EPS bearer identity ** + ** esm_cause: ESM cause code ** + ** Others: None ** ** ** - ** Outputs: msg: The ESM message to be sent ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: msg: The ESM message to be sent ** + ** Return: RETURNok, RETURNerror ** + ** 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; @@ -84,9 +84,9 @@ int esm_send_status(int pti, int ebi, esm_status_msg* msg, int esm_cause) msg->esmcause = esm_cause; LOG_TRACE(WARNING, "ESM-SAP - Send ESM Status message (pti=%d, ebi=%d)", - msg->proceduretransactionidentity, msg->epsbeareridentity); + msg->proceduretransactionidentity, msg->epsbeareridentity); - LOG_FUNC_RETURN(RETURNok); + LOG_FUNC_RETURN(RETURNok); } /* @@ -97,29 +97,29 @@ int esm_send_status(int pti, int ebi, esm_status_msg* msg, int esm_cause) #ifdef NAS_UE /**************************************************************************** ** ** - ** Name: esm_send_pdn_connectivity_request() ** + ** Name: esm_send_pdn_connectivity_request() ** ** ** ** Description: Builds PDN Connectivity Request message ** ** ** - ** The PDN connectivity request message is sent by the UE to ** - ** the network to initiate establishment of a PDN connection.** + ** The PDN connectivity request message is sent by the UE to ** + ** the network to initiate establishment of a PDN connection.** ** ** - ** Inputs: pti: Procedure transaction identity assigned to ** - ** the PDN connection ** - ** is_emergency: Indicates whether the PDN connectivity is ** - ** requested for emergency bearer services ** - ** pdn_type: PDN address type ** - ** apn: Access Point Name of the PDN to connect to ** - ** Others: None ** + ** Inputs: pti: Procedure transaction identity assigned to ** + ** the PDN connection ** + ** is_emergency: Indicates whether the PDN connectivity is ** + ** requested for emergency bearer services ** + ** pdn_type: PDN address type ** + ** apn: Access Point Name of the PDN to connect to ** + ** Others: None ** ** ** - ** Outputs: msg: The ESM message to be sent ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: msg: The ESM message to be sent ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ 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; @@ -131,61 +131,61 @@ int esm_send_pdn_connectivity_request(int pti, int is_emergency, int pdn_type, /* Mandatory - PDN connectivity request type */ if (is_emergency) { - msg->requesttype = REQUEST_TYPE_EMERGENCY; + msg->requesttype = REQUEST_TYPE_EMERGENCY; } else { - msg->requesttype = REQUEST_TYPE_INITIAL_REQUEST; + msg->requesttype = REQUEST_TYPE_INITIAL_REQUEST; } /* Mandatory - PDN type */ if (pdn_type == NET_PDN_TYPE_IPV4) { - msg->pdntype = PDN_TYPE_IPV4; + msg->pdntype = PDN_TYPE_IPV4; } else if (pdn_type == NET_PDN_TYPE_IPV6) { - msg->pdntype = PDN_TYPE_IPV6; + msg->pdntype = PDN_TYPE_IPV6; } else if (pdn_type == NET_PDN_TYPE_IPV4V6) { - msg->pdntype = PDN_TYPE_IPV4V6; + msg->pdntype = PDN_TYPE_IPV4V6; } /* Optional - Access Point Name */ msg->presencemask = 0; if (apn) { - size_t len = strlen(apn); - if (len > 0) { - msg->presencemask |= - PDN_CONNECTIVITY_REQUEST_ACCESS_POINT_NAME_PRESENT; - msg->accesspointname.accesspointnamevalue.length = len; - msg->accesspointname.accesspointnamevalue.value = (uint8_t*)apn; - } + size_t len = strlen(apn); + if (len > 0) { + msg->presencemask |= + PDN_CONNECTIVITY_REQUEST_ACCESS_POINT_NAME_PRESENT; + msg->accesspointname.accesspointnamevalue.length = len; + msg->accesspointname.accesspointnamevalue.value = (uint8_t *)apn; + } } LOG_TRACE(INFO, "ESM-SAP - Send PDN Connectivity Request message " - "(pti=%d, ebi=%d)", - msg->proceduretransactionidentity, msg->epsbeareridentity); + "(pti=%d, ebi=%d)", + msg->proceduretransactionidentity, msg->epsbeareridentity); LOG_FUNC_RETURN(RETURNok); } /**************************************************************************** ** ** - ** Name: esm_send_pdn_disconnect_request() ** + ** Name: esm_send_pdn_disconnect_request() ** ** ** ** Description: Builds PDN Disconnect Request message ** ** ** - ** The PDN disconnect request message is sent by the UE to ** - ** the network to initiate release of a PDN connection. ** + ** The PDN disconnect request message is sent by the UE to ** + ** the network to initiate release of a PDN connection. ** ** ** - ** Inputs: pti: Procedure transaction identity assigned to ** - ** the PDN connection ** - ** ebi: EPS bearer identity of the default bearer ** - ** associated with the PDN to disconnect from ** - ** Others: None ** + ** Inputs: pti: Procedure transaction identity assigned to ** + ** the PDN connection ** + ** ebi: EPS bearer identity of the default bearer ** + ** associated with the PDN to disconnect from ** + ** Others: None ** ** ** - ** Outputs: msg: The ESM message to be sent ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: msg: The ESM message to be sent ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ int esm_send_pdn_disconnect_request(int pti, int ebi, - pdn_disconnect_request_msg* msg) + pdn_disconnect_request_msg *msg) { LOG_FUNC_IN; @@ -201,32 +201,32 @@ int esm_send_pdn_disconnect_request(int pti, int ebi, msg->presencemask = 0; LOG_TRACE(INFO, "ESM-SAP - Send PDN Disconnect Request message " - "(pti=%d, ebi=%d)", - msg->proceduretransactionidentity, msg->epsbeareridentity); + "(pti=%d, ebi=%d)", + msg->proceduretransactionidentity, msg->epsbeareridentity); LOG_FUNC_RETURN(RETURNok); } /**************************************************************************** ** ** - ** Name: esm_send_activate_default_eps_bearer_context_accept() ** + ** Name: esm_send_activate_default_eps_bearer_context_accept() ** ** ** ** Description: Builds Activate Default EPS Bearer Context Accept message ** ** ** - ** The activate default EPS bearer context accept message is ** - ** sent by the UE to the network to acknowledge activation ** - ** of a default EPS bearer context. ** + ** The activate default EPS bearer context accept message is ** + ** sent by the UE to the network to acknowledge activation ** + ** of a default EPS bearer context. ** ** ** - ** Inputs: ebi: EPS bearer identity ** - ** Others: None ** + ** Inputs: ebi: EPS bearer identity ** + ** Others: None ** ** ** - ** Outputs: msg: The ESM message to be sent ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: msg: The ESM message to be sent ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ 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; @@ -240,33 +240,33 @@ int esm_send_activate_default_eps_bearer_context_accept(int ebi, msg->presencemask = 0; LOG_TRACE(INFO, "ESM-SAP - Send Activate Default EPS Bearer Context " - "Accept message (pti=%d, ebi=%d)", - msg->proceduretransactionidentity, msg->epsbeareridentity); + "Accept message (pti=%d, ebi=%d)", + msg->proceduretransactionidentity, msg->epsbeareridentity); LOG_FUNC_RETURN(RETURNok); } /**************************************************************************** ** ** - ** Name: esm_send_activate_default_eps_bearer_context_reject() ** + ** Name: esm_send_activate_default_eps_bearer_context_reject() ** ** ** ** Description: Builds Activate Default EPS Bearer Context Reject message ** ** ** - ** The activate default EPS bearer context reject message is ** - ** sent by UE to the network to reject activation of a de- ** - ** fault EPS bearer context. ** + ** The activate default EPS bearer context reject message is ** + ** sent by UE to the network to reject activation of a de- ** + ** fault EPS bearer context. ** ** ** - ** Inputs: ebi: EPS bearer identity ** - ** esm_cause: ESM cause code ** - ** Others: None ** + ** Inputs: ebi: EPS bearer identity ** + ** esm_cause: ESM cause code ** + ** Others: None ** ** ** - ** Outputs: msg: The ESM message to be sent ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: msg: The ESM message to be sent ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ 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; @@ -281,35 +281,35 @@ int esm_send_activate_default_eps_bearer_context_reject(int ebi, msg->presencemask = 0; LOG_TRACE(INFO, "ESM-SAP - Send Activate Default EPS Bearer Context " - "Reject message (pti=%d, ebi=%d)", - msg->proceduretransactionidentity, msg->epsbeareridentity); + "Reject message (pti=%d, ebi=%d)", + msg->proceduretransactionidentity, msg->epsbeareridentity); LOG_FUNC_RETURN(RETURNok); } /**************************************************************************** ** ** - ** Name: esm_send_activate_dedicated_eps_bearer_context_accept() ** + ** Name: esm_send_activate_dedicated_eps_bearer_context_accept() ** ** ** ** Description: Builds Activate Dedicated EPS Bearer Context Accept ** - ** message ** + ** message ** ** ** - ** The activate dedicated EPS bearer context accept message ** - ** is sent by the UE to the network to acknowledge activa- ** - ** tion of a dedicated EPS bearer context associated with ** - ** the same PDN address(es) and APN as an already active EPS ** - ** bearer context. ** + ** The activate dedicated EPS bearer context accept message ** + ** is sent by the UE to the network to acknowledge activa- ** + ** tion of a dedicated EPS bearer context associated with ** + ** the same PDN address(es) and APN as an already active EPS ** + ** bearer context. ** ** ** - ** Inputs: ebi: EPS bearer identity ** - ** Others: None ** + ** Inputs: ebi: EPS bearer identity ** + ** Others: None ** ** ** - ** Outputs: msg: The ESM message to be sent ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: msg: The ESM message to be sent ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ 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; @@ -323,34 +323,34 @@ int esm_send_activate_dedicated_eps_bearer_context_accept(int ebi, msg->presencemask = 0; LOG_TRACE(INFO, "ESM-SAP - Send Activate Dedicated EPS Bearer Context " - "Accept message (pti=%d, ebi=%d)", - msg->proceduretransactionidentity, msg->epsbeareridentity); + "Accept message (pti=%d, ebi=%d)", + msg->proceduretransactionidentity, msg->epsbeareridentity); LOG_FUNC_RETURN(RETURNok); } /**************************************************************************** ** ** - ** Name: esm_send_activate_dedicated_eps_bearer_context_reject() ** + ** Name: esm_send_activate_dedicated_eps_bearer_context_reject() ** ** ** ** Description: Builds Activate Dedicated EPS Bearer Context Reject ** - ** message ** + ** message ** ** ** - ** The activate dedicated EPS bearer context reject message ** - ** is sent by UE to the network to reject activation of a ** - ** dedicated EPS bearer context. ** + ** The activate dedicated EPS bearer context reject message ** + ** is sent by UE to the network to reject activation of a ** + ** dedicated EPS bearer context. ** ** ** - ** Inputs: ebi: EPS bearer identity ** - ** esm_cause: ESM cause code ** - ** Others: None ** + ** Inputs: ebi: EPS bearer identity ** + ** esm_cause: ESM cause code ** + ** Others: None ** ** ** - ** Outputs: msg: The ESM message to be sent ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: msg: The ESM message to be sent ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ 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; @@ -365,32 +365,32 @@ int esm_send_activate_dedicated_eps_bearer_context_reject(int ebi, msg->presencemask = 0; LOG_TRACE(INFO, "ESM-SAP - Send Activate Dedicated EPS Bearer Context " - "Reject message (pti=%d, ebi=%d)", - msg->proceduretransactionidentity, msg->epsbeareridentity); + "Reject message (pti=%d, ebi=%d)", + msg->proceduretransactionidentity, msg->epsbeareridentity); LOG_FUNC_RETURN(RETURNok); } /**************************************************************************** ** ** - ** Name: esm_send_deactivate_eps_bearer_context_accept() ** + ** Name: esm_send_deactivate_eps_bearer_context_accept() ** ** ** ** Description: Builds Deactivate EPS Bearer Context Accept message ** ** ** - ** The deactivate EPS bearer context accept message is sent ** - ** by the UE to acknowledge deactivation of an EPS bearer ** - ** context. ** + ** The deactivate EPS bearer context accept message is sent ** + ** by the UE to acknowledge deactivation of an EPS bearer ** + ** context. ** ** ** - ** Inputs: ebi: EPS bearer identity ** - ** Others: None ** + ** Inputs: ebi: EPS bearer identity ** + ** Others: None ** ** ** - ** Outputs: msg: The ESM message to be sent ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: msg: The ESM message to be sent ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ 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; @@ -404,8 +404,8 @@ int esm_send_deactivate_eps_bearer_context_accept(int ebi, msg->presencemask = 0; LOG_TRACE(INFO, "ESM-SAP - Send Deactivate EPS Bearer Context Accept" - " message (pti=%d, ebi=%d)", - msg->proceduretransactionidentity, msg->epsbeareridentity); + " message (pti=%d, ebi=%d)", + msg->proceduretransactionidentity, msg->epsbeareridentity); LOG_FUNC_RETURN(RETURNok); } @@ -419,25 +419,25 @@ int esm_send_deactivate_eps_bearer_context_accept(int ebi, #ifdef NAS_MME /**************************************************************************** ** ** - ** Name: esm_send_pdn_connectivity_reject() ** + ** Name: esm_send_pdn_connectivity_reject() ** ** ** ** Description: Builds PDN Connectivity Reject message ** ** ** - ** The PDN connectivity reject message is sent by the net- ** - ** work to the UE to reject establishment of a PDN connec- ** - ** tion. ** + ** The PDN connectivity reject message is sent by the net- ** + ** work to the UE to reject establishment of a PDN connec- ** + ** tion. ** ** ** - ** Inputs: pti: Procedure transaction identity ** - ** esm_cause: ESM cause code ** - ** Others: None ** + ** Inputs: pti: Procedure transaction identity ** + ** esm_cause: ESM cause code ** + ** Others: None ** ** ** - ** Outputs: msg: The ESM message to be sent ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: msg: The ESM message to be sent ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ -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) { LOG_FUNC_IN; @@ -453,32 +453,32 @@ int esm_send_pdn_connectivity_reject(int pti, pdn_connectivity_reject_msg* msg, msg->presencemask = 0; LOG_TRACE(INFO, "ESM-SAP - Send PDN Connectivity Reject message " - "(pti=%d, ebi=%d)", - msg->proceduretransactionidentity, msg->epsbeareridentity); + "(pti=%d, ebi=%d)", + msg->proceduretransactionidentity, msg->epsbeareridentity); LOG_FUNC_RETURN(RETURNok); } /**************************************************************************** ** ** - ** Name: esm_send_pdn_disconnect_reject() ** + ** Name: esm_send_pdn_disconnect_reject() ** ** ** ** Description: Builds PDN Disconnect Reject message ** ** ** - ** The PDN disconnect reject message is sent by the network ** - ** to the UE to reject release of a PDN connection. ** + ** The PDN disconnect reject message is sent by the network ** + ** to the UE to reject release of a PDN connection. ** ** ** - ** Inputs: pti: Procedure transaction identity ** - ** esm_cause: ESM cause code ** - ** Others: None ** + ** Inputs: pti: Procedure transaction identity ** + ** esm_cause: ESM cause code ** + ** Others: None ** ** ** - ** Outputs: msg: The ESM message to be sent ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: msg: The ESM message to be sent ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ -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) { LOG_FUNC_IN; @@ -494,41 +494,41 @@ int esm_send_pdn_disconnect_reject(int pti, pdn_disconnect_reject_msg* msg, msg->presencemask = 0; LOG_TRACE(INFO, "ESM-SAP - Send PDN Disconnect Reject message " - "(pti=%d, ebi=%d)", - msg->proceduretransactionidentity, msg->epsbeareridentity); + "(pti=%d, ebi=%d)", + msg->proceduretransactionidentity, msg->epsbeareridentity); LOG_FUNC_RETURN(RETURNok); } /**************************************************************************** ** ** - ** Name: esm_send_activate_default_eps_bearer_context_request() ** + ** Name: esm_send_activate_default_eps_bearer_context_request() ** ** ** ** Description: Builds Activate Default EPS Bearer Context Request ** - ** message ** + ** message ** ** ** - ** The activate default EPS bearer context request message ** - ** is sent by the network to the UE to request activation of ** - ** a default EPS bearer context. ** + ** The activate default EPS bearer context request message ** + ** is sent by the network to the UE to request activation of ** + ** a default EPS bearer context. ** ** ** - ** Inputs: pti: Procedure transaction identity ** - ** ebi: EPS bearer identity ** - ** qos: Subscribed EPS quality of service ** - ** apn: Access Point Name in used ** - ** pdn_addr: PDN IPv4 address and/or IPv6 suffix ** - ** esm_cause: ESM cause code ** - ** Others: None ** + ** Inputs: pti: Procedure transaction identity ** + ** ebi: EPS bearer identity ** + ** qos: Subscribed EPS quality of service ** + ** apn: Access Point Name in used ** + ** pdn_addr: PDN IPv4 address and/or IPv6 suffix ** + ** esm_cause: ESM cause code ** + ** Others: None ** ** ** - ** Outputs: msg: The ESM message to be sent ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: msg: The ESM message to be sent ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ 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; @@ -551,49 +551,49 @@ int esm_send_activate_default_eps_bearer_context_request(int pti, int ebi, /* Optional - ESM cause code */ msg->presencemask = 0; if (esm_cause != ESM_CAUSE_SUCCESS) { - msg->presencemask |= - ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_ESM_CAUSE_PRESENT; - msg->esmcause = esm_cause; + msg->presencemask |= + ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_ESM_CAUSE_PRESENT; + msg->esmcause = esm_cause; } LOG_TRACE(INFO, "ESM-SAP - Send Activate Default EPS Bearer Context " - "Request message (pti=%d, ebi=%d)", - msg->proceduretransactionidentity, msg->epsbeareridentity); + "Request message (pti=%d, ebi=%d)", + msg->proceduretransactionidentity, msg->epsbeareridentity); LOG_FUNC_RETURN(RETURNok); } /**************************************************************************** ** ** - ** Name: esm_send_activate_dedicated_eps_bearer_context_request() ** + ** Name: esm_send_activate_dedicated_eps_bearer_context_request() ** ** ** ** Description: Builds Activate Dedicated EPS Bearer Context Request ** - ** message ** - ** ** - ** The activate dedicated EPS bearer context request message ** - ** is sent by the network to the UE to request activation of ** - ** a dedicated EPS bearer context associated with the same ** - ** PDN address(es) and APN as an already active default EPS ** - ** bearer context. ** - ** ** - ** Inputs: pti: Procedure transaction identity ** - ** ebi: EPS bearer identity ** - ** linked_ebi: EPS bearer identity of the default bearer ** - ** associated with the EPS dedicated bearer ** - ** to be activated ** - ** qos: EPS quality of service ** - ** tft: Traffic flow template ** - ** Others: None ** - ** ** - ** Outputs: msg: The ESM message to be sent ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** message ** + ** ** + ** The activate dedicated EPS bearer context request message ** + ** is sent by the network to the UE to request activation of ** + ** a dedicated EPS bearer context associated with the same ** + ** PDN address(es) and APN as an already active default EPS ** + ** bearer context. ** + ** ** + ** Inputs: pti: Procedure transaction identity ** + ** ebi: EPS bearer identity ** + ** linked_ebi: EPS bearer identity of the default bearer ** + ** associated with the EPS dedicated bearer ** + ** to be activated ** + ** qos: EPS quality of service ** + ** tft: Traffic flow template ** + ** Others: None ** + ** ** + ** Outputs: msg: The ESM message to be sent ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ 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,44 +611,43 @@ 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++) - { - msg->tft.packetfilterlist.createtft[i] = (*pkfs)[i]; + for (i = 0; i < msg->tft.numberofpacketfilters; i++) { + msg->tft.packetfilterlist.createtft[i] = (*pkfs)[i]; } /* Optional */ msg->presencemask = 0; LOG_TRACE(INFO, "ESM-SAP - Send Activate Dedicated EPS Bearer Context " - "Request message (pti=%d, ebi=%d)", - msg->proceduretransactionidentity, msg->epsbeareridentity); + "Request message (pti=%d, ebi=%d)", + msg->proceduretransactionidentity, msg->epsbeareridentity); LOG_FUNC_RETURN(RETURNok); } /**************************************************************************** ** ** - ** Name: esm_send_deactivate_eps_bearer_context_request() ** + ** Name: esm_send_deactivate_eps_bearer_context_request() ** ** ** ** Description: Builds Deactivate EPS Bearer Context Request message ** ** ** - ** The deactivate EPS bearer context request message is sent ** - ** by the network to request deactivation of an active EPS ** - ** bearer context. ** + ** The deactivate EPS bearer context request message is sent ** + ** by the network to request deactivation of an active EPS ** + ** bearer context. ** ** ** - ** Inputs: pti: Procedure transaction identity ** - ** ebi: EPS bearer identity ** - ** esm_cause: ESM cause code ** - ** Others: None ** + ** Inputs: pti: Procedure transaction identity ** + ** ebi: EPS bearer identity ** + ** esm_cause: ESM cause code ** + ** Others: None ** ** ** - ** Outputs: msg: The ESM message to be sent ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: msg: The ESM message to be sent ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ int esm_send_deactivate_eps_bearer_context_request(int pti, int ebi, - deactivate_eps_bearer_context_request_msg* msg, - int esm_cause) + deactivate_eps_bearer_context_request_msg *msg, + int esm_cause) { LOG_FUNC_IN; @@ -664,8 +663,8 @@ int esm_send_deactivate_eps_bearer_context_request(int pti, int ebi, msg->presencemask = 0; LOG_TRACE(INFO, "ESM-SAP - Send Deactivate EPS Bearer Context Request " - "message (pti=%d, ebi=%d)", - msg->proceduretransactionidentity, msg->epsbeareridentity); + "message (pti=%d, ebi=%d)", + msg->proceduretransactionidentity, msg->epsbeareridentity); LOG_FUNC_RETURN(RETURNok); } diff --git a/openair-cn/NAS/EURECOM-NAS/src/esm/sap/esm_send.h b/openair-cn/NAS/EURECOM-NAS/src/esm/sap/esm_send.h index 7dd4674900..91039833f2 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/esm/sap/esm_send.h +++ b/openair-cn/NAS/EURECOM-NAS/src/esm/sap/esm_send.h @@ -1,22 +1,22 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source esm_send.h +Source esm_send.h -Version 0.1 +Version 0.1 -Date 2013/02/11 +Date 2013/02/11 -Product NAS stack +Product NAS stack -Subsystem EPS Session Management +Subsystem EPS Session Management -Author Frederic Maurel +Author Frederic Maurel -Description Defines functions executed at the ESM Service Access - Point to send EPS Session Management messages to the - EPS Mobility Management sublayer. +Description Defines functions executed at the ESM Service Access + Point to send EPS Session Management messages to the + EPS Mobility Management sublayer. *****************************************************************************/ #ifndef __ESM_SEND_H__ @@ -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 diff --git a/openair-cn/NAS/EURECOM-NAS/src/include/securityDef.h b/openair-cn/NAS/EURECOM-NAS/src/include/securityDef.h index 108ce80bec..fe4412f351 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/include/securityDef.h +++ b/openair-cn/NAS/EURECOM-NAS/src/include/securityDef.h @@ -1,20 +1,20 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source securityDef.h +Source securityDef.h -Version 0.1 +Version 0.1 -Date 2013/05/02 +Date 2013/05/02 -Product NAS stack +Product NAS stack -Subsystem include +Subsystem include -Author Frederic Maurel +Author Frederic Maurel -Description Contains global security definitions +Description Contains global security definitions *****************************************************************************/ #ifndef __SECURITYDEF_H__ @@ -27,33 +27,33 @@ Description Contains global security definitions /* * Index of the first byte of each fields of the AUTN parameter */ -#define AUTH_SQN_INDEX 0 -#define AUTH_AMF_INDEX (AUTH_SQN_INDEX + AUTH_SQN_SIZE) -#define AUTH_MAC_INDEX (AUTH_AMF_INDEX + AUTH_AMF_SIZE) +#define AUTH_SQN_INDEX 0 +#define AUTH_AMF_INDEX (AUTH_SQN_INDEX + AUTH_SQN_SIZE) +#define AUTH_MAC_INDEX (AUTH_AMF_INDEX + AUTH_AMF_SIZE) /* * Size of the authentication challenge parameters in bytes */ -#define AUTH_SQN_SIZE 6 /* Sequence number: 48 bits */ -#define AUTH_AK_SIZE 6 /* Anonymity key: 48 bits */ -#define AUTH_AMF_SIZE 2 /* Authentication Management Field: 16 bits */ -#define AUTH_MAC_SIZE 8 /* Message Authentication Code: 64 bits */ -#define AUTH_AUTN_SIZE 16 /* Authentication token: 128 bits - AUTN = (SQN ⊕ AK) || AMF || MAC */ -#define AUTH_MACS_SIZE 8 /* Re-synchronization MAC: 64 bits */ -#define AUTH_AUTS_SIZE 16 /* Re-synchronization AUT: 128 bits */ -#define AUTH_RAND_SIZE 16 /* Random challenge: 128 bits */ -#define AUTH_CK_SIZE 16 /* Ciphering key: 128 bits */ -#define AUTH_IK_SIZE 16 /* Integrity key: 128 bits */ -#define AUTH_RES_SIZE 16 /* Authentication response: 128 bits */ -#define AUTH_SNID_SIZE 3 /* Serving network's identity: 24 bits */ -#define AUTH_KASME_SIZE 32 /* ASME security key: 256 bits */ -#define AUTH_KNAS_INT_SIZE AUTH_KASME_SIZE /* NAS integrity key */ -#define AUTH_KNAS_ENC_SIZE AUTH_KASME_SIZE /* NAS cyphering key */ -#define AUTH_KENB_SIZE AUTH_KASME_SIZE /* eNodeB security key */ +#define AUTH_SQN_SIZE 6 /* Sequence number: 48 bits */ +#define AUTH_AK_SIZE 6 /* Anonymity key: 48 bits */ +#define AUTH_AMF_SIZE 2 /* Authentication Management Field: 16 bits */ +#define AUTH_MAC_SIZE 8 /* Message Authentication Code: 64 bits */ +#define AUTH_AUTN_SIZE 16 /* Authentication token: 128 bits + AUTN = (SQN ⊕ AK) || AMF || MAC */ +#define AUTH_MACS_SIZE 8 /* Re-synchronization MAC: 64 bits */ +#define AUTH_AUTS_SIZE 16 /* Re-synchronization AUT: 128 bits */ +#define AUTH_RAND_SIZE 16 /* Random challenge: 128 bits */ +#define AUTH_CK_SIZE 16 /* Ciphering key: 128 bits */ +#define AUTH_IK_SIZE 16 /* Integrity key: 128 bits */ +#define AUTH_RES_SIZE 16 /* Authentication response: 128 bits */ +#define AUTH_SNID_SIZE 3 /* Serving network's identity: 24 bits */ +#define AUTH_KASME_SIZE 32 /* ASME security key: 256 bits */ +#define AUTH_KNAS_INT_SIZE AUTH_KASME_SIZE /* NAS integrity key */ +#define AUTH_KNAS_ENC_SIZE AUTH_KASME_SIZE /* NAS cyphering key */ +#define AUTH_KENB_SIZE AUTH_KASME_SIZE /* eNodeB security key */ /* "Separation bit" of AMF field */ -#define AUTH_AMF_SEPARATION_BIT(a) ((a) & 0x80) +#define AUTH_AMF_SEPARATION_BIT(a) ((a) & 0x80) /****************************************************************************/ /************************ G L O B A L T Y P E S ************************/ @@ -63,14 +63,14 @@ Description Contains global security definitions * EPS authentication vector */ typedef struct { - /* ASME security key */ + /* ASME security key */ char kasme[AUTH_KASME_SIZE + 1]; - /* Random challenge parameter */ + /* Random challenge parameter */ char rand[AUTH_RAND_SIZE + 1]; - /* Authentication token parameter */ + /* Authentication token parameter */ char autn[AUTH_AUTN_SIZE + 1]; - /* Expected Authentication response parameter */ -#define AUTH_XRES_SIZE AUTH_RES_SIZE + /* Expected Authentication response parameter */ +#define AUTH_XRES_SIZE AUTH_RES_SIZE char xres[AUTH_XRES_SIZE + 1]; } auth_vector_t; diff --git a/openair-cn/NAS/EURECOM-NAS/src/include/userDef.h b/openair-cn/NAS/EURECOM-NAS/src/include/userDef.h index 3f075212d8..943db69420 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/include/userDef.h +++ b/openair-cn/NAS/EURECOM-NAS/src/include/userDef.h @@ -1,20 +1,20 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source userDef.h +Source userDef.h -Version 0.1 +Version 0.1 -Date 2012/09/21 +Date 2012/09/21 -Product NAS stack +Product NAS stack -Subsystem include +Subsystem include -Author Frederic Maurel +Author Frederic Maurel -Description Contains user's global definitions +Description Contains user's global definitions *****************************************************************************/ #ifndef __USERDEF_H__ @@ -30,13 +30,13 @@ Description Contains user's global definitions * The name of the file used as non-volatile memory device to store * UE data parameters */ -#define USER_NVRAM_FILENAME ".ue.nvram" +#define USER_NVRAM_FILENAME ".ue.nvram" /* * The name of the environment variable which defines the directory * where the UE data file is located */ -#define USER_NVRAM_DIRNAME "NVRAM_DIR" +#define USER_NVRAM_DIRNAME "NVRAM_DIR" /****************************************************************************/ /************************ G L O B A L T Y P E S ************************/ @@ -48,17 +48,17 @@ Description Contains user's global definitions * ------------------------------ */ typedef struct { - /* International Mobile Equipment Identity */ -#define USER_IMEI_SIZE 15 + /* International Mobile Equipment Identity */ +#define USER_IMEI_SIZE 15 char IMEI[USER_IMEI_SIZE+1]; - /* Manufacturer identifier */ -#define USER_MANUFACTURER_SIZE 16 + /* Manufacturer identifier */ +#define USER_MANUFACTURER_SIZE 16 char manufacturer[USER_MANUFACTURER_SIZE+1]; - /* Model identifier */ -#define USER_MODEL_SIZE 16 + /* Model identifier */ +#define USER_MODEL_SIZE 16 char model[USER_MODEL_SIZE+1]; - /* SIM Personal Identification Number */ -#define USER_PIN_SIZE 4 + /* SIM Personal Identification Number */ +#define USER_PIN_SIZE 4 char PIN[USER_PIN_SIZE+1]; } user_nvdata_t; diff --git a/openair-cn/NAS/EURECOM-NAS/src/nas_network.c b/openair-cn/NAS/EURECOM-NAS/src/nas_network.c index e19efd2901..52bc5ffaa2 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/nas_network.c +++ b/openair-cn/NAS/EURECOM-NAS/src/nas_network.c @@ -1,20 +1,20 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source nas_network.h +Source nas_network.h -Version 0.1 +Version 0.1 -Date 2012/09/20 +Date 2012/09/20 -Product NAS stack +Product NAS stack -Subsystem NAS main process +Subsystem NAS main process -Author Frederic Maurel +Author Frederic Maurel -Description NAS procedure functions triggered by the network +Description NAS procedure functions triggered by the network *****************************************************************************/ @@ -39,16 +39,16 @@ Description NAS procedure functions triggered by the network /**************************************************************************** ** ** - ** Name: nas_network_initialize() ** + ** Name: nas_network_initialize() ** ** ** ** Description: Initializes network internal data ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: None ** - ** Others: None ** + ** Outputs: None ** + ** Return: None ** + ** Others: None ** ** ** ***************************************************************************/ void nas_network_initialize(void) @@ -65,16 +65,16 @@ void nas_network_initialize(void) /**************************************************************************** ** ** - ** Name: nas_network_cleanup() ** + ** Name: nas_network_cleanup() ** ** ** ** Description: Performs clean up procedure before the system is shutdown ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: None ** - ** Others: None ** + ** Outputs: None ** + ** Return: None ** + ** Others: None ** ** ** ***************************************************************************/ void nas_network_cleanup(void) @@ -88,155 +88,145 @@ void nas_network_cleanup(void) /**************************************************************************** ** ** - ** Name: nas_network_process_data() ** + ** Name: nas_network_process_data() ** ** ** ** Description: Process Access Stratum messages received from the network ** - ** and call applicable NAS procedure function. ** + ** and call applicable NAS procedure function. ** ** ** - ** Inputs: msg_id: AS message identifier ** - ** data: Generic pointer to data structure that has ** - ** to be processed ** - ** Others: None ** + ** Inputs: msg_id: AS message identifier ** + ** data: Generic pointer to data structure that has ** + ** to be processed ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok if the message has been success- ** - ** fully processed; RETURNerror otherwise ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok if the message has been success- ** + ** fully processed; RETURNerror otherwise ** + ** 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 */ if (msg_id != msg->msgID) { - LOG_TRACE(ERROR, "NET-MAIN - Message identifier 0x%x to process " - "is different from that of the network data (0x%x)", - msg_id, msg->msgID); - LOG_FUNC_RETURN (RETURNerror); + LOG_TRACE(ERROR, "NET-MAIN - Message identifier 0x%x to process " + "is different from that of the network data (0x%x)", + msg_id, msg->msgID); + LOG_FUNC_RETURN (RETURNerror); } - switch (msg_id) - { + switch (msg_id) { #ifdef NAS_UE - case AS_BROADCAST_INFO_IND: - break; - - case AS_CELL_INFO_CNF: - { - /* Received cell information confirm */ - 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, - info->rsrp, info->rsrq); - break; - } - - case AS_CELL_INFO_IND: - break; - - case AS_PAGING_IND: - break; - - case AS_NAS_ESTABLISH_CNF: - { - /* Received NAS signalling connection establishment confirm */ - 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 { - LOG_TRACE(WARNING, "NET-MAIN - " - "Initial NAS message not delivered"); - rc = nas_proc_establish_rej(); - } - break; - } - - case AS_NAS_RELEASE_IND: - /* Received NAS signalling connection releaase indication */ - rc = nas_proc_release_ind(msg->msg.nas_release_ind.cause); - break; - - case AS_UL_INFO_TRANSFER_CNF: - /* Received uplink data transfer confirm */ - if (msg->msg.ul_info_transfer_cnf.errCode != AS_SUCCESS) { - LOG_TRACE(WARNING, "NET-MAIN - " - "Uplink NAS message not delivered"); - rc = nas_proc_ul_transfer_rej(); - } - 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; - /* Received downlink data transfer indication */ - rc = nas_proc_dl_transfer_ind(info->nasMsg.data, - info->nasMsg.length); - break; - } - - case AS_RAB_ESTABLISH_IND: - break; - - case AS_RAB_RELEASE_IND: - break; + case AS_BROADCAST_INFO_IND: + break; + + case AS_CELL_INFO_CNF: { + /* Received cell information confirm */ + 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, + info->rsrp, info->rsrq); + break; + } + + case AS_CELL_INFO_IND: + break; + + case AS_PAGING_IND: + break; + + case AS_NAS_ESTABLISH_CNF: { + /* Received NAS signalling connection establishment confirm */ + 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 { + LOG_TRACE(WARNING, "NET-MAIN - " + "Initial NAS message not delivered"); + rc = nas_proc_establish_rej(); + } + break; + } + + case AS_NAS_RELEASE_IND: + /* Received NAS signalling connection releaase indication */ + rc = nas_proc_release_ind(msg->msg.nas_release_ind.cause); + break; + + case AS_UL_INFO_TRANSFER_CNF: + /* Received uplink data transfer confirm */ + if (msg->msg.ul_info_transfer_cnf.errCode != AS_SUCCESS) { + LOG_TRACE(WARNING, "NET-MAIN - " + "Uplink NAS message not delivered"); + rc = nas_proc_ul_transfer_rej(); + } 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; + /* Received downlink data transfer indication */ + rc = nas_proc_dl_transfer_ind(info->nasMsg.data, + info->nasMsg.length); + break; + } + + case AS_RAB_ESTABLISH_IND: + break; + + case AS_RAB_RELEASE_IND: + break; #endif #ifdef NAS_MME - case AS_NAS_ESTABLISH_IND: - { - /* Received NAS signalling connection establishment indication */ - const nas_establish_ind_t* indication = &msg->msg.nas_establish_ind; - rc = nas_proc_establish_ind(indication->UEid, - indication->tac, - indication->initialNasMsg.data, - indication->initialNasMsg.length); - break; - } - - 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 { - 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; - /* Received uplink data transfer indication */ - rc = nas_proc_ul_transfer_ind(info->UEid, - info->nasMsg.data, - info->nasMsg.length); - break; - } - - case AS_RAB_ESTABLISH_CNF: - break; + case AS_NAS_ESTABLISH_IND: { + /* Received NAS signalling connection establishment indication */ + const nas_establish_ind_t *indication = &msg->msg.nas_establish_ind; + rc = nas_proc_establish_ind(indication->UEid, + indication->tac, + indication->initialNasMsg.data, + indication->initialNasMsg.length); + break; + } + + 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 { + 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; + /* Received uplink data transfer indication */ + rc = nas_proc_ul_transfer_ind(info->UEid, + info->nasMsg.data, + info->nasMsg.length); + break; + } + + case AS_RAB_ESTABLISH_CNF: + break; #endif - default: + default: LOG_TRACE(ERROR, "NET-MAIN - Unexpected AS message type: 0x%x", - msg_id); - rc = RETURNerror; - break; + msg_id); + rc = RETURNerror; + break; } LOG_FUNC_RETURN (rc); diff --git a/openair-cn/NAS/EURECOM-NAS/src/nas_network.h b/openair-cn/NAS/EURECOM-NAS/src/nas_network.h index 3534e23be6..608aadad43 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/nas_network.h +++ b/openair-cn/NAS/EURECOM-NAS/src/nas_network.h @@ -1,20 +1,20 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source nas_network.h +Source nas_network.h -Version 0.1 +Version 0.1 -Date 2012/09/20 +Date 2012/09/20 -Product NAS stack +Product NAS stack -Subsystem NAS main process +Subsystem NAS main process -Author Frederic Maurel +Author Frederic Maurel -Description NAS procedure functions triggered by the network +Description NAS procedure functions triggered by the network *****************************************************************************/ #ifndef __NAS_NETWORK_H__ @@ -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__*/ diff --git a/openair-cn/NAS/EURECOM-NAS/src/nas_parser.c b/openair-cn/NAS/EURECOM-NAS/src/nas_parser.c index 0ebd77b244..641b2703a4 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/nas_parser.c +++ b/openair-cn/NAS/EURECOM-NAS/src/nas_parser.c @@ -1,26 +1,26 @@ /***************************************************************************** -Source nas_parser.c +Source nas_parser.c -Version 0.1 +Version 0.1 -Date 2012/02/27 +Date 2012/02/27 -Product NAS stack +Product NAS stack -Subsystem NAS main process +Subsystem NAS main process -Author Frederic Maurel +Author Frederic Maurel -Description NAS command line parser +Description NAS command line parser *****************************************************************************/ #include "nas_parser.h" #include "parser.h" -#include <stdio.h> // fprintf -#include <stdlib.h> // atoi +#include <stdio.h> // fprintf +#include <stdlib.h> // atoi /****************************************************************************/ /**************** E X T E R N A L D E F I N I T I O N S ****************/ @@ -33,23 +33,22 @@ Description NAS command line parser /* * Identifiers of the NAS command line options */ -enum -{ +enum { #ifdef NAS_UE - NAS_PARSER_UE_ID, /* User Equipement Identifier */ + NAS_PARSER_UE_ID, /* User Equipement Identifier */ #endif // NAS_UE - NAS_PARSER_TRACE_LEVEL, /* Logging trace level */ + NAS_PARSER_TRACE_LEVEL, /* Logging trace level */ #ifdef NAS_UE - NAS_PARSER_USER_HOST, /* User app layer's hostname */ + NAS_PARSER_USER_HOST, /* User app layer's hostname */ #endif // NAS_UE - NAS_PARSER_NETWORK_HOST, /* Network layer's hostname */ + NAS_PARSER_NETWORK_HOST, /* Network layer's hostname */ #ifdef NAS_UE - NAS_PARSER_USER_PORT, /* User app layer's port number */ + NAS_PARSER_USER_PORT, /* User app layer's port number */ #endif // NAS_UE - NAS_PARSER_NETWORK_PORT, /* Network layer's port number */ + NAS_PARSER_NETWORK_PORT, /* Network layer's port number */ #ifdef NAS_UE - NAS_PARSER_DEVICE_PATH, /* Device pathname */ - NAS_PARSER_DEVICE_ATTR, /* Device attribute parameters */ + NAS_PARSER_DEVICE_PATH, /* Device pathname */ + NAS_PARSER_DEVICE_ATTR, /* Device attribute parameters */ #endif // NAS_UE NAS_PARSER_NB_OPTIONS }; @@ -57,37 +56,49 @@ enum /* ----------------------------------------------------- * Definition of the internal NAS command line structure * ----------------------------------------------------- - * The command line is defined with a name (default is "NASprocess" - * but it will be replaced by the command name actually used at - * runtime), a number of options and the list of options. - * An option is defined with a name, an argument following the name, - * the usage displayed by the usage function and a default value. + * The command line is defined with a name (default is "NASprocess" + * but it will be replaced by the command name actually used at + * runtime), a number of options and the list of options. + * An option is defined with a name, an argument following the name, + * the usage displayed by the usage function and a default value. */ static parser_command_line_t nasParserCommandLine = { - "NASprocess", /* Command name */ - NAS_PARSER_NB_OPTIONS, /* Number of options */ - { /* Command line options */ + "NASprocess", /* Command name */ + 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"}, + {"-dev", "<devpath>", "Device pathname\t\t", "NULL"}, + {"-params", "<params>", "Device attribute parameters", "NULL"}, #endif // NAS_UE } }; @@ -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 ******************/ @@ -103,20 +114,20 @@ static int atohex(const char* a_char); /**************************************************************************** ** ** - ** Name: nas_parser_print_usage() ** + ** Name: nas_parser_print_usage() ** ** ** ** Description: Displays the command line options used to run the NAS ** - ** process and the firmware version defined at compilation ** - ** time ** + ** process and the firmware version defined at compilation ** + ** time ** ** ** - ** Inputs: version: Firmware version ** - ** Others: None ** + ** Inputs: version: Firmware version ** + ** Others: None ** ** ** - ** Outputs: Return: None ** - ** Others: None ** + ** Outputs: Return: None ** + ** 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); @@ -124,35 +135,35 @@ void nas_parser_print_usage(const char* version) /**************************************************************************** ** ** - ** Name: nas_parser_get_options() ** + ** Name: nas_parser_get_options() ** ** ** ** Description: Gets the command line options used to run the NAS process ** ** ** - ** Inputs: argc: Number of options ** - ** argv: Pointer to the list of options ** - ** Others: None ** + ** Inputs: argc: Number of options ** + ** argv: Pointer to the list of options ** + ** Others: None ** ** ** - ** Outputs: Return: RETURNerror, RETURNok ** - ** Others: None ** + ** Outputs: Return: RETURNerror, RETURNok ** + ** 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); } /**************************************************************************** ** ** - ** Name: nas_parser_get_nb_options() ** + ** Name: nas_parser_get_nb_options() ** ** ** ** Description: Returns the number of the command line options used to ** - ** run the NAS process ** + ** run the NAS process ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: Return: Number of command line options ** - ** Others: None ** + ** Outputs: Return: Number of command line options ** + ** Others: None ** ** ** ***************************************************************************/ int nas_parser_get_nb_options(void) @@ -162,15 +173,15 @@ int nas_parser_get_nb_options(void) /**************************************************************************** ** ** - ** Name: nas_parser_get_trace_level() ** + ** Name: nas_parser_get_trace_level() ** ** ** ** Description: Returns the value of the logging trace level ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: Return: Value of the logging trace level ** - ** Others: None ** + ** Outputs: Return: Value of the logging trace level ** + ** Others: None ** ** ** ***************************************************************************/ int nas_parser_get_trace_level(void) @@ -180,36 +191,36 @@ int nas_parser_get_trace_level(void) /**************************************************************************** ** ** - ** Name: nas_parser_get_network_host() ** + ** Name: nas_parser_get_network_host() ** ** ** ** Description: Returns the value of the network layer hostname ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: Return: Value of the network layer hostname ** - ** Others: None ** + ** Outputs: Return: Value of the network layer hostname ** + ** 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; } /**************************************************************************** ** ** - ** Name: nas_parser_get_network_port() ** + ** Name: nas_parser_get_network_port() ** ** ** ** Description: Returns the value of the network layer port number ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: Return: Value of the network layer port number ** - ** Others: None ** + ** Outputs: Return: Value of the network layer port number ** + ** 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; } @@ -217,15 +228,15 @@ const char* nas_parser_get_network_port(void) #ifdef NAS_UE /**************************************************************************** ** ** - ** Name: nas_parser_get_ueid() ** + ** Name: nas_parser_get_ueid() ** ** ** ** Description: Returns the value of the UE identifier option ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: Return: Value of the UE identifier option ** - ** Others: None ** + ** Outputs: Return: Value of the UE identifier option ** + ** Others: None ** ** ** ***************************************************************************/ int nas_parser_get_ueid(void) @@ -235,73 +246,73 @@ int nas_parser_get_ueid(void) /**************************************************************************** ** ** - ** Name: nas_parser_get_user_host() ** + ** Name: nas_parser_get_user_host() ** ** ** ** Description: Returns the value of the user application layer hostname ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: Return: Value of the user app layer hostname ** - ** Others: None ** + ** Outputs: Return: Value of the user app layer hostname ** + ** 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; } /**************************************************************************** ** ** - ** Name: nas_parser_get_user_port() ** + ** Name: nas_parser_get_user_port() ** ** ** ** Description: Returns the value of the user application layer port ** - ** number ** + ** number ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: Return: Value of the user app layer port number ** - ** Others: None ** + ** Outputs: Return: Value of the user app layer port number ** + ** 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; } /**************************************************************************** ** ** - ** Name: nas_parser_get_device_path() ** + ** Name: nas_parser_get_device_path() ** ** ** ** Description: Returns the value of the device pathname ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: Return: Value of the device pathname ** - ** Others: None ** + ** Outputs: Return: Value of the device pathname ** + ** 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; } /**************************************************************************** ** ** - ** Name: nas_parser_get_device_params() ** + ** Name: nas_parser_get_device_params() ** ** ** ** Description: Returns the value of the device attribute parameters ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: Return: Value of the device attribute parameters ** - ** Others: None ** + ** Outputs: Return: Value of the device attribute parameters ** + ** 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,28 +322,20 @@ 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') - { - result = (result << 4) + (*a_char - '0'); - } - else if (*a_char >= 'A' && *a_char <= 'F') - { - result = (result << 4) + (*a_char - 'A' + 10); - } - else if (*a_char >= 'a' && *a_char <= 'f') - { - result = (result << 4) + (*a_char - 'a' + 10); - } - else - { - break; - } + 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') { + result = (result << 4) + (*a_char - 'A' + 10); + } else if (*a_char >= 'a' && *a_char <= 'f') { + result = (result << 4) + (*a_char - 'a' + 10); + } else { + break; + } } return result; } diff --git a/openair-cn/NAS/EURECOM-NAS/src/nas_parser.h b/openair-cn/NAS/EURECOM-NAS/src/nas_parser.h index 7421889cae..8067715461 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/nas_parser.h +++ b/openair-cn/NAS/EURECOM-NAS/src/nas_parser.h @@ -1,18 +1,18 @@ /***************************************************************************** -Source nas_parser.h +Source nas_parser.h -Version 0.1 +Version 0.1 -Date 2012/02/27 +Date 2012/02/27 -Product NAS stack +Product NAS stack -Subsystem NAS main process +Subsystem NAS main process -Author Frederic Maurel +Author Frederic Maurel -Description NAS command line parser +Description NAS command line parser *****************************************************************************/ #ifndef __NAS_PARSER_H__ @@ -23,23 +23,23 @@ Description NAS command line parser /****************************************************************************/ /* Logging trace level default value */ -#define NAS_PARSER_DEFAULT_TRACE_LEVEL "0" /* No trace */ +#define NAS_PARSER_DEFAULT_TRACE_LEVEL "0" /* No trace */ /* Network layer default hostname */ -#define NAS_PARSER_DEFAULT_NETWORK_HOSTNAME "localhost" +#define NAS_PARSER_DEFAULT_NETWORK_HOSTNAME "localhost" /* Network layer default port number */ -#define NAS_PARSER_DEFAULT_NETWORK_PORT_NUMBER "12000" +#define NAS_PARSER_DEFAULT_NETWORK_PORT_NUMBER "12000" #ifdef NAS_UE /* User Identifier default value */ -#define NAS_PARSER_DEFAULT_UE_ID "1" +#define NAS_PARSER_DEFAULT_UE_ID "1" /* User application layer default hostname */ -#define NAS_PARSER_DEFAULT_USER_HOSTNAME "localhost" +#define NAS_PARSER_DEFAULT_USER_HOSTNAME "localhost" /* User application layer default port number */ -#define NAS_PARSER_DEFAULT_USER_PORT_NUMBER "10000" +#define NAS_PARSER_DEFAULT_USER_PORT_NUMBER "10000" #endif // NAS_UE /****************************************************************************/ @@ -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__*/ diff --git a/openair-cn/NAS/EURECOM-NAS/src/nas_proc.c b/openair-cn/NAS/EURECOM-NAS/src/nas_proc.c index 1ab93afb1a..2f88b016cc 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/nas_proc.c +++ b/openair-cn/NAS/EURECOM-NAS/src/nas_proc.c @@ -1,20 +1,20 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source nas_proc.c +Source nas_proc.c -Version 0.1 +Version 0.1 -Date 2012/09/20 +Date 2012/09/20 -Product NAS stack +Product NAS stack -Subsystem NAS main process +Subsystem NAS main process -Author Frederic Maurel +Author Frederic Maurel -Description NAS procedure call manager +Description NAS procedure call manager *****************************************************************************/ @@ -27,7 +27,7 @@ Description NAS procedure call manager #include "esm_main.h" #include "esm_sap.h" -#include <stdio.h> // sprintf +#include <stdio.h> // sprintf /****************************************************************************/ /**************** E X T E R N A L D E F I N I T I O N S ****************/ @@ -41,8 +41,8 @@ Description NAS procedure call manager /* * Signal strength/quality value not known or not detectable */ -#define NAS_PROC_RSRQ_UNKNOWN 255 -#define NAS_PROC_RSRP_UNKNOWN 255 +#define NAS_PROC_RSRQ_UNKNOWN 255 +#define NAS_PROC_RSRP_UNKNOWN 255 /* * Local NAS data @@ -50,9 +50,9 @@ Description NAS procedure call manager static struct { /* EPS capibility status */ int EPS_capability_status; - /* Reference signal received quality */ + /* Reference signal received quality */ int rsrq; - /* Reference signal received power */ + /* Reference signal received power */ int rsrp; } _nas_proc_data; @@ -66,23 +66,23 @@ static int _nas_proc_deactivate(int cid, int apply_to_all); #ifdef NAS_UE /**************************************************************************** ** ** - ** Name: nas_proc_initialize() ** + ** Name: nas_proc_initialize() ** ** ** ** Description: ** ** ** - ** Inputs: emm_cb: Mobility Management indication callback ** - ** esm_cb: Session Management indication callback ** - ** imei: The IMEI read from the UE's non-volatile ** - ** memory ** - ** Others: None ** + ** Inputs: emm_cb: Mobility Management indication callback ** + ** esm_cb: Session Management indication callback ** + ** imei: The IMEI read from the UE's non-volatile ** + ** memory ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: None ** - ** Others: _nas_proc_data ** + ** Outputs: None ** + ** Return: None ** + ** Others: _nas_proc_data ** ** ** ***************************************************************************/ 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; @@ -103,16 +103,16 @@ void nas_proc_initialize(emm_indication_callback_t emm_cb, #ifdef NAS_MME /**************************************************************************** ** ** - ** Name: nas_proc_initialize() ** + ** Name: nas_proc_initialize() ** ** ** ** Description: ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: None ** - ** Others: None ** + ** Outputs: None ** + ** Return: None ** + ** Others: None ** ** ** ***************************************************************************/ void nas_proc_initialize(void) @@ -131,16 +131,16 @@ void nas_proc_initialize(void) /**************************************************************************** ** ** - ** Name: nas_proc_cleanup() ** + ** Name: nas_proc_cleanup() ** ** ** ** Description: Performs clean up procedure before the system is shutdown ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: None ** - ** Others: None ** + ** Outputs: None ** + ** Return: None ** + ** Others: None ** ** ** ***************************************************************************/ void nas_proc_cleanup(void) @@ -151,7 +151,7 @@ void nas_proc_cleanup(void) /* Detach the UE from the EPS network */ int rc = nas_proc_detach(TRUE); if (rc != RETURNok) { - LOG_TRACE(ERROR, "NAS-PROC - Failed to detach from the network"); + LOG_TRACE(ERROR, "NAS-PROC - Failed to detach from the network"); } #endif @@ -166,23 +166,23 @@ void nas_proc_cleanup(void) /* * -------------------------------------------------------------------------- - * NAS procedures triggered by the user + * NAS procedures triggered by the user * -------------------------------------------------------------------------- */ #ifdef NAS_UE /**************************************************************************** ** ** - ** Name: nas_proc_enable_s1_mode() ** + ** Name: nas_proc_enable_s1_mode() ** ** ** ** Description: Notify the EPS Mobility Manager that the UE can be ** - ** operated ** + ** operated ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ int nas_proc_enable_s1_mode(void) @@ -205,17 +205,17 @@ int nas_proc_enable_s1_mode(void) /**************************************************************************** ** ** - ** Name: nas_proc_disable_s1_mode() ** + ** Name: nas_proc_disable_s1_mode() ** ** ** ** Description: Notify the EPS Mobility Manager that the S1 mode is no ** - ** longer activated ** + ** longer activated ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ int nas_proc_disable_s1_mode(void) @@ -238,20 +238,20 @@ int nas_proc_disable_s1_mode(void) /**************************************************************************** ** ** - ** Name: nas_proc_get_eps() ** + ** Name: nas_proc_get_eps() ** ** ** ** Description: Get the current value of the EPS capability status ** ** ** - ** Inputs: None ** - ** Others: _nas_proc_data ** + ** Inputs: None ** + ** Others: _nas_proc_data ** ** ** - ** Outputs: stat: The current value of the EPS capability ** - ** status ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: stat: The current value of the EPS capability ** + ** status ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ -int nas_proc_get_eps(int* stat) +int nas_proc_get_eps(int *stat) { LOG_FUNC_IN; @@ -262,42 +262,42 @@ int nas_proc_get_eps(int* stat) /**************************************************************************** ** ** - ** Name: nas_proc_get_imsi() ** + ** Name: nas_proc_get_imsi() ** ** ** ** Description: Get the International Mobile Subscriber Identity number ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: imsi: The value of the IMSI ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: imsi: The value of the IMSI ** + ** Return: RETURNok, RETURNerror ** + ** 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; - offset += sprintf(imsi_str + offset, "%u%u%u%u%u", - imsi->u.num.digit1, imsi->u.num.digit2, - imsi->u.num.digit3, imsi->u.num.digit4, - imsi->u.num.digit5); - if (imsi->u.num.digit6 != 0xf) { - offset += sprintf(imsi_str + offset, "%u", imsi->u.num.digit6); - } - offset += sprintf(imsi_str + offset, "%u%u%u%u%u%u%u%u", - imsi->u.num.digit7, imsi->u.num.digit8, - imsi->u.num.digit9, imsi->u.num.digit10, - imsi->u.num.digit11, imsi->u.num.digit12, - imsi->u.num.digit13, imsi->u.num.digit14); - if (imsi->u.num.digit15 != 0xf) { - offset += sprintf(imsi_str + offset, "%u", imsi->u.num.digit15); - } - LOG_FUNC_RETURN (RETURNok); + int offset = 0; + offset += sprintf(imsi_str + offset, "%u%u%u%u%u", + imsi->u.num.digit1, imsi->u.num.digit2, + imsi->u.num.digit3, imsi->u.num.digit4, + imsi->u.num.digit5); + if (imsi->u.num.digit6 != 0xf) { + offset += sprintf(imsi_str + offset, "%u", imsi->u.num.digit6); + } + offset += sprintf(imsi_str + offset, "%u%u%u%u%u%u%u%u", + imsi->u.num.digit7, imsi->u.num.digit8, + imsi->u.num.digit9, imsi->u.num.digit10, + imsi->u.num.digit11, imsi->u.num.digit12, + imsi->u.num.digit13, imsi->u.num.digit14); + if (imsi->u.num.digit15 != 0xf) { + offset += sprintf(imsi_str + offset, "%u", imsi->u.num.digit15); + } + LOG_FUNC_RETURN (RETURNok); } LOG_FUNC_RETURN (RETURNerror); @@ -305,49 +305,48 @@ int nas_proc_get_imsi(char* imsi_str) /**************************************************************************** ** ** - ** Name: nas_proc_get_msisdn() ** + ** Name: nas_proc_get_msisdn() ** ** ** ** Description: Get the Mobile Subscriber dialing number ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: msisdn: The value of the subscriber dialing number ** - ** ton_npi: Type Of Number / Numbering Plan Indicator ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: msisdn: The value of the subscriber dialing number ** + ** ton_npi: Type Of Number / Numbering Plan Indicator ** + ** Return: RETURNok, RETURNerror ** + ** 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(); - - if (msisdn != NULL) - { - union { - struct { - Byte_t ext:1; - Byte_t ton:3; - Byte_t npi:4; - } ext_ton_npi; - Byte_t type; - } converter; - converter.ext_ton_npi.ext = msisdn->ext; - converter.ext_ton_npi.ton = msisdn->ton; - converter.ext_ton_npi.npi = msisdn->npi; - *ton_npi = converter.type; - - sprintf(msisdn_str, "%u%u%u%u%u%u%u%u%u%u%u", - msisdn->digit[0].msb, msisdn->digit[0].lsb, - msisdn->digit[1].msb, msisdn->digit[1].lsb, - msisdn->digit[2].msb, msisdn->digit[2].lsb, - msisdn->digit[3].msb, msisdn->digit[3].lsb, - msisdn->digit[4].msb, msisdn->digit[4].lsb, - msisdn->digit[5].msb); - - LOG_FUNC_RETURN (RETURNok); + const msisdn_t *msisdn = emm_main_get_msisdn(); + + if (msisdn != NULL) { + union { + struct { + Byte_t ext:1; + Byte_t ton:3; + Byte_t npi:4; + } ext_ton_npi; + Byte_t type; + } converter; + converter.ext_ton_npi.ext = msisdn->ext; + converter.ext_ton_npi.ton = msisdn->ton; + converter.ext_ton_npi.npi = msisdn->npi; + *ton_npi = converter.type; + + sprintf(msisdn_str, "%u%u%u%u%u%u%u%u%u%u%u", + msisdn->digit[0].msb, msisdn->digit[0].lsb, + msisdn->digit[1].msb, msisdn->digit[1].lsb, + msisdn->digit[2].msb, msisdn->digit[2].lsb, + msisdn->digit[3].msb, msisdn->digit[3].lsb, + msisdn->digit[4].msb, msisdn->digit[4].lsb, + msisdn->digit[5].msb); + + LOG_FUNC_RETURN (RETURNok); } LOG_FUNC_RETURN (RETURNerror); @@ -355,20 +354,20 @@ int nas_proc_get_msisdn(char* msisdn_str, int* ton_npi) /**************************************************************************** ** ** - ** Name: nas_proc_get_signal_quality() ** + ** Name: nas_proc_get_signal_quality() ** ** ** ** Description: Get the signal strength/quality parameters ** ** ** - ** Inputs: None ** - ** Others: _nas_proc_data ** + ** Inputs: None ** + ** Others: _nas_proc_data ** ** ** - ** Outputs: rsrq: Reference signal received quality value ** - ** rsrp: Reference signal received power value ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: rsrq: Reference signal received quality value ** + ** rsrp: Reference signal received power value ** + ** Return: RETURNok, RETURNerror ** + ** 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; @@ -380,24 +379,24 @@ int nas_proc_get_signal_quality(int* rsrq, int* rsrp) /**************************************************************************** ** ** - ** Name: nas_proc_register() ** + ** Name: nas_proc_register() ** ** ** ** Description: Execute the network selection and registration procedure. ** ** ** - ** Inputs: mode: Network selection mode of operation ** - ** format: Represention format of the operator iden- ** - ** tifier ** - ** oper: Identifier of the network operator to re- ** - ** gister ** - ** AcT: The selected Access Technology ** - ** Others: None ** + ** Inputs: mode: Network selection mode of operation ** + ** format: Represention format of the operator iden- ** + ** tifier ** + ** oper: Identifier of the network operator to re- ** + ** gister ** + ** AcT: The selected Access Technology ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** 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; @@ -408,14 +407,14 @@ int nas_proc_register(int mode, int format, const network_plmn_t* oper, int AcT) */ int index = emm_main_set_plmn_selection_mode(mode, format, oper, AcT); if ( !(index < 0) ) { - /* - * Notify the EMM procedure call manager that network (re)selection - * procedure has to be executed - */ - emm_sap_t emm_sap; - emm_sap.primitive = EMMREG_REGISTER_REQ; - emm_sap.u.emm_reg.u.regist.index = index; - rc = emm_sap_send(&emm_sap); + /* + * Notify the EMM procedure call manager that network (re)selection + * procedure has to be executed + */ + emm_sap_t emm_sap; + emm_sap.primitive = EMMREG_REGISTER_REQ; + emm_sap.u.emm_reg.u.regist.index = index; + rc = emm_sap_send(&emm_sap); } LOG_FUNC_RETURN (rc); @@ -423,16 +422,16 @@ int nas_proc_register(int mode, int format, const network_plmn_t* oper, int AcT) /**************************************************************************** ** ** - ** Name: nas_proc_deregister() ** + ** Name: nas_proc_deregister() ** ** ** ** Description: Execute the network deregistration procedure. ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ int nas_proc_deregister(void) @@ -441,31 +440,32 @@ int nas_proc_deregister(void) /* TODO: Force an attempt to deregister from the network */ LOG_TRACE(ERROR, "NAS-PROC - Network deregistration procedure is " - "not implemented"); + "not implemented"); LOG_FUNC_RETURN (RETURNok); } /**************************************************************************** ** ** - ** Name: nas_proc_get_reg_data() ** + ** Name: nas_proc_get_reg_data() ** ** ** ** Description: Gets network registration data from EMM ** ** ** - ** Inputs: format: Format of the representation of the net- ** - ** work operator identifier ** - ** Others: None ** + ** Inputs: format: Format of the representation of the net- ** + ** work operator identifier ** + ** Others: None ** ** ** - ** Outputs: mode: The current network selection mode of ope- ** - ** ration ** - ** oper: The identifier of the selected network ** - ** operator ** - ** AcT: The access technology currently used ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: mode: The current network selection mode of ope- ** + ** ration ** + ** oper: The identifier of the selected network ** + ** operator ** + ** AcT: The access technology currently used ** + ** Return: RETURNok, RETURNerror ** + ** 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,18 +473,17 @@ 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 { - /* No any operator is selected */ - *selected = FALSE; - *AcT = NET_ACCESS_UNAVAILABLE; + /* An operator is currently selected */ + *selected = TRUE; + /* Get the supported Radio Access Technology */ + *AcT = emm_main_get_plmn_rat(); + } else { + /* No any operator is selected */ + *selected = FALSE; + *AcT = NET_ACCESS_UNAVAILABLE; } LOG_FUNC_RETURN (RETURNok); @@ -492,19 +491,19 @@ int nas_proc_get_reg_data(int* mode, int* selected, int format, network_plmn_t* /**************************************************************************** ** ** - ** Name: nas_proc_get_oper_list() ** + ** Name: nas_proc_get_oper_list() ** ** ** ** Description: Gets the list of operators present in the network ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: oper_list: The list of operators ** - ** Return: The size of the list in bytes ** - ** Others: None ** + ** Outputs: oper_list: The list of operators ** + ** Return: The size of the list in bytes ** + ** 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; @@ -515,21 +514,21 @@ int nas_proc_get_oper_list(const char** oper_list) /**************************************************************************** ** ** - ** Name: nas_proc_get_reg_status() ** + ** Name: nas_proc_get_reg_status() ** ** ** ** Description: Get the value of the network registration status which ** - ** shows whether the network has currently indicated the ** - ** registration of the UE ** + ** shows whether the network has currently indicated the ** + ** registration of the UE ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: stat: The current network registration status ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: stat: The current network registration status ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ -int nas_proc_get_reg_status(int* stat) +int nas_proc_get_reg_status(int *stat) { LOG_FUNC_IN; @@ -540,46 +539,46 @@ int nas_proc_get_reg_status(int* stat) /**************************************************************************** ** ** - ** Name: nas_proc_get_loc_info() ** + ** Name: nas_proc_get_loc_info() ** ** ** ** Description: Get the location information when the UE is registered in ** - ** the Network ** + ** the Network ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: tac: The code of the tracking area the registe- ** - ** red PLMN belongs to ** - ** ci: The identifier of the serving cell ** - ** AcT: The access technology in used ** - ** rac: The GPRS routing area code, if available ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: tac: The code of the tracking area the registe- ** + ** red PLMN belongs to ** + ** ci: The identifier of the serving cell ** + ** AcT: The access technology in used ** + ** rac: The GPRS routing area code, if available ** + ** Return: RETURNok, RETURNerror ** + ** 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; - sprintf(tac, "%.4x", emm_main_get_plmn_tac()); // two byte - sprintf(ci, "%.8x", emm_main_get_plmn_ci()); // four byte - *AcT = emm_main_get_plmn_rat(); // E-UTRAN + sprintf(tac, "%.4x", emm_main_get_plmn_tac()); // two byte + sprintf(ci, "%.8x", emm_main_get_plmn_ci()); // four byte + *AcT = emm_main_get_plmn_rat(); // E-UTRAN LOG_FUNC_RETURN (RETURNok); } /**************************************************************************** ** ** - ** Name: nas_proc_detach() ** + ** Name: nas_proc_detach() ** ** ** ** Description: Initiates a detach procedure ** ** ** - ** Inputs: switch_off: TRUE if the detach is due to UE switch-off ** - ** Others: None ** + ** Inputs: switch_off: TRUE if the detach is due to UE switch-off ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ int nas_proc_detach(int switch_off) @@ -590,10 +589,10 @@ int nas_proc_detach(int switch_off) int rc = RETURNok; if ( emm_main_is_attached() ) { - /* Initiate an Detach procedure */ - emm_sap.primitive = EMMREG_DETACH_INIT; - emm_sap.u.emm_reg.u.detach.switch_off = switch_off; - rc = emm_sap_send(&emm_sap); + /* Initiate an Detach procedure */ + emm_sap.primitive = EMMREG_DETACH_INIT; + emm_sap.u.emm_reg.u.detach.switch_off = switch_off; + rc = emm_sap_send(&emm_sap); } LOG_FUNC_RETURN (rc); @@ -601,16 +600,16 @@ int nas_proc_detach(int switch_off) /**************************************************************************** ** ** - ** Name: nas_proc_attach() ** + ** Name: nas_proc_attach() ** ** ** ** Description: Initiates an attach procedure ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ int nas_proc_attach(void) @@ -621,10 +620,10 @@ int nas_proc_attach(void) int rc = RETURNok; if ( !emm_main_is_attached() ) { - /* Initiate an Attach procedure */ - emm_sap.primitive = EMMREG_ATTACH_INIT; - emm_sap.u.emm_reg.u.attach.is_emergency = FALSE; - rc = emm_sap_send(&emm_sap); + /* Initiate an Attach procedure */ + emm_sap.primitive = EMMREG_ATTACH_INIT; + emm_sap.u.emm_reg.u.attach.is_emergency = FALSE; + rc = emm_sap_send(&emm_sap); } LOG_FUNC_RETURN (rc); @@ -632,17 +631,17 @@ int nas_proc_attach(void) /**************************************************************************** ** ** - ** Name: nas_proc_get_attach_status() ** + ** Name: nas_proc_get_attach_status() ** ** ** ** Description: Gets the current network attachment status ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: TRUE if the UE is currently attached to ** - ** the network ** - ** Others: None ** + ** Outputs: None ** + ** Return: TRUE if the UE is currently attached to ** + ** the network ** + ** Others: None ** ** ** ***************************************************************************/ int nas_proc_get_attach_status(void) @@ -656,16 +655,16 @@ int nas_proc_get_attach_status(void) /**************************************************************************** ** ** - ** Name: nas_proc_pdn_range() ** + ** Name: nas_proc_pdn_range() ** ** ** ** Description: Gets the maximum value of a PDN context identifier ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: The PDN context identifier maximum value ** - ** Others: None ** + ** Outputs: None ** + ** Return: The PDN context identifier maximum value ** + ** Others: None ** ** ** ***************************************************************************/ int nas_proc_get_pdn_range(void) @@ -679,21 +678,21 @@ int nas_proc_get_pdn_range(void) /**************************************************************************** ** ** - ** Name: nas_proc_get_pdn_status() ** + ** Name: nas_proc_get_pdn_status() ** ** ** ** Description: Gets the activation state of every defined PDN contexts ** ** ** - ** Inputs: n_pdn_max: Maximum number of PDN contexts ** - ** Others: None ** + ** Inputs: n_pdn_max: Maximum number of PDN contexts ** + ** Others: None ** ** ** - ** Outputs: cids: List of PDN context identifiers ** - ** states: List of PDN context activation states ** - ** Return: The number of PDN contexts that are cur- ** - ** rently in a defined state ** - ** Others: None ** + ** Outputs: cids: List of PDN context identifiers ** + ** states: List of PDN context activation states ** + ** Return: The number of PDN contexts that are cur- ** + ** rently in a defined state ** + ** 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; @@ -704,15 +703,15 @@ int nas_proc_get_pdn_status(int* cids, int* states, int n_pdn_max) /* For all PDN contexts */ for (int cid = 1; (cid < n_pdn+1) && (n_defined_pdn < n_pdn_max); cid++) { - /* Get the status of this PDN */ - int state = FALSE; - int is_defined = esm_main_get_pdn_status(cid, &state); - if (is_defined != FALSE) { - /* This PDN has been defined */ - *(cids++) = cid; - *(states++) = state; - n_defined_pdn += 1; - } + /* Get the status of this PDN */ + int state = FALSE; + int is_defined = esm_main_get_pdn_status(cid, &state); + if (is_defined != FALSE) { + /* This PDN has been defined */ + *(cids++) = cid; + *(states++) = state; + n_defined_pdn += 1; + } } LOG_FUNC_RETURN (n_defined_pdn); @@ -720,23 +719,23 @@ int nas_proc_get_pdn_status(int* cids, int* states, int n_pdn_max) /**************************************************************************** ** ** - ** Name: nas_proc_get_pdn_param() ** + ** Name: nas_proc_get_pdn_param() ** ** ** ** Description: Gets the parameters of every defined PDN contexts ** ** ** - ** Inputs: n_pdn_max: Maximum number of PDN contexts ** - ** Others: None ** + ** Inputs: n_pdn_max: Maximum number of PDN contexts ** + ** Others: None ** ** ** - ** Outputs: cids: List of PDN context identifiers ** - ** types: List of PDN types (IPv4, IPv6, IPv4v6) ** - ** apns: List of Access Point Names ** - ** Return: The number of PDN contexts that are cur- ** - ** rently in a defined state ** - ** Others: None ** + ** Outputs: cids: List of PDN context identifiers ** + ** types: List of PDN types (IPv4, IPv6, IPv4v6) ** + ** apns: List of Access Point Names ** + ** Return: The number of PDN contexts that are cur- ** + ** rently in a defined state ** + ** Others: None ** ** ** ***************************************************************************/ -int nas_proc_get_pdn_param(int* cids, int* types, const char** apns, - int n_pdn_max) +int nas_proc_get_pdn_param(int *cids, int *types, const char **apns, + int n_pdn_max) { LOG_FUNC_IN; @@ -747,16 +746,16 @@ int nas_proc_get_pdn_param(int* cids, int* types, const char** apns, /* For all PDN contexts */ for (int cid = 1; (cid < n_pdn+1) && (n_defined_pdn < n_pdn_max); cid++) { - int emergency, active; - /* Get PDN connection parameters */ - int rc = esm_main_get_pdn(cid, types, apns, &emergency, &active); - if (rc != RETURNerror) { - /* This PDN has been defined */ - *(cids++) = cid; - types++; - apns++; - n_defined_pdn += 1; - } + int emergency, active; + /* Get PDN connection parameters */ + int rc = esm_main_get_pdn(cid, types, apns, &emergency, &active); + if (rc != RETURNerror) { + /* This PDN has been defined */ + *(cids++) = cid; + types++; + apns++; + n_defined_pdn += 1; + } } LOG_FUNC_RETURN (n_defined_pdn); @@ -764,29 +763,29 @@ int nas_proc_get_pdn_param(int* cids, int* types, const char** apns, /**************************************************************************** ** ** - ** Name: nas_proc_get_pdn_addr() ** + ** Name: nas_proc_get_pdn_addr() ** ** ** ** Description: When the cid parameter value is positive, gets the addres-** - ** s(es) assigned to the specified PDN context. ** - ** When the cid parameter value is negative, gets the addres-** - ** s(es) assigned to each defined PDN context. ** - ** When the cid parameter value is null, gets the list of ** - ** defined PDN contexts. ** - ** ** - ** Inputs: cid: PDN context identifier ** - ** n_pdn_max: Maximum number of PDN contexts ** - ** Others: None ** - ** ** - ** Outputs: cids: List of PDN context identifiers ** - ** addr1: List of IPv4 addresses ** - ** addr2: List of IPv6 addresses ** - ** Return: The number PDN contexts that have at least ** - ** one IP address assigned ** - ** Others: None ** + ** s(es) assigned to the specified PDN context. ** + ** When the cid parameter value is negative, gets the addres-** + ** s(es) assigned to each defined PDN context. ** + ** When the cid parameter value is null, gets the list of ** + ** defined PDN contexts. ** + ** ** + ** Inputs: cid: PDN context identifier ** + ** n_pdn_max: Maximum number of PDN contexts ** + ** Others: None ** + ** ** + ** Outputs: cids: List of PDN context identifiers ** + ** addr1: List of IPv4 addresses ** + ** addr2: List of IPv6 addresses ** + ** Return: The number PDN contexts that have at least ** + ** one IP address assigned ** + ** 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; @@ -794,33 +793,30 @@ int nas_proc_get_pdn_addr(int cid, int* cids, const char** addr1, int n_defined_pdn = 0; if (cid > 0) { - /* Get addresses assigned to the specified PDN */ - rc = esm_main_get_pdn_addr(cid, addr1, addr2); - if (rc != RETURNerror) { - *cids = cid; - n_defined_pdn = 1; - } - } - 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++) - { - /* Get PDN connection addresses */ - rc = esm_main_get_pdn_addr(cid, addr1, addr2); - if (rc != RETURNerror) { - /* This PDN has been defined */ - *(cids++) = cid; - addr1++; - addr2++; - n_defined_pdn += 1; - } - } - } - else { - /* Get the list of defined PDN contexts */ + /* Get addresses assigned to the specified PDN */ + rc = esm_main_get_pdn_addr(cid, addr1, addr2); + if (rc != RETURNerror) { + *cids = cid; + n_defined_pdn = 1; + } + } 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++) { + /* Get PDN connection addresses */ + rc = esm_main_get_pdn_addr(cid, addr1, addr2); + if (rc != RETURNerror) { + /* This PDN has been defined */ + *(cids++) = cid; + addr1++; + addr2++; + n_defined_pdn += 1; + } + } + } else { + /* Get the list of defined PDN contexts */ } @@ -829,28 +825,28 @@ int nas_proc_get_pdn_addr(int cid, int* cids, const char** addr1, /**************************************************************************** ** ** - ** Name: nas_proc_set_pdn() ** + ** Name: nas_proc_set_pdn() ** ** ** ** Description: Setup parameters of a specified PDN context ** ** ** - ** Inputs: cid: Identifier of the PDN context to setup ** - ** type: Type of PDN (IPv4, IPv6,IPv4v6) ** - ** apn: Access Point Name of the external network ** - ** to connect to ** - ** ipv4_addr: IPv4 address allocation (NAS, DHCP) ** - ** emergency: Emergency bearer support indication ** - ** p_cscf: Preference of P-CSCF address discovery ** - ** im_cn_signal: IM CN subsystem-related signalling indica- ** - ** tion parameter ** - ** Others: None ** - ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Inputs: cid: Identifier of the PDN context to setup ** + ** type: Type of PDN (IPv4, IPv6,IPv4v6) ** + ** apn: Access Point Name of the external network ** + ** to connect to ** + ** ipv4_addr: IPv4 address allocation (NAS, DHCP) ** + ** emergency: Emergency bearer support indication ** + ** p_cscf: Preference of P-CSCF address discovery ** + ** im_cn_signal: IM CN subsystem-related signalling indica- ** + ** tion parameter ** + ** Others: None ** + ** ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ -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) { LOG_FUNC_IN; @@ -875,16 +871,16 @@ int nas_proc_set_pdn(int cid, int type, const char* apn, int ipv4_addr, /**************************************************************************** ** ** - ** Name: nas_proc_reset_pdn() ** + ** Name: nas_proc_reset_pdn() ** ** ** ** Description: Reset parameters of a specified PDN context ** ** ** - ** Inputs: cid: Identifier of the PDN context to setup ** - ** Others: None ** + ** Inputs: cid: Identifier of the PDN context to setup ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ int nas_proc_reset_pdn(int cid) @@ -907,18 +903,18 @@ int nas_proc_reset_pdn(int cid) /**************************************************************************** ** ** - ** Name: nas_proc_deactivate_pdn() ** + ** Name: nas_proc_deactivate_pdn() ** ** ** ** Description: Deactivates specified PDN context or all PDN contexts if ** - ** specified cid is negative ** + ** specified cid is negative ** ** ** - ** Inputs: cid: Identifier of the PDN context to be deac- ** - ** tivate ** - ** Others: None ** + ** Inputs: cid: Identifier of the PDN context to be deac- ** + ** tivate ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ int nas_proc_deactivate_pdn(int cid) @@ -928,18 +924,16 @@ int nas_proc_deactivate_pdn(int cid) int rc = RETURNok; if (cid > 0) { - /* Deactivate only the specified PDN context */ - rc = _nas_proc_deactivate(cid, FALSE); - } - 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)) - { - rc = _nas_proc_deactivate(cid++, TRUE); - } + /* Deactivate only the specified PDN context */ + rc = _nas_proc_deactivate(cid, FALSE); + } 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)) { + rc = _nas_proc_deactivate(cid++, TRUE); + } } LOG_FUNC_RETURN (rc); @@ -947,18 +941,18 @@ int nas_proc_deactivate_pdn(int cid) /**************************************************************************** ** ** - ** Name: nas_proc_activate_pdn() ** + ** Name: nas_proc_activate_pdn() ** ** ** ** Description: Activates specified PDN context or all PDN contexts if ** - ** specified cid is negative ** + ** specified cid is negative ** ** ** - ** Inputs: cid: Identifier of the PDN context to be act- ** - ** tivate ** - ** Others: None ** + ** Inputs: cid: Identifier of the PDN context to be act- ** + ** tivate ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ int nas_proc_activate_pdn(int cid) @@ -968,34 +962,30 @@ int nas_proc_activate_pdn(int cid) int rc = RETURNok; if ( !emm_main_is_attached() ) { - /* - * If the UE is not attached to the network, perform EPS attach - * procedure prior to attempt to request any PDN connectivity - */ - LOG_TRACE(WARNING, "NAS-PROC - UE is not attached to the network"); - rc = nas_proc_attach(); - } - 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 the UE is not attached to the network, perform EPS attach + * procedure prior to attempt to request any PDN connectivity + */ + LOG_TRACE(WARNING, "NAS-PROC - UE is not attached to the network"); + rc = nas_proc_attach(); + } 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 (cid > 0) { - /* Activate only the specified PDN context */ - rc = _nas_proc_activate(cid, FALSE); - } - else { - cid = 1; - /* Activate all defined PDN contexts */ - while ((rc != RETURNerror) && (cid < esm_main_get_nb_pdns_max()+1)) - { - rc = _nas_proc_activate(cid++, TRUE); - } - } + if (rc != RETURNerror) { + if (cid > 0) { + /* Activate only the specified PDN context */ + rc = _nas_proc_activate(cid, FALSE); + } else { + cid = 1; + /* Activate all defined PDN contexts */ + while ((rc != RETURNerror) && (cid < esm_main_get_nb_pdns_max()+1)) { + rc = _nas_proc_activate(cid++, TRUE); + } + } } LOG_FUNC_RETURN (rc); @@ -1003,36 +993,36 @@ int nas_proc_activate_pdn(int cid) /* * -------------------------------------------------------------------------- - * NAS procedures triggered by the network + * NAS procedures triggered by the network * -------------------------------------------------------------------------- */ /**************************************************************************** ** ** - ** Name: nas_proc_cell_info() ** + ** Name: nas_proc_cell_info() ** ** ** ** Description: Processes the cell information received from the network ** ** ** - ** Inputs: found: Indicates whether a suitable cell is found ** - ** for the selected PLMN to camp on ** - ** tac: The code of the tracking area the PLMN ** - ** belongs to ** - ** ci: The identifier of a cell serving this PLMN ** - ** AcT: The access technology supported by the ** - ** serving cell ** - ** rsrq: Reference signal received quality measure- ** - ** ment ** - ** rsrp: Reference signal received power measure- ** - ** ment ** - ** Others: None ** - ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: _nas_proc_data ** + ** Inputs: found: Indicates whether a suitable cell is found ** + ** for the selected PLMN to camp on ** + ** tac: The code of the tracking area the PLMN ** + ** belongs to ** + ** ci: The identifier of a cell serving this PLMN ** + ** AcT: The access technology supported by the ** + ** serving cell ** + ** rsrq: Reference signal received quality measure- ** + ** ment ** + ** rsrp: Reference signal received power measure- ** + ** ment ** + ** Others: None ** + ** ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: _nas_proc_data ** ** ** ***************************************************************************/ int nas_proc_cell_info(int found, tac_t tac, ci_t ci, AcT_t AcT, - UInt8_t rsrq, UInt8_t rsrp) + UInt8_t rsrq, UInt8_t rsrp) { LOG_FUNC_IN; @@ -1061,22 +1051,22 @@ int nas_proc_cell_info(int found, tac_t tac, ci_t ci, AcT_t AcT, /**************************************************************************** ** ** - ** Name: nas_proc_establish_cnf() ** + ** Name: nas_proc_establish_cnf() ** ** ** ** Description: Processes the NAS signalling connection establishment ** - ** confirm message received from the network ** + ** confirm message received from the network ** ** ** - ** Inputs: data: The initial NAS message transfered within ** - ** the message ** - ** len: The length of the initial NAS message ** - ** Others: None ** + ** Inputs: data: The initial NAS message transfered within ** + ** the message ** + ** len: The length of the initial NAS message ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** 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); @@ -1098,19 +1088,19 @@ int nas_proc_establish_cnf(const Byte_t* data, UInt32_t len) /**************************************************************************** ** ** - ** Name: nas_proc_establish_rej() ** + ** Name: nas_proc_establish_rej() ** ** ** ** Description: Processes the NAS signalling connection establishment ** - ** confirm message received from the network while initial ** - ** NAS message has not been delivered to the NAS sublayer on ** - ** the receiver side. ** + ** confirm message received from the network while initial ** + ** NAS message has not been delivered to the NAS sublayer on ** + ** the receiver side. ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ int nas_proc_establish_rej(void) @@ -1133,17 +1123,17 @@ int nas_proc_establish_rej(void) /**************************************************************************** ** ** - ** Name: nas_proc_release_ind() ** + ** Name: nas_proc_release_ind() ** ** ** ** Description: Processes the NAS signalling connection release indica- ** - ** tion message received from the network ** + ** tion message received from the network ** ** ** - ** Inputs: cause: The release cause ** - ** Others: None ** + ** Inputs: cause: The release cause ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ int nas_proc_release_ind(int cause) @@ -1166,18 +1156,18 @@ int nas_proc_release_ind(int cause) /**************************************************************************** ** ** - ** Name: nas_proc_ul_transfer_cnf() ** + ** Name: nas_proc_ul_transfer_cnf() ** ** ** ** Description: Processes the uplink data transfer confirm message recei- ** - ** ved from the network while NAS message has been success- ** - ** fully delivered to the NAS sublayer on the receiver side. ** + ** ved from the network while NAS message has been success- ** + ** fully delivered to the NAS sublayer on the receiver side. ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ int nas_proc_ul_transfer_cnf(void) @@ -1203,18 +1193,18 @@ int nas_proc_ul_transfer_cnf(void) /**************************************************************************** ** ** - ** Name: nas_proc_ul_transfer_rej() ** + ** Name: nas_proc_ul_transfer_rej() ** ** ** ** Description: Processes the uplink data transfer confirm message recei- ** - ** ved from the network while NAS message has not been deli- ** - ** vered to the NAS sublayer on the receiver side. ** + ** ved from the network while NAS message has not been deli- ** + ** vered to the NAS sublayer on the receiver side. ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ int nas_proc_ul_transfer_rej(void) @@ -1240,38 +1230,38 @@ int nas_proc_ul_transfer_rej(void) /**************************************************************************** ** ** - ** Name: nas_proc_dl_transfer_ind() ** + ** Name: nas_proc_dl_transfer_ind() ** ** ** ** Description: Processes downlink data transfer indication message re- ** - ** ceived from the network ** + ** ceived from the network ** ** ** - ** Inputs: data: The transfered NAS message ** - ** len: The length of the NAS message ** - ** Others: None ** + ** Inputs: data: The transfered NAS message ** + ** len: The length of the NAS message ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** 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; int rc = RETURNerror; if (len > 0) { - emm_sap_t emm_sap; - /* - * Notify the EMM procedure call manager that data transfer - * indication has been received from the Access-Stratum sublayer - */ - emm_sap.primitive = EMMAS_DATA_IND; - 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; - rc = emm_sap_send(&emm_sap); + emm_sap_t emm_sap; + /* + * Notify the EMM procedure call manager that data transfer + * indication has been received from the Access-Stratum sublayer + */ + emm_sap.primitive = EMMAS_DATA_IND; + 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; + rc = emm_sap_send(&emm_sap); } LOG_FUNC_RETURN (rc); @@ -1281,43 +1271,43 @@ int nas_proc_dl_transfer_ind(const Byte_t* data, UInt32_t len) #ifdef NAS_MME /**************************************************************************** ** ** - ** Name: nas_proc_establish_ind() ** + ** Name: nas_proc_establish_ind() ** ** ** ** Description: Processes the NAS signalling connection establishment ** - ** indication message received from the network ** + ** indication message received from the network ** ** ** - ** Inputs: ueid: UE identifier ** - ** tac: The code of the tracking area the initia- ** - ** ting UE belongs to ** - ** data: The initial NAS message transfered within ** - ** the message ** - ** len: The length of the initial NAS message ** - ** Others: None ** + ** Inputs: ueid: UE identifier ** + ** tac: The code of the tracking area the initia- ** + ** ting UE belongs to ** + ** data: The initial NAS message transfered within ** + ** the message ** + ** len: The length of the initial NAS message ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ 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; int rc = RETURNerror; if (len > 0) { - emm_sap_t emm_sap; - /* - * Notify the EMM procedure call manager that NAS signalling - * connection establishment indication message has been received - * from the Access-Stratum sublayer - */ - 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; - rc = emm_sap_send(&emm_sap); + emm_sap_t emm_sap; + /* + * Notify the EMM procedure call manager that NAS signalling + * connection establishment indication message has been received + * from the Access-Stratum sublayer + */ + 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; + rc = emm_sap_send(&emm_sap); } LOG_FUNC_RETURN (rc); @@ -1325,18 +1315,18 @@ int nas_proc_establish_ind(UInt32_t ueid, tac_t tac, /**************************************************************************** ** ** - ** Name: nas_proc_dl_transfer_cnf() ** + ** Name: nas_proc_dl_transfer_cnf() ** ** ** ** Description: Processes the downlink data transfer confirm message re- ** - ** ceived from the network while NAS message has been succes-** - ** sfully delivered to the NAS sublayer on the receiver side.** + ** ceived from the network while NAS message has been succes-** + ** sfully delivered to the NAS sublayer on the receiver side.** ** ** - ** Inputs: ueid: UE identifier ** - ** Others: None ** + ** Inputs: ueid: UE identifier ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ int nas_proc_dl_transfer_cnf(UInt32_t ueid) @@ -1362,18 +1352,18 @@ int nas_proc_dl_transfer_cnf(UInt32_t ueid) /**************************************************************************** ** ** - ** Name: nas_proc_dl_transfer_rej() ** + ** Name: nas_proc_dl_transfer_rej() ** ** ** ** Description: Processes the downlink data transfer confirm message re- ** - ** ceived from the network while NAS message has not been ** - ** delivered to the NAS sublayer on the receiver side. ** + ** ceived from the network while NAS message has not been ** + ** delivered to the NAS sublayer on the receiver side. ** ** ** - ** Inputs: ueid: UE identifier ** - ** Others: None ** + ** Inputs: ueid: UE identifier ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ int nas_proc_dl_transfer_rej(UInt32_t ueid) @@ -1399,39 +1389,39 @@ int nas_proc_dl_transfer_rej(UInt32_t ueid) /**************************************************************************** ** ** - ** Name: nas_proc_ul_transfer_ind() ** + ** Name: nas_proc_ul_transfer_ind() ** ** ** ** Description: Processes uplink data transfer indication message recei- ** - ** ved from the network ** + ** ved from the network ** ** ** - ** Inputs: ueid: UE identifier ** - ** data: The transfered NAS message ** - ** len: The length of the NAS message ** - ** Others: None ** + ** Inputs: ueid: UE identifier ** + ** data: The transfered NAS message ** + ** len: The length of the NAS message ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** 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; int rc = RETURNerror; if (len > 0) { - emm_sap_t emm_sap; - /* - * Notify the EMM procedure call manager that data transfer - * indication has been received from the Access-Stratum sublayer - */ - emm_sap.primitive = EMMAS_DATA_IND; - 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; - rc = emm_sap_send(&emm_sap); + emm_sap_t emm_sap; + /* + * Notify the EMM procedure call manager that data transfer + * indication has been received from the Access-Stratum sublayer + */ + emm_sap.primitive = EMMAS_DATA_IND; + 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; + rc = emm_sap_send(&emm_sap); } LOG_FUNC_RETURN (rc); @@ -1445,20 +1435,20 @@ int nas_proc_ul_transfer_ind(UInt32_t ueid, const Byte_t* data, UInt32_t len) #ifdef NAS_UE /**************************************************************************** ** ** - ** Name: _nas_proc_activate() ** + ** Name: _nas_proc_activate() ** ** ** ** Description: Initiates a PDN connectivity procedure ** ** ** - ** Inputs: cid: Identifier of the PDN context used to es- ** - ** tablished connectivity to specified PDN ** - ** apply_to_all: TRUE if the PDN connectivity procedure is ** - ** initiated to establish connectivity to all ** - ** defined PDNs ** - ** Others: None ** + ** Inputs: cid: Identifier of the PDN context used to es- ** + ** tablished connectivity to specified PDN ** + ** apply_to_all: TRUE if the PDN connectivity procedure is ** + ** initiated to establish connectivity to all ** + ** defined PDNs ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ static int _nas_proc_activate(int cid, int apply_to_all) @@ -1472,33 +1462,33 @@ static int _nas_proc_activate(int cid, int apply_to_all) /* Get PDN context parameters */ rc = esm_main_get_pdn(cid, &esm_sap.data.pdn_connect.pdn_type, - &esm_sap.data.pdn_connect.apn, - &esm_sap.data.pdn_connect.is_emergency, &active); + &esm_sap.data.pdn_connect.apn, + &esm_sap.data.pdn_connect.is_emergency, &active); if (rc != RETURNok) { - /* No any context is defined for the specified PDN */ - if (apply_to_all) { - /* Go ahead to activate next PDN context */ - LOG_FUNC_RETURN (RETURNok); - } - /* Return an error */ - LOG_FUNC_RETURN (RETURNerror); + /* No any context is defined for the specified PDN */ + if (apply_to_all) { + /* Go ahead to activate next PDN context */ + LOG_FUNC_RETURN (RETURNok); + } + /* Return an error */ + LOG_FUNC_RETURN (RETURNerror); } if (active) { - /* The PDN context is already active */ - LOG_TRACE(WARNING, "NAS-PROC - PDN connection %d is active", cid); - LOG_FUNC_RETURN (RETURNok); + /* The PDN context is already active */ + LOG_TRACE(WARNING, "NAS-PROC - PDN connection %d is active", cid); + LOG_FUNC_RETURN (RETURNok); } if (esm_sap.data.pdn_connect.is_emergency) { - if (esm_main_has_emergency()) { - /* There is already a PDN connection for emergency - * bearer services established; the UE shall not - * request an additional PDN connection for emer- - * gency bearer services */ - LOG_TRACE(WARNING, "NAS-PROC - PDN connection for emergency " - "bearer services is already established (cid=%d)", cid); - LOG_FUNC_RETURN (RETURNerror); - } + if (esm_main_has_emergency()) { + /* There is already a PDN connection for emergency + * bearer services established; the UE shall not + * request an additional PDN connection for emer- + * gency bearer services */ + LOG_TRACE(WARNING, "NAS-PROC - PDN connection for emergency " + "bearer services is already established (cid=%d)", cid); + LOG_FUNC_RETURN (RETURNerror); + } } /* * Notify ESM that a default EPS bearer has to be established @@ -1515,19 +1505,19 @@ static int _nas_proc_activate(int cid, int apply_to_all) /**************************************************************************** ** ** - ** Name: _nas_proc_deactivate() ** + ** Name: _nas_proc_deactivate() ** ** ** ** Description: Initiates a PDN disconnect procedure ** ** ** - ** Inputs: cid: Identifier of the PDN context ** - ** apply_to_all: TRUE if the PDN disconnect procedure is ** - ** initiated to request disconnection from ** - ** all active PDNs ** - ** Others: None ** + ** Inputs: cid: Identifier of the PDN context ** + ** apply_to_all: TRUE if the PDN disconnect procedure is ** + ** initiated to request disconnection from ** + ** all active PDNs ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok, RETURNerror ** - ** Others: None ** + ** Outputs: None ** + ** Return: RETURNok, RETURNerror ** + ** Others: None ** ** ** ***************************************************************************/ static int _nas_proc_deactivate(int cid, int apply_to_all) @@ -1536,43 +1526,42 @@ 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; /* Get PDN context parameters */ rc = esm_main_get_pdn(cid, &pdn_type, &apn, &emergency, &active); if (rc != RETURNok) { - /* No any context is defined for the specified PDN */ - if (apply_to_all) { - /* Go ahead to deactivate next PDN connection */ - LOG_FUNC_RETURN (RETURNok); - } - LOG_FUNC_RETURN (RETURNerror); + /* No any context is defined for the specified PDN */ + if (apply_to_all) { + /* Go ahead to deactivate next PDN connection */ + LOG_FUNC_RETURN (RETURNok); + } + LOG_FUNC_RETURN (RETURNerror); } if (!active) { - /* The PDN connection is already inactive */ - LOG_TRACE(WARNING, "NAS-PROC - PDN connection %d is not active", cid); - LOG_FUNC_RETURN (RETURNok); + /* The PDN connection is already inactive */ + LOG_TRACE(WARNING, "NAS-PROC - PDN connection %d is not active", cid); + LOG_FUNC_RETURN (RETURNok); } if (esm_main_get_nb_pdns() > 1) { - /* - * Notify ESM that all EPS bearers towards the specified PDN - * has to be released - */ - esm_sap_t esm_sap; - esm_sap.primitive = ESM_PDN_DISCONNECT_REQ; - esm_sap.data.pdn_disconnect.cid = cid; - rc = esm_sap_send(&esm_sap); - } - 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 - " - "Attempt to disconnect from the last PDN is not allowed"); - rc = RETURNerror; + /* + * Notify ESM that all EPS bearers towards the specified PDN + * has to be released + */ + esm_sap_t esm_sap; + esm_sap.primitive = ESM_PDN_DISCONNECT_REQ; + esm_sap.data.pdn_disconnect.cid = cid; + rc = esm_sap_send(&esm_sap); + } 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 - " + "Attempt to disconnect from the last PDN is not allowed"); + rc = RETURNerror; } LOG_FUNC_RETURN (rc); diff --git a/openair-cn/NAS/EURECOM-NAS/src/nas_proc.h b/openair-cn/NAS/EURECOM-NAS/src/nas_proc.h index 34548a6fae..3d0a022dcf 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/nas_proc.h +++ b/openair-cn/NAS/EURECOM-NAS/src/nas_proc.h @@ -1,20 +1,20 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source nas_proc.h +Source nas_proc.h -Version 0.1 +Version 0.1 -Date 2012/09/20 +Date 2012/09/20 -Product NAS stack +Product NAS stack -Subsystem NAS main process +Subsystem NAS main process -Author Frederic Maurel +Author Frederic Maurel -Description NAS procedure call manager +Description NAS procedure call manager *****************************************************************************/ #ifndef __NAS_PROC_H__ @@ -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); @@ -50,67 +51,73 @@ void nas_proc_cleanup(void); /* * -------------------------------------------------------------------------- - * NAS procedures triggered by the user + * NAS procedures triggered by the user * -------------------------------------------------------------------------- */ #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 /* * -------------------------------------------------------------------------- - * NAS procedures triggered by the network + * NAS procedures triggered by the network * -------------------------------------------------------------------------- */ #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__*/ diff --git a/openair-cn/NAS/EURECOM-NAS/src/nas_user.c b/openair-cn/NAS/EURECOM-NAS/src/nas_user.c index 75507fbe4d..642f5b58b6 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/nas_user.c +++ b/openair-cn/NAS/EURECOM-NAS/src/nas_user.c @@ -1,20 +1,20 @@ /***************************************************************************** - Eurecom OpenAirInterface 3 - Copyright(c) 2012 Eurecom + Eurecom OpenAirInterface 3 + Copyright(c) 2012 Eurecom -Source nas_user.c +Source nas_user.c -Version 0.1 +Version 0.1 -Date 2012/03/09 +Date 2012/03/09 -Product NAS stack +Product NAS stack -Subsystem NAS main process +Subsystem NAS main process -Author Frederic Maurel +Author Frederic Maurel -Description NAS procedure functions triggered by the user +Description NAS procedure functions triggered by the user *****************************************************************************/ @@ -31,8 +31,8 @@ Description NAS procedure functions triggered by the user #include "user_indication.h" #include "nas_proc.h" -#include <string.h> // memset, strncpy, strncmp -#include <stdlib.h> // free +#include <string.h> // memset, strncpy, strncmp +#include <stdlib.h> // free /****************************************************************************/ /**************** E X T E R N A L D E F I N I T I O N S ****************/ @@ -44,57 +44,57 @@ Description NAS procedure functions triggered by the user /* * --------------------------------------------------------------------- - * Functions executed upon receiving AT command from 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, - _nas_user_proc_cgsn, /* CGSN */ - _nas_user_proc_cgmi, /* CGMI */ - _nas_user_proc_cgmm, /* CGMM */ - _nas_user_proc_cgmr, /* CGMR */ - _nas_user_proc_cimi, /* CIMI */ - _nas_user_proc_cfun, /* CFUN */ - _nas_user_proc_cpin, /* CPIN */ - _nas_user_proc_csq, /* CSQ */ - _nas_user_proc_cesq, /* CESQ */ - _nas_user_proc_clac, /* CLAC */ - _nas_user_proc_cmee, /* CMEE */ - _nas_user_proc_cnum, /* CNUM */ - _nas_user_proc_clck, /* CLCK */ - _nas_user_proc_cops, /* COPS */ - _nas_user_proc_creg, /* CREG */ - _nas_user_proc_cgatt, /* CGATT */ - _nas_user_proc_cgreg, /* CGREG */ - _nas_user_proc_cereg, /* CEREG */ - _nas_user_proc_cgdcont, /* CGDCONT */ - _nas_user_proc_cgact, /* CGACT */ - _nas_user_proc_cgpaddr, /* CGPADDR */ + _nas_user_proc_cgsn, /* CGSN */ + _nas_user_proc_cgmi, /* CGMI */ + _nas_user_proc_cgmm, /* CGMM */ + _nas_user_proc_cgmr, /* CGMR */ + _nas_user_proc_cimi, /* CIMI */ + _nas_user_proc_cfun, /* CFUN */ + _nas_user_proc_cpin, /* CPIN */ + _nas_user_proc_csq, /* CSQ */ + _nas_user_proc_cesq, /* CESQ */ + _nas_user_proc_clac, /* CLAC */ + _nas_user_proc_cmee, /* CMEE */ + _nas_user_proc_cnum, /* CNUM */ + _nas_user_proc_clck, /* CLCK */ + _nas_user_proc_cops, /* COPS */ + _nas_user_proc_creg, /* CREG */ + _nas_user_proc_cgatt, /* CGATT */ + _nas_user_proc_cgreg, /* CGREG */ + _nas_user_proc_cereg, /* CEREG */ + _nas_user_proc_cgdcont, /* CGDCONT */ + _nas_user_proc_cgact, /* CGACT */ + _nas_user_proc_cgpaddr, /* CGPADDR */ }; /* @@ -105,7 +105,7 @@ static at_response_t _nas_user_data = {}; /* * --------------------------------------------------------------------- - * Local UE context + * Local UE context * --------------------------------------------------------------------- */ /* @@ -116,13 +116,13 @@ static at_response_t _nas_user_data = {}; * (read and test command only). */ typedef enum { - NAS_USER_READY, /* MT is not pending for any password */ - NAS_USER_SIM_PIN, /* MT is waiting SIM PIN to be given */ - NAS_USER_SIM_PUK, /* MT is waiting SIM PUK to be given */ - NAS_USER_PH_SIM_PIN /* MT is waiting phone-to-SIM card - * password to be given */ + NAS_USER_READY, /* MT is not pending for any password */ + NAS_USER_SIM_PIN, /* MT is waiting SIM PIN to be given */ + NAS_USER_SIM_PUK, /* MT is waiting SIM PUK to be given */ + 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,19 +132,18 @@ static const char* _nas_user_sim_status_str[] = { /* * The local UE context */ -static struct -{ - /* Firmware version number */ - const char* version; - /* SIM pending status */ +static struct { + /* Firmware version number */ + const char *version; + /* SIM pending status */ nas_user_sim_status sim_status; - /* Level of functionality */ + /* Level of functionality */ int fun; } _nas_user_context; /* * --------------------------------------------------------------------- - * UE parameters stored in the UE's non-volatile memory device + * UE parameters stored in the UE's non-volatile memory device * --------------------------------------------------------------------- */ static user_nvdata_t _nas_user_nvdata; @@ -155,38 +154,38 @@ static user_nvdata_t _nas_user_nvdata; /**************************************************************************** ** ** - ** Name: nas_user_initialize() ** + ** Name: nas_user_initialize() ** ** ** ** Description: Initializes user internal data ** ** ** - ** Inputs: emm_cb: Mobility Management indication callback ** - ** esm_cb: Session Management indication callback ** - ** version: Firmware version ** - ** Others: None ** + ** Inputs: emm_cb: Mobility Management indication callback ** + ** esm_cb: Session Management indication callback ** + ** version: Firmware version ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: None ** - ** Others: _nas_user_nvdata, _nas_user_context ** + ** Outputs: None ** + ** Return: None ** + ** Others: _nas_user_nvdata, _nas_user_context ** ** ** ***************************************************************************/ 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"); + LOG_TRACE(ERROR, "USR-MAIN - Failed to get UE's data pathname"); } /* Get UE data stored in the non-volatile memory device */ else { - int rc = memory_read(path, &_nas_user_nvdata, sizeof(user_nvdata_t)); - if (rc != RETURNok) { - LOG_TRACE(ERROR, "USR-MAIN - Failed to read %s", path); - } - free(path); + int rc = memory_read(path, &_nas_user_nvdata, sizeof(user_nvdata_t)); + if (rc != RETURNok) { + LOG_TRACE(ERROR, "USR-MAIN - Failed to read %s", path); + } + free(path); } _nas_user_context.version = version; @@ -201,55 +200,53 @@ void nas_user_initialize(emm_indication_callback_t emm_cb, /**************************************************************************** ** ** - ** Name: nas_user_process_data() ** + ** Name: nas_user_process_data() ** ** ** ** Description: Executes AT command operations received from the user and ** - ** calls applicable NAS procedure function. ** + ** calls applicable NAS procedure function. ** ** ** - ** Inputs: data: Generic pointer to data structure that has ** - ** to be processed ** - ** Others: None ** + ** Inputs: data: Generic pointer to data structure that has ** + ** to be processed ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok if the command has been success- ** - ** fully executed; RETURNerror otherwise ** - ** Others: _nas_user_data ** + ** Outputs: None ** + ** Return: RETURNok if the command has been success- ** + ** fully executed; RETURNerror otherwise ** + ** 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); - _nas_user_procedure_t nas_procedure; - - LOG_TRACE(INFO, "USR-MAIN - Process %s AT command %d", - (user_data->type == AT_COMMAND_ACT) ? "action" : - (user_data->type == AT_COMMAND_SET) ? "set parameter" : - (user_data->type == AT_COMMAND_GET) ? "get parameter" : - (user_data->type == AT_COMMAND_TST) ? "test parameter" - : "unknown type", user_data->id); - - /* Call NAS procedure applicable to the AT command */ - nas_procedure = _nas_user_procedure[user_data->id]; - if (nas_procedure != NULL) { - ret_code = (*nas_procedure)(user_data); - } - else { - /* AT command related to result format only */ - _nas_user_data.id = user_data->id; - _nas_user_data.type = user_data->type; - _nas_user_data.mask = user_data->mask; - _nas_user_data.cause_code = AT_ERROR_SUCCESS; - ret_code = RETURNok; - } - } - else { - LOG_TRACE(ERROR, "USR-MAIN - Data to be processed is null"); - _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; + 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", + (user_data->type == AT_COMMAND_ACT) ? "action" : + (user_data->type == AT_COMMAND_SET) ? "set parameter" : + (user_data->type == AT_COMMAND_GET) ? "get parameter" : + (user_data->type == AT_COMMAND_TST) ? "test parameter" + : "unknown type", user_data->id); + + /* Call NAS procedure applicable to the AT command */ + nas_procedure = _nas_user_procedure[user_data->id]; + if (nas_procedure != NULL) { + ret_code = (*nas_procedure)(user_data); + } else { + /* AT command related to result format only */ + _nas_user_data.id = user_data->id; + _nas_user_data.type = user_data->type; + _nas_user_data.mask = user_data->mask; + _nas_user_data.cause_code = AT_ERROR_SUCCESS; + ret_code = RETURNok; + } + } else { + LOG_TRACE(ERROR, "USR-MAIN - Data to be processed is null"); + _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; } LOG_FUNC_RETURN (ret_code); @@ -257,25 +254,25 @@ int nas_user_process_data(const void* data) /**************************************************************************** ** ** - ** Name: nas_user_get_data() ** + ** Name: nas_user_get_data() ** ** ** ** Description: Get a generic pointer to the internal representation of ** - ** the data structure returned as the result of NAS proce- ** - ** dure function call. ** - ** Casting to the proper type is necessary before its usage. ** + ** the data structure returned as the result of NAS proce- ** + ** dure function call. ** + ** Casting to the proper type is necessary before its usage. ** ** ** - ** Inputs: None ** - ** Others: None ** + ** Inputs: None ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: A generic pointer to the data structure ** - ** Others: None ** + ** Outputs: None ** + ** Return: A generic pointer to the data structure ** + ** 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); } /****************************************************************************/ @@ -284,29 +281,29 @@ const void* nas_user_get_data(void) /**************************************************************************** ** ** - ** Name: nas_user_proc_cgsn() ** + ** Name: nas_user_proc_cgsn() ** ** ** ** Description: Executes the AT CGSN command operations: ** - ** The AT CGSN command returns information text intended to ** - ** permit the user to identify the individual Mobile ** - ** Equipment to which it is connected to. ** - ** Typically, the text will consist of a single line contai- ** - ** ning the IMEI. ** + ** The AT CGSN command returns information text intended to ** + ** permit the user to identify the individual Mobile ** + ** Equipment to which it is connected to. ** + ** Typically, the text will consist of a single line contai- ** + ** ning the IMEI. ** ** ** - ** Inputs: data: Pointer to the AT command data structure ** - ** Others: _nas_user_nvdata ** + ** Inputs: data: Pointer to the AT command data structure ** + ** Others: _nas_user_nvdata ** ** ** - ** Outputs: None ** - ** Return: RETURNok; RETURNerror; ** - ** Others: _nas_user_data ** + ** Outputs: None ** + ** Return: RETURNok; RETURNerror; ** + ** 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,23 +311,23 @@ 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) - { - case AT_COMMAND_ACT: - /* Get the Product Serial Number Identification (IMEI) */ - strncpy(cgsn->sn, _nas_user_nvdata.IMEI, - AT_RESPONSE_INFO_TEXT_SIZE); - break; - - case AT_COMMAND_TST: - /* Nothing to do */ - break; - - default: - 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; + switch (data->type) { + case AT_COMMAND_ACT: + /* Get the Product Serial Number Identification (IMEI) */ + strncpy(cgsn->sn, _nas_user_nvdata.IMEI, + AT_RESPONSE_INFO_TEXT_SIZE); + break; + + case AT_COMMAND_TST: + /* Nothing to do */ + break; + + default: + 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; } LOG_FUNC_RETURN (ret_code); @@ -338,27 +335,27 @@ static int _nas_user_proc_cgsn(const at_command_t* data) /**************************************************************************** ** ** - ** Name: nas_user_proc_cgmi() ** + ** Name: nas_user_proc_cgmi() ** ** ** ** Description: Executes the AT CGMI command operations: ** - ** The AT CGMI command returns information text intended to ** - ** permit the user to identify the manufacturer of the Mobi- ** - ** le Equipment to which it is connected to. ** + ** The AT CGMI command returns information text intended to ** + ** permit the user to identify the manufacturer of the Mobi- ** + ** le Equipment to which it is connected to. ** ** ** - ** Inputs: data: Pointer to the AT command data structure ** - ** Others: _nas_user_nvdata ** + ** Inputs: data: Pointer to the AT command data structure ** + ** Others: _nas_user_nvdata ** ** ** - ** Outputs: None ** - ** Return: RETURNok; RETURNerror; ** - ** Others: _nas_user_data ** + ** Outputs: None ** + ** Return: RETURNok; RETURNerror; ** + ** 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,23 +363,23 @@ 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) - { - case AT_COMMAND_ACT: - /* Get the Manufacturer identifier */ - strncpy(cgmi->manufacturer, _nas_user_nvdata.manufacturer, - AT_RESPONSE_INFO_TEXT_SIZE); - break; - - case AT_COMMAND_TST: - /* Nothing to do */ - break; - - default: - 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; + switch (data->type) { + case AT_COMMAND_ACT: + /* Get the Manufacturer identifier */ + strncpy(cgmi->manufacturer, _nas_user_nvdata.manufacturer, + AT_RESPONSE_INFO_TEXT_SIZE); + break; + + case AT_COMMAND_TST: + /* Nothing to do */ + break; + + default: + 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; } LOG_FUNC_RETURN (ret_code); @@ -390,27 +387,27 @@ static int _nas_user_proc_cgmi(const at_command_t* data) /**************************************************************************** ** ** - ** Name: nas_user_proc_cgmm() ** + ** Name: nas_user_proc_cgmm() ** ** ** ** Description: Executes the AT CGMM command operations: ** - ** The AT CGMM command returns information text intended to ** - ** permit the user to identify specific model of the Mobile ** - ** Equipment to which it is connected to. ** + ** The AT CGMM command returns information text intended to ** + ** permit the user to identify specific model of the Mobile ** + ** Equipment to which it is connected to. ** ** ** - ** Inputs: data: Pointer to the AT command data structure ** - ** Others: _nas_user_nvdata ** + ** Inputs: data: Pointer to the AT command data structure ** + ** Others: _nas_user_nvdata ** ** ** - ** Outputs: None ** - ** Return: RETURNok; RETURNerror; ** - ** Others: _nas_user_data ** + ** Outputs: None ** + ** Return: RETURNok; RETURNerror; ** + ** 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,23 +415,23 @@ 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) - { - case AT_COMMAND_ACT: - /* Get the Model identifier */ - strncpy(cgmm->model, _nas_user_nvdata.model, - AT_RESPONSE_INFO_TEXT_SIZE); - break; - - case AT_COMMAND_TST: - /* Nothing to do */ - break; - - default: - 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; + switch (data->type) { + case AT_COMMAND_ACT: + /* Get the Model identifier */ + strncpy(cgmm->model, _nas_user_nvdata.model, + AT_RESPONSE_INFO_TEXT_SIZE); + break; + + case AT_COMMAND_TST: + /* Nothing to do */ + break; + + default: + 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; } LOG_FUNC_RETURN (ret_code); @@ -442,28 +439,28 @@ static int _nas_user_proc_cgmm(const at_command_t* data) /**************************************************************************** ** ** - ** Name: nas_user_proc_cgmr() ** + ** Name: nas_user_proc_cgmr() ** ** ** ** Description: Executes the AT CGMR command operations: ** - ** The AT CGMR command returns information text intended to ** - ** permit the user to identify the version, revision level ** - ** or date, or other pertinent information of the Mobile ** - ** Equipment to which it is connected to. ** + ** The AT CGMR command returns information text intended to ** + ** permit the user to identify the version, revision level ** + ** or date, or other pertinent information of the Mobile ** + ** Equipment to which it is connected to. ** ** ** - ** Inputs: data: Pointer to the AT command data structure ** - ** Others: _nas_user_context ** + ** Inputs: data: Pointer to the AT command data structure ** + ** Others: _nas_user_context ** ** ** - ** Outputs: None ** - ** Return: RETURNok; RETURNerror; ** - ** Others: _nas_user_data ** + ** Outputs: None ** + ** Return: RETURNok; RETURNerror; ** + ** 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,23 +468,23 @@ 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) - { - case AT_COMMAND_ACT: - /* Get the revision identifier */ - strncpy(cgmr->revision, _nas_user_context.version, - AT_RESPONSE_INFO_TEXT_SIZE); - break; - - case AT_COMMAND_TST: - /* Nothing to do */ - break; - - default: - 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; + switch (data->type) { + case AT_COMMAND_ACT: + /* Get the revision identifier */ + strncpy(cgmr->revision, _nas_user_context.version, + AT_RESPONSE_INFO_TEXT_SIZE); + break; + + case AT_COMMAND_TST: + /* Nothing to do */ + break; + + default: + 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; } LOG_FUNC_RETURN (ret_code); @@ -495,31 +492,31 @@ static int _nas_user_proc_cgmr(const at_command_t* data) /**************************************************************************** ** ** - ** Name: nas_user_proc_cimi() ** + ** Name: nas_user_proc_cimi() ** ** ** ** Description: Executes the AT CIMI command operations: ** - ** The AT CIMI command returns information text intended to ** - ** permit the user to identify the individual SIM card or ** - ** active application in the UICC (GSM or USIM) which is ** - ** attached to the Mobile Equipment to which it is connected ** - ** to. ** - ** Typically, the text will consist of a single line contai- ** - ** ning the IMSI. ** + ** The AT CIMI command returns information text intended to ** + ** permit the user to identify the individual SIM card or ** + ** active application in the UICC (GSM or USIM) which is ** + ** attached to the Mobile Equipment to which it is connected ** + ** to. ** + ** Typically, the text will consist of a single line contai- ** + ** ning the IMSI. ** ** ** - ** Inputs: data: Pointer to the AT command data structure ** - ** Others: _nas_user_nvdata ** + ** Inputs: data: Pointer to the AT command data structure ** + ** Others: _nas_user_nvdata ** ** ** - ** Outputs: None ** - ** Return: RETURNok; RETURNerror; ** - ** Others: _nas_user_data ** + ** Outputs: None ** + ** Return: RETURNok; RETURNerror; ** + ** 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,30 +524,30 @@ 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) - { - case AT_COMMAND_ACT: - if (_nas_user_context.sim_status != NAS_USER_READY) { - _nas_user_data.cause_code = AT_ERROR_SIM_PIN_REQUIRED; - LOG_FUNC_RETURN(RETURNerror); - } - /* Get the International Mobile Subscriber Identity (IMSI) */ - ret_code = nas_proc_get_imsi(cimi->IMSI); - if (ret_code != RETURNok) { - LOG_TRACE(ERROR, "USR-MAIN - Failed to get IMSI number"); - _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; - } - break; - - case AT_COMMAND_TST: - /* Nothing to do */ - break; - - default: - 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; + 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; + LOG_FUNC_RETURN(RETURNerror); + } + /* Get the International Mobile Subscriber Identity (IMSI) */ + ret_code = nas_proc_get_imsi(cimi->IMSI); + if (ret_code != RETURNok) { + LOG_TRACE(ERROR, "USR-MAIN - Failed to get IMSI number"); + _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; + } + break; + + case AT_COMMAND_TST: + /* Nothing to do */ + break; + + default: + 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; } LOG_FUNC_RETURN (ret_code); @@ -558,26 +555,26 @@ static int _nas_user_proc_cimi(const at_command_t* data) /**************************************************************************** ** ** - ** Name: nas_user_proc_cfun() ** + ** Name: nas_user_proc_cfun() ** ** ** ** Description: Executes the AT CFUN command operations: ** - ** The AT CFUN command is used to set the Mobile Equipment ** - ** to different power consumption states. ** + ** The AT CFUN command is used to set the Mobile Equipment ** + ** to different power consumption states. ** ** ** - ** Inputs: data: Pointer to the AT command data structure ** - ** Others: _nas_user_context ** + ** Inputs: data: Pointer to the AT command data structure ** + ** Others: _nas_user_context ** ** ** - ** Outputs: None ** - ** Return: RETURNok; RETURNerror; ** - ** Others: _nas_user_data ** + ** Outputs: None ** + ** Return: RETURNok; RETURNerror; ** + ** 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,83 +584,79 @@ 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) - { - case AT_COMMAND_SET: - /* - * Set command selects the level of functionality in the MT - */ - 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) { - /* The value of the reset parameter is not valid; - * return an error message */ - LOG_TRACE(ERROR, "USR-MAIN - <rst> parameter is not valid" - " (%d)", data->command.cfun.rst); - _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; - ret_code = RETURNerror; - break; - } - } - - 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 - * is not valid; return an error message */ - LOG_TRACE(ERROR, "USR-MAIN - <fun> parameter is not valid" - " (%d)", data->command.cfun.fun); - _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; - ret_code = RETURNerror; - break; - } - /* Set to the selected parameter value */ - fun = data->command.cfun.fun; - } - - switch (fun) - { - case AT_CFUN_MIN: - /* TODO: Shutdown ??? */ - break; - - case AT_CFUN_FULL: - /* Notify the NAS procedure call manager that the UE is - * operational */ - ret_code = nas_proc_enable_s1_mode(); - break; - - default: - /* TODO: Disable the radio ??? */ - break; - } - - if (ret_code != RETURNerror) { - /* Update the functionality level */ - _nas_user_context.fun = fun; - } - break; - - case AT_COMMAND_GET: - /* Get the MT's functionality level */ - cfun->fun = _nas_user_context.fun; - break; - - case AT_COMMAND_TST: - /* - * Test command returns values supported as a compound value - */ - break; - - default: - 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; + 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->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) { + /* The value of the reset parameter is not valid; + * return an error message */ + LOG_TRACE(ERROR, "USR-MAIN - <rst> parameter is not valid" + " (%d)", data->command.cfun.rst); + _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; + ret_code = RETURNerror; + break; + } + } + + 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 + * is not valid; return an error message */ + LOG_TRACE(ERROR, "USR-MAIN - <fun> parameter is not valid" + " (%d)", data->command.cfun.fun); + _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; + ret_code = RETURNerror; + break; + } + /* Set to the selected parameter value */ + fun = data->command.cfun.fun; + } + + switch (fun) { + case AT_CFUN_MIN: + /* TODO: Shutdown ??? */ + break; + + case AT_CFUN_FULL: + /* Notify the NAS procedure call manager that the UE is + * operational */ + ret_code = nas_proc_enable_s1_mode(); + break; + + default: + /* TODO: Disable the radio ??? */ + break; + } + + if (ret_code != RETURNerror) { + /* Update the functionality level */ + _nas_user_context.fun = fun; + } + break; + + case AT_COMMAND_GET: + /* Get the MT's functionality level */ + cfun->fun = _nas_user_context.fun; + break; + + case AT_COMMAND_TST: + /* + * Test command returns values supported as a compound value + */ + break; + + default: + 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; } LOG_FUNC_RETURN (ret_code); @@ -671,27 +664,27 @@ static int _nas_user_proc_cfun(const at_command_t* data) /**************************************************************************** ** ** - ** Name: nas_user_proc_cpin() ** + ** Name: nas_user_proc_cpin() ** ** ** ** Description: Executes the AT CPIN command operations: ** - ** The AT CPIN command is used to enter the Mobile Equipment ** - ** passwords which are needed before any other functionality ** - ** can be operated. ** + ** The AT CPIN command is used to enter the Mobile Equipment ** + ** passwords which are needed before any other functionality ** + ** can be operated. ** ** ** - ** Inputs: data: Pointer to the AT command data structure ** - ** Others: _nas_user_context ** + ** Inputs: data: Pointer to the AT command data structure ** + ** Others: _nas_user_context ** ** ** - ** Outputs: None ** - ** Return: RETURNok; RETURNerror; ** - ** Others: _nas_user_context, _nas_user_data ** + ** Outputs: None ** + ** Return: RETURNok; RETURNerror; ** + ** 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,60 +692,56 @@ 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) - { - 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) - { - /* 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) { - /* The PIN code is NOT matching; return an error message */ - LOG_TRACE(ERROR, "USR-MAIN - PIN code is not correct " - "(%s)", data->command.cpin.pin); - _nas_user_data.cause_code = AT_ERROR_INCORRECT_PASSWD; - ret_code = RETURNerror; - } - else { - /* The PIN code is matching; update the user's PIN - * pending status */ - _nas_user_context.sim_status = NAS_USER_READY; - } - } - else - { - /* The MT is NOT waiting for PIN password; - * return an error message */ - _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_ALLOWED; - ret_code = RETURNerror; - } - - break; - - case AT_COMMAND_GET: - /* - * Read command returns an alphanumeric string indicating - * whether some password is required or not. - */ - strncpy(cpin->code, - _nas_user_sim_status_str[_nas_user_context.sim_status], - AT_CPIN_RESP_SIZE); - break; - - case AT_COMMAND_TST: - /* Nothing to do */ - break; - - 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); - _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; - ret_code = RETURNerror; - break; + 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) { + /* 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) { + /* The PIN code is NOT matching; return an error message */ + LOG_TRACE(ERROR, "USR-MAIN - PIN code is not correct " + "(%s)", data->command.cpin.pin); + _nas_user_data.cause_code = AT_ERROR_INCORRECT_PASSWD; + ret_code = RETURNerror; + } else { + /* The PIN code is matching; update the user's PIN + * pending status */ + _nas_user_context.sim_status = NAS_USER_READY; + } + } else { + /* The MT is NOT waiting for PIN password; + * return an error message */ + _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_ALLOWED; + ret_code = RETURNerror; + } + + break; + + case AT_COMMAND_GET: + /* + * Read command returns an alphanumeric string indicating + * whether some password is required or not. + */ + strncpy(cpin->code, + _nas_user_sim_status_str[_nas_user_context.sim_status], + AT_CPIN_RESP_SIZE); + break; + + case AT_COMMAND_TST: + /* Nothing to do */ + break; + + 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); + _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; + ret_code = RETURNerror; + break; } LOG_FUNC_RETURN (ret_code); @@ -760,27 +749,27 @@ static int _nas_user_proc_cpin(const at_command_t* data) /**************************************************************************** ** ** - ** Name: nas_user_proc_csq() ** + ** Name: nas_user_proc_csq() ** ** ** ** Description: Executes the AT CSQ command operations: ** - ** The AT CSQ command returns received signal strength ** - ** indication and channel bit error rate from the Mobile ** - ** Equipment. ** + ** The AT CSQ command returns received signal strength ** + ** indication and channel bit error rate from the Mobile ** + ** Equipment. ** ** ** - ** Inputs: data: Pointer to the AT command data structure ** - ** Others: _nas_user_context ** + ** Inputs: data: Pointer to the AT command data structure ** + ** Others: _nas_user_context ** ** ** - ** Outputs: None ** - ** Return: RETURNok; RETURNerror; ** - ** Others: _nas_user_data ** + ** Outputs: None ** + ** Return: RETURNok; RETURNerror; ** + ** 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,32 +777,32 @@ 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) - { - case AT_COMMAND_ACT: - if (_nas_user_context.sim_status != NAS_USER_READY) { - _nas_user_data.cause_code = AT_ERROR_SIM_PIN_REQUIRED; - LOG_FUNC_RETURN(RETURNerror); - } - /* - * Execution command returns received signal strength indication - * and channel bit error rate <ber> from the MT - */ - csq->rssi = AT_CESQ_RSSI_UNKNOWN; - csq->ber = AT_CESQ_BER_UNKNOWN; - break; - - case AT_COMMAND_TST: - /* - * Test command returns values supported as a compound value - */ - break; - - default: - 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; + 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; + LOG_FUNC_RETURN(RETURNerror); + } + /* + * Execution command returns received signal strength indication + * and channel bit error rate <ber> from the MT + */ + csq->rssi = AT_CESQ_RSSI_UNKNOWN; + csq->ber = AT_CESQ_BER_UNKNOWN; + break; + + case AT_COMMAND_TST: + /* + * Test command returns values supported as a compound value + */ + break; + + default: + 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; } LOG_FUNC_RETURN (ret_code); @@ -821,26 +810,26 @@ static int _nas_user_proc_csq(const at_command_t* data) /**************************************************************************** ** ** - ** Name: nas_user_proc_cesq() ** + ** Name: nas_user_proc_cesq() ** ** ** ** Description: Executes the AT CESQ command operations: ** - ** The AT CESQ command returns received signal quality para- ** - ** meters. ** + ** The AT CESQ command returns received signal quality para- ** + ** meters. ** ** ** - ** Inputs: data: Pointer to the AT command data structure ** - ** Others: _nas_user_context ** + ** Inputs: data: Pointer to the AT command data structure ** + ** Others: _nas_user_context ** ** ** - ** Outputs: None ** - ** Return: RETURNok; RETURNerror; ** - ** Others: _nas_user_data ** + ** Outputs: None ** + ** Return: RETURNok; RETURNerror; ** + ** 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,34 +837,34 @@ 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) - { - case AT_COMMAND_ACT: - if (_nas_user_context.sim_status != NAS_USER_READY) { - _nas_user_data.cause_code = AT_ERROR_SIM_PIN_REQUIRED; - LOG_FUNC_RETURN(RETURNerror); - } - /* - * Execution command returns received signal quality parameters - */ - cesq->rssi = AT_CESQ_RSSI_UNKNOWN; - cesq->ber = AT_CESQ_BER_UNKNOWN; - cesq->rscp = AT_CESQ_RSCP_UNKNOWN; - cesq->ecno = AT_CESQ_ECNO_UNKNOWN; - ret_code = nas_proc_get_signal_quality(&cesq->rsrq, &cesq->rsrp); - break; - - case AT_COMMAND_TST: - /* - * Test command returns values supported as a compound value - */ - break; - - default: - 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; + 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; + LOG_FUNC_RETURN(RETURNerror); + } + /* + * Execution command returns received signal quality parameters + */ + cesq->rssi = AT_CESQ_RSSI_UNKNOWN; + cesq->ber = AT_CESQ_BER_UNKNOWN; + cesq->rscp = AT_CESQ_RSCP_UNKNOWN; + cesq->ecno = AT_CESQ_ECNO_UNKNOWN; + ret_code = nas_proc_get_signal_quality(&cesq->rsrq, &cesq->rsrp); + break; + + case AT_COMMAND_TST: + /* + * Test command returns values supported as a compound value + */ + break; + + default: + 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; } LOG_FUNC_RETURN (ret_code); @@ -883,28 +872,28 @@ static int _nas_user_proc_cesq(const at_command_t* data) /**************************************************************************** ** ** - ** Name: nas_user_proc_cops() ** + ** Name: nas_user_proc_cops() ** ** ** ** Description: Executes the AT COPS command operations: ** - ** The AT COPS command forces an attempt to select and ** - ** register the GSM/UMTS/EPS network operator using the ** - ** SIM/USIM card installed in the currently selected card ** - ** slot. ** + ** The AT COPS command forces an attempt to select and ** + ** register the GSM/UMTS/EPS network operator using the ** + ** SIM/USIM card installed in the currently selected card ** + ** slot. ** ** ** - ** Inputs: data: Pointer to the AT command data structure ** - ** Others: _nas_user_context ** + ** Inputs: data: Pointer to the AT command data structure ** + ** Others: _nas_user_context ** ** ** - ** Outputs: None ** - ** Return: RETURNok; RETURNerror; ** - ** Others: _nas_user_data ** + ** Outputs: None ** + ** Return: RETURNok; RETURNerror; ** + ** 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,205 +911,200 @@ 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) - { - case AT_COMMAND_SET: - if (_nas_user_context.sim_status != NAS_USER_READY) { - _nas_user_data.cause_code = AT_ERROR_SIM_PIN_REQUIRED; - LOG_FUNC_RETURN(RETURNerror); - } - /* - * Set command forces an attempt to select and register the - * GSM/UMTS/EPS network operator using the SIM/USIM card - * installed in the currently selected card slot. - */ - if (data->mask & AT_COPS_MODE_MASK) - { - mode = data->command.cops.mode; - switch (mode) - { - case AT_COPS_AUTO: - /* - * Register in automatic mode - */ - break; - - case AT_COPS_MANUAL: - /* - * Register in manual mode - */ - - /** break is intentionaly missing */ - - case AT_COPS_MANAUTO: - /* - * Register in manual/automatic mode - */ - - /* <oper> field shall be present */ - if ( !(data->mask & AT_COPS_OPER_MASK) ) { - LOG_TRACE(ERROR, "USR-MAIN - <oper> parameter is not present"); - _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; - ret_code = RETURNerror; - break; - } - - /* <format> field shall be present */ - if ( !(data->mask & AT_COPS_FORMAT_MASK) ) { - LOG_TRACE(ERROR, "USR-MAIN - <format> parameter is not present"); - _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; - ret_code = RETURNerror; - break; - } - - /* Set the operator's representation format */ - 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); - _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; - ret_code = RETURNerror; - break; - } - read_format = format = data->command.cops.format; - - /* Set the access technology */ - 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); - _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; - ret_code = RETURNerror; - break; - } - AcT = data->command.cops.AcT; - } - - break; - - case AT_COPS_DEREG: - /* - * Deregister from network - */ - /* Nothing to do there */ - break; - - case AT_COPS_FORMAT: - /* - * Set only <format> for read command +COPS? - */ - 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); - _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 { - /* Format is not present; set to default */ - read_format = AT_COPS_FORMAT_DEFAULT; - } - - break; - - default: - LOG_TRACE(ERROR, "USR-MAIN - <mode> parameter is not supported (%d)", mode); - _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; - ret_code = RETURNerror; - break; - } - } - - /* - * Performs network registration - */ - if (ret_code != RETURNerror) - { - if (mode == AT_COPS_DEREG) { - /* Force an attempt to deregister from the network */ - ret_code = nas_proc_deregister(); - if (ret_code != RETURNok) { - LOG_TRACE(ERROR, "USR-MAIN - Network deregistration failed"); - _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; - break; - } - } - 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, - &data->command.cops.plmn, AcT); - if (ret_code != RETURNok) { - LOG_TRACE(ERROR, "USR-MAIN - Network registration failed (<mode>=%d)", mode); - _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; - break; - } - } - } - - break; - - case AT_COMMAND_GET: - /* - * Read command returns the current mode, the currently selected - * network operator and the current Access Technology. - */ - - /* Get the current network registration data */ - ret_code = nas_proc_get_reg_data(&mode, - &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); - _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; - break; - } - - /* Set the network selection operating mode */ - if (mode == NET_PLMN_AUTO) { - cops->get.mode = AT_COPS_AUTO; - } - else if (mode == NET_PLMN_MANUAL) { - cops->get.mode = AT_COPS_MANUAL; - } - else { - cops->get.mode = AT_COPS_MANAUTO; - } - - /* Set optional parameter bitmask */ - if (oper_is_selected) { - cops->get.format = read_format; - _nas_user_data.mask |= (AT_COPS_RESP_FORMAT_MASK | - AT_COPS_RESP_OPER_MASK); - - if (cops->get.AcT != NET_ACCESS_UNAVAILABLE) { - _nas_user_data.mask |= AT_COPS_RESP_ACT_MASK; - } - } - - break; - - case AT_COMMAND_TST: - /* - * Test command returns a set of parameters, each representing - * an operator present in the network. - */ - cops->tst.size = nas_proc_get_oper_list(&cops->tst.data); - break; - - default: - 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; + 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; + LOG_FUNC_RETURN(RETURNerror); + } + /* + * Set command forces an attempt to select and register the + * GSM/UMTS/EPS network operator using the SIM/USIM card + * installed in the currently selected card slot. + */ + if (data->mask & AT_COPS_MODE_MASK) { + mode = data->command.cops.mode; + switch (mode) { + case AT_COPS_AUTO: + /* + * Register in automatic mode + */ + break; + + case AT_COPS_MANUAL: + /* + * Register in manual mode + */ + + /** break is intentionaly missing */ + + case AT_COPS_MANAUTO: + /* + * Register in manual/automatic mode + */ + + /* <oper> field shall be present */ + if ( !(data->mask & AT_COPS_OPER_MASK) ) { + LOG_TRACE(ERROR, "USR-MAIN - <oper> parameter is not present"); + _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; + ret_code = RETURNerror; + break; + } + + /* <format> field shall be present */ + if ( !(data->mask & AT_COPS_FORMAT_MASK) ) { + LOG_TRACE(ERROR, "USR-MAIN - <format> parameter is not present"); + _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; + ret_code = RETURNerror; + break; + } + + /* Set the operator's representation format */ + 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); + _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; + ret_code = RETURNerror; + break; + } + read_format = format = data->command.cops.format; + + /* Set the access technology */ + 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); + _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; + ret_code = RETURNerror; + break; + } + AcT = data->command.cops.AcT; + } + + break; + + case AT_COPS_DEREG: + /* + * Deregister from network + */ + /* Nothing to do there */ + break; + + case AT_COPS_FORMAT: + /* + * Set only <format> for read command +COPS? + */ + 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); + _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 { + /* Format is not present; set to default */ + read_format = AT_COPS_FORMAT_DEFAULT; + } + + break; + + default: + LOG_TRACE(ERROR, "USR-MAIN - <mode> parameter is not supported (%d)", mode); + _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; + ret_code = RETURNerror; + break; + } + } + + /* + * Performs network registration + */ + if (ret_code != RETURNerror) { + if (mode == AT_COPS_DEREG) { + /* Force an attempt to deregister from the network */ + ret_code = nas_proc_deregister(); + if (ret_code != RETURNok) { + LOG_TRACE(ERROR, "USR-MAIN - Network deregistration failed"); + _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; + break; + } + } 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, + &data->command.cops.plmn, AcT); + if (ret_code != RETURNok) { + LOG_TRACE(ERROR, "USR-MAIN - Network registration failed (<mode>=%d)", mode); + _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; + break; + } + } + } + + break; + + case AT_COMMAND_GET: + /* + * Read command returns the current mode, the currently selected + * network operator and the current Access Technology. + */ + + /* Get the current network registration data */ + ret_code = nas_proc_get_reg_data(&mode, + &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); + _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; + break; + } + + /* Set the network selection operating mode */ + if (mode == NET_PLMN_AUTO) { + cops->get.mode = AT_COPS_AUTO; + } else if (mode == NET_PLMN_MANUAL) { + cops->get.mode = AT_COPS_MANUAL; + } else { + cops->get.mode = AT_COPS_MANAUTO; + } + + /* Set optional parameter bitmask */ + if (oper_is_selected) { + cops->get.format = read_format; + _nas_user_data.mask |= (AT_COPS_RESP_FORMAT_MASK | + AT_COPS_RESP_OPER_MASK); + + if (cops->get.AcT != NET_ACCESS_UNAVAILABLE) { + _nas_user_data.mask |= AT_COPS_RESP_ACT_MASK; + } + } + + break; + + case AT_COMMAND_TST: + /* + * Test command returns a set of parameters, each representing + * an operator present in the network. + */ + cops->tst.size = nas_proc_get_oper_list(&cops->tst.data); + break; + + default: + 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; } LOG_FUNC_RETURN (ret_code); @@ -1128,26 +1112,26 @@ static int _nas_user_proc_cops(const at_command_t* data) /**************************************************************************** ** ** - ** Name: nas_user_proc_cgatt() ** + ** Name: nas_user_proc_cgatt() ** ** ** ** Description: Executes the AT CGATT command operations: ** - ** The AT CGATT command is used to attach the MT to, ** - ** or detach the MT from, the EPS service. ** + ** The AT CGATT command is used to attach the MT to, ** + ** or detach the MT from, the EPS service. ** ** ** - ** Inputs: data: Pointer to the AT command data structure ** - ** Others: _nas_user_context ** + ** Inputs: data: Pointer to the AT command data structure ** + ** Others: _nas_user_context ** ** ** - ** Outputs: None ** - ** Return: RETURNok; RETURNerror; ** - ** Others: _nas_user_data ** + ** Outputs: None ** + ** Return: RETURNok; RETURNerror; ** + ** 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,71 +1139,69 @@ 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) - { - case AT_COMMAND_SET: - if (_nas_user_context.sim_status != NAS_USER_READY) { - _nas_user_data.cause_code = AT_ERROR_SIM_PIN_REQUIRED; - LOG_FUNC_RETURN(RETURNerror); - } - /* - * 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->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); - _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; - ret_code = RETURNerror; - break; - } - /* - * Perform EPS service attach/detach - */ - 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) { - ret_code = nas_proc_detach(FALSE); - } - if (ret_code != RETURNok) { - LOG_TRACE(ERROR, "USR-MAIN - Failed to attach/detach " - "to/from EPS service (<state>=%d)", - data->command.cgatt.state); - _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; - } - } - break; - - case AT_COMMAND_GET: - /* - * Read command returns the current EPS service state. - */ - if (nas_proc_get_attach_status() != TRUE) { - cgatt->state = AT_CGATT_DETACHED; - } - else { - cgatt->state = AT_CGATT_ATTACHED; - } - break; - - case AT_COMMAND_TST: - /* - * Test command is used for requesting information on the supported - * EPS service states - */ - break; - - default: - 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; + 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; + LOG_FUNC_RETURN(RETURNerror); + } + /* + * 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->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); + _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; + ret_code = RETURNerror; + break; + } + /* + * Perform EPS service attach/detach + */ + 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) { + ret_code = nas_proc_detach(FALSE); + } + if (ret_code != RETURNok) { + LOG_TRACE(ERROR, "USR-MAIN - Failed to attach/detach " + "to/from EPS service (<state>=%d)", + data->command.cgatt.state); + _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; + } + } + break; + + case AT_COMMAND_GET: + /* + * Read command returns the current EPS service state. + */ + if (nas_proc_get_attach_status() != TRUE) { + cgatt->state = AT_CGATT_DETACHED; + } else { + cgatt->state = AT_CGATT_ATTACHED; + } + break; + + case AT_COMMAND_TST: + /* + * Test command is used for requesting information on the supported + * EPS service states + */ + break; + + default: + 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; } LOG_FUNC_RETURN (ret_code); @@ -1227,27 +1209,27 @@ static int _nas_user_proc_cgatt(const at_command_t* data) /**************************************************************************** ** ** - ** Name: nas_user_proc_creg() ** + ** Name: nas_user_proc_creg() ** ** ** ** Description: Executes the AT CREG command operations: ** - ** The AT CREG command returns the Mobile Equipment's ** - ** circuit mode network registration status and optionnally ** - ** location information in GERA/UTRA/E-UTRA Network. ** + ** The AT CREG command returns the Mobile Equipment's ** + ** circuit mode network registration status and optionnally ** + ** location information in GERA/UTRA/E-UTRA Network. ** ** ** - ** Inputs: data: Pointer to the AT command data structure ** - ** Others: _nas_user_context ** + ** Inputs: data: Pointer to the AT command data structure ** + ** Others: _nas_user_context ** ** ** - ** Outputs: None ** - ** Return: RETURNok; RETURNerror; ** - ** Others: _nas_user_data ** + ** Outputs: None ** + ** Return: RETURNok; RETURNerror; ** + ** 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,109 +1239,106 @@ 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) - { - case AT_COMMAND_SET: - if (_nas_user_context.sim_status != NAS_USER_READY) { - _nas_user_data.cause_code = AT_ERROR_SIM_PIN_REQUIRED; - LOG_FUNC_RETURN(RETURNerror); - } - /* - * The set command controls the presentation of an unsolicited - * result code when there is a change in the MT's circuit mode - * 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->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; - * return an error message */ - LOG_TRACE(ERROR, "USR-MAIN - <n> parameter is not valid" - " (%d)", data->command.creg.n); - _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; - ret_code = RETURNerror; - break; - } - /* Set to the selected parameter value */ - n = data->command.creg.n; - } - else { - /* The numeric parameter is not present; set to default */ - n = AT_CREG_N_DEFAULT; - } - - /* Disable/Enable network logging */ - switch (n) - { - case AT_CREG_OFF: - /* Disable logging of network registration status */ - ret_code = user_ind_deregister(USER_IND_REG); - if (ret_code != RETURNerror) { - /* Disable logging of location information */ - ret_code = user_ind_deregister(USER_IND_LOC); - } - if (ret_code != RETURNok) { - LOG_TRACE(ERROR, "USR-MAIN - Failed to disable logging of network notification"); - _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; - } - break; - - case AT_CREG_BOTH: - /* Location Area Code (lac) is not available */ - case AT_CREG_ON: - /* Enable logging of the MT's circuit mode network - * registration status in GERAN/UTRAN/E_UTRAN */ - ret_code = user_ind_register(USER_IND_REG, AT_CREG, NULL); - if (ret_code != RETURNok) { - LOG_TRACE(ERROR, "USR-MAIN - Failed to enable logging of registration status"); - _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; - } - break; - - default: - break; - } - - break; - - case AT_COMMAND_GET: - /* - * The read command returns the status of result code presentation, - * and indication of whether the network has currently indicated - * the registration of the MT, and available location information - * elements when the MT is registered in the network. - */ - creg->n = n; - switch (n) - { - case AT_CREG_BOTH: - /* Location Area Code (lac) is not available */ - case AT_CREG_OFF: - case AT_CREG_ON: - /* Get network registration status */ - ret_code = nas_proc_get_reg_status(&creg->stat); - if (ret_code != RETURNok) { - LOG_TRACE(ERROR, "USR-MAIN - Failed to get registration status"); - _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; - } - break; - - default: - break; - } - - break; - - case AT_COMMAND_TST: - break; - - default: - 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; + 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; + LOG_FUNC_RETURN(RETURNerror); + } + /* + * The set command controls the presentation of an unsolicited + * result code when there is a change in the MT's circuit mode + * 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->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; + * return an error message */ + LOG_TRACE(ERROR, "USR-MAIN - <n> parameter is not valid" + " (%d)", data->command.creg.n); + _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; + ret_code = RETURNerror; + break; + } + /* Set to the selected parameter value */ + n = data->command.creg.n; + } else { + /* The numeric parameter is not present; set to default */ + n = AT_CREG_N_DEFAULT; + } + + /* Disable/Enable network logging */ + switch (n) { + case AT_CREG_OFF: + /* Disable logging of network registration status */ + ret_code = user_ind_deregister(USER_IND_REG); + if (ret_code != RETURNerror) { + /* Disable logging of location information */ + ret_code = user_ind_deregister(USER_IND_LOC); + } + if (ret_code != RETURNok) { + LOG_TRACE(ERROR, + "USR-MAIN - Failed to disable logging of network notification"); + _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; + } + break; + + case AT_CREG_BOTH: + /* Location Area Code (lac) is not available */ + case AT_CREG_ON: + /* Enable logging of the MT's circuit mode network + * registration status in GERAN/UTRAN/E_UTRAN */ + ret_code = user_ind_register(USER_IND_REG, AT_CREG, NULL); + if (ret_code != RETURNok) { + LOG_TRACE(ERROR, "USR-MAIN - Failed to enable logging of registration status"); + _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; + } + break; + + default: + break; + } + + break; + + case AT_COMMAND_GET: + /* + * The read command returns the status of result code presentation, + * and indication of whether the network has currently indicated + * the registration of the MT, and available location information + * elements when the MT is registered in the network. + */ + creg->n = n; + switch (n) { + case AT_CREG_BOTH: + /* Location Area Code (lac) is not available */ + case AT_CREG_OFF: + case AT_CREG_ON: + /* Get network registration status */ + ret_code = nas_proc_get_reg_status(&creg->stat); + if (ret_code != RETURNok) { + LOG_TRACE(ERROR, "USR-MAIN - Failed to get registration status"); + _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; + } + break; + + default: + break; + } + + break; + + case AT_COMMAND_TST: + break; + + default: + 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; } LOG_FUNC_RETURN (ret_code); @@ -1367,27 +1346,27 @@ static int _nas_user_proc_creg(const at_command_t* data) /**************************************************************************** ** ** - ** Name: nas_user_proc_cgreg() ** + ** Name: nas_user_proc_cgreg() ** ** ** ** Description: Executes the AT CGREG command operations: ** - ** The AT CGREG command returns the Mobile Equipment's GPRS ** - ** network registration status and optionnally location ** - ** information in GERA/UTRA Network. ** + ** The AT CGREG command returns the Mobile Equipment's GPRS ** + ** network registration status and optionnally location ** + ** information in GERA/UTRA Network. ** ** ** - ** Inputs: data: Pointer to the AT command data structure ** - ** Others: _nas_user_context ** + ** Inputs: data: Pointer to the AT command data structure ** + ** Others: _nas_user_context ** ** ** - ** Outputs: None ** - ** Return: RETURNok; RETURNerror; ** - ** Others: _nas_user_data ** + ** Outputs: None ** + ** Return: RETURNok; RETURNerror; ** + ** 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,109 +1376,106 @@ 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) - { - case AT_COMMAND_SET: - if (_nas_user_context.sim_status != NAS_USER_READY) { - _nas_user_data.cause_code = AT_ERROR_SIM_PIN_REQUIRED; - LOG_FUNC_RETURN(RETURNerror); - } - /* - * The set command controls the presentation of an unsolicited - * result code when there is a change in the MT's GPRS network - * registration status, or when there is a change of the network - * cell in GERAN/UTRAN. - */ - 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; - * return an error message */ - LOG_TRACE(ERROR, "USR-MAIN - <n> parameter is not valid" - " (%d)", data->command.cgreg.n); - _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; - ret_code = RETURNerror; - break; - } - /* Set to the selected parameter value */ - n = data->command.cgreg.n; - } - else { - /* The numeric parameter is not present; set to default */ - n = AT_CGREG_N_DEFAULT; - } - - /* Disable/Enable network logging */ - switch (n) - { - case AT_CGREG_OFF: - /* Disable logging of network registration status */ - ret_code = user_ind_deregister(USER_IND_REG); - if (ret_code != RETURNerror) { - /* Disable logging of location information */ - ret_code = user_ind_deregister(USER_IND_LOC); - } - if (ret_code != RETURNok) { - LOG_TRACE(ERROR, "USR-MAIN - Failed to disable logging of network notification"); - _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; - } - break; - - case AT_CGREG_BOTH: - /* Location Area Code (lac) is not available */ - case AT_CGREG_ON: - /* Enable logging of the MT's GPRS network registration - * status in GERAN/UTRAN/E_UTRAN */ - ret_code = user_ind_register(USER_IND_REG, AT_CGREG, NULL); - if (ret_code != RETURNok) { - LOG_TRACE(ERROR, "USR-MAIN - Failed to enable logging of registration status"); - _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; - } - break; - - default: - break; - } - - break; - - case AT_COMMAND_GET: - /* - * The read command returns the status of result code presentation, - * and indication of whether the network has currently indicated - * the registration of the MT, and available location information - * elements when the MT is registered in the network. - */ - cgreg->n = n; - switch (n) - { - case AT_CGREG_BOTH: - /* Location Area Code (lac) is not available */ - case AT_CGREG_OFF: - case AT_CGREG_ON: - /* Get network registration status */ - ret_code = nas_proc_get_reg_status(&cgreg->stat); - if (ret_code != RETURNok) { - LOG_TRACE(ERROR, "USR-MAIN - Failed to get registration status"); - _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; - } - break; - - default: - break; - } - - break; - - case AT_COMMAND_TST: - break; - - default: - 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; + 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; + LOG_FUNC_RETURN(RETURNerror); + } + /* + * The set command controls the presentation of an unsolicited + * result code when there is a change in the MT's GPRS network + * registration status, or when there is a change of the network + * cell in GERAN/UTRAN. + */ + 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; + * return an error message */ + LOG_TRACE(ERROR, "USR-MAIN - <n> parameter is not valid" + " (%d)", data->command.cgreg.n); + _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; + ret_code = RETURNerror; + break; + } + /* Set to the selected parameter value */ + n = data->command.cgreg.n; + } else { + /* The numeric parameter is not present; set to default */ + n = AT_CGREG_N_DEFAULT; + } + + /* Disable/Enable network logging */ + switch (n) { + case AT_CGREG_OFF: + /* Disable logging of network registration status */ + ret_code = user_ind_deregister(USER_IND_REG); + if (ret_code != RETURNerror) { + /* Disable logging of location information */ + ret_code = user_ind_deregister(USER_IND_LOC); + } + if (ret_code != RETURNok) { + LOG_TRACE(ERROR, + "USR-MAIN - Failed to disable logging of network notification"); + _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; + } + break; + + case AT_CGREG_BOTH: + /* Location Area Code (lac) is not available */ + case AT_CGREG_ON: + /* Enable logging of the MT's GPRS network registration + * status in GERAN/UTRAN/E_UTRAN */ + ret_code = user_ind_register(USER_IND_REG, AT_CGREG, NULL); + if (ret_code != RETURNok) { + LOG_TRACE(ERROR, "USR-MAIN - Failed to enable logging of registration status"); + _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; + } + break; + + default: + break; + } + + break; + + case AT_COMMAND_GET: + /* + * The read command returns the status of result code presentation, + * and indication of whether the network has currently indicated + * the registration of the MT, and available location information + * elements when the MT is registered in the network. + */ + cgreg->n = n; + switch (n) { + case AT_CGREG_BOTH: + /* Location Area Code (lac) is not available */ + case AT_CGREG_OFF: + case AT_CGREG_ON: + /* Get network registration status */ + ret_code = nas_proc_get_reg_status(&cgreg->stat); + if (ret_code != RETURNok) { + LOG_TRACE(ERROR, "USR-MAIN - Failed to get registration status"); + _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; + } + break; + + default: + break; + } + + break; + + case AT_COMMAND_TST: + break; + + default: + 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; } LOG_FUNC_RETURN (ret_code); @@ -1507,27 +1483,27 @@ static int _nas_user_proc_cgreg(const at_command_t* data) /**************************************************************************** ** ** - ** Name: nas_user_proc_cereg() ** + ** Name: nas_user_proc_cereg() ** ** ** ** Description: Executes the AT CEREG command operations: ** - ** The AT CEREG command returns the Mobile Equipment's EPS ** - ** services registration status and optionnally location ** - ** information in E-UTRA Network. ** + ** The AT CEREG command returns the Mobile Equipment's EPS ** + ** services registration status and optionnally location ** + ** information in E-UTRA Network. ** ** ** - ** Inputs: data: Pointer to the AT command data structure ** - ** Others: _nas_user_context ** + ** Inputs: data: Pointer to the AT command data structure ** + ** Others: _nas_user_context ** ** ** - ** Outputs: None ** - ** Return: RETURNok; RETURNerror; ** - ** Others: _nas_user_data ** + ** Outputs: None ** + ** Return: RETURNok; RETURNerror; ** + ** 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,134 +1513,131 @@ 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) - { - case AT_COMMAND_SET: - if (_nas_user_context.sim_status != NAS_USER_READY) { - _nas_user_data.cause_code = AT_ERROR_SIM_PIN_REQUIRED; - LOG_FUNC_RETURN(RETURNerror); - } - /* - * The set command controls the presentation of an unsolicited - * result code when there is a change in the MT's EPS network - * registration status, or when there is a change of the network - * cell in E-UTRAN. - */ - 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; - * return an error message */ - LOG_TRACE(ERROR, "USR-MAIN - <n> parameter is not valid" - " (%d)", data->command.cereg.n); - _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; - ret_code = RETURNerror; - break; - } - /* Set to the selected parameter value */ - n = data->command.cereg.n; - } - else { - /* The numeric parameter is not present; set to default */ - n = AT_CEREG_N_DEFAULT; - } - - /* Disable/Enable network logging */ - switch (n) - { - case AT_CEREG_OFF: - /* Disable logging of network registration status */ - ret_code = user_ind_deregister(USER_IND_REG); - if (ret_code != RETURNerror) { - /* Disable logging of location information */ - ret_code = user_ind_deregister(USER_IND_LOC); - } - if (ret_code != RETURNok) { - LOG_TRACE(ERROR, "USR-MAIN - Failed to disable logging of network notification"); - _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; - } - break; - - case AT_CEREG_BOTH: - /* Enable logging of the location information in E-UTRAN */ - ret_code = user_ind_register(USER_IND_LOC, AT_CEREG, NULL); - if (ret_code != RETURNok) { - LOG_TRACE(ERROR, "USR-MAIN - Failed to enable logging of location information"); - _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; - } - break; - - case AT_CEREG_ON: - /* Enable logging of the MT's EPS network registration - * status in E-UTRAN */ - ret_code = user_ind_register(USER_IND_REG, AT_CEREG, NULL); - if (ret_code != RETURNok) { - LOG_TRACE(ERROR, "USR-MAIN - Failed to enable logging of registration status"); - _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; - } - break; - - default: - break; - } - - break; - - case AT_COMMAND_GET: - /* - * The read command returns the status of result code presentation, - * and indication of whether the network has currently indicated - * the registration of the MT, and available location information - * elements when the MT is registered in the network. - */ - cereg->n = n; - switch (n) - { - case AT_CEREG_BOTH: - /* Get EPS location information */ - ret_code = nas_proc_get_loc_info(cereg->tac, cereg->ci, - &cereg->AcT); - if (ret_code != RETURNok) { - LOG_TRACE(ERROR, "USR-MAIN - Failed to get location information"); - _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; - break; - } - - if (cereg->tac[0] != 0) { - _nas_user_data.mask |= (AT_CEREG_RESP_TAC_MASK | - AT_CEREG_RESP_CI_MASK); - if (cereg->AcT != NET_ACCESS_UNAVAILABLE) { - _nas_user_data.mask |= (AT_CEREG_RESP_ACT_MASK); - } - } - - /** break is intentionaly missing */ - - case AT_CEREG_OFF: - case AT_CEREG_ON: - /* Get network registration status */ - ret_code = nas_proc_get_reg_status(&cereg->stat); - if (ret_code != RETURNok) { - LOG_TRACE(ERROR, "USR-MAIN - Failed to get registration status"); - _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; - } - break; - - default: - break; - } - - break; - - case AT_COMMAND_TST: - break; - - default: - 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; + 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; + LOG_FUNC_RETURN(RETURNerror); + } + /* + * The set command controls the presentation of an unsolicited + * result code when there is a change in the MT's EPS network + * registration status, or when there is a change of the network + * cell in E-UTRAN. + */ + 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; + * return an error message */ + LOG_TRACE(ERROR, "USR-MAIN - <n> parameter is not valid" + " (%d)", data->command.cereg.n); + _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; + ret_code = RETURNerror; + break; + } + /* Set to the selected parameter value */ + n = data->command.cereg.n; + } else { + /* The numeric parameter is not present; set to default */ + n = AT_CEREG_N_DEFAULT; + } + + /* Disable/Enable network logging */ + switch (n) { + case AT_CEREG_OFF: + /* Disable logging of network registration status */ + ret_code = user_ind_deregister(USER_IND_REG); + if (ret_code != RETURNerror) { + /* Disable logging of location information */ + ret_code = user_ind_deregister(USER_IND_LOC); + } + if (ret_code != RETURNok) { + LOG_TRACE(ERROR, + "USR-MAIN - Failed to disable logging of network notification"); + _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; + } + break; + + case AT_CEREG_BOTH: + /* Enable logging of the location information in E-UTRAN */ + ret_code = user_ind_register(USER_IND_LOC, AT_CEREG, NULL); + if (ret_code != RETURNok) { + LOG_TRACE(ERROR, "USR-MAIN - Failed to enable logging of location information"); + _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; + } + break; + + case AT_CEREG_ON: + /* Enable logging of the MT's EPS network registration + * status in E-UTRAN */ + ret_code = user_ind_register(USER_IND_REG, AT_CEREG, NULL); + if (ret_code != RETURNok) { + LOG_TRACE(ERROR, "USR-MAIN - Failed to enable logging of registration status"); + _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; + } + break; + + default: + break; + } + + break; + + case AT_COMMAND_GET: + /* + * The read command returns the status of result code presentation, + * and indication of whether the network has currently indicated + * the registration of the MT, and available location information + * elements when the MT is registered in the network. + */ + cereg->n = n; + switch (n) { + case AT_CEREG_BOTH: + /* Get EPS location information */ + ret_code = nas_proc_get_loc_info(cereg->tac, cereg->ci, + &cereg->AcT); + if (ret_code != RETURNok) { + LOG_TRACE(ERROR, "USR-MAIN - Failed to get location information"); + _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; + break; + } + + if (cereg->tac[0] != 0) { + _nas_user_data.mask |= (AT_CEREG_RESP_TAC_MASK | + AT_CEREG_RESP_CI_MASK); + if (cereg->AcT != NET_ACCESS_UNAVAILABLE) { + _nas_user_data.mask |= (AT_CEREG_RESP_ACT_MASK); + } + } + + /** break is intentionaly missing */ + + case AT_CEREG_OFF: + case AT_CEREG_ON: + /* Get network registration status */ + ret_code = nas_proc_get_reg_status(&cereg->stat); + if (ret_code != RETURNok) { + LOG_TRACE(ERROR, "USR-MAIN - Failed to get registration status"); + _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; + } + break; + + default: + break; + } + + break; + + case AT_COMMAND_TST: + break; + + default: + 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; } LOG_FUNC_RETURN (ret_code); @@ -1672,37 +1645,37 @@ static int _nas_user_proc_cereg(const at_command_t* data) /**************************************************************************** ** ** - ** Name: nas_user_proc_cgdcont() ** + ** Name: nas_user_proc_cgdcont() ** ** ** ** Description: Executes the AT CGDCONT command operations: ** - ** The AT CGDCONT command specifies PDP context parameter ** - ** values for a PDP context identified by the local context ** - ** identification parameter (cid). ** + ** The AT CGDCONT command specifies PDP context parameter ** + ** values for a PDP context identified by the local context ** + ** identification parameter (cid). ** ** ** - ** There is a 1 to 1 mapping between EPS bearer context and ** - ** PDP context. Therefore a PDP context used for UMTS/GPRS ** - ** designates a PDN connection and its associated EPS de- ** - ** fault bearer and traffic flows in EPS. ** + ** There is a 1 to 1 mapping between EPS bearer context and ** + ** PDP context. Therefore a PDP context used for UMTS/GPRS ** + ** designates a PDN connection and its associated EPS de- ** + ** fault bearer and traffic flows in EPS. ** ** ** - ** Inputs: data: Pointer to the AT command data structure ** - ** Others: _nas_user_context ** + ** Inputs: data: Pointer to the AT command data structure ** + ** Others: _nas_user_context ** ** ** - ** Outputs: None ** - ** Return: RETURNok; RETURNerror; ** - ** Others: _nas_user_data ** + ** Outputs: None ** + ** Return: RETURNok; RETURNerror; ** + ** 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,202 +1687,192 @@ 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) - { - case AT_COMMAND_SET: - if (_nas_user_context.sim_status != NAS_USER_READY) { - _nas_user_data.cause_code = AT_ERROR_SIM_PIN_REQUIRED; - LOG_FUNC_RETURN(RETURNerror); - } - /* - * Set command specifies PDN connection and its default - * EPS bearer context parameter values - */ - 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 */ - LOG_TRACE(ERROR, "USR-MAIN - <cid> parameter is not valid" - " (%d)", data->command.cgdcont.cid); - _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; - ret_code = RETURNerror; - break; - } - cid = data->command.cgdcont.cid; - } - 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) { - pdn_type = NET_PDN_TYPE_IPV6; - } - else if (strcmp(data->command.cgdcont.PDP_type,"IPV4V6") == 0) { - pdn_type = NET_PDN_TYPE_IPV4V6; - } - else { - /* The value of the PDP type is not valid; - * return an error message */ - LOG_TRACE(ERROR, "USR-MAIN - <PDN_type> parameter is not " - "valid (%s)", data->command.cgdcont.PDP_type); - _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; - ret_code = RETURNerror; - break; - } - reset_pdn = FALSE; - } - if (data->mask & AT_CGDCONT_APN_MASK) - { - apn = data->command.cgdcont.APN; - } - 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 - * not valid; return an error message */ - LOG_TRACE(ERROR, "USR-MAIN - <d_comp> parameter is not " - "valid (%d)", data->command.cgdcont.d_comp); - _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; - ret_code = RETURNerror; - break; - } - /* Not supported: Applicable for SNDCP only */ - } - 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 - * not valid; return an error message */ - LOG_TRACE(ERROR, "USR-MAIN - <h_comp> parameter is not " - "valid (%d)", data->command.cgdcont.h_comp); - _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; - ret_code = RETURNerror; - break; - } - /* 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) ) { - /* The value of the IPv4 address allocation parameter is - * not valid; return an error message */ - LOG_TRACE(ERROR, "USR-MAIN - <IPv4AddrAlloc> parameter " - "is not valid (%d)", - data->command.cgdcont.IPv4AddrAlloc); - _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; - ret_code = RETURNerror; - break; - } - 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) ) { - /* The value of the emergency indication parameter is - * not valid; return an error message */ - LOG_TRACE(ERROR, "USR-MAIN - <emergency indication> " - "parameter is not valid (%d)", - data->command.cgdcont.emergency_indication); - _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; - ret_code = RETURNerror; - break; - } - 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) ) { - /* The value of the P-CSCF address discovery parameter is - * not valid; return an error message */ - LOG_TRACE(ERROR, "USR-MAIN - <P-CSCF_discovery> " - "parameter is not valid (%d)", - data->command.cgdcont.P_CSCF_discovery); - _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; - ret_code = RETURNerror; - break; - } - 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) ) { - /* The value of the IM CN subsystem-related signalling - * support indication is not valid; - * return an error message */ - LOG_TRACE(ERROR, "USR-MAIN - <IM_CN_Signalling_Flag_Ind> " - "parameter is not valid (%d)", - data->command.cgdcont.IM_CN_Signalling_Flag_Ind); - _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; - ret_code = RETURNerror; - break; - } - im_cn_signalling = data->command.cgdcont.IM_CN_Signalling_Flag_Ind; - } - /* - * Setup PDN context - */ - if (reset_pdn) { - /* 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 { - /* Define a new PDN connection */ - ret_code = nas_proc_set_pdn(cid, pdn_type, apn, - ipv4_addr_allocation, emergency, - p_cscf, im_cn_signalling); - } - if (ret_code != RETURNok) { - LOG_TRACE(ERROR, "USR-MAIN - Failed to setup PDN connection " - "(<cid>=%d)", data->command.cgdcont.cid); - _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; - } - - break; - - case AT_COMMAND_GET: - /* - * Read command returns the current settings for each - * defined PDN connection/default EPS bearer context - */ - cgdcont->n_pdns = nas_proc_get_pdn_param(cgdcont->cid, - cgdcont->PDP_type, - cgdcont->APN, - AT_CGDCONT_RESP_SIZE); - if (cgdcont->n_pdns == 0) { - LOG_TRACE(ERROR, "USR-MAIN - No any PDN context is defined"); - _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; - } - break; - - case AT_COMMAND_TST: - /* - * Test command returns values supported as a compound value - */ - { - /* Get the maximum value of a PDN context identifier */ - int cid_max = nas_proc_get_pdn_range(); - if (cid_max > AT_CGDCONT_RESP_SIZE) { - /* The range is defined by the user interface */ - _nas_user_data.response.cgdcont.tst.n_cid = - AT_CGDCONT_RESP_SIZE; - } - else { - /* The range is defined by the ESM sublayer application */ - _nas_user_data.response.cgdcont.tst.n_cid = cid_max; - } - } - break; - - default: - 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; + 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; + LOG_FUNC_RETURN(RETURNerror); + } + /* + * Set command specifies PDN connection and its default + * EPS bearer context parameter values + */ + 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 */ + LOG_TRACE(ERROR, "USR-MAIN - <cid> parameter is not valid" + " (%d)", data->command.cgdcont.cid); + _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; + ret_code = RETURNerror; + break; + } + cid = data->command.cgdcont.cid; + } + 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) { + pdn_type = NET_PDN_TYPE_IPV6; + } else if (strcmp(data->command.cgdcont.PDP_type,"IPV4V6") == 0) { + pdn_type = NET_PDN_TYPE_IPV4V6; + } else { + /* The value of the PDP type is not valid; + * return an error message */ + LOG_TRACE(ERROR, "USR-MAIN - <PDN_type> parameter is not " + "valid (%s)", data->command.cgdcont.PDP_type); + _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; + ret_code = RETURNerror; + break; + } + reset_pdn = FALSE; + } + if (data->mask & AT_CGDCONT_APN_MASK) { + apn = data->command.cgdcont.APN; + } + 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 + * not valid; return an error message */ + LOG_TRACE(ERROR, "USR-MAIN - <d_comp> parameter is not " + "valid (%d)", data->command.cgdcont.d_comp); + _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; + ret_code = RETURNerror; + break; + } + /* Not supported: Applicable for SNDCP only */ + } + 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 + * not valid; return an error message */ + LOG_TRACE(ERROR, "USR-MAIN - <h_comp> parameter is not " + "valid (%d)", data->command.cgdcont.h_comp); + _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; + ret_code = RETURNerror; + break; + } + /* 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) ) { + /* The value of the IPv4 address allocation parameter is + * not valid; return an error message */ + LOG_TRACE(ERROR, "USR-MAIN - <IPv4AddrAlloc> parameter " + "is not valid (%d)", + data->command.cgdcont.IPv4AddrAlloc); + _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; + ret_code = RETURNerror; + break; + } + 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) ) { + /* The value of the emergency indication parameter is + * not valid; return an error message */ + LOG_TRACE(ERROR, "USR-MAIN - <emergency indication> " + "parameter is not valid (%d)", + data->command.cgdcont.emergency_indication); + _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; + ret_code = RETURNerror; + break; + } + 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) ) { + /* The value of the P-CSCF address discovery parameter is + * not valid; return an error message */ + LOG_TRACE(ERROR, "USR-MAIN - <P-CSCF_discovery> " + "parameter is not valid (%d)", + data->command.cgdcont.P_CSCF_discovery); + _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; + ret_code = RETURNerror; + break; + } + 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) ) { + /* The value of the IM CN subsystem-related signalling + * support indication is not valid; + * return an error message */ + LOG_TRACE(ERROR, "USR-MAIN - <IM_CN_Signalling_Flag_Ind> " + "parameter is not valid (%d)", + data->command.cgdcont.IM_CN_Signalling_Flag_Ind); + _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; + ret_code = RETURNerror; + break; + } + im_cn_signalling = data->command.cgdcont.IM_CN_Signalling_Flag_Ind; + } + /* + * Setup PDN context + */ + if (reset_pdn) { + /* 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 { + /* Define a new PDN connection */ + ret_code = nas_proc_set_pdn(cid, pdn_type, apn, + ipv4_addr_allocation, emergency, + p_cscf, im_cn_signalling); + } + if (ret_code != RETURNok) { + LOG_TRACE(ERROR, "USR-MAIN - Failed to setup PDN connection " + "(<cid>=%d)", data->command.cgdcont.cid); + _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; + } + + break; + + case AT_COMMAND_GET: + /* + * Read command returns the current settings for each + * defined PDN connection/default EPS bearer context + */ + cgdcont->n_pdns = nas_proc_get_pdn_param(cgdcont->cid, + cgdcont->PDP_type, + cgdcont->APN, + AT_CGDCONT_RESP_SIZE); + if (cgdcont->n_pdns == 0) { + LOG_TRACE(ERROR, "USR-MAIN - No any PDN context is defined"); + _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; + } + break; + + case AT_COMMAND_TST: + /* + * Test command returns values supported as a compound value + */ + { + /* Get the maximum value of a PDN context identifier */ + int cid_max = nas_proc_get_pdn_range(); + if (cid_max > AT_CGDCONT_RESP_SIZE) { + /* The range is defined by the user interface */ + _nas_user_data.response.cgdcont.tst.n_cid = + AT_CGDCONT_RESP_SIZE; + } else { + /* The range is defined by the ESM sublayer application */ + _nas_user_data.response.cgdcont.tst.n_cid = cid_max; + } + } + break; + + default: + 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; } LOG_FUNC_RETURN (ret_code); @@ -1917,27 +1880,27 @@ static int _nas_user_proc_cgdcont(const at_command_t* data) /**************************************************************************** ** ** - ** Name: nas_user_proc_cgact() ** + ** Name: nas_user_proc_cgact() ** ** ** ** Description: Executes the AT CGACT command operations: ** - ** The AT CGACT command is used to activate or deactivate ** - ** the specified PDP context(s) or PDN/EPS bearer context(s) ** - ** for E-UTRAN ** + ** The AT CGACT command is used to activate or deactivate ** + ** the specified PDP context(s) or PDN/EPS bearer context(s) ** + ** for E-UTRAN ** ** ** - ** Inputs: data: Pointer to the AT command data structure ** - ** Others: _nas_user_context ** + ** Inputs: data: Pointer to the AT command data structure ** + ** Others: _nas_user_context ** ** ** - ** Outputs: None ** - ** Return: RETURNok; RETURNerror; ** - ** Others: _nas_user_data ** + ** Outputs: None ** + ** Return: RETURNok; RETURNerror; ** + ** 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,89 +1911,86 @@ 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) - { - case AT_COMMAND_SET: - if (_nas_user_context.sim_status != NAS_USER_READY) { - _nas_user_data.cause_code = AT_ERROR_SIM_PIN_REQUIRED; - LOG_FUNC_RETURN(RETURNerror); - } - /* - * 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->command.cgact.state < AT_CGACT_STATE_MIN) || - (data->command.cgact.state > AT_CGACT_STATE_MAX) ) { - /* The value of the PDP context activation status is - * not valid; return an error message */ - LOG_TRACE(ERROR, "USR-MAIN - <state> parameter is " - "not valid (%d)", data->command.cgact.state); - _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; - ret_code = RETURNerror; - break; - } - state = data->command.cgact.state; - } - 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 */ - LOG_TRACE(ERROR, "USR-MAIN - <cid> parameter is " - "not valid (%d)", data->command.cgact.cid); - _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; - ret_code = RETURNerror; - break; - } - cid = data->command.cgact.cid; - } - /* - * Activate/Deactivate PDN context - */ - ret_code = RETURNerror; - if (state == AT_CGACT_DEACTIVATED) { - ret_code = nas_proc_deactivate_pdn(cid); - } - else if (state == AT_CGACT_ACTIVATED) { - ret_code = nas_proc_activate_pdn(cid); - } - if (ret_code != RETURNok) { - LOG_TRACE(ERROR, "USR-MAIN - Failed to %s PDN context " - "(<state>=%d,<cid>=%d)", - (state != AT_CGACT_ACTIVATED)? "deactivate" : - "activate", state, cid); - _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; - } - - break; - - case AT_COMMAND_GET: - /* - * The read command returns the current activation states for - * all the defined PDN/EPS bearer contexts - */ - cgact->n_pdns = nas_proc_get_pdn_status(cgact->cid, cgact->state, - AT_CGACT_RESP_SIZE); - if (cgact->n_pdns == 0) { - LOG_TRACE(ERROR, "USR-MAIN - No any PDN context is defined"); - _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; - } - break; - - case AT_COMMAND_TST: - /* - * The test command is used for requesting information on the - * supported PDN/EPS bearer context activation states. - */ - break; - - default: - 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; + 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; + LOG_FUNC_RETURN(RETURNerror); + } + /* + * 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->command.cgact.state < AT_CGACT_STATE_MIN) || + (data->command.cgact.state > AT_CGACT_STATE_MAX) ) { + /* The value of the PDP context activation status is + * not valid; return an error message */ + LOG_TRACE(ERROR, "USR-MAIN - <state> parameter is " + "not valid (%d)", data->command.cgact.state); + _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; + ret_code = RETURNerror; + break; + } + state = data->command.cgact.state; + } + 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 */ + LOG_TRACE(ERROR, "USR-MAIN - <cid> parameter is " + "not valid (%d)", data->command.cgact.cid); + _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; + ret_code = RETURNerror; + break; + } + cid = data->command.cgact.cid; + } + /* + * Activate/Deactivate PDN context + */ + ret_code = RETURNerror; + if (state == AT_CGACT_DEACTIVATED) { + ret_code = nas_proc_deactivate_pdn(cid); + } else if (state == AT_CGACT_ACTIVATED) { + ret_code = nas_proc_activate_pdn(cid); + } + if (ret_code != RETURNok) { + LOG_TRACE(ERROR, "USR-MAIN - Failed to %s PDN context " + "(<state>=%d,<cid>=%d)", + (state != AT_CGACT_ACTIVATED)? "deactivate" : + "activate", state, cid); + _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; + } + + break; + + case AT_COMMAND_GET: + /* + * The read command returns the current activation states for + * all the defined PDN/EPS bearer contexts + */ + cgact->n_pdns = nas_proc_get_pdn_status(cgact->cid, cgact->state, + AT_CGACT_RESP_SIZE); + if (cgact->n_pdns == 0) { + LOG_TRACE(ERROR, "USR-MAIN - No any PDN context is defined"); + _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; + } + break; + + case AT_COMMAND_TST: + /* + * The test command is used for requesting information on the + * supported PDN/EPS bearer context activation states. + */ + break; + + default: + 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; } LOG_FUNC_RETURN (ret_code); @@ -2038,27 +1998,27 @@ static int _nas_user_proc_cgact(const at_command_t* data) /**************************************************************************** ** ** - ** Name: nas_user_proc_cmee() ** + ** Name: nas_user_proc_cmee() ** ** ** ** Description: Executes the AT CMEE command operations: ** - ** The AT CMEE command disables or enables the use of final ** - ** result code +CME ERROR: <err> as an indication of an er- ** - ** ror relating to the functionality of the MT. ** + ** The AT CMEE command disables or enables the use of final ** + ** result code +CME ERROR: <err> as an indication of an er- ** + ** ror relating to the functionality of the MT. ** ** ** - ** Inputs: data: Pointer to the AT command data structure ** - ** Others: None ** + ** Inputs: data: Pointer to the AT command data structure ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok; RETURNerror; ** - ** Others: _nas_user_data ** + ** Outputs: None ** + ** Return: RETURNok; RETURNerror; ** + ** 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,81 +2028,79 @@ 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) - { - case AT_COMMAND_ACT: /* ATV0, ATV1 response format commands */ - case AT_COMMAND_SET: - /* - * The set command controls the presentation of final result code - * +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->command.cmee.n < AT_CMEE_N_MIN) || - (data->command.cmee.n > AT_CMEE_N_MAX) ) { - /* The value of the numeric parameter is not valid; - * return an error message */ - LOG_TRACE(ERROR, "USR-MAIN - <n> parameter is not valid" - " (%d)", data->command.cmee.n); - _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; - ret_code = RETURNerror; - break; - } - /* Set to the selected parameter value */ - n = data->command.cmee.n; - } - - /* Disable/Enable final result code logging */ - switch (n) - { - case AT_CMEE_OFF: - /* Disable logging of final result code */ - at_error_set_format(AT_ERROR_OFF); - break; - - case AT_CMEE_NUMERIC: - /* Enable logging of numeric final result code */ - at_error_set_format(AT_ERROR_NUMERIC); - break; - - case AT_CMEE_VERBOSE: - /* Enable logging of verbose final result code */ - at_error_set_format(AT_ERROR_VERBOSE); - break; - - default: - break; - } - - break; - - case AT_COMMAND_GET: - /* - * Read command returns the status of the final result code - * presentation. - */ - n = at_error_get_format(); - cmee->n = ( (n == AT_ERROR_OFF)? AT_CMEE_OFF : - (n == AT_ERROR_NUMERIC)? AT_CMEE_NUMERIC : - (n == AT_ERROR_VERBOSE)? AT_CMEE_VERBOSE : RETURNerror); - if (cmee->n == RETURNerror) { - LOG_TRACE(ERROR, "USR-MAIN - Failed to get format of the final result code"); - _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; - } - break; - - case AT_COMMAND_TST: - /* - * Test command returns values supported as a compound value - */ - break; - - default: - 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; + switch (data->type) { + case AT_COMMAND_ACT: /* ATV0, ATV1 response format commands */ + case AT_COMMAND_SET: + /* + * The set command controls the presentation of final result code + * +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->command.cmee.n < AT_CMEE_N_MIN) || + (data->command.cmee.n > AT_CMEE_N_MAX) ) { + /* The value of the numeric parameter is not valid; + * return an error message */ + LOG_TRACE(ERROR, "USR-MAIN - <n> parameter is not valid" + " (%d)", data->command.cmee.n); + _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; + ret_code = RETURNerror; + break; + } + /* Set to the selected parameter value */ + n = data->command.cmee.n; + } + + /* Disable/Enable final result code logging */ + switch (n) { + case AT_CMEE_OFF: + /* Disable logging of final result code */ + at_error_set_format(AT_ERROR_OFF); + break; + + case AT_CMEE_NUMERIC: + /* Enable logging of numeric final result code */ + at_error_set_format(AT_ERROR_NUMERIC); + break; + + case AT_CMEE_VERBOSE: + /* Enable logging of verbose final result code */ + at_error_set_format(AT_ERROR_VERBOSE); + break; + + default: + break; + } + + break; + + case AT_COMMAND_GET: + /* + * Read command returns the status of the final result code + * presentation. + */ + n = at_error_get_format(); + cmee->n = ( (n == AT_ERROR_OFF)? AT_CMEE_OFF : + (n == AT_ERROR_NUMERIC)? AT_CMEE_NUMERIC : + (n == AT_ERROR_VERBOSE)? AT_CMEE_VERBOSE : RETURNerror); + if (cmee->n == RETURNerror) { + LOG_TRACE(ERROR, "USR-MAIN - Failed to get format of the final result code"); + _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; + } + break; + + case AT_COMMAND_TST: + /* + * Test command returns values supported as a compound value + */ + break; + + default: + 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; } LOG_FUNC_RETURN (ret_code); @@ -2150,26 +2108,26 @@ static int _nas_user_proc_cmee(const at_command_t* data) /**************************************************************************** ** ** - ** Name: nas_user_proc_clck() ** + ** Name: nas_user_proc_clck() ** ** ** ** Description: Executes the AT CLCK command operations: ** - ** The AT CLCK command locks, unlocks or interrogates a MT ** - ** or a network facility. ** + ** The AT CLCK command locks, unlocks or interrogates a MT ** + ** or a network facility. ** ** ** - ** Inputs: data: Pointer to the AT command data structure ** - ** Others: None ** + ** Inputs: data: Pointer to the AT command data structure ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: RETURNok; RETURNerror; ** - ** Others: _nas_user_data ** + ** Outputs: None ** + ** Return: RETURNok; RETURNerror; ** + ** 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,99 +2135,96 @@ 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) - { - case AT_COMMAND_SET: - /* - * Execution command locks, unlocks or returns status of a network - * facility - */ - - /* Check facility parameter */ - if (strncmp(data->command.clck.fac, AT_CLCK_SC, - 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); - _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; - ret_code = RETURNerror; - break; - } - /* Check password parameter */ - 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) { - /* The PIN code is NOT matching; return an error message */ - LOG_TRACE(ERROR, "USR-MAIN - Password is not correct " - "(%s)", data->command.clck.passwd); - _nas_user_data.cause_code = AT_ERROR_INCORRECT_PASSWD; - ret_code = RETURNerror; - break; - } - } - /* Execute the command with specified mode of operation */ - switch (data->command.clck.mode) - { - case AT_CLCK_UNLOCK: - /* unlock facility */ - if ( !(data->mask & AT_CLCK_PASSWD_MASK) ) { - /* unlock requires password */ - LOG_TRACE(ERROR, "USR-MAIN - unlock mode of operation " - "requires a password"); - _nas_user_data.cause_code = AT_ERROR_SIM_PIN_REQUIRED; - ret_code = RETURNerror; - break; - } - LOG_TRACE(ERROR, "USR-MAIN - unlock mode of operation " - "is not supported"); - _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; - ret_code = RETURNerror; - break; - - case AT_CLCK_LOCK: - /* lock facility */ - if ( !(data->mask & AT_CLCK_PASSWD_MASK) ) { - /* unlock requires password */ - LOG_TRACE(ERROR, "USR-MAIN - lock mode of operation " - "requires a password"); - _nas_user_data.cause_code = AT_ERROR_SIM_PIN_REQUIRED; - ret_code = RETURNerror; - break; - } - LOG_TRACE(ERROR, "USR-MAIN - lock mode of operation " - "is not supported"); - _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; - ret_code = RETURNerror; - break; - - case AT_CLCK_STATUS: - /* Read facility status */ - clck->status = AT_CLCK_RESP_STATUS_NOT_ACTIVE; - break; - - default: - LOG_TRACE(ERROR, "USR-MAIN - <mode> parameter is not valid" - " (%d)", data->command.clck.mode); - _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; - ret_code = RETURNerror; - break; - } - break; - - case AT_COMMAND_TST: - /* - * Test command returns values supported as a compound value - */ - break; - - default: - 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; + switch (data->type) { + case AT_COMMAND_SET: + /* + * Execution command locks, unlocks or returns status of a network + * facility + */ + + /* Check facility parameter */ + if (strncmp(data->command.clck.fac, AT_CLCK_SC, + 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); + _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; + ret_code = RETURNerror; + break; + } + /* Check password parameter */ + 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) { + /* The PIN code is NOT matching; return an error message */ + LOG_TRACE(ERROR, "USR-MAIN - Password is not correct " + "(%s)", data->command.clck.passwd); + _nas_user_data.cause_code = AT_ERROR_INCORRECT_PASSWD; + ret_code = RETURNerror; + break; + } + } + /* Execute the command with specified mode of operation */ + switch (data->command.clck.mode) { + case AT_CLCK_UNLOCK: + /* unlock facility */ + if ( !(data->mask & AT_CLCK_PASSWD_MASK) ) { + /* unlock requires password */ + LOG_TRACE(ERROR, "USR-MAIN - unlock mode of operation " + "requires a password"); + _nas_user_data.cause_code = AT_ERROR_SIM_PIN_REQUIRED; + ret_code = RETURNerror; + break; + } + LOG_TRACE(ERROR, "USR-MAIN - unlock mode of operation " + "is not supported"); + _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; + ret_code = RETURNerror; + break; + + case AT_CLCK_LOCK: + /* lock facility */ + if ( !(data->mask & AT_CLCK_PASSWD_MASK) ) { + /* unlock requires password */ + LOG_TRACE(ERROR, "USR-MAIN - lock mode of operation " + "requires a password"); + _nas_user_data.cause_code = AT_ERROR_SIM_PIN_REQUIRED; + ret_code = RETURNerror; + break; + } + LOG_TRACE(ERROR, "USR-MAIN - lock mode of operation " + "is not supported"); + _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; + ret_code = RETURNerror; + break; + + case AT_CLCK_STATUS: + /* Read facility status */ + clck->status = AT_CLCK_RESP_STATUS_NOT_ACTIVE; + break; + + default: + LOG_TRACE(ERROR, "USR-MAIN - <mode> parameter is not valid" + " (%d)", data->command.clck.mode); + _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; + ret_code = RETURNerror; + break; + } + break; + + case AT_COMMAND_TST: + /* + * Test command returns values supported as a compound value + */ + break; + + default: + 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; } LOG_FUNC_RETURN (ret_code); @@ -2277,26 +2232,26 @@ static int _nas_user_proc_clck(const at_command_t* data) /**************************************************************************** ** ** - ** Name: nas_user_proc_cgpaddr() ** + ** Name: nas_user_proc_cgpaddr() ** ** ** ** Description: Executes the AT CGPADDR command operations: ** - ** The AT CGPADDR command returns a list of PDP addresses ** - ** for the specified context identifiers ** + ** The AT CGPADDR command returns a list of PDP addresses ** + ** for the specified context identifiers ** ** ** - ** Inputs: data: Pointer to the AT command data structure ** - ** Others: _nas_user_context ** + ** Inputs: data: Pointer to the AT command data structure ** + ** Others: _nas_user_context ** ** ** - ** Outputs: None ** - ** Return: RETURNok; RETURNerror; ** - ** Others: _nas_user_data ** + ** Outputs: None ** + ** Return: RETURNok; RETURNerror; ** + ** 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,59 +2261,57 @@ 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) - { - case AT_COMMAND_SET: - if (_nas_user_context.sim_status != NAS_USER_READY) { - _nas_user_data.cause_code = AT_ERROR_SIM_PIN_REQUIRED; - LOG_FUNC_RETURN(RETURNerror); - } - /* - * The execution command returns a list of PDP addresses for - * the specified context identifiers - */ - 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 */ - LOG_TRACE(ERROR, "USR-MAIN - <cid> parameter is " - "not valid (%d)", data->command.cgpaddr.cid); - _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; - ret_code = RETURNerror; - break; - } - cid = data->command.cgpaddr.cid; - } - /* - * Get the PDP addresses - */ - cgpaddr->n_pdns = nas_proc_get_pdn_addr(cid, cgpaddr->cid, - cgpaddr->PDP_addr_1, - cgpaddr->PDP_addr_2, - AT_CGPADDR_RESP_SIZE); - if (cgpaddr->n_pdns == 0) { - LOG_TRACE(ERROR, "USR-MAIN - No any PDN context is defined"); - _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; - } - break; - - case AT_COMMAND_TST: - /* - * The test command returns a list of defined <cid>s. - */ - cgpaddr->n_pdns = nas_proc_get_pdn_addr(cid, cgpaddr->cid, - cgpaddr->PDP_addr_1, - cgpaddr->PDP_addr_2, - AT_CGPADDR_RESP_SIZE); - break; - - default: - LOG_TRACE(ERROR, "USR-MAIN - AT+CGPADDR command type %d is " - "not supported", data->type); - _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; - ret_code = RETURNerror; - break; + 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; + LOG_FUNC_RETURN(RETURNerror); + } + /* + * The execution command returns a list of PDP addresses for + * the specified context identifiers + */ + 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 */ + LOG_TRACE(ERROR, "USR-MAIN - <cid> parameter is " + "not valid (%d)", data->command.cgpaddr.cid); + _nas_user_data.cause_code = AT_ERROR_INCORRECT_PARAMETERS; + ret_code = RETURNerror; + break; + } + cid = data->command.cgpaddr.cid; + } + /* + * Get the PDP addresses + */ + cgpaddr->n_pdns = nas_proc_get_pdn_addr(cid, cgpaddr->cid, + cgpaddr->PDP_addr_1, + cgpaddr->PDP_addr_2, + AT_CGPADDR_RESP_SIZE); + if (cgpaddr->n_pdns == 0) { + LOG_TRACE(ERROR, "USR-MAIN - No any PDN context is defined"); + _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; + } + break; + + case AT_COMMAND_TST: + /* + * The test command returns a list of defined <cid>s. + */ + cgpaddr->n_pdns = nas_proc_get_pdn_addr(cid, cgpaddr->cid, + cgpaddr->PDP_addr_1, + cgpaddr->PDP_addr_2, + AT_CGPADDR_RESP_SIZE); + break; + + default: + LOG_TRACE(ERROR, "USR-MAIN - AT+CGPADDR command type %d is " + "not supported", data->type); + _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; + ret_code = RETURNerror; + break; } LOG_FUNC_RETURN (ret_code); @@ -2366,26 +2319,26 @@ static int _nas_user_proc_cgpaddr(const at_command_t* data) /**************************************************************************** ** ** - ** Name: nas_user_proc_cnum() ** + ** Name: nas_user_proc_cnum() ** ** ** ** Description: Executes the AT CNUM command operations: ** - ** The AT CNUM command returns the MSISDNs related to the ** - ** subscriber. ** + ** The AT CNUM command returns the MSISDNs related to the ** + ** subscriber. ** ** ** - ** Inputs: data: Pointer to the AT command data structure ** - ** Others: _nas_user_context ** + ** Inputs: data: Pointer to the AT command data structure ** + ** Others: _nas_user_context ** ** ** - ** Outputs: None ** - ** Return: RETURNok; RETURNerror; ** - ** Others: _nas_user_data ** + ** Outputs: None ** + ** Return: RETURNok; RETURNerror; ** + ** 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,31 +2346,30 @@ 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) - { - case AT_COMMAND_ACT: - if (_nas_user_context.sim_status != NAS_USER_READY) { - _nas_user_data.cause_code = AT_ERROR_SIM_PIN_REQUIRED; - LOG_FUNC_RETURN(RETURNerror); - } - /* Get the International Mobile Subscriber Identity (IMSI) */ - ret_code = nas_proc_get_msisdn(cnum->number, &cnum->type); - if (ret_code != RETURNok) { - LOG_TRACE(ERROR, "USR-MAIN - Failed to get MS dialing number"); - _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; - } - break; - - case AT_COMMAND_TST: - /* Nothing to do */ - break; - - default: - LOG_TRACE(ERROR, "USR-MAIN - AT+CNUM command type %d is " - "not supported", data->type); - _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; - ret_code = RETURNerror; - break; + 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; + LOG_FUNC_RETURN(RETURNerror); + } + /* Get the International Mobile Subscriber Identity (IMSI) */ + ret_code = nas_proc_get_msisdn(cnum->number, &cnum->type); + if (ret_code != RETURNok) { + LOG_TRACE(ERROR, "USR-MAIN - Failed to get MS dialing number"); + _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; + } + break; + + case AT_COMMAND_TST: + /* Nothing to do */ + break; + + default: + LOG_TRACE(ERROR, "USR-MAIN - AT+CNUM command type %d is " + "not supported", data->type); + _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; + ret_code = RETURNerror; + break; } LOG_FUNC_RETURN (ret_code); @@ -2425,26 +2377,26 @@ static int _nas_user_proc_cnum(const at_command_t* data) /**************************************************************************** ** ** - ** Name: nas_user_proc_clac() ** + ** Name: nas_user_proc_clac() ** ** ** ** Description: Executes the AT CLAC command operations: ** - ** The AT CLAC command returns the list of AT Commands that ** - ** are available for the user. ** + ** The AT CLAC command returns the list of AT Commands that ** + ** are available for the user. ** ** ** - ** Inputs: data: Pointer to the AT command data structure ** - ** Others: _nas_user_context ** + ** Inputs: data: Pointer to the AT command data structure ** + ** Others: _nas_user_context ** ** ** - ** Outputs: None ** - ** Return: RETURNok; RETURNerror; ** - ** Others: _nas_user_data ** + ** Outputs: None ** + ** Return: RETURNok; RETURNerror; ** + ** 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,28 +2404,27 @@ 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) - { - case AT_COMMAND_ACT: - /* Get the list of supported AT commands */ - clac->n_acs = at_command_get_list(clac->ac, AT_CLAC_RESP_SIZE); - if (clac->n_acs == 0) { - LOG_TRACE(ERROR, "USR-MAIN - Failed to get the list of " - "supported AT commands"); - _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; - } - break; - - case AT_COMMAND_TST: - /* Nothing to do */ - break; - - default: - LOG_TRACE(ERROR, "USR-MAIN - AT+CLAC command type %d is " - "not supported", data->type); - _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; - ret_code = RETURNerror; - break; + 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); + if (clac->n_acs == 0) { + LOG_TRACE(ERROR, "USR-MAIN - Failed to get the list of " + "supported AT commands"); + _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; + } + break; + + case AT_COMMAND_TST: + /* Nothing to do */ + break; + + default: + LOG_TRACE(ERROR, "USR-MAIN - AT+CLAC command type %d is " + "not supported", data->type); + _nas_user_data.cause_code = AT_ERROR_OPERATION_NOT_SUPPORTED; + ret_code = RETURNerror; + break; } LOG_FUNC_RETURN (ret_code); diff --git a/openair-cn/NAS/EURECOM-NAS/src/nas_user.h b/openair-cn/NAS/EURECOM-NAS/src/nas_user.h index 75a8fbc78c..1249eeee91 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/nas_user.h +++ b/openair-cn/NAS/EURECOM-NAS/src/nas_user.h @@ -1,18 +1,18 @@ /***************************************************************************** -Source nas_user.h +Source nas_user.h -Version 0.1 +Version 0.1 -Date 2012/03/09 +Date 2012/03/09 -Product NAS stack +Product NAS stack -Subsystem NAS main process +Subsystem NAS main process -Author Frederic Maurel +Author Frederic Maurel -Description NAS procedure functions triggered by the user +Description NAS procedure functions triggered by the user *****************************************************************************/ #ifndef __NAS_USER_H__ @@ -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__*/ diff --git a/openair-cn/NAS/Makefile.am b/openair-cn/NAS/Makefile.am index 5a55086bba..57a1fb1f67 100644 --- a/openair-cn/NAS/Makefile.am +++ b/openair-cn/NAS/Makefile.am @@ -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 diff --git a/openair-cn/NAS/nas_itti_messaging.c b/openair-cn/NAS/nas_itti_messaging.c new file mode 100644 index 0000000000..745cff15aa --- /dev/null +++ b/openair-cn/NAS/nas_itti_messaging.c @@ -0,0 +1,46 @@ +/******************************************************************************* + + 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); +} diff --git a/openair-cn/NAS/nas_itti_messaging.h b/openair-cn/NAS/nas_itti_messaging.h new file mode 100644 index 0000000000..7b3e8aba37 --- /dev/null +++ b/openair-cn/NAS/nas_itti_messaging.h @@ -0,0 +1,37 @@ +/******************************************************************************* + + 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_ */ diff --git a/openair-cn/NAS/nas_main.c b/openair-cn/NAS/nas_main.c index 1f03ad5f1f..ac2a0aa2b8 100644 --- a/openair-cn/NAS/nas_main.c +++ b/openair-cn/NAS/nas_main.c @@ -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), diff --git a/openair-cn/S1AP/s1ap_mme.c b/openair-cn/S1AP/s1ap_mme.c index 49104b89f3..52ffd22b7c 100644 --- a/openair-cn/S1AP/s1ap_mme.c +++ b/openair-cn/S1AP/s1ap_mme.c @@ -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)); diff --git a/openair-cn/S1AP/s1ap_mme_itti_messaging.c b/openair-cn/S1AP/s1ap_mme_itti_messaging.c index 993fd45b7a..e30d4afb99 100644 --- a/openair-cn/S1AP/s1ap_mme_itti_messaging.c +++ b/openair-cn/S1AP/s1ap_mme_itti_messaging.c @@ -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); } diff --git a/openair-cn/S1AP/s1ap_mme_itti_messaging.h b/openair-cn/S1AP/s1ap_mme_itti_messaging.h index e92a7fc405..b099c3c764 100644 --- a/openair-cn/S1AP/s1ap_mme_itti_messaging.h +++ b/openair-cn/S1AP/s1ap_mme_itti_messaging.h @@ -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_ */ diff --git a/openair-cn/S1AP/s1ap_mme_nas_procedures.c b/openair-cn/S1AP/s1ap_mme_nas_procedures.c index a828a17cc9..3bb5ddc47b 100644 --- a/openair-cn/S1AP/s1ap_mme_nas_procedures.c +++ b/openair-cn/S1AP/s1ap_mme_nas_procedures.c @@ -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, - ue_ref->eNB->sctp_assoc_id, - ue_ref->sctp_stream_send); + 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; } diff --git a/openair-cn/S1AP/s1ap_mme_nas_procedures.h b/openair-cn/S1AP/s1ap_mme_nas_procedures.h index 5c4d217e10..78f481565a 100644 --- a/openair-cn/S1AP/s1ap_mme_nas_procedures.h +++ b/openair-cn/S1AP/s1ap_mme_nas_procedures.h @@ -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_ */ diff --git a/openair-cn/SCTP/sctp_itti_messaging.c b/openair-cn/SCTP/sctp_itti_messaging.c index 1694e5704e..ee2541a2e9 100644 --- a/openair-cn/SCTP/sctp_itti_messaging.c +++ b/openair-cn/SCTP/sctp_itti_messaging.c @@ -25,22 +25,19 @@ int sctp_itti_send_new_message_ind(int n, uint8_t *buffer, uint32_t assoc_id, uint16_t stream, 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); + MessageDef *message_p; - sctp_new_msg_ind_p = &message_p->ittiMsg.s1ap_sctp_new_msg_ind; + message_p = itti_alloc_new_message(TASK_SCTP, SCTP_DATA_IND); - sctp_new_msg_ind_p->buffer = malloc(sizeof(uint8_t) * n); + SCTP_DATA_IND(message_p).buffer = malloc(sizeof(uint8_t) * n); - memcpy((void *)sctp_new_msg_ind_p->buffer, (void *)buffer, n); + memcpy((void *)SCTP_DATA_IND(message_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); } diff --git a/openair-cn/SCTP/sctp_primitives_server.c b/openair-cn/SCTP/sctp_primitives_server.c index 467319803c..9498a95711 100644 --- a/openair-cn/SCTP/sctp_primitives_server.c +++ b/openair-cn/SCTP/sctp_primitives_server.c @@ -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), -- 2.26.2