Commit 50f8f3de authored by Bartosz Podrygajlo's avatar Bartosz Podrygajlo

Fix formatting in nr_nas_msg_sim.c

parent 4f12a25e
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
* 2023.01.27 Vladimir Dorovskikh 16 digits IMEISV * 2023.01.27 Vladimir Dorovskikh 16 digits IMEISV
*/ */
#include <string.h> // memset #include <string.h> // memset
#include <stdlib.h> // malloc, free #include <stdlib.h> // malloc, free
...@@ -131,10 +130,7 @@ security_state_t nas_security_rx_process(nr_ue_nas_t *nas, uint8_t *pdu_buffer, ...@@ -131,10 +130,7 @@ security_state_t nas_security_rx_process(nr_ue_nas_t *nas, uint8_t *pdu_buffer,
return NAS_SECURITY_INTEGRITY_PASSED; return NAS_SECURITY_INTEGRITY_PASSED;
} }
static int nas_protected_security_header_encode( static int nas_protected_security_header_encode(char *buffer, const fgs_nas_message_security_header_t *header, int length)
char *buffer,
const fgs_nas_message_security_header_t *header,
int length)
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
...@@ -144,18 +140,18 @@ static int nas_protected_security_header_encode( ...@@ -144,18 +140,18 @@ static int nas_protected_security_header_encode(
ENCODE_U8(buffer, header->protocol_discriminator, size); ENCODE_U8(buffer, header->protocol_discriminator, size);
/* Encode the security header type */ /* Encode the security header type */
ENCODE_U8(buffer+size, (header->security_header_type & 0xf), size); ENCODE_U8(buffer + size, (header->security_header_type & 0xf), size);
/* Encode the message authentication code */ /* Encode the message authentication code */
ENCODE_U32(buffer+size, header->message_authentication_code, size); ENCODE_U32(buffer + size, header->message_authentication_code, size);
/* Encode the sequence number */ /* Encode the sequence number */
ENCODE_U8(buffer+size, header->sequence_number, size); ENCODE_U8(buffer + size, header->sequence_number, size);
LOG_FUNC_RETURN (size); LOG_FUNC_RETURN(size);
} }
static int _nas_mm_msg_encode_header(const mm_msg_header_t *header, static int _nas_mm_msg_encode_header(const mm_msg_header_t *header, uint8_t *buffer, uint32_t len)
uint8_t *buffer, uint32_t len) { {
int size = 0; int size = 0;
/* Check the buffer length */ /* Check the buffer length */
...@@ -165,8 +161,7 @@ static int _nas_mm_msg_encode_header(const mm_msg_header_t *header, ...@@ -165,8 +161,7 @@ static int _nas_mm_msg_encode_header(const mm_msg_header_t *header,
/* Check the protocol discriminator */ /* Check the protocol discriminator */
if (header->ex_protocol_discriminator != FGS_MOBILITY_MANAGEMENT_MESSAGE) { if (header->ex_protocol_discriminator != FGS_MOBILITY_MANAGEMENT_MESSAGE) {
LOG_TRACE(ERROR, "ESM-MSG - Unexpected extened protocol discriminator: 0x%x", LOG_TRACE(ERROR, "ESM-MSG - Unexpected extened protocol discriminator: 0x%x", header->ex_protocol_discriminator);
header->ex_protocol_discriminator);
return (TLV_ENCODE_PROTOCOL_NOT_SUPPORTED); return (TLV_ENCODE_PROTOCOL_NOT_SUPPORTED);
} }
...@@ -201,7 +196,7 @@ static int fill_guti(FGSMobileIdentity *mi, const Guti5GSMobileIdentity_t *guti) ...@@ -201,7 +196,7 @@ static int fill_guti(FGSMobileIdentity *mi, const Guti5GSMobileIdentity_t *guti)
static int fill_imeisv(FGSMobileIdentity *mi, const uicc_t *uicc) static int fill_imeisv(FGSMobileIdentity *mi, const uicc_t *uicc)
{ {
int i=0; int i = 0;
mi->imeisv.typeofidentity = FGS_MOBILE_IDENTITY_IMEISV; mi->imeisv.typeofidentity = FGS_MOBILE_IDENTITY_IMEISV;
mi->imeisv.digittac01 = getImeisvDigit(uicc, i++); mi->imeisv.digittac01 = getImeisvDigit(uicc, i++);
mi->imeisv.digittac02 = getImeisvDigit(uicc, i++); mi->imeisv.digittac02 = getImeisvDigit(uicc, i++);
...@@ -224,26 +219,28 @@ static int fill_imeisv(FGSMobileIdentity *mi, const uicc_t *uicc) ...@@ -224,26 +219,28 @@ static int fill_imeisv(FGSMobileIdentity *mi, const uicc_t *uicc)
return 19; return 19;
} }
int mm_msg_encode(MM_msg *mm_msg, uint8_t *buffer, uint32_t len) { int mm_msg_encode(MM_msg *mm_msg, uint8_t *buffer, uint32_t len)
{
LOG_FUNC_IN; LOG_FUNC_IN;
int header_result; int header_result;
int encode_result; int encode_result;
uint8_t msg_type = mm_msg->header.message_type; uint8_t msg_type = mm_msg->header.message_type;
/* First encode the EMM message header */ /* First encode the EMM message header */
header_result = _nas_mm_msg_encode_header(&mm_msg->header, buffer, len); header_result = _nas_mm_msg_encode_header(&mm_msg->header, buffer, len);
if (header_result < 0) { if (header_result < 0) {
LOG_TRACE(ERROR, "EMM-MSG - Failed to encode EMM message header " LOG_TRACE(ERROR,
"(%d)", header_result); "EMM-MSG - Failed to encode EMM message header "
"(%d)",
header_result);
LOG_FUNC_RETURN(header_result); LOG_FUNC_RETURN(header_result);
} }
buffer += header_result; buffer += header_result;
len -= header_result; len -= header_result;
switch(msg_type) { switch (msg_type) {
case REGISTRATION_REQUEST: case REGISTRATION_REQUEST:
encode_result = encode_registration_request(&mm_msg->registration_request, buffer, len); encode_result = encode_registration_request(&mm_msg->registration_request, buffer, len);
break; break;
...@@ -260,32 +257,36 @@ int mm_msg_encode(MM_msg *mm_msg, uint8_t *buffer, uint32_t len) { ...@@ -260,32 +257,36 @@ int mm_msg_encode(MM_msg *mm_msg, uint8_t *buffer, uint32_t len) {
encode_result = encode_fgs_uplink_nas_transport(&mm_msg->uplink_nas_transport, buffer, len); encode_result = encode_fgs_uplink_nas_transport(&mm_msg->uplink_nas_transport, buffer, len);
break; break;
case FGS_DEREGISTRATION_REQUEST_UE_ORIGINATING: case FGS_DEREGISTRATION_REQUEST_UE_ORIGINATING:
encode_result = encode_fgs_deregistration_request_ue_originating(&mm_msg->fgs_deregistration_request_ue_originating, buffer, len); encode_result =
encode_fgs_deregistration_request_ue_originating(&mm_msg->fgs_deregistration_request_ue_originating, buffer, len);
break; break;
default: default:
LOG_TRACE(ERROR, "EMM-MSG - Unexpected message type: 0x%x", LOG_TRACE(ERROR, "EMM-MSG - Unexpected message type: 0x%x", mm_msg->header.message_type);
mm_msg->header.message_type);
encode_result = TLV_ENCODE_WRONG_MESSAGE_TYPE; encode_result = TLV_ENCODE_WRONG_MESSAGE_TYPE;
break; break;
/* TODO: Handle not standard layer 3 messages: SERVICE_REQUEST */ /* TODO: Handle not standard layer 3 messages: SERVICE_REQUEST */
} }
if (encode_result < 0) { if (encode_result < 0) {
LOG_TRACE(ERROR, "EMM-MSG - Failed to encode L3 EMM message 0x%x " LOG_TRACE(ERROR,
"(%d)", mm_msg->header.message_type, encode_result); "EMM-MSG - Failed to encode L3 EMM message 0x%x "
"(%d)",
mm_msg->header.message_type,
encode_result);
} }
if (encode_result < 0) if (encode_result < 0)
LOG_FUNC_RETURN (encode_result); LOG_FUNC_RETURN(encode_result);
LOG_FUNC_RETURN (header_result + encode_result); LOG_FUNC_RETURN(header_result + encode_result);
} }
void transferRES(uint8_t ck[16], uint8_t ik[16], uint8_t *input, uint8_t rand[16], uint8_t *output, uicc_t* uicc) { void transferRES(uint8_t ck[16], uint8_t ik[16], uint8_t *input, uint8_t rand[16], uint8_t *output, uicc_t *uicc)
uint8_t S[100]={0}; {
uint8_t S[100] = {0};
S[0] = 0x6B; S[0] = 0x6B;
servingNetworkName (S+1, uicc->imsiStr, uicc->nmc_size); servingNetworkName(S + 1, uicc->imsiStr, uicc->nmc_size);
int netNamesize = strlen((char*)S+1); int netNamesize = strlen((char *)S + 1);
S[1 + netNamesize] = (netNamesize & 0xff00) >> 8; S[1 + netNamesize] = (netNamesize & 0xff00) >> 8;
S[2 + netNamesize] = (netNamesize & 0x00ff); S[2 + netNamesize] = (netNamesize & 0x00ff);
for (int i = 0; i < 16; i++) for (int i = 0; i < 16; i++)
...@@ -297,7 +298,7 @@ void transferRES(uint8_t ck[16], uint8_t ik[16], uint8_t *input, uint8_t rand[16 ...@@ -297,7 +298,7 @@ void transferRES(uint8_t ck[16], uint8_t ik[16], uint8_t *input, uint8_t rand[16
S[29 + netNamesize] = 0x00; S[29 + netNamesize] = 0x00;
S[30 + netNamesize] = 0x08; S[30 + netNamesize] = 0x08;
uint8_t plmn[3] = { 0x02, 0xf8, 0x39 }; uint8_t plmn[3] = {0x02, 0xf8, 0x39};
uint8_t oldS[100]; uint8_t oldS[100];
oldS[0] = 0x6B; oldS[0] = 0x6B;
memcpy(&oldS[1], plmn, 3); memcpy(&oldS[1], plmn, 3);
...@@ -312,10 +313,9 @@ void transferRES(uint8_t ck[16], uint8_t ik[16], uint8_t *input, uint8_t rand[16 ...@@ -312,10 +313,9 @@ void transferRES(uint8_t ck[16], uint8_t ik[16], uint8_t *input, uint8_t rand[16
oldS[32] = 0x00; oldS[32] = 0x00;
oldS[33] = 0x08; oldS[33] = 0x08;
uint8_t key[32] = {0}; uint8_t key[32] = {0};
memcpy(&key[0], ck, 16); memcpy(&key[0], ck, 16);
memcpy(&key[16], ik, 16); //KEY memcpy(&key[16], ik, 16); // KEY
uint8_t out[32] = {0}; uint8_t out[32] = {0};
byte_array_t data = {.buf = S, .len = 31 + netNamesize}; byte_array_t data = {.buf = S, .len = 31 + netNamesize};
...@@ -324,15 +324,16 @@ void transferRES(uint8_t ck[16], uint8_t ik[16], uint8_t *input, uint8_t rand[16 ...@@ -324,15 +324,16 @@ void transferRES(uint8_t ck[16], uint8_t ik[16], uint8_t *input, uint8_t rand[16
memcpy(output, out + 16, 16); memcpy(output, out + 16, 16);
} }
void derive_kausf(uint8_t ck[16], uint8_t ik[16], uint8_t sqn[6], uint8_t kausf[32], uicc_t *uicc) { void derive_kausf(uint8_t ck[16], uint8_t ik[16], uint8_t sqn[6], uint8_t kausf[32], uicc_t *uicc)
uint8_t S[100]={0}; {
uint8_t S[100] = {0};
uint8_t key[32] = {0}; uint8_t key[32] = {0};
memcpy(&key[0], ck, 16); memcpy(&key[0], ck, 16);
memcpy(&key[16], ik, 16); //KEY memcpy(&key[16], ik, 16); // KEY
S[0] = 0x6A; S[0] = 0x6A;
servingNetworkName (S+1, uicc->imsiStr, uicc->nmc_size); servingNetworkName(S + 1, uicc->imsiStr, uicc->nmc_size);
int netNamesize = strlen((char*)S+1); int netNamesize = strlen((char *)S + 1);
S[1 + netNamesize] = (uint8_t)((netNamesize & 0xff00) >> 8); S[1 + netNamesize] = (uint8_t)((netNamesize & 0xff00) >> 8);
S[2 + netNamesize] = (uint8_t)(netNamesize & 0x00ff); S[2 + netNamesize] = (uint8_t)(netNamesize & 0x00ff);
for (int i = 0; i < 6; i++) { for (int i = 0; i < 6; i++) {
...@@ -345,23 +346,25 @@ void derive_kausf(uint8_t ck[16], uint8_t ik[16], uint8_t sqn[6], uint8_t kausf[ ...@@ -345,23 +346,25 @@ void derive_kausf(uint8_t ck[16], uint8_t ik[16], uint8_t sqn[6], uint8_t kausf[
kdf(key, data, 32, kausf); kdf(key, data, 32, kausf);
} }
void derive_kseaf(uint8_t kausf[32], uint8_t kseaf[32], uicc_t *uicc) { void derive_kseaf(uint8_t kausf[32], uint8_t kseaf[32], uicc_t *uicc)
uint8_t S[100]={0}; {
S[0] = 0x6C; //FC uint8_t S[100] = {0};
servingNetworkName (S+1, uicc->imsiStr, uicc->nmc_size); S[0] = 0x6C; // FC
int netNamesize = strlen((char*)S+1); servingNetworkName(S + 1, uicc->imsiStr, uicc->nmc_size);
int netNamesize = strlen((char *)S + 1);
S[1 + netNamesize] = (uint8_t)((netNamesize & 0xff00) >> 8); S[1 + netNamesize] = (uint8_t)((netNamesize & 0xff00) >> 8);
S[2 + netNamesize] = (uint8_t)(netNamesize & 0x00ff); S[2 + netNamesize] = (uint8_t)(netNamesize & 0x00ff);
byte_array_t data = {.buf = S , .len = 3 + netNamesize}; byte_array_t data = {.buf = S, .len = 3 + netNamesize};
kdf(kausf, data, 32, kseaf); kdf(kausf, data, 32, kseaf);
} }
void derive_kamf(uint8_t *kseaf, uint8_t *kamf, uint16_t abba, uicc_t* uicc) { void derive_kamf(uint8_t *kseaf, uint8_t *kamf, uint16_t abba, uicc_t *uicc)
{
int imsiLen = strlen(uicc->imsiStr); int imsiLen = strlen(uicc->imsiStr);
uint8_t S[100] = {0}; uint8_t S[100] = {0};
S[0] = 0x6D; //FC = 0x6D S[0] = 0x6D; // FC = 0x6D
memcpy(&S[1], uicc->imsiStr, imsiLen ); memcpy(&S[1], uicc->imsiStr, imsiLen);
S[1 + imsiLen] = (uint8_t)((imsiLen & 0xff00) >> 8); S[1 + imsiLen] = (uint8_t)((imsiLen & 0xff00) >> 8);
S[2 + imsiLen] = (uint8_t)(imsiLen & 0x00ff); S[2 + imsiLen] = (uint8_t)(imsiLen & 0x00ff);
S[3 + imsiLen] = abba & 0x00ff; S[3 + imsiLen] = abba & 0x00ff;
...@@ -377,8 +380,8 @@ void derive_kamf(uint8_t *kseaf, uint8_t *kamf, uint16_t abba, uicc_t* uicc) { ...@@ -377,8 +380,8 @@ void derive_kamf(uint8_t *kseaf, uint8_t *kamf, uint16_t abba, uicc_t* uicc) {
void derive_knas(algorithm_type_dist_t nas_alg_type, uint8_t nas_alg_id, uint8_t kamf[32], uint8_t *knas) void derive_knas(algorithm_type_dist_t nas_alg_type, uint8_t nas_alg_id, uint8_t kamf[32], uint8_t *knas)
{ {
uint8_t S[20] = {0}; uint8_t S[20] = {0};
uint8_t out[32] = { 0 }; uint8_t out[32] = {0};
S[0] = 0x69; //FC S[0] = 0x69; // FC
S[1] = (uint8_t)(nas_alg_type & 0xFF); S[1] = (uint8_t)(nas_alg_type & 0xFF);
S[2] = 0x00; S[2] = 0x00;
S[3] = 0x01; S[3] = 0x01;
...@@ -389,10 +392,11 @@ void derive_knas(algorithm_type_dist_t nas_alg_type, uint8_t nas_alg_id, uint8_t ...@@ -389,10 +392,11 @@ void derive_knas(algorithm_type_dist_t nas_alg_type, uint8_t nas_alg_id, uint8_t
byte_array_t data = {.buf = S, .len = 7}; byte_array_t data = {.buf = S, .len = 7};
kdf(kamf, data, 32, out); kdf(kamf, data, 32, out);
memcpy(knas, out+16, 16); memcpy(knas, out + 16, 16);
} }
void derive_kgnb(uint8_t kamf[32], uint32_t count, uint8_t *kgnb){ void derive_kgnb(uint8_t kamf[32], uint32_t count, uint8_t *kgnb)
{
/* Compute the KDF input parameter /* Compute the KDF input parameter
* S = FC(0x6E) || UL NAS Count || 0x00 0x04 || 0x01 || 0x00 0x01 * S = FC(0x6E) || UL NAS Count || 0x00 0x04 || 0x01 || 0x00 0x01
*/ */
...@@ -421,12 +425,13 @@ void derive_kgnb(uint8_t kamf[32], uint32_t count, uint8_t *kgnb){ ...@@ -421,12 +425,13 @@ void derive_kgnb(uint8_t kamf[32], uint32_t count, uint8_t *kgnb){
kdf(kamf, data, 32, kgnb); kdf(kamf, data, 32, kgnb);
printf("kgnb : "); printf("kgnb : ");
for(int pp=0;pp<32;pp++) for (int pp = 0; pp < 32; pp++)
printf("%02x ",kgnb[pp]); printf("%02x ", kgnb[pp]);
printf("\n"); printf("\n");
} }
void derive_ue_keys(uint8_t *buf, nr_ue_nas_t *nas) { void derive_ue_keys(uint8_t *buf, nr_ue_nas_t *nas)
{
uint8_t ak[6]; uint8_t ak[6];
uint8_t sqn[6]; uint8_t sqn[6];
...@@ -439,8 +444,8 @@ void derive_ue_keys(uint8_t *buf, nr_ue_nas_t *nas) { ...@@ -439,8 +444,8 @@ void derive_ue_keys(uint8_t *buf, nr_ue_nas_t *nas) {
uint8_t *kgnb = nas->security.kgnb; uint8_t *kgnb = nas->security.kgnb;
// get RAND for authentication request // get RAND for authentication request
for(int index = 0; index < 16;index++){ for (int index = 0; index < 16; index++) {
rand[index] = buf[8+index]; rand[index] = buf[8 + index];
} }
uint8_t resTemp[16]; uint8_t resTemp[16];
...@@ -449,30 +454,30 @@ void derive_ue_keys(uint8_t *buf, nr_ue_nas_t *nas) { ...@@ -449,30 +454,30 @@ void derive_ue_keys(uint8_t *buf, nr_ue_nas_t *nas) {
transferRES(ck, ik, resTemp, rand, output, nas->uicc); transferRES(ck, ik, resTemp, rand, output, nas->uicc);
for(int index = 0; index < 6; index++){ for (int index = 0; index < 6; index++) {
sqn[index] = buf[26+index]; sqn[index] = buf[26 + index];
} }
derive_kausf(ck, ik, sqn, kausf, nas->uicc); derive_kausf(ck, ik, sqn, kausf, nas->uicc);
derive_kseaf(kausf, kseaf, nas->uicc); derive_kseaf(kausf, kseaf, nas->uicc);
derive_kamf(kseaf, kamf, 0x0000, nas->uicc); derive_kamf(kseaf, kamf, 0x0000, nas->uicc);
derive_kgnb(kamf,0,kgnb); derive_kgnb(kamf, 0, kgnb);
printf("kausf:"); printf("kausf:");
for(int i = 0; i < 32; i++){ for (int i = 0; i < 32; i++) {
printf("%x ", kausf[i]); printf("%x ", kausf[i]);
} }
printf("\n"); printf("\n");
printf("kseaf:"); printf("kseaf:");
for(int i = 0; i < 32; i++){ for (int i = 0; i < 32; i++) {
printf("%x ", kseaf[i]); printf("%x ", kseaf[i]);
} }
printf("\n"); printf("\n");
printf("kamf:"); printf("kamf:");
for(int i = 0; i < 32; i++){ for (int i = 0; i < 32; i++) {
printf("%x ", kamf[i]); printf("%x ", kamf[i]);
} }
printf("\n"); printf("\n");
...@@ -491,7 +496,7 @@ nr_ue_nas_t *get_ue_nas_info(module_id_t module_id) ...@@ -491,7 +496,7 @@ nr_ue_nas_t *get_ue_nas_info(module_id_t module_id)
void generateRegistrationRequest(as_nas_info_t *initialNasMsg, nr_ue_nas_t *nas) void generateRegistrationRequest(as_nas_info_t *initialNasMsg, nr_ue_nas_t *nas)
{ {
int size = sizeof(mm_msg_header_t); int size = sizeof(mm_msg_header_t);
fgs_nas_message_t nas_msg={0}; fgs_nas_message_t nas_msg = {0};
MM_msg *mm_msg; MM_msg *mm_msg;
mm_msg = &nas_msg.plain.mm_msg; mm_msg = &nas_msg.plain.mm_msg;
...@@ -500,7 +505,6 @@ void generateRegistrationRequest(as_nas_info_t *initialNasMsg, nr_ue_nas_t *nas) ...@@ -500,7 +505,6 @@ void generateRegistrationRequest(as_nas_info_t *initialNasMsg, nr_ue_nas_t *nas)
mm_msg->header.security_header_type = PLAIN_5GS_MSG; mm_msg->header.security_header_type = PLAIN_5GS_MSG;
mm_msg->header.message_type = REGISTRATION_REQUEST; mm_msg->header.message_type = REGISTRATION_REQUEST;
// set registration request // set registration request
mm_msg->registration_request.protocoldiscriminator = FGS_MOBILITY_MANAGEMENT_MESSAGE; mm_msg->registration_request.protocoldiscriminator = FGS_MOBILITY_MANAGEMENT_MESSAGE;
size += 1; size += 1;
...@@ -511,7 +515,7 @@ void generateRegistrationRequest(as_nas_info_t *initialNasMsg, nr_ue_nas_t *nas) ...@@ -511,7 +515,7 @@ void generateRegistrationRequest(as_nas_info_t *initialNasMsg, nr_ue_nas_t *nas)
mm_msg->registration_request.fgsregistrationtype = INITIAL_REGISTRATION; mm_msg->registration_request.fgsregistrationtype = INITIAL_REGISTRATION;
mm_msg->registration_request.naskeysetidentifier.naskeysetidentifier = 1; mm_msg->registration_request.naskeysetidentifier.naskeysetidentifier = 1;
size += 1; size += 1;
if(nas->guti){ if (nas->guti) {
size += fill_guti(&mm_msg->registration_request.fgsmobileidentity, nas->guti); size += fill_guti(&mm_msg->registration_request.fgsmobileidentity, nas->guti);
} else { } else {
size += fill_suci(&mm_msg->registration_request.fgsmobileidentity, nas->uicc); size += fill_suci(&mm_msg->registration_request.fgsmobileidentity, nas->uicc);
...@@ -542,12 +546,12 @@ void generateRegistrationRequest(as_nas_info_t *initialNasMsg, nr_ue_nas_t *nas) ...@@ -542,12 +546,12 @@ void generateRegistrationRequest(as_nas_info_t *initialNasMsg, nr_ue_nas_t *nas)
initialNasMsg->data = malloc16_clear(size * sizeof(Byte_t)); initialNasMsg->data = malloc16_clear(size * sizeof(Byte_t));
nas->registration_request_buf = initialNasMsg->data; nas->registration_request_buf = initialNasMsg->data;
initialNasMsg->length = mm_msg_encode(mm_msg, (uint8_t*)(initialNasMsg->data), size); initialNasMsg->length = mm_msg_encode(mm_msg, (uint8_t *)(initialNasMsg->data), size);
nas->registration_request_len = initialNasMsg->length; nas->registration_request_len = initialNasMsg->length;
} }
void generateIdentityResponse(as_nas_info_t *initialNasMsg, uint8_t identitytype, uicc_t* uicc) { void generateIdentityResponse(as_nas_info_t *initialNasMsg, uint8_t identitytype, uicc_t *uicc)
{
int size = sizeof(mm_msg_header_t); int size = sizeof(mm_msg_header_t);
fgs_nas_message_t nas_msg; fgs_nas_message_t nas_msg;
memset(&nas_msg, 0, sizeof(fgs_nas_message_t)); memset(&nas_msg, 0, sizeof(fgs_nas_message_t));
...@@ -559,7 +563,6 @@ void generateIdentityResponse(as_nas_info_t *initialNasMsg, uint8_t identitytype ...@@ -559,7 +563,6 @@ void generateIdentityResponse(as_nas_info_t *initialNasMsg, uint8_t identitytype
mm_msg->header.security_header_type = PLAIN_5GS_MSG; mm_msg->header.security_header_type = PLAIN_5GS_MSG;
mm_msg->header.message_type = FGS_IDENTITY_RESPONSE; mm_msg->header.message_type = FGS_IDENTITY_RESPONSE;
// set identity response // set identity response
mm_msg->fgs_identity_response.protocoldiscriminator = FGS_MOBILITY_MANAGEMENT_MESSAGE; mm_msg->fgs_identity_response.protocoldiscriminator = FGS_MOBILITY_MANAGEMENT_MESSAGE;
size += 1; size += 1;
...@@ -567,15 +570,14 @@ void generateIdentityResponse(as_nas_info_t *initialNasMsg, uint8_t identitytype ...@@ -567,15 +570,14 @@ void generateIdentityResponse(as_nas_info_t *initialNasMsg, uint8_t identitytype
size += 1; size += 1;
mm_msg->fgs_identity_response.messagetype = FGS_IDENTITY_RESPONSE; mm_msg->fgs_identity_response.messagetype = FGS_IDENTITY_RESPONSE;
size += 1; size += 1;
if(identitytype == FGS_MOBILE_IDENTITY_SUCI){ if (identitytype == FGS_MOBILE_IDENTITY_SUCI) {
size += fill_suci(&mm_msg->fgs_identity_response.fgsmobileidentity, uicc); size += fill_suci(&mm_msg->fgs_identity_response.fgsmobileidentity, uicc);
} }
// encode the message // encode the message
initialNasMsg->data = (Byte_t *)malloc(size * sizeof(Byte_t)); initialNasMsg->data = (Byte_t *)malloc(size * sizeof(Byte_t));
initialNasMsg->length = mm_msg_encode(mm_msg, (uint8_t*)(initialNasMsg->data), size); initialNasMsg->length = mm_msg_encode(mm_msg, (uint8_t *)(initialNasMsg->data), size);
} }
static void generateAuthenticationResp(nr_ue_nas_t *nas, as_nas_info_t *initialNasMsg, uint8_t *buf) static void generateAuthenticationResp(nr_ue_nas_t *nas, as_nas_info_t *initialNasMsg, uint8_t *buf)
...@@ -583,7 +585,7 @@ static void generateAuthenticationResp(nr_ue_nas_t *nas, as_nas_info_t *initialN ...@@ -583,7 +585,7 @@ static void generateAuthenticationResp(nr_ue_nas_t *nas, as_nas_info_t *initialN
derive_ue_keys(buf, nas); derive_ue_keys(buf, nas);
OctetString res; OctetString res;
res.length = 16; res.length = 16;
res.value = calloc(1,16); res.value = calloc(1, 16);
memcpy(res.value, nas->security.res, 16); memcpy(res.value, nas->security.res, 16);
int size = sizeof(mm_msg_header_t); int size = sizeof(mm_msg_header_t);
...@@ -605,13 +607,13 @@ static void generateAuthenticationResp(nr_ue_nas_t *nas, as_nas_info_t *initialN ...@@ -605,13 +607,13 @@ static void generateAuthenticationResp(nr_ue_nas_t *nas, as_nas_info_t *initialN
mm_msg->fgs_identity_response.messagetype = FGS_AUTHENTICATION_RESPONSE; mm_msg->fgs_identity_response.messagetype = FGS_AUTHENTICATION_RESPONSE;
size += 1; size += 1;
//set response parameter // set response parameter
mm_msg->fgs_auth_response.authenticationresponseparameter.res = res; mm_msg->fgs_auth_response.authenticationresponseparameter.res = res;
size += 18; size += 18;
// encode the message // encode the message
initialNasMsg->data = (Byte_t *)malloc(size * sizeof(Byte_t)); initialNasMsg->data = (Byte_t *)malloc(size * sizeof(Byte_t));
initialNasMsg->length = mm_msg_encode(mm_msg, (uint8_t*)(initialNasMsg->data), size); initialNasMsg->length = mm_msg_encode(mm_msg, (uint8_t *)(initialNasMsg->data), size);
} }
int nas_itti_kgnb_refresh_req(instance_t instance, const uint8_t kgnb[32]) int nas_itti_kgnb_refresh_req(instance_t instance, const uint8_t kgnb[32])
...@@ -661,9 +663,11 @@ static void generateSecurityModeComplete(nr_ue_nas_t *nas, as_nas_info_t *initia ...@@ -661,9 +663,11 @@ static void generateSecurityModeComplete(nr_ue_nas_t *nas, as_nas_info_t *initia
// encode the message // encode the message
initialNasMsg->data = (Byte_t *)malloc(size * sizeof(Byte_t)); initialNasMsg->data = (Byte_t *)malloc(size * sizeof(Byte_t));
int security_header_len = nas_protected_security_header_encode((char*)(initialNasMsg->data),&(nas_msg.header), size); int security_header_len = nas_protected_security_header_encode((char *)(initialNasMsg->data), &(nas_msg.header), size);
initialNasMsg->length = security_header_len + mm_msg_encode(mm_msg, (uint8_t*)(initialNasMsg->data+security_header_len), size-security_header_len); initialNasMsg->length =
security_header_len
+ mm_msg_encode(mm_msg, (uint8_t *)(initialNasMsg->data + security_header_len), size - security_header_len);
/* ciphering */ /* ciphering */
uint8_t buf[initialNasMsg->length - 7]; uint8_t buf[initialNasMsg->length - 7];
...@@ -690,8 +694,8 @@ static void generateSecurityModeComplete(nr_ue_nas_t *nas, as_nas_info_t *initia ...@@ -690,8 +694,8 @@ static void generateSecurityModeComplete(nr_ue_nas_t *nas, as_nas_info_t *initia
stream_compute_integrity(nas->security_container->integrity_algorithm, &stream_cipher, mac); stream_compute_integrity(nas->security_container->integrity_algorithm, &stream_cipher, mac);
printf("mac %x %x %x %x \n", mac[0], mac[1], mac[2], mac[3]); printf("mac %x %x %x %x \n", mac[0], mac[1], mac[2], mac[3]);
for(int i = 0; i < 4; i++){ for (int i = 0; i < 4; i++) {
initialNasMsg->data[2+i] = mac[i]; initialNasMsg->data[2 + i] = mac[i];
} }
} }
...@@ -711,13 +715,13 @@ static void handle_security_mode_command(nr_ue_nas_t *nas, as_nas_info_t *initia ...@@ -711,13 +715,13 @@ static void handle_security_mode_command(nr_ue_nas_t *nas, as_nas_info_t *initia
derive_knas(0x02, integrity_algorithm, kamf, knas_int); derive_knas(0x02, integrity_algorithm, kamf, knas_int);
printf("knas_int: "); printf("knas_int: ");
for(int i = 0; i < 16; i++){ for (int i = 0; i < 16; i++) {
printf("%x ", knas_int[i]); printf("%x ", knas_int[i]);
} }
printf("\n"); printf("\n");
printf("knas_enc: "); printf("knas_enc: ");
for(int i = 0; i < 16; i++){ for (int i = 0; i < 16; i++) {
printf("%x ", knas_enc[i]); printf("%x ", knas_enc[i]);
} }
printf("\n"); printf("\n");
...@@ -753,7 +757,9 @@ static void decodeRegistrationAccept(const uint8_t *buf, int len, nr_ue_nas_t *n ...@@ -753,7 +757,9 @@ static void decodeRegistrationAccept(const uint8_t *buf, int len, nr_ue_nas_t *n
} }
} }
static void generateRegistrationComplete(nr_ue_nas_t *nas, as_nas_info_t *initialNasMsg, SORTransparentContainer *sortransparentcontainer) static void generateRegistrationComplete(nr_ue_nas_t *nas,
as_nas_info_t *initialNasMsg,
SORTransparentContainer *sortransparentcontainer)
{ {
int length = 0; int length = 0;
int size = 0; int size = 0;
...@@ -778,7 +784,7 @@ static void generateRegistrationComplete(nr_ue_nas_t *nas, as_nas_info_t *initia ...@@ -778,7 +784,7 @@ static void generateRegistrationComplete(nr_ue_nas_t *nas, as_nas_info_t *initia
sp_msg->plain.mm_msg.registration_complete.messagetype = REGISTRATION_COMPLETE; sp_msg->plain.mm_msg.registration_complete.messagetype = REGISTRATION_COMPLETE;
length += 1; length += 1;
if(sortransparentcontainer) { if (sortransparentcontainer) {
length += sortransparentcontainer->sortransparentcontainercontents.length; length += sortransparentcontainer->sortransparentcontainercontents.length;
} }
...@@ -798,7 +804,6 @@ static void generateRegistrationComplete(nr_ue_nas_t *nas, as_nas_info_t *initia ...@@ -798,7 +804,6 @@ static void generateRegistrationComplete(nr_ue_nas_t *nas, as_nas_info_t *initia
/* Encode the sequence number */ /* Encode the sequence number */
ENCODE_U8(initialNasMsg->data + size, sp_msg->header.sequence_number, size); ENCODE_U8(initialNasMsg->data + size, sp_msg->header.sequence_number, size);
/* Encode the extended protocol discriminator */ /* Encode the extended protocol discriminator */
ENCODE_U8(initialNasMsg->data + size, sp_msg->plain.mm_msg.registration_complete.protocoldiscriminator, size); ENCODE_U8(initialNasMsg->data + size, sp_msg->plain.mm_msg.registration_complete.protocoldiscriminator, size);
...@@ -808,7 +813,7 @@ static void generateRegistrationComplete(nr_ue_nas_t *nas, as_nas_info_t *initia ...@@ -808,7 +813,7 @@ static void generateRegistrationComplete(nr_ue_nas_t *nas, as_nas_info_t *initia
/* Encode the message type */ /* Encode the message type */
ENCODE_U8(initialNasMsg->data + size, sp_msg->plain.mm_msg.registration_complete.messagetype, size); ENCODE_U8(initialNasMsg->data + size, sp_msg->plain.mm_msg.registration_complete.messagetype, size);
if(sortransparentcontainer) { if (sortransparentcontainer) {
encode_registration_complete(&sp_msg->plain.mm_msg.registration_complete, initialNasMsg->data + size, length - size); encode_registration_complete(&sp_msg->plain.mm_msg.registration_complete, initialNasMsg->data + size, length - size);
} }
...@@ -836,14 +841,15 @@ static void generateRegistrationComplete(nr_ue_nas_t *nas, as_nas_info_t *initia ...@@ -836,14 +841,15 @@ static void generateRegistrationComplete(nr_ue_nas_t *nas, as_nas_info_t *initia
stream_compute_integrity(nas->security_container->integrity_algorithm, &stream_cipher, mac); stream_compute_integrity(nas->security_container->integrity_algorithm, &stream_cipher, mac);
printf("mac %x %x %x %x \n", mac[0], mac[1], mac[2], mac[3]); printf("mac %x %x %x %x \n", mac[0], mac[1], mac[2], mac[3]);
for(int i = 0; i < 4; i++){ for (int i = 0; i < 4; i++) {
initialNasMsg->data[2+i] = mac[i]; initialNasMsg->data[2 + i] = mac[i];
} }
} }
void decodeDownlinkNASTransport(as_nas_info_t *initialNasMsg, uint8_t * pdu_buffer){ void decodeDownlinkNASTransport(as_nas_info_t *initialNasMsg, uint8_t *pdu_buffer)
{
uint8_t msg_type = *(pdu_buffer + 16); uint8_t msg_type = *(pdu_buffer + 16);
if(msg_type == FGS_PDU_SESSION_ESTABLISHMENT_ACC){ if (msg_type == FGS_PDU_SESSION_ESTABLISHMENT_ACC) {
uint8_t *ip_p = pdu_buffer + 39; uint8_t *ip_p = pdu_buffer + 39;
char ip[20]; char ip[20];
sprintf(ip, "%d.%d.%d.%d", *(ip_p), *(ip_p + 1), *(ip_p + 2), *(ip_p + 3)); sprintf(ip, "%d.%d.%d.%d", *(ip_p), *(ip_p + 1), *(ip_p + 2), *(ip_p + 3));
...@@ -884,7 +890,9 @@ static void generateDeregistrationRequest(nr_ue_nas_t *nas, as_nas_info_t *initi ...@@ -884,7 +890,9 @@ static void generateDeregistrationRequest(nr_ue_nas_t *nas, as_nas_info_t *initi
initialNasMsg->data = calloc(size, sizeof(Byte_t)); initialNasMsg->data = calloc(size, sizeof(Byte_t));
int security_header_len = nas_protected_security_header_encode((char *)(initialNasMsg->data), &nas_msg.header, size); int security_header_len = nas_protected_security_header_encode((char *)(initialNasMsg->data), &nas_msg.header, size);
initialNasMsg->length = security_header_len + mm_msg_encode(&sp_msg->plain.mm_msg, (uint8_t *)(initialNasMsg->data + security_header_len), size - security_header_len); initialNasMsg->length =
security_header_len
+ mm_msg_encode(&sp_msg->plain.mm_msg, (uint8_t *)(initialNasMsg->data + security_header_len), size - security_header_len);
nas_stream_cipher_t stream_cipher; nas_stream_cipher_t stream_cipher;
...@@ -913,15 +921,15 @@ static void generateDeregistrationRequest(nr_ue_nas_t *nas, as_nas_info_t *initi ...@@ -913,15 +921,15 @@ static void generateDeregistrationRequest(nr_ue_nas_t *nas, as_nas_info_t *initi
stream_compute_integrity(nas->security_container->integrity_algorithm, &stream_cipher, mac); stream_compute_integrity(nas->security_container->integrity_algorithm, &stream_cipher, mac);
printf("mac %x %x %x %x \n", mac[0], mac[1], mac[2], mac[3]); printf("mac %x %x %x %x \n", mac[0], mac[1], mac[2], mac[3]);
for(int i = 0; i < 4; i++){ for (int i = 0; i < 4; i++) {
initialNasMsg->data[2+i] = mac[i]; initialNasMsg->data[2 + i] = mac[i];
} }
} }
static void generatePduSessionEstablishRequest(nr_ue_nas_t *nas, as_nas_info_t *initialNasMsg, nas_pdu_session_req_t *pdu_req) static void generatePduSessionEstablishRequest(nr_ue_nas_t *nas, as_nas_info_t *initialNasMsg, nas_pdu_session_req_t *pdu_req)
{ {
int size = 0; int size = 0;
fgs_nas_message_t nas_msg={0}; fgs_nas_message_t nas_msg = {0};
// setup pdu session establishment request // setup pdu session establishment request
uint16_t req_length = 7; uint16_t req_length = 7;
...@@ -935,8 +943,6 @@ static void generatePduSessionEstablishRequest(nr_ue_nas_t *nas, as_nas_info_t * ...@@ -935,8 +943,6 @@ static void generatePduSessionEstablishRequest(nr_ue_nas_t *nas, as_nas_info_t *
pdu_session_establish.pdusessiontype = pdu_req->pdusession_type; pdu_session_establish.pdusessiontype = pdu_req->pdusession_type;
encode_pdu_session_establishment_request(&pdu_session_establish, req_buffer); encode_pdu_session_establishment_request(&pdu_session_establish, req_buffer);
MM_msg *mm_msg; MM_msg *mm_msg;
nas_stream_cipher_t stream_cipher; nas_stream_cipher_t stream_cipher;
uint8_t mac[4]; uint8_t mac[4];
...@@ -966,14 +972,14 @@ static void generatePduSessionEstablishRequest(nr_ue_nas_t *nas, as_nas_info_t * ...@@ -966,14 +972,14 @@ static void generatePduSessionEstablishRequest(nr_ue_nas_t *nas, as_nas_info_t *
size += 1; size += 1;
mm_msg->uplink_nas_transport.fgspayloadcontainer.payloadcontainercontents.length = req_length; mm_msg->uplink_nas_transport.fgspayloadcontainer.payloadcontainercontents.length = req_length;
mm_msg->uplink_nas_transport.fgspayloadcontainer.payloadcontainercontents.value = req_buffer; mm_msg->uplink_nas_transport.fgspayloadcontainer.payloadcontainercontents.value = req_buffer;
size += (2+req_length); size += (2 + req_length);
mm_msg->uplink_nas_transport.pdusessionid = pdu_req->pdusession_id; mm_msg->uplink_nas_transport.pdusessionid = pdu_req->pdusession_id;
mm_msg->uplink_nas_transport.requesttype = 1; mm_msg->uplink_nas_transport.requesttype = 1;
size += 3; size += 3;
const bool has_nssai_sd = pdu_req->sd != 0xffffff; // 0xffffff means "no SD", TS 23.003 const bool has_nssai_sd = pdu_req->sd != 0xffffff; // 0xffffff means "no SD", TS 23.003
const size_t nssai_len = has_nssai_sd ? 4 : 1; const size_t nssai_len = has_nssai_sd ? 4 : 1;
mm_msg->uplink_nas_transport.snssai.length = nssai_len; mm_msg->uplink_nas_transport.snssai.length = nssai_len;
//Fixme: it seems there are a lot of memory errors in this: this value was on the stack, // Fixme: it seems there are a lot of memory errors in this: this value was on the stack,
// but pushed in a itti message to another thread // but pushed in a itti message to another thread
// this kind of error seems in many places in 5G NAS // this kind of error seems in many places in 5G NAS
mm_msg->uplink_nas_transport.snssai.value = calloc(1, nssai_len); mm_msg->uplink_nas_transport.snssai.value = calloc(1, nssai_len);
...@@ -981,18 +987,20 @@ static void generatePduSessionEstablishRequest(nr_ue_nas_t *nas, as_nas_info_t * ...@@ -981,18 +987,20 @@ static void generatePduSessionEstablishRequest(nr_ue_nas_t *nas, as_nas_info_t *
if (has_nssai_sd) if (has_nssai_sd)
INT24_TO_BUFFER(pdu_req->sd, &mm_msg->uplink_nas_transport.snssai.value[1]); INT24_TO_BUFFER(pdu_req->sd, &mm_msg->uplink_nas_transport.snssai.value[1]);
size += 1 + 1 + nssai_len; size += 1 + 1 + nssai_len;
int dnnSize=strlen(nas->uicc->dnnStr); int dnnSize = strlen(nas->uicc->dnnStr);
mm_msg->uplink_nas_transport.dnn.value=calloc(1,dnnSize+1); mm_msg->uplink_nas_transport.dnn.value = calloc(1, dnnSize + 1);
mm_msg->uplink_nas_transport.dnn.length = dnnSize + 1; mm_msg->uplink_nas_transport.dnn.length = dnnSize + 1;
mm_msg->uplink_nas_transport.dnn.value[0] = dnnSize; mm_msg->uplink_nas_transport.dnn.value[0] = dnnSize;
memcpy(mm_msg->uplink_nas_transport.dnn.value + 1, nas->uicc->dnnStr, dnnSize); memcpy(mm_msg->uplink_nas_transport.dnn.value + 1, nas->uicc->dnnStr, dnnSize);
size += (1+1+dnnSize+1); size += (1 + 1 + dnnSize + 1);
// encode the message // encode the message
initialNasMsg->data = (Byte_t *)malloc(size * sizeof(Byte_t)); initialNasMsg->data = (Byte_t *)malloc(size * sizeof(Byte_t));
int security_header_len = nas_protected_security_header_encode((char*)(initialNasMsg->data),&(nas_msg.header), size); int security_header_len = nas_protected_security_header_encode((char *)(initialNasMsg->data), &(nas_msg.header), size);
initialNasMsg->length = security_header_len + mm_msg_encode(mm_msg, (uint8_t*)(initialNasMsg->data+security_header_len), size-security_header_len); initialNasMsg->length =
security_header_len
+ mm_msg_encode(mm_msg, (uint8_t *)(initialNasMsg->data + security_header_len), size - security_header_len);
/* ciphering */ /* ciphering */
uint8_t buf[initialNasMsg->length - 7]; uint8_t buf[initialNasMsg->length - 7];
...@@ -1018,12 +1026,11 @@ static void generatePduSessionEstablishRequest(nr_ue_nas_t *nas, as_nas_info_t * ...@@ -1018,12 +1026,11 @@ static void generatePduSessionEstablishRequest(nr_ue_nas_t *nas, as_nas_info_t *
stream_compute_integrity(nas->security_container->integrity_algorithm, &stream_cipher, mac); stream_compute_integrity(nas->security_container->integrity_algorithm, &stream_cipher, mac);
printf("mac %x %x %x %x \n", mac[0], mac[1], mac[2], mac[3]); printf("mac %x %x %x %x \n", mac[0], mac[1], mac[2], mac[3]);
for(int i = 0; i < 4; i++){ for (int i = 0; i < 4; i++) {
initialNasMsg->data[2+i] = mac[i]; initialNasMsg->data[2 + i] = mac[i];
} }
} }
static uint8_t get_msg_type(uint8_t *pdu_buffer, uint32_t length) static uint8_t get_msg_type(uint8_t *pdu_buffer, uint32_t length)
{ {
if (pdu_buffer == NULL) if (pdu_buffer == NULL)
...@@ -1066,7 +1073,7 @@ static void send_nas_uplink_data_req(nr_ue_nas_t *nas, const as_nas_info_t *init ...@@ -1066,7 +1073,7 @@ static void send_nas_uplink_data_req(nr_ue_nas_t *nas, const as_nas_info_t *init
MessageDef *msg = itti_alloc_new_message(TASK_NAS_NRUE, nas->UE_id, NAS_UPLINK_DATA_REQ); MessageDef *msg = itti_alloc_new_message(TASK_NAS_NRUE, nas->UE_id, NAS_UPLINK_DATA_REQ);
ul_info_transfer_req_t *req = &NAS_UPLINK_DATA_REQ(msg); ul_info_transfer_req_t *req = &NAS_UPLINK_DATA_REQ(msg);
req->UEid = nas->UE_id; req->UEid = nas->UE_id;
req->nasMsg.data = (uint8_t *) initial_nas_msg->data; req->nasMsg.data = (uint8_t *)initial_nas_msg->data;
req->nasMsg.length = initial_nas_msg->length; req->nasMsg.length = initial_nas_msg->length;
itti_send_msg_to_task(TASK_RRC_NRUE, nas->UE_id, msg); itti_send_msg_to_task(TASK_RRC_NRUE, nas->UE_id, msg);
} }
...@@ -1207,9 +1214,7 @@ void *nas_nrue_task(void *args_p) ...@@ -1207,9 +1214,7 @@ void *nas_nrue_task(void *args_p)
} }
} }
static void handle_registration_accept(nr_ue_nas_t *nas, static void handle_registration_accept(nr_ue_nas_t *nas, const uint8_t *pdu_buffer, uint32_t msg_length)
const uint8_t *pdu_buffer,
uint32_t msg_length)
{ {
LOG_I(NAS, "[UE] Received REGISTRATION ACCEPT message\n"); LOG_I(NAS, "[UE] Received REGISTRATION ACCEPT message\n");
decodeRegistrationAccept(pdu_buffer, msg_length, nas); decodeRegistrationAccept(pdu_buffer, msg_length, nas);
...@@ -1305,8 +1310,7 @@ void *nas_nrue(void *args_p) ...@@ -1305,8 +1310,7 @@ void *nas_nrue(void *args_p)
int pdu_length = NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.length; int pdu_length = NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.length;
security_state_t security_state = nas_security_rx_process(nas, pdu_buffer, pdu_length); security_state_t security_state = nas_security_rx_process(nas, pdu_buffer, pdu_length);
if (security_state != NAS_SECURITY_INTEGRITY_PASSED if (security_state != NAS_SECURITY_INTEGRITY_PASSED && security_state != NAS_SECURITY_NO_SECURITY_CONTEXT) {
&& security_state != NAS_SECURITY_NO_SECURITY_CONTEXT) {
LOG_E(NAS, "NAS integrity failed, discard incoming message\n"); LOG_E(NAS, "NAS integrity failed, discard incoming message\n");
break; break;
} }
...@@ -1323,8 +1327,7 @@ void *nas_nrue(void *args_p) ...@@ -1323,8 +1327,7 @@ void *nas_nrue(void *args_p)
} }
case NR_NAS_CONN_RELEASE_IND: case NR_NAS_CONN_RELEASE_IND:
LOG_I(NAS, "[UE %ld] Received %s: cause %u\n", LOG_I(NAS, "[UE %ld] Received %s: cause %u\n", nas->UE_id, ITTI_MSG_NAME(msg_p), NR_NAS_CONN_RELEASE_IND(msg_p).cause);
nas->UE_id, ITTI_MSG_NAME (msg_p), NR_NAS_CONN_RELEASE_IND (msg_p).cause);
// TODO handle connection release // TODO handle connection release
if (nas->termination_procedure) { if (nas->termination_procedure) {
/* the following is not clean, but probably necessary: we need to give /* the following is not clean, but probably necessary: we need to give
...@@ -1385,8 +1388,7 @@ void *nas_nrue(void *args_p) ...@@ -1385,8 +1388,7 @@ void *nas_nrue(void *args_p)
security_state = NAS_SECURITY_INTEGRITY_PASSED; security_state = NAS_SECURITY_INTEGRITY_PASSED;
} }
if (security_state != NAS_SECURITY_INTEGRITY_PASSED if (security_state != NAS_SECURITY_INTEGRITY_PASSED && security_state != NAS_SECURITY_NO_SECURITY_CONTEXT) {
&& security_state != NAS_SECURITY_NO_SECURITY_CONTEXT) {
LOG_E(NAS, "NAS integrity failed, discard incoming message\n"); LOG_E(NAS, "NAS integrity failed, discard incoming message\n");
break; break;
} }
......
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