Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-AMF
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
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
OpenXG
OpenXG-AMF
Commits
15fdf156
Commit
15fdf156
authored
Mar 29, 2023
by
Tien Thinh NGUYEN
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Mobility Restriction List and Masked IMEISV in InitialContextSetupRequest
parent
16930745
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
134 additions
and
34 deletions
+134
-34
src/amf-app/amf_n1.cpp
src/amf-app/amf_n1.cpp
+35
-4
src/amf-app/amf_n2.cpp
src/amf-app/amf_n2.cpp
+18
-1
src/common/conversions.cpp
src/common/conversions.cpp
+14
-16
src/contexts/nas_context.cpp
src/contexts/nas_context.cpp
+1
-0
src/contexts/nas_context.hpp
src/contexts/nas_context.hpp
+2
-0
src/nas/ies/5GSMobileIdentity.cpp
src/nas/ies/5GSMobileIdentity.cpp
+1
-1
src/nas/msgs/SecurityModeCommand.cpp
src/nas/msgs/SecurityModeCommand.cpp
+9
-1
src/ngap/ngapIEs/MobilityRestrictionList.cpp
src/ngap/ngapIEs/MobilityRestrictionList.cpp
+4
-4
src/ngap/ngapIEs/MobilityRestrictionList.hpp
src/ngap/ngapIEs/MobilityRestrictionList.hpp
+2
-2
src/ngap/ngapMsgs/HandoverRequest.hpp
src/ngap/ngapMsgs/HandoverRequest.hpp
+1
-2
src/ngap/ngapMsgs/InitialContextSetupRequest.cpp
src/ngap/ngapMsgs/InitialContextSetupRequest.cpp
+37
-0
src/ngap/ngapMsgs/InitialContextSetupRequest.hpp
src/ngap/ngapMsgs/InitialContextSetupRequest.hpp
+10
-3
No files found.
src/amf-app/amf_n1.cpp
View file @
15fdf156
...
...
@@ -849,7 +849,11 @@ void amf_n1::service_request_handle(
Logger
::
amf_app
().
debug
(
"Get Security Context from old NAS Context"
);
nc
->
security_ctx
=
std
::
make_optional
<
nas_secu_ctx
>
(
old_nc
->
security_ctx
.
value
());
nc
->
imsi
=
old_nc
->
imsi
;
nc
->
imsi
=
old_nc
->
imsi
;
if
(
old_nc
->
imeisv
.
has_value
())
{
nc
->
imeisv
=
std
::
make_optional
<
nas
::
IMEISV_t
>
(
old_nc
->
imeisv
.
value
());
}
nc
->
requested_nssai
=
old_nc
->
requested_nssai
;
nc
->
allowed_nssai
=
old_nc
->
allowed_nssai
;
for
(
auto
r
:
nc
->
allowed_nssai
)
{
...
...
@@ -1179,9 +1183,9 @@ void amf_n1::service_request_handle(
uint8_t
amf_pointer
=
{};
string
tmsi
=
{};
if
(
service_request
->
Get5gSTmsi
(
amf_set_id
,
amf_pointer
,
tmsi
))
{
std
::
string
guti
=
uc
->
tai
.
mcc
+
uc
->
tai
.
mnc
+
amf_cfg
.
guami
.
regionID
+
std
::
to_string
(
amf_set_id
)
+
std
::
to_string
(
amf_pointer
)
+
tmsi
;
std
::
string
guti
=
conv
::
tmsi_to_guti
(
uc
->
tai
.
mcc
,
uc
->
tai
.
mnc
,
amf_cfg
.
guami
.
regionID
,
std
::
to_string
(
amf_set_id
),
std
::
to_string
(
amf_pointer
),
tmsi
)
;
Logger
::
amf_app
().
debug
(
"GUTI %s, 5G-TMSI %s"
,
guti
.
c_str
(),
tmsi
.
c_str
());
...
...
@@ -1193,6 +1197,26 @@ void amf_n1::service_request_handle(
nc
->
imsi
=
old_nc
->
imsi
;
ran_ue_ngap_id_old_nas_connection
=
old_nc
->
ran_ue_ngap_id
;
amf_ue_ngap_id_old_nas_connection
=
old_nc
->
amf_ue_ngap_id
;
if
(
old_nc
->
imeisv
.
has_value
())
{
nc
->
imeisv
=
std
::
make_optional
<
nas
::
IMEISV_t
>
(
old_nc
->
imeisv
.
value
());
}
nc
->
requested_nssai
=
old_nc
->
requested_nssai
;
nc
->
allowed_nssai
=
old_nc
->
allowed_nssai
;
for
(
auto
r
:
nc
->
allowed_nssai
)
{
Logger
::
nas_mm
().
debug
(
"Allowed NSSAI: %s"
,
r
.
ToString
().
c_str
());
}
nc
->
subscribed_snssai
=
old_nc
->
subscribed_snssai
;
nc
->
configured_nssai
=
old_nc
->
configured_nssai
;
for
(
const
auto
&
sn
:
nc
->
subscribed_snssai
)
{
if
(
sn
.
first
)
{
SNSSAI_t
snssai
=
{};
snssai
=
sn
.
second
;
Logger
::
amf_n1
().
debug
(
"Configured S-NSSAI %s"
,
snssai
.
ToString
().
c_str
());
}
}
Logger
::
amf_n2
().
debug
(
"Old ran_ue_ngap_id ("
GNB_UE_NGAP_ID_FMT
"), old amf_ue_ngap_id ("
AMF_UE_NGAP_ID_FMT
")"
,
...
...
@@ -2913,6 +2937,13 @@ void amf_n1::security_mode_complete_handle(
"amf_n1"
,
"Security Mode Complete message buffer"
,
(
uint8_t
*
)
bdata
(
nas_msg
),
blength
(
nas_msg
));
// Store UE Id (IMEISV) if available
nas
::
IMEISV_t
imeisv
=
{};
if
(
security_mode_complete
->
GetNonImeisv
(
imeisv
))
{
nc
->
imeisv
=
std
::
make_optional
<
nas
::
IMEISV_t
>
(
imeisv
);
}
// Process NAS Container
bstring
nas_msg_container
=
nullptr
;
if
(
security_mode_complete
->
GetNasMessageContainer
(
nas_msg_container
))
{
output_wrapper
::
print_buffer
(
...
...
src/amf-app/amf_n2.cpp
View file @
15fdf156
...
...
@@ -875,8 +875,25 @@ void amf_n2::handle_itti_message(itti_initial_context_setup_request& itti_msg) {
0xe000
,
0xe000
,
0x0000
,
0x0000
);
// TODO: remove hardcoded value
msg
->
setSecurityKey
((
uint8_t
*
)
bdata
(
itti_msg
.
kgnb
));
msg
->
setNasPdu
(
itti_msg
.
nas
);
ngap
::
PlmnId
plmn_id
=
{};
plmn_id
.
set
(
amf_cfg
.
guami
.
mcc
,
amf_cfg
.
guami
.
mnc
);
msg
->
setMobilityRestrictionList
(
plmn_id
);
// IMEISV
std
::
shared_ptr
<
nas_context
>
nc
=
{};
if
(
!
amf_n1_inst
->
amf_ue_id_2_nas_context
(
itti_msg
.
amf_ue_ngap_id
,
nc
))
{
Logger
::
amf_n2
().
warn
(
"No existed nas_context with amf_ue_ngap_id("
AMF_UE_NGAP_ID_FMT
")"
,
itti_msg
.
amf_ue_ngap_id
);
// TODO:
}
else
{
if
(
nc
->
imeisv
.
has_value
())
{
msg
->
setMaskedIMEISV
(
nc
->
imeisv
.
value
().
identity
);
}
}
msg
->
setNasPdu
(
itti_msg
.
nas
);
if
(
itti_msg
.
is_sr
or
itti_msg
.
is_pdu_exist
)
{
// Set UE Radio Capability if available
...
...
src/common/conversions.cpp
View file @
15fdf156
...
...
@@ -303,25 +303,23 @@ bool conv::octet_string_2_bit_string(
//------------------------------------------------------------------------------
bool
conv
::
bstring_2_bit_string
(
const
bstring
&
b_str
,
BIT_STRING_t
&
bit_str
)
{
OCTET_STRING_t
octet_str
;
bstring_2_octet_string
(
b_str
,
octet_str
);
octet_string_2_bit_string
(
octet_str
,
bit_str
,
0
);
/*
int size = blength(b_str);
if (!b_str or size <= 0) return false;
if (!bdata(b_str)) return false;
// OCTET_STRING_t octet_str;
// bstring_2_octet_string(b_str, octet_str);
// octet_string_2_bit_string(octet_str, bit_str, 0);
int
size
=
blength
(
b_str
);
if
(
!
b_str
or
size
<=
0
)
return
false
;
if
(
!
bdata
(
b_str
))
return
false
;
bit_str
.
buf
=
(
uint8_t
*
)
calloc
(
size
+
1
,
sizeof
(
uint8_t
));
if
(
!
bit_str
.
buf
)
return
false
;
bit_str.buf = (uint8_t*) calloc(size + 1, sizeof(uint8_t));
if (!bit_str.buf) return false;
if
(
check_bstring
(
b_str
))
memcpy
((
void
*
)
bit_str
.
buf
,
(
char
*
)
b_str
->
data
,
blength
(
b_str
));
((
uint8_t
*
)
bit_str
.
buf
)[
size
]
=
'\0'
;
bit_str
.
size
=
size
;
if (check_bstring (b_str)) memcpy((void*) bit_str.buf, (char*)octet_str.buf,
blength(b_str));
((uint8_t*) bit_str.buf)[size] = '\0';
bit_str.size = size;
bit_str
.
bits_unused
=
0
;
bit_str.bits_unused = 0;
*/
return
true
;
}
...
...
src/contexts/nas_context.cpp
View file @
15fdf156
...
...
@@ -56,6 +56,7 @@ nas_context::nas_context() : _5g_he_av(), _5g_av(), kamf(), _5gmm_capability() {
mobile_reachable_timer
=
ITTI_INVALID_TIMER_ID
;
implicit_deregistration_timer
=
ITTI_INVALID_TIMER_ID
;
href
=
{};
imeisv
=
std
::
nullopt
;
}
//------------------------------------------------------------------------------
...
...
src/contexts/nas_context.hpp
View file @
15fdf156
...
...
@@ -81,6 +81,8 @@ class nas_context {
uint8_t
ngksi
;
// 4 bits
std
::
string
imsi
;
// TODO: use SUPI instead
std
::
optional
<
nas
::
IMEISV_t
>
imeisv
;
std
::
uint8_t
_5gmm_capability
[
13
];
nas
::
UESecurityCapability
ue_security_capability
;
...
...
src/nas/ies/5GSMobileIdentity.cpp
View file @
15fdf156
...
...
@@ -656,7 +656,7 @@ int _5GSMobileIdentity::DecodeImeisv(uint8_t* buf, int len) {
}
imeisv_
=
std
::
optional
<
IMEISV_t
>
(
imeisv_tmp
);
Logger
::
nas_mm
().
debug
(
"
d
ecoded 5GSMobilityIdentity IMEISV len (%d)"
,
decoded_size
);
"
D
ecoded 5GSMobilityIdentity IMEISV len (%d)"
,
decoded_size
);
return
decoded_size
;
}
...
...
src/nas/msgs/SecurityModeCommand.cpp
View file @
15fdf156
...
...
@@ -144,7 +144,15 @@ int SecurityModeCommand::Encode(uint8_t* buf, int len) {
// NAS key set identifier
size
=
ie_ng_ksi
.
Encode
(
buf
+
encoded_size
,
len
-
encoded_size
);
if
(
size
!=
KEncodeDecodeError
)
{
encoded_size
++
;
// 1/2 octet for ngKSI, 1/2 for Spare half octet
// 1/2 octet for ngKSI, 1/2 for Spare half octet
// TODO:do it in NAS Key Set Identifier
uint8_t
octet
=
0
;
int
decoded_size
=
0
;
DECODE_U8
(
buf
+
encoded_size
,
octet
,
decoded_size
);
// clear spare half
octet
=
octet
&
0x0f
;
ENCODE_U8
(
buf
+
encoded_size
,
octet
,
encoded_size
);
// encoded_size++; // 1/2 octet for ngKSI, 1/2 for Spare half octet
}
else
{
Logger
::
nas_mm
().
error
(
"Encoding %s error"
,
NasKeySetIdentifier
::
GetIeName
().
c_str
());
...
...
src/ngap/ngapIEs/MobilityRestrictionList.cpp
View file @
15fdf156
...
...
@@ -28,13 +28,13 @@ MobilityRestrictionList::MobilityRestrictionList() {}
MobilityRestrictionList
::~
MobilityRestrictionList
()
{}
//------------------------------------------------------------------------------
void
MobilityRestrictionList
::
setPLMN
(
const
PlmnId
&
sPLMN
)
{
servingPLMN
=
sPLMN
;
void
MobilityRestrictionList
::
setPLMN
(
const
PlmnId
&
plmn
)
{
servingPLMN
=
plmn
;
}
//------------------------------------------------------------------------------
void
MobilityRestrictionList
::
getPLMN
(
PlmnId
&
sPLMN
)
{
sPLMN
=
servingPLMN
;
void
MobilityRestrictionList
::
getPLMN
(
PlmnId
&
plmn
)
const
{
plmn
=
servingPLMN
;
}
//------------------------------------------------------------------------------
...
...
src/ngap/ngapIEs/MobilityRestrictionList.hpp
View file @
15fdf156
...
...
@@ -32,8 +32,8 @@ class MobilityRestrictionList {
MobilityRestrictionList
();
virtual
~
MobilityRestrictionList
();
void
setPLMN
(
const
PlmnId
&
sP
lmn
);
void
getPLMN
(
PlmnId
&
sPlmn
)
;
void
setPLMN
(
const
PlmnId
&
p
lmn
);
void
getPLMN
(
PlmnId
&
plmn
)
const
;
bool
encode
(
Ngap_MobilityRestrictionList_t
*
mobility_restriction_list
);
bool
decode
(
Ngap_MobilityRestrictionList_t
*
mobility_restriction_list
);
...
...
src/ngap/ngapMsgs/HandoverRequest.hpp
View file @
15fdf156
...
...
@@ -113,8 +113,7 @@ class HandoverRequest : public NgapMessage {
// Masked IMEISV (TODO: Optional)
Ngap_SourceToTarget_TransparentContainer_t
SourceToTarget_TransparentContainer
;
// TODO: Mandatory
std
::
optional
<
MobilityRestrictionList
>
mobilityRestrictionList
;
// TODO: Optional
std
::
optional
<
MobilityRestrictionList
>
mobilityRestrictionList
;
// Location Reporting Request Type (TODO: Optional)
// RRC Inactive Transition Report Request (TODO: Optional)
GUAMI
guami
;
// Mandatory
...
...
src/ngap/ngapMsgs/InitialContextSetupRequest.cpp
View file @
15fdf156
...
...
@@ -39,6 +39,7 @@ InitialContextSetupRequestMsg::InitialContextSetupRequestMsg()
coreNetworkAssistanceInfo
=
std
::
nullopt
;
pduSessionResourceSetupRequestList
=
std
::
nullopt
;
ueRadioCapability
=
std
::
nullopt
;
maskedIMEISV
=
std
::
nullopt
;
nasPdu
=
std
::
nullopt
;
setMessageType
(
NgapMessageType
::
INITIAL_CONTEXT_SETUP_REQUEST
);
...
...
@@ -528,6 +529,35 @@ bool InitialContextSetupRequestMsg::getSecurityKey(uint8_t*& key) {
return
true
;
}
//------------------------------------------------------------------------------
void
InitialContextSetupRequestMsg
::
setMobilityRestrictionList
(
const
PlmnId
&
plmn_id
)
{
MobilityRestrictionList
tmp
=
{};
tmp
.
setPLMN
(
plmn_id
);
mobilityRestrictionList
=
std
::
optional
<
MobilityRestrictionList
>
(
tmp
);
Ngap_InitialContextSetupRequestIEs_t
*
ie
=
(
Ngap_InitialContextSetupRequestIEs_t
*
)
calloc
(
1
,
sizeof
(
Ngap_InitialContextSetupRequestIEs_t
));
ie
->
id
=
Ngap_ProtocolIE_ID_id_MobilityRestrictionList
;
ie
->
criticality
=
Ngap_Criticality_ignore
;
ie
->
value
.
present
=
Ngap_InitialContextSetupRequestIEs__value_PR_MobilityRestrictionList
;
int
ret
=
mobilityRestrictionList
.
value
().
encode
(
&
ie
->
value
.
choice
.
MobilityRestrictionList
);
if
(
!
ret
)
{
Logger
::
ngap
().
error
(
"Encode MobilityRestrictionList IE error!"
);
free_wrapper
((
void
**
)
&
ie
);
return
;
}
ret
=
ASN_SEQUENCE_ADD
(
&
initialContextSetupRequestIEs
->
protocolIEs
.
list
,
ie
);
if
(
ret
!=
0
)
Logger
::
ngap
().
error
(
"Encode MobilityRestrictionList IE error!"
);
}
//------------------------------------------------------------------------------
void
InitialContextSetupRequestMsg
::
setNasPdu
(
const
bstring
&
pdu
)
{
NAS_PDU
tmp
=
{};
...
...
@@ -592,6 +622,13 @@ void InitialContextSetupRequestMsg::getUERadioCapability(
ueRadioCapability
.
value
().
get
(
ue_radio_capability
);
}
//------------------------------------------------------------------------------
void
InitialContextSetupRequestMsg
::
setMaskedIMEISV
(
const
bstring
&
imeisv
)
{
Ngap_MaskedIMEISV_t
tmp
=
{};
conv
::
bstring_2_bit_string
(
imeisv
,
tmp
);
maskedIMEISV
=
std
::
make_optional
<
Ngap_MaskedIMEISV_t
>
(
tmp
);
}
//------------------------------------------------------------------------------
bool
InitialContextSetupRequestMsg
::
decodeFromPdu
(
Ngap_NGAP_PDU_t
*
ngapMsgPdu
)
{
ngapPdu
=
ngapMsgPdu
;
...
...
src/ngap/ngapMsgs/InitialContextSetupRequest.hpp
View file @
15fdf156
...
...
@@ -32,6 +32,7 @@
#include "UERadioCapability.hpp"
#include "UESecurityCapabilities.hpp"
#include "NgapUEMessage.hpp"
#include "MobilityRestrictionList.hpp"
#include <optional>
...
...
@@ -100,9 +101,15 @@ class InitialContextSetupRequestMsg : public NgapUEMessage {
void
setSecurityKey
(
uint8_t
*
key
);
// 256bits
bool
getSecurityKey
(
uint8_t
*&
key
);
// 256bits
void
setMobilityRestrictionList
(
const
PlmnId
&
plmn_id
);
// TODO: getMobilityRestrictionList
void
setUERadioCapability
(
const
bstring
&
ue_radio_capability
);
void
getUERadioCapability
(
bstring
&
ue_radio_capability
);
void
setMaskedIMEISV
(
const
bstring
&
imeisv
);
// bool getMaskedIMEISV();
void
setNasPdu
(
const
bstring
&
pdu
);
bool
getNasPdu
(
bstring
&
pdu
);
...
...
@@ -120,11 +127,11 @@ class InitialContextSetupRequestMsg : public NgapUEMessage {
UESecurityCapabilities
uESecurityCapabilities
;
// Mandatory
SecurityKey
securityKey
;
// Mandatory
// TODO: Trace Activation (Optional)
// TODO: Mobility Restriction List
std
::
optional
<
MobilityRestrictionList
>
mobilityRestrictionList
;
std
::
optional
<
UERadioCapability
>
ueRadioCapability
;
// Optional
// TODO: Index to RAT/Frequency Selection Priority
// TODO: Masked IMEISV
std
::
optional
<
NAS_PDU
>
nasPdu
;
// Optional
std
::
optional
<
Ngap_MaskedIMEISV_t
>
maskedIMEISV
;
// Optional
std
::
optional
<
NAS_PDU
>
nasPdu
;
// Optional
// TODO: Emergency Fallback Indicator
// TODO: RRC Inactive Transition Report Request
// TODO: UE Radio Capability for Paging
...
...
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