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)",
LOG_TRACE(INFO, "EMM-PROC - Authentication complete (ueid="NAS_UE_ID_FMT", cause=%d)",
ueid, emm_cause);
/* Stop timer T3460 */
LOG_TRACE(INFO, "EMM-PROC - Stop timer T3460 (%d)", T3460.id);
T3460.id = nas_timer_stop(T3460.id);
/* Release retransmission timer paramaters */
authentication_data_t *data =
......@@ -304,21 +301,22 @@ int emm_proc_authentication_complete(unsigned int ueid, int emm_cause,
/* Get the UE context */
emm_data_context_t *emm_ctx = NULL;
#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) {
/* Stop timer T3460 */
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" ", data->ueid);
}
if (emm_cause == EMM_CAUSE_SUCCESS) {
/* Check the received RES parameter */
if ( (emm_ctx == NULL) ||
......@@ -342,7 +340,7 @@ int emm_proc_authentication_complete(unsigned int ueid, int emm_cause,
*/
MSC_LOG_EVENT(
MSC_NAS_EMM_MME,
"SQN SYNCH_FAILURE ue id %06x", ueid);
"0 SQN SYNCH_FAILURE ue id "NAS_UE_ID_FMT" ", ueid);
LOG_TRACE(DEBUG, "EMM-PROC - USIM has detected a mismatch in SQN Ask for a new vector");
nas_itti_auth_info_req(ueid, emm_ctx->imsi, 0, res->value);
......@@ -365,7 +363,7 @@ int emm_proc_authentication_complete(unsigned int ueid, int emm_cause,
MSC_NAS_EMM_MME,
MSC_NAS_EMM_MME,
NULL,0,
"0 EMMREG_COMMON_PROC_REJ ue id %06x", ueid);
"0 EMMREG_COMMON_PROC_REJ ue id "NAS_UE_ID_FMT" ", ueid);
emm_sap.primitive = EMMREG_COMMON_PROC_REJ;
......@@ -381,7 +379,7 @@ int emm_proc_authentication_complete(unsigned int ueid, int emm_cause,
MSC_NAS_EMM_MME,
MSC_NAS_EMM_MME,
NULL,0,
"0 EMMREG_COMMON_PROC_CNF ue id %06x", ueid);
"0 EMMREG_COMMON_PROC_CNF ue id "NAS_UE_ID_FMT" ", ueid);
LOG_TRACE(DEBUG, "EMM-PROC - Notify EMM that the authentication procedure successfully completed");
emm_sap.primitive = EMMREG_COMMON_PROC_CNF;
......@@ -520,22 +518,26 @@ int _authentication_request(authentication_data_t *data)
MSC_NAS_EMM_MME,
MSC_NAS_EMM_MME,
NULL,0,
"0 EMMAS_SECURITY_REQ ue id %06x", data->ueid);
"0 EMMAS_SECURITY_REQ ue id "NAS_UE_ID_FMT" ", data->ueid);
rc = emm_sap_send(&emm_sap);
if (rc != RETURNerror) {
if (T3460.id != NAS_TIMER_INACTIVE_ID) {
/* Re-start T3460 timer */
T3460.id = nas_timer_restart(T3460.id);
} else {
/* Start T3460 timer */
T3460.id = nas_timer_start(T3460.sec, _authentication_t3460_handler,
if (emm_ctx) {
if (emm_ctx->T3460.id != NAS_TIMER_INACTIVE_ID) {
/* Re-start T3460 timer */
emm_ctx->T3460.id = nas_timer_restart(emm_ctx->T3460.id);
MSC_LOG_EVENT(MSC_NAS_EMM_MME, "0 T3460 restarted UE "NAS_UE_ID_FMT" ", data->ueid);
} else {
/* Start T3460 timer */
emm_ctx->T3460.id = nas_timer_start(emm_ctx->T3460.sec, _authentication_t3460_handler,
data);
MSC_LOG_EVENT(MSC_NAS_EMM_MME, "0 T3460 started UE "NAS_UE_ID_FMT" ", data->ueid);
}
}
LOG_TRACE(INFO,"EMM-PROC - Timer T3460 (%d) expires in %ld seconds",
T3460.id, T3460.sec);
emm_ctx->T3460.id, emm_ctx->T3460.sec);
}
LOG_FUNC_RETURN (rc);
......@@ -604,6 +606,7 @@ static int _authentication_abort(void *args)
LOG_FUNC_IN;
int rc = RETURNerror;
struct emm_data_context_s *emm_ctx;
authentication_data_t *data = (authentication_data_t *)(args);
......@@ -612,12 +615,19 @@ static int _authentication_abort(void *args)
int notify_failure = data->notify_failure;
LOG_TRACE(WARNING, "EMM-PROC - Abort authentication procedure "
"(ueid=%u)", ueid);
/* Stop timer T3460 */
if (T3460.id != NAS_TIMER_INACTIVE_ID) {
LOG_TRACE(INFO, "EMM-PROC - Stop timer T3460 (%d)", T3460.id);
T3460.id = nas_timer_stop(T3460.id);
"(ueid="NAS_UE_ID_FMT")", ueid);
#if defined(NAS_BUILT_IN_EPC)
emm_ctx = emm_data_context_get(&_emm_data, ueid);
#else
emm_ctx = _emm_data.ctx[ueid];
#endif
if (emm_ctx) {
/* 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" ", data->ueid);
}
}
/* Release retransmission timer paramaters */
......
......@@ -188,7 +188,7 @@ int emm_proc_detach_request(unsigned int ueid, emm_proc_detach_type_t type,
int rc;
emm_data_context_t *emm_ctx = NULL;
LOG_TRACE(INFO, "EMM-PROC - Detach type = %s (%d) requested (ueid=%u)",
LOG_TRACE(INFO, "EMM-PROC - Detach type = %s (%d) requested (ueid="NAS_UE_ID_FMT")",
_emm_detach_type_str[type], type, ueid);
/* Get the UE context */
......@@ -207,13 +207,13 @@ int emm_proc_detach_request(unsigned int ueid, emm_proc_detach_type_t type,
#endif
if (emm_ctx == NULL) {
LOG_TRACE(WARNING, "No EMM context exists for the UE (ueid=%u)", ueid);
LOG_TRACE(WARNING, "No EMM context exists for the UE (ueid="NAS_UE_ID_FMT")", ueid);
LOG_FUNC_RETURN(RETURNok);
}
if (switch_off) {
MSC_LOG_EVENT(MSC_NAS_EMM_MME,
"0 Removing UE context ue id %06x", ueid);
"0 Removing UE context ue id "NAS_UE_ID_FMT" ", ueid);
/* The UE is switched off */
if (emm_ctx->guti) {
free(emm_ctx->guti);
......@@ -249,7 +249,24 @@ int emm_proc_detach_request(unsigned int ueid, emm_proc_detach_type_t type,
free(emm_ctx->security);
}
/* 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);
......@@ -267,7 +284,7 @@ int emm_proc_detach_request(unsigned int ueid, emm_proc_detach_type_t type,
MSC_NAS_EMM_MME,
MSC_NAS_EMM_MME,
NULL,0,
"0 EMM_AS_NAS_INFO_DETACH ue id %06x", ueid);
"0 EMM_AS_NAS_INFO_DETACH ue id "NAS_UE_ID_FMT" ", ueid);
/* Setup NAS information message to transfer */
emm_as->NASinfo = EMM_AS_NAS_INFO_DETACH;
......@@ -295,7 +312,7 @@ int emm_proc_detach_request(unsigned int ueid, emm_proc_detach_type_t type,
MSC_NAS_EMM_MME,
MSC_NAS_ESM_MME,
NULL,0,
"0 ESM_EPS_BEARER_CONTEXT_DEACTIVATE_REQ ue id %06x", ueid);
"0 ESM_EPS_BEARER_CONTEXT_DEACTIVATE_REQ ue id "NAS_UE_ID_FMT" ", ueid);
esm_sap_t esm_sap;
esm_sap.primitive = ESM_EPS_BEARER_CONTEXT_DEACTIVATE_REQ;
esm_sap.ueid = ueid;
......@@ -312,7 +329,7 @@ int emm_proc_detach_request(unsigned int ueid, emm_proc_detach_type_t type,
MSC_NAS_EMM_MME,
MSC_NAS_EMM_MME,
NULL,0,
"0 EMMREG_DETACH_REQ ue id %06x", ueid);
"0 EMMREG_DETACH_REQ ue id "NAS_UE_ID_FMT" ", ueid);
emm_sap.primitive = EMMREG_DETACH_REQ;
emm_sap.u.emm_reg.ueid = ueid;
emm_sap.u.emm_reg.ctx = emm_ctx;
......
......@@ -193,7 +193,7 @@ int emm_proc_identification(unsigned int ueid,
MSC_NAS_EMM_MME,
MSC_NAS_EMM_MME,
NULL,0,
"0 EMMREG_COMMON_PROC_REQ ue id %06x (identification)", ueid);
"0 EMMREG_COMMON_PROC_REQ ue id "NAS_UE_ID_FMT" (identification)", ueid);
emm_sap_t emm_sap;
emm_sap.primitive = EMMREG_COMMON_PROC_REQ;
......@@ -229,7 +229,7 @@ int emm_proc_identification(unsigned int ueid,
** **
***************************************************************************/
int emm_proc_identification_complete(unsigned int ueid, const imsi_t *imsi,
const imei_t *imei, UInt32_t *tmsi)
const imei_t *imei, uint32_t *tmsi)
{
int rc = RETURNerror;
emm_sap_t emm_sap;
......@@ -238,36 +238,32 @@ int emm_proc_identification_complete(unsigned int ueid, const imsi_t *imsi,
LOG_FUNC_IN;
LOG_TRACE(INFO, "EMM-PROC - Identification complete (ueid=%u)", ueid);
/* Stop timer T3470 */
LOG_TRACE(INFO, "EMM-PROC - Stop timer T3470 (%d)", T3470.id);
T3470.id = nas_timer_stop(T3470.id);
LOG_TRACE(INFO, "EMM-PROC - Identification complete (ueid="NAS_UE_ID_FMT")", ueid);
/* Release retransmission timer paramaters */
identification_data_t *data =
(identification_data_t *)(emm_proc_common_get_args(ueid));
if (data) {
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) {
/* Stop timer T3470 */
LOG_TRACE(INFO, "EMM-PROC - Stop timer T3470 (%d)", emm_ctx->T3470.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" ", ueid);
if (imsi) {
/* Update the IMSI */
if (emm_ctx->imsi == NULL) {
......@@ -306,7 +302,7 @@ int emm_proc_identification_complete(unsigned int ueid, const imsi_t *imsi,
MSC_NAS_EMM_MME,
MSC_NAS_EMM_MME,
NULL,0,
"0 EMMREG_COMMON_PROC_CNF ue id %06x", ueid);
"0 EMMREG_COMMON_PROC_CNF ue id "NAS_UE_ID_FMT" ", ueid);
emm_sap.primitive = EMMREG_COMMON_PROC_CNF;
emm_sap.u.emm_reg.ueid = ueid;
......@@ -321,7 +317,7 @@ int emm_proc_identification_complete(unsigned int ueid, const imsi_t *imsi,
MSC_NAS_EMM_MME,
MSC_NAS_EMM_MME,
NULL,0,
"0 EMMREG_COMMON_PROC_REJ ue id %06x", ueid);
"0 EMMREG_COMMON_PROC_REJ ue id "NAS_UE_ID_FMT" ", ueid);
emm_sap.primitive = EMMREG_COMMON_PROC_REJ;
emm_sap.u.emm_reg.ueid = ueid;
......@@ -428,7 +424,7 @@ int _identification_request(identification_data_t *data)
MSC_NAS_EMM_MME,
MSC_NAS_EMM_MME,
NULL,0,
"0 EMMAS_SECURITY_REQ ue id %06x", data->ueid);
"0 EMMAS_SECURITY_REQ ue id "NAS_UE_ID_FMT" ", data->ueid);
emm_sap.primitive = EMMAS_SECURITY_REQ;
emm_sap.u.emm_as.u.security.guti = NULL;
......@@ -437,17 +433,13 @@ int _identification_request(identification_data_t *data)
emm_sap.u.emm_as.u.security.identType = data->type;
#if defined(NAS_BUILT_IN_EPC)
if (data->ueid > 0) {
emm_ctx = emm_data_context_get(&_emm_data, data->ueid);
}
#else
if (data->ueid < EMM_DATA_NB_UE_MAX) {
emm_ctx = _emm_data.ctx[data->ueid];
}
#endif
/* Setup EPS NAS security data */
emm_as_set_security_data(&emm_sap.u.emm_as.u.security.sctx,
......@@ -455,17 +447,19 @@ int _identification_request(identification_data_t *data)
rc = emm_sap_send(&emm_sap);
if (rc != RETURNerror) {
if (T3470.id != NAS_TIMER_INACTIVE_ID) {
if (emm_ctx->T3470.id != NAS_TIMER_INACTIVE_ID) {
/* Re-start T3470 timer */
T3470.id = nas_timer_restart(T3470.id);
emm_ctx->T3470.id = nas_timer_restart(emm_ctx->T3470.id);
MSC_LOG_EVENT(MSC_NAS_EMM_MME, "0 T3470 restarted UE "NAS_UE_ID_FMT" ", data->ueid);
} else {
/* Start T3470 timer */
T3470.id = nas_timer_start(T3470.sec, _identification_t3470_handler,
emm_ctx->T3470.id = nas_timer_start(emm_ctx->T3470.sec, _identification_t3470_handler,
data);
MSC_LOG_EVENT(MSC_NAS_EMM_MME, "0 T3470 started UE "NAS_UE_ID_FMT" ", data->ueid);
}
LOG_TRACE(INFO,"EMM-PROC - Timer T3470 (%d) expires in %ld seconds",
T3470.id, T3470.sec);
emm_ctx->T3470.id, emm_ctx->T3470.sec);
}
LOG_FUNC_RETURN (rc);
......@@ -496,14 +490,25 @@ static int _identification_abort(void *args)
if (data) {
unsigned int ueid = data->ueid;
int notify_failure = data->notify_failure;
struct emm_data_context_s *emm_ctx = NULL;
/* 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
LOG_TRACE(WARNING, "EMM-PROC - Abort identification procedure "
"(ueid=%u)", ueid);
"(ueid="NAS_UE_ID_FMT")", ueid);
/* Stop timer T3470 */
if (T3470.id != NAS_TIMER_INACTIVE_ID) {
LOG_TRACE(INFO, "EMM-PROC - Stop timer T3470 (%d)", T3470.id);
T3470.id = nas_timer_stop(T3470.id);
if (emm_ctx->T3470.id != NAS_TIMER_INACTIVE_ID) {
LOG_TRACE(INFO, "EMM-PROC - Stop timer T3470 (%d)", emm_ctx->T3470.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" ", data->ueid);
}
/* Release retransmission timer paramaters */
......@@ -517,7 +522,7 @@ static int _identification_abort(void *args)
MSC_NAS_EMM_MME,
MSC_NAS_EMM_MME,
NULL,0,
"0 EMMREG_COMMON_PROC_REJ ue id %06x", ueid);
"0 EMMREG_COMMON_PROC_REJ ue id "NAS_UE_ID_FMT" ", ueid);
emm_sap_t emm_sap;
emm_sap.primitive = EMMREG_COMMON_PROC_REJ;
emm_sap.u.emm_reg.ueid = ueid;
......
......@@ -102,6 +102,7 @@ int lowerlayer_success(unsigned int ueid)
emm_sap.primitive = EMMREG_LOWERLAYER_SUCCESS;
emm_sap.u.emm_reg.ueid = ueid;
emm_sap.u.emm_reg.ctx = NULL;
rc = emm_sap_send(&emm_sap);
LOG_FUNC_RETURN (rc);
......@@ -131,6 +132,15 @@ int lowerlayer_failure(unsigned int ueid)
emm_sap.primitive = EMMREG_LOWERLAYER_FAILURE;
emm_sap.u.emm_reg.ueid = ueid;
#if defined(NAS_BUILT_IN_EPC)
emm_data_context_t *emm_ctx = NULL;
if (ueid > 0) {
emm_ctx = emm_data_context_get(&_emm_data, ueid);
}
emm_sap.u.emm_reg.ctx = emm_ctx;
#else
emm_sap.u.emm_reg.ctx = NULL;
#endif
rc = emm_sap_send(&emm_sap);
LOG_FUNC_RETURN (rc);
......@@ -182,6 +192,7 @@ int lowerlayer_release(int cause)
emm_sap.primitive = EMMREG_LOWERLAYER_RELEASE;
emm_sap.u.emm_reg.ueid = 0;
emm_sap.u.emm_reg.ctx = NULL;
rc = emm_sap_send(&emm_sap);
LOG_FUNC_RETURN (rc);
......@@ -328,7 +339,7 @@ void emm_as_set_security_data(emm_as_security_data_t *data, const void *args,
is_new,
context->eksi,
context->ul_count.seq_num,
*(UInt32_t *)(&context->ul_count));
*(uint32_t *)(&context->ul_count));
LOG_TRACE(INFO,
"knas_int %s",dump_octet_string(&context->knas_int));
LOG_TRACE(INFO,
......@@ -339,7 +350,7 @@ void emm_as_set_security_data(emm_as_security_data_t *data, const void *args,
data->is_new = is_new;
data->ksi = context->eksi;
data->sqn = context->dl_count.seq_num;
// LG data->count = *(UInt32_t *)(&context->ul_count);
// LG data->count = *(uint32_t *)(&context->ul_count);
data->count = 0x00000000 | (context->dl_count.overflow << 8 ) | context->dl_count.seq_num;
/* NAS integrity and cyphering keys may not be available if the
* current security context is a partial EPS security context
......
......@@ -201,7 +201,7 @@ int emm_as_send(const emm_as_t *msg)
int emm_cause = EMM_CAUSE_SUCCESS;
emm_as_primitive_t primitive = msg->primitive;
UInt32_t ueid = 0;
uint32_t ueid = 0;
LOG_TRACE(INFO, "EMMAS-SAP - Received primitive %s (%d)",
_emm_as_primitive_str[primitive - _EMMAS_START - 1], primitive);
......@@ -445,7 +445,7 @@ static int _emm_as_data_ind(const emm_as_data_t *msg, int *emm_cause)
int rc = RETURNerror;
LOG_TRACE(INFO, "EMMAS-SAP - Received AS data transfer indication "
"(ueid=%u, delivered=%s, length=%d)", msg->ueid,
"(ueid="NAS_UE_ID_FMT", delivered=%s, length=%d)", msg->ueid,
(msg->delivered)? "TRUE" : "FALSE", msg->NASmsg.length);
if (msg->delivered) {
......@@ -992,7 +992,7 @@ static int _emm_as_send(const emm_as_t *msg)
LOG_FUNC_RETURN (RETURNok);
} else {
LOG_TRACE(DEBUG, "EMMAS-SAP - "
"Sending nas_itti_establish_cnf to S1AP UE ID %d"
"Sending nas_itti_establish_cnf to S1AP UE ID 0x%x"
" selected_encryption_algorithm 0x%04X",
" selected_integrity_algorithm 0x%04X",
as_msg.msg.nas_establish_rsp.UEid,
......@@ -1295,9 +1295,9 @@ static int _emm_as_security_req(const emm_as_security_t *msg,
if (emm_msg != NULL) switch (msg->msgType) {
case EMM_AS_MSG_TYPE_IDENT:
if (msg->guti) {
MSC_LOG_EVENT(MSC_NAS_EMM_MME, "send IDENTITY_REQUEST to s_TMSI %u.%u ", as_msg->s_tmsi.MMEcode, as_msg->s_tmsi.m_tmsi);
MSC_LOG_EVENT(MSC_NAS_EMM_MME, "0 send IDENTITY_REQUEST to s_TMSI %u.%u ", as_msg->s_tmsi.MMEcode, as_msg->s_tmsi.m_tmsi);
} else {
MSC_LOG_EVENT(MSC_NAS_EMM_MME, "send IDENTITY_REQUEST to ue id %u ", as_msg->UEid);
MSC_LOG_EVENT(MSC_NAS_EMM_MME, "0 send IDENTITY_REQUEST to ue id "NAS_UE_ID_FMT" ", as_msg->UEid);
}
size = emm_send_identity_request(msg,
&emm_msg->identity_request);
......@@ -1305,9 +1305,9 @@ static int _emm_as_security_req(const emm_as_security_t *msg,
case EMM_AS_MSG_TYPE_AUTH:
if (msg->guti) {
MSC_LOG_EVENT(MSC_NAS_EMM_MME, "send AUTHENTICATION_REQUEST to s_TMSI %u.%u ", as_msg->s_tmsi.MMEcode, as_msg->s_tmsi.m_tmsi);
MSC_LOG_EVENT(MSC_NAS_EMM_MME, "0 send AUTHENTICATION_REQUEST to s_TMSI %u.%u ", as_msg->s_tmsi.MMEcode, as_msg->s_tmsi.m_tmsi);
} else {
MSC_LOG_EVENT(MSC_NAS_EMM_MME, "send AUTHENTICATION_REQUEST to ue id %u ", as_msg->UEid);
MSC_LOG_EVENT(MSC_NAS_EMM_MME, "0 send AUTHENTICATION_REQUEST to ue id "NAS_UE_ID_FMT" ", as_msg->UEid);
}
size = emm_send_authentication_request(msg,
&emm_msg->authentication_request);
......@@ -1315,9 +1315,9 @@ static int _emm_as_security_req(const emm_as_security_t *msg,
case EMM_AS_MSG_TYPE_SMC:
if (msg->guti) {
MSC_LOG_EVENT(MSC_NAS_EMM_MME, "send SECURITY_MODE_COMMAND to s_TMSI %u.%u ", as_msg->s_tmsi.MMEcode, as_msg->s_tmsi.m_tmsi);
MSC_LOG_EVENT(MSC_NAS_EMM_MME, "0 send SECURITY_MODE_COMMAND to s_TMSI %u.%u ", as_msg->s_tmsi.MMEcode, as_msg->s_tmsi.m_tmsi);
} else {
MSC_LOG_EVENT(MSC_NAS_EMM_MME, "send SECURITY_MODE_COMMAND to ue id %u ", as_msg->UEid);
MSC_LOG_EVENT(MSC_NAS_EMM_MME, "0 send SECURITY_MODE_COMMAND to ue id "NAS_UE_ID_FMT" ", as_msg->UEid);
}
size = emm_send_security_mode_command(msg,
&emm_msg->security_mode_command);
......@@ -1410,9 +1410,9 @@ static int _emm_as_security_rej(const emm_as_security_t *msg,
if (emm_msg != NULL) switch (msg->msgType) {
case EMM_AS_MSG_TYPE_AUTH:
if (msg->guti) {
MSC_LOG_EVENT(MSC_NAS_EMM_MME, "send AUTHENTICATION_REJECT to s_TMSI %u.%u ", as_msg->s_tmsi.MMEcode, as_msg->s_tmsi.m_tmsi);
MSC_LOG_EVENT(MSC_NAS_EMM_MME, "0 send AUTHENTICATION_REJECT to s_TMSI %u.%u ", as_msg->s_tmsi.MMEcode, as_msg->s_tmsi.m_tmsi);
} else {
MSC_LOG_EVENT(MSC_NAS_EMM_MME, "send AUTHENTICATION_REJECT to ue id %x ", as_msg->UEid);
MSC_LOG_EVENT(MSC_NAS_EMM_MME, "0 send AUTHENTICATION_REJECT to ue id "NAS_UE_ID_FMT" ", as_msg->UEid);
}
size = emm_send_authentication_reject(
&emm_msg->authentication_reject);
......@@ -1516,7 +1516,7 @@ static int _emm_as_establish_cnf(const emm_as_establish_t *msg,
"EMMAS-SAP - emm_as_establish.nasMSG.length=%d",
msg->NASmsg.length);
MSC_LOG_EVENT(MSC_NAS_EMM_MME, "send ATTACH_ACCEPT to s_TMSI %u.%u ", as_msg->s_tmsi.MMEcode, as_msg->s_tmsi.m_tmsi);
MSC_LOG_EVENT(MSC_NAS_EMM_MME, "0 send ATTACH_ACCEPT to s_TMSI %u.%u ", as_msg->s_tmsi.MMEcode, as_msg->s_tmsi.m_tmsi);
size = emm_send_attach_accept(msg, &emm_msg->attach_accept);
break;
......@@ -1632,18 +1632,18 @@ static int _emm_as_establish_rej(const emm_as_establish_t *msg,
if (emm_msg != NULL) switch (msg->NASinfo) {
case EMM_AS_NAS_INFO_ATTACH:
if (msg->UEid.guti) {
MSC_LOG_EVENT(MSC_NAS_EMM_MME, "send ATTACH_REJECT to s_TMSI %u.%u ", as_msg->s_tmsi.MMEcode, as_msg->s_tmsi.m_tmsi);
MSC_LOG_EVENT(MSC_NAS_EMM_MME, "0 send ATTACH_REJECT to s_TMSI %u.%u ", as_msg->s_tmsi.MMEcode, as_msg->s_tmsi.m_tmsi);
} else {
MSC_LOG_EVENT(MSC_NAS_EMM_MME, "send ATTACH_REJECT to ue id 0x%06"PRIX32" ", as_msg->UEid);
MSC_LOG_EVENT(MSC_NAS_EMM_MME, "0 send ATTACH_REJECT to ue id "NAS_UE_ID_FMT" ", as_msg->UEid);
}
size = emm_send_attach_reject(msg, &emm_msg->attach_reject);
break;
case EMM_AS_NAS_INFO_TAU:
if (msg->UEid.guti) {
MSC_LOG_EVENT(MSC_NAS_EMM_MME, "send TRACKING_AREA_UPDATE_REJECT to s_TMSI %u.%u ", as_msg->s_tmsi.MMEcode, as_msg->s_tmsi.m_tmsi);
MSC_LOG_EVENT(MSC_NAS_EMM_MME, "0 send TRACKING_AREA_UPDATE_REJECT to s_TMSI %u.%u ", as_msg->s_tmsi.MMEcode, as_msg->s_tmsi.m_tmsi);
} else {
MSC_LOG_EVENT(MSC_NAS_EMM_MME, "send TRACKING_AREA_UPDATE_REJECT to ue id 0x%06"PRIX32" ", as_msg->UEid);
MSC_LOG_EVENT(MSC_NAS_EMM_MME, "0 send TRACKING_AREA_UPDATE_REJECT to ue id "NAS_UE_ID_FMT" ", as_msg->UEid);
}
size = emm_send_tracking_area_update_reject(msg,
&emm_msg->tracking_area_update_reject);
......
......@@ -81,11 +81,11 @@ typedef enum emm_as_primitive_u {
/* Data used to setup EPS NAS security */
typedef struct emm_as_security_data_s {
UInt8_t is_new; /* New security data indicator */
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 */
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;
......@@ -99,21 +99,21 @@ typedef struct emm_as_security_data_s {
* ----------------------------
*/
typedef struct emm_as_security_s {
UInt32_t ueid; /* UE lower layer identifier */
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 */
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 */
uint32_t tmsi; /* The requested TMSI of the UE */
/*
* Authentication request/response
*/
UInt8_t ksi; /* NAS key set identifier */
uint8_t ksi; /* NAS key set identifier */
const OctetString *rand; /* Random challenge number */
const OctetString *autn; /* Authentication token */
const OctetString *res; /* Authentication response */
......@@ -121,23 +121,23 @@ typedef struct emm_as_security_s {
/*
* Security Mode Command
*/
UInt8_t eea; /* Replayed EPS encryption algorithms */
UInt8_t eia; /* Replayed EPS integrity algorithms */
UInt8_t uea; /* Replayed UMTS encryption algorithms */
uint8_t eea; /* Replayed EPS encryption algorithms */
uint8_t eia; /* Replayed EPS integrity algorithms */
uint8_t uea; /* Replayed UMTS encryption algorithms */
uint8_t ucs2;
UInt8_t uia; /* Replayed UMTS integrity algorithms */
UInt8_t gea; /* Replayed GPRS encryption algorithms */
UInt8_t umts_present;
UInt8_t gprs_present;
uint8_t uia; /* Replayed UMTS integrity algorithms */
uint8_t gea; /* Replayed GPRS encryption algorithms */
uint8_t umts_present;
uint8_t gprs_present;
// Added by LG
UInt8_t selected_eea; /* Selected EPS encryption algorithms */
UInt8_t selected_eia; /* Selected EPS integrity algorithms */
uint8_t selected_eea; /* Selected EPS encryption algorithms */
uint8_t selected_eia; /* Selected 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 */
uint8_t msgType; /* Type of NAS security message to transfer */
} emm_as_security_t;
/*
......@@ -153,17 +153,17 @@ typedef struct emm_as_EPS_identity_s {
} emm_as_EPS_identity_t;
typedef struct emm_as_establish_s {
UInt32_t ueid; /* UE lower layer identifier */
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 */
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 */
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
......@@ -175,7 +175,7 @@ typedef struct emm_as_establish_s {
#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 */
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;
......@@ -185,11 +185,11 @@ typedef struct emm_as_establish_s {
* --------------------------------------
*/
typedef struct emm_as_release_s {
UInt32_t ueid; /* UE lower layer identifier */
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 */
uint8_t cause; /* Release cause */
} emm_as_release_t;
/*
......@@ -197,15 +197,15 @@ typedef struct emm_as_release_s {
* ---------------------------------
*/
typedef struct emm_as_data_s {
UInt32_t ueid; /* UE lower layer identifier */
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 */
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 */
uint8_t NASinfo; /* Type of NAS information to transfer */
OctetString NASmsg; /* NAS message to be transfered */
} emm_as_data_t;
......@@ -220,7 +220,7 @@ typedef struct emm_as_page_s {} emm_as_page_t;
* -------------------------------------
*/
typedef struct emm_as_status_s {
UInt32_t ueid; /* UE lower layer identifier */
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 */
......@@ -231,7 +231,7 @@ typedef struct emm_as_status_s {
* ------------------------------------
*/
typedef struct emm_as_cell_info_s {
UInt8_t found; /* Indicates whether a suitable cell is found */
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 */
......
......@@ -105,7 +105,7 @@ static int _emm_cn_authentication_res(const emm_cn_auth_res_t *msg)
if (emm_ctx == NULL) {
LOG_TRACE(ERROR, "EMM-PROC - "
"Failed to find UE associated to id %u...", msg->ue_id);
"Failed to find UE associated to id "NAS_UE_ID_FMT"...", msg->ue_id);
LOG_FUNC_RETURN (rc);
}
......@@ -166,13 +166,13 @@ static int _emm_cn_authentication_fail(const emm_cn_auth_fail_t *msg)
LOG_FUNC_RETURN (rc);
}
static int _emm_cn_deregister_ue(const UInt32_t ue_id)
static int _emm_cn_deregister_ue(const uint32_t ue_id)
{
int rc = RETURNok;
LOG_FUNC_IN;
LOG_TRACE(WARNING, "EMM-PROC - "
"TODO deregister UE %u, following procedure is a test");
"TODO deregister UE "NAS_UE_ID_FMT", following procedure is a test", ue_id);
emm_proc_detach_request(ue_id, EMM_DETACH_TYPE_EPS /* ??? emm_proc_detach_type_t*/,
1 /*switch_off*/, 0 /*native_ksi*/, 0 /*ksi*/,
NULL /*guti*/, NULL /*imsi*/, NULL /*imei*/);
......@@ -207,7 +207,7 @@ static int _emm_cn_pdn_connectivity_res(const emm_cn_pdn_res_t *msg_pP)
if (emm_ctx_p == NULL) {
LOG_TRACE(ERROR, "EMMCN-SAP - "
"Failed to find UE associated to id %u...", msg_pP->ue_id);
"Failed to find UE associated to id "NAS_UE_ID_FMT"...", msg_pP->ue_id);
LOG_FUNC_RETURN (rc);
}
......
......@@ -70,7 +70,7 @@ typedef nas_pdn_connectivity_rsp_t emm_cn_pdn_res_t;
typedef nas_pdn_connectivity_fail_t emm_cn_pdn_fail_t;
typedef struct emm_cn_deregister_ue_s {
UInt32_t UEid;
uint32_t UEid;
} emm_cn_deregister_ue_t;
typedef struct emm_mme_ul_s {
......
......@@ -55,6 +55,7 @@ Description Defines the EPS Mobility Management procedures executed at
#if defined(NAS_BUILT_IN_EPC)
# include "assertions.h"
#endif
# include "msc.h"
/****************************************************************************/
/**************** E X T E R N A L D E F I N I T I O N S ****************/
......@@ -201,11 +202,12 @@ int emm_fsm_set_status(
DevAssert(emm_ctx != NULL);
if ((status < EMM_STATE_MAX) && (ueid > 0)) {
LOG_TRACE(INFO, "EMM-FSM - Status changed: %s ===> %s",
_emm_fsm_status_str[emm_ctx->_emm_fsm_status],
_emm_fsm_status_str[status]);
if (status != emm_ctx->_emm_fsm_status) {
LOG_TRACE(INFO, "EMM-FSM - Status changed: %s ===> %s",
_emm_fsm_status_str[emm_ctx->_emm_fsm_status],
_emm_fsm_status_str[status]);
MSC_LOG_EVENT(MSC_NAS_EMM_MME, "0 EMM state %s ", _emm_fsm_status_str[status]);
emm_ctx->_emm_fsm_status = status;
}
......@@ -215,11 +217,11 @@ 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]) {
LOG_TRACE(INFO, "EMM-FSM - Status changed: %s ===> %s",
_emm_fsm_status_str[_emm_fsm_status[ueid]],
_emm_fsm_status_str[status]);
_emm_fsm_status[ueid] = status;
}
......@@ -250,7 +252,11 @@ emm_fsm_state_t emm_fsm_get_status(unsigned int ueid, void *ctx)
{
# if defined(NAS_BUILT_IN_EPC)
emm_data_context_t *emm_ctx = (emm_data_context_t *)ctx;
if (emm_ctx == NULL) {
LOG_TRACE(INFO, "EMM-FSM - try again get context ueid "NAS_UE_ID_FMT" ",
ueid);
emm_ctx = emm_data_context_get(&_emm_data, ueid);
}
if (emm_ctx != NULL) {
return emm_ctx->_emm_fsm_status;
}
......@@ -290,7 +296,6 @@ int emm_fsm_process(const emm_reg_t *evt)
# if defined(NAS_BUILT_IN_EPC)
emm_data_context_t *emm_ctx = (emm_data_context_t *)evt->ctx;
DevAssert(emm_ctx != NULL);
status = emm_fsm_get_status(0, emm_ctx);
......
......@@ -562,7 +562,7 @@ int emm_recv_identity_response(unsigned int ueid, identity_response_msg *msg,
/* Execute the identification completion procedure */
rc = emm_proc_identification_complete(ueid, p_imsi, p_imei,
(UInt32_t *)(p_tmsi));
(uint32_t *)(p_tmsi));
LOG_FUNC_RETURN (rc);
}
......
......@@ -338,7 +338,7 @@ int emm_proc_security_mode_control(unsigned int ueid, int ksi,
MSC_NAS_EMM_MME,
MSC_NAS_EMM_MME,
NULL,0,
"0 EMMREG_COMMON_PROC_REQ ue id %06x (security mode control)", ueid);
"0 EMMREG_COMMON_PROC_REQ ue id "NAS_UE_ID_FMT" (security mode control)", ueid);
emm_sap_t emm_sap;
emm_sap.primitive = EMMREG_COMMON_PROC_REQ;
emm_sap.u.emm_reg.ueid = ueid;
......@@ -381,34 +381,33 @@ int emm_proc_security_mode_complete(unsigned int ueid)
LOG_FUNC_IN;
LOG_TRACE(INFO, "EMM-PROC - Security mode complete (ueid=%u)", ueid);
LOG_TRACE(INFO, "EMM-PROC - Security mode complete (ueid="NAS_UE_ID_FMT")", ueid);
/* Stop timer T3460 */
LOG_TRACE(INFO, "EMM-PROC - Stop timer T3460 (%d)", T3460.id);
T3460.id = nas_timer_stop(T3460.id);
/* Release retransmission timer paramaters */
security_data_t *data = (security_data_t *)(emm_proc_common_get_args(ueid));
if (data) {
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) {
/* Stop timer T3460 */
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" ", ueid);
}
/* Release retransmission timer paramaters */
security_data_t *data = (security_data_t *)(emm_proc_common_get_args(ueid));
if (data) {
free(data);
}
if (emm_ctx && emm_ctx->security) {
/*
* Notify EMM that the authentication procedure successfully completed
......@@ -417,7 +416,7 @@ int emm_proc_security_mode_complete(unsigned int ueid)
MSC_NAS_EMM_MME,
MSC_NAS_EMM_MME,
NULL,0,
"0 EMMREG_COMMON_PROC_CNF ue id %06x (security mode complete)", ueid);
"0 EMMREG_COMMON_PROC_CNF ue id "NAS_UE_ID_FMT" (security mode complete)", ueid);
emm_sap.primitive = EMMREG_COMMON_PROC_CNF;
emm_sap.u.emm_reg.ueid = ueid;
emm_sap.u.emm_reg.ctx = emm_ctx;
......@@ -431,7 +430,7 @@ int emm_proc_security_mode_complete(unsigned int ueid)
MSC_NAS_EMM_MME,
MSC_NAS_EMM_MME,
NULL,0,
"0 EMMREG_COMMON_PROC_REJ ue id %06x (security mode complete)", ueid);
"0 EMMREG_COMMON_PROC_REJ ue id "NAS_UE_ID_FMT" (security mode complete)", ueid);
emm_sap.primitive = EMMREG_COMMON_PROC_REJ;
emm_sap.u.emm_reg.ueid = ueid;
emm_sap.u.emm_reg.ctx = emm_ctx;
......@@ -474,34 +473,32 @@ int emm_proc_security_mode_reject(unsigned int ueid)
LOG_FUNC_IN;
LOG_TRACE(WARNING, "EMM-PROC - Security mode command not accepted by the UE"
"(ueid=0x%08x)", ueid);
/* Stop timer T3460 */
LOG_TRACE(INFO, "EMM-PROC - Stop timer T3460 (%d)", T3460.id);
T3460.id = nas_timer_stop(T3460.id);
"(ueid="NAS_UE_ID_FMT")", ueid);
/* Release retransmission timer paramaters */
security_data_t *data = (security_data_t *)(emm_proc_common_get_args(ueid));
if (data) {
free(data);
}
/* Get the UE context */
#if defined(NAS_BUILT_IN_EPC)
if (ueid > 0) {
emm_ctx = emm_data_context_get(&_emm_data, ueid);
DevAssert(emm_ctx != NULL);
}
#else
if (ueid < EMM_DATA_NB_UE_MAX) {
emm_ctx = _emm_data.ctx[ueid];
}
#endif
if (emm_ctx) {
/* Stop timer T3460 */
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" ", ueid);
}
/* Release retransmission timer paramaters */
security_data_t *data = (security_data_t *)(emm_proc_common_get_args(ueid));
if (data) {
free(data);
}
/* Set the key set identifier to its previous value */
if (emm_ctx && emm_ctx->security) {
......@@ -521,7 +518,7 @@ int emm_proc_security_mode_reject(unsigned int ueid)
MSC_NAS_EMM_MME,
MSC_NAS_EMM_MME,
NULL,0,
"0 EMMREG_COMMON_PROC_REJ ue id %06x (security mode reject)", ueid);
"0 EMMREG_COMMON_PROC_REJ ue id "NAS_UE_ID_FMT" (security mode reject)", ueid);
emm_sap_t emm_sap;
emm_sap.primitive = EMMREG_COMMON_PROC_REJ;
emm_sap.u.emm_reg.ueid = ueid;
......@@ -642,17 +639,13 @@ int _security_request(security_data_t *data, int is_new)
emm_sap.u.emm_as.u.security.selected_eia = data->selected_eia;
#if defined(NAS_BUILT_IN_EPC)
if (data->ueid > 0) {
emm_ctx = emm_data_context_get(&_emm_data, data->ueid);
}
#else
if (data->ueid < EMM_DATA_NB_UE_MAX) {
emm_ctx = _emm_data.ctx[data->ueid];
}
#endif
/* Setup EPS NAS security data */
......@@ -662,22 +655,22 @@ int _security_request(security_data_t *data, int is_new)
MSC_NAS_EMM_MME,
MSC_NAS_EMM_MME,
NULL,0,
"0 EMMAS_SECURITY_REQ ue id %06x", data->ueid);
"0 EMMAS_SECURITY_REQ ue id "NAS_UE_ID_FMT" ", data->ueid);
rc = emm_sap_send(&emm_sap);
if (rc != RETURNerror) {
if (T3460.id != NAS_TIMER_INACTIVE_ID) {
if (emm_ctx->T3460.id != NAS_TIMER_INACTIVE_ID) {
/* Re-start T3460 timer */
T3460.id = nas_timer_restart(T3460.id);
emm_ctx->T3460.id = nas_timer_restart(emm_ctx->T3460.id);
MSC_LOG_EVENT(MSC_NAS_EMM_MME, "0 T3460 restarted UE "NAS_UE_ID_FMT" ", data->ueid);
} else {
/* Start T3460 timer */
T3460.id = nas_timer_start(T3460.sec, _security_t3460_handler, data);
emm_ctx->T3460.id = nas_timer_start(emm_ctx->T3460.sec, _security_t3460_handler, data);
MSC_LOG_EVENT(MSC_NAS_EMM_MME, "0 T3460 started UE "NAS_UE_ID_FMT" ", data->ueid);
}
LOG_TRACE(INFO,"EMM-PROC - Timer T3460 (%d) expires in %ld seconds",
T3460.id, T3460.sec);
emm_ctx->T3460.id, emm_ctx->T3460.sec);
}
LOG_FUNC_RETURN (rc);
}
......@@ -700,6 +693,7 @@ static int _security_abort(void *args)
{
LOG_FUNC_IN;
struct emm_data_context_s *emm_ctx = NULL;
int rc = RETURNerror;
security_data_t *data = (security_data_t *)(args);
......@@ -709,12 +703,21 @@ static int _security_abort(void *args)
int notify_failure = data->notify_failure;
LOG_TRACE(WARNING, "EMM-PROC - Abort security mode control procedure "
"(ueid=%u)", ueid);
"(ueid="NAS_UE_ID_FMT")", ueid);
#if defined(NAS_BUILT_IN_EPC)
if (data->ueid > 0) {
emm_ctx = emm_data_context_get(&_emm_data, data->ueid);
}
#else
if (data->ueid < EMM_DATA_NB_UE_MAX) {
emm_ctx = _emm_data.ctx[data->ueid];
}
#endif
/* Stop timer T3460 */
if (T3460.id != NAS_TIMER_INACTIVE_ID) {
LOG_TRACE(INFO, "EMM-PROC - Stop timer T3460 (%d)", T3460.id);
T3460.id = nas_timer_stop(T3460.id);
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" ", ueid);
}
/* Release retransmission timer paramaters */
......@@ -728,7 +731,7 @@ static int _security_abort(void *args)
MSC_NAS_EMM_MME,
MSC_NAS_EMM_MME,
NULL,0,
"0 EMMREG_COMMON_PROC_REJ ue id %06x (security abort)", data->ueid);
"0 EMMREG_COMMON_PROC_REJ ue id "NAS_UE_ID_FMT" (security abort)", data->ueid);
emm_sap_t emm_sap;
emm_sap.primitive = EMMREG_COMMON_PROC_REJ;
emm_sap.u.emm_reg.ueid = ueid;
......
......@@ -158,7 +158,7 @@ static int _emm_tracking_area_update_reject(void *args)
if (emm_ctx) {
emm_sap_t emm_sap;
LOG_TRACE(WARNING, "EMM-PROC - EMM tracking area update 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 Tracking Area Update Reject message has to be sent
......
......@@ -110,22 +110,22 @@ typedef struct emm_security_context_s {
OctetString knas_enc; /* NAS cyphering key */
OctetString knas_int; /* NAS integrity key */
struct count_s{
UInt32_t spare:8;
UInt32_t overflow:16;
UInt32_t seq_num:8;
uint32_t spare:8;
uint32_t overflow:16;
uint32_t seq_num:8;
} dl_count, ul_count; /* Downlink and uplink count parameters */
struct {
UInt8_t eps_encryption; /* algorithm used for ciphering */
UInt8_t eps_integrity; /* algorithm used for integrity protection */
UInt8_t umts_encryption; /* algorithm used for ciphering */
UInt8_t umts_integrity; /* algorithm used for integrity protection */
UInt8_t gprs_encryption; /* algorithm used for ciphering */
UInt8_t umts_present:1;
UInt8_t gprs_present:1;
uint8_t eps_encryption; /* algorithm used for ciphering */
uint8_t eps_integrity; /* algorithm used for integrity protection */
uint8_t umts_encryption; /* algorithm used for ciphering */
uint8_t umts_integrity; /* algorithm used for integrity protection */
uint8_t gprs_encryption; /* algorithm used for ciphering */
uint8_t umts_present:1;
uint8_t gprs_present:1;
} capability; /* UE network capability */
struct {
UInt8_t encryption:4; /* algorithm used for ciphering */
UInt8_t integrity:4; /* algorithm used for integrity protection */
uint8_t encryption:4; /* algorithm used for ciphering */
uint8_t integrity:4; /* algorithm used for integrity protection */
} selected_algorithms; /* MME selected algorithms */
} emm_security_context_t;
......@@ -181,6 +181,10 @@ typedef struct emm_data_context_s {
emm_fsm_state_t _emm_fsm_status;
struct nas_timer_t T3450; /* EMM message retransmission timer */
struct nas_timer_t T3460; /* Authentication timer */
struct nas_timer_t T3470; /* Identification timer */
esm_data_context_t esm_data_ctx;
} emm_data_context_t;
......@@ -240,10 +244,6 @@ emm_data_t _emm_data;
#define T3460_DEFAULT_VALUE 6 /* 6 seconds */
#define T3470_DEFAULT_VALUE 6 /* 6 seconds */
struct nas_timer_t T3450; /* EMM message retransmission timer */
struct nas_timer_t T3460; /* Authentication timer */
struct nas_timer_t T3470; /* Identification timer */
/*
* mobile reachable timer
* ----------------------
......
......@@ -80,13 +80,13 @@ struct emm_data_context_s *emm_data_context_get(
struct emm_data_context_s *emm_data_context_remove(
emm_data_t *emm_data, struct emm_data_context_s *elm)
{
LOG_TRACE(INFO, "EMM-CTX - Remove in context %p UE id %u", elm, elm->ueid);
LOG_TRACE(INFO, "EMM-CTX - Remove in context %p UE id "NAS_UE_ID_FMT" ", elm, elm->ueid);
return RB_REMOVE(emm_data_context_map, &emm_data->ctx_map, elm);
}
void emm_data_context_add(emm_data_t *emm_data, struct emm_data_context_s *elm)
{
LOG_TRACE(INFO, "EMM-CTX - Add in context %p UE id %u", elm, elm->ueid);
LOG_TRACE(INFO, "EMM-CTX - Add in context %p UE id "NAS_UE_ID_FMT" ", elm, elm->ueid);
RB_INSERT(emm_data_context_map, &emm_data->ctx_map, elm);
}
......@@ -97,7 +97,7 @@ void emm_data_context_dump(struct emm_data_context_s *elm_pP)
char guti_str[22];
int k, size, remaining_size;
char key_string[KASME_LENGTH_OCTETS*2];
LOG_TRACE(INFO, "EMM-CTX: ue id: 0x%06"PRIX32" (UE identifier)", elm_pP->ueid);
LOG_TRACE(INFO, "EMM-CTX: ue id: "NAS_UE_ID_FMT" (UE identifier)", elm_pP->ueid);
LOG_TRACE(INFO, " is_dynamic: %u (Dynamically allocated context indicator)", elm_pP->is_dynamic);
LOG_TRACE(INFO, " is_attached: %u (Attachment indicator)", elm_pP->is_attached);
LOG_TRACE(INFO, " is_emergency: %u (Emergency bearer services indicator)", elm_pP->is_emergency);
......
......@@ -104,16 +104,6 @@ void emm_main_initialize(void)
RB_INIT(&_emm_data.ctx_map);
#endif
/*
* Initialize EMM timers
*/
T3450.id = NAS_TIMER_INACTIVE_ID;
T3450.sec = T3450_DEFAULT_VALUE;
T3460.id = NAS_TIMER_INACTIVE_ID;
T3460.sec = T3460_DEFAULT_VALUE;
T3470.id = NAS_TIMER_INACTIVE_ID;
T3470.sec = T3470_DEFAULT_VALUE;
LOG_FUNC_OUT;
}
......
......@@ -156,7 +156,7 @@ int emm_proc_identification(unsigned int ueid,
emm_common_reject_callback_t reject,
emm_common_failure_callback_t failure);
int emm_proc_identification_complete(unsigned int ueid, const imsi_t *imsi,
const imei_t *imei, UInt32_t *tmsi);
const imei_t *imei, uint32_t *tmsi);
/*
* --------------------------------------------------------------------------
......
......@@ -134,7 +134,7 @@ int esm_proc_dedicated_eps_bearer_context(emm_data_context_t *ctx, int pid,
LOG_FUNC_IN;
LOG_TRACE(INFO, "ESM-PROC - Dedicated EPS bearer context activation "
"(ueid=%u, pid=%d)", ctx->ueid, pid);
"(ueid="NAS_UE_ID_FMT", pid=%d)", ctx->ueid, pid);
/* Assign new EPS bearer context */
*ebi = esm_ebr_assign(ctx, ESM_EBI_UNASSIGNED);
......@@ -194,7 +194,7 @@ int esm_proc_dedicated_eps_bearer_context_request(int is_standalone,
int rc = RETURNok;
LOG_TRACE(INFO,"ESM-PROC - Initiate dedicated EPS bearer context "
"activation (ueid=%d, ebi=%d)", ctx->ueid, ebi);
"activation (ueid="NAS_UE_ID_FMT", ebi=%d)", ctx->ueid, ebi);
/* Send activate dedicated EPS bearer context request message and
* start timer T3485 */
......@@ -244,7 +244,7 @@ int esm_proc_dedicated_eps_bearer_context_accept(emm_data_context_t *ctx, int eb
int rc;
LOG_TRACE(INFO, "ESM-PROC - Dedicated EPS bearer context activation "
"accepted by the UE (ueid=%u, ebi=%d)", ctx->ueid, ebi);
"accepted by the UE (ueid="NAS_UE_ID_FMT", ebi=%d)", ctx->ueid, ebi);
/* Stop T3485 timer */
rc = esm_ebr_stop_timer(ctx, ebi);
......@@ -297,7 +297,7 @@ int esm_proc_dedicated_eps_bearer_context_reject(emm_data_context_t *ctx, int eb
LOG_FUNC_IN;
LOG_TRACE(WARNING, "ESM-PROC - Dedicated EPS bearer context activation "
"not accepted by the UE (ueid=%u, ebi=%d)", ctx->ueid, ebi);
"not accepted by the UE (ueid="NAS_UE_ID_FMT", ebi=%d)", ctx->ueid, ebi);
/* Stop T3485 timer if running */
rc = esm_ebr_stop_timer(ctx, ebi);
......@@ -362,7 +362,7 @@ static void *_dedicated_eps_bearer_activate_t3485_handler(void *args)
/* Increment the retransmission counter */
data->count += 1;
LOG_TRACE(WARNING, "ESM-PROC - T3485 timer expired (ueid=%d, ebi=%d), "
LOG_TRACE(WARNING, "ESM-PROC - T3485 timer expired (ueid="NAS_UE_ID_FMT", ebi=%d), "
"retransmission counter = %d",
data->ueid, data->ebi, data->count);
......
......@@ -126,7 +126,7 @@ int esm_proc_default_eps_bearer_context(emm_data_context_t *ctx, int pid,
LOG_FUNC_IN;
LOG_TRACE(INFO, "ESM-PROC - Default EPS bearer context activation "
"(ueid=%u, pid=%d, GBR UL %u GBR DL %u, MBR UL %u MBR DL %u QCI %u)",
"(ueid="NAS_UE_ID_FMT", pid=%d, GBR UL %u GBR DL %u, MBR UL %u MBR DL %u QCI %u)",
ctx->ueid,
pid,
qos->gbrUL,
......@@ -200,11 +200,11 @@ int esm_proc_default_eps_bearer_context_request(int is_standalone,
/* Send activate default EPS bearer context request message and
* start timer T3485 */
LOG_TRACE(INFO,"ESM-PROC - Initiate standalone default EPS bearer context activation "
"(ueid=%u, ebi=%d)", ctx->ueid, ebi);
"(ueid="NAS_UE_ID_FMT", ebi=%d)", ctx->ueid, ebi);
rc = _default_eps_bearer_activate(ctx, ebi, msg);
} else {
LOG_TRACE(INFO,"ESM-PROC - Initiate non standalone default EPS bearer context activation "
"(ueid=%u, ebi=%d)", ctx->ueid, ebi);
"(ueid="NAS_UE_ID_FMT", ebi=%d)", ctx->ueid, ebi);
}
if (rc != RETURNerror) {
......@@ -251,7 +251,7 @@ int esm_proc_default_eps_bearer_context_accept(emm_data_context_t *ctx, int ebi,
int rc;
LOG_TRACE(INFO, "ESM-PROC - Default EPS bearer context activation "
"accepted by the UE (ueid=%u, ebi=%d)", ctx->ueid, ebi);
"accepted by the UE (ueid="NAS_UE_ID_FMT", ebi=%d)", ctx->ueid, ebi);
/* Stop T3485 timer if running */
rc = esm_ebr_stop_timer(ctx, ebi);
......@@ -300,7 +300,7 @@ int esm_proc_default_eps_bearer_context_reject(emm_data_context_t *ctx, int ebi,
int rc;
LOG_TRACE(WARNING, "ESM-PROC - Default EPS bearer context activation "
"not accepted by the UE (ueid=%u, ebi=%d)", ctx->ueid, ebi);
"not accepted by the UE (ueid="NAS_UE_ID_FMT", ebi=%d)", ctx->ueid, ebi);
/* Stop T3485 timer if running */
rc = esm_ebr_stop_timer(ctx, ebi);
......@@ -352,7 +352,7 @@ int esm_proc_default_eps_bearer_context_failure(emm_data_context_t *ctx)
LOG_FUNC_IN;
LOG_TRACE(WARNING, "ESM-PROC - Default EPS bearer context activation "
"failure (ueid=%u)", ctx->ueid);
"failure (ueid="NAS_UE_ID_FMT")", ctx->ueid);
/* Get the EPS bearer identity of the EPS bearer context which is still
* pending in the active pending state */
......@@ -417,7 +417,7 @@ static void *_default_eps_bearer_activate_t3485_handler(void *args)
/* Increment the retransmission counter */
data->count += 1;
LOG_TRACE(WARNING, "ESM-PROC - T3485 timer expired (ueid=%d, ebi=%d), "
LOG_TRACE(WARNING, "ESM-PROC - T3485 timer expired (ueid="NAS_UE_ID_FMT", ebi=%d), "
"retransmission counter = %d",
data->ueid, data->ebi, data->count);
......
......@@ -164,7 +164,7 @@ int esm_proc_eps_bearer_context_deactivate(emm_data_context_t *ctx, int is_local
}
LOG_TRACE(INFO, "ESM-PROC - EPS bearer context deactivation "
"(ueid=%u, ebi=%d)", ctx->ueid, ebi);
"(ueid="NAS_UE_ID_FMT", ebi=%d)", ctx->ueid, ebi);
if ((ctx != NULL) &&
(*pid < ESM_DATA_PDN_MAX) ) {
......@@ -234,7 +234,7 @@ int esm_proc_eps_bearer_context_deactivate_request(int is_standalone,
int rc;
LOG_TRACE(INFO,"ESM-PROC - Initiate EPS bearer context deactivation "
"(ueid=%d, ebi=%d)", ctx->ueid, ebi);
"(ueid="NAS_UE_ID_FMT", ebi=%d)", ctx->ueid, ebi);
/* Send deactivate EPS bearer context request message and
* start timer T3495 */
......@@ -288,7 +288,7 @@ int esm_proc_eps_bearer_context_deactivate_accept(emm_data_context_t *ctx, int e
int pid = RETURNerror;
LOG_TRACE(INFO, "ESM-PROC - EPS bearer context deactivation "
"accepted by the UE (ueid=%u, ebi=%d)", ctx->ueid, ebi);
"accepted by the UE (ueid="NAS_UE_ID_FMT", ebi=%d)", ctx->ueid, ebi);
/* Stop T3495 timer if running */
rc = esm_ebr_stop_timer(ctx, ebi);
......@@ -353,7 +353,7 @@ static void *_eps_bearer_deactivate_t3495_handler(void *args)
/* Increment the retransmission counter */
data->count += 1;
LOG_TRACE(WARNING, "ESM-PROC - T3495 timer expired (ueid=%d, ebi=%d), "
LOG_TRACE(WARNING, "ESM-PROC - T3495 timer expired (ueid="NAS_UE_ID_FMT", ebi=%d), "
"retransmission counter = %d",
data->ueid, data->ebi, data->count);
......
......@@ -162,7 +162,7 @@ int esm_proc_pdn_connectivity_request(emm_data_context_t *ctx, int pti,
LOG_FUNC_IN;
LOG_TRACE(INFO, "ESM-PROC - PDN connectivity requested by the UE "
"(ueid=%u, pti=%d) PDN type = %s, APN = %s pdn addr = %s", ctx->ueid, pti,
"(ueid="NAS_UE_ID_FMT", pti=%d) PDN type = %s, APN = %s pdn addr = %s", ctx->ueid, pti,
(pdn_type == ESM_PDN_TYPE_IPV4)? "IPv4" :
(pdn_type == ESM_PDN_TYPE_IPV6)? "IPv6" : "IPv4v6",
(apn) ? (char *)(apn->value) : "null",
......@@ -323,7 +323,7 @@ int esm_proc_pdn_connectivity_reject(int is_standalone, emm_data_context_t *ctx,
int rc = RETURNerror;
LOG_TRACE(WARNING, "ESM-PROC - PDN connectivity not accepted by the "
"network (ueid=%d)", ctx->ueid);
"network (ueid="NAS_UE_ID_FMT")", ctx->ueid);
if (is_standalone) {
emm_sap_t emm_sap;
......@@ -371,7 +371,7 @@ int esm_proc_pdn_connectivity_failure(emm_data_context_t *ctx, int pid)
LOG_FUNC_IN;
LOG_TRACE(WARNING, "ESM-PROC - PDN connectivity failure (ueid=%u, pid=%d)",
LOG_TRACE(WARNING, "ESM-PROC - PDN connectivity failure (ueid="NAS_UE_ID_FMT", pid=%d)",
ctx->ueid, pid);
/* Delete the PDN connection entry */
......@@ -426,7 +426,7 @@ static int _pdn_connectivity_create(emm_data_context_t *ctx,
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,
"(pti=%d) APN = %s, IP address = %s (ueid="NAS_UE_ID_FMT")", 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), ctx->ueid);
......
......@@ -123,7 +123,7 @@ int esm_proc_pdn_disconnect_request(emm_data_context_t *ctx, int pti, int *esm_c
LOG_FUNC_IN;
LOG_TRACE(INFO, "ESM-PROC - PDN disconnect requested by the UE "
"(ueid=%d, pti=%d)", ctx->ueid, pti);
"(ueid="NAS_UE_ID_FMT", pti=%d)", ctx->ueid, pti);
/* Get UE's ESM context */
if (ctx->esm_data_ctx.n_pdns > 1) {
......@@ -173,7 +173,7 @@ int esm_proc_pdn_disconnect_accept(emm_data_context_t *ctx, int pid, int *esm_ca
LOG_FUNC_IN;
LOG_TRACE(INFO, "ESM-PROC - PDN disconnect accepted by the UE "
"(ueid=%d, pid=%d)", ctx->ueid, pid);
"(ueid="NAS_UE_ID_FMT", pid=%d)", ctx->ueid, pid);
/* Release the connectivity with the requested PDN */
int rc = mme_api_unsubscribe(NULL);
......@@ -225,7 +225,7 @@ int esm_proc_pdn_disconnect_reject(int is_standalone, emm_data_context_t *ctx,
emm_sap_t emm_sap;
LOG_TRACE(WARNING, "ESM-PROC - PDN disconnect not accepted by the network "
"(ueid=%d)", ctx->ueid);
"(ueid="NAS_UE_ID_FMT")", ctx->ueid);
/*
* Notity EMM that ESM PDU has to be forwarded to lower layers
......
......@@ -53,6 +53,7 @@ Description Defines functions used to handle state of EPS bearer contexts
#include "nas_log.h"
#include "mme_api.h"
#include "msc.h"
/****************************************************************************/
/**************** E X T E R N A L D E F I N I T I O N S ****************/
......@@ -268,6 +269,7 @@ int esm_ebr_release(
LOG_TRACE(INFO, "ESM-FSM - Stop retransmission timer %d",
ebr_ctx->timer.id);
ebr_ctx->timer.id = nas_timer_stop(ebr_ctx->timer.id);
MSC_LOG_EVENT(MSC_NAS_ESM_MME, "0 Timer %x ebi %u stopped",ebr_ctx->timer.id, ebi);
}
/* Release the retransmisison timer parameters */
......@@ -335,6 +337,7 @@ int esm_ebr_start_timer(emm_data_context_t *ctx, int ebi, const OctetString *msg
if (ebr_ctx->args) {
/* Re-start the retransmission timer */
ebr_ctx->timer.id = nas_timer_restart(ebr_ctx->timer.id);
MSC_LOG_EVENT(MSC_NAS_ESM_MME, "0 Timer %x ebi %u restarted",ebr_ctx->timer.id, ebi);
}
} else {
/* Setup the retransmission timer parameters */
......@@ -359,6 +362,7 @@ int esm_ebr_start_timer(emm_data_context_t *ctx, int ebi, const OctetString *msg
/* Setup the retransmission timer to expire at the given
* time interval */
ebr_ctx->timer.id = nas_timer_start(sec, cb, ebr_ctx->args);
MSC_LOG_EVENT(MSC_NAS_ESM_MME, "0 Timer %x ebi %u started",ebr_ctx->timer.id, ebi);
ebr_ctx->timer.sec = sec;
}
}
......@@ -415,6 +419,7 @@ int esm_ebr_stop_timer(emm_data_context_t *ctx, int ebi)
LOG_TRACE(INFO, "ESM-FSM - Stop retransmission timer %d",
ebr_ctx->timer.id);
ebr_ctx->timer.id = nas_timer_stop(ebr_ctx->timer.id);
MSC_LOG_EVENT(MSC_NAS_ESM_MME, "0 Timer %x ebi %u stopped",ebr_ctx->timer.id, ebi);
}
/* Release the retransmisison timer parameters */
......@@ -526,13 +531,18 @@ int esm_ebr_set_status(
old_status = ebr_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) {
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]);
MSC_LOG_EVENT(MSC_NAS_ESM_MME, "0 ESM state %s => %s "NAS_UE_ID_FMT" ",
_esm_ebr_state_str[old_status], _esm_ebr_state_str[status], ctx->ueid);
ebr_ctx->status = status;
LOG_FUNC_RETURN (RETURNok);
} else {
LOG_TRACE(INFO, "ESM-FSM - Status of EPS bearer context %d unchanged:"
" %s ", ebi, _esm_ebr_state_str[status]);
}
}
......
......@@ -37,7 +37,7 @@
#if defined(NAS_BUILT_IN_EPC)
static const UInt8_t emm_message_ids[] = {
static const uint8_t emm_message_ids[] = {
ATTACH_REQUEST,
ATTACH_ACCEPT,
ATTACH_COMPLETE,
......@@ -69,7 +69,7 @@ static const UInt8_t emm_message_ids[] = {
CS_SERVICE_NOTIFICATION,
};
static const UInt8_t esm_message_ids[] = {
static const uint8_t esm_message_ids[] = {
ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST,
ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_ACCEPT,
ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REJECT,
......@@ -94,7 +94,7 @@ static const UInt8_t esm_message_ids[] = {
ESM_STATUS,
};
static int _nas_find_message_index(const UInt8_t message_id, const UInt8_t *message_ids, const int ids_number)
static int _nas_find_message_index(const uint8_t message_id, const uint8_t *message_ids, const int ids_number)
{
int i;
......@@ -201,7 +201,7 @@ int nas_itti_dl_data_req(const uint32_t ue_id, void *const data,
MSC_NAS_MME,
MSC_S1AP_MME,
NULL,0,
"0 NAS_DOWNLINK_DATA_REQ ue id %06"PRIX32" len %u", ue_id, length);
"0 NAS_DOWNLINK_DATA_REQ ue id "NAS_UE_ID_FMT" len %u", ue_id, length);
return itti_send_msg_to_task(TASK_S1AP, INSTANCE_DEFAULT, message_p);
}
......
......@@ -165,8 +165,8 @@ void nas_proc_cleanup(void)
** Others: None **
** **
***************************************************************************/
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)
{
LOG_FUNC_IN;
......@@ -179,7 +179,7 @@ int nas_proc_establish_ind(UInt32_t ueid, tac_t tac,
MSC_NAS_MME,
MSC_NAS_EMM_MME,
NULL,0,
"0 EMMAS_ESTABLISH_REQ ue id %06"PRIX32" tac %u", ueid, tac);
"0 EMMAS_ESTABLISH_REQ ue id "NAS_UE_ID_FMT" tac %u", ueid, tac);
/*
* Notify the EMM procedure call manager that NAS signalling
* connection establishment indication message has been received
......@@ -211,7 +211,7 @@ int nas_proc_establish_ind(UInt32_t ueid, tac_t tac,
** Others: None **
** **
***************************************************************************/
int nas_proc_dl_transfer_cnf(UInt32_t ueid)
int nas_proc_dl_transfer_cnf(uint32_t ueid)
{
LOG_FUNC_IN;
......@@ -222,7 +222,7 @@ int nas_proc_dl_transfer_cnf(UInt32_t ueid)
MSC_NAS_MME,
MSC_NAS_EMM_MME,
NULL,0,
"0 EMMAS_DATA_IND dl_transfer_conf ue id %06"PRIX32"", ueid);
"0 EMMAS_DATA_IND dl_transfer_conf ue id "NAS_UE_ID_FMT" ", ueid);
/*
* Notify the EMM procedure call manager that downlink NAS message
......@@ -254,7 +254,7 @@ int nas_proc_dl_transfer_cnf(UInt32_t ueid)
** Others: None **
** **
***************************************************************************/
int nas_proc_dl_transfer_rej(UInt32_t ueid)
int nas_proc_dl_transfer_rej(uint32_t ueid)
{
LOG_FUNC_IN;
......@@ -265,7 +265,7 @@ int nas_proc_dl_transfer_rej(UInt32_t ueid)
MSC_NAS_MME,
MSC_NAS_EMM_MME,
NULL,0,
"0 EMMAS_DATA_IND dl_transfer_reject ue id %06"PRIX32"", ueid);
"0 EMMAS_DATA_IND dl_transfer_reject ue id "NAS_UE_ID_FMT" ", ueid);
/*
* Notify the EMM procedure call manager that transmission
......@@ -298,7 +298,7 @@ int nas_proc_dl_transfer_rej(UInt32_t ueid)
** Others: None **
** **
***************************************************************************/
int nas_proc_ul_transfer_ind(UInt32_t ueid, const Byte_t *data, UInt32_t len)
int nas_proc_ul_transfer_ind(uint32_t ueid, const Byte_t *data, uint32_t len)
{
int rc = RETURNerror;
......@@ -314,7 +314,7 @@ int nas_proc_ul_transfer_ind(UInt32_t ueid, const Byte_t *data, UInt32_t len)
MSC_NAS_MME,
MSC_NAS_EMM_MME,
NULL,0,
"0 EMMAS_DATA_IND ue id %06"PRIX32" len %u", ueid, len);
"0 EMMAS_DATA_IND ue id "NAS_UE_ID_FMT" len %u", ueid, len);
emm_sap.primitive = EMMAS_DATA_IND;
emm_sap.u.emm_as.u.data.ueid = ueid;
......@@ -370,7 +370,7 @@ int nas_proc_auth_param_fail(emm_cn_auth_fail_t *emm_cn_auth_fail)
LOG_FUNC_RETURN (rc);
}
int nas_proc_deregister_ue(UInt32_t ue_id)
int nas_proc_deregister_ue(uint32_t ue_id)
{
int rc = RETURNerror;
emm_sap_t emm_sap;
......@@ -381,7 +381,7 @@ int nas_proc_deregister_ue(UInt32_t ue_id)
MSC_NAS_MME,
MSC_NAS_EMM_MME,
NULL,0,
"0 EMMCN_DEREGISTER_UE ue_id %06"PRIX32"",ue_id);
"0 EMMCN_DEREGISTER_UE ue_id "NAS_UE_ID_FMT" ",ue_id);
emm_sap.primitive = EMMCN_DEREGISTER_UE;
emm_sap.u.emm_cn.u.deregister.UEid = ue_id;
......
......@@ -93,12 +93,12 @@ void nas_proc_cleanup(void);
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_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);
/*
* --------------------------------------------------------------------------
......@@ -108,7 +108,7 @@ int nas_proc_ul_transfer_ind(UInt32_t ueid, const Byte_t *data, UInt32_t len);
#if defined(NAS_BUILT_IN_EPC)
int nas_proc_auth_param_res(emm_cn_auth_res_t *emm_cn_auth_res);
int nas_proc_auth_param_fail(emm_cn_auth_fail_t *emm_cn_auth_fail);
int nas_proc_deregister_ue(UInt32_t ue_id);
int nas_proc_deregister_ue(uint32_t ue_id);
int nas_proc_pdn_connectivity_res(nas_pdn_connectivity_rsp_t *nas_pdn_connectivity_rsp);
int nas_proc_pdn_connectivity_fail(nas_pdn_connectivity_fail_t *nas_pdn_connectivity_fail);
#endif
......
......@@ -57,12 +57,12 @@ Description Implements the Access-Stratum simulator operating between
/*
* Direction of the message to be transfered to the UE NAS process
*/
static UInt8_t _as_simulator_ue_transfer = AS_SIMULATOR_NO_TRANSFER;
static uint8_t _as_simulator_ue_transfer = AS_SIMULATOR_NO_TRANSFER;
/*
* Direction of the message to be transfered to the MME NAS process
*/
static UInt8_t _as_simulator_mme_transfer = AS_SIMULATOR_NO_TRANSFER;
static uint8_t _as_simulator_mme_transfer = AS_SIMULATOR_NO_TRANSFER;
/*
* Size of the message to be transfered to the UE NAS process
......
......@@ -515,9 +515,9 @@ static void _display_usim_data(const usim_data_t* data)
memcpy(kasme, data->securityctx.Kasme.value, USIM_K_ASME_SIZE);
printf("\tKasme\t: \"%s\"\n", kasme);
printf("\tulNAScount\t: 0x%.8x\n",
*(UInt32_t*)data->securityctx.ulNAScount.value);
*(uint32_t*)data->securityctx.ulNAScount.value);
printf("\tdlNAScount\t: 0x%.8x\n",
*(UInt32_t*)data->securityctx.dlNAScount.value);
*(uint32_t*)data->securityctx.dlNAScount.value);
printf("\talgorithmID\t: 0x%.2x\n\n",
data->securityctx.algorithmID.value[0]);
......
......@@ -90,7 +90,7 @@ typedef struct {
* has activated or desactivated a PDN connection
*/
typedef struct {
UInt8_t cid; /* PDN connection identifier */
uint8_t cid; /* PDN connection identifier */
network_pdn_state_t status; /* PDN connection status */
} user_ind_pdn_t;
......
......@@ -79,7 +79,7 @@ Description Implements the API used by the NAS layer to read/write
#define USIM_API_K_SIZE 16
#define USIM_API_K_VALUE "8BAF473F2F8FD09487CCCBD7097C6862"
static UInt8_t _usim_api_k[USIM_API_K_SIZE];
static uint8_t _usim_api_k[USIM_API_K_SIZE];
/*
......@@ -87,16 +87,16 @@ static UInt8_t _usim_api_k[USIM_API_K_SIZE];
*/
static struct _usim_api_data_s {
/* Highest sequence number the USIM has ever accepted */
UInt32_t sqn_ms;
uint32_t sqn_ms;
/* List of the last used sequence numbers */
#define USIM_API_SQN_LIST_SIZE 32
UInt8_t n_sqns;
UInt32_t sqn[USIM_API_SQN_LIST_SIZE];
uint8_t n_sqns;
uint32_t sqn[USIM_API_SQN_LIST_SIZE];
} _usim_api_data;
static UInt8_t _usim_api_hex_char_to_hex_value (char c);
static void _usim_api_hex_string_to_hex_value (UInt8_t *hex_value, const char *hex_string, int size);
static int _usim_api_check_sqn(UInt32_t seq, UInt8_t ind);
static uint8_t _usim_api_hex_char_to_hex_value (char c);
static void _usim_api_hex_string_to_hex_value (uint8_t *hex_value, const char *hex_string, int size);
static int _usim_api_check_sqn(uint32_t seq, uint8_t ind);
/****************************************************************************/
/****************** E X P O R T E D F U N C T I O N S ******************/
......@@ -274,7 +274,7 @@ int usim_api_authenticate(const OctetString* rand_pP, const OctetString* autn_pP
}
/* Verify that the received sequence number SQN is in the correct range */
rc = _usim_api_check_sqn(*(UInt32_t*)(sqn), sqn[USIM_API_SQN_SIZE - 1]);
rc = _usim_api_check_sqn(*(uint32_t*)(sqn), sqn[USIM_API_SQN_SIZE - 1]);
if (rc != RETURNok) {
/* Synchronisation failure; compute the AUTS parameter */
......@@ -291,7 +291,7 @@ int usim_api_authenticate(const OctetString* rand_pP, const OctetString* autn_pP
for (i = 0; i < USIM_API_SQN_MS_SIZE; i++) {
#warning "LG:BUG HERE TODO"
sqn_ms[USIM_API_SQNMS_SIZE - i] =
((UInt8_t*)(_usim_api_data.sqn_ms))[USIM_API_SQN_MS_SIZE - i];
((uint8_t*)(_usim_api_data.sqn_ms))[USIM_API_SQN_MS_SIZE - i];
}
u8 sqnms[USIM_API_SQNMS_SIZE];
......@@ -340,7 +340,7 @@ int usim_api_authenticate(const OctetString* rand_pP, const OctetString* autn_pP
** Others: None **
** **
***************************************************************************/
static UInt8_t _usim_api_hex_char_to_hex_value (char c)
static uint8_t _usim_api_hex_char_to_hex_value (char c)
{
if (c >= 'A') {
/* Remove case bit */
......@@ -368,7 +368,7 @@ static UInt8_t _usim_api_hex_char_to_hex_value (char c)
** Others: None **
** **
***************************************************************************/
static void _usim_api_hex_string_to_hex_value (UInt8_t *hex_value, const char *hex_string, int size)
static void _usim_api_hex_string_to_hex_value (uint8_t *hex_value, const char *hex_string, int size)
{
int i;
......@@ -396,7 +396,7 @@ static void _usim_api_hex_string_to_hex_value (UInt8_t *hex_value, const char *h
** Others: None **
** **
***************************************************************************/
static int _usim_api_check_sqn(UInt32_t seq, UInt8_t ind)
static int _usim_api_check_sqn(uint32_t seq, uint8_t ind)
{
/* TODO */
return (RETURNok);
......
......@@ -63,7 +63,7 @@ Description Implements the API used by the NAS layer to read/write
* USIM TLV parameter structure
* ----------------------------
*/
#define USIM_TLV_T(SIZE) struct {UInt8_t type; UInt8_t length; Byte_t value[SIZE];}
#define USIM_TLV_T(SIZE) struct {uint8_t type; uint8_t length; Byte_t value[SIZE];}
/*
* Non Access Stratum Configuration
......@@ -123,7 +123,7 @@ typedef struct {
typedef struct {
/* Length of all subsequent data */
#define USIM_EPS_NAS_SECURITY_CONTEXT_TAG 0xA0U
UInt8_t length;
uint8_t length;
/* Key set identifier KSI_ASME */
#define USIM_KSI_ASME_TAG 0x80U
USIM_TLV_T(1) KSIasme;
......@@ -197,7 +197,7 @@ typedef struct {
tac_t start;
tac_t end;
/* PLMN Network Name Record Identifier */
UInt8_t record_id;
uint8_t record_id;
} usim_opl_t;
/*
......@@ -212,7 +212,7 @@ typedef struct {
#define USIM_ACT_CDMA_1xRTT 0x1000
#define USIM_ACT_UTRAN 0x0080
#define USIM_ACT_EUTRAN 0x0040
UInt16_t AcT;
uint16_t AcT;
} usim_plmn_act_t;
/*
......@@ -220,7 +220,7 @@ typedef struct {
* ------------------------------
*/
typedef struct {
UInt32_t tmsi; /* Temporary Mobile Subscriber Identity */
uint32_t tmsi; /* Temporary Mobile Subscriber Identity */
lai_t lai; /* Location Area Identity */
Byte_t reserved; /* Reserved for future use */
#define USIM_LOCI_UPDATED 0x00
......@@ -235,7 +235,7 @@ typedef struct {
* ----------------------------------------------
*/
typedef struct {
UInt32_t p_tmsi; /* Packet Temporary Mobile Subscriber Identity */
uint32_t p_tmsi; /* Packet Temporary Mobile Subscriber Identity */
Byte_t signature[3]; /* P-TMSI signature value */
RAI_t rai; /* Routing Area Identity */
#define USIM_PSLOCI_UPDATED 0x00
......@@ -280,7 +280,7 @@ typedef struct {
#define USIM_MAINTENANCE_MODE 0x02U
#define USIM_CELL_TEST_MODE 0x04U
Byte_t UE_Operation_Mode; /* Mode of operation for the UE */
UInt16_t Additional_Info; /* Additional information depending on
uint16_t Additional_Info; /* Additional information depending on
* the UE operation mode */
Byte_t MNC_Length; /* Number of digits used for extracting
* the MNC from the IMSI */
......
......@@ -945,16 +945,16 @@ static int _authentication_kasme(const OctetString *autn,
kasme->length);
/* Compute the derivation key KEY = CK || IK */
UInt8_t key[ck->length + ik->length];
uint8_t key[ck->length + ik->length];
memcpy(key, ck->value, ck->length);
memcpy(key + ck->length, ik->value, ik->length);
/* Compute the KDF input_s parameter
* S = FC(0x10) || SNid(MCC, MNC) || 0x00 0x03 || SQN ⊕ AK || 0x00 0x06
*/
UInt8_t input_s[16]; // less than 16
UInt8_t sn_id[AUTH_SNID_SIZE]; // less than 16
UInt16_t length;
uint8_t input_s[16]; // less than 16
uint8_t sn_id[AUTH_SNID_SIZE]; // less than 16
uint16_t length;
int offset = 0;
int size_of_length = sizeof(length);
......
......@@ -453,7 +453,7 @@ void emm_as_set_security_data(emm_as_security_data_t *data, const void *args,
is_new,
context->eksi,
context->ul_count.seq_num,
*(UInt32_t *)(&context->ul_count));
*(uint32_t *)(&context->ul_count));
LOG_TRACE(INFO,
"knas_int %s",dump_octet_string(&context->knas_int));
LOG_TRACE(INFO,
......@@ -464,7 +464,7 @@ void emm_as_set_security_data(emm_as_security_data_t *data, const void *args,
data->is_new = is_new;
data->ksi = context->eksi;
data->sqn = context->ul_count.seq_num;
// LG data->count = *(UInt32_t *)(&context->ul_count);
// LG data->count = *(uint32_t *)(&context->ul_count);
data->count = 0x00000000 | (context->ul_count.overflow << 8 ) | context->ul_count.seq_num;
/* NAS integrity and cyphering keys may not be available if the
* current security context is a partial EPS security context
......
......@@ -203,7 +203,7 @@ int emm_as_send(const emm_as_t *msg)
int emm_cause = EMM_CAUSE_SUCCESS;
emm_as_primitive_t primitive = msg->primitive;
UInt32_t ueid = 0;
uint32_t ueid = 0;
LOG_TRACE(INFO, "EMMAS-SAP - Received primitive %s (%d)",
_emm_as_primitive_str[primitive - _EMMAS_START - 1], primitive);
......
......@@ -81,11 +81,11 @@ typedef enum emm_as_primitive_u {
/* Data used to setup EPS NAS security */
typedef struct emm_as_security_data_s {
UInt8_t is_new; /* New security data indicator */
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 */
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;
......@@ -99,21 +99,21 @@ typedef struct emm_as_security_data_s {
* ----------------------------
*/
typedef struct emm_as_security_s {
UInt32_t ueid; /* UE lower layer identifier */
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 */
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 */
uint32_t tmsi; /* The requested TMSI of the UE */
/*
* Authentication request/response
*/
UInt8_t ksi; /* NAS key set identifier */
uint8_t ksi; /* NAS key set identifier */
const OctetString *rand; /* Random challenge number */
const OctetString *autn; /* Authentication token */
const OctetString *res; /* Authentication response */
......@@ -121,23 +121,23 @@ typedef struct emm_as_security_s {
/*
* Security Mode Command
*/
UInt8_t eea; /* Replayed EPS encryption algorithms */
UInt8_t eia; /* Replayed EPS integrity algorithms */
UInt8_t uea; /* Replayed UMTS encryption algorithms */
uint8_t eea; /* Replayed EPS encryption algorithms */
uint8_t eia; /* Replayed EPS integrity algorithms */
uint8_t uea; /* Replayed UMTS encryption algorithms */
uint8_t ucs2;
UInt8_t uia; /* Replayed UMTS integrity algorithms */
UInt8_t gea; /* Replayed GPRS encryption algorithms */
UInt8_t umts_present;
UInt8_t gprs_present;
uint8_t uia; /* Replayed UMTS integrity algorithms */
uint8_t gea; /* Replayed GPRS encryption algorithms */
uint8_t umts_present;
uint8_t gprs_present;
// Added by LG
UInt8_t selected_eea; /* Selected EPS encryption algorithms */
UInt8_t selected_eia; /* Selected EPS integrity algorithms */
uint8_t selected_eea; /* Selected EPS encryption algorithms */
uint8_t selected_eia; /* Selected 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 */
uint8_t msgType; /* Type of NAS security message to transfer */
} emm_as_security_t;
/*
......@@ -153,17 +153,17 @@ typedef struct emm_as_EPS_identity_s {
} emm_as_EPS_identity_t;
typedef struct emm_as_establish_s {
UInt32_t ueid; /* UE lower layer identifier */
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 */
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 */
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
......@@ -175,7 +175,7 @@ typedef struct emm_as_establish_s {
#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 */
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;
......@@ -185,11 +185,11 @@ typedef struct emm_as_establish_s {
* --------------------------------------
*/
typedef struct emm_as_release_s {
UInt32_t ueid; /* UE lower layer identifier */
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 */
uint8_t cause; /* Release cause */
} emm_as_release_t;
/*
......@@ -197,15 +197,15 @@ typedef struct emm_as_release_s {
* ---------------------------------
*/
typedef struct emm_as_data_s {
UInt32_t ueid; /* UE lower layer identifier */
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 */
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 */
uint8_t NASinfo; /* Type of NAS information to transfer */
OctetString NASmsg; /* NAS message to be transfered */
} emm_as_data_t;
......@@ -220,7 +220,7 @@ typedef struct emm_as_page_s {} emm_as_page_t;
* -------------------------------------
*/
typedef struct emm_as_status_s {
UInt32_t ueid; /* UE lower layer identifier */
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 */
......@@ -231,7 +231,7 @@ typedef struct emm_as_status_s {
* ------------------------------------
*/
typedef struct emm_as_cell_info_s {
UInt8_t found; /* Indicates whether a suitable cell is found */
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 */
......
......@@ -86,14 +86,14 @@ Description Defines the security mode control EMM procedure executed by the
* --------------------------------------------------------------------------
*/
static int _security_kdf(const OctetString *kasme, OctetString *key,
UInt8_t algo_dist, UInt8_t algo_id);
uint8_t algo_dist, uint8_t algo_id);
static int _security_knas_enc(const OctetString *kasme, OctetString *knas_enc,
UInt8_t eia);
uint8_t eia);
static int _security_knas_int(const OctetString *kasme, OctetString *knas_int,
UInt8_t eea);
uint8_t eea);
static int _security_kenb(const OctetString *kasme, OctetString *kenb,
UInt32_t count);
uint32_t count);
/*
* Internal data used for security mode control procedure
......@@ -166,8 +166,8 @@ int emm_proc_security_mode_command(int native_ksi, int ksi,
/*
* Check the replayed UE security capabilities
*/
UInt8_t eea = (0x80 >> _emm_data.security->capability.eps_encryption);
UInt8_t eia = (0x80 >> _emm_data.security->capability.eps_integrity);
uint8_t eea = (0x80 >> _emm_data.security->capability.eps_encryption);
uint8_t eia = (0x80 >> _emm_data.security->capability.eps_integrity);
if ( (reea != eea) || (reia != eia) ) {
LOG_TRACE(WARNING, "EMM-PROC - Replayed UE security capabilities "
......@@ -240,7 +240,7 @@ int emm_proc_security_mode_command(int native_ksi, int ksi,
// LG COMMENT rc = _security_kenb(&_emm_data.security->kasme,
rc = _security_kenb(&_emm_data.non_current->kasme,
&_security_data.kenb,
*(UInt32_t *)(&_emm_data.non_current->ul_count));
*(uint32_t *)(&_emm_data.non_current->ul_count));
}
}
......@@ -416,7 +416,7 @@ static void _security_release(emm_security_context_t *ctx)
** **
***************************************************************************/
static int _security_knas_enc(const OctetString *kasme, OctetString *knas_enc,
UInt8_t eea)
uint8_t eea)
{
LOG_FUNC_IN;
LOG_TRACE(INFO, "%s with algo dist %d algo id %d", __FUNCTION__,0x01, eea);
......@@ -442,7 +442,7 @@ static int _security_knas_enc(const OctetString *kasme, OctetString *knas_enc,
** **
***************************************************************************/
static int _security_knas_int(const OctetString *kasme, OctetString *knas_int,
UInt8_t eia)
uint8_t eia)
{
LOG_FUNC_IN;
LOG_TRACE(INFO, "%s with algo dist %d algo id %d", __FUNCTION__,0x02, eia);
......@@ -468,13 +468,13 @@ static int _security_knas_int(const OctetString *kasme, OctetString *knas_int,
** **
***************************************************************************/
static int _security_kenb(const OctetString *kasme, OctetString *kenb,
UInt32_t count)
uint32_t count)
{
/* Compute the KDF input parameter
* S = FC(0x11) || UL NAS Count || 0x00 0x04
*/
UInt8_t input[32];
// UInt16_t length = 4;
uint8_t input[32];
// uint16_t length = 4;
// int offset = 0;
LOG_TRACE(INFO, "%s with count= %d", __FUNCTION__, count);
......@@ -482,9 +482,9 @@ static int _security_kenb(const OctetString *kasme, OctetString *kenb,
input[0] = 0x11;
// P0
input[1] = count >> 24;
input[2] = (UInt8_t)(count >> 16);
input[3] = (UInt8_t)(count >> 8);
input[4] = (UInt8_t)count;
input[2] = (uint8_t)(count >> 16);
input[3] = (uint8_t)(count >> 8);
input[4] = (uint8_t)count;
// L0
input[5] = 0;
input[6] = 4;
......@@ -515,14 +515,14 @@ static int _security_kenb(const OctetString *kasme, OctetString *kenb,
** **
***************************************************************************/
static int _security_kdf(const OctetString *kasme, OctetString *key,
UInt8_t algo_dist, UInt8_t algo_id)
uint8_t algo_dist, uint8_t algo_id)
{
/* Compute the KDF input parameter
* S = FC(0x15) || Algorithm distinguisher || 0x00 0x01
|| Algorithm identity || 0x00 0x01
*/
UInt8_t input[32];
UInt8_t output[32];
uint8_t input[32];
uint8_t output[32];
LOG_TRACE(DEBUG, "%s:%u output key mem %p lenth %u",
__FUNCTION__, __LINE__,
key->value,
......
......@@ -122,22 +122,22 @@ typedef struct emm_security_context_s {
OctetString knas_enc; /* NAS cyphering key */
OctetString knas_int; /* NAS integrity key */
struct count_s{
UInt32_t spare:8;
UInt32_t overflow:16;
UInt32_t seq_num:8;
uint32_t spare:8;
uint32_t overflow:16;
uint32_t seq_num:8;
} dl_count, ul_count; /* Downlink and uplink count parameters */
struct {
UInt8_t eps_encryption; /* algorithm used for ciphering */
UInt8_t eps_integrity; /* algorithm used for integrity protection */
UInt8_t umts_encryption; /* algorithm used for ciphering */
UInt8_t umts_integrity; /* algorithm used for integrity protection */
UInt8_t gprs_encryption; /* algorithm used for ciphering */
UInt8_t umts_present:1;
UInt8_t gprs_present:1;
uint8_t eps_encryption; /* algorithm used for ciphering */
uint8_t eps_integrity; /* algorithm used for integrity protection */
uint8_t umts_encryption; /* algorithm used for ciphering */
uint8_t umts_integrity; /* algorithm used for integrity protection */
uint8_t gprs_encryption; /* algorithm used for ciphering */
uint8_t umts_present:1;
uint8_t gprs_present:1;
} capability; /* UE network capability */
struct {
UInt8_t encryption:4; /* algorithm used for ciphering */
UInt8_t integrity:4; /* algorithm used for integrity protection */
uint8_t encryption:4; /* algorithm used for ciphering */
uint8_t integrity:4; /* algorithm used for integrity protection */
} selected_algorithms; /* MME selected algorithms */
} emm_security_context_t;
......@@ -275,14 +275,14 @@ typedef struct emm_data_s {
/* List of user controlled PLMNs */
#define EMM_DATA_PLMN_MAX 4
PLMN_LIST_T(EMM_DATA_PLMN_MAX) plmn;
UInt16_t userAcT[EMM_DATA_PLMN_MAX];
uint16_t userAcT[EMM_DATA_PLMN_MAX];
/* List of operator controlled PLMNs */
#define EMM_DATA_OPLMN_MAX 4
PLMN_LIST_T(EMM_DATA_OPLMN_MAX) oplmn;
UInt16_t operAcT[EMM_DATA_OPLMN_MAX];
uint16_t operAcT[EMM_DATA_OPLMN_MAX];
/* List of operator network name records */
#define EMM_DATA_OPNN_MAX 16
UInt8_t n_opnns;
uint8_t n_opnns;
struct {
const plmn_t *plmn;
const char *fullname;
......
......@@ -287,14 +287,14 @@ void emm_main_initialize(emm_indication_callback_t cb, const char *imei)
}
/* Downlink count parameter */
if (_usim_data.securityctx.dlNAScount.length <= sizeof(UInt32_t)) {
if (_usim_data.securityctx.dlNAScount.length <= sizeof(uint32_t)) {
memcpy(&_emm_data.security->dl_count,
_usim_data.securityctx.dlNAScount.value,
_usim_data.securityctx.dlNAScount.length);
}
/* Uplink count parameter */
if (_usim_data.securityctx.ulNAScount.length <= sizeof(UInt32_t)) {
if (_usim_data.securityctx.ulNAScount.length <= sizeof(uint32_t)) {
memcpy(&_emm_data.security->ul_count,
_usim_data.securityctx.ulNAScount.value,
_usim_data.securityctx.ulNAScount.length);
......
......@@ -35,7 +35,7 @@
# define TASK_ORIGIN TASK_NAS_UE
#if (defined(ENABLE_NAS_UE_LOGGING) && defined(NAS_BUILT_IN_UE) )
static const UInt8_t emm_message_ids[] = {
static const uint8_t emm_message_ids[] = {
ATTACH_REQUEST,
ATTACH_ACCEPT,
ATTACH_COMPLETE,
......@@ -67,7 +67,7 @@ static const UInt8_t emm_message_ids[] = {
CS_SERVICE_NOTIFICATION,
};
static const UInt8_t esm_message_ids[] = {
static const uint8_t esm_message_ids[] = {
ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST,
ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_ACCEPT,
ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REJECT,
......@@ -92,7 +92,7 @@ static const UInt8_t esm_message_ids[] = {
ESM_STATUS,
};
static int _nas_find_message_index(const UInt8_t message_id, const UInt8_t *message_ids, const int ids_number)
static int _nas_find_message_index(const uint8_t message_id, const uint8_t *message_ids, const int ids_number)
{
int i;
......@@ -207,7 +207,7 @@ int nas_itti_cell_info_req(const plmn_t plmnID, const Byte_t rat)
return itti_send_msg_to_task(TASK_RRC_UE, NB_eNB_INST + 0 /* TODO to be virtualized */, message_p);
}
int nas_itti_nas_establish_req(as_cause_t cause, as_call_type_t type, as_stmsi_t s_tmsi, plmn_t plmnID, Byte_t *data, UInt32_t length)
int nas_itti_nas_establish_req(as_cause_t cause, as_call_type_t type, as_stmsi_t s_tmsi, plmn_t plmnID, Byte_t *data, uint32_t length)
{
MessageDef *message_p;
......
......@@ -56,7 +56,7 @@ int nas_itti_protected_msg(
# if defined(NAS_BUILT_IN_UE)
int nas_itti_cell_info_req(const plmn_t plmnID, const Byte_t rat);
int nas_itti_nas_establish_req(as_cause_t cause, as_call_type_t type, as_stmsi_t s_tmsi, plmn_t plmnID, Byte_t *data_pP, UInt32_t lengthP);
int nas_itti_nas_establish_req(as_cause_t cause, as_call_type_t type, as_stmsi_t s_tmsi, plmn_t plmnID, Byte_t *data_pP, uint32_t lengthP);
int nas_itti_ul_data_req(const uint32_t ue_idP, void *const data_pP, const uint32_t lengthP);
......
......@@ -1029,7 +1029,7 @@ int nas_proc_activate_pdn(int cid)
** **
***************************************************************************/
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;
......@@ -1073,7 +1073,7 @@ int nas_proc_cell_info(int found, tac_t tac, ci_t ci, AcT_t AcT,
** Others: None **
** **
***************************************************************************/
int nas_proc_establish_cnf(const Byte_t *data, UInt32_t len)
int nas_proc_establish_cnf(const Byte_t *data, uint32_t len)
{
LOG_FUNC_IN;
......@@ -1251,7 +1251,7 @@ int nas_proc_ul_transfer_rej(void)
** Others: None **
** **
***************************************************************************/
int nas_proc_dl_transfer_ind(const Byte_t *data, UInt32_t len)
int nas_proc_dl_transfer_ind(const Byte_t *data, uint32_t len)
{
LOG_FUNC_IN;
......
......@@ -115,17 +115,17 @@ int nas_proc_activate_pdn(int cid);
* --------------------------------------------------------------------------
*/
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);
......
......@@ -49,6 +49,9 @@ Description Contains global common definitions
#include <stdint.h>
#include <stddef.h>
#define NAS_UE_ID_FMT "0x%06x"
/****************************************************************************/
/********************* G L O B A L C O N S T A N T S *******************/
/****************************************************************************/
......@@ -80,17 +83,8 @@ Description Contains global common definitions
-----------------------------------------------------------------------------
*/
typedef int8_t SByte_t; /* 8 bit signed integer */
typedef int8_t Int8_t; /* 8 bit signed integer */
typedef int16_t Int16_t; /* 16 bit signed integer */
typedef int32_t Int32_t; /* 32 bit signed integer */
typedef int64_t Int64_t; /* 64 bit signed integer */
typedef uint8_t Byte_t; /* 8 bit unsigned integer */
typedef uint8_t UInt8_t; /* 8 bit unsigned integer */
typedef uint16_t UInt16_t; /* 16 bit unsigned integer */
typedef uint32_t UInt32_t; /* 32 bit unsigned integer */
typedef uint64_t UInt64_t; /* 64 bit unsigned integer */
/*
-----------------------------------------------------------------------------
......@@ -98,12 +92,12 @@ typedef uint64_t UInt64_t; /* 64 bit unsigned integer */
-----------------------------------------------------------------------------
*/
typedef UInt8_t Stat_t; /* Registration status */
typedef UInt16_t lac_t; /* Location Area Code */
typedef UInt8_t rac_t; /* Routing Area Code */
typedef UInt16_t tac_t; /* Tracking Area Code */
typedef UInt32_t ci_t; /* Cell Identifier */
typedef UInt8_t AcT_t; /* Access Technology */
typedef uint8_t Stat_t; /* Registration status */
typedef uint16_t lac_t; /* Location Area Code */
typedef uint8_t rac_t; /* Routing Area Code */
typedef uint16_t tac_t; /* Tracking Area Code */
typedef uint32_t ci_t; /* Cell Identifier */
typedef uint8_t AcT_t; /* Access Technology */
/*
* International Mobile Subscriber Identity
......@@ -244,8 +238,8 @@ typedef struct {
*/
typedef struct {
plmn_t plmn; /* <MCC> + <MNC> */
UInt16_t MMEgid; /* MME group identifier */
UInt8_t MMEcode; /* MME code */
uint16_t MMEgid; /* MME group identifier */
uint8_t MMEcode; /* MME code */
} gummei_t;
/*
......@@ -253,7 +247,7 @@ typedef struct {
*/
typedef struct {
gummei_t gummei; /* Globally Unique MME Identity */
UInt32_t m_tmsi; /* M-Temporary Mobile Subscriber Identity */
uint32_t m_tmsi; /* M-Temporary Mobile Subscriber Identity */
} GUTI_t;
#define GUTI2STR(GuTi_PtR, GuTi_StR, MaXlEn) \
{\
......
......@@ -19,7 +19,7 @@ eNBs =
mobile_country_code = "208";
mobile_network_code = "93";
mobile_network_code = "95";
////////// Physical parameters:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment