Commit 2d6270a7 authored by gauthier's avatar gauthier

Better behaviour for NAS MME (NAS NON DELIVERY INDICATION)

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@7660 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent f777e5c7
......@@ -1082,14 +1082,14 @@ void *gtpv1u_eNB_task(void *args)
if (rc != NW_GTPV1U_OK) {
LOG_E(GTPU, "nwGtpv1uGpduMsgNew failed: 0x%x\n", rc);
MSC_LOG_EVENT(MSC_GTPU_ENB,"Failed send G-PDU ltid %u rtid %u size %u",
MSC_LOG_EVENT(MSC_GTPU_ENB,"0 Failed send G-PDU ltid %u rtid %u size %u",
enb_s1u_teid,sgw_s1u_teid,data_req_p->length);
} else {
rc = nwGtpv1uProcessUlpReq(gtpv1u_data_g.gtpv1u_stack, &stack_req);
if (rc != NW_GTPV1U_OK) {
LOG_E(GTPU, "nwGtpv1uProcessUlpReq failed: 0x%x\n", rc);
MSC_LOG_EVENT(MSC_GTPU_ENB,"Failed send G-PDU ltid %u rtid %u size %u",
MSC_LOG_EVENT(MSC_GTPU_ENB,"0 Failed send G-PDU ltid %u rtid %u size %u",
enb_s1u_teid,sgw_s1u_teid,data_req_p->length);
} else {
MSC_LOG_TX_MESSAGE(
......
......@@ -170,8 +170,8 @@ int
mme_app_handle_authentication_info_answer(
const s6a_auth_info_ans_t * const s6a_auth_info_ans_pP)
{
struct ue_context_s *ue_context;
uint64_t imsi;
struct ue_context_s *ue_context = NULL;
uint64_t imsi = 0;
DevAssert(s6a_auth_info_ans_pP != NULL);
......
......@@ -275,6 +275,29 @@ int mme_insert_ue_context(mme_ue_context_t *mme_ue_context, struct ue_context_s
return 0;
}
//------------------------------------------------------------------------------
void mme_remove_ue_context(mme_ue_context_t *mme_ue_context, struct ue_context_s *ue_context_p)
//------------------------------------------------------------------------------
{
struct ue_context_s *collision_p = NULL;
DevAssert(mme_ue_context != NULL);
DevAssert(ue_context_p != NULL);
/* Updating statistics */
mme_ue_context->nb_ue_managed++;
mme_ue_context->nb_ue_since_last_stat++;
collision_p = RB_REMOVE(ue_context_map, &mme_ue_context->ue_context_tree,
ue_context_p);
#warning "TODO mme_ue_context_free_content"
//TODO mme_ue_context_free_content(ue_context_p);
free(ue_context_p);
return 0;
}
//------------------------------------------------------------------------------
void mme_app_dump_ue_contexts(mme_ue_context_t *mme_ue_context)
//------------------------------------------------------------------------------
......@@ -451,13 +474,12 @@ void mme_app_dump_ue_contexts(mme_ue_context_t *mme_ue_context)
void mme_app_handle_s1ap_ue_context_release_req(const s1ap_ue_context_release_req_t const *s1ap_ue_context_release_req)
//------------------------------------------------------------------------------
{
struct ue_context_s *ue_context_p = NULL;
struct ue_context_s *ue_context_p = NULL;
MessageDef *message_p = NULL;
MME_APP_DEBUG("Received S1AP_UE_CONTEXT_RELEASE_REQ from S1AP\n");
ue_context_p = mme_ue_context_exists_nas_ue_id(&mme_app_desc.mme_ue_contexts, s1ap_ue_context_release_req->mme_ue_s1ap_id);
if (ue_context_p == NULL) {
MSC_LOG_EVENT(
MSC_MMEAPP_MME,
......@@ -467,7 +489,29 @@ void mme_app_handle_s1ap_ue_context_release_req(const s1ap_ue_context_release_re
s1ap_ue_context_release_req->mme_ue_s1ap_id);
return;
}
mme_app_send_s11_release_access_bearers_req(ue_context_p);
if ((ue_context_p->mme_s11_teid == 0) &&
(ue_context_p->sgw_s11_teid == 0)) {
// no session was created, no need for releasing bearers in SGW
message_p = itti_alloc_new_message(TASK_MME_APP, S1AP_UE_CONTEXT_RELEASE_COMMAND);
AssertFatal(message_p != NULL, "itti_alloc_new_message Failed");
memset((void*)&message_p->ittiMsg.s1ap_ue_context_release_command,
0,
sizeof(s1ap_ue_context_release_command_t));
S1AP_UE_CONTEXT_RELEASE_COMMAND(message_p).mme_ue_s1ap_id = ue_context_p->mme_ue_s1ap_id;
MSC_LOG_TX_MESSAGE(
MSC_MMEAPP_MME,
MSC_S1AP_MME,
NULL,0,
"0 S1AP_UE_CONTEXT_RELEASE_COMMAND mme_ue_s1ap_id %06"PRIX32" ",
S1AP_UE_CONTEXT_RELEASE_COMMAND(message_p).mme_ue_s1ap_id);
itti_send_msg_to_task(TASK_S1AP, INSTANCE_DEFAULT, message_p);
} else {
mme_app_send_s11_release_access_bearers_req(ue_context_p);
}
}
......@@ -506,4 +550,6 @@ void mme_app_handle_s1ap_ue_context_release_complete(const s1ap_ue_context_relea
"0 S1AP_DEREGISTER_UE_REQ");
itti_send_msg_to_task(TASK_NAS_MME, INSTANCE_DEFAULT, message_p);
mme_remove_ue_context(&mme_app_desc.mme_ue_contexts, ue_context_p);
}
......@@ -241,6 +241,13 @@ ue_context_t *mme_ue_context_exists_guti(mme_ue_context_t *mme_ue_context,
int mme_insert_ue_context(mme_ue_context_t *mme_ue_context,
struct ue_context_s *ue_context_p);
/** \brief Remove a UE context of the tree of known UEs.
* \param ue_context_p The UE context to remove
**/
void mme_remove_ue_context(mme_ue_context_t *mme_ue_context,
struct ue_context_s *ue_context_p);
/** \brief Allocate memory for a new UE context
* @returns Pointer to the new structure, NULL if allocation failed
**/
......
......@@ -91,8 +91,8 @@ int as_message_decode(const char* buffer, as_message_t* msg, int length)
Byte_t** data = NULL;
/* Get the message type */
msg->msgID = *(UInt16_t*)(buffer);
bytes = sizeof(UInt16_t);
msg->msgID = *(uint16_t*)(buffer);
bytes = sizeof(uint16_t);
switch (msg->msgID) {
case AS_NAS_ESTABLISH_REQ:
......
......@@ -204,13 +204,13 @@ typedef struct {} paging_ind_t;
/* Structure of the SAE Temporary Mobile Subscriber Identity */
typedef struct {
UInt8_t MMEcode; /* MME code that allocated the GUTI */
UInt32_t m_tmsi; /* M-Temporary Mobile Subscriber Identity */
uint8_t MMEcode; /* MME code that allocated the GUTI */
uint32_t m_tmsi; /* M-Temporary Mobile Subscriber Identity */
} as_stmsi_t;
/* Structure of the dedicated NAS information */
typedef struct {
UInt32_t length; /* Length of the NAS information data */
uint32_t length; /* Length of the NAS information data */
Byte_t* data; /* Dedicated NAS information data container */
} as_nas_info_t;
......@@ -220,8 +220,8 @@ typedef struct {
* to transfer initial NAS message to the network while UE is in IDLE mode.
*/
typedef struct {
UInt8_t cause; /* Connection establishment cause */
UInt8_t type; /* Associated call type */
uint8_t cause; /* Connection establishment cause */
uint8_t type; /* Associated call type */
plmn_t plmnID; /* Identifier of the selected PLMN */
as_stmsi_t s_tmsi; /* SAE Temporary Mobile Subscriber Identity */
as_nas_info_t initialNasMsg;/* Initial NAS message to transfer */
......@@ -274,7 +274,7 @@ typedef as_nas_info_t ul_info_transfer_t;
* --------------------------------------------------------------------------
*/
typedef struct {
UInt16_t msgID;
uint16_t msgID;
union {
cell_info_req_t cell_info_req;
cell_info_rsp_t cell_info_rsp;
......
......@@ -97,9 +97,9 @@ static int _nas_message_protected_encode(
static int _nas_message_decrypt(
char* dest,
const char* src,
UInt8_t type,
UInt32_t code,
UInt8_t seq,
uint8_t type,
uint32_t code,
uint8_t seq,
int length,
const emm_security_context_t * const emm_security_context);
......@@ -108,15 +108,15 @@ static int
_nas_message_encrypt(
char *dest,
const char *src,
UInt8_t type,
UInt32_t code,
UInt8_t seq,
uint8_t type,
uint32_t code,
uint8_t seq,
int const direction,
int length,
const emm_security_context_t * const emm_security_context);
/* Functions used for integrity protection of layer 3 NAS messages */
static UInt32_t _nas_message_get_mac(
static uint32_t _nas_message_get_mac(
const char * const buffer,
int const length,
int const direction,
......@@ -180,9 +180,9 @@ nas_message_encrypt(
/* Integrity protected the NAS message */
if (bytes > 0) {
/* Compute offset of the sequence number field */
int offset = size - sizeof(UInt8_t);
int offset = size - sizeof(uint8_t);
/* Compute the NAS message authentication code */
UInt32_t mac = _nas_message_get_mac(
uint32_t mac = _nas_message_get_mac(
outbuf + offset,
bytes + size - offset,
#ifdef NAS_MME
......@@ -192,7 +192,7 @@ nas_message_encrypt(
#endif
emm_security_context);
/* Set the message authentication code of the NAS message */
*(UInt32_t*)(outbuf + sizeof(UInt8_t)) = htonl(mac);
*(uint32_t*)(outbuf + sizeof(uint8_t)) = htonl(mac);
}
} else {
/* The input buffer does not need to be encrypted */
......@@ -301,9 +301,9 @@ int nas_message_decrypt(
}
/* Compute offset of the sequence number field */
int offset = size - sizeof(UInt8_t);
int offset = size - sizeof(uint8_t);
/* Compute the NAS message authentication code */
UInt32_t mac = _nas_message_get_mac(
uint32_t mac = _nas_message_get_mac(
inbuf + offset,
length - offset,
#ifdef NAS_MME
......@@ -410,9 +410,9 @@ int nas_message_decode(
}
/* Compute offset of the sequence number field */
int offset = size - sizeof(UInt8_t);
int offset = size - sizeof(uint8_t);
/* Compute the NAS message authentication code */
UInt32_t mac = _nas_message_get_mac(
uint32_t mac = _nas_message_get_mac(
buffer + offset,
length - offset,
#ifdef NAS_MME
......@@ -524,13 +524,13 @@ int nas_message_encode(
/* Integrity protect the NAS message */
if (bytes > 0) {
/* Compute offset of the sequence number field */
int offset = size - sizeof(UInt8_t);
int offset = size - sizeof(uint8_t);
/* Compute the NAS message authentication code */
LOG_TRACE(DEBUG,
"offset %d = %d - %d, hdr encode = %d, length = %d bytes = %d",
offset, size, sizeof(UInt8_t),
offset, size, sizeof(uint8_t),
size, length, bytes);
UInt32_t mac = _nas_message_get_mac(
uint32_t mac = _nas_message_get_mac(
buffer + offset,
bytes + size - offset,
#ifdef NAS_MME
......@@ -540,7 +540,7 @@ int nas_message_encode(
#endif
emm_security_context);
/* Set the message authentication code of the NAS message */
*(UInt32_t*)(buffer + sizeof(UInt8_t)) = htonl(mac);
*(uint32_t*)(buffer + sizeof(uint8_t)) = htonl(mac);
if (emm_security_context) {
#ifdef NAS_MME
......@@ -644,7 +644,7 @@ _nas_message_header_decode(
/* Decode the first octet of the header (security header type or EPS bearer
* identity, and protocol discriminator) */
DECODE_U8(buffer, *(UInt8_t*)(header), size);
DECODE_U8(buffer, *(uint8_t*)(header), size);
if (header->protocol_discriminator == EPS_MOBILITY_MANAGEMENT_MESSAGE) {
if (header->security_header_type != SECURITY_HEADER_TYPE_NOT_PROTECTED) {
......@@ -798,7 +798,7 @@ static int _nas_message_header_encode(
/* Encode the first octet of the header (security header type or EPS bearer
* identity, and protocol discriminator) */
ENCODE_U8(buffer, *(UInt8_t*)(header), size);
ENCODE_U8(buffer, *(uint8_t*)(header), size);
if (header->protocol_discriminator == EPS_MOBILITY_MANAGEMENT_MESSAGE) {
if (header->security_header_type != SECURITY_HEADER_TYPE_NOT_PROTECTED) {
......@@ -956,9 +956,9 @@ static int _nas_message_protected_encode(
static int _nas_message_decrypt(
char *dest,
const char *src,
UInt8_t security_header_type,
UInt32_t code,
UInt8_t seq,
uint8_t security_header_type,
uint32_t code,
uint8_t seq,
int length,
const emm_security_context_t * const emm_security_context)
{
......@@ -986,7 +986,7 @@ static int _nas_message_decrypt(
"No decryption of message length %u according to security header type 0x%02x",
length, security_header_type);
memcpy(dest, src, length);
DECODE_U8(dest, *(UInt8_t*)(&header), size);
DECODE_U8(dest, *(uint8_t*)(&header), size);
LOG_FUNC_RETURN (header.protocol_discriminator);
//LOG_FUNC_RETURN (length);
break;
......@@ -1022,7 +1022,7 @@ static int _nas_message_decrypt(
nas_stream_encrypt_eea1(&stream_cipher, dest);
/* Decode the first octet (security header type or EPS bearer identity,
* and protocol discriminator) */
DECODE_U8(dest, *(UInt8_t*)(&header), size);
DECODE_U8(dest, *(uint8_t*)(&header), size);
LOG_FUNC_RETURN (header.protocol_discriminator);
......@@ -1056,7 +1056,7 @@ static int _nas_message_decrypt(
nas_stream_encrypt_eea1(&stream_cipher, dest);
/* Decode the first octet (security header type or EPS bearer identity,
* and protocol discriminator) */
DECODE_U8(dest, *(UInt8_t*)(&header), size);
DECODE_U8(dest, *(uint8_t*)(&header), size);
LOG_FUNC_RETURN (header.protocol_discriminator);
}
......@@ -1071,7 +1071,7 @@ static int _nas_message_decrypt(
memcpy(dest, src, length);
/* Decode the first octet (security header type or EPS bearer identity,
* and protocol discriminator) */
DECODE_U8(dest, *(UInt8_t*)(&header), size);
DECODE_U8(dest, *(uint8_t*)(&header), size);
LOG_FUNC_RETURN (header.protocol_discriminator);
......@@ -1084,7 +1084,7 @@ static int _nas_message_decrypt(
memcpy(dest, src, length);
/* Decode the first octet (security header type or EPS bearer identity,
* and protocol discriminator) */
DECODE_U8(dest, *(UInt8_t*)(&header), size);
DECODE_U8(dest, *(uint8_t*)(&header), size);
LOG_FUNC_RETURN (header.protocol_discriminator);
break;
......@@ -1124,9 +1124,9 @@ static int _nas_message_decrypt(
static int _nas_message_encrypt(
char *dest,
const char *src,
UInt8_t security_header_type,
UInt32_t code,
UInt8_t seq,
uint8_t security_header_type,
uint32_t code,
uint8_t seq,
int const direction,
int length,
const emm_security_context_t * const emm_security_context)
......@@ -1274,7 +1274,7 @@ static int _nas_message_encrypt(
** Others: None **
** **
***************************************************************************/
static UInt32_t _nas_message_get_mac(
static uint32_t _nas_message_get_mac(
const char * const buffer,
int const length,
int const direction,
......@@ -1296,10 +1296,10 @@ static UInt32_t _nas_message_get_mac(
switch (emm_security_context->selected_algorithms.integrity) {
case NAS_SECURITY_ALGORITHMS_EIA1: {
UInt8_t mac[4];
uint8_t mac[4];
nas_stream_cipher_t stream_cipher;
UInt32_t count;
UInt32_t *mac32;
uint32_t count;
uint32_t *mac32;
int i,bytes = 0;
......@@ -1354,20 +1354,20 @@ static UInt32_t _nas_message_get_mac(
LOG_TRACE(DEBUG,
"NAS_SECURITY_ALGORITHMS_EIA1 returned MAC %x.%x.%x.%x(%u) for length %d direction %d, count %d",
mac[0], mac[1], mac[2],mac[3],
*((UInt32_t*)&mac),
*((uint32_t*)&mac),
length,
direction,
count);
mac32 = (UInt32_t*)&mac;
mac32 = (uint32_t*)&mac;
LOG_FUNC_RETURN (ntohl(*mac32));
}
break;
case NAS_SECURITY_ALGORITHMS_EIA2: {
UInt8_t mac[4];
uint8_t mac[4];
nas_stream_cipher_t stream_cipher;
UInt32_t count;
UInt32_t *mac32;
uint32_t count;
uint32_t *mac32;
if (direction == SECU_DIRECTION_UPLINK) {
count = 0x00000000 ||
......@@ -1400,11 +1400,11 @@ static UInt32_t _nas_message_get_mac(
LOG_TRACE(DEBUG,
"NAS_SECURITY_ALGORITHMS_EIA2 returned MAC %x.%x.%x.%x(%u) for length %d direction %d, count %d",
mac[0], mac[1], mac[2],mac[3],
*((UInt32_t*)&mac),
*((uint32_t*)&mac),
length,
direction,
count);
mac32 = (UInt32_t*)&mac;
mac32 = (uint32_t*)&mac;
LOG_FUNC_RETURN (ntohl(*mac32));
}
break;
......
......@@ -68,14 +68,14 @@ Description Defines the layer 3 messages supported by the NAS sublayer
typedef struct {
#ifdef __LITTLE_ENDIAN_BITFIELD
eps_protocol_discriminator_t protocol_discriminator:4;
UInt8_t security_header_type:4;
uint8_t security_header_type:4;
#endif
#ifdef __BIG_ENDIAN_BITFIELD
UInt8_t security_header_type:4;
UInt8_t protocol_discriminator:4;
uint8_t security_header_type:4;
uint8_t protocol_discriminator:4;
#endif
UInt32_t message_authentication_code;
UInt8_t sequence_number;
uint32_t message_authentication_code;
uint8_t sequence_number;
} nas_message_security_header_t;
/* Structure of plain NAS message */
......
......@@ -98,19 +98,19 @@ static const plmn_t mme_api_plmn = {0, 2, 0xf, 8, 0, 1}; // 20810
/* Authentication parameter RAND */
static const UInt8_t _mme_api_rand[AUTH_RAND_SIZE] = {
static const uint8_t _mme_api_rand[AUTH_RAND_SIZE] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x02, 0x03, 0x04
};
/* Authentication parameter AUTN */
static const UInt8_t _mme_api_autn[AUTH_AUTN_SIZE] = {
static const uint8_t _mme_api_autn[AUTH_AUTN_SIZE] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x05, 0x04, 0x03, 0x02, 0x00,
0x00, 0x00, 0x00, 0x00
};
/* Authentication response parameter */
static const UInt8_t _mme_api_xres[AUTH_XRES_SIZE] = {
static const uint8_t _mme_api_xres[AUTH_XRES_SIZE] = {
0x67, 0x70, 0x3a, 0x31, 0xf2, 0x2a, 0x2d, 0x51, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00
};
......
......@@ -58,7 +58,7 @@ Description Implements the API used by the NAS layer running in the MME
/****************************************************************************/
/* Maximum number of UEs the MME may simultaneously support */
#define MME_API_NB_UE_MAX 1
#define MME_API_NB_UE_MAX 256
/* Features supported by the MME */
......
......@@ -207,7 +207,7 @@ int emm_proc_attach_request(
int rc;
emm_data_context_t ue_ctx;
LOG_TRACE(INFO, "EMM-PROC - EPS attach type = %s (%d) requested (ueid=0x%08x)",
LOG_TRACE(INFO, "EMM-PROC - EPS attach type = %s (%d) requested (ueid="NAS_UE_ID_FMT")",
_emm_attach_type_str[type], type, ueid);
LOG_TRACE(INFO, "EMM-PROC - umts_present = %u umts_present = %u",
umts_present, gprs_present);
......@@ -314,6 +314,15 @@ int emm_proc_attach_request(
(*emm_ctx)->emm_cause = EMM_CAUSE_SUCCESS;
(*emm_ctx)->_emm_fsm_status = EMM_INVALID;
(*emm_ctx)->ueid = ueid;
/*
* Initialize EMM timers
*/
(*emm_ctx)->T3450.id = NAS_TIMER_INACTIVE_ID;
(*emm_ctx)->T3450.sec = T3450_DEFAULT_VALUE;
(*emm_ctx)->T3460.id = NAS_TIMER_INACTIVE_ID;
(*emm_ctx)->T3460.sec = T3460_DEFAULT_VALUE;
(*emm_ctx)->T3470.id = NAS_TIMER_INACTIVE_ID;
(*emm_ctx)->T3470.sec = T3470_DEFAULT_VALUE;
emm_fsm_set_status(ueid, *emm_ctx, EMM_DEREGISTERED);
#if defined(NAS_BUILT_IN_EPC)
......@@ -324,7 +333,7 @@ int emm_proc_attach_request(
if (tai) {
LOG_TRACE(WARNING,
"EMM-PROC - Set tac %u in context %u ",
"EMM-PROC - Set tac %u in context",
tai->tac);
(*emm_ctx)->tac = tai->tac;
} else {
......@@ -433,11 +442,7 @@ int emm_proc_attach_complete(unsigned int ueid, const OctetString *esm_msg_pP)
LOG_FUNC_IN;
LOG_TRACE(INFO, "EMM-PROC - EPS attach complete (ueid=%u)", ueid);
/* Stop timer T3450 */
LOG_TRACE(INFO, "EMM-PROC - Stop timer T3450 (%d)", T3450.id);
T3450.id = nas_timer_stop(T3450.id);
LOG_TRACE(INFO, "EMM-PROC - EPS attach complete (ueid="NAS_UE_ID_FMT")", ueid);
/* Release retransmission timer parameters */
attach_data_t *data = (attach_data_t *)(emm_proc_common_get_args(ueid));
......@@ -446,28 +451,27 @@ int emm_proc_attach_complete(unsigned int ueid, const OctetString *esm_msg_pP)
if (data->esm_msg.length > 0) {
free(data->esm_msg.value);
}
free(data);
}
/* Get the UE context */
#if defined(NAS_BUILT_IN_EPC)
if (ueid > 0) {
emm_ctx = emm_data_context_get(&_emm_data, ueid);
}
#else
if (ueid < EMM_DATA_NB_UE_MAX) {
emm_ctx = _emm_data.ctx[ueid];
}
#endif
if (emm_ctx) {
/* Delete the old GUTI and consider the GUTI sent in the Attach
/* Stop timer T3450 */
LOG_TRACE(INFO, "EMM-PROC - Stop timer T3450 (%d)", emm_ctx->T3450.id);
emm_ctx->T3450.id = nas_timer_stop(emm_ctx->T3450.id);
MSC_LOG_EVENT(MSC_NAS_EMM_MME, "0 T3450 stopped UE "NAS_UE_ID_FMT" ", ueid);
/* Delete the old GUTI and consider the GUTI sent in the Attach
* Accept message as valid */
emm_ctx->guti_is_new = FALSE;
emm_ctx->old_guti = NULL;
......@@ -612,7 +616,7 @@ static int _emm_attach_release(void *args)
emm_data_context_t *emm_ctx = (emm_data_context_t *)(args);
if (emm_ctx) {
LOG_TRACE(WARNING, "EMM-PROC - Release UE context data (ueid=%u)",
LOG_TRACE(WARNING, "EMM-PROC - Release UE context data (ueid="NAS_UE_ID_FMT")",
emm_ctx->ueid);
unsigned int ueid = emm_ctx->ueid;
......@@ -663,6 +667,25 @@ static int _emm_attach_release(void *args)
emm_ctx->security = NULL;
}
/* Stop timer T3450 */
if (emm_ctx->T3450.id != NAS_TIMER_INACTIVE_ID) {
LOG_TRACE(INFO, "EMM-PROC - Stop timer T3450 (%d)", emm_ctx->T3450.id);
emm_ctx->T3450.id = nas_timer_stop(emm_ctx->T3450.id);
MSC_LOG_EVENT(MSC_NAS_EMM_MME, "0 T3450 stopped UE "NAS_UE_ID_FMT" ", emm_ctx->ueid);
}
/* Stop timer T3460 */
if (emm_ctx->T3460.id != NAS_TIMER_INACTIVE_ID) {
LOG_TRACE(INFO, "EMM-PROC - Stop timer T3460 (%d)", emm_ctx->T3460.id);
emm_ctx->T3460.id = nas_timer_stop(emm_ctx->T3460.id);
MSC_LOG_EVENT(MSC_NAS_EMM_MME, "0 T3460 stopped UE "NAS_UE_ID_FMT" ", emm_ctx->ueid);
}
/* Stop timer T3470 */
if (emm_ctx->T3470.id != NAS_TIMER_INACTIVE_ID) {
LOG_TRACE(INFO, "EMM-PROC - Stop timer T3470 (%d)", emm_ctx->T3460.id);
emm_ctx->T3470.id = nas_timer_stop(emm_ctx->T3470.id);
MSC_LOG_EVENT(MSC_NAS_EMM_MME, "0 T3470 stopped UE "NAS_UE_ID_FMT" ", emm_ctx->ueid);
}
/* Release the EMM context */
#if defined(NAS_BUILT_IN_EPC)
emm_data_context_remove(&_emm_data, emm_ctx);
......@@ -713,7 +736,7 @@ static int _emm_attach_reject(void *args)
if (emm_ctx) {
emm_sap_t emm_sap;
LOG_TRACE(WARNING, "EMM-PROC - EMM attach procedure not accepted "
"by the network (ueid=%08x, cause=%d)",
"by the network (ueid="NAS_UE_ID_FMT", cause=%d)",
emm_ctx->ueid, emm_ctx->emm_cause);
/*
* Notify EMM-AS SAP that Attach Reject message has to be sent
......@@ -783,13 +806,20 @@ static int _emm_attach_abort(void *args)
unsigned int ueid = data->ueid;
esm_sap_t esm_sap;
LOG_TRACE(WARNING, "EMM-PROC - Abort the attach procedure (ueid=%u)",
LOG_TRACE(WARNING, "EMM-PROC - Abort the attach procedure (ueid="NAS_UE_ID_FMT")",
ueid);
/* Stop timer T3450 */
if (T3450.id != NAS_TIMER_INACTIVE_ID) {
LOG_TRACE(INFO, "EMM-PROC - Stop timer T3450 (%d)", T3450.id);
T3450.id = nas_timer_stop(T3450.id);
#if defined(NAS_BUILT_IN_EPC)
ctx = emm_data_context_get(&_emm_data, ueid);
#else
ctx = _emm_data.ctx[ueid];
#endif
if (ctx) {
/* Stop timer T3450 */
if (ctx->T3450.id != NAS_TIMER_INACTIVE_ID) {
LOG_TRACE(INFO, "EMM-PROC - Stop timer T3450 (%d)", ctx->T3450.id);
ctx->T3450.id = nas_timer_stop(ctx->T3450.id);
MSC_LOG_EVENT(MSC_NAS_EMM_MME, "0 T3450 stopped UE "NAS_UE_ID_FMT" ", data->ueid);
}
}
/* Release retransmission timer parameters */
......@@ -799,11 +829,7 @@ static int _emm_attach_abort(void *args)
free(data);
#if defined(NAS_BUILT_IN_EPC)
ctx = emm_data_context_get(&_emm_data, ueid);
#else
ctx = _emm_data.ctx[ueid];
#endif
/*
* Notify ESM that the network locally refused PDN connectivity
......@@ -865,7 +891,7 @@ static int _emm_attach_identify(void *args)
LOG_FUNC_IN;
LOG_TRACE(INFO, "EMM-PROC - Identify incoming UE (ueid=0x%08x) using %s",
LOG_TRACE(INFO, "EMM-PROC - Identify incoming UE (ueid="NAS_UE_ID_FMT") using %s",
emm_ctx->ueid, (emm_ctx->imsi)? "IMSI" : (emm_ctx->guti)? "GUTI" :
(emm_ctx->imei)? "IMEI" : "none");
......@@ -1055,7 +1081,7 @@ static int _emm_attach_security(void *args)
int rc;
emm_data_context_t *emm_ctx = (emm_data_context_t *)(args);
LOG_TRACE(INFO, "EMM-PROC - Setup NAS security (ueid=%u)", emm_ctx->ueid);
LOG_TRACE(INFO, "EMM-PROC - Setup NAS security (ueid="NAS_UE_ID_FMT")", emm_ctx->ueid);
/* Create new NAS security context */
if (emm_ctx->security == NULL) {
......@@ -1131,7 +1157,7 @@ static int _emm_attach(void *args)
emm_data_context_t *emm_ctx = (emm_data_context_t *)(args);
LOG_TRACE(INFO, "EMM-PROC - Attach UE (ueid=%u)", emm_ctx->ueid);
LOG_TRACE(INFO, "EMM-PROC - Attach UE (ueid="NAS_UE_ID_FMT")", emm_ctx->ueid);
/* 3GPP TS 24.401, Figure 5.3.2.1-1, point 5a
* At this point, all NAS messages shall be protected by the NAS security
......@@ -1330,16 +1356,18 @@ static int _emm_attach_accept(emm_data_context_t *emm_ctx, attach_data_t *data)
rc = emm_sap_send(&emm_sap);
if (rc != RETURNerror) {
if (T3450.id != NAS_TIMER_INACTIVE_ID) {
if (emm_ctx->T3450.id != NAS_TIMER_INACTIVE_ID) {
/* Re-start T3450 timer */
T3450.id = nas_timer_restart(T3450.id);
emm_ctx->T3450.id = nas_timer_restart(emm_ctx->T3450.id);
MSC_LOG_EVENT(MSC_NAS_EMM_MME, "0 T3450 restarted UE "NAS_UE_ID_FMT"", data->ueid);
} else {
/* Start T3450 timer */
T3450.id = nas_timer_start(T3450.sec, _emm_attach_t3450_handler, data);
emm_ctx->T3450.id = nas_timer_start(emm_ctx->T3450.sec, _emm_attach_t3450_handler, data);
MSC_LOG_EVENT(MSC_NAS_EMM_MME, "0 T3450 started UE "NAS_UE_ID_FMT" ", data->ueid);
}
LOG_TRACE(INFO,"EMM-PROC - Timer T3450 (%d) expires in %ld seconds",
T3450.id, T3450.sec);
emm_ctx->T3450.id, emm_ctx->T3450.sec);
}
} else {
LOG_TRACE(WARNING,"EMM-PROC - emm_ctx NULL");
......
......@@ -235,7 +235,7 @@ int emm_proc_authentication(void *ctx, unsigned int ueid, int ksi,
MSC_NAS_EMM_MME,
MSC_NAS_EMM_MME,
NULL,0,
"0 EMMREG_COMMON_PROC_REQ ue id %06x (authentication)", ueid);
"0 EMMREG_COMMON_PROC_REQ ue id "NAS_UE_ID_FMT" (authentication)", ueid);
emm_sap_t emm_sap;
emm_sap.primitive = EMMREG_COMMON_PROC_REQ;
......@@ -279,12 +279,9 @@ int emm_proc_authentication_complete(unsigned int ueid, int emm_cause,
LOG_FUNC_IN;
LOG_TRACE(INFO, "EMM-PROC - Authentication complete (ueid=%u, cause=%d)",