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
spbro
OpenXG-RAN
Commits
e35401ef
Commit
e35401ef
authored
Mar 13, 2023
by
Robert Schmidt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
NAS refactor: no moduleID, group UICC and security in one context
parent
223fd28b
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
93 additions
and
93 deletions
+93
-93
openair2/RRC/NR_UE/rrc_UE.c
openair2/RRC/NR_UE/rrc_UE.c
+2
-1
openair3/NAS/COMMON/NR_NAS_defs.h
openair3/NAS/COMMON/NR_NAS_defs.h
+1
-1
openair3/NAS/COMMON/nr_common.c
openair3/NAS/COMMON/nr_common.c
+1
-1
openair3/NAS/NR_UE/nr_nas_msg_sim.c
openair3/NAS/NR_UE/nr_nas_msg_sim.c
+79
-85
openair3/NAS/NR_UE/nr_nas_msg_sim.h
openair3/NAS/NR_UE/nr_nas_msg_sim.h
+8
-1
openair3/UICC/usim_interface.c
openair3/UICC/usim_interface.c
+1
-2
openair3/UICC/usim_interface.h
openair3/UICC/usim_interface.h
+1
-2
No files found.
openair2/RRC/NR_UE/rrc_UE.c
View file @
e35401ef
...
...
@@ -1372,7 +1372,8 @@ static void rrc_ue_generate_RRCSetupComplete(
if
(
get_softmodem_params
()
->
sa
)
{
as_nas_info_t
initialNasMsg
;
generateRegistrationRequest
(
&
initialNasMsg
,
ctxt_pP
->
module_id
);
nr_ue_nas_t
*
nas
=
get_ue_nas_info
(
ctxt_pP
->
module_id
);
generateRegistrationRequest
(
&
initialNasMsg
,
nas
);
nas_msg
=
(
char
*
)
initialNasMsg
.
data
;
nas_msg_length
=
initialNasMsg
.
length
;
}
else
{
...
...
openair3/NAS/COMMON/NR_NAS_defs.h
View file @
e35401ef
...
...
@@ -371,7 +371,7 @@ typedef struct {
#define STATIC_ASSERT(test_for_true) _Static_assert((test_for_true), "(" #test_for_true ") failed")
#define myCalloc(var, type) type * var=(type*)calloc(sizeof(type),1);
#define arrayCpy(tO, FroM) STATIC_ASSERT(sizeof(tO) == sizeof(FroM)) ; memcpy(tO, FroM, sizeof(tO))
int
resToresStar
(
uint8_t
*
msg
,
uicc_t
*
uicc
);
int
resToresStar
(
uint8_t
*
msg
,
const
uicc_t
*
uicc
);
int
identityResponse
(
void
**
msg
,
nr_user_nas_t
*
UE
);
int
authenticationResponse
(
void
**
msg
,
nr_user_nas_t
*
UE
);
...
...
openair3/NAS/COMMON/nr_common.c
View file @
e35401ef
...
...
@@ -39,7 +39,7 @@ void servingNetworkName(uint8_t *msg, char * imsiStr, int nmc_size) {
memcpy
(
msg
+
13
,
imsiStr
,
3
);
}
int
resToresStar
(
uint8_t
*
msg
,
uicc_t
*
uicc
)
{
int
resToresStar
(
uint8_t
*
msg
,
const
uicc_t
*
uicc
)
{
// TS 33.220 annex B.2 => FC=0x6B in TS 33.501 annex A.4
//input S to KDF
uint8_t
S
[
128
]
=
{
0
};
...
...
openair3/NAS/NR_UE/nr_nas_msg_sim.c
View file @
e35401ef
...
...
@@ -44,7 +44,6 @@
#include "PduSessionEstablishmentAccept.h"
#include "intertask_interface.h"
#include "openair2/RRC/NAS/nas_config.h"
#include <openair3/UICC/usim_interface.h>
#include <openair3/NAS/COMMON/NR_NAS_defs.h>
#include <openair1/PHY/phy_extern_nr_ue.h>
#include <openair1/SIMULATION/ETH_TRANSPORT/proto.h>
...
...
@@ -54,7 +53,7 @@ uint8_t *registration_request_buf;
uint32_t
registration_request_len
;
extern
char
*
baseNetAddress
;
extern
uint16_t
NB_UE_INST
;
static
ue_sa_security_key_t
**
ue_security_key
;
static
nr_ue_nas_t
nr_ue_nas
;
static
int
nas_protected_security_header_encode
(
char
*
buffer
,
...
...
@@ -117,46 +116,44 @@ static int fill_suci(FGSMobileIdentity *mi, const uicc_t *uicc)
return
sizeof
(
Suci5GSMobileIdentity_t
);
}
static
int
fill_guti
(
FGSMobileIdentity
*
mi
,
const
uicc_t
*
uicc
)
static
int
fill_guti
(
FGSMobileIdentity
*
mi
,
const
nr_ue_nas_t
*
nas
)
{
uicc_t
*
uicc
=
nas
->
uicc
;
AssertFatal
(
false
,
"Need to add AMF data in function
\n
"
);
mi
->
guti
.
typeofidentity
=
FGS_MOBILE_IDENTITY_5G_GUTI
;
mi
->
guti
.
amfregionid
=
0xca
;
mi
->
guti
.
amfpointer
=
0
;
mi
->
guti
.
amfsetid
=
1016
;
mi
->
guti
.
tmsi
=
10
;
mi
->
guti
.
mncdigit1
=
uicc
->
nmc_size
==
2
?
uicc
->
imsiStr
[
3
]
-
'0'
:
uicc
->
imsiStr
[
4
]
-
'0'
;
mi
->
guti
.
mncdigit2
=
uicc
->
nmc_size
==
2
?
uicc
->
imsiStr
[
4
]
-
'0'
:
uicc
->
imsiStr
[
5
]
-
'0'
;
mi
->
guti
.
mncdigit3
=
uicc
->
nmc_size
==
2
?
0xf
:
uicc
->
imsiStr
[
3
]
-
'0'
;
mi
->
guti
.
mncdigit1
=
uicc
->
nmc_size
==
2
?
uicc
->
imsiStr
[
3
]
-
'0'
:
uicc
->
imsiStr
[
4
]
-
'0'
;
mi
->
guti
.
mncdigit2
=
uicc
->
nmc_size
==
2
?
uicc
->
imsiStr
[
4
]
-
'0'
:
uicc
->
imsiStr
[
5
]
-
'0'
;
mi
->
guti
.
mncdigit3
=
uicc
->
nmc_size
==
2
?
0xf
:
uicc
->
imsiStr
[
3
]
-
'0'
;
mi
->
guti
.
mccdigit1
=
uicc
->
imsiStr
[
0
]
-
'0'
;
mi
->
guti
.
mccdigit2
=
uicc
->
imsiStr
[
1
]
-
'0'
;
mi
->
guti
.
mccdigit3
=
uicc
->
imsiStr
[
2
]
-
'0'
;
return
13
;
}
static
int
fill_imeisv
(
FGSMobileIdentity
*
mi
,
int
Mod_id
)
static
int
fill_imeisv
(
FGSMobileIdentity
*
mi
,
const
uicc_t
*
uicc
)
{
int
i
=
0
;
mi
->
imeisv
.
typeofidentity
=
FGS_MOBILE_IDENTITY_IMEISV
;
mi
->
imeisv
.
digittac01
=
getImeisvDigit
(
Mod_id
,
i
++
);
mi
->
imeisv
.
digittac02
=
getImeisvDigit
(
Mod_id
,
i
++
);
mi
->
imeisv
.
digittac03
=
getImeisvDigit
(
Mod_id
,
i
++
);
mi
->
imeisv
.
digittac04
=
getImeisvDigit
(
Mod_id
,
i
++
);
mi
->
imeisv
.
digittac05
=
getImeisvDigit
(
Mod_id
,
i
++
);
mi
->
imeisv
.
digittac06
=
getImeisvDigit
(
Mod_id
,
i
++
);
mi
->
imeisv
.
digittac07
=
getImeisvDigit
(
Mod_id
,
i
++
);
mi
->
imeisv
.
digittac08
=
getImeisvDigit
(
Mod_id
,
i
++
);
mi
->
imeisv
.
digit09
=
getImeisvDigit
(
Mod_id
,
i
++
);
mi
->
imeisv
.
digit10
=
getImeisvDigit
(
Mod_id
,
i
++
);
mi
->
imeisv
.
digit11
=
getImeisvDigit
(
Mod_id
,
i
++
);
mi
->
imeisv
.
digit12
=
getImeisvDigit
(
Mod_id
,
i
++
);
mi
->
imeisv
.
digit13
=
getImeisvDigit
(
Mod_id
,
i
++
);
mi
->
imeisv
.
digit14
=
getImeisvDigit
(
Mod_id
,
i
++
);
mi
->
imeisv
.
digitsv1
=
getImeisvDigit
(
Mod_id
,
i
++
);
mi
->
imeisv
.
digitsv2
=
getImeisvDigit
(
Mod_id
,
i
++
);
mi
->
imeisv
.
digittac01
=
getImeisvDigit
(
uicc
,
i
++
);
mi
->
imeisv
.
digittac02
=
getImeisvDigit
(
uicc
,
i
++
);
mi
->
imeisv
.
digittac03
=
getImeisvDigit
(
uicc
,
i
++
);
mi
->
imeisv
.
digittac04
=
getImeisvDigit
(
uicc
,
i
++
);
mi
->
imeisv
.
digittac05
=
getImeisvDigit
(
uicc
,
i
++
);
mi
->
imeisv
.
digittac06
=
getImeisvDigit
(
uicc
,
i
++
);
mi
->
imeisv
.
digittac07
=
getImeisvDigit
(
uicc
,
i
++
);
mi
->
imeisv
.
digittac08
=
getImeisvDigit
(
uicc
,
i
++
);
mi
->
imeisv
.
digit09
=
getImeisvDigit
(
uicc
,
i
++
);
mi
->
imeisv
.
digit10
=
getImeisvDigit
(
uicc
,
i
++
);
mi
->
imeisv
.
digit11
=
getImeisvDigit
(
uicc
,
i
++
);
mi
->
imeisv
.
digit12
=
getImeisvDigit
(
uicc
,
i
++
);
mi
->
imeisv
.
digit13
=
getImeisvDigit
(
uicc
,
i
++
);
mi
->
imeisv
.
digit14
=
getImeisvDigit
(
uicc
,
i
++
);
mi
->
imeisv
.
digitsv1
=
getImeisvDigit
(
uicc
,
i
++
);
mi
->
imeisv
.
digitsv2
=
getImeisvDigit
(
uicc
,
i
++
);
mi
->
imeisv
.
spare
=
0x0f
;
mi
->
imeisv
.
oddeven
=
1
;
return
19
;
...
...
@@ -360,25 +357,18 @@ void derive_kgnb(uint8_t kamf[32], uint32_t count, uint8_t *kgnb){
printf
(
"
\n
"
);
}
void
derive_ue_keys
(
int
Mod_id
,
uint8_t
*
buf
,
uicc_t
*
uicc
)
{
void
derive_ue_keys
(
uint8_t
*
buf
,
nr_ue_nas_t
*
nas
)
{
uint8_t
ak
[
6
];
uint8_t
sqn
[
6
];
AssertFatal
(
Mod_id
<
NB_UE_INST
,
"Failed, Mod_id %d is over NB_UE_INST!
\n
"
,
Mod_id
);
if
(
ue_security_key
[
Mod_id
]){
// clear old key
memset
(
ue_security_key
[
Mod_id
],
0
,
sizeof
(
ue_sa_security_key_t
));
}
else
{
// Allocate new memory
ue_security_key
[
Mod_id
]
=
(
ue_sa_security_key_t
*
)
calloc
(
1
,
sizeof
(
ue_sa_security_key_t
));
}
uint8_t
*
kausf
=
ue_security_key
[
Mod_id
]
->
kausf
;
uint8_t
*
kseaf
=
ue_security_key
[
Mod_id
]
->
kseaf
;
uint8_t
*
kamf
=
ue_security_key
[
Mod_id
]
->
kamf
;
uint8_t
*
knas_int
=
ue_security_key
[
Mod_id
]
->
knas_int
;
uint8_t
*
output
=
ue_security_key
[
Mod_id
]
->
res
;
uint8_t
*
rand
=
ue_security_key
[
Mod_id
]
->
rand
;
uint8_t
*
kgnb
=
ue_security_key
[
Mod_id
]
->
kgnb
;
DevAssert
(
nas
!=
NULL
);
uint8_t
*
kausf
=
nas
->
security
.
kausf
;
uint8_t
*
kseaf
=
nas
->
security
.
kseaf
;
uint8_t
*
kamf
=
nas
->
security
.
kamf
;
uint8_t
*
knas_int
=
nas
->
security
.
knas_int
;
uint8_t
*
output
=
nas
->
security
.
res
;
uint8_t
*
rand
=
nas
->
security
.
rand
;
uint8_t
*
kgnb
=
nas
->
security
.
kgnb
;
// get RAND for authentication request
for
(
int
index
=
0
;
index
<
16
;
index
++
){
...
...
@@ -387,17 +377,17 @@ void derive_ue_keys(int Mod_id, uint8_t *buf, uicc_t *uicc) {
uint8_t
resTemp
[
16
];
uint8_t
ck
[
16
],
ik
[
16
];
f2345
(
uicc
->
key
,
rand
,
resTemp
,
ck
,
ik
,
ak
,
uicc
->
opc
);
f2345
(
nas
->
uicc
->
key
,
rand
,
resTemp
,
ck
,
ik
,
ak
,
nas
->
uicc
->
opc
);
transferRES
(
ck
,
ik
,
resTemp
,
rand
,
output
,
uicc
);
transferRES
(
ck
,
ik
,
resTemp
,
rand
,
output
,
nas
->
uicc
);
for
(
int
index
=
0
;
index
<
6
;
index
++
){
sqn
[
index
]
=
buf
[
26
+
index
];
}
derive_kausf
(
ck
,
ik
,
sqn
,
kausf
,
uicc
);
derive_kseaf
(
kausf
,
kseaf
,
uicc
);
derive_kamf
(
kseaf
,
kamf
,
0x0000
,
uicc
);
derive_kausf
(
ck
,
ik
,
sqn
,
kausf
,
nas
->
uicc
);
derive_kseaf
(
kausf
,
kseaf
,
nas
->
uicc
);
derive_kamf
(
kseaf
,
kamf
,
0x0000
,
nas
->
uicc
);
derive_knas
(
0x02
,
2
,
kamf
,
knas_int
);
derive_kgnb
(
kamf
,
0
,
kgnb
);
...
...
@@ -427,11 +417,17 @@ void derive_ue_keys(int Mod_id, uint8_t *buf, uicc_t *uicc) {
printf
(
"
\n
"
);
}
void
generateRegistrationRequest
(
as_nas_info_t
*
initialNasMsg
,
int
Mod_id
)
{
nr_ue_nas_t
*
get_ue_nas_info
(
module_id_t
module_id
)
{
DevAssert
(
module_id
==
0
);
return
&
nr_ue_nas
;
}
void
generateRegistrationRequest
(
as_nas_info_t
*
initialNasMsg
,
nr_ue_nas_t
*
nas
)
{
int
size
=
sizeof
(
mm_msg_header_t
);
fgs_nas_message_t
nas_msg
=
{
0
};
MM_msg
*
mm_msg
;
uicc_t
*
uicc
=
checkUicc
(
Mod_id
);
mm_msg
=
&
nas_msg
.
plain
.
mm_msg
;
// set header
...
...
@@ -451,9 +447,9 @@ void generateRegistrationRequest(as_nas_info_t *initialNasMsg, int Mod_id) {
mm_msg
->
registration_request
.
naskeysetidentifier
.
naskeysetidentifier
=
1
;
size
+=
1
;
if
(
0
){
size
+=
fill_guti
(
&
mm_msg
->
registration_request
.
fgsmobileidentity
,
uicc
);
size
+=
fill_guti
(
&
mm_msg
->
registration_request
.
fgsmobileidentity
,
nas
);
}
else
{
size
+=
fill_suci
(
&
mm_msg
->
registration_request
.
fgsmobileidentity
,
uicc
);
size
+=
fill_suci
(
&
mm_msg
->
registration_request
.
fgsmobileidentity
,
nas
->
uicc
);
}
mm_msg
->
registration_request
.
presencemask
|=
REGISTRATION_REQUEST_5GMM_CAPABILITY_PRESENT
;
...
...
@@ -511,13 +507,13 @@ void generateIdentityResponse(as_nas_info_t *initialNasMsg, uint8_t identitytype
}
static
void
generateAuthenticationResp
(
int
Mod_id
,
as_nas_info_t
*
initialNasMsg
,
uint8_t
*
buf
,
uicc_t
*
uicc
){
derive_ue_keys
(
Mod_id
,
buf
,
uicc
);
static
void
generateAuthenticationResp
(
nr_ue_nas_t
*
nas
,
as_nas_info_t
*
initialNasMsg
,
uint8_t
*
buf
)
{
derive_ue_keys
(
buf
,
nas
);
OctetString
res
;
res
.
length
=
16
;
res
.
value
=
calloc
(
1
,
16
);
memcpy
(
res
.
value
,
ue_security_key
[
Mod_id
]
->
res
,
16
);
memcpy
(
res
.
value
,
nas
->
security
.
res
,
16
);
int
size
=
sizeof
(
mm_msg_header_t
);
fgs_nas_message_t
nas_msg
;
...
...
@@ -547,14 +543,15 @@ static void generateAuthenticationResp(int Mod_id,as_nas_info_t *initialNasMsg,
initialNasMsg
->
length
=
mm_msg_encode
(
mm_msg
,
(
uint8_t
*
)(
initialNasMsg
->
data
),
size
);
}
int
nas_itti_kgnb_refresh_req
(
const
uint8_t
kgnb
[
32
],
int
instance
)
{
int
nas_itti_kgnb_refresh_req
(
const
uint8_t
kgnb
[
32
])
{
MessageDef
*
message_p
;
message_p
=
itti_alloc_new_message
(
TASK_NAS_NRUE
,
0
,
NAS_KENB_REFRESH_REQ
);
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
,
0
,
message_p
);
}
static
void
generateSecurityModeComplete
(
int
Mod_id
,
as_nas_info_t
*
initialNasMsg
)
static
void
generateSecurityModeComplete
(
nr_ue_nas_t
*
nas
,
as_nas_info_t
*
initialNasMsg
)
{
int
size
=
sizeof
(
mm_msg_header_t
);
fgs_nas_message_t
nas_msg
;
...
...
@@ -583,7 +580,7 @@ static void generateSecurityModeComplete(int Mod_id,as_nas_info_t *initialNasMsg
mm_msg
->
fgs_security_mode_complete
.
messagetype
=
FGS_SECURITY_MODE_COMPLETE
;
size
+=
1
;
size
+=
fill_imeisv
(
&
mm_msg
->
fgs_security_mode_complete
.
fgsmobileidentity
,
Mod_id
);
size
+=
fill_imeisv
(
&
mm_msg
->
fgs_security_mode_complete
.
fgsmobileidentity
,
nas
->
uicc
);
mm_msg
->
fgs_security_mode_complete
.
fgsnasmessagecontainer
.
nasmessagecontainercontents
.
value
=
registration_request_buf
;
mm_msg
->
fgs_security_mode_complete
.
fgsnasmessagecontainer
.
nasmessagecontainercontents
.
length
=
registration_request_len
;
...
...
@@ -596,7 +593,7 @@ static void generateSecurityModeComplete(int Mod_id,as_nas_info_t *initialNasMsg
initialNasMsg
->
length
=
security_header_len
+
mm_msg_encode
(
mm_msg
,
(
uint8_t
*
)(
initialNasMsg
->
data
+
security_header_len
),
size
-
security_header_len
);
stream_cipher
.
key
=
ue_security_key
[
Mod_id
]
->
knas_int
;
stream_cipher
.
key
=
nas
->
security
.
knas_int
;
stream_cipher
.
key_length
=
16
;
stream_cipher
.
count
=
0
;
stream_cipher
.
bearer
=
1
;
...
...
@@ -616,7 +613,8 @@ static void generateSecurityModeComplete(int Mod_id,as_nas_info_t *initialNasMsg
}
}
static
void
generateRegistrationComplete
(
int
Mod_id
,
as_nas_info_t
*
initialNasMsg
,
SORTransparentContainer
*
sortransparentcontainer
)
{
static
void
generateRegistrationComplete
(
nr_ue_nas_t
*
nas
,
as_nas_info_t
*
initialNasMsg
,
SORTransparentContainer
*
sortransparentcontainer
)
{
//wait send RRCReconfigurationComplete and InitialContextSetupResponse
sleep
(
1
);
int
length
=
0
;
...
...
@@ -676,7 +674,7 @@ static void generateRegistrationComplete(int Mod_id, as_nas_info_t *initialNasMs
}
initialNasMsg
->
length
=
length
;
stream_cipher
.
key
=
ue_security_key
[
Mod_id
]
->
knas_int
;
stream_cipher
.
key
=
nas
->
security
.
knas_int
;
stream_cipher
.
key_length
=
16
;
stream_cipher
.
count
=
1
;
stream_cipher
.
bearer
=
1
;
...
...
@@ -709,7 +707,8 @@ void decodeDownlinkNASTransport(as_nas_info_t *initialNasMsg, uint8_t * pdu_buff
}
}
static
void
generatePduSessionEstablishRequest
(
int
Mod_id
,
uicc_t
*
uicc
,
as_nas_info_t
*
initialNasMsg
){
static
void
generatePduSessionEstablishRequest
(
nr_ue_nas_t
*
nas
,
as_nas_info_t
*
initialNasMsg
)
{
//wait send RegistrationComplete
usleep
(
100
*
150
);
int
size
=
0
;
...
...
@@ -760,25 +759,25 @@ static void generatePduSessionEstablishRequest(int Mod_id, uicc_t * uicc, as_nas
mm_msg
->
uplink_nas_transport
.
pdusessionid
=
10
;
mm_msg
->
uplink_nas_transport
.
requesttype
=
1
;
size
+=
3
;
const
bool
has_nssai_sd
=
uicc
->
nssai_sd
!=
0xffffff
;
// 0xffffff means "no SD", TS 23.003
const
bool
has_nssai_sd
=
nas
->
uicc
->
nssai_sd
!=
0xffffff
;
// 0xffffff means "no SD", TS 23.003
const
size_t
nssai_len
=
has_nssai_sd
?
4
:
1
;
mm_msg
->
uplink_nas_transport
.
snssai
.
length
=
nssai_len
;
//Fixme: it seems there are a lot of memory errors in this: this value was on the stack,
// but pushed in a itti message to another thread
// this kind of error seems in many places in 5G NAS
mm_msg
->
uplink_nas_transport
.
snssai
.
value
=
calloc
(
1
,
nssai_len
);
mm_msg
->
uplink_nas_transport
.
snssai
.
value
[
0
]
=
uicc
->
nssai_sst
;
mm_msg
->
uplink_nas_transport
.
snssai
.
value
[
0
]
=
nas
->
uicc
->
nssai_sst
;
if
(
has_nssai_sd
)
{
mm_msg
->
uplink_nas_transport
.
snssai
.
value
[
1
]
=
(
uicc
->
nssai_sd
>>
16
)
&
0xFF
;
mm_msg
->
uplink_nas_transport
.
snssai
.
value
[
2
]
=
(
uicc
->
nssai_sd
>>
8
)
&
0xFF
;
mm_msg
->
uplink_nas_transport
.
snssai
.
value
[
3
]
=
(
uicc
->
nssai_sd
)
&
0xFF
;
mm_msg
->
uplink_nas_transport
.
snssai
.
value
[
1
]
=
(
nas
->
uicc
->
nssai_sd
>>
16
)
&
0xFF
;
mm_msg
->
uplink_nas_transport
.
snssai
.
value
[
2
]
=
(
nas
->
uicc
->
nssai_sd
>>
8
)
&
0xFF
;
mm_msg
->
uplink_nas_transport
.
snssai
.
value
[
3
]
=
(
nas
->
uicc
->
nssai_sd
)
&
0xFF
;
}
size
+=
1
+
1
+
nssai_len
;
int
dnnSize
=
strlen
(
uicc
->
dnnStr
);
int
dnnSize
=
strlen
(
nas
->
uicc
->
dnnStr
);
mm_msg
->
uplink_nas_transport
.
dnn
.
value
=
calloc
(
1
,
dnnSize
+
1
);
mm_msg
->
uplink_nas_transport
.
dnn
.
length
=
dnnSize
+
1
;
mm_msg
->
uplink_nas_transport
.
dnn
.
value
[
0
]
=
dnnSize
;
memcpy
(
mm_msg
->
uplink_nas_transport
.
dnn
.
value
+
1
,
uicc
->
dnnStr
,
dnnSize
);
memcpy
(
mm_msg
->
uplink_nas_transport
.
dnn
.
value
+
1
,
nas
->
uicc
->
dnnStr
,
dnnSize
);
size
+=
(
1
+
1
+
dnnSize
+
1
);
// encode the message
...
...
@@ -787,7 +786,7 @@ static void generatePduSessionEstablishRequest(int Mod_id, uicc_t * uicc, as_nas
initialNasMsg
->
length
=
security_header_len
+
mm_msg_encode
(
mm_msg
,
(
uint8_t
*
)(
initialNasMsg
->
data
+
security_header_len
),
size
-
security_header_len
);
stream_cipher
.
key
=
ue_security_key
[
Mod_id
]
->
knas_int
;
stream_cipher
.
key
=
nas
->
security
.
knas_int
;
stream_cipher
.
key_length
=
16
;
stream_cipher
.
count
=
0
;
stream_cipher
.
bearer
=
1
;
...
...
@@ -851,7 +850,8 @@ void *nas_nrue_task(void *args_p)
uint8_t
*
pdu_buffer
=
NULL
;
ue_security_key
=
(
ue_sa_security_key_t
**
)
calloc
(
1
,
sizeof
(
ue_sa_security_key_t
*
)
*
NB_UE_INST
);
nr_ue_nas
.
uicc
=
checkUicc
(
0
);
nr_ue_nas_t
*
nas
=
get_ue_nas_info
(
0
);
itti_mark_task_ready
(
TASK_NAS_NRUE
);
while
(
1
)
{
...
...
@@ -860,13 +860,7 @@ void *nas_nrue_task(void *args_p)
if
(
msg_p
!=
NULL
)
{
instance
=
msg_p
->
ittiMsgHeader
.
originInstance
;
uicc_t
*
uicc
=
checkUicc
(
instance
);
if
(
instance
==
INSTANCE_DEFAULT
)
{
printf
(
"%s:%d: FATAL: instance is INSTANCE_DEFAULT, should not happen.
\n
"
,
__FILE__
,
__LINE__
);
exit_fun
(
"exit...
\n
"
);
}
AssertFatal
(
instance
==
0
,
"cannot handle more than one UE!
\n
"
);
switch
(
ITTI_MSG_ID
(
msg_p
))
{
case
INITIALIZE_MESSAGE
:
...
...
@@ -918,7 +912,7 @@ void *nas_nrue_task(void *args_p)
as_nas_info_t
initialNasMsg
;
memset
(
&
initialNasMsg
,
0
,
sizeof
(
as_nas_info_t
));
generateRegistrationComplete
(
instance
,
&
initialNasMsg
,
NULL
);
generateRegistrationComplete
(
nas
,
&
initialNasMsg
,
NULL
);
if
(
initialNasMsg
.
length
>
0
)
{
send_nas_uplink_data_req
(
instance
,
&
initialNasMsg
);
LOG_I
(
NAS
,
"Send NAS_UPLINK_DATA_REQ message(RegistrationComplete)
\n
"
);
...
...
@@ -926,7 +920,7 @@ void *nas_nrue_task(void *args_p)
as_nas_info_t
pduEstablishMsg
;
memset
(
&
pduEstablishMsg
,
0
,
sizeof
(
as_nas_info_t
));
generatePduSessionEstablishRequest
(
instance
,
uicc
,
&
pduEstablishMsg
);
generatePduSessionEstablishRequest
(
nas
,
&
pduEstablishMsg
);
if
(
pduEstablishMsg
.
length
>
0
)
{
send_nas_uplink_data_req
(
instance
,
&
pduEstablishMsg
);
LOG_I
(
NAS
,
"Send NAS_UPLINK_DATA_REQ message(PduSessionEstablishRequest)
\n
"
);
...
...
@@ -966,14 +960,14 @@ void *nas_nrue_task(void *args_p)
switch
(
msg_type
){
case
FGS_IDENTITY_REQUEST
:
generateIdentityResponse
(
&
initialNasMsg
,
*
(
pdu_buffer
+
3
),
uicc
);
generateIdentityResponse
(
&
initialNasMsg
,
*
(
pdu_buffer
+
3
),
nas
->
uicc
);
break
;
case
FGS_AUTHENTICATION_REQUEST
:
generateAuthenticationResp
(
instance
,
&
initialNasMsg
,
pdu_buffer
,
uicc
);
generateAuthenticationResp
(
nas
,
&
initialNasMsg
,
pdu_buffer
);
break
;
case
FGS_SECURITY_MODE_COMMAND
:
nas_itti_kgnb_refresh_req
(
ue_security_key
[
instance
]
->
kgnb
,
instance
);
generateSecurityModeComplete
(
instance
,
&
initialNasMsg
);
nas_itti_kgnb_refresh_req
(
nas
->
security
.
kgnb
);
generateSecurityModeComplete
(
nas
,
&
initialNasMsg
);
break
;
case
FGS_DOWNLINK_NAS_TRANSPORT
:
decodeDownlinkNASTransport
(
&
initialNasMsg
,
pdu_buffer
);
...
...
openair3/NAS/NR_UE/nr_nas_msg_sim.h
View file @
e35401ef
...
...
@@ -39,6 +39,7 @@
#include "RegistrationComplete.h"
#include "as_message.h"
#include "FGSUplinkNasTransport.h"
#include <openair3/UICC/usim_interface.h>
#define PLAIN_5GS_MSG 0b0000
#define INTEGRITY_PROTECTED 0b0001
...
...
@@ -80,6 +81,11 @@ typedef struct {
uint8_t
kgnb
[
32
];
}
ue_sa_security_key_t
;
typedef
struct
{
uicc_t
*
uicc
;
ue_sa_security_key_t
security
;
}
nr_ue_nas_t
;
typedef
enum
fgs_protocol_discriminator_e
{
/* Protocol discriminator identifier for 5GS Mobility Management */
FGS_MOBILITY_MANAGEMENT_MESSAGE
=
0x7E
,
...
...
@@ -158,7 +164,8 @@ typedef struct {
fgs_sm_nas_msg_header_t
sm_nas_msg_header
;
}
dl_nas_transport_t
;
void
generateRegistrationRequest
(
as_nas_info_t
*
initialNasMsg
,
int
Mod_id
);
nr_ue_nas_t
*
get_ue_nas_info
(
module_id_t
module_id
);
void
generateRegistrationRequest
(
as_nas_info_t
*
initialNasMsg
,
nr_ue_nas_t
*
nas
);
void
*
nas_nrue_task
(
void
*
args_p
);
#endif
/* __NR_NAS_MSG_SIM_H__*/
...
...
openair3/UICC/usim_interface.c
View file @
e35401ef
...
...
@@ -116,9 +116,8 @@ uicc_t * checkUicc(int Mod_id) {
return
(
uicc_t
*
)
uiccArray
[
Mod_id
];
}
uint8_t
getImeisvDigit
(
int
Mod_id
,
uint8_t
i
)
uint8_t
getImeisvDigit
(
const
uicc_t
*
uicc
,
uint8_t
i
)
{
uicc_t
*
uicc
=
checkUicc
(
Mod_id
);
uint8_t
r
=
0
;
uint8_t
l
=
strlen
(
uicc
->
imeisvStr
);
if
(
l
>
IMEISV_STR_MAX_LENGTH
)
{
...
...
openair3/UICC/usim_interface.h
View file @
e35401ef
...
...
@@ -73,6 +73,5 @@ typedef struct {
uicc_t
*
checkUicc
(
int
Mod_id
);
uicc_t
*
init_uicc
(
char
*
sectionName
);
void
uicc_milenage_generate
(
uint8_t
*
autn
,
uicc_t
*
uicc
);
uicc_t
*
checkUicc
(
int
Mod_id
);
uint8_t
getImeisvDigit
(
int
Mod_id
,
uint8_t
i
);
uint8_t
getImeisvDigit
(
const
uicc_t
*
uicc
,
uint8_t
i
);
#endif
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