Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
canghaiwuhen
OpenXG-RAN
Commits
5880c1f8
Commit
5880c1f8
authored
Oct 27, 2020
by
heshanyun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add nas message for registration request
parent
a5343618
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
525 additions
and
9 deletions
+525
-9
cmake_targets/CMakeLists.txt
cmake_targets/CMakeLists.txt
+119
-1
openair2/RRC/NR_UE/rrc_UE.c
openair2/RRC/NR_UE/rrc_UE.c
+11
-0
openair3/NAS/COMMON/EMM/MSG/RegistrationRequest.c
openair3/NAS/COMMON/EMM/MSG/RegistrationRequest.c
+24
-1
openair3/NAS/COMMON/EMM/MSG/RegistrationRequest.h
openair3/NAS/COMMON/EMM/MSG/RegistrationRequest.h
+5
-0
openair3/NAS/COMMON/IES/FGMMCapability.c
openair3/NAS/COMMON/IES/FGMMCapability.c
+34
-0
openair3/NAS/COMMON/IES/FGMMCapability.h
openair3/NAS/COMMON/IES/FGMMCapability.h
+30
-0
openair3/NAS/COMMON/IES/FGSMobileIdentity.c
openair3/NAS/COMMON/IES/FGSMobileIdentity.c
+2
-4
openair3/NAS/COMMON/IES/FGSRegistrationType.c
openair3/NAS/COMMON/IES/FGSRegistrationType.c
+3
-2
openair3/NAS/COMMON/IES/FGSRegistrationType.h
openair3/NAS/COMMON/IES/FGSRegistrationType.h
+1
-1
openair3/NAS/COMMON/IES/NrUESecurityCapability.c
openair3/NAS/COMMON/IES/NrUESecurityCapability.c
+42
-0
openair3/NAS/COMMON/IES/NrUESecurityCapability.h
openair3/NAS/COMMON/IES/NrUESecurityCapability.h
+33
-0
openair3/NAS/NR_UE/nr_nas_msg_sim.c
openair3/NAS/NR_UE/nr_nas_msg_sim.c
+148
-0
openair3/NAS/NR_UE/nr_nas_msg_sim.h
openair3/NAS/NR_UE/nr_nas_msg_sim.h
+73
-0
No files found.
cmake_targets/CMakeLists.txt
View file @
5880c1f8
...
...
@@ -2380,6 +2380,124 @@ if(NAS_UE)
endif
()
if
(
ITTI_SIM
)
set
(
libnas_ue_api_OBJS
${
NAS_SRC
}
UE/API/USER/at_command.c
${
NAS_SRC
}
UE/API/USER/at_error.c
${
NAS_SRC
}
UE/API/USER/at_response.c
${
NAS_SRC
}
UE/API/USER/user_api.c
${
NAS_SRC
}
UE/API/USER/user_indication.c
${
NAS_SRC
}
UE/API/USIM/aka_functions.c
${
NAS_SRC
}
UE/API/USIM/usim_api.c
)
set
(
libnas_ue_emm_OBJS
${
NAS_SRC
}
UE/EMM/Attach.c
${
NAS_SRC
}
UE/EMM/Authentication.c
${
NAS_SRC
}
UE/EMM/Detach.c
${
NAS_SRC
}
UE/EMM/emm_main.c
${
NAS_SRC
}
UE/EMM/EmmStatusHdl.c
${
NAS_SRC
}
UE/EMM/Identification.c
${
NAS_SRC
}
UE/EMM/IdleMode.c
${
NAS_SRC
}
UE/EMM/LowerLayer.c
${
NAS_SRC
}
UE/EMM/SecurityModeControl.c
${
NAS_SRC
}
UE/EMM/ServiceRequestHdl.c
${
NAS_SRC
}
UE/EMM/TrackingAreaUpdate.c
)
set
(
libnas_ue_emm_sap_OBJS
${
NAS_SRC
}
UE/EMM/SAP/emm_as.c
${
NAS_SRC
}
UE/EMM/SAP/EmmDeregisteredAttachNeeded.c
${
NAS_SRC
}
UE/EMM/SAP/EmmDeregisteredAttemptingToAttach.c
${
NAS_SRC
}
UE/EMM/SAP/EmmDeregistered.c
${
NAS_SRC
}
UE/EMM/SAP/EmmDeregisteredInitiated.c
${
NAS_SRC
}
UE/EMM/SAP/EmmDeregisteredLimitedService.c
${
NAS_SRC
}
UE/EMM/SAP/EmmDeregisteredNoCellAvailable.c
${
NAS_SRC
}
UE/EMM/SAP/EmmDeregisteredNoImsi.c
${
NAS_SRC
}
UE/EMM/SAP/EmmDeregisteredNormalService.c
${
NAS_SRC
}
UE/EMM/SAP/EmmDeregisteredPlmnSearch.c
${
NAS_SRC
}
UE/EMM/SAP/emm_esm.c
${
NAS_SRC
}
UE/EMM/SAP/emm_fsm.c
${
NAS_SRC
}
UE/EMM/SAP/EmmNull.c
${
NAS_SRC
}
UE/EMM/SAP/emm_recv.c
${
NAS_SRC
}
UE/EMM/SAP/emm_reg.c
${
NAS_SRC
}
UE/EMM/SAP/EmmRegisteredAttemptingToUpdate.c
${
NAS_SRC
}
UE/EMM/SAP/EmmRegistered.c
${
NAS_SRC
}
UE/EMM/SAP/EmmRegisteredImsiDetachInitiated.c
${
NAS_SRC
}
UE/EMM/SAP/EmmRegisteredInitiated.c
${
NAS_SRC
}
UE/EMM/SAP/EmmRegisteredLimitedService.c
${
NAS_SRC
}
UE/EMM/SAP/EmmRegisteredNoCellAvailable.c
${
NAS_SRC
}
UE/EMM/SAP/EmmRegisteredNormalService.c
${
NAS_SRC
}
UE/EMM/SAP/EmmRegisteredPlmnSearch.c
${
NAS_SRC
}
UE/EMM/SAP/EmmRegisteredUpdateNeeded.c
${
NAS_SRC
}
UE/EMM/SAP/emm_sap.c
${
NAS_SRC
}
UE/EMM/SAP/emm_send.c
${
NAS_SRC
}
UE/EMM/SAP/EmmServiceRequestInitiated.c
${
NAS_SRC
}
UE/EMM/SAP/EmmTrackingAreaUpdatingInitiated.c
)
set
(
libnas_ue_esm_OBJS
${
NAS_SRC
}
UE/ESM/DedicatedEpsBearerContextActivation.c
${
NAS_SRC
}
UE/ESM/DefaultEpsBearerContextActivation.c
${
NAS_SRC
}
UE/ESM/EpsBearerContextDeactivation.c
${
NAS_SRC
}
UE/ESM/esm_ebr.c
${
NAS_SRC
}
UE/ESM/esm_ebr_context.c
${
NAS_SRC
}
UE/ESM/esm_ip.c
${
NAS_SRC
}
UE/ESM/esm_main.c
${
NAS_SRC
}
UE/ESM/esm_pt.c
${
NAS_SRC
}
UE/ESM/EsmStatusHdl.c
${
NAS_SRC
}
UE/ESM/PdnConnectivity.c
${
NAS_SRC
}
UE/ESM/PdnDisconnect.c
)
set
(
libnas_ue_esm_sap_OBJS
${
NAS_SRC
}
UE/ESM/SAP/esm_recv.c
${
NAS_SRC
}
UE/ESM/SAP/esm_send.c
${
NAS_SRC
}
UE/ESM/SAP/esm_sap.c
)
set
(
libnrnas_emm_msg_OBJS
${
NAS_SRC
}
COMMON/EMM/MSG/RegistrationRequest.c
)
set
(
libnrnas_ies_OBJS
${
NAS_SRC
}
COMMON/IES/ExtendedProtocolDiscriminator.c
${
NAS_SRC
}
COMMON/IES/FGSMobileIdentity.c
${
NAS_SRC
}
COMMON/IES/FGSRegistrationType.c
${
NAS_SRC
}
COMMON/IES/SpareHalfOctet.c
${
NAS_SRC
}
COMMON/IES/FGMMCapability.c
${
NAS_SRC
}
COMMON/IES/NrUESecurityCapability.c
)
add_library
(
LIB_NAS_SIMUE
${
NAS_SRC
}
UE/nas_itti_messaging.c
${
NAS_SRC
}
UE/nas_network.c
${
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
${
libnas_api_OBJS
}
${
libnas_ue_api_OBJS
}
${
libnas_emm_msg_OBJS
}
${
libnas_esm_msg_OBJS
}
${
libnas_ies_OBJS
}
${
libnas_utils_OBJS
}
${
libnas_ue_emm_OBJS
}
${
libnas_ue_emm_sap_OBJS
}
${
libnas_ue_esm_OBJS
}
${
libnas_ue_esm_sap_OBJS
}
${
libnrnas_emm_msg_OBJS
}
${
libnrnas_ies_OBJS
}
)
add_dependencies
(
LIB_NAS_SIMUE rrc_flag
)
set
(
NAS_SIM_LIB LIB_NAS_SIMUE
)
include_directories
(
${
NAS_SRC
}
NR_UE
)
include_directories
(
${
NAS_SRC
}
UE
)
include_directories
(
${
NAS_SRC
}
UE/API/USER
)
include_directories
(
${
NAS_SRC
}
UE/API/USIM
)
include_directories
(
${
NAS_SRC
}
UE/EMM
)
include_directories
(
${
NAS_SRC
}
UE/EMM/SAP
)
include_directories
(
${
NAS_SRC
}
UE/ESM
)
include_directories
(
${
NAS_SRC
}
UE/ESM/SAP
)
endif
()
# nbiot
add_definitions
(
"-DNUMBER_OF_UE_MAX_NB_IoT=16"
)
set
(
NBIOT_SOURCES
...
...
@@ -3332,7 +3450,7 @@ add_executable(nr-ittisim
target_link_libraries
(
nr-ittisim
-Wl,--start-group
UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB SCHED_RU_LIB SCHED_NR_LIB PHY_NR PHY PHY_COMMON PHY_NR_COMMON PHY_RU LFDS NR_GTPV1U SECU_CN SECU_OSA
${
ITTI_LIB
}
${
FLPT_MSG_LIB
}
${
ASYNC_IF_LIB
}
${
FLEXRAN_AGENT_LIB
}
LFDS7
${
MSC_LIB
}
${
RAL_LIB
}
${
NAS_
UE
_LIB
}
RRC_LIB NR_RRC_LIB
${
ITTI_LIB
}
${
FLPT_MSG_LIB
}
${
ASYNC_IF_LIB
}
${
FLEXRAN_AGENT_LIB
}
LFDS7
${
MSC_LIB
}
${
RAL_LIB
}
${
NAS_
SIM
_LIB
}
RRC_LIB NR_RRC_LIB
NGAP_LIB NGAP_GNB S1AP_LIB S1AP_ENB L2_LTE_NR L2_NR MAC_NR_COMMON NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB
X2AP_LIB X2AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB
${
PROTO_AGENT_LIB
}
${
FSPT_MSG_LIB
}
NR_L2_UE
...
...
openair2/RRC/NR_UE/rrc_UE.c
View file @
5880c1f8
...
...
@@ -68,6 +68,10 @@
#include "RRC/NAS/rb_config.h"
#include "SIMULATION/TOOLS/sim.h" // for taus
#if ITTI_SIM
#include "nr_nas_msg_sim.h"
#endif
/* NAS Attach request with IMSI */
static
const
char
nr_nas_attach_req_imsi
[]
=
{
0x07
,
0x41
,
...
...
@@ -1351,8 +1355,15 @@ static void rrc_ue_generate_RRCSetupComplete(
const
char
*
nas_msg
;
int
nas_msg_length
;
if
(
AMF_MODE_ENABLED
)
{
#if ITTI_SIM
as_nas_info_t
initialNasMsg
;
generateRegistrationRequest
(
&
initialNasMsg
);
nas_msg
=
(
char
*
)
initialNasMsg
.
data
;
nas_msg_length
=
initialNasMsg
.
length
;
#else
nas_msg
=
(
char
*
)
NR_UE_rrc_inst
[
ctxt_pP
->
module_id
].
initialNasMsg
.
data
;
nas_msg_length
=
NR_UE_rrc_inst
[
ctxt_pP
->
module_id
].
initialNasMsg
.
length
;
#endif
}
else
{
nas_msg
=
nr_nas_attach_req_imsi
;
nas_msg_length
=
sizeof
(
nr_nas_attach_req_imsi
);
...
...
openair3/NAS/COMMON/EMM/MSG/RegistrationRequest.c
View file @
5880c1f8
...
...
@@ -65,7 +65,30 @@ int encode_registration_request(registration_request_msg *registration_request,
else
encoded
+=
encode_result
;
// TODO, Eecoding optional fields
if
((
registration_request
->
presencemask
&
REGISTRATION_REQUEST_5GMM_CAPABILITY_PRESENT
)
==
REGISTRATION_REQUEST_5GMM_CAPABILITY_PRESENT
)
{
if
((
encode_result
=
encode_5gmm_capability
(
&
registration_request
->
fgmmcapability
,
REGISTRATION_REQUEST_5GMM_CAPABILITY_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
// Return in case of error
return
encode_result
;
else
encoded
+=
encode_result
;
}
if
((
registration_request
->
presencemask
&
REGISTRATION_REQUEST_UE_SECURITY_CAPABILITY_PRESENT
)
==
REGISTRATION_REQUEST_UE_SECURITY_CAPABILITY_PRESENT
)
{
if
((
encode_result
=
encode_nrue_security_capability
(
&
registration_request
->
nruesecuritycapability
,
REGISTRATION_REQUEST_UE_SECURITY_CAPABILITY_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
// Return in case of error
return
encode_result
;
else
encoded
+=
encode_result
;
}
// TODO, Encoding optional fields
return
encoded
;
}
openair3/NAS/COMMON/EMM/MSG/RegistrationRequest.h
View file @
5880c1f8
...
...
@@ -18,6 +18,8 @@
#include "NasKeySetIdentifier.h"
#include "FGSRegistrationType.h"
#include "MessageType.h"
#include "FGMMCapability.h"
#include "NrUESecurityCapability.h"
#ifndef REGISTRATION_REQUEST_H_
#define REGISTRATION_REQUEST_H_
...
...
@@ -89,6 +91,9 @@ typedef struct registration_request_msg_tag {
FGSMobileIdentity
fgsmobileidentity
;
/* Optional fields */
uint32_t
presencemask
;
FGMMCapability
fgmmcapability
;
NrUESecurityCapability
nruesecuritycapability
;
}
registration_request_msg
;
int
decode_registration_request
(
registration_request_msg
*
registrationrequest
,
uint8_t
*
buffer
,
uint32_t
len
);
...
...
openair3/NAS/COMMON/IES/FGMMCapability.c
0 → 100644
View file @
5880c1f8
/*! \file FGSMobileIdentity.c
\brief 5GS Mobile Identity for registration request procedures
\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 "TLVEncoder.h"
#include "TLVDecoder.h"
#include "FGMMCapability.h"
int
encode_5gmm_capability
(
FGMMCapability
*
fgmmcapability
,
uint8_t
iei
,
uint8_t
*
buffer
,
uint32_t
len
)
{
int
encoded
=
0
;
if
(
iei
){
*
buffer
=
fgmmcapability
->
iei
;
encoded
++
;
*
(
buffer
+
encoded
)
=
fgmmcapability
->
length
;
encoded
++
;
*
(
buffer
+
encoded
)
=
fgmmcapability
->
value
;
encoded
++
;
}
return
encoded
;
}
openair3/NAS/COMMON/IES/FGMMCapability.h
0 → 100644
View file @
5880c1f8
/*! \file FGSMobileIdentity.h
\brief 5GS Mobile Identity for registration request procedures
\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 "OctetString.h"
#ifndef FGMM_CAPABILITY_H_
#define FGMM_CAPABILITY_H_
typedef
struct
{
uint8_t
iei
;
uint8_t
length
;
uint8_t
value
;
}
FGMMCapability
;
int
encode_5gmm_capability
(
FGMMCapability
*
fgmmcapability
,
uint8_t
iei
,
uint8_t
*
buffer
,
uint32_t
len
);
#endif
/* FGMM_CAPABILITY_H_ */
openair3/NAS/COMMON/IES/FGSMobileIdentity.c
View file @
5880c1f8
...
...
@@ -51,7 +51,6 @@ int decode_5gs_mobile_identity(FGSMobileIdentity *fgsmobileidentity, uint8_t iei
int
encode_5gs_mobile_identity
(
FGSMobileIdentity
*
fgsmobileidentity
,
uint8_t
iei
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint8_t
*
lenPtr
;
int
encoded_rc
=
TLV_ENCODE_VALUE_DOESNT_MATCH
;
uint32_t
encoded
=
0
;
...
...
@@ -60,8 +59,7 @@ int encode_5gs_mobile_identity(FGSMobileIdentity *fgsmobileidentity, uint8_t iei
encoded
++
;
}
lenPtr
=
(
buffer
+
encoded
);
encoded
++
;
encoded
=
encoded
+
2
;
if
(
fgsmobileidentity
->
guti
.
typeofidentity
==
FGS_MOBILE_IDENTITY_5G_GUTI
)
{
encoded_rc
=
encode_guti_5gs_mobile_identity
(
&
fgsmobileidentity
->
guti
,
...
...
@@ -72,7 +70,7 @@ int encode_5gs_mobile_identity(FGSMobileIdentity *fgsmobileidentity, uint8_t iei
return
encoded_rc
;
}
*
lenPtr
=
encoded
+
encoded_rc
-
1
-
((
iei
>
0
)
?
1
:
0
);
*
(
uint16_t
*
)
buffer
=
htons
(
encoded
+
encoded_rc
-
2
-
((
iei
>
0
)
?
1
:
0
)
);
return
(
encoded
+
encoded_rc
);
}
...
...
openair3/NAS/COMMON/IES/FGSRegistrationType.c
View file @
5880c1f8
...
...
@@ -15,9 +15,10 @@
#include "TLVDecoder.h"
#include "FGSRegistrationType.h"
int
decode_5gs_registration_type
(
FGSRegistrationType
*
fgsregistrationtype
,
uint8_t
iei
,
uint8_t
*
buffer
,
uint32_t
len
)
int
decode_5gs_registration_type
(
FGSRegistrationType
*
fgsregistrationtype
,
uint8_t
iei
,
uint8_t
value
,
uint32_t
len
)
{
int
decoded
=
0
;
uint8_t
*
buffer
=
&
value
;
if
(
iei
>
0
)
{
CHECK_IEI_DECODER
((
*
buffer
&
0xf0
),
iei
);
}
...
...
@@ -34,7 +35,7 @@ int encode_5gs_registration_type(FGSRegistrationType *fgsregistrationtype)
uint8_t
*
buffer
=
&
bufferReturn
;
uint8_t
encoded
=
0
;
uint8_t
iei
=
0
;
*
(
buffer
+
encoded
)
=
0x00
|
(
iei
&
0xf0
)
|
*
(
buffer
+
encoded
)
=
0x00
|
(
iei
&
0xf0
)
|
0x8
|
(
*
fgsregistrationtype
&
0x7
);
encoded
++
;
...
...
openair3/NAS/COMMON/IES/FGSRegistrationType.h
View file @
5880c1f8
...
...
@@ -28,7 +28,7 @@ typedef uint8_t FGSRegistrationType;
int
encode_5gs_registration_type
(
FGSRegistrationType
*
fgsregistrationtype
);
int
decode_5gs_registration_type
(
FGSRegistrationType
*
fgsregistrationtype
,
uint8_t
iei
,
uint8_t
*
buffer
,
uint32_t
len
);
int
decode_5gs_registration_type
(
FGSRegistrationType
*
fgsregistrationtype
,
uint8_t
iei
,
uint8_t
value
,
uint32_t
len
);
#endif
/* FGS_REGISTRATION_TYPE_H_*/
...
...
openair3/NAS/COMMON/IES/NrUESecurityCapability.c
0 → 100644
View file @
5880c1f8
/*! \file FGSMobileIdentity.c
\brief 5GS Mobile Identity for registration request procedures
\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 "TLVEncoder.h"
#include "TLVDecoder.h"
#include "NrUESecurityCapability.h"
int
encode_nrue_security_capability
(
NrUESecurityCapability
*
nruesecuritycapability
,
uint8_t
iei
,
uint8_t
*
buffer
,
uint32_t
len
)
{
int
encoded
=
0
;
if
(
iei
){
*
buffer
=
nruesecuritycapability
->
iei
;
encoded
++
;
*
(
buffer
+
encoded
)
=
nruesecuritycapability
->
length
;
encoded
++
;
*
(
buffer
+
encoded
)
=
nruesecuritycapability
->
fg_EA
;
encoded
++
;
*
(
buffer
+
encoded
)
=
nruesecuritycapability
->
fg_IA
;
encoded
++
;
*
(
buffer
+
encoded
)
=
nruesecuritycapability
->
EEA
;
encoded
++
;
*
(
buffer
+
encoded
)
=
nruesecuritycapability
->
EIA
;
encoded
++
;
if
((
nruesecuritycapability
->
length
-
4
)
>
0
)
encoded
=
encoded
+
nruesecuritycapability
->
length
-
4
;
}
return
encoded
;
}
openair3/NAS/COMMON/IES/NrUESecurityCapability.h
0 → 100644
View file @
5880c1f8
/*! \file FGSMobileIdentity.h
\brief 5GS Mobile Identity for registration request procedures
\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 "OctetString.h"
#ifndef NRUE_SECURITY_CAPABILITY_H_
#define NRUE_SECURITY_CAPABILITY_H_
typedef
struct
{
uint8_t
iei
;
uint8_t
length
;
uint8_t
fg_EA
;
uint8_t
fg_IA
;
uint8_t
EEA
;
uint8_t
EIA
;
}
NrUESecurityCapability
;
int
encode_nrue_security_capability
(
NrUESecurityCapability
*
nruesecuritycapability
,
uint8_t
iei
,
uint8_t
*
buffer
,
uint32_t
len
);
#endif
/* NRUE_SECURITY_CAPABILITY_H_ */
openair3/NAS/NR_UE/nr_nas_msg_sim.c
0 → 100644
View file @
5880c1f8
/*! \file nr_nas_msg_sim.c
\brief simulator for nr nas message
\author Yoshio INOUE, Masayuki HARADA
\email: yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com
\date 2020
\version 0.1
*/
#include <string.h> // memset
#include <stdlib.h> // malloc, free
#include "nas_log.h"
#include "TLVDecoder.h"
#include "TLVEncoder.h"
#include "nr_nas_msg_sim.h"
static
int
_nas_mm_msg_encode_header
(
const
mm_msg_header_t
*
header
,
uint8_t
*
buffer
,
uint32_t
len
)
{
int
size
=
0
;
/* Check the buffer length */
if
(
len
<
sizeof
(
mm_msg_header_t
))
{
return
(
TLV_ENCODE_BUFFER_TOO_SHORT
);
}
/* Check the protocol discriminator */
if
(
header
->
ex_protocol_discriminator
!=
FGS_MOBILITY_MANAGEMENT_MESSAGE
)
{
LOG_TRACE
(
ERROR
,
"ESM-MSG - Unexpected extened protocol discriminator: 0x%x"
,
header
->
ex_protocol_discriminator
);
return
(
TLV_ENCODE_PROTOCOL_NOT_SUPPORTED
);
}
/* Encode the extendedprotocol discriminator */
ENCODE_U8
(
buffer
+
size
,
header
->
ex_protocol_discriminator
,
size
);
/* Encode the security header type */
ENCODE_U8
(
buffer
+
size
,
(
header
->
security_header_type
&
0xf
),
size
);
/* Encode the message type */
ENCODE_U8
(
buffer
+
size
,
header
->
message_type
,
size
);
return
(
size
);
}
int
mm_msg_encode
(
MM_msg
*
mm_msg
,
uint8_t
*
buffer
,
uint32_t
len
)
{
LOG_FUNC_IN
;
int
header_result
;
int
encode_result
;
uint8_t
msg_type
=
mm_msg
->
header
.
message_type
;
/* First encode the EMM message header */
header_result
=
_nas_mm_msg_encode_header
(
&
mm_msg
->
header
,
buffer
,
len
);
if
(
header_result
<
0
)
{
LOG_TRACE
(
ERROR
,
"EMM-MSG - Failed to encode EMM message header "
"(%d)"
,
header_result
);
LOG_FUNC_RETURN
(
header_result
);
}
buffer
+=
header_result
;
len
-=
header_result
;
switch
(
msg_type
)
{
case
REGISTRATION_REQUEST
:
encode_result
=
encode_registration_request
(
&
mm_msg
->
registration_request
,
buffer
,
len
);
break
;
default:
LOG_TRACE
(
ERROR
,
"EMM-MSG - Unexpected message type: 0x%x"
,
mm_msg
->
header
.
message_type
);
encode_result
=
TLV_ENCODE_WRONG_MESSAGE_TYPE
;
break
;
/* TODO: Handle not standard layer 3 messages: SERVICE_REQUEST */
}
if
(
encode_result
<
0
)
{
LOG_TRACE
(
ERROR
,
"EMM-MSG - Failed to encode L3 EMM message 0x%x "
"(%d)"
,
mm_msg
->
header
.
message_type
,
encode_result
);
}
if
(
encode_result
<
0
)
LOG_FUNC_RETURN
(
encode_result
);
LOG_FUNC_RETURN
(
header_result
+
encode_result
);
}
void
generateRegistrationRequest
(
as_nas_info_t
*
initialNasMsg
)
{
int
size
=
sizeof
(
mm_msg_header_t
);
fgs_nas_message_t
nas_msg
;
memset
(
&
nas_msg
,
0
,
sizeof
(
fgs_nas_message_t
));
MM_msg
*
mm_msg
;
mm_msg
=
&
nas_msg
.
plain
.
mm_msg
;
// set header
mm_msg
->
header
.
ex_protocol_discriminator
=
FGS_MOBILITY_MANAGEMENT_MESSAGE
;
mm_msg
->
header
.
security_header_type
=
PLAIN_5GS_MSG
;
mm_msg
->
header
.
message_type
=
REGISTRATION_REQUEST
;
// set registration request
mm_msg
->
registration_request
.
protocoldiscriminator
=
FGS_MOBILITY_MANAGEMENT_MESSAGE
;
size
+=
1
;
mm_msg
->
registration_request
.
securityheadertype
=
PLAIN_5GS_MSG
;
size
+=
1
;
mm_msg
->
registration_request
.
messagetype
=
REGISTRATION_REQUEST
;
size
+=
1
;
mm_msg
->
registration_request
.
fgsregistrationtype
=
INITIAL_REGISTRATION
;
mm_msg
->
registration_request
.
naskeysetidentifier
.
naskeysetidentifier
=
NAS_KEY_SET_IDENTIFIER_NOT_AVAILABLE
;
size
+=
1
;
mm_msg
->
registration_request
.
fgsmobileidentity
.
guti
.
typeofidentity
=
FGS_MOBILE_IDENTITY_5G_GUTI
;
// mm_msg->registration_request.fgsmobileidentity.guti.amfregionid = 1;
// mm_msg->registration_request.fgsmobileidentity.guti.amfpointer = 1;
// mm_msg->registration_request.fgsmobileidentity.guti.amfsetid = 1;
mm_msg
->
registration_request
.
fgsmobileidentity
.
guti
.
tmsi
=
10
;
mm_msg
->
registration_request
.
fgsmobileidentity
.
guti
.
mncdigit1
=
9
;
mm_msg
->
registration_request
.
fgsmobileidentity
.
guti
.
mncdigit2
=
3
;
mm_msg
->
registration_request
.
fgsmobileidentity
.
guti
.
mccdigit1
=
2
;
mm_msg
->
registration_request
.
fgsmobileidentity
.
guti
.
mccdigit2
=
0
;
mm_msg
->
registration_request
.
fgsmobileidentity
.
guti
.
mccdigit3
=
8
;
size
+=
13
;
mm_msg
->
registration_request
.
presencemask
|=
REGISTRATION_REQUEST_5GMM_CAPABILITY_PRESENT
;
mm_msg
->
registration_request
.
fgmmcapability
.
iei
=
REGISTRATION_REQUEST_5GMM_CAPABILITY_IEI
;
mm_msg
->
registration_request
.
fgmmcapability
.
length
=
1
;
mm_msg
->
registration_request
.
fgmmcapability
.
value
=
0x7
;
size
+=
3
;
mm_msg
->
registration_request
.
presencemask
|=
REGISTRATION_REQUEST_UE_SECURITY_CAPABILITY_PRESENT
;
mm_msg
->
registration_request
.
nruesecuritycapability
.
iei
=
REGISTRATION_REQUEST_UE_SECURITY_CAPABILITY_IEI
;
mm_msg
->
registration_request
.
nruesecuritycapability
.
length
=
8
;
mm_msg
->
registration_request
.
nruesecuritycapability
.
fg_EA
=
0x80
;
mm_msg
->
registration_request
.
nruesecuritycapability
.
fg_IA
=
0x20
;
mm_msg
->
registration_request
.
nruesecuritycapability
.
EEA
=
0
;
mm_msg
->
registration_request
.
nruesecuritycapability
.
EIA
=
0
;
size
+=
10
;
// encode the message
initialNasMsg
->
data
=
(
Byte_t
*
)
malloc
(
size
*
sizeof
(
Byte_t
));
initialNasMsg
->
length
=
mm_msg_encode
(
mm_msg
,
(
uint8_t
*
)(
initialNasMsg
->
data
),
size
);
}
openair3/NAS/NR_UE/nr_nas_msg_sim.h
0 → 100644
View file @
5880c1f8
/*! \file nr_nas_msg_sim.h
\brief simulator for nr nas message
\author Yoshio INOUE, Masayuki HARADA
\email: yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com
\date 2020
\version 0.1
*/
#ifndef __NR_NAS_MSG_SIM_H__
#define __NR_NAS_MSG_SIM_H__
#include "RegistrationRequest.h"
#include "as_message.h"
#define PLAIN_5GS_MSG 0b0000
#define INTEGRITY_PROTECTED 0b0001
#define REGISTRATION_REQUEST 0b01000001
/* 65 = 0x41 */
#define INITIAL_REGISTRATION 0b001
typedef
enum
fgs_protocol_discriminator_e
{
/* Protocol discriminator identifier for 5GS Mobility Management */
FGS_MOBILITY_MANAGEMENT_MESSAGE
=
0x7E
,
/* Protocol discriminator identifier for 5GS Session Management */
FGS_SESSION_MANAGEMENT_MESSAGE
=
0x2E
,
}
fgs_protocol_discriminator_t
;
typedef
struct
{
uint8_t
ex_protocol_discriminator
;
uint8_t
security_header_type
;
uint8_t
message_type
;
}
mm_msg_header_t
;
/* 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_nas_message_security_header_t
;
typedef
union
{
mm_msg_header_t
header
;
registration_request_msg
registration_request
;
}
MM_msg
;
typedef
struct
{
MM_msg
mm_msg
;
/* 5GS Mobility Management messages */
}
fgs_nas_message_plain_t
;
typedef
struct
{
fgs_nas_message_security_header_t
header
;
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
;
fgs_nas_message_plain_t
plain
;
}
fgs_nas_message_t
;
void
generateRegistrationRequest
(
as_nas_info_t
*
initialNasMsg
);
#endif
/* __NR_NAS_MSG_SIM_H__*/
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment