Better behaviour for NAS MME (NAS NON DELIVERY INDICATION)
git-svn-id: http://svn.eurecom.fr/openair4G/trunk@7660 818b1a75-f10b-46b9-bf7c-635c3b92a50f
This commit is contained in:
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user