add nas message for registration complete
This commit is contained in:
@@ -2458,6 +2458,7 @@ if(ITTI_SIM)
|
||||
${NAS_SRC}COMMON/EMM/MSG/FGSIdentityResponse.c
|
||||
${NAS_SRC}COMMON/EMM/MSG/FGSAuthenticationResponse.c
|
||||
${NAS_SRC}COMMON/EMM/MSG/FGSNASSecurityModeComplete.c
|
||||
${NAS_SRC}COMMON/EMM/MSG/RegistrationComplete.c
|
||||
)
|
||||
|
||||
set(libnrnas_ies_OBJS
|
||||
@@ -2469,6 +2470,7 @@ if(ITTI_SIM)
|
||||
${NAS_SRC}COMMON/IES/FGMMCapability.c
|
||||
${NAS_SRC}COMMON/IES/NrUESecurityCapability.c
|
||||
${NAS_SRC}COMMON/IES/FGCNasMessageContainer.c
|
||||
${NAS_SRC}COMMON/IES/SORTransparentContainer.c
|
||||
)
|
||||
|
||||
add_library(LIB_NAS_SIMUE
|
||||
|
||||
@@ -2298,12 +2298,28 @@ nr_rrc_ue_decode_dcch(
|
||||
break;
|
||||
|
||||
case NR_DL_DCCH_MessageType__c1_PR_rrcReconfiguration:
|
||||
{
|
||||
rrc_ue_process_rrcReconfiguration(ctxt_pP,
|
||||
dl_dcch_msg->message.choice.c1->choice.rrcReconfiguration,
|
||||
gNB_indexP);
|
||||
nr_rrc_ue_generate_RRCReconfigurationComplete(ctxt_pP,
|
||||
gNB_indexP,
|
||||
dl_dcch_msg->message.choice.c1->choice.rrcReconfiguration->rrc_TransactionIdentifier);
|
||||
#ifdef ITTI_SIM
|
||||
as_nas_info_t initialNasMsg;
|
||||
memset(&initialNasMsg, 0, sizeof(as_nas_info_t));
|
||||
generateRegistrationComplete(&initialNasMsg, NULL);
|
||||
if(initialNasMsg.length > 0){
|
||||
MessageDef *message_p;
|
||||
message_p = itti_alloc_new_message(TASK_RRC_NRUE, NAS_UPLINK_DATA_REQ);
|
||||
NAS_UPLINK_DATA_REQ(message_p).UEid = ctxt_pP->module_id;
|
||||
NAS_UPLINK_DATA_REQ(message_p).nasMsg.data = (uint8_t *)initialNasMsg.data;
|
||||
NAS_UPLINK_DATA_REQ(message_p).nasMsg.length = initialNasMsg.length;
|
||||
itti_send_msg_to_task(TASK_RRC_NRUE, ctxt_pP->instance, message_p);
|
||||
LOG_I(NR_RRC, " Send NAS_UPLINK_DATA_REQ message(RegistrationComplete)\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
case NR_DL_DCCH_MessageType__c1_PR_rrcResume:
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.openairinterface.org/?page_id=698
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
#include "TLVEncoder.h"
|
||||
#include "TLVDecoder.h"
|
||||
#include "RegistrationComplete.h"
|
||||
#include "SORTransparentContainer.h"
|
||||
|
||||
int decode_registration_complete(registration_complete_msg *registration_complete, uint8_t *buffer, uint32_t len)
|
||||
{
|
||||
uint32_t decoded = 0;
|
||||
int decoded_result = 0;
|
||||
|
||||
/* Decoding mandatory fields */
|
||||
if ((decoded_result = decode_sor_transparent_container(®istration_complete->sortransparentcontainer, 0, buffer + decoded, len - decoded)) < 0)
|
||||
return decoded_result;
|
||||
else
|
||||
decoded += decoded_result;
|
||||
|
||||
return decoded;
|
||||
}
|
||||
|
||||
int encode_registration_complete(registration_complete_msg *registration_complete, uint8_t *buffer, uint32_t len)
|
||||
{
|
||||
int encoded = 0;
|
||||
int encode_result = 0;
|
||||
|
||||
if ((encode_result =
|
||||
encode_sor_transparent_container(®istration_complete->sortransparentcontainer, 0,
|
||||
buffer + encoded, len - encoded)) < 0) //Return in case of error
|
||||
return encode_result;
|
||||
else
|
||||
encoded += encode_result;
|
||||
|
||||
return encoded;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/*! \file RegistrationRequest.h
|
||||
|
||||
\brief registration request procedures for gNB
|
||||
\author Yoshio INOUE, Masayuki HARADA
|
||||
\email: yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com
|
||||
\date 2020
|
||||
\version 0.1
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "ExtendedProtocolDiscriminator.h"
|
||||
#include "SecurityHeaderType.h"
|
||||
#include "SpareHalfOctet.h"
|
||||
#include "MessageType.h"
|
||||
#include "SORTransparentContainer.h"
|
||||
|
||||
#ifndef REGISTRATION_COMPLETE_H_
|
||||
#define REGISTRATION_COMPLETE_H_
|
||||
|
||||
|
||||
typedef struct registration_complete_msg_tag {
|
||||
/* Mandatory fields */
|
||||
ExtendedProtocolDiscriminator protocoldiscriminator;
|
||||
SecurityHeaderType securityheadertype:4;
|
||||
SpareHalfOctet sparehalfoctet:4;
|
||||
MessageType messagetype;
|
||||
|
||||
/* Optional fields */
|
||||
SORTransparentContainer sortransparentcontainer;
|
||||
} registration_complete_msg;
|
||||
|
||||
|
||||
int decode_registration_complete(registration_complete_msg *registrationcomplete, uint8_t *buffer, uint32_t len);
|
||||
|
||||
int encode_registration_complete(registration_complete_msg *registrationcomplete, uint8_t *buffer, uint32_t len);
|
||||
|
||||
#endif /* ! defined(REGISTRATION_COMPLETE_H_) */
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.openairinterface.org/?page_id=698
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "TLVEncoder.h"
|
||||
#include "TLVDecoder.h"
|
||||
#include "SORTransparentContainer.h"
|
||||
#include "nas_log.h"
|
||||
|
||||
//#define NAS_DEBUG 1
|
||||
|
||||
int decode_sor_transparent_container(SORTransparentContainer *sortransparentcontainer, uint8_t iei, uint8_t *buffer, uint32_t len)
|
||||
{
|
||||
int decoded = 0;
|
||||
int decode_result;
|
||||
uint16_t ielen;
|
||||
|
||||
LOG_FUNC_IN;
|
||||
|
||||
if (iei > 0) {
|
||||
CHECK_IEI_DECODER(iei, *buffer);
|
||||
decoded++;
|
||||
}
|
||||
|
||||
DECODE_LENGTH_U16(buffer + decoded, ielen, decoded);
|
||||
|
||||
CHECK_LENGTH_DECODER(len - decoded, ielen);
|
||||
|
||||
|
||||
if ((decode_result = decode_octet_string(&sortransparentcontainer->sortransparentcontainercontents, ielen, buffer + decoded, len - decoded)) < 0) {
|
||||
LOG_FUNC_RETURN(decode_result);
|
||||
} else {
|
||||
decoded += decode_result;
|
||||
}
|
||||
|
||||
#if defined (NAS_DEBUG)
|
||||
dump_sor_transparent_container_xml(sortransparentcontainer, iei);
|
||||
#endif
|
||||
LOG_FUNC_RETURN(decoded);
|
||||
}
|
||||
|
||||
int encode_sor_transparent_container(SORTransparentContainer *sortransparentcontainer, uint8_t iei, uint8_t *buffer, uint32_t len)
|
||||
{
|
||||
uint8_t *lenPtr;
|
||||
uint32_t encoded = 0;
|
||||
int32_t encode_result;
|
||||
/* Checking IEI and pointer */
|
||||
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, SOR_TRANSPARENT_CONTAINER_MINIMUM_LENGTH, len);
|
||||
#if defined (NAS_DEBUG)
|
||||
dump_sor_transparent_container_xml(sortransparentcontainer, iei);
|
||||
#endif
|
||||
|
||||
if (iei > 0) {
|
||||
*buffer = iei;
|
||||
encoded++;
|
||||
}
|
||||
|
||||
lenPtr = (buffer + encoded);
|
||||
|
||||
//encoded += 2;
|
||||
//if ((encode_result = encode_octet_string(&sortransparentcontainer->sortransparentcontainercontents, buffer + sizeof(uint16_t), len - sizeof(uint16_t))) < 0)
|
||||
if ((encode_result = encode_octet_string(&sortransparentcontainer->sortransparentcontainercontents, lenPtr + sizeof(uint16_t), len - sizeof(uint16_t))) < 0)
|
||||
return encode_result;
|
||||
else
|
||||
encoded += encode_result;
|
||||
|
||||
ENCODE_U16(lenPtr, encode_result, encoded);
|
||||
return encoded;
|
||||
}
|
||||
|
||||
void dump_sor_transparent_container_xml(SORTransparentContainer *sortransparentcontainer, uint8_t iei)
|
||||
{
|
||||
printf("<SOR Transparent Container>\n");
|
||||
|
||||
if (iei > 0)
|
||||
/* Don't display IEI if = 0 */
|
||||
printf(" <IEI>0x%X</IEI>\n", iei);
|
||||
|
||||
printf("%s", dump_octet_string_xml(&sortransparentcontainer->sortransparentcontainercontents));
|
||||
printf("</SOR Transparent Container>\n");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.openairinterface.org/?page_id=698
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "OctetString.h"
|
||||
|
||||
#ifndef SOR_TRANSPARENT_CONTAINER_H_
|
||||
#define SOR_TRANSPARENT_CONTAINER_H_
|
||||
|
||||
#define SOR_TRANSPARENT_CONTAINER_MINIMUM_LENGTH 2 // [length]+[length]
|
||||
#define SOR_TRANSPARENT_CONTAINER_MAXIMUM_LENGTH 65538 // [IEI]+[length]+[length]+[ESM msg]
|
||||
|
||||
typedef struct SORTransparentContainer_tag {
|
||||
OctetString sortransparentcontainercontents;
|
||||
} SORTransparentContainer;
|
||||
|
||||
int encode_sor_transparent_container(SORTransparentContainer *sortransparentcontainer, uint8_t iei, uint8_t *buffer, uint32_t len);
|
||||
|
||||
int decode_sor_transparent_container(SORTransparentContainer *sortransparentcontainer, uint8_t iei, uint8_t *buffer, uint32_t len);
|
||||
|
||||
void dump_sor_transparent_container_xml(SORTransparentContainer *sortransparentcontainer, uint8_t iei);
|
||||
|
||||
#endif /* ESM MESSAGE CONTAINER_H_ */
|
||||
|
||||
@@ -499,3 +499,81 @@ void generateSecurityModeComplete(as_nas_info_t *initialNasMsg)
|
||||
initialNasMsg->data[2+i] = mac[i];
|
||||
}
|
||||
}
|
||||
|
||||
void generateRegistrationComplete(as_nas_info_t *initialNasMsg, SORTransparentContainer *sortransparentcontainer) {
|
||||
int length = sizeof(fgs_nas_message_security_header_t);
|
||||
int size = 0;
|
||||
fgs_nas_message_t nas_msg;
|
||||
nas_stream_cipher_t stream_cipher;
|
||||
uint8_t mac[4];
|
||||
memset(&nas_msg, 0, sizeof(fgs_nas_message_t));
|
||||
fgs_nas_message_security_protected_t *sp_msg;
|
||||
|
||||
sp_msg = &nas_msg.security_protected;
|
||||
// set header
|
||||
sp_msg->header.protocol_discriminator = FGS_MOBILITY_MANAGEMENT_MESSAGE;
|
||||
sp_msg->header.security_header_type = INTEGRITY_PROTECTED_AND_CIPHERED;
|
||||
sp_msg->header.message_authentication_code = 0;
|
||||
sp_msg->header.sequence_number = 1;
|
||||
|
||||
sp_msg->plain.mm_msg.registration_complete.protocoldiscriminator = FGS_MOBILITY_MANAGEMENT_MESSAGE;
|
||||
length += 1;
|
||||
sp_msg->plain.mm_msg.registration_complete.securityheadertype = PLAIN_5GS_MSG;
|
||||
sp_msg->plain.mm_msg.registration_complete.sparehalfoctet = 0;
|
||||
length += 1;
|
||||
sp_msg->plain.mm_msg.registration_complete.messagetype = REGISTRATION_COMPLETE;
|
||||
length += 1;
|
||||
|
||||
if(sortransparentcontainer) {
|
||||
length += sortransparentcontainer->sortransparentcontainercontents.length;
|
||||
}
|
||||
|
||||
// encode the message
|
||||
initialNasMsg->data = (Byte_t *)malloc(length * sizeof(Byte_t));
|
||||
|
||||
/* Encode the first octet of the header (extended protocol discriminator) */
|
||||
ENCODE_U8(initialNasMsg->data + size, sp_msg->header.protocol_discriminator, size);
|
||||
|
||||
/* Encode the security header type */
|
||||
ENCODE_U8(initialNasMsg->data + size, sp_msg->header.security_header_type, size);
|
||||
|
||||
/* Encode the message authentication code */
|
||||
ENCODE_U32(initialNasMsg->data + size, sp_msg->header.message_authentication_code, size);
|
||||
|
||||
/* Encode the sequence number */
|
||||
ENCODE_U8(initialNasMsg->data + size, sp_msg->header.sequence_number, size);
|
||||
|
||||
|
||||
/* Encode the extended protocol discriminator */
|
||||
ENCODE_U8(initialNasMsg->data + size, sp_msg->plain.mm_msg.registration_complete.protocoldiscriminator, size);
|
||||
|
||||
/* Encode the security header type */
|
||||
ENCODE_U8(initialNasMsg->data + size, sp_msg->plain.mm_msg.registration_complete.securityheadertype, size);
|
||||
|
||||
/* Encode the message type */
|
||||
ENCODE_U8(initialNasMsg->data + size, sp_msg->plain.mm_msg.registration_complete.messagetype, size);
|
||||
|
||||
if(sortransparentcontainer) {
|
||||
encode_registration_complete(&sp_msg->plain.mm_msg.registration_complete, initialNasMsg->data + size, length - size);
|
||||
}
|
||||
|
||||
initialNasMsg->length = length;
|
||||
stream_cipher.key = knas_int.value;
|
||||
stream_cipher.key_length = 16;
|
||||
stream_cipher.count = 0;
|
||||
stream_cipher.bearer = 1;
|
||||
stream_cipher.direction = 0;
|
||||
stream_cipher.message = (unsigned char *)(initialNasMsg->data + 6);
|
||||
/* length in bits */
|
||||
stream_cipher.blength = (initialNasMsg->length - 6) << 3;
|
||||
|
||||
// only for Type of integrity protection algorithm: 128-5G-IA2 (2)
|
||||
nas_stream_encrypt_eia2(
|
||||
&stream_cipher,
|
||||
mac);
|
||||
|
||||
printf("mac %x %x %x %x \n", mac[0], mac[1], mac[2], mac[3]);
|
||||
for(int i = 0; i < 4; i++){
|
||||
initialNasMsg->data[2+i] = mac[i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "FGSIdentityResponse.h"
|
||||
#include "FGSAuthenticationResponse.h"
|
||||
#include "FGSNASSecurityModeComplete.h"
|
||||
#include "RegistrationComplete.h"
|
||||
#include "as_message.h"
|
||||
|
||||
|
||||
@@ -25,6 +26,7 @@
|
||||
#define INTEGRITY_PROTECTED_AND_CIPHERED_WITH_NEW_SECU_CTX 0b0100 // only for SECURITY MODE COMPLETE
|
||||
|
||||
#define REGISTRATION_REQUEST 0b01000001 /* 65 = 0x41 */
|
||||
#define REGISTRATION_COMPLETE 0b01000011 /* 67 = 0x43 */
|
||||
#define FGS_AUTHENTICATION_REQUEST 0b01010110 /* 86 = 0x56 */
|
||||
#define FGS_AUTHENTICATION_RESPONSE 0b01010111 /* 87 = 0x57 */
|
||||
#define FGS_IDENTITY_REQUEST 0b01011011 /* 91 = 0x5b */
|
||||
@@ -64,6 +66,7 @@ typedef union {
|
||||
fgs_identiy_response_msg fgs_identity_response;
|
||||
fgs_authentication_response_msg fgs_auth_response;
|
||||
fgs_security_mode_complete_msg fgs_security_mode_complete;
|
||||
registration_complete_msg registration_complete;
|
||||
} MM_msg;
|
||||
|
||||
|
||||
@@ -88,6 +91,7 @@ void generateRegistrationRequest(as_nas_info_t *initialNasMsg);
|
||||
void generateIdentityResponse(as_nas_info_t *initialNasMsg, uint8_t identitytype);
|
||||
void generateAuthenticationResp(as_nas_info_t *initialNasMsg, uint8_t *buf);
|
||||
void generateSecurityModeComplete(as_nas_info_t *initialNasMsg);
|
||||
void generateRegistrationComplete(as_nas_info_t *initialNasMsg, SORTransparentContainer *sortransparentcontainer);
|
||||
|
||||
#endif /* __NR_NAS_MSG_SIM_H__*/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user