Merge remote-tracking branch 'origin/nr-ue-nas-cleanup' into integration_2024_w34
This commit is contained in:
@@ -188,7 +188,7 @@ static void nr_rrc_ue_process_rrcReconfiguration(NR_UE_RRC_INST_t *rrc,
|
|||||||
if (ie->nonCriticalExtension->dedicatedNAS_MessageList) {
|
if (ie->nonCriticalExtension->dedicatedNAS_MessageList) {
|
||||||
struct NR_RRCReconfiguration_v1530_IEs__dedicatedNAS_MessageList *tmp = ext->dedicatedNAS_MessageList;
|
struct NR_RRCReconfiguration_v1530_IEs__dedicatedNAS_MessageList *tmp = ext->dedicatedNAS_MessageList;
|
||||||
for (int i = 0; i < tmp->list.count; i++) {
|
for (int i = 0; i < tmp->list.count; i++) {
|
||||||
MessageDef *ittiMsg = itti_alloc_new_message(TASK_RRC_NRUE, 0, NAS_CONN_ESTABLI_CNF);
|
MessageDef *ittiMsg = itti_alloc_new_message(TASK_RRC_NRUE, rrc->ue_id, NAS_CONN_ESTABLI_CNF);
|
||||||
NasConnEstabCnf *msg = &NAS_CONN_ESTABLI_CNF(ittiMsg);
|
NasConnEstabCnf *msg = &NAS_CONN_ESTABLI_CNF(ittiMsg);
|
||||||
msg->errCode = AS_SUCCESS;
|
msg->errCode = AS_SUCCESS;
|
||||||
msg->nasMsg.length = tmp->list.array[i]->size;
|
msg->nasMsg.length = tmp->list.array[i]->size;
|
||||||
@@ -1658,7 +1658,7 @@ static int nr_rrc_ue_decode_dcch(NR_UE_RRC_INST_t *rrc,
|
|||||||
NR_DedicatedNAS_Message_t *dedicatedNAS_Message =
|
NR_DedicatedNAS_Message_t *dedicatedNAS_Message =
|
||||||
dlInformationTransfer->criticalExtensions.choice.dlInformationTransfer->dedicatedNAS_Message;
|
dlInformationTransfer->criticalExtensions.choice.dlInformationTransfer->dedicatedNAS_Message;
|
||||||
|
|
||||||
MessageDef *ittiMsg = itti_alloc_new_message(TASK_RRC_NRUE, 0, NAS_DOWNLINK_DATA_IND);
|
MessageDef *ittiMsg = itti_alloc_new_message(TASK_RRC_NRUE, rrc->ue_id, NAS_DOWNLINK_DATA_IND);
|
||||||
NasDlDataInd *msg = &NAS_DOWNLINK_DATA_IND(ittiMsg);
|
NasDlDataInd *msg = &NAS_DOWNLINK_DATA_IND(ittiMsg);
|
||||||
msg->UEid = rrc->ue_id;
|
msg->UEid = rrc->ue_id;
|
||||||
msg->nasMsg.length = dedicatedNAS_Message->size;
|
msg->nasMsg.length = dedicatedNAS_Message->size;
|
||||||
@@ -2310,7 +2310,7 @@ void nr_rrc_going_to_IDLE(NR_UE_RRC_INST_t *rrc,
|
|||||||
rrc->rnti = 0;
|
rrc->rnti = 0;
|
||||||
|
|
||||||
// Indicate the release of the RRC connection to upper layers
|
// Indicate the release of the RRC connection to upper layers
|
||||||
MessageDef *msg_p = itti_alloc_new_message(TASK_RRC_NRUE, 0, NR_NAS_CONN_RELEASE_IND);
|
MessageDef *msg_p = itti_alloc_new_message(TASK_RRC_NRUE, rrc->ue_id, NR_NAS_CONN_RELEASE_IND);
|
||||||
NR_NAS_CONN_RELEASE_IND(msg_p).cause = release_cause;
|
NR_NAS_CONN_RELEASE_IND(msg_p).cause = release_cause;
|
||||||
itti_send_msg_to_task(TASK_NAS_NRUE, rrc->ue_id, msg_p);
|
itti_send_msg_to_task(TASK_NAS_NRUE, rrc->ue_id, msg_p);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
@@ -52,8 +51,10 @@
|
|||||||
#include "openair3/SECU/nas_stream_eia2.h"
|
#include "openair3/SECU/nas_stream_eia2.h"
|
||||||
#include "openair3/UTILS/conversions.h"
|
#include "openair3/UTILS/conversions.h"
|
||||||
|
|
||||||
|
#define MAX_NAS_UE 4
|
||||||
|
|
||||||
extern uint16_t NB_UE_INST;
|
extern uint16_t NB_UE_INST;
|
||||||
static nr_ue_nas_t nr_ue_nas = {0};
|
static nr_ue_nas_t nr_ue_nas[MAX_NAS_UE] = {0};
|
||||||
static nr_nas_msg_snssai_t nas_allowed_nssai[8];
|
static nr_nas_msg_snssai_t nas_allowed_nssai[8];
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@@ -129,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;
|
||||||
|
|
||||||
@@ -152,8 +150,8 @@ static int nas_protected_security_header_encode(
|
|||||||
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 */
|
||||||
@@ -163,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,19 +219,21 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,19 +257,22 @@ 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)
|
||||||
@@ -279,7 +281,8 @@ int mm_msg_encode(MM_msg *mm_msg, uint8_t *buffer, uint32_t len) {
|
|||||||
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);
|
||||||
@@ -310,7 +313,6 @@ 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
|
||||||
@@ -322,7 +324,8 @@ 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};
|
||||||
|
|
||||||
@@ -343,7 +346,8 @@ 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};
|
uint8_t S[100] = {0};
|
||||||
S[0] = 0x6C; // FC
|
S[0] = 0x6C; // FC
|
||||||
servingNetworkName(S + 1, uicc->imsiStr, uicc->nmc_size);
|
servingNetworkName(S + 1, uicc->imsiStr, uicc->nmc_size);
|
||||||
@@ -355,7 +359,8 @@ void derive_kseaf(uint8_t kausf[32], uint8_t kseaf[32], uicc_t *uicc) {
|
|||||||
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
|
||||||
@@ -390,7 +395,8 @@ void derive_knas(algorithm_type_dist_t nas_alg_type, uint8_t nas_alg_id, uint8_t
|
|||||||
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
|
||||||
*/
|
*/
|
||||||
@@ -424,7 +430,8 @@ void derive_kgnb(uint8_t kamf[32], uint32_t count, uint8_t *kgnb){
|
|||||||
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];
|
||||||
|
|
||||||
@@ -478,10 +485,12 @@ void derive_ue_keys(uint8_t *buf, nr_ue_nas_t *nas) {
|
|||||||
|
|
||||||
nr_ue_nas_t *get_ue_nas_info(module_id_t module_id)
|
nr_ue_nas_t *get_ue_nas_info(module_id_t module_id)
|
||||||
{
|
{
|
||||||
DevAssert(module_id == 0);
|
DevAssert(module_id < MAX_NAS_UE);
|
||||||
if (!nr_ue_nas.uicc)
|
if (!nr_ue_nas[module_id].uicc) {
|
||||||
nr_ue_nas.uicc = checkUicc(0);
|
nr_ue_nas[module_id].uicc = checkUicc(module_id);
|
||||||
return &nr_ue_nas;
|
nr_ue_nas[module_id].UE_id = module_id;
|
||||||
|
}
|
||||||
|
return &nr_ue_nas[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)
|
||||||
@@ -496,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;
|
||||||
@@ -540,10 +548,10 @@ void generateRegistrationRequest(as_nas_info_t *initialNasMsg, nr_ue_nas_t *nas)
|
|||||||
|
|
||||||
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));
|
||||||
@@ -555,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;
|
||||||
@@ -571,7 +578,6 @@ void generateIdentityResponse(as_nas_info_t *initialNasMsg, uint8_t identitytype
|
|||||||
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)
|
||||||
@@ -613,7 +619,7 @@ static void generateAuthenticationResp(nr_ue_nas_t *nas, as_nas_info_t *initialN
|
|||||||
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])
|
||||||
{
|
{
|
||||||
MessageDef *message_p;
|
MessageDef *message_p;
|
||||||
message_p = itti_alloc_new_message(TASK_NAS_NRUE, 0, NAS_KENB_REFRESH_REQ);
|
message_p = itti_alloc_new_message(TASK_NAS_NRUE, instance, NAS_KENB_REFRESH_REQ);
|
||||||
memcpy(NAS_KENB_REFRESH_REQ(message_p).kenb, kgnb, sizeof(NAS_KENB_REFRESH_REQ(message_p).kenb));
|
memcpy(NAS_KENB_REFRESH_REQ(message_p).kenb, kgnb, sizeof(NAS_KENB_REFRESH_REQ(message_p).kenb));
|
||||||
return itti_send_msg_to_task(TASK_RRC_NRUE, instance, message_p);
|
return itti_send_msg_to_task(TASK_RRC_NRUE, instance, message_p);
|
||||||
}
|
}
|
||||||
@@ -659,7 +665,9 @@ static void generateSecurityModeComplete(nr_ue_nas_t *nas, as_nas_info_t *initia
|
|||||||
|
|
||||||
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];
|
||||||
@@ -691,7 +699,7 @@ static void generateSecurityModeComplete(nr_ue_nas_t *nas, as_nas_info_t *initia
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_security_mode_command(instance_t instance, nr_ue_nas_t *nas, as_nas_info_t *initialNasMsg, uint8_t *pdu, int pdu_length)
|
static void handle_security_mode_command(nr_ue_nas_t *nas, as_nas_info_t *initialNasMsg, uint8_t *pdu, int pdu_length)
|
||||||
{
|
{
|
||||||
/* retrieve integrity and ciphering algorithms */
|
/* retrieve integrity and ciphering algorithms */
|
||||||
AssertFatal(pdu_length > 10, "nas: bad pdu\n");
|
AssertFatal(pdu_length > 10, "nas: bad pdu\n");
|
||||||
@@ -721,7 +729,7 @@ static void handle_security_mode_command(instance_t instance, nr_ue_nas_t *nas,
|
|||||||
/* todo: stream_security_container_delete() is not called anywhere, deal with that */
|
/* todo: stream_security_container_delete() is not called anywhere, deal with that */
|
||||||
nas->security_container = stream_security_container_init(ciphering_algorithm, integrity_algorithm, knas_enc, knas_int);
|
nas->security_container = stream_security_container_init(ciphering_algorithm, integrity_algorithm, knas_enc, knas_int);
|
||||||
|
|
||||||
nas_itti_kgnb_refresh_req(instance, nas->security.kgnb);
|
nas_itti_kgnb_refresh_req(nas->UE_id, nas->security.kgnb);
|
||||||
generateSecurityModeComplete(nas, initialNasMsg);
|
generateSecurityModeComplete(nas, initialNasMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -749,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;
|
||||||
@@ -794,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);
|
||||||
|
|
||||||
@@ -837,7 +846,8 @@ static void generateRegistrationComplete(nr_ue_nas_t *nas, as_nas_info_t *initia
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
@@ -880,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;
|
||||||
|
|
||||||
@@ -931,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];
|
||||||
@@ -988,7 +998,9 @@ static void generatePduSessionEstablishRequest(nr_ue_nas_t *nas, as_nas_info_t *
|
|||||||
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];
|
||||||
@@ -1019,7 +1031,6 @@ static void generatePduSessionEstablishRequest(nr_ue_nas_t *nas, as_nas_info_t *
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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)
|
||||||
@@ -1057,22 +1068,22 @@ error:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void send_nas_uplink_data_req(instance_t instance, const as_nas_info_t *initial_nas_msg)
|
static void send_nas_uplink_data_req(nr_ue_nas_t *nas, const as_nas_info_t *initial_nas_msg)
|
||||||
{
|
{
|
||||||
MessageDef *msg = itti_alloc_new_message(TASK_NAS_NRUE, 0, 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 = instance;
|
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, instance, msg);
|
itti_send_msg_to_task(TASK_RRC_NRUE, nas->UE_id, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void send_nas_detach_req(instance_t instance, bool wait_release)
|
static void send_nas_detach_req(nr_ue_nas_t *nas, bool wait_release)
|
||||||
{
|
{
|
||||||
MessageDef *msg = itti_alloc_new_message(TASK_NAS_NRUE, 0, NAS_DETACH_REQ);
|
MessageDef *msg = itti_alloc_new_message(TASK_NAS_NRUE, nas->UE_id, NAS_DETACH_REQ);
|
||||||
nas_detach_req_t *req = &NAS_DETACH_REQ(msg);
|
nas_detach_req_t *req = &NAS_DETACH_REQ(msg);
|
||||||
req->wait_release = wait_release;
|
req->wait_release = wait_release;
|
||||||
itti_send_msg_to_task(TASK_RRC_NRUE, instance, msg);
|
itti_send_msg_to_task(TASK_RRC_NRUE, nas->UE_id, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void parse_allowed_nssai(nr_nas_msg_snssai_t nssaiList[8], const uint8_t *buf, const uint32_t len)
|
static void parse_allowed_nssai(nr_nas_msg_snssai_t nssaiList[8], const uint8_t *buf, const uint32_t len)
|
||||||
@@ -1171,14 +1182,14 @@ static void get_allowed_nssai(nr_nas_msg_snssai_t nssai[8], const uint8_t *pdu_b
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void request_default_pdusession(int instance, int nssai_idx)
|
static void request_default_pdusession(nr_ue_nas_t *nas, int nssai_idx)
|
||||||
{
|
{
|
||||||
MessageDef *message_p = itti_alloc_new_message(TASK_NAS_NRUE, 0, NAS_PDU_SESSION_REQ);
|
MessageDef *message_p = itti_alloc_new_message(TASK_NAS_NRUE, nas->UE_id, NAS_PDU_SESSION_REQ);
|
||||||
NAS_PDU_SESSION_REQ(message_p).pdusession_id = 10; /* first or default pdu session */
|
NAS_PDU_SESSION_REQ(message_p).pdusession_id = 10; /* first or default pdu session */
|
||||||
NAS_PDU_SESSION_REQ(message_p).pdusession_type = 0x91; // 0x91 = IPv4, 0x92 = IPv6, 0x93 = IPv4v6
|
NAS_PDU_SESSION_REQ(message_p).pdusession_type = 0x91; // 0x91 = IPv4, 0x92 = IPv6, 0x93 = IPv4v6
|
||||||
NAS_PDU_SESSION_REQ(message_p).sst = nas_allowed_nssai[nssai_idx].sst;
|
NAS_PDU_SESSION_REQ(message_p).sst = nas_allowed_nssai[nssai_idx].sst;
|
||||||
NAS_PDU_SESSION_REQ(message_p).sd = nas_allowed_nssai[nssai_idx].sd;
|
NAS_PDU_SESSION_REQ(message_p).sd = nas_allowed_nssai[nssai_idx].sd;
|
||||||
itti_send_msg_to_task(TASK_NAS_NRUE, instance, message_p);
|
itti_send_msg_to_task(TASK_NAS_NRUE, nas->UE_id, message_p);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_user_nssai_idx(const nr_nas_msg_snssai_t allowed_nssai[8], const nr_ue_nas_t *nas)
|
static int get_user_nssai_idx(const nr_nas_msg_snssai_t allowed_nssai[8], const nr_ue_nas_t *nas)
|
||||||
@@ -1193,16 +1204,17 @@ static int get_user_nssai_idx(const nr_nas_msg_snssai_t allowed_nssai[8], const
|
|||||||
|
|
||||||
void *nas_nrue_task(void *args_p)
|
void *nas_nrue_task(void *args_p)
|
||||||
{
|
{
|
||||||
nr_ue_nas.uicc = checkUicc(0);
|
for (int UE_id = 0; UE_id < NB_UE_INST; UE_id++) {
|
||||||
|
// This sets UE uicc from command line. Needs to be called 2 seconds into nr-ue runtime, otherwise the unused command line
|
||||||
|
// arguments will be reported as unused and the modem asserts.
|
||||||
|
(void)get_ue_nas_info(UE_id);
|
||||||
|
}
|
||||||
while (1) {
|
while (1) {
|
||||||
nas_nrue(NULL);
|
nas_nrue(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_registration_accept(instance_t instance,
|
static void handle_registration_accept(nr_ue_nas_t *nas, const uint8_t *pdu_buffer, uint32_t msg_length)
|
||||||
nr_ue_nas_t *nas,
|
|
||||||
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);
|
||||||
@@ -1211,27 +1223,25 @@ static void handle_registration_accept(instance_t instance,
|
|||||||
as_nas_info_t initialNasMsg = {0};
|
as_nas_info_t initialNasMsg = {0};
|
||||||
generateRegistrationComplete(nas, &initialNasMsg, NULL);
|
generateRegistrationComplete(nas, &initialNasMsg, NULL);
|
||||||
if (initialNasMsg.length > 0) {
|
if (initialNasMsg.length > 0) {
|
||||||
send_nas_uplink_data_req(instance, &initialNasMsg);
|
send_nas_uplink_data_req(nas, &initialNasMsg);
|
||||||
LOG_I(NAS, "Send NAS_UPLINK_DATA_REQ message(RegistrationComplete)\n");
|
LOG_I(NAS, "Send NAS_UPLINK_DATA_REQ message(RegistrationComplete)\n");
|
||||||
}
|
}
|
||||||
const int nssai_idx = get_user_nssai_idx(nas_allowed_nssai, nas);
|
const int nssai_idx = get_user_nssai_idx(nas_allowed_nssai, nas);
|
||||||
if (nssai_idx < 0) {
|
if (nssai_idx < 0) {
|
||||||
LOG_E(NAS, "NSSAI parameters not match with allowed NSSAI. Couldn't request PDU session.\n");
|
LOG_E(NAS, "NSSAI parameters not match with allowed NSSAI. Couldn't request PDU session.\n");
|
||||||
} else {
|
} else {
|
||||||
request_default_pdusession(instance, nssai_idx);
|
request_default_pdusession(nas, nssai_idx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void *nas_nrue(void *args_p)
|
void *nas_nrue(void *args_p)
|
||||||
{
|
{
|
||||||
// Wait for a message or an event
|
// Wait for a message or an event
|
||||||
nr_ue_nas.uicc = checkUicc(0);
|
|
||||||
MessageDef *msg_p;
|
MessageDef *msg_p;
|
||||||
itti_receive_msg(TASK_NAS_NRUE, &msg_p);
|
itti_receive_msg(TASK_NAS_NRUE, &msg_p);
|
||||||
|
|
||||||
if (msg_p != NULL) {
|
if (msg_p != NULL) {
|
||||||
instance_t instance = msg_p->ittiMsgHeader.originInstance;
|
nr_ue_nas_t *nas = get_ue_nas_info(msg_p->ittiMsgHeader.destinationInstance);
|
||||||
AssertFatal(instance == 0, "cannot handle more than one UE!\n");
|
|
||||||
|
|
||||||
switch (ITTI_MSG_ID(msg_p)) {
|
switch (ITTI_MSG_ID(msg_p)) {
|
||||||
case INITIALIZE_MESSAGE:
|
case INITIALIZE_MESSAGE:
|
||||||
@@ -1248,7 +1258,7 @@ void *nas_nrue(void *args_p)
|
|||||||
case NAS_CELL_SELECTION_CNF:
|
case NAS_CELL_SELECTION_CNF:
|
||||||
LOG_I(NAS,
|
LOG_I(NAS,
|
||||||
"[UE %ld] Received %s: errCode %u, cellID %u, tac %u\n",
|
"[UE %ld] Received %s: errCode %u, cellID %u, tac %u\n",
|
||||||
instance,
|
nas->UE_id,
|
||||||
ITTI_MSG_NAME(msg_p),
|
ITTI_MSG_NAME(msg_p),
|
||||||
NAS_CELL_SELECTION_CNF(msg_p).errCode,
|
NAS_CELL_SELECTION_CNF(msg_p).errCode,
|
||||||
NAS_CELL_SELECTION_CNF(msg_p).cellID,
|
NAS_CELL_SELECTION_CNF(msg_p).cellID,
|
||||||
@@ -1263,7 +1273,7 @@ void *nas_nrue(void *args_p)
|
|||||||
case NAS_CELL_SELECTION_IND:
|
case NAS_CELL_SELECTION_IND:
|
||||||
LOG_I(NAS,
|
LOG_I(NAS,
|
||||||
"[UE %ld] Received %s: cellID %u, tac %u\n",
|
"[UE %ld] Received %s: cellID %u, tac %u\n",
|
||||||
instance,
|
nas->UE_id,
|
||||||
ITTI_MSG_NAME(msg_p),
|
ITTI_MSG_NAME(msg_p),
|
||||||
NAS_CELL_SELECTION_IND(msg_p).cellID,
|
NAS_CELL_SELECTION_IND(msg_p).cellID,
|
||||||
NAS_CELL_SELECTION_IND(msg_p).tac);
|
NAS_CELL_SELECTION_IND(msg_p).tac);
|
||||||
@@ -1272,7 +1282,7 @@ void *nas_nrue(void *args_p)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case NAS_PAGING_IND:
|
case NAS_PAGING_IND:
|
||||||
LOG_I(NAS, "[UE %ld] Received %s: cause %u\n", instance, ITTI_MSG_NAME(msg_p), NAS_PAGING_IND(msg_p).cause);
|
LOG_I(NAS, "[UE %ld] Received %s: cause %u\n", nas->UE_id, ITTI_MSG_NAME(msg_p), NAS_PAGING_IND(msg_p).cause);
|
||||||
|
|
||||||
/* TODO not processed by NAS currently */
|
/* TODO not processed by NAS currently */
|
||||||
break;
|
break;
|
||||||
@@ -1280,10 +1290,9 @@ void *nas_nrue(void *args_p)
|
|||||||
case NAS_PDU_SESSION_REQ: {
|
case NAS_PDU_SESSION_REQ: {
|
||||||
as_nas_info_t pduEstablishMsg = {0};
|
as_nas_info_t pduEstablishMsg = {0};
|
||||||
nas_pdu_session_req_t *pduReq = &NAS_PDU_SESSION_REQ(msg_p);
|
nas_pdu_session_req_t *pduReq = &NAS_PDU_SESSION_REQ(msg_p);
|
||||||
nr_ue_nas_t *nas = get_ue_nas_info(0);
|
|
||||||
generatePduSessionEstablishRequest(nas, &pduEstablishMsg, pduReq);
|
generatePduSessionEstablishRequest(nas, &pduEstablishMsg, pduReq);
|
||||||
if (pduEstablishMsg.length > 0) {
|
if (pduEstablishMsg.length > 0) {
|
||||||
send_nas_uplink_data_req(instance, &pduEstablishMsg);
|
send_nas_uplink_data_req(nas, &pduEstablishMsg);
|
||||||
LOG_I(NAS, "Send NAS_UPLINK_DATA_REQ message(PduSessionEstablishRequest)\n");
|
LOG_I(NAS, "Send NAS_UPLINK_DATA_REQ message(PduSessionEstablishRequest)\n");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1292,7 +1301,7 @@ void *nas_nrue(void *args_p)
|
|||||||
case NAS_CONN_ESTABLI_CNF: {
|
case NAS_CONN_ESTABLI_CNF: {
|
||||||
LOG_I(NAS,
|
LOG_I(NAS,
|
||||||
"[UE %ld] Received %s: errCode %u, length %u\n",
|
"[UE %ld] Received %s: errCode %u, length %u\n",
|
||||||
instance,
|
nas->UE_id,
|
||||||
ITTI_MSG_NAME(msg_p),
|
ITTI_MSG_NAME(msg_p),
|
||||||
NAS_CONN_ESTABLI_CNF(msg_p).errCode,
|
NAS_CONN_ESTABLI_CNF(msg_p).errCode,
|
||||||
NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.length);
|
NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.length);
|
||||||
@@ -1300,11 +1309,8 @@ void *nas_nrue(void *args_p)
|
|||||||
uint8_t *pdu_buffer = NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.data;
|
uint8_t *pdu_buffer = NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.data;
|
||||||
int pdu_length = NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.length;
|
int pdu_length = NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.length;
|
||||||
|
|
||||||
nr_ue_nas_t *nas = get_ue_nas_info(0);
|
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
@@ -1312,7 +1318,7 @@ void *nas_nrue(void *args_p)
|
|||||||
int msg_type = get_msg_type(pdu_buffer, pdu_length);
|
int msg_type = get_msg_type(pdu_buffer, pdu_length);
|
||||||
|
|
||||||
if (msg_type == REGISTRATION_ACCEPT) {
|
if (msg_type == REGISTRATION_ACCEPT) {
|
||||||
handle_registration_accept(instance, nas, pdu_buffer, pdu_length);
|
handle_registration_accept(nas, pdu_buffer, pdu_length);
|
||||||
} else if (msg_type == FGS_PDU_SESSION_ESTABLISHMENT_ACC) {
|
} else if (msg_type == FGS_PDU_SESSION_ESTABLISHMENT_ACC) {
|
||||||
capture_pdu_session_establishment_accept_msg(pdu_buffer, pdu_length);
|
capture_pdu_session_establishment_accept_msg(pdu_buffer, pdu_length);
|
||||||
}
|
}
|
||||||
@@ -1321,9 +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);
|
||||||
instance, ITTI_MSG_NAME (msg_p), NR_NAS_CONN_RELEASE_IND (msg_p).cause);
|
|
||||||
nr_ue_nas_t *nas = get_ue_nas_info(0);
|
|
||||||
// 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
|
||||||
@@ -1338,7 +1342,7 @@ void *nas_nrue(void *args_p)
|
|||||||
case NAS_UPLINK_DATA_CNF:
|
case NAS_UPLINK_DATA_CNF:
|
||||||
LOG_I(NAS,
|
LOG_I(NAS,
|
||||||
"[UE %ld] Received %s: UEid %u, errCode %u\n",
|
"[UE %ld] Received %s: UEid %u, errCode %u\n",
|
||||||
instance,
|
nas->UE_id,
|
||||||
ITTI_MSG_NAME(msg_p),
|
ITTI_MSG_NAME(msg_p),
|
||||||
NAS_UPLINK_DATA_CNF(msg_p).UEid,
|
NAS_UPLINK_DATA_CNF(msg_p).UEid,
|
||||||
NAS_UPLINK_DATA_CNF(msg_p).errCode);
|
NAS_UPLINK_DATA_CNF(msg_p).errCode);
|
||||||
@@ -1346,33 +1350,31 @@ void *nas_nrue(void *args_p)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case NAS_DEREGISTRATION_REQ: {
|
case NAS_DEREGISTRATION_REQ: {
|
||||||
LOG_I(NAS, "[UE %ld] Received %s\n", instance, ITTI_MSG_NAME(msg_p));
|
LOG_I(NAS, "[UE %ld] Received %s\n", nas->UE_id, ITTI_MSG_NAME(msg_p));
|
||||||
nr_ue_nas_t *nas = get_ue_nas_info(0);
|
|
||||||
nas_deregistration_req_t *req = &NAS_DEREGISTRATION_REQ(msg_p);
|
nas_deregistration_req_t *req = &NAS_DEREGISTRATION_REQ(msg_p);
|
||||||
if (nas->guti) {
|
if (nas->guti) {
|
||||||
if (req->cause == AS_DETACH) {
|
if (req->cause == AS_DETACH) {
|
||||||
nas->termination_procedure = true;
|
nas->termination_procedure = true;
|
||||||
send_nas_detach_req(instance, true);
|
send_nas_detach_req(nas, true);
|
||||||
}
|
}
|
||||||
as_nas_info_t initialNasMsg = {0};
|
as_nas_info_t initialNasMsg = {0};
|
||||||
generateDeregistrationRequest(nas, &initialNasMsg, req);
|
generateDeregistrationRequest(nas, &initialNasMsg, req);
|
||||||
send_nas_uplink_data_req(instance, &initialNasMsg);
|
send_nas_uplink_data_req(nas, &initialNasMsg);
|
||||||
} else {
|
} else {
|
||||||
LOG_W(NAS, "No GUTI, cannot trigger deregistration request.\n");
|
LOG_W(NAS, "No GUTI, cannot trigger deregistration request.\n");
|
||||||
if (req->cause == AS_DETACH)
|
if (req->cause == AS_DETACH)
|
||||||
send_nas_detach_req(instance, false);
|
send_nas_detach_req(nas, false);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case NAS_DOWNLINK_DATA_IND: {
|
case NAS_DOWNLINK_DATA_IND: {
|
||||||
LOG_I(NAS,
|
LOG_I(NAS,
|
||||||
"[UE %ld] Received %s: length %u , buffer %p\n",
|
"[UE %ld] Received %s: length %u , buffer %p\n",
|
||||||
instance,
|
nas->UE_id,
|
||||||
ITTI_MSG_NAME(msg_p),
|
ITTI_MSG_NAME(msg_p),
|
||||||
NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.length,
|
NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.length,
|
||||||
NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.data);
|
NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.data);
|
||||||
as_nas_info_t initialNasMsg = {0};
|
as_nas_info_t initialNasMsg = {0};
|
||||||
nr_ue_nas_t *nas = get_ue_nas_info(0);
|
|
||||||
|
|
||||||
uint8_t *pdu_buffer = NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.data;
|
uint8_t *pdu_buffer = NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.data;
|
||||||
int pdu_length = NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.length;
|
int pdu_length = NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.length;
|
||||||
@@ -1386,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;
|
||||||
}
|
}
|
||||||
@@ -1402,13 +1403,13 @@ void *nas_nrue(void *args_p)
|
|||||||
generateAuthenticationResp(nas, &initialNasMsg, pdu_buffer);
|
generateAuthenticationResp(nas, &initialNasMsg, pdu_buffer);
|
||||||
break;
|
break;
|
||||||
case FGS_SECURITY_MODE_COMMAND:
|
case FGS_SECURITY_MODE_COMMAND:
|
||||||
handle_security_mode_command(instance, nas, &initialNasMsg, pdu_buffer, pdu_length);
|
handle_security_mode_command(nas, &initialNasMsg, pdu_buffer, pdu_length);
|
||||||
break;
|
break;
|
||||||
case FGS_DOWNLINK_NAS_TRANSPORT:
|
case FGS_DOWNLINK_NAS_TRANSPORT:
|
||||||
decodeDownlinkNASTransport(&initialNasMsg, pdu_buffer);
|
decodeDownlinkNASTransport(&initialNasMsg, pdu_buffer);
|
||||||
break;
|
break;
|
||||||
case REGISTRATION_ACCEPT:
|
case REGISTRATION_ACCEPT:
|
||||||
handle_registration_accept(instance, nas, pdu_buffer, pdu_length);
|
handle_registration_accept(nas, pdu_buffer, pdu_length);
|
||||||
break;
|
break;
|
||||||
case FGS_DEREGISTRATION_ACCEPT:
|
case FGS_DEREGISTRATION_ACCEPT:
|
||||||
LOG_I(NAS, "received deregistration accept\n");
|
LOG_I(NAS, "received deregistration accept\n");
|
||||||
@@ -1448,11 +1449,11 @@ void *nas_nrue(void *args_p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (initialNasMsg.length > 0)
|
if (initialNasMsg.length > 0)
|
||||||
send_nas_uplink_data_req(instance, &initialNasMsg);
|
send_nas_uplink_data_req(nas, &initialNasMsg);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
LOG_E(NAS, "[UE %ld] Received unexpected message %s\n", instance, ITTI_MSG_NAME(msg_p));
|
LOG_E(NAS, "[UE %ld] Received unexpected message %s\n", nas->UE_id, ITTI_MSG_NAME(msg_p));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ typedef struct {
|
|||||||
bool termination_procedure;
|
bool termination_procedure;
|
||||||
uint8_t *registration_request_buf;
|
uint8_t *registration_request_buf;
|
||||||
uint32_t registration_request_len;
|
uint32_t registration_request_len;
|
||||||
|
instance_t UE_id;
|
||||||
} nr_ue_nas_t;
|
} nr_ue_nas_t;
|
||||||
|
|
||||||
typedef enum fgs_protocol_discriminator_e {
|
typedef enum fgs_protocol_discriminator_e {
|
||||||
|
|||||||
Reference in New Issue
Block a user