remove duplicated code, add registration reject cause
This commit is contained in:
+1
-3
@@ -1781,7 +1781,7 @@ add_library(LIB_NAS_SIMUE
|
||||
${NAS_SRC}UE/nas_parser.c
|
||||
${NAS_SRC}UE/nas_proc.c
|
||||
${NAS_SRC}UE/nas_user.c
|
||||
${NAS_SRC}NR_UE/nr_nas_msg_sim.c
|
||||
${NAS_SRC}NR_UE/nr_nas_msg.c
|
||||
${libnas_api_OBJS}
|
||||
${libnas_ue_api_OBJS}
|
||||
${libnas_emm_msg_OBJS}
|
||||
@@ -1844,8 +1844,6 @@ add_library(NB_IoT MODULE ${NBIOT_SOURCES} )
|
||||
|
||||
add_library(LIB_5GNAS_GNB
|
||||
${NAS_SRC}/COMMON/nr_common.c
|
||||
${NAS_SRC}/gNB/network_process_nas.c
|
||||
${NAS_SRC}/NR_UE/ue_process_nas.c
|
||||
${OPENAIR3_DIR}//UICC/usim_interface.c
|
||||
)
|
||||
|
||||
|
||||
@@ -321,8 +321,6 @@ typedef struct {
|
||||
TASK_DEF(TASK_DU_F1, 200) \
|
||||
TASK_DEF(TASK_CUCP_E1, 200) \
|
||||
TASK_DEF(TASK_CUUP_E1, 200) \
|
||||
TASK_DEF(TASK_RRC_UE_SIM, 200) \
|
||||
TASK_DEF(TASK_RRC_GNB_SIM, 200) \
|
||||
TASK_DEF(TASK_RRC_NSA_UE, 200) \
|
||||
TASK_DEF(TASK_RRC_NSA_NRUE, 200) \
|
||||
TASK_DEF(TASK_NAS_NRUE, 200) \
|
||||
|
||||
+2
-4
@@ -1133,9 +1133,8 @@ INPUT = \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/UICC/usim_interface.h \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/UICC/usim_interface.c \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/ocp-gtpu/gtp_itf.h \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/NAS/NR_UE/nr_nas_msg_sim.h \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/NAS/NR_UE/ue_process_nas.c \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/NAS/NR_UE/nr_nas_msg_sim.c \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/NAS/NR_UE/nr_nas_msg.h \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/NAS/NR_UE/nr_nas_msgc \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/NAS/UE/nas_itti_messaging.c \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/NAS/UE/user_defs.h \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/NAS/UE/EMM/emm_proc.h \
|
||||
@@ -1584,7 +1583,6 @@ INPUT = \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/NAS/COMMON/ESM/MSG/ActivateDefaultEpsBearerContextAccept.h \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/NAS/COMMON/userDef.h \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/NAS/COMMON/nr_common.c \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/NAS/gNB/network_process_nas.c \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/UTILS/conversions.h \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/../openair2/X2AP/x2ap_eNB_encoder.h \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/../openair2/X2AP/x2ap_eNB_management_procedures.c \
|
||||
|
||||
@@ -84,7 +84,7 @@ unsigned short config_frames[4] = {2,9,11,13};
|
||||
#include "executables/softmodem-common.h"
|
||||
#include "executables/thread-common.h"
|
||||
|
||||
#include "nr_nas_msg_sim.h"
|
||||
#include "nr_nas_msg.h"
|
||||
#include <openair1/PHY/MODULATION/nr_modulation.h>
|
||||
#include "openair2/GNB_APP/gnb_paramdef.h"
|
||||
|
||||
@@ -335,7 +335,7 @@ static void trigger_stop(int sig)
|
||||
static void trigger_deregistration(int sig)
|
||||
{
|
||||
if (!stop_immediately) {
|
||||
MessageDef *msg = itti_alloc_new_message(TASK_RRC_UE_SIM, 0, NAS_DEREGISTRATION_REQ);
|
||||
MessageDef *msg = itti_alloc_new_message(TASK_NAS_NRUE, 0, NAS_DEREGISTRATION_REQ);
|
||||
NAS_DEREGISTRATION_REQ(msg).cause = AS_DETACH;
|
||||
itti_send_msg_to_task(TASK_NAS_NRUE, 0, msg);
|
||||
stop_immediately = true;
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
|
||||
#include "SIMULATION/TOOLS/sim.h" // for taus
|
||||
|
||||
#include "nr_nas_msg_sim.h"
|
||||
#include "nr_nas_msg.h"
|
||||
#include "openair2/SDAP/nr_sdap/nr_sdap_entity.h"
|
||||
|
||||
static NR_UE_RRC_INST_t *NR_UE_rrc_inst;
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
#include "PduSessionEstablishmentAccept.h"
|
||||
#include "common/utils/LOG/log.h"
|
||||
#include "nr_nas_msg_sim.h"
|
||||
#include "nr_nas_msg.h"
|
||||
#include "common/utils/tun_if.h"
|
||||
#include "openair2/SDAP/nr_sdap/nr_sdap.h"
|
||||
|
||||
|
||||
@@ -63,55 +63,55 @@ typedef enum {
|
||||
SGSmobilitymanagementmessages=0x7e,
|
||||
} Extendedprotocoldiscriminator_t;
|
||||
|
||||
#define FOREACH_TYPE(TYPE_DEF) \
|
||||
TYPE_DEF( Registrationrequest,0x41 )\
|
||||
TYPE_DEF( Registrationaccept,0x42 )\
|
||||
TYPE_DEF( Registrationcomplete,0x43 )\
|
||||
TYPE_DEF( Registrationreject,0x44 )\
|
||||
TYPE_DEF( DeregistrationrequestUEoriginating,0x45 )\
|
||||
TYPE_DEF( DeregistrationacceptUEoriginating,0x46 )\
|
||||
TYPE_DEF( DeregistrationrequestUEterminated,0x47 )\
|
||||
TYPE_DEF( DeregistrationacceptUEterminated,0x48 )\
|
||||
TYPE_DEF( Servicerequest,0x4c )\
|
||||
TYPE_DEF( Servicereject,0x4d )\
|
||||
TYPE_DEF( Serviceaccept,0x4e )\
|
||||
TYPE_DEF( Controlplaneservicerequest,0x4f )\
|
||||
TYPE_DEF( Networkslicespecificauthenticationcommand,0x50 )\
|
||||
TYPE_DEF( Networkslicespecificauthenticationcomplete,0x51 )\
|
||||
TYPE_DEF( Networkslicespecificauthenticationresult,0x52 )\
|
||||
TYPE_DEF( Configurationupdatecommand,0x54 )\
|
||||
TYPE_DEF( Configurationupdatecomplete,0x55 )\
|
||||
TYPE_DEF( Authenticationrequest,0x56 )\
|
||||
TYPE_DEF( Authenticationresponse,0x57 )\
|
||||
TYPE_DEF( Authenticationreject,0x58 )\
|
||||
TYPE_DEF( Authenticationfailure,0x59 )\
|
||||
TYPE_DEF( Authenticationresult,0x5a )\
|
||||
TYPE_DEF( Identityrequest,0x5b )\
|
||||
TYPE_DEF( Identityresponse,0x5c )\
|
||||
TYPE_DEF( Securitymodecommand,0x5d )\
|
||||
TYPE_DEF( Securitymodecomplete,0x5e )\
|
||||
TYPE_DEF( Securitymodereject,0x5f )\
|
||||
TYPE_DEF( SGMMstatus,0x64 )\
|
||||
TYPE_DEF( Notification,0x65 )\
|
||||
TYPE_DEF( Notificationresponse,0x66 )\
|
||||
TYPE_DEF( ULNAStransport,0x67 )\
|
||||
TYPE_DEF( DLNAStransport,0x68 )\
|
||||
TYPE_DEF( PDUsessionestablishmentrequest,0xc1 )\
|
||||
TYPE_DEF( PDUsessionestablishmentaccept,0xc2 )\
|
||||
TYPE_DEF( PDUsessionestablishmentreject,0xc3 )\
|
||||
TYPE_DEF( PDUsessionauthenticationcommand,0xc5 )\
|
||||
TYPE_DEF( PDUsessionauthenticationcomplete,0xc6 )\
|
||||
TYPE_DEF( PDUsessionauthenticationresult,0xc7 )\
|
||||
TYPE_DEF( PDUsessionmodificationrequest,0xc9 )\
|
||||
TYPE_DEF( PDUsessionmodificationreject,0xca )\
|
||||
TYPE_DEF( PDUsessionmodificationcommand,0xcb )\
|
||||
TYPE_DEF( PDUsessionmodificationcomplete,0xcc )\
|
||||
TYPE_DEF( PDUsessionmodificationcommandreject,0xcd )\
|
||||
TYPE_DEF( PDUsessionreleaserequest,0xd1 )\
|
||||
TYPE_DEF( PDUsessionreleasereject,0xd2 )\
|
||||
TYPE_DEF( PDUsessionreleasecommand,0xd3 )\
|
||||
TYPE_DEF( PDUsessionreleasecomplete,0xd4 )\
|
||||
TYPE_DEF( SGSMstatus,0xd6 )\
|
||||
#define FOREACH_TYPE(TYPE_DEF) \
|
||||
TYPE_DEF(REGISTRATION_REQUEST, 0x41) \
|
||||
TYPE_DEF(REGISTRATION_ACCEPT, 0x42) \
|
||||
TYPE_DEF(REGISTRATION_COMPLETE, 0x43) \
|
||||
TYPE_DEF(REGISTRATION_REJECT, 0x44) \
|
||||
TYPE_DEF(FGS_DEREGISTRATION_REQUEST_UE_ORIGINATING, 0x45) \
|
||||
TYPE_DEF(FGS_DEREGISTRATION_ACCEPT_UE_ORIGINATING, 0x46) \
|
||||
TYPE_DEF(DeregistrationrequestUEterminated, 0x47) \
|
||||
TYPE_DEF(DeregistrationacceptUEterminated, 0x48) \
|
||||
TYPE_DEF(Servicerequest, 0x4c) \
|
||||
TYPE_DEF(Servicereject, 0x4d) \
|
||||
TYPE_DEF(Serviceaccept, 0x4e) \
|
||||
TYPE_DEF(Controlplaneservicerequest, 0x4f) \
|
||||
TYPE_DEF(Networkslicespecificauthenticationcommand, 0x50) \
|
||||
TYPE_DEF(Networkslicespecificauthenticationcomplete, 0x51) \
|
||||
TYPE_DEF(Networkslicespecificauthenticationresult, 0x52) \
|
||||
TYPE_DEF(Configurationupdatecommand, 0x54) \
|
||||
TYPE_DEF(Configurationupdatecomplete, 0x55) \
|
||||
TYPE_DEF(FGS_AUTHENTICATION_REQUEST, 0x56) \
|
||||
TYPE_DEF(FGS_AUTHENTICATION_RESPONSE, 0x57) \
|
||||
TYPE_DEF(Authenticationreject, 0x58) \
|
||||
TYPE_DEF(Authenticationfailure, 0x59) \
|
||||
TYPE_DEF(Authenticationresult, 0x5a) \
|
||||
TYPE_DEF(FGS_IDENTITY_REQUEST, 0x5b) \
|
||||
TYPE_DEF(FGS_IDENTITY_RESPONSE, 0x5c) \
|
||||
TYPE_DEF(FGS_SECURITY_MODE_COMMAND, 0x5d) \
|
||||
TYPE_DEF(FGS_SECURITY_MODE_COMPLETE, 0x5e) \
|
||||
TYPE_DEF(Securitymodereject, 0x5f) \
|
||||
TYPE_DEF(SGMMstatus, 0x64) \
|
||||
TYPE_DEF(Notification, 0x65) \
|
||||
TYPE_DEF(Notificationresponse, 0x66) \
|
||||
TYPE_DEF(FGS_UPLINK_NAS_TRANSPORT, 0x67) \
|
||||
TYPE_DEF(FGS_DOWNLINK_NAS_TRANSPORT, 0x68) \
|
||||
TYPE_DEF(FGS_PDU_SESSION_ESTABLISHMENT_REQ, 0xc1) \
|
||||
TYPE_DEF(FGS_PDU_SESSION_ESTABLISHMENT_ACC, 0xc2) \
|
||||
TYPE_DEF(FGS_PDU_SESSION_ESTABLISHMENT_REJ, 0xc3) \
|
||||
TYPE_DEF(PDUsessionauthenticationcommand, 0xc5) \
|
||||
TYPE_DEF(PDUsessionauthenticationcomplete, 0xc6) \
|
||||
TYPE_DEF(PDUsessionauthenticationresult, 0xc7) \
|
||||
TYPE_DEF(PDUsessionmodificationrequest, 0xc9) \
|
||||
TYPE_DEF(PDUsessionmodificationreject, 0xca) \
|
||||
TYPE_DEF(PDUsessionmodificationcommand, 0xcb) \
|
||||
TYPE_DEF(PDUsessionmodificationcomplete, 0xcc) \
|
||||
TYPE_DEF(PDUsessionmodificationcommandreject, 0xcd) \
|
||||
TYPE_DEF(PDUsessionreleaserequest, 0xd1) \
|
||||
TYPE_DEF(PDUsessionreleasereject, 0xd2) \
|
||||
TYPE_DEF(PDUsessionreleasecommand, 0xd3) \
|
||||
TYPE_DEF(PDUsessionreleasecomplete, 0xd4) \
|
||||
TYPE_DEF(SGSMstatus, 0xd6)
|
||||
|
||||
static const text_info_t message_text_info[] = {
|
||||
FOREACH_TYPE(TO_TEXT)
|
||||
@@ -124,11 +124,11 @@ typedef enum {
|
||||
|
||||
// TS 24.501
|
||||
typedef enum {
|
||||
notsecurityprotected=0,
|
||||
Integrityprotected=1,
|
||||
Integrityprotectedandciphered=2,
|
||||
Integrityprotectedwithnew5GNASsecuritycontext=3,
|
||||
Integrityprotectedandcipheredwithnew5GNASsecuritycontext=4,
|
||||
PLAIN_5GS_MSG = 0,
|
||||
INTEGRITY_PROTECTED = 1,
|
||||
INTEGRITY_PROTECTED_AND_CIPHERED = 2,
|
||||
INTEGRITY_PROTECTED_WITH_NEW_SECU_CTX = 3,
|
||||
INTEGRITY_PROTECTED_AND_CIPHERED_WITH_NEW_SECU_CTX = 4,
|
||||
} Security_header_t;
|
||||
|
||||
typedef enum {
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
/*! \file nr_nas_msg_sim.c
|
||||
/*! \file nr_nas_msg.c
|
||||
* \brief simulator for nr nas message
|
||||
* \author Yoshio INOUE, Masayuki HARADA
|
||||
* \email yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com
|
||||
@@ -35,7 +35,7 @@
|
||||
#include "nas_log.h"
|
||||
#include "TLVDecoder.h"
|
||||
#include "TLVEncoder.h"
|
||||
#include "nr_nas_msg_sim.h"
|
||||
#include "nr_nas_msg.h"
|
||||
#include "aka_functions.h"
|
||||
#include "secu_defs.h"
|
||||
#include "kdf.h"
|
||||
@@ -1393,7 +1393,7 @@ void *nas_nrue(void *args_p)
|
||||
if (security_state == NAS_SECURITY_UNPROTECTED) {
|
||||
int msg_type = get_msg_type(pdu_buffer, pdu_length);
|
||||
/* for the moment, only FGS_DEREGISTRATION_ACCEPT is accepted */
|
||||
if (msg_type == FGS_DEREGISTRATION_ACCEPT)
|
||||
if (msg_type == FGS_DEREGISTRATION_ACCEPT_UE_ORIGINATING)
|
||||
security_state = NAS_SECURITY_INTEGRITY_PASSED;
|
||||
}
|
||||
|
||||
@@ -1420,7 +1420,7 @@ void *nas_nrue(void *args_p)
|
||||
case REGISTRATION_ACCEPT:
|
||||
handle_registration_accept(nas, pdu_buffer, pdu_length);
|
||||
break;
|
||||
case FGS_DEREGISTRATION_ACCEPT:
|
||||
case FGS_DEREGISTRATION_ACCEPT_UE_ORIGINATING:
|
||||
LOG_I(NAS, "received deregistration accept\n");
|
||||
break;
|
||||
case FGS_PDU_SESSION_ESTABLISHMENT_ACC: {
|
||||
@@ -1449,13 +1449,13 @@ void *nas_nrue(void *args_p)
|
||||
offset++;
|
||||
}
|
||||
} break;
|
||||
case FGS_PDU_SESSION_ESTABLISHMENT_REJ:
|
||||
LOG_E(NAS, "Received PDU Session Establishment reject\n");
|
||||
break;
|
||||
case REGISTRATION_REJECT:
|
||||
LOG_E(NAS, "Received Registration reject\n");
|
||||
exit(1);
|
||||
break;
|
||||
case FGS_PDU_SESSION_ESTABLISHMENT_REJ:
|
||||
LOG_E(NAS, "Received PDU Session Establishment reject\n");
|
||||
break;
|
||||
case REGISTRATION_REJECT:
|
||||
LOG_E(NAS, "Received Registration reject cause: %s\n", cause_text_info[pdu_buffer[17]].text);
|
||||
exit(1);
|
||||
break;
|
||||
default:
|
||||
LOG_W(NR_RRC, "unknown message type %d\n", msg_type);
|
||||
break;
|
||||
@@ -19,7 +19,7 @@
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
/*! \file nr_nas_msg_sim.h
|
||||
/*! \file nr_nas_msg.h
|
||||
* \brief simulator for nr nas message
|
||||
* \author Yoshio INOUE, Masayuki HARADA
|
||||
* \email yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com
|
||||
@@ -27,8 +27,6 @@
|
||||
* \version 0.1
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef __NR_NAS_MSG_SIM_H__
|
||||
#define __NR_NAS_MSG_SIM_H__
|
||||
|
||||
@@ -43,38 +41,12 @@
|
||||
#include <openair3/UICC/usim_interface.h>
|
||||
#include "secu_defs.h"
|
||||
|
||||
#define PLAIN_5GS_MSG 0b0000
|
||||
#define INTEGRITY_PROTECTED 0b0001
|
||||
#define INTEGRITY_PROTECTED_AND_CIPHERED 0b0010
|
||||
#define INTEGRITY_PROTECTED_WITH_NEW_SECU_CTX 0b0011 // only for SECURITY MODE COMMAND
|
||||
#define INTEGRITY_PROTECTED_AND_CIPHERED_WITH_NEW_SECU_CTX 0b0100 // only for SECURITY MODE COMPLETE
|
||||
#define INITIAL_REGISTRATION 0b001
|
||||
|
||||
#define REGISTRATION_REQUEST 0b01000001 /* 65 = 0x41 */
|
||||
#define REGISTRATION_ACCEPT 0b01000010 /* 66 = 0x42 */
|
||||
#define REGISTRATION_COMPLETE 0b01000011 /* 67 = 0x43 */
|
||||
#define REGISTRATION_REJECT 68
|
||||
#define FGS_DEREGISTRATION_REQUEST_UE_ORIGINATING 0b01000101
|
||||
#define FGS_DEREGISTRATION_ACCEPT 0b01000110
|
||||
#define FGS_AUTHENTICATION_REQUEST 0b01010110 /* 86 = 0x56 */
|
||||
#define FGS_AUTHENTICATION_RESPONSE 0b01010111 /* 87 = 0x57 */
|
||||
#define FGS_IDENTITY_REQUEST 0b01011011 /* 91 = 0x5b */
|
||||
#define FGS_IDENTITY_RESPONSE 0b01011100 /* 92 = 0x5c */
|
||||
#define FGS_SECURITY_MODE_COMMAND 0b01011101 /* 93 = 0x5d */
|
||||
#define FGS_SECURITY_MODE_COMPLETE 0b01011110 /* 94 = 0x5e */
|
||||
#define FGS_UPLINK_NAS_TRANSPORT 0b01100111 /* 103= 0x67 */
|
||||
#define FGS_DOWNLINK_NAS_TRANSPORT 0b01101000 /* 104= 0x68 */
|
||||
|
||||
// message type for 5GS session management
|
||||
#define FGS_PDU_SESSION_ESTABLISHMENT_REQ 0b11000001 /* 193= 0xc1 */
|
||||
#define FGS_PDU_SESSION_ESTABLISHMENT_ACC 0b11000010 /* 194= 0xc2 */
|
||||
#define FGS_PDU_SESSION_ESTABLISHMENT_REJ 0b11000011 /* 195= 0xc3 */
|
||||
|
||||
#define INITIAL_REGISTRATION 0b001
|
||||
|
||||
#define PLAIN_5GS_NAS_MESSAGE_HEADER_LENGTH 3
|
||||
#define SECURITY_PROTECTED_5GS_NAS_MESSAGE_HEADER_LENGTH 7
|
||||
#define PAYLOAD_CONTAINER_LENGTH_MIN 3
|
||||
#define PAYLOAD_CONTAINER_LENGTH_MAX 65537
|
||||
#define PLAIN_5GS_NAS_MESSAGE_HEADER_LENGTH 3
|
||||
#define SECURITY_PROTECTED_5GS_NAS_MESSAGE_HEADER_LENGTH 7
|
||||
#define PAYLOAD_CONTAINER_LENGTH_MIN 3
|
||||
#define PAYLOAD_CONTAINER_LENGTH_MAX 65537
|
||||
|
||||
/* List of allowed NSSAI from NAS messaging. */
|
||||
typedef struct {
|
||||
@@ -104,20 +76,19 @@ typedef struct {
|
||||
stream_security_container_t *security_container;
|
||||
Guti5GSMobileIdentity_t *guti;
|
||||
bool termination_procedure;
|
||||
uint8_t *registration_request_buf;
|
||||
uint32_t registration_request_len;
|
||||
uint8_t *registration_request_buf;
|
||||
uint32_t registration_request_len;
|
||||
instance_t UE_id;
|
||||
} nr_ue_nas_t;
|
||||
|
||||
typedef enum fgs_protocol_discriminator_e {
|
||||
/* Protocol discriminator identifier for 5GS Mobility Management */
|
||||
FGS_MOBILITY_MANAGEMENT_MESSAGE = 0x7E,
|
||||
FGS_MOBILITY_MANAGEMENT_MESSAGE = 0x7E,
|
||||
|
||||
/* Protocol discriminator identifier for 5GS Session Management */
|
||||
FGS_SESSION_MANAGEMENT_MESSAGE = 0x2E,
|
||||
FGS_SESSION_MANAGEMENT_MESSAGE = 0x2E,
|
||||
} fgs_protocol_discriminator_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t ex_protocol_discriminator;
|
||||
uint8_t security_header_type;
|
||||
@@ -126,27 +97,25 @@ typedef struct {
|
||||
|
||||
/* Structure of security protected header */
|
||||
typedef struct {
|
||||
fgs_protocol_discriminator_t protocol_discriminator;
|
||||
uint8_t security_header_type;
|
||||
uint32_t message_authentication_code;
|
||||
uint8_t sequence_number;
|
||||
fgs_protocol_discriminator_t protocol_discriminator;
|
||||
uint8_t security_header_type;
|
||||
uint32_t message_authentication_code;
|
||||
uint8_t sequence_number;
|
||||
} fgs_nas_message_security_header_t;
|
||||
|
||||
typedef union {
|
||||
mm_msg_header_t header;
|
||||
registration_request_msg registration_request;
|
||||
fgs_identiy_response_msg fgs_identity_response;
|
||||
fgs_authentication_response_msg fgs_auth_response;
|
||||
mm_msg_header_t header;
|
||||
registration_request_msg registration_request;
|
||||
fgs_identiy_response_msg fgs_identity_response;
|
||||
fgs_authentication_response_msg fgs_auth_response;
|
||||
fgs_deregistration_request_ue_originating_msg fgs_deregistration_request_ue_originating;
|
||||
fgs_security_mode_complete_msg fgs_security_mode_complete;
|
||||
registration_complete_msg registration_complete;
|
||||
fgs_uplink_nas_transport_msg uplink_nas_transport;
|
||||
fgs_security_mode_complete_msg fgs_security_mode_complete;
|
||||
registration_complete_msg registration_complete;
|
||||
fgs_uplink_nas_transport_msg uplink_nas_transport;
|
||||
} MM_msg;
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
MM_msg mm_msg; /* 5GS Mobility Management messages */
|
||||
MM_msg mm_msg; /* 5GS Mobility Management messages */
|
||||
} fgs_nas_message_plain_t;
|
||||
|
||||
typedef struct {
|
||||
@@ -154,7 +123,6 @@ typedef struct {
|
||||
fgs_nas_message_plain_t plain;
|
||||
} fgs_nas_message_security_protected_t;
|
||||
|
||||
|
||||
typedef union {
|
||||
fgs_nas_message_security_header_t header;
|
||||
fgs_nas_message_security_protected_t security_protected;
|
||||
@@ -165,11 +133,11 @@ typedef struct {
|
||||
union {
|
||||
mm_msg_header_t plain_nas_msg_header;
|
||||
struct security_protected_nas_msg_header_s {
|
||||
uint8_t ex_protocol_discriminator;
|
||||
uint8_t security_header_type;
|
||||
uint8_t ex_protocol_discriminator;
|
||||
uint8_t security_header_type;
|
||||
uint16_t message_authentication_code1;
|
||||
uint16_t message_authentication_code2;
|
||||
uint8_t sequence_number;
|
||||
uint8_t sequence_number;
|
||||
} security_protected_nas_msg_header_t;
|
||||
} choice;
|
||||
} nas_msg_header_t;
|
||||
@@ -182,10 +150,10 @@ typedef struct {
|
||||
} fgs_sm_nas_msg_header_t;
|
||||
|
||||
typedef struct {
|
||||
mm_msg_header_t plain_nas_msg_header;
|
||||
uint8_t payload_container_type;
|
||||
uint16_t payload_container_length;
|
||||
fgs_sm_nas_msg_header_t sm_nas_msg_header;
|
||||
mm_msg_header_t plain_nas_msg_header;
|
||||
uint8_t payload_container_type;
|
||||
uint16_t payload_container_length;
|
||||
fgs_sm_nas_msg_header_t sm_nas_msg_header;
|
||||
} dl_nas_transport_t;
|
||||
|
||||
nr_ue_nas_t *get_ue_nas_info(module_id_t module_id);
|
||||
@@ -194,6 +162,3 @@ void *nas_nrue_task(void *args_p);
|
||||
void *nas_nrue(void *args_p);
|
||||
|
||||
#endif /* __NR_NAS_MSG_SIM_H__*/
|
||||
|
||||
|
||||
|
||||
@@ -1,178 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* Author and copyright: Laurent Thomas, open-cells.com
|
||||
*
|
||||
* 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 <openair3/NAS/COMMON/NR_NAS_defs.h>
|
||||
#include <openair3/SECU/secu_defs.h>
|
||||
|
||||
|
||||
void SGSabortNet(void *msg, nr_user_nas_t *UE) {
|
||||
}
|
||||
|
||||
void ue_nas_schedule(void) {
|
||||
}
|
||||
|
||||
/*
|
||||
*Message reception
|
||||
*/
|
||||
|
||||
void SGSauthenticationReq(void *msg, nr_user_nas_t *UE) {
|
||||
authenticationrequestHeader_t *amsg=(authenticationrequestHeader_t *) msg;
|
||||
arrayCpy(UE->uicc->rand,amsg->RAND);
|
||||
arrayCpy(UE->uicc->autn,amsg->AUTN);
|
||||
// AUTHENTICATION REQUEST message that contains a valid ngKSI, SQN and MAC is received
|
||||
// TBD verify ngKSI (we set it as '2', see gNB code)
|
||||
// SQN and MAC are tested in auth resp processing
|
||||
ue_nas_schedule();
|
||||
}
|
||||
|
||||
void SGSidentityReq(void *msg, nr_user_nas_t *UE) {
|
||||
Identityrequest_t *idmsg=(Identityrequest_t *) msg;
|
||||
|
||||
if (idmsg->it == SUCI ) {
|
||||
LOG_I(NAS,"Received Identity request, scheduling answer\n");
|
||||
ue_nas_schedule();
|
||||
} else
|
||||
LOG_E(NAS,"Not developped: identity request for %d\n", idmsg->it);
|
||||
}
|
||||
|
||||
void SGSsecurityModeCommand(void *msg, nr_user_nas_t *UE) {
|
||||
}
|
||||
|
||||
|
||||
void UEprocessNAS(void *msg,nr_user_nas_t *UE) {
|
||||
SGScommonHeader_t *header=(SGScommonHeader_t *) msg;
|
||||
|
||||
if ( header->sh > 4 )
|
||||
SGSabortNet(msg, UE);
|
||||
else {
|
||||
switch (header->epd) {
|
||||
case SGSmobilitymanagementmessages:
|
||||
LOG_I(NAS,"Received message: %s\n", idStr(message_text_info, header->mt));
|
||||
|
||||
switch (header->mt) {
|
||||
case Authenticationrequest:
|
||||
SGSauthenticationReq(msg, UE);
|
||||
break;
|
||||
|
||||
case Identityrequest:
|
||||
SGSidentityReq(msg, UE);
|
||||
break;
|
||||
|
||||
case Securitymodecommand:
|
||||
SGSsecurityModeCommand(msg, UE);
|
||||
break;
|
||||
|
||||
default:
|
||||
SGSabortNet(msg, UE);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case SGSsessionmanagementmessages:
|
||||
SGSabortNet(msg, UE);
|
||||
break;
|
||||
|
||||
default:
|
||||
SGSabortNet(msg, UE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Messages emission
|
||||
*/
|
||||
|
||||
int identityResponse(void **msg, nr_user_nas_t *UE) {
|
||||
if (UE->uicc == NULL)
|
||||
// config file section hardcoded as "uicc", nevertheless it opens to manage several UEs or a multi SIM UE
|
||||
UE->uicc=init_uicc("uicc");
|
||||
|
||||
// TS 24.501 9.11.3.4
|
||||
int imsiL=strlen(UE->uicc->imsiStr);
|
||||
int msinL=imsiL-3-UE->uicc->nmc_size;
|
||||
int respSize=sizeof(IdentityresponseIMSI_t) + (msinL+1)/2;
|
||||
IdentityresponseIMSI_t *resp=(IdentityresponseIMSI_t *) calloc(respSize,1);
|
||||
resp->common.epd=SGSmobilitymanagementmessages;
|
||||
resp->common.sh=0;
|
||||
resp->common.mt=Identityresponse;
|
||||
resp->common.len=htons(respSize-sizeof(Identityresponse_t));
|
||||
resp->mi=SUCI;
|
||||
resp->mcc1=UE->uicc->imsiStr[0]-'0';
|
||||
resp->mcc2=UE->uicc->imsiStr[1]-'0';
|
||||
resp->mcc3=UE->uicc->imsiStr[2]-'0';
|
||||
resp->mnc1=UE->uicc->imsiStr[3]-'0';
|
||||
resp->mnc2=UE->uicc->imsiStr[4]-'0';
|
||||
resp->mnc3=UE->uicc->nmc_size==2? 0xF : UE->uicc->imsiStr[3]-'0';
|
||||
// TBD: routing to fill (FF ?)
|
||||
char *out=(char *)(resp+1);
|
||||
char *ptr=UE->uicc->imsiStr + 3 + UE->uicc->nmc_size;
|
||||
|
||||
while ( ptr < UE->uicc->imsiStr+strlen(UE->uicc->imsiStr) ) {
|
||||
*out=((*(ptr+1)-'0')<<4) | (*(ptr) -'0');
|
||||
out++;
|
||||
ptr+=2;
|
||||
}
|
||||
|
||||
if (msinL%2 == 1)
|
||||
*out=((*(ptr-1)-'0')) | 0xF0;
|
||||
|
||||
*msg=resp;
|
||||
return respSize;
|
||||
}
|
||||
|
||||
int authenticationResponse(void **msg,nr_user_nas_t *UE) {
|
||||
if (UE->uicc == NULL)
|
||||
// config file section hardcoded as "uicc", nevertheless it opens to manage several UEs or a multi SIM UE
|
||||
UE->uicc=init_uicc("uicc");
|
||||
|
||||
myCalloc(resp, authenticationresponse_t);
|
||||
resp->epd=SGSmobilitymanagementmessages;
|
||||
resp->sh=0;
|
||||
resp->mt=Authenticationresponse;
|
||||
resp->iei=IEI_AuthenticationResponse;
|
||||
resp->RESlen=sizeof(resp->RES); // always 16 see TS 24.501 Table 8.2.2.1.1
|
||||
// Verify the AUTN
|
||||
// a full implementation need to test several SQN
|
||||
// as the last 5bits can be any value
|
||||
// and the value can also be greater and accepted (if it is in the accepted window)
|
||||
uint8_t AUTN[16];
|
||||
uicc_milenage_generate(AUTN, UE->uicc);
|
||||
|
||||
if ( memcmp(UE->uicc->autn, AUTN, sizeof(AUTN)) == 0 ) {
|
||||
// prepare and send good answer
|
||||
resToresStar(resp->RES,UE->uicc);
|
||||
} else {
|
||||
// prepare and send autn is not compatible with our data
|
||||
abort();
|
||||
}
|
||||
|
||||
*msg=resp;
|
||||
return sizeof(authenticationresponse_t);
|
||||
}
|
||||
|
||||
int securityModeComplete(void **msg, nr_user_nas_t *UE) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int registrationComplete(void **msg, nr_user_nas_t *UE) {
|
||||
return -1;
|
||||
}
|
||||
@@ -1,214 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* Author and copyright: Laurent Thomas, open-cells.com
|
||||
*
|
||||
* 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 <openair3/NAS/COMMON/NR_NAS_defs.h>
|
||||
|
||||
void SGSabortUE(void *msg, NRUEcontext_t *UE) {
|
||||
}
|
||||
void nas_schedule(void) {
|
||||
}
|
||||
/*
|
||||
*Message reception
|
||||
*/
|
||||
|
||||
void SGSregistrationReq(void *msg, NRUEcontext_t *UE) {
|
||||
}
|
||||
|
||||
void SGSderegistrationUEReq(void *msg, NRUEcontext_t *UE) {
|
||||
}
|
||||
|
||||
void SGSidentityResp(void *msg, NRUEcontext_t *UE) {
|
||||
// use the UE SUPI to load the USIM
|
||||
IdentityresponseIMSI_t *resp=(IdentityresponseIMSI_t *)msg;
|
||||
char configName[100]={0};
|
||||
char * ptr= stpcpy(configName,"uicc");
|
||||
*ptr++=resp->mcc1+'0';
|
||||
*ptr++=resp->mcc2+'0';
|
||||
*ptr++=resp->mcc3+'0';
|
||||
*ptr++=resp->mnc1+'0';
|
||||
*ptr++=resp->mnc2+'0';
|
||||
if ( resp->mnc3 != 0xF )
|
||||
*ptr++=resp->mnc3 +'0';
|
||||
int respSize=ntohs(resp->common.len);
|
||||
int msinByteSize=respSize-sizeof(IdentityresponseIMSI_t);
|
||||
uint8_t * msin=(uint8_t *) (resp+1);
|
||||
for(int i=3 ; i<msinByteSize; i++) {
|
||||
char digit1=(msin[i] >> 4) ;
|
||||
*ptr++=(msin[i] & 0xf) +'0';
|
||||
if (digit1 != 0xf)
|
||||
*ptr++=digit1 +'0';
|
||||
}
|
||||
*ptr=0;
|
||||
if (UE->uicc == NULL)
|
||||
// config file section hardcoded as "uicc", nevertheless it opens to manage several UEs or a multi SIM UE
|
||||
UE->uicc=init_uicc(configName);
|
||||
//We schedule Authentication request
|
||||
nas_schedule();
|
||||
}
|
||||
|
||||
void SGSauthenticationResp(void *msg, NRUEcontext_t *UE) {
|
||||
// Let's check the answer
|
||||
authenticationresponse_t* resp=(authenticationresponse_t*) msg;
|
||||
uint8_t resStarLocal[16];
|
||||
resToresStar(resStarLocal,UE->uicc);
|
||||
if ( memcmp(resStarLocal, resp->RES, sizeof(resStarLocal)) == 0 ) {
|
||||
LOG_I(NAS,"UE answer to authentication resquest is correct\n");
|
||||
// we will send securityModeCommand
|
||||
nas_schedule();
|
||||
} else {
|
||||
LOG_E(NAS,"UE authentication response not good\n");
|
||||
// To be implemented ?
|
||||
}
|
||||
}
|
||||
|
||||
void SGSsecurityModeComplete(void *msg, NRUEcontext_t *UE) {
|
||||
|
||||
}
|
||||
|
||||
void SGSregistrationComplete(void *msg, NRUEcontext_t *UE) {
|
||||
}
|
||||
|
||||
void processNAS(void *msg, NRUEcontext_t *UE) {
|
||||
SGScommonHeader_t *header=(SGScommonHeader_t *) msg;
|
||||
|
||||
if ( header->sh > 4 )
|
||||
SGSabortUE(msg, UE);
|
||||
else {
|
||||
switch (header->epd) {
|
||||
case SGSmobilitymanagementmessages:
|
||||
LOG_I(NAS,"Received message: %s\n", idStr(message_text_info, header->mt));
|
||||
|
||||
switch (header->mt) {
|
||||
case Registrationrequest:
|
||||
SGSregistrationReq(msg, UE);
|
||||
break;
|
||||
|
||||
case DeregistrationrequestUEoriginating:
|
||||
SGSderegistrationUEReq(msg, UE);
|
||||
break;
|
||||
|
||||
case Authenticationresponse:
|
||||
SGSauthenticationResp(msg, UE);
|
||||
break;
|
||||
|
||||
case Identityresponse:
|
||||
SGSidentityResp(msg, UE);
|
||||
break;
|
||||
|
||||
case Securitymodecomplete:
|
||||
SGSsecurityModeComplete(msg, UE);
|
||||
break;
|
||||
|
||||
case Registrationcomplete:
|
||||
SGSregistrationComplete(msg, UE);
|
||||
break;
|
||||
|
||||
default:
|
||||
SGSabortUE(msg, UE);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case SGSsessionmanagementmessages:
|
||||
SGSabortUE(msg, UE);
|
||||
break;
|
||||
|
||||
default:
|
||||
SGSabortUE(msg, UE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Messages emission
|
||||
*/
|
||||
|
||||
int identityRequest(void **msg, NRUEcontext_t *UE) {
|
||||
myCalloc(req, Identityrequest_t);
|
||||
req->epd=SGSmobilitymanagementmessages;
|
||||
req->sh=0;
|
||||
req->mt=Identityrequest;
|
||||
req->it=SUCI;
|
||||
*msg=req;
|
||||
return sizeof(Identityrequest_t);
|
||||
}
|
||||
|
||||
int authenticationRequest(void **msg, NRUEcontext_t *UE) {
|
||||
|
||||
myCalloc(req, authenticationrequestHeader_t);
|
||||
req->epd=SGSmobilitymanagementmessages;
|
||||
req->sh=0;
|
||||
req->mt=Authenticationrequest;
|
||||
// native security context => bit 4 to 0
|
||||
// probably from TS 33.501, table A-8.1
|
||||
// N-NAS-int-alg (Native NAS integrity)
|
||||
/*
|
||||
N-NAS-enc-alg 0x01
|
||||
N-NAS-int-alg 0x02
|
||||
N-RRC-enc-alg 0x03
|
||||
N-RRC-int-alg 0x04
|
||||
N-UP-enc-alg 0x05
|
||||
N-UP-int-alg 0x06
|
||||
*/
|
||||
req->ngKSI=2;
|
||||
// TS 33.501, Annex A.7.1: Initial set of security features defined for 5GS.
|
||||
req->ABBALen=2;
|
||||
req->ABBA=0;
|
||||
//rand (TV)
|
||||
req->ieiRAND=IEI_RAND;
|
||||
FILE *h=fopen("/dev/random","r");
|
||||
|
||||
if ( sizeof(req->RAND) != fread(req->RAND,1,sizeof(req->RAND),h) )
|
||||
LOG_E(NAS, "can't read /dev/random\n");
|
||||
|
||||
fclose(h);
|
||||
memcpy(UE->uicc->rand, req->RAND, sizeof(UE->uicc->rand));
|
||||
// challenge/AUTN (TLV)
|
||||
req->ieiAUTN=IEI_AUTN;
|
||||
req->AUTNlen=sizeof(req->AUTN);
|
||||
uicc_milenage_generate( req->AUTN, UE->uicc);
|
||||
// EAP message (TLV-E)
|
||||
// not developped
|
||||
*msg=req;
|
||||
return sizeof(authenticationrequestHeader_t);
|
||||
}
|
||||
|
||||
int securityModeCommand(void **msg, NRUEcontext_t *UE) {
|
||||
*msg=NULL;
|
||||
myCalloc(req, securityModeCommand_t);
|
||||
req->epd=SGSmobilitymanagementmessages;
|
||||
req->sh=0;
|
||||
req->mt=Securitymodecommand;
|
||||
|
||||
// integrity algo from 5G-IA0 (null algo) to 5G-IA7 in first 4 bits
|
||||
unsigned int ia=0;
|
||||
// cyphering algo from 5G-EA0 (null algo) to 5G-IA7 in MSB 4 bits
|
||||
unsigned int ea=0;
|
||||
// trace from commercial: 5G-IA0 (0) 128-5G-IA2 (2)
|
||||
req->selectedNASsecurityalgorithms= ea<<4 | ia;
|
||||
|
||||
// KSI: N-NAS-int-alg 0x02
|
||||
req->ngKSI=2;
|
||||
|
||||
*msg=req;
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user