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
c140a19c
Commit
c140a19c
authored
Feb 20, 2023
by
Raphael Defosseux
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'fix_tmsi_handling' into 'develop'
Fix tmsi handling See merge request oai/cn5g/oai-cn5g-amf!184
parents
c904b0f4
0ce0fbc7
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
135 additions
and
83 deletions
+135
-83
src/amf-app/amf_app.cpp
src/amf-app/amf_app.cpp
+5
-3
src/amf-app/amf_n1.cpp
src/amf-app/amf_n1.cpp
+60
-56
src/amf-app/amf_n1.hpp
src/amf-app/amf_n1.hpp
+8
-8
src/amf-app/amf_n2.cpp
src/amf-app/amf_n2.cpp
+11
-11
src/amf-app/amf_sbi.cpp
src/amf-app/amf_sbi.cpp
+1
-1
src/common/conversions.cpp
src/common/conversions.cpp
+37
-2
src/common/conversions.hpp
src/common/conversions.hpp
+11
-0
src/ngap/ngap_app/ngap_message_callback.hpp
src/ngap/ngap_app/ngap_message_callback.hpp
+2
-2
No files found.
src/amf-app/amf_app.cpp
View file @
c140a19c
...
@@ -204,7 +204,6 @@ long amf_app::generate_amf_ue_ngap_id() {
...
@@ -204,7 +204,6 @@ long amf_app::generate_amf_ue_ngap_id() {
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
bool
amf_app
::
is_ran_amf_id_2_ue_context
(
const
string
&
ue_context_key
)
const
{
bool
amf_app
::
is_ran_amf_id_2_ue_context
(
const
string
&
ue_context_key
)
const
{
std
::
shared_lock
lock
(
m_ue_ctx_key
);
std
::
shared_lock
lock
(
m_ue_ctx_key
);
// return bool{ue_ctx_key.count(ue_context_key) > 0};
if
(
ue_ctx_key
.
count
(
ue_context_key
)
>
0
)
{
if
(
ue_ctx_key
.
count
(
ue_context_key
)
>
0
)
{
if
(
ue_ctx_key
.
at
(
ue_context_key
)
!=
nullptr
)
{
if
(
ue_ctx_key
.
at
(
ue_context_key
)
!=
nullptr
)
{
return
true
;
return
true
;
...
@@ -407,14 +406,16 @@ void amf_app::handle_itti_message(
...
@@ -407,14 +406,16 @@ void amf_app::handle_itti_message(
uc
->
isUeContextRequest
=
false
;
uc
->
isUeContextRequest
=
false
;
else
else
uc
->
isUeContextRequest
=
true
;
uc
->
isUeContextRequest
=
true
;
uc
->
ran_ue_ngap_id
=
itti_msg
.
ran_ue_ngap_id
;
uc
->
ran_ue_ngap_id
=
itti_msg
.
ran_ue_ngap_id
;
uc
->
amf_ue_ngap_id
=
amf_ue_ngap_id
;
uc
->
amf_ue_ngap_id
=
amf_ue_ngap_id
;
std
::
string
guti
=
{};
std
::
string
guti
=
{};
bool
is_guti_valid
=
false
;
bool
is_guti_valid
=
false
;
if
(
itti_msg
.
is_5g_s_tmsi_present
)
{
if
(
itti_msg
.
is_5g_s_tmsi_present
)
{
guti
=
itti_msg
.
tai
.
mcc
+
itti_msg
.
tai
.
mnc
+
amf_cfg
.
guami
.
regionID
+
guti
=
conv
::
tmsi_to_guti
(
itti_msg
.
_5g_s_tmsi
;
itti_msg
.
tai
.
mcc
,
itti_msg
.
tai
.
mnc
,
amf_cfg
.
guami
.
regionID
,
itti_msg
.
_5g_s_tmsi
);
is_guti_valid
=
true
;
is_guti_valid
=
true
;
Logger
::
amf_app
().
debug
(
"Receiving GUTI %s"
,
guti
.
c_str
());
Logger
::
amf_app
().
debug
(
"Receiving GUTI %s"
,
guti
.
c_str
());
}
}
...
@@ -822,6 +823,7 @@ uint32_t amf_app::get_number_registered_ues() const {
...
@@ -822,6 +823,7 @@ uint32_t amf_app::get_number_registered_ues() const {
std
::
shared_lock
lock
(
m_amf_ue_ngap_id2ue_ctx
);
std
::
shared_lock
lock
(
m_amf_ue_ngap_id2ue_ctx
);
return
amf_ue_ngap_id2ue_ctx
.
size
();
return
amf_ue_ngap_id2ue_ctx
.
size
();
}
}
//---------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
void
amf_app
::
add_n1n2_message_subscription
(
void
amf_app
::
add_n1n2_message_subscription
(
const
std
::
string
&
ue_ctx_id
,
const
n1n2sub_id_t
&
sub_id
,
const
std
::
string
&
ue_ctx_id
,
const
n1n2sub_id_t
&
sub_id
,
...
...
src/amf-app/amf_n1.cpp
View file @
c140a19c
...
@@ -149,7 +149,7 @@ amf_n1::amf_n1()
...
@@ -149,7 +149,7 @@ amf_n1::amf_n1()
throw
std
::
runtime_error
(
"Cannot create task TASK_AMF_N1"
);
throw
std
::
runtime_error
(
"Cannot create task TASK_AMF_N1"
);
}
}
amfueid2nas_context
=
{};
amfueid2nas_context
=
{};
ims
i2nas_context
=
{};
sup
i2nas_context
=
{};
supi2amfId
=
{};
supi2amfId
=
{};
supi2ranId
=
{};
supi2ranId
=
{};
guti2nas_context
=
{};
guti2nas_context
=
{};
...
@@ -275,7 +275,7 @@ void amf_n1::handle_itti_message(itti_downlink_nas_transfer& itti_msg) {
...
@@ -275,7 +275,7 @@ void amf_n1::handle_itti_message(itti_downlink_nas_transfer& itti_msg) {
if
(
!
amf_app_inst
->
find_pdu_session_context
(
if
(
!
amf_app_inst
->
find_pdu_session_context
(
nc
->
imsi
,
itti_msg
.
pdu_session_id
,
psc
))
{
nc
->
imsi
,
itti_msg
.
pdu_session_id
,
psc
))
{
Logger
::
amf_n1
().
error
(
Logger
::
amf_n1
().
error
(
"Cannot get pdu_session_context with
SUP
I (%s)"
,
nc
->
imsi
.
c_str
());
"Cannot get pdu_session_context with
IMS
I (%s)"
,
nc
->
imsi
.
c_str
());
return
;
return
;
}
}
...
@@ -392,9 +392,10 @@ void amf_n1::handle_itti_message(itti_uplink_nas_data_ind& nas_data_ind) {
...
@@ -392,9 +392,10 @@ void amf_n1::handle_itti_message(itti_uplink_nas_data_ind& nas_data_ind) {
nc
->
ran_ue_ngap_id
=
nas_data_ind
.
ran_ue_ngap_id
;
nc
->
ran_ue_ngap_id
=
nas_data_ind
.
ran_ue_ngap_id
;
set_amf_ue_ngap_id_2_nas_context
(
amf_ue_ngap_id
,
nc
);
set_amf_ue_ngap_id_2_nas_context
(
amf_ue_ngap_id
,
nc
);
set_supi_2_amf_id
(
"imsi-"
+
nc
->
imsi
,
amf_ue_ngap_id
);
std
::
string
supi
=
conv
::
imsi_to_supi
(
nc
->
imsi
);
set_supi_2_ran_id
(
"imsi-"
+
nc
->
imsi
,
ran_ue_ngap_id
);
set_supi_2_amf_id
(
supi
,
amf_ue_ngap_id
);
set_imsi_2_nas_context
(
"imsi-"
+
nc
->
imsi
,
nc
);
set_supi_2_ran_id
(
supi
,
ran_ue_ngap_id
);
set_supi_2_nas_context
(
supi
,
nc
);
// TODO: To be verified IMSI or SUPI
}
else
{
}
else
{
Logger
::
amf_n1
().
error
(
Logger
::
amf_n1
().
error
(
"No existing nas_context with GUTI %s"
,
nas_data_ind
.
guti
.
c_str
());
"No existing nas_context with GUTI %s"
,
nas_data_ind
.
guti
.
c_str
());
...
@@ -553,7 +554,7 @@ void amf_n1::nas_signalling_establishment_request_handle(
...
@@ -553,7 +554,7 @@ void amf_n1::nas_signalling_establishment_request_handle(
// Trigger UE Reachability Status Notify
// Trigger UE Reachability Status Notify
if
(
!
nc
->
imsi
.
empty
())
{
if
(
!
nc
->
imsi
.
empty
())
{
string
supi
=
"imsi-"
+
nc
->
imsi
;
string
supi
=
conv
::
imsi_to_supi
(
nc
->
imsi
)
;
Logger
::
amf_n1
().
debug
(
Logger
::
amf_n1
().
debug
(
"Signal the UE Reachability Status Event notification for SUPI %s"
,
"Signal the UE Reachability Status Event notification for SUPI %s"
,
supi
.
c_str
());
supi
.
c_str
());
...
@@ -714,13 +715,12 @@ void amf_n1::identity_response_handle(
...
@@ -714,13 +715,12 @@ void amf_n1::identity_response_handle(
Logger
::
amf_n1
().
error
(
"Decode Identity Response error"
);
Logger
::
amf_n1
().
error
(
"Decode Identity Response error"
);
return
;
return
;
}
}
string
supi
=
{};
string
imsi_str
=
{};
//_5GSMobileIdentity mobile_identity = {};
// TODO: avoid accessing member function directly
// TODO: avoid accessing member function directly
nas
::
SUCI_imsi_t
imsi
=
{};
nas
::
SUCI_imsi_t
imsi
=
{};
identity_response
->
ie_mobile_identity
.
GetSuciWithSupiImsi
(
imsi
);
identity_response
->
ie_mobile_identity
.
GetSuciWithSupiImsi
(
imsi
);
supi
=
imsi
.
mcc
+
imsi
.
mnc
+
imsi
.
msin
;
imsi_str
=
imsi
.
mcc
+
imsi
.
mnc
+
imsi
.
msin
;
Logger
::
amf_n1
().
debug
(
"Identity Response: SUCI (%s)"
,
supi
.
c_str
());
Logger
::
amf_n1
().
debug
(
"Identity Response: SUCI (%s)"
,
imsi_str
.
c_str
());
string
ue_context_key
=
string
ue_context_key
=
conv
::
get_ue_context_key
(
ran_ue_ngap_id
,
amf_ue_ngap_id
);
conv
::
get_ue_context_key
(
ran_ue_ngap_id
,
amf_ue_ngap_id
);
...
@@ -728,7 +728,7 @@ void amf_n1::identity_response_handle(
...
@@ -728,7 +728,7 @@ void amf_n1::identity_response_handle(
std
::
shared_ptr
<
ue_context
>
uc
=
{};
std
::
shared_ptr
<
ue_context
>
uc
=
{};
if
(
amf_app_inst
->
ran_amf_id_2_ue_context
(
ue_context_key
,
uc
))
{
if
(
amf_app_inst
->
ran_amf_id_2_ue_context
(
ue_context_key
,
uc
))
{
// Update UE context
// Update UE context
uc
->
supi
=
"imsi-"
+
supi
;
uc
->
supi
=
conv
::
imsi_to_supi
(
imsi_str
)
;
// associate SUPI with UC
// associate SUPI with UC
// Verify if there's PDU session info in the old context
// Verify if there's PDU session info in the old context
std
::
shared_ptr
<
ue_context
>
old_uc
=
{};
std
::
shared_ptr
<
ue_context
>
old_uc
=
{};
...
@@ -756,9 +756,10 @@ void amf_n1::identity_response_handle(
...
@@ -756,9 +756,10 @@ void amf_n1::identity_response_handle(
nc
->
amf_ue_ngap_id
=
amf_ue_ngap_id
;
nc
->
amf_ue_ngap_id
=
amf_ue_ngap_id
;
nc
->
ran_ue_ngap_id
=
ran_ue_ngap_id
;
nc
->
ran_ue_ngap_id
=
ran_ue_ngap_id
;
nc
->
is_imsi_present
=
true
;
nc
->
is_imsi_present
=
true
;
nc
->
imsi
=
supi
;
nc
->
imsi
=
imsi_str
;
set_supi_2_amf_id
(
"imsi-"
+
nc
->
imsi
,
amf_ue_ngap_id
);
string
supi
=
conv
::
imsi_to_supi
(
nc
->
imsi
);
set_supi_2_ran_id
(
"imsi-"
+
nc
->
imsi
,
ran_ue_ngap_id
);
set_supi_2_amf_id
(
supi
,
amf_ue_ngap_id
);
set_supi_2_ran_id
(
supi
,
ran_ue_ngap_id
);
// Stop Mobile Reachable Timer/Implicit Deregistration Timer
// Stop Mobile Reachable Timer/Implicit Deregistration Timer
itti_inst
->
timer_remove
(
nc
->
mobile_reachable_timer
);
itti_inst
->
timer_remove
(
nc
->
mobile_reachable_timer
);
itti_inst
->
timer_remove
(
nc
->
implicit_deregistration_timer
);
itti_inst
->
timer_remove
(
nc
->
implicit_deregistration_timer
);
...
@@ -792,7 +793,6 @@ void amf_n1::identity_response_handle(
...
@@ -792,7 +793,6 @@ void amf_n1::identity_response_handle(
set_5gmm_state
(
nc
,
_5GMM_COMMON_PROCEDURE_INITIATED
);
set_5gmm_state
(
nc
,
_5GMM_COMMON_PROCEDURE_INITIATED
);
string
supi
=
"imsi-"
+
nc
->
imsi
;
Logger
::
amf_n1
().
debug
(
Logger
::
amf_n1
().
debug
(
"Signal the UE Registration State Event notification for SUPI %s"
,
"Signal the UE Registration State Event notification for SUPI %s"
,
supi
.
c_str
());
supi
.
c_str
());
...
@@ -828,9 +828,9 @@ void amf_n1::service_request_handle(
...
@@ -828,9 +828,9 @@ void amf_n1::service_request_handle(
uint8_t
amf_pointer
=
{};
uint8_t
amf_pointer
=
{};
string
tmsi
=
{};
string
tmsi
=
{};
if
(
service_request
->
Get5gSTmsi
(
amf_set_id
,
amf_pointer
,
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
::
string
guti
=
conv
::
tmsi_to_guti
(
std
::
to_string
(
amf_set_id
)
+
uc
->
tai
.
mcc
,
uc
->
tai
.
mnc
,
amf_cfg
.
guami
.
regionID
,
std
::
to_string
(
amf_pointer
)
+
tmsi
;
std
::
to_string
(
amf_set_id
),
std
::
to_string
(
amf_pointer
),
tmsi
)
;
Logger
::
amf_app
().
debug
(
Logger
::
amf_app
().
debug
(
"GUTI %s, 5G-TMSI %s"
,
guti
.
c_str
(),
tmsi
.
c_str
());
"GUTI %s, 5G-TMSI %s"
,
guti
.
c_str
(),
tmsi
.
c_str
());
...
@@ -887,7 +887,7 @@ void amf_n1::service_request_handle(
...
@@ -887,7 +887,7 @@ void amf_n1::service_request_handle(
std
::
unique_ptr
<
ServiceAccept
>
service_accept
=
std
::
unique_ptr
<
ServiceAccept
>
service_accept
=
std
::
make_unique
<
ServiceAccept
>
();
std
::
make_unique
<
ServiceAccept
>
();
service_accept
->
SetHeader
(
PLAIN_5GS_MSG
);
service_accept
->
SetHeader
(
PLAIN_5GS_MSG
);
string
supi
=
"imsi-"
+
nc
->
imsi
;
string
supi
=
conv
::
imsi_to_supi
(
nc
->
imsi
)
;
uc
->
supi
=
supi
;
uc
->
supi
=
supi
;
set_supi_2_amf_id
(
supi
,
amf_ue_ngap_id
);
set_supi_2_amf_id
(
supi
,
amf_ue_ngap_id
);
set_supi_2_ran_id
(
supi
,
ran_ue_ngap_id
);
set_supi_2_ran_id
(
supi
,
ran_ue_ngap_id
);
...
@@ -1121,12 +1121,12 @@ void amf_n1::registration_request_handle(
...
@@ -1121,12 +1121,12 @@ void amf_n1::registration_request_handle(
}
}
nc
->
is_imsi_present
=
true
;
nc
->
is_imsi_present
=
true
;
nc
->
imsi
=
imsi
.
mcc
+
imsi
.
mnc
+
imsi
.
msin
;
nc
->
imsi
=
conv
::
get_imsi
(
imsi
.
mcc
,
imsi
.
mnc
,
imsi
.
msin
)
;
Logger
::
amf_n1
().
debug
(
"Received IMSI %s"
,
nc
->
imsi
.
c_str
());
Logger
::
amf_n1
().
debug
(
"Received IMSI %s"
,
nc
->
imsi
.
c_str
());
// Trigger UE Reachability Status Notify
// Trigger UE Reachability Status Notify
if
(
!
nc
->
imsi
.
empty
())
{
if
(
!
nc
->
imsi
.
empty
())
{
string
supi
=
"imsi-"
+
nc
->
imsi
;
string
supi
=
conv
::
imsi_to_supi
(
nc
->
imsi
)
;
Logger
::
amf_n1
().
debug
(
Logger
::
amf_n1
().
debug
(
"Signal the UE Reachability Status Event notification for SUPI "
"Signal the UE Reachability Status Event notification for SUPI "
"%s"
,
"%s"
,
...
@@ -1134,19 +1134,19 @@ void amf_n1::registration_request_handle(
...
@@ -1134,19 +1134,19 @@ void amf_n1::registration_request_handle(
event_sub
.
ue_reachability_status
(
supi
,
CM_CONNECTED
,
1
);
event_sub
.
ue_reachability_status
(
supi
,
CM_CONNECTED
,
1
);
}
}
set_supi_2_amf_id
(
"imsi-"
+
nc
->
imsi
,
amf_ue_ngap_id
);
std
::
string
supi
=
conv
::
imsi_to_supi
(
nc
->
imsi
);
set_supi_2_ran_id
(
"imsi-"
+
nc
->
imsi
,
ran_ue_ngap_id
);
set_supi_2_amf_id
(
supi
,
amf_ue_ngap_id
);
set_supi_2_ran_id
(
supi
,
ran_ue_ngap_id
);
// Try to find old nas_context and release
// Try to find old nas_context and release
std
::
shared_ptr
<
nas_context
>
old_nc
=
{};
std
::
shared_ptr
<
nas_context
>
old_nc
=
{};
if
(
imsi_2_nas_context
(
"imsi-"
+
nc
->
ims
i
,
old_nc
))
{
if
(
supi_2_nas_context
(
sup
i
,
old_nc
))
{
old_nc
.
reset
();
old_nc
.
reset
();
}
}
set_
imsi_2_nas_context
(
"imsi-"
+
nc
->
ims
i
,
nc
);
set_
supi_2_nas_context
(
sup
i
,
nc
);
Logger
::
amf_n1
().
info
(
Logger
::
amf_n1
().
info
(
"Associating IMSI (%s) with nas_context (%p)"
,
"Associating SUPI (%s) with nas_context (%p)"
,
supi
.
c_str
(),
nc
);
(
"imsi-"
+
nc
->
imsi
).
c_str
(),
nc
);
if
(
!
nc
->
is_stacs_available
)
{
if
(
!
nc
->
is_stacs_available
)
{
ue_info_t
ueItem
;
ue_info_t
ueItem
;
ueItem
.
connStatus
=
"5GMM-CONNECTED"
;
//"CM-CONNECTED";
ueItem
.
connStatus
=
"5GMM-CONNECTED"
;
//"CM-CONNECTED";
...
@@ -1187,8 +1187,9 @@ void amf_n1::registration_request_handle(
...
@@ -1187,8 +1187,9 @@ void amf_n1::registration_request_handle(
// Update Nas Context
// Update Nas Context
nc
->
amf_ue_ngap_id
=
amf_ue_ngap_id
;
nc
->
amf_ue_ngap_id
=
amf_ue_ngap_id
;
nc
->
ran_ue_ngap_id
=
ran_ue_ngap_id
;
nc
->
ran_ue_ngap_id
=
ran_ue_ngap_id
;
set_supi_2_amf_id
(
"imsi-"
+
nc
->
imsi
,
amf_ue_ngap_id
);
std
::
string
supi
=
conv
::
imsi_to_supi
(
nc
->
imsi
);
set_supi_2_ran_id
(
"imsi-"
+
nc
->
imsi
,
ran_ue_ngap_id
);
set_supi_2_amf_id
(
supi
,
amf_ue_ngap_id
);
set_supi_2_ran_id
(
supi
,
ran_ue_ngap_id
);
nc
->
is_auth_vectors_present
=
false
;
nc
->
is_auth_vectors_present
=
false
;
nc
->
is_current_security_available
=
false
;
nc
->
is_current_security_available
=
false
;
if
(
nc
->
security_ctx
)
if
(
nc
->
security_ctx
)
...
@@ -1220,9 +1221,9 @@ void amf_n1::registration_request_handle(
...
@@ -1220,9 +1221,9 @@ void amf_n1::registration_request_handle(
nc
->
is_5g_guti_present
=
true
;
nc
->
is_5g_guti_present
=
true
;
nc
->
to_be_register_by_new_suci
=
true
;
nc
->
to_be_register_by_new_suci
=
true
;
nc
->
ngKsi
=
100
&
0xf
;
// TODO: remove hardcoded value
nc
->
ngKsi
=
100
&
0xf
;
// TODO: remove hardcoded value
//
nc->imsi =
//
std::string supi = conv::imsi_to_supi(nc->imsi);
// set_supi_2_amf_id(
"imsi-" + nc->ims
i, amf_ue_ngap_id);
// set_supi_2_amf_id(
sup
i, amf_ue_ngap_id);
// set_supi_2_ran_id(
"imsi-" + nc->ims
i, ran_ue_ngap_id);
// set_supi_2_ran_id(
sup
i, ran_ue_ngap_id);
// Stop Mobile Reachable Timer/Implicit Deregistration Timer
// Stop Mobile Reachable Timer/Implicit Deregistration Timer
itti_inst
->
timer_remove
(
nc
->
mobile_reachable_timer
);
itti_inst
->
timer_remove
(
nc
->
mobile_reachable_timer
);
...
@@ -1230,7 +1231,7 @@ void amf_n1::registration_request_handle(
...
@@ -1230,7 +1231,7 @@ void amf_n1::registration_request_handle(
// Trigger UE Reachability Status Notify
// Trigger UE Reachability Status Notify
if
(
!
nc
->
imsi
.
empty
())
{
if
(
!
nc
->
imsi
.
empty
())
{
st
ring
supi
=
"imsi-"
+
nc
->
imsi
;
st
d
::
string
supi
=
conv
::
imsi_to_supi
(
nc
->
imsi
)
;
Logger
::
amf_n1
().
debug
(
Logger
::
amf_n1
().
debug
(
"Signal the UE Reachability Status Event notification for SUPI "
"Signal the UE Reachability Status Event notification for SUPI "
"%s"
,
"%s"
,
...
@@ -1252,8 +1253,9 @@ void amf_n1::registration_request_handle(
...
@@ -1252,8 +1253,9 @@ void amf_n1::registration_request_handle(
set_amf_ue_ngap_id_2_nas_context
(
amf_ue_ngap_id
,
nc
);
set_amf_ue_ngap_id_2_nas_context
(
amf_ue_ngap_id
,
nc
);
nc
->
amf_ue_ngap_id
=
amf_ue_ngap_id
;
nc
->
amf_ue_ngap_id
=
amf_ue_ngap_id
;
nc
->
ran_ue_ngap_id
=
ran_ue_ngap_id
;
nc
->
ran_ue_ngap_id
=
ran_ue_ngap_id
;
set_supi_2_amf_id
(
"imsi-"
+
nc
->
imsi
,
amf_ue_ngap_id
);
std
::
string
supi
=
conv
::
imsi_to_supi
(
nc
->
imsi
);
set_supi_2_ran_id
(
"imsi-"
+
nc
->
imsi
,
ran_ue_ngap_id
);
set_supi_2_amf_id
(
supi
,
amf_ue_ngap_id
);
set_supi_2_ran_id
(
supi
,
ran_ue_ngap_id
);
nc
->
is_auth_vectors_present
=
false
;
nc
->
is_auth_vectors_present
=
false
;
nc
->
is_current_security_available
=
false
;
nc
->
is_current_security_available
=
false
;
...
@@ -1293,7 +1295,7 @@ void amf_n1::registration_request_handle(
...
@@ -1293,7 +1295,7 @@ void amf_n1::registration_request_handle(
// Update UE context
// Update UE context
if
(
uc
!=
nullptr
)
{
if
(
uc
!=
nullptr
)
{
std
::
string
supi
=
"imsi-"
+
nc
->
imsi
;
std
::
string
supi
=
conv
::
imsi_to_supi
(
nc
->
imsi
)
;
uc
->
supi
=
supi
;
uc
->
supi
=
supi
;
// associate SUPI with UC
// associate SUPI with UC
amf_app_inst
->
set_supi_2_ue_context
(
supi
,
uc
);
amf_app_inst
->
set_supi_2_ue_context
(
supi
,
uc
);
...
@@ -1579,12 +1581,12 @@ bool amf_n1::remove_guti_2_nas_context(const std::string& guti) {
...
@@ -1579,12 +1581,12 @@ bool amf_n1::remove_guti_2_nas_context(const std::string& guti) {
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
bool
amf_n1
::
ims
i_2_nas_context
(
bool
amf_n1
::
sup
i_2_nas_context
(
const
std
::
string
&
imsi
,
std
::
shared_ptr
<
nas_context
>&
nc
)
const
{
const
std
::
string
&
imsi
,
std
::
shared_ptr
<
nas_context
>&
nc
)
const
{
std
::
shared_lock
lock
(
m_nas_context
);
std
::
shared_lock
lock
(
m_nas_context
);
if
(
ims
i2nas_context
.
count
(
imsi
)
>
0
)
{
if
(
sup
i2nas_context
.
count
(
imsi
)
>
0
)
{
if
(
!
ims
i2nas_context
.
at
(
imsi
))
return
false
;
if
(
!
sup
i2nas_context
.
at
(
imsi
))
return
false
;
nc
=
ims
i2nas_context
.
at
(
imsi
);
nc
=
sup
i2nas_context
.
at
(
imsi
);
return
true
;
return
true
;
}
else
{
}
else
{
return
false
;
return
false
;
...
@@ -1592,17 +1594,17 @@ bool amf_n1::imsi_2_nas_context(
...
@@ -1592,17 +1594,17 @@ bool amf_n1::imsi_2_nas_context(
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void
amf_n1
::
set_
ims
i_2_nas_context
(
void
amf_n1
::
set_
sup
i_2_nas_context
(
const
std
::
string
&
imsi
,
const
std
::
shared_ptr
<
nas_context
>&
nc
)
{
const
std
::
string
&
imsi
,
const
std
::
shared_ptr
<
nas_context
>&
nc
)
{
std
::
unique_lock
lock
(
m_nas_context
);
std
::
unique_lock
lock
(
m_nas_context
);
ims
i2nas_context
[
imsi
]
=
nc
;
sup
i2nas_context
[
imsi
]
=
nc
;
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
bool
amf_n1
::
remove_
ims
i_2_nas_context
(
const
std
::
string
&
imsi
)
{
bool
amf_n1
::
remove_
sup
i_2_nas_context
(
const
std
::
string
&
imsi
)
{
std
::
unique_lock
lock
(
m_nas_context
);
std
::
unique_lock
lock
(
m_nas_context
);
if
(
ims
i2nas_context
.
count
(
imsi
)
>
0
)
{
if
(
sup
i2nas_context
.
count
(
imsi
)
>
0
)
{
ims
i2nas_context
.
erase
(
imsi
);
sup
i2nas_context
.
erase
(
imsi
);
return
true
;
return
true
;
}
}
return
false
;
return
false
;
...
@@ -2561,7 +2563,7 @@ void amf_n1::security_mode_complete_handle(
...
@@ -2561,7 +2563,7 @@ void amf_n1::security_mode_complete_handle(
// If AMF can't handle this and there's an error when trying to handling the
// If AMF can't handle this and there's an error when trying to handling the
// UE to the target AMFs, thus encoding REGISTRATION REJECT
// UE to the target AMFs, thus encoding REGISTRATION REJECT
if
(
!
reroute_result
)
{
if
(
!
reroute_result
)
{
uint8_t
cause_value
=
7
;
// 5GS services not allowed - TO BE VERIFIED
uint8_t
cause_value
=
7
;
//
TODO:
5GS services not allowed - TO BE VERIFIED
send_registration_reject_msg
(
cause_value
,
ran_ue_ngap_id
,
amf_ue_ngap_id
);
send_registration_reject_msg
(
cause_value
,
ran_ue_ngap_id
,
amf_ue_ngap_id
);
return
;
return
;
}
}
...
@@ -2583,10 +2585,12 @@ void amf_n1::security_mode_complete_handle(
...
@@ -2583,10 +2585,12 @@ void amf_n1::security_mode_complete_handle(
mcc
,
mnc
,
amf_cfg
.
guami
.
regionID
,
amf_cfg
.
guami
.
AmfSetID
,
mcc
,
mnc
,
amf_cfg
.
guami
.
regionID
,
amf_cfg
.
guami
.
AmfSetID
,
amf_cfg
.
guami
.
AmfPointer
,
tmsi
);
amf_cfg
.
guami
.
AmfPointer
,
tmsi
);
std
::
string
guti
=
mcc
+
mnc
+
amf_cfg
.
guami
.
regionID
+
std
::
string
guti
=
conv
::
tmsi_to_guti
(
amf_cfg
.
guami
.
AmfSetID
+
amf_cfg
.
guami
.
AmfPointer
+
mcc
,
mnc
,
amf_cfg
.
guami
.
regionID
,
amf_cfg
.
guami
.
AmfSetID
,
conv
::
tmsi_to_string
(
tmsi
);
amf_cfg
.
guami
.
AmfPointer
,
conv
::
tmsi_to_string
(
tmsi
));
Logger
::
amf_n1
().
debug
(
"Allocated GUTI %s"
,
guti
.
c_str
());
Logger
::
amf_n1
().
debug
(
"Allocated GUTI %s (TMSI %s)"
,
guti
.
c_str
(),
conv
::
tmsi_to_string
(
tmsi
).
c_str
());
// registration_accept->SetT3512Value(0x5, T3512_TIMER_VALUE_MIN);
// registration_accept->SetT3512Value(0x5, T3512_TIMER_VALUE_MIN);
uint8_t
buffer
[
BUFFER_SIZE_1024
]
=
{
0
};
uint8_t
buffer
[
BUFFER_SIZE_1024
]
=
{
0
};
...
@@ -2664,7 +2668,7 @@ void amf_n1::security_mode_complete_handle(
...
@@ -2664,7 +2668,7 @@ void amf_n1::security_mode_complete_handle(
}
}
// Trigger UE Registration Status Notify
// Trigger UE Registration Status Notify
string
supi
=
"imsi-"
+
nc
->
imsi
;
string
supi
=
conv
::
imsi_to_supi
(
nc
->
imsi
)
;
Logger
::
amf_n1
().
debug
(
Logger
::
amf_n1
().
debug
(
"Signal the UE Registration State Event notification for SUPI %s"
,
"Signal the UE Registration State Event notification for SUPI %s"
,
supi
.
c_str
());
supi
.
c_str
());
...
@@ -3166,7 +3170,7 @@ void amf_n1::ue_initiate_de_registration_handle(
...
@@ -3166,7 +3170,7 @@ void amf_n1::ue_initiate_de_registration_handle(
set_5gmm_state
(
nc
,
_5GMM_DEREGISTERED
);
set_5gmm_state
(
nc
,
_5GMM_DEREGISTERED
);
stacs
.
display
();
stacs
.
display
();
string
supi
=
"imsi-"
+
nc
->
imsi
;
string
supi
=
conv
::
imsi_to_supi
(
nc
->
imsi
)
;
// Trigger UE Registration Status Notify
// Trigger UE Registration Status Notify
Logger
::
amf_n1
().
debug
(
Logger
::
amf_n1
().
debug
(
"Signal the UE Registration State Event notification for SUPI %s"
,
"Signal the UE Registration State Event notification for SUPI %s"
,
...
@@ -3206,7 +3210,7 @@ void amf_n1::ue_initiate_de_registration_handle(
...
@@ -3206,7 +3210,7 @@ void amf_n1::ue_initiate_de_registration_handle(
amf_ue_ngap_id
);
amf_ue_ngap_id
);
}
}
if
(
remove_
ims
i_2_nas_context
(
supi
))
{
if
(
remove_
sup
i_2_nas_context
(
supi
))
{
Logger
::
amf_n1
().
debug
(
Logger
::
amf_n1
().
debug
(
"Deleted nas_context associated SUPI %s "
,
supi
.
c_str
());
"Deleted nas_context associated SUPI %s "
,
supi
.
c_str
());
}
else
{
}
else
{
...
@@ -4198,7 +4202,7 @@ void amf_n1::initialize_registration_accept(
...
@@ -4198,7 +4202,7 @@ void amf_n1::initialize_registration_accept(
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
bool
amf_n1
::
find_ue_context
(
bool
amf_n1
::
find_ue_context
(
const
std
::
shared_ptr
<
nas_context
>&
nc
,
std
::
shared_ptr
<
ue_context
>&
uc
)
{
const
std
::
shared_ptr
<
nas_context
>&
nc
,
std
::
shared_ptr
<
ue_context
>&
uc
)
{
string
supi
=
"imsi-"
+
nc
->
imsi
;
string
supi
=
conv
::
imsi_to_supi
(
nc
->
imsi
)
;
Logger
::
amf_n1
().
debug
(
"Key for PDU Session Context SUPI (%s)"
,
supi
.
c_str
());
Logger
::
amf_n1
().
debug
(
"Key for PDU Session Context SUPI (%s)"
,
supi
.
c_str
());
string
ue_context_key
=
string
ue_context_key
=
...
@@ -4240,7 +4244,7 @@ void amf_n1::mobile_reachable_timer_timeout(
...
@@ -4240,7 +4244,7 @@ void amf_n1::mobile_reachable_timer_timeout(
set_mobile_reachable_timer_timeout
(
nc
,
true
);
set_mobile_reachable_timer_timeout
(
nc
,
true
);
// Trigger UE Loss of Connectivity Status Notify
// Trigger UE Loss of Connectivity Status Notify
string
supi
=
"imsi-"
+
nc
->
imsi
;
string
supi
=
conv
::
imsi_to_supi
(
nc
->
imsi
)
;
Logger
::
amf_n1
().
debug
(
Logger
::
amf_n1
().
debug
(
"Signal the UE Loss of Connectivity Event notification for SUPI %s"
,
"Signal the UE Loss of Connectivity Event notification for SUPI %s"
,
supi
.
c_str
());
supi
.
c_str
());
...
@@ -4320,7 +4324,7 @@ void amf_n1::implicit_deregistration_timer_timeout(
...
@@ -4320,7 +4324,7 @@ void amf_n1::implicit_deregistration_timer_timeout(
}
}
// Trigger UE Connectivity Status Notify
// Trigger UE Connectivity Status Notify
string
supi
=
"imsi-"
+
nc
->
imsi
;
string
supi
=
conv
::
imsi_to_supi
(
nc
->
imsi
)
;
Logger
::
amf_n1
().
debug
(
Logger
::
amf_n1
().
debug
(
"Signal the UE Connectivity Status Event notification for SUPI %s"
,
"Signal the UE Connectivity Status Event notification for SUPI %s"
,
supi
.
c_str
());
supi
.
c_str
());
...
...
src/amf-app/amf_n1.hpp
View file @
c140a19c
...
@@ -221,22 +221,22 @@ class amf_n1 {
...
@@ -221,22 +221,22 @@ class amf_n1 {
bool
remove_supi_2_ran_id
(
const
std
::
string
&
supi
);
bool
remove_supi_2_ran_id
(
const
std
::
string
&
supi
);
/*
/*
* Get UE NAS context associated with an
IMS
I
* Get UE NAS context associated with an
SUP
I
* @param [const std::string&] imsi: UE
IMS
I
* @param [const std::string&] imsi: UE
SUP
I
* @param [const std::shared_ptr<nas_context>&] nc: pointer to UE NAS context
* @param [const std::shared_ptr<nas_context>&] nc: pointer to UE NAS context
* @return true if the NAS context exists and is not null, otherwise return
* @return true if the NAS context exists and is not null, otherwise return
* false
* false
*/
*/
bool
ims
i_2_nas_context
(
bool
sup
i_2_nas_context
(
const
std
::
string
&
imsi
,
std
::
shared_ptr
<
nas_context
>&
)
const
;
const
std
::
string
&
imsi
,
std
::
shared_ptr
<
nas_context
>&
)
const
;
/*
/*
* Store an UE NAS context associated with an
IMS
I
* Store an UE NAS context associated with an
SUP
I
* @param [const std::string&] imsi: UE
IMS
I
* @param [const std::string&] imsi: UE
SUP
I
* @param [const std::shared_ptr<nas_context>&] nc: pointer to UE NAS context
* @param [const std::shared_ptr<nas_context>&] nc: pointer to UE NAS context
* @return void
* @return void
*/
*/
void
set_
ims
i_2_nas_context
(
void
set_
sup
i_2_nas_context
(
const
std
::
string
&
imsi
,
const
std
::
shared_ptr
<
nas_context
>&
nc
);
const
std
::
string
&
imsi
,
const
std
::
shared_ptr
<
nas_context
>&
nc
);
/*
/*
...
@@ -244,7 +244,7 @@ class amf_n1 {
...
@@ -244,7 +244,7 @@ class amf_n1 {
* @param [const std::string&] imsi: UE IMSI
* @param [const std::string&] imsi: UE IMSI
* @return true if successful, otherwise return false
* @return true if successful, otherwise return false
*/
*/
bool
remove_
ims
i_2_nas_context
(
const
std
::
string
&
imsi
);
bool
remove_
sup
i_2_nas_context
(
const
std
::
string
&
imsi
);
/*
/*
* Perform Registration procedure
* Perform Registration procedure
...
@@ -991,7 +991,7 @@ class amf_n1 {
...
@@ -991,7 +991,7 @@ class amf_n1 {
amfueid2nas_context
;
// amf ue ngap id
amfueid2nas_context
;
// amf ue ngap id
mutable
std
::
shared_mutex
m_amfueid2nas_context
;
mutable
std
::
shared_mutex
m_amfueid2nas_context
;
std
::
map
<
std
::
string
,
std
::
shared_ptr
<
nas_context
>>
ims
i2nas_context
;
std
::
map
<
std
::
string
,
std
::
shared_ptr
<
nas_context
>>
sup
i2nas_context
;
std
::
map
<
std
::
string
,
long
>
supi2amfId
;
std
::
map
<
std
::
string
,
long
>
supi2amfId
;
std
::
map
<
std
::
string
,
uint32_t
>
supi2ranId
;
std
::
map
<
std
::
string
,
uint32_t
>
supi2ranId
;
mutable
std
::
shared_mutex
m_nas_context
;
mutable
std
::
shared_mutex
m_nas_context
;
...
...
src/amf-app/amf_n2.cpp
View file @
c140a19c
...
@@ -888,7 +888,7 @@ void amf_n2::handle_itti_message(itti_initial_context_setup_request& itti_msg) {
...
@@ -888,7 +888,7 @@ void amf_n2::handle_itti_message(itti_initial_context_setup_request& itti_msg) {
itti_msg
.
amf_ue_ngap_id
);
itti_msg
.
amf_ue_ngap_id
);
// TODO:
// TODO:
}
}
string
supi
=
"imsi-"
+
nc
->
imsi
;
string
supi
=
conv
::
imsi_to_supi
(
nc
->
imsi
)
;
Logger
::
amf_n2
().
debug
(
"SUPI (%s)"
,
supi
.
c_str
());
Logger
::
amf_n2
().
debug
(
"SUPI (%s)"
,
supi
.
c_str
());
// Get S_NSSAI from PDU Session Context
// Get S_NSSAI from PDU Session Context
...
@@ -974,7 +974,7 @@ void amf_n2::handle_itti_message(
...
@@ -974,7 +974,7 @@ void amf_n2::handle_itti_message(
itti_msg
.
amf_ue_ngap_id
);
itti_msg
.
amf_ue_ngap_id
);
// TODO:
// TODO:
}
}
string
supi
=
"imsi-"
+
nc
->
imsi
;
string
supi
=
conv
::
imsi_to_supi
(
nc
->
imsi
)
;
Logger
::
amf_n2
().
debug
(
"SUPI (%s)"
,
supi
.
c_str
());
Logger
::
amf_n2
().
debug
(
"SUPI (%s)"
,
supi
.
c_str
());
// Get SNSSAI info from PDU Session Context
// Get SNSSAI info from PDU Session Context
...
@@ -1196,7 +1196,7 @@ void amf_n2::handle_itti_message(itti_ue_context_release_command& itti_msg) {
...
@@ -1196,7 +1196,7 @@ void amf_n2::handle_itti_message(itti_ue_context_release_command& itti_msg) {
itti_msg
.
amf_ue_ngap_id
);
itti_msg
.
amf_ue_ngap_id
);
return
;
return
;
}
}
string
supi
=
"imsi-"
+
nc
->
imsi
;
string
supi
=
conv
::
imsi_to_supi
(
nc
->
imsi
)
;
Logger
::
amf_n2
().
debug
(
Logger
::
amf_n2
().
debug
(
"Send request to SBI to trigger UE Communication Failure Report (SUPI "
"Send request to SBI to trigger UE Communication Failure Report (SUPI "
...
@@ -1304,7 +1304,7 @@ void amf_n2::handle_itti_message(itti_ue_context_release_complete& itti_msg) {
...
@@ -1304,7 +1304,7 @@ void amf_n2::handle_itti_message(itti_ue_context_release_complete& itti_msg) {
// TODO: may consider releasing all exisiting PDU sessions
// TODO: may consider releasing all exisiting PDU sessions
/*
/*
if (pdu_sessions_to_be_released.size() == 0) {
if (pdu_sessions_to_be_released.size() == 0) {
string supi = "imsi-" + nc->imsi
;
string supi = conv::imsi_to_supi(nc->imsi)
;
std::vector<std::shared_ptr<pdu_session_context>> sessions_ctx;
std::vector<std::shared_ptr<pdu_session_context>> sessions_ctx;
if (!amf_app_inst->get_pdu_sessions_context(supi, sessions_ctx)) {
if (!amf_app_inst->get_pdu_sessions_context(supi, sessions_ctx)) {
Logger::amf_n2().debug("No PDU Session Context found");
Logger::amf_n2().debug("No PDU Session Context found");
...
@@ -1556,7 +1556,7 @@ bool amf_n2::handle_itti_message(itti_handover_required& itti_msg) {
...
@@ -1556,7 +1556,7 @@ bool amf_n2::handle_itti_message(itti_handover_required& itti_msg) {
bstring
knh_bs
=
blk2bstr
(
knh
,
32
);
bstring
knh_bs
=
blk2bstr
(
knh
,
32
);
handover_request
->
setSecurityContext
(
unc
->
ncc
/*NCC count*/
,
knh_bs
);
handover_request
->
setSecurityContext
(
unc
->
ncc
/*NCC count*/
,
knh_bs
);
string
supi
=
"imsi-"
+
nc
->
imsi
;
string
supi
=
conv
::
imsi_to_supi
(
nc
->
imsi
)
;
Logger
::
amf_n2
().
debug
(
Logger
::
amf_n2
().
debug
(
"Received Handover Required for UE (SUPI %s)"
,
supi
.
c_str
());
"Received Handover Required for UE (SUPI %s)"
,
supi
.
c_str
());
...
@@ -1738,7 +1738,7 @@ void amf_n2::handle_itti_message(itti_handover_request_Ack& itti_msg) {
...
@@ -1738,7 +1738,7 @@ void amf_n2::handle_itti_message(itti_handover_request_Ack& itti_msg) {
return
;
return
;
}
}
string
supi
=
"imsi-"
+
nc
->
imsi
;
string
supi
=
conv
::
imsi_to_supi
(
nc
->
imsi
)
;
// Send PDUSessionUpdateSMContextRequest to SMF for all associated PDU
// Send PDUSessionUpdateSMContextRequest to SMF for all associated PDU
// sessions
// sessions
...
@@ -1890,7 +1890,7 @@ void amf_n2::handle_itti_message(itti_handover_notify& itti_msg) {
...
@@ -1890,7 +1890,7 @@ void amf_n2::handle_itti_message(itti_handover_notify& itti_msg) {
return
;
return
;
}
}
string
supi
=
"imsi-"
+
nc
->
imsi
;
string
supi
=
conv
::
imsi_to_supi
(
nc
->
imsi
)
;
std
::
vector
<
std
::
shared_ptr
<
pdu_session_context
>>
sessions_ctx
;
std
::
vector
<
std
::
shared_ptr
<
pdu_session_context
>>
sessions_ctx
;
...
@@ -2184,7 +2184,7 @@ void amf_n2::remove_ue_context_with_ran_ue_ngap_id(
...
@@ -2184,7 +2184,7 @@ void amf_n2::remove_ue_context_with_ran_ue_ngap_id(
std
::
shared_ptr
<
nas_context
>
nc
=
{};
std
::
shared_ptr
<
nas_context
>
nc
=
{};
if
(
amf_n1_inst
->
amf_ue_id_2_nas_context
(
unc
->
amf_ue_ngap_id
,
nc
))
{
if
(
amf_n1_inst
->
amf_ue_id_2_nas_context
(
unc
->
amf_ue_ngap_id
,
nc
))
{
// Remove all NAS context
// Remove all NAS context
string
supi
=
"imsi-"
+
nc
->
imsi
;
string
supi
=
conv
::
imsi_to_supi
(
nc
->
imsi
)
;
if
(
nc
->
is_stacs_available
)
{
if
(
nc
->
is_stacs_available
)
{
stacs
.
update_5gmm_state
(
nc
->
imsi
,
"5GMM-DEREGISTERED"
);
stacs
.
update_5gmm_state
(
nc
->
imsi
,
"5GMM-DEREGISTERED"
);
}
}
...
@@ -2195,7 +2195,7 @@ void amf_n2::remove_ue_context_with_ran_ue_ngap_id(
...
@@ -2195,7 +2195,7 @@ void amf_n2::remove_ue_context_with_ran_ue_ngap_id(
amf_n1_inst
->
event_sub
.
ue_loss_of_connectivity
(
amf_n1_inst
->
event_sub
.
ue_loss_of_connectivity
(
supi
,
DEREGISTERED
,
1
,
ran_ue_ngap_id
,
unc
->
amf_ue_ngap_id
);
supi
,
DEREGISTERED
,
1
,
ran_ue_ngap_id
,
unc
->
amf_ue_ngap_id
);
amf_n1_inst
->
remove_
ims
i_2_nas_context
(
supi
);
amf_n1_inst
->
remove_
sup
i_2_nas_context
(
supi
);
// TODO: remove_guti_2_nas_context(guti);
// TODO: remove_guti_2_nas_context(guti);
amf_n1_inst
->
remove_amf_ue_ngap_id_2_nas_context
(
unc
->
amf_ue_ngap_id
);
amf_n1_inst
->
remove_amf_ue_ngap_id_2_nas_context
(
unc
->
amf_ue_ngap_id
);
// Update UE status
// Update UE status
...
@@ -2271,7 +2271,7 @@ void amf_n2::remove_ue_context_with_amf_ue_ngap_id(
...
@@ -2271,7 +2271,7 @@ void amf_n2::remove_ue_context_with_amf_ue_ngap_id(
std
::
shared_ptr
<
nas_context
>
nc
=
{};
std
::
shared_ptr
<
nas_context
>
nc
=
{};
if
(
amf_n1_inst
->
amf_ue_id_2_nas_context
(
amf_ue_ngap_id
,
nc
))
{
if
(
amf_n1_inst
->
amf_ue_id_2_nas_context
(
amf_ue_ngap_id
,
nc
))
{
// Remove all NAS context
// Remove all NAS context
string
supi
=
"imsi-"
+
nc
->
imsi
;
string
supi
=
conv
::
imsi_to_supi
(
nc
->
imsi
)
;
// Update UE status
// Update UE status
if
(
nc
->
is_stacs_available
)
{
if
(
nc
->
is_stacs_available
)
{
stacs
.
update_5gmm_state
(
nc
->
imsi
,
"5GMM-DEREGISTERED"
);
stacs
.
update_5gmm_state
(
nc
->
imsi
,
"5GMM-DEREGISTERED"
);
...
@@ -2283,7 +2283,7 @@ void amf_n2::remove_ue_context_with_amf_ue_ngap_id(
...
@@ -2283,7 +2283,7 @@ void amf_n2::remove_ue_context_with_amf_ue_ngap_id(
amf_n1_inst
->
event_sub
.
ue_loss_of_connectivity
(
amf_n1_inst
->
event_sub
.
ue_loss_of_connectivity
(
supi
,
DEREGISTERED
,
1
,
nc
->
ran_ue_ngap_id
,
amf_ue_ngap_id
);
supi
,
DEREGISTERED
,
1
,
nc
->
ran_ue_ngap_id
,
amf_ue_ngap_id
);
amf_n1_inst
->
remove_
ims
i_2_nas_context
(
supi
);
amf_n1_inst
->
remove_
sup
i_2_nas_context
(
supi
);
// TODO: remove_guti_2_nas_context(guti);
// TODO: remove_guti_2_nas_context(guti);
amf_n1_inst
->
remove_amf_ue_ngap_id_2_nas_context
(
amf_ue_ngap_id
);
amf_n1_inst
->
remove_amf_ue_ngap_id_2_nas_context
(
amf_ue_ngap_id
);
// Remove NGAP context related to RAN UE NGAP ID
// Remove NGAP context related to RAN UE NGAP ID
...
...
src/amf-app/amf_sbi.cpp
View file @
c140a19c
...
@@ -285,7 +285,7 @@ void amf_sbi::handle_itti_message(itti_nsmf_pdusession_create_sm_context& smf) {
...
@@ -285,7 +285,7 @@ void amf_sbi::handle_itti_message(itti_nsmf_pdusession_create_sm_context& smf) {
return
;
return
;
}
}
st
d
::
string
supi
=
"imsi-"
+
nc
->
imsi
;
st
ring
supi
=
conv
::
imsi_to_supi
(
nc
->
imsi
)
;
string
ue_context_key
=
string
ue_context_key
=
conv
::
get_ue_context_key
(
nc
->
ran_ue_ngap_id
,
nc
->
amf_ue_ngap_id
);
conv
::
get_ue_context_key
(
nc
->
ran_ue_ngap_id
,
nc
->
amf_ue_ngap_id
);
std
::
shared_ptr
<
ue_context
>
uc
=
{};
std
::
shared_ptr
<
ue_context
>
uc
=
{};
...
...
src/common/conversions.cpp
View file @
c140a19c
...
@@ -33,6 +33,9 @@
...
@@ -33,6 +33,9 @@
#include "amf.hpp"
#include "amf.hpp"
#include "logger.hpp"
#include "logger.hpp"
constexpr
uint8_t
kUint32Length
=
8
;
// 4 bytes -8 characters representation in hex
static
const
char
hex_to_ascii_table
[
16
]
=
{
static
const
char
hex_to_ascii_table
[
16
]
=
{
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
,
'8'
,
'9'
,
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
,
...
@@ -110,8 +113,8 @@ std::string conv::mncToString(
...
@@ -110,8 +113,8 @@ std::string conv::mncToString(
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
std
::
string
conv
::
tmsi_to_string
(
const
uint32_t
tmsi
)
{
std
::
string
conv
::
tmsi_to_string
(
const
uint32_t
tmsi
)
{
std
::
string
s
=
{};
std
::
string
s
=
{};
std
::
string
tmsi_str
=
std
::
to
_string
(
tmsi
);
std
::
string
tmsi_str
=
uint32_to_hex
_string
(
tmsi
);
uint8_t
length
=
4
-
tmsi_str
.
size
();
uint8_t
length
=
kUint32Length
-
tmsi_str
.
size
();
for
(
uint8_t
i
=
0
;
i
<
length
;
i
++
)
{
for
(
uint8_t
i
=
0
;
i
<
length
;
i
++
)
{
s
.
append
(
"0"
);
s
.
append
(
"0"
);
}
}
...
@@ -491,3 +494,35 @@ std::string conv::get_serving_network_name(
...
@@ -491,3 +494,35 @@ std::string conv::get_serving_network_name(
snn
=
"5G:mnc"
+
mnc
+
".mcc"
+
mcc
+
".3gppnetwork.org"
;
snn
=
"5G:mnc"
+
mnc
+
".mcc"
+
mcc
+
".3gppnetwork.org"
;
return
snn
;
return
snn
;
}
}
//------------------------------------------------------------------------------
std
::
string
conv
::
uint32_to_hex_string
(
uint32_t
value
)
{
char
hex_str
[
kUint32Length
+
1
];
sprintf
(
hex_str
,
"%X"
,
value
);
return
std
::
string
(
hex_str
);
}
//------------------------------------------------------------------------------
std
::
string
conv
::
tmsi_to_guti
(
const
std
::
string
&
mcc
,
const
std
::
string
&
mnc
,
const
std
::
string
&
region_id
,
const
std
::
string
&
_5g_s_tmsi
)
{
return
{
mcc
+
mnc
+
region_id
+
_5g_s_tmsi
};
}
//------------------------------------------------------------------------------
std
::
string
conv
::
tmsi_to_guti
(
const
std
::
string
&
mcc
,
const
std
::
string
&
mnc
,
const
std
::
string
&
region_id
,
const
std
::
string
&
amf_set_id
,
const
std
::
string
&
amf_pointer
,
const
std
::
string
&
tmsi
)
{
return
{
mcc
+
mnc
+
region_id
+
amf_set_id
+
amf_pointer
+
tmsi
};
}
//------------------------------------------------------------------------------
std
::
string
conv
::
imsi_to_supi
(
const
std
::
string
&
imsi
)
{
return
{
"imsi-"
+
imsi
};
}
//------------------------------------------------------------------------------
std
::
string
conv
::
get_imsi
(
const
std
::
string
&
mcc
,
const
std
::
string
&
mnc
,
const
std
::
string
&
msin
)
{
return
{
mcc
+
mnc
+
msin
};
}
src/common/conversions.hpp
View file @
c140a19c
...
@@ -99,5 +99,16 @@ class conv {
...
@@ -99,5 +99,16 @@ class conv {
const
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
);
const
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
);
static
std
::
string
get_serving_network_name
(
static
std
::
string
get_serving_network_name
(
const
std
::
string
&
mnc
,
const
std
::
string
&
mcc
);
const
std
::
string
&
mnc
,
const
std
::
string
&
mcc
);
static
std
::
string
uint32_to_hex_string
(
uint32_t
value
);
static
std
::
string
tmsi_to_guti
(
const
std
::
string
&
mcc
,
const
std
::
string
&
mnc
,
const
std
::
string
&
region_id
,
const
std
::
string
&
_5g_s_tmsi
);
static
std
::
string
tmsi_to_guti
(
const
std
::
string
&
mcc
,
const
std
::
string
&
mnc
,
const
std
::
string
&
region_id
,
const
std
::
string
&
amf_set_id
,
const
std
::
string
&
amf_pointer
,
const
std
::
string
&
tmsi
);
static
std
::
string
imsi_to_supi
(
const
std
::
string
&
imsi
);
static
std
::
string
get_imsi
(
const
std
::
string
&
mcc
,
const
std
::
string
&
mnc
,
const
std
::
string
&
msin
);
};
};
#endif
/* FILE_CONVERSIONS_HPP_SEEN */
#endif
/* FILE_CONVERSIONS_HPP_SEEN */
src/ngap/ngap_app/ngap_message_callback.hpp
View file @
c140a19c
...
@@ -433,7 +433,7 @@ int ngap_amf_handle_pdu_session_resource_setup_response(
...
@@ -433,7 +433,7 @@ int ngap_amf_handle_pdu_session_resource_setup_response(
"No UE NAS context with amf_ue_ngap_id (0x%x)"
,
amf_ue_ngap_id
);
"No UE NAS context with amf_ue_ngap_id (0x%x)"
,
amf_ue_ngap_id
);
return
RETURNerror
;
return
RETURNerror
;
}
}
itti_msg
->
supi
=
"imsi-"
+
nct
->
imsi
;
itti_msg
->
supi
=
conv
::
imsi_to_supi
(
nct
->
imsi
)
;
itti_msg
->
pdu_session_id
=
list
[
0
].
pduSessionId
;
itti_msg
->
pdu_session_id
=
list
[
0
].
pduSessionId
;
itti_msg
->
n2sm
=
blk2bstr
(
itti_msg
->
n2sm
=
blk2bstr
(
list
[
0
].
pduSessionResourceSetupResponseTransfer
.
buf
,
list
[
0
].
pduSessionResourceSetupResponseTransfer
.
buf
,
...
@@ -503,7 +503,7 @@ int ngap_amf_handle_pdu_session_resource_setup_response(
...
@@ -503,7 +503,7 @@ int ngap_amf_handle_pdu_session_resource_setup_response(
return
RETURNerror
;
return
RETURNerror
;
}
}
string
supi
=
"imsi-"
+
nct
->
imsi
;
string
supi
=
conv
::
imsi_to_supi
(
nct
->
imsi
)
;
std
::
shared_ptr
<
pdu_session_context
>
psc
=
{};
std
::
shared_ptr
<
pdu_session_context
>
psc
=
{};
if
(
amf_app_inst
->
find_pdu_session_context
(
if
(
amf_app_inst
->
find_pdu_session_context
(
supi
,
list_fail
[
0
].
pduSessionId
,
psc
))
{
supi
,
list_fail
[
0
].
pduSessionId
,
psc
))
{
...
...
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