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
f7222ed1
Commit
f7222ed1
authored
Jan 25, 2023
by
Tien Thinh NGUYEN
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'code_refactor_amf_app' into nas_refactor_v2
parents
7ee201a7
5fcec6a9
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
139 additions
and
143 deletions
+139
-143
src/amf-app/amf_app.cpp
src/amf-app/amf_app.cpp
+47
-62
src/amf-app/amf_app.hpp
src/amf-app/amf_app.hpp
+15
-31
src/amf-app/amf_n1.cpp
src/amf-app/amf_n1.cpp
+24
-15
src/amf-app/amf_n2.cpp
src/amf-app/amf_n2.cpp
+16
-21
src/amf-app/amf_n2.hpp
src/amf-app/amf_n2.hpp
+8
-8
src/amf-app/amf_sbi.cpp
src/amf-app/amf_sbi.cpp
+5
-5
src/common/conversions.cpp
src/common/conversions.cpp
+19
-0
src/common/conversions.hpp
src/common/conversions.hpp
+5
-0
src/oai-amf/main.cpp
src/oai-amf/main.cpp
+0
-1
No files found.
src/amf-app/amf_app.cpp
View file @
f7222ed1
...
...
@@ -99,11 +99,6 @@ amf_app::amf_app(const amf_config& amf_cfg)
Logger
::
amf_app
().
startup
(
"Started timer (%d)"
,
tid
);
}
//------------------------------------------------------------------------------
void
amf_app
::
allRegistredModulesInit
(
const
amf_modules
&
modules
)
{
Logger
::
amf_app
().
info
(
"Initiating all registered modules"
);
}
//------------------------------------------------------------------------------
void
amf_app_task
(
void
*
)
{
const
task_id_t
task_id
=
TASK_AMF_APP
;
...
...
@@ -111,7 +106,7 @@ void amf_app_task(void*) {
do
{
std
::
shared_ptr
<
itti_msg
>
shared_msg
=
itti_inst
->
receive_msg
(
task_id
);
auto
*
msg
=
shared_msg
.
get
();
timer_id_t
tid
;
timer_id_t
tid
=
{}
;
switch
(
msg
->
msg_type
)
{
case
NAS_SIG_ESTAB_REQ
:
{
Logger
::
amf_app
().
debug
(
"Received NAS_SIG_ESTAB_REQ"
);
...
...
@@ -206,30 +201,16 @@ long amf_app::generate_amf_ue_ngap_id() {
return
tmp
&
0xffffffffff
;
}
//------------------------------------------------------------------------------
bool
amf_app
::
is_amf_ue_id_2_ue_context
(
const
long
&
amf_ue_ngap_id
)
const
{
std
::
shared_lock
lock
(
m_amf_ue_ngap_id2ue_ctx
);
return
bool
{
amf_ue_ngap_id2ue_ctx
.
count
(
amf_ue_ngap_id
)
>
0
};
}
//------------------------------------------------------------------------------
std
::
shared_ptr
<
ue_context
>
amf_app
::
amf_ue_id_2_ue_context
(
const
long
&
amf_ue_ngap_id
)
const
{
std
::
shared_lock
lock
(
m_amf_ue_ngap_id2ue_ctx
);
return
amf_ue_ngap_id2ue_ctx
.
at
(
amf_ue_ngap_id
);
}
//------------------------------------------------------------------------------
void
amf_app
::
set_amf_ue_ngap_id_2_ue_context
(
const
long
&
amf_ue_ngap_id
,
const
std
::
shared_ptr
<
ue_context
>&
uc
)
{
std
::
unique_lock
lock
(
m_amf_ue_ngap_id2ue_ctx
);
amf_ue_ngap_id2ue_ctx
[
amf_ue_ngap_id
]
=
uc
;
}
//------------------------------------------------------------------------------
bool
amf_app
::
is_ran_amf_id_2_ue_context
(
const
string
&
ue_context_key
)
const
{
std
::
shared_lock
lock
(
m_ue_ctx_key
);
return
bool
{
ue_ctx_key
.
count
(
ue_context_key
)
>
0
};
// return bool{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
)
{
return
true
;
}
}
return
false
;
}
//------------------------------------------------------------------------------
...
...
@@ -247,8 +228,8 @@ bool amf_app::ran_amf_id_2_ue_context(
uc
=
ue_ctx_key
.
at
(
ue_context_key
);
if
(
uc
==
nullptr
)
return
false
;
return
true
;
}
else
return
false
;
}
return
false
;
}
//------------------------------------------------------------------------------
...
...
@@ -261,7 +242,13 @@ void amf_app::set_ran_amf_id_2_ue_context(
//------------------------------------------------------------------------------
bool
amf_app
::
is_supi_2_ue_context
(
const
string
&
supi
)
const
{
std
::
shared_lock
lock
(
m_supi2ue_ctx
);
return
bool
{
supi2ue_ctx
.
count
(
supi
)
>
0
};
// return bool{supi2ue_ctx.count(supi) > 0};
if
(
supi2ue_ctx
.
count
(
supi
)
>
0
)
{
if
(
supi2ue_ctx
.
at
(
supi
)
!=
nullptr
)
{
return
true
;
}
}
return
false
;
}
//------------------------------------------------------------------------------
...
...
@@ -271,6 +258,18 @@ std::shared_ptr<ue_context> amf_app::supi_2_ue_context(
return
supi2ue_ctx
.
at
(
supi
);
}
//------------------------------------------------------------------------------
bool
amf_app
::
supi_2_ue_context
(
const
std
::
string
&
supi
,
std
::
shared_ptr
<
ue_context
>&
uc
)
const
{
std
::
shared_lock
lock
(
m_supi2ue_ctx
);
if
(
supi2ue_ctx
.
count
(
supi
)
>
0
)
{
uc
=
supi2ue_ctx
.
at
(
supi
);
if
(
uc
==
nullptr
)
return
false
;
return
true
;
}
return
false
;
}
//------------------------------------------------------------------------------
void
amf_app
::
set_supi_2_ue_context
(
const
string
&
supi
,
const
std
::
shared_ptr
<
ue_context
>&
uc
)
{
...
...
@@ -282,9 +281,8 @@ void amf_app::set_supi_2_ue_context(
bool
amf_app
::
find_pdu_session_context
(
const
string
&
supi
,
const
std
::
uint8_t
pdu_session_id
,
std
::
shared_ptr
<
pdu_session_context
>&
psc
)
{
if
(
!
is_supi_2_ue_context
(
supi
))
return
false
;
std
::
shared_ptr
<
ue_context
>
uc
=
{};
uc
=
supi_2_ue_context
(
supi
)
;
if
(
!
supi_2_ue_context
(
supi
,
uc
))
return
false
;
if
(
!
uc
->
find_pdu_session_context
(
pdu_session_id
,
psc
))
return
false
;
return
true
;
}
...
...
@@ -293,20 +291,18 @@ bool amf_app::find_pdu_session_context(
bool
amf_app
::
get_pdu_sessions_context
(
const
string
&
supi
,
std
::
vector
<
std
::
shared_ptr
<
pdu_session_context
>>&
sessions_ctx
)
{
if
(
!
is_supi_2_ue_context
(
supi
))
return
false
;
std
::
shared_ptr
<
ue_context
>
uc
=
{};
uc
=
supi_2_ue_context
(
supi
)
;
if
(
!
supi_2_ue_context
(
supi
,
uc
))
return
false
;
if
(
!
uc
->
get_pdu_sessions_context
(
sessions_ctx
))
return
false
;
return
true
;
}
//------------------------------------------------------------------------------
bool
amf_app
::
update_pdu_sessions_context
(
const
string
&
ue_id
,
const
uint8_t
&
pdu_session_id
,
const
string
&
supi
,
const
uint8_t
&
pdu_session_id
,
const
oai
::
amf
::
model
::
SmContextStatusNotification
&
statusNotification
)
{
if
(
!
is_supi_2_ue_context
(
ue_id
))
return
false
;
std
::
shared_ptr
<
ue_context
>
uc
=
{};
uc
=
supi_2_ue_context
(
ue_id
)
;
if
(
!
supi_2_ue_context
(
supi
,
uc
))
return
false
;
// TODO: process SmContextStatusNotification
oai
::
amf
::
model
::
StatusInfo
statusInfo
=
statusNotification
.
getStatusInfo
();
oai
::
amf
::
model
::
ResourceStatus
resourceStatus
=
...
...
@@ -334,16 +330,16 @@ void amf_app::handle_itti_message(
if
(
itti_msg
.
is_ppi_set
)
{
// Paging procedure
Logger
::
amf_app
().
info
(
"Handle ITTI N1N2 Message Transfer Request for Paging"
);
std
::
shared_ptr
<
itti_paging
>
i
=
std
::
shared_ptr
<
itti_paging
>
paging_msg
=
std
::
make_shared
<
itti_paging
>
(
TASK_AMF_APP
,
TASK_AMF_N2
);
amf_n1_inst
->
supi_2_amf_id
(
itti_msg
.
supi
,
i
->
amf_ue_ngap_id
);
amf_n1_inst
->
supi_2_ran_id
(
itti_msg
.
supi
,
i
->
ran_ue_ngap_id
);
amf_n1_inst
->
supi_2_amf_id
(
itti_msg
.
supi
,
paging_msg
->
amf_ue_ngap_id
);
amf_n1_inst
->
supi_2_ran_id
(
itti_msg
.
supi
,
paging_msg
->
ran_ue_ngap_id
);
int
ret
=
itti_inst
->
send_msg
(
i
);
if
(
0
!=
ret
)
{
int
ret
=
itti_inst
->
send_msg
(
paging_msg
);
if
(
ret
!=
RETURNok
)
{
Logger
::
amf_app
().
error
(
"Could not send ITTI message %s to task TASK_AMF_N2"
,
i
->
get_msg_name
());
paging_msg
->
get_msg_name
());
}
}
else
{
Logger
::
amf_app
().
info
(
"Handle ITTI N1N2 Message Transfer Request"
);
...
...
@@ -375,7 +371,7 @@ void amf_app::handle_itti_message(
amf_n1_inst
->
supi_2_ran_id
(
itti_msg
.
supi
,
dl_msg
->
ran_ue_ngap_id
);
int
ret
=
itti_inst
->
send_msg
(
dl_msg
);
if
(
0
!=
ret
)
{
if
(
ret
!=
RETURNok
)
{
Logger
::
amf_app
().
error
(
"Could not send ITTI message %s to task TASK_AMF_N1"
,
dl_msg
->
get_msg_name
());
...
...
@@ -394,8 +390,8 @@ void amf_app::handle_itti_message(
amf_ue_ngap_id
=
generate_amf_ue_ngap_id
();
}
string
ue_context_key
=
"app_ue_ranid_"
+
to_string
(
itti_msg
.
ran_ue_ngap_id
)
+
":amfid_"
+
to_string
(
amf_ue_ngap_id
);
string
ue_context_key
=
conv
::
get_ue_context_key
(
itti_msg
.
ran_ue_ngap_id
,
amf_ue_ngap_id
);
if
(
!
is_ran_amf_id_2_ue_context
(
ue_context_key
))
{
Logger
::
amf_app
().
debug
(
"No existing UE Context, Create a new one with ran_amf_id %s"
,
...
...
@@ -406,13 +402,12 @@ void amf_app::handle_itti_message(
// Update AMF UE NGAP ID
std
::
shared_ptr
<
ue_ngap_context
>
unc
=
{};
if
(
!
amf_n2_inst
->
is_ran_ue_id_2_ue_ngap_context
(
itti_msg
.
ran_ue_ngap_id
))
{
if
(
!
amf_n2_inst
->
ran_ue_id_2_ue_ngap_context
(
itti_msg
.
ran_ue_ngap_id
,
unc
))
{
Logger
::
amf_n1
().
error
(
"Could not find UE NGAP Context with ran_ue_ngap_id "
"("
GNB_UE_NGAP_ID_FMT
")"
,
itti_msg
.
ran_ue_ngap_id
);
}
else
{
unc
=
amf_n2_inst
->
ran_ue_id_2_ue_ngap_context
(
itti_msg
.
ran_ue_ngap_id
);
unc
->
amf_ue_ngap_id
=
amf_ue_ngap_id
;
amf_n2_inst
->
set_amf_ue_ngap_id_2_ue_ngap_context
(
amf_ue_ngap_id
,
unc
);
}
...
...
@@ -568,8 +563,8 @@ void amf_app::handle_itti_message(itti_sbi_n1_message_notification& itti_msg) {
}
}
string
ue_context_key
=
"app_ue_ranid_"
+
to_string
(
ran_ue_ngap_id
)
+
":amfid_"
+
to_string
(
amf_ue_ngap_id
);
string
ue_context_key
=
conv
::
get_ue_context_key
(
ran_ue_ngap_id
,
amf_ue_ngap_id
);
if
(
!
is_ran_amf_id_2_ue_context
(
ue_context_key
))
{
Logger
::
amf_app
().
debug
(
"No existing UE Context associated with UE Context Key %s"
,
...
...
@@ -615,21 +610,12 @@ void amf_app::handle_itti_message(itti_sbi_n1_message_notification& itti_msg) {
// Step 4. Create UE NGAP Context if necessary
// Create/Update UE NGAP Context
std
::
shared_ptr
<
ue_ngap_context
>
unc
=
{};
if
(
!
amf_n2_inst
->
is_ran_ue_id_2_ue_ngap_context
(
ran_ue_ngap_id
))
{
if
(
!
amf_n2_inst
->
ran_ue_id_2_ue_ngap_context
(
ran_ue_ngap_id
,
unc
))
{
Logger
::
amf_app
().
debug
(
"Create a new UE NGAP context with ran_ue_ngap_id "
GNB_UE_NGAP_ID_FMT
,
ran_ue_ngap_id
);
unc
=
std
::
shared_ptr
<
ue_ngap_context
>
(
new
ue_ngap_context
());
amf_n2_inst
->
set_ran_ue_ngap_id_2_ue_ngap_context
(
ran_ue_ngap_id
,
unc
);
}
else
{
unc
=
amf_n2_inst
->
ran_ue_id_2_ue_ngap_context
(
ran_ue_ngap_id
);
if
(
!
unc
)
{
Logger
::
amf_app
().
error
(
"Failed to get UE NGAP context for "
"ran_ue_ngap_id "
GNB_UE_NGAP_ID_FMT
,
ran_ue_ngap_id
);
return
;
}
}
// Store related information into UE NGAP context
...
...
@@ -911,8 +897,7 @@ uint32_t amf_app::generate_tmsi() {
bool
amf_app
::
generate_5g_guti
(
const
uint32_t
ranid
,
const
long
amfid
,
string
&
mcc
,
string
&
mnc
,
uint32_t
&
tmsi
)
{
string
ue_context_key
=
"app_ue_ranid_"
+
to_string
(
ranid
)
+
":amfid_"
+
to_string
(
amfid
);
string
ue_context_key
=
conv
::
get_ue_context_key
(
ranid
,
amfid
);
if
(
!
is_ran_amf_id_2_ue_context
(
ue_context_key
))
{
Logger
::
amf_app
().
error
(
"No UE context for ran_amf_id %s, exit"
,
ue_context_key
.
c_str
());
...
...
src/amf-app/amf_app.hpp
View file @
f7222ed1
...
...
@@ -99,7 +99,6 @@ class amf_app {
explicit
amf_app
(
const
amf_config
&
amf_cfg
);
amf_app
(
amf_app
const
&
)
=
delete
;
void
operator
=
(
amf_app
const
&
)
=
delete
;
void
allRegistredModulesInit
(
const
amf_modules
&
modules
);
/*
* Generate AMF UE NGAP ID
...
...
@@ -193,33 +192,9 @@ class amf_app {
uint32_t
get_number_registered_ues
()
const
;
/*
* Verify if a UE context associated with an AMF UE NGAP ID exist
* @param [const long&] amf_ue_ngap_id: AMF UE NGAP ID
* @return true if UE context exist, otherwise false
*/
bool
is_amf_ue_id_2_ue_context
(
const
long
&
amf_ue_ngap_id
)
const
;
/*
* Get UE context associated with an AMF UE NGAP ID
* @param [const long&] amf_ue_ngap_id: AMF UE NGAP ID
* @return shared pointer to the context
*/
std
::
shared_ptr
<
ue_context
>
amf_ue_id_2_ue_context
(
const
long
&
amf_ue_ngap_id
)
const
;
/*
* Store an UE context associated with an AMF UE NGAP ID
* @param [const long&] amf_ue_ngap_id: AMF UE NGAP ID
* @param [std::shared_ptr<ue_context>&] uc: pointer to UE context
* @return void
*/
void
set_amf_ue_ngap_id_2_ue_context
(
const
long
&
amf_ue_ngap_id
,
const
std
::
shared_ptr
<
ue_context
>&
uc
);
/*
* Verify if a UE context associated with an UE Context Key exist
* Verify if a UE context associated with an UE Context Key exist and not null
* @param [const std::string&] ue_context_key: UE Context Key
* @return true if UE context exist, otherwise false
* @return true if UE context exist
and not null
, otherwise false
*/
bool
is_ran_amf_id_2_ue_context
(
const
std
::
string
&
ue_context_key
)
const
;
...
...
@@ -251,9 +226,9 @@ class amf_app {
const
std
::
string
&
ue_context_key
,
const
std
::
shared_ptr
<
ue_context
>&
uc
);
/*
* Verify whether a UE context associated with a SUPI exist
* Verify whether a UE context associated with a SUPI exist
and not null
* @param [const std::string&] supi: UE SUPI
* @return true if UE context exist, otherwise false
* @return true if UE context exist
and not null
, otherwise false
*/
bool
is_supi_2_ue_context
(
const
string
&
supi
)
const
;
...
...
@@ -264,6 +239,15 @@ class amf_app {
*/
std
::
shared_ptr
<
ue_context
>
supi_2_ue_context
(
const
string
&
supi
)
const
;
/*
* Get UE context associated with a SUPI
* @param [const std::string&] supi: SUPI
* @param [std::shared_ptr<ue_context>&] uc: pointer to UE context if exist
* @return true if UE Context exist and not null
*/
bool
supi_2_ue_context
(
const
std
::
string
&
supi
,
std
::
shared_ptr
<
ue_context
>&
uc
)
const
;
/*
* Store an UE context associated with a SUPI
* @param [const std::string&] supi: UE SUPI
...
...
@@ -298,14 +282,14 @@ class amf_app {
/*
* Update PDU Session Context status
* @param [const std::string&]
ue_id
: UE SUPI
* @param [const std::string&]
supi
: UE SUPI
* @param [const uint8_t&] pdu_session_id: PDU Session ID
* @param [const oai::amf::model::SmContextStatusNotification&]
* statusNotification: Notification information received from SMF
* @return true if success, otherwise false
*/
bool
update_pdu_sessions_context
(
const
string
&
ue_id
,
const
uint8_t
&
pdu_session_id
,
const
string
&
supi
,
const
uint8_t
&
pdu_session_id
,
const
oai
::
amf
::
model
::
SmContextStatusNotification
&
statusNotification
);
/*
...
...
src/amf-app/amf_n1.cpp
View file @
f7222ed1
...
...
@@ -364,17 +364,19 @@ void amf_n1::handle_itti_message(itti_uplink_nas_data_ind& nas_data_ind) {
long
amf_ue_ngap_id
=
nas_data_ind
.
amf_ue_ngap_id
;
uint32_t
ran_ue_ngap_id
=
nas_data_ind
.
ran_ue_ngap_id
;
std
::
string
nas_context_key
=
"app_ue_ranid_"
+
to_string
(
ran_ue_ngap_id
)
+
":amfid_"
+
to_string
(
amf_ue_ngap_id
);
// key for nas_context, option 1
std
::
string
nas_context_key
=
conv
::
get_ue_context_key
(
ran_ue_ngap_id
,
amf_ue_ngap_id
);
// key for nas_context, option 1
std
::
string
snn
=
{};
std
::
string
snn
=
conv
::
get_serving_network_name
(
nas_data_ind
.
mnc
,
nas_data_ind
.
mcc
);
/*
if (nas_data_ind.mnc.length() == 2) // TODO: remove hardcoded value
snn = "5G:mnc0" + nas_data_ind.mnc + ".mcc" + nas_data_ind.mcc +
".3gppnetwork.org";
else
snn = "5G:mnc" + nas_data_ind.mnc + ".mcc" + nas_data_ind.mcc +
".3gppnetwork.org";
*/
Logger
::
amf_n1
().
debug
(
"Serving network name %s"
,
snn
.
c_str
());
plmn_t
plmn
=
{};
...
...
@@ -730,8 +732,8 @@ void amf_n1::identity_response_handle(
supi
=
imsi
.
mcc
+
imsi
.
mnc
+
imsi
.
msin
;
Logger
::
amf_n1
().
debug
(
"Identity Response: SUCI (%s)"
,
supi
.
c_str
());
string
ue_context_key
=
"app_ue_ranid_"
+
to_string
(
ran_ue_ngap_id
)
+
":amfid_"
+
to_string
(
amf_ue_ngap_id
);
string
ue_context_key
=
conv
::
get_ue_context_key
(
ran_ue_ngap_id
,
amf_ue_ngap_id
);
if
(
amf_app_inst
->
is_ran_amf_id_2_ue_context
(
ue_context_key
))
{
std
::
shared_ptr
<
ue_context
>
uc
=
{};
...
...
@@ -1259,7 +1261,7 @@ void amf_n1::registration_request_handle(
if
(
uc
)
uc
.
reset
();
std
::
shared_ptr
<
ue_ngap_context
>
unc
=
{};
if
(
!
amf_n2_inst
->
is_
ran_ue_id_2_ue_ngap_context
(
ran_ue_ngap_id
,
unc
))
{
if
(
!
amf_n2_inst
->
ran_ue_id_2_ue_ngap_context
(
ran_ue_ngap_id
,
unc
))
{
Logger
::
amf_n1
().
error
(
"No UE NGAP context with ran_ue_ngap_id ("
GNB_UE_NGAP_ID_FMT
")"
,
ran_ue_ngap_id
);
...
...
@@ -2605,7 +2607,7 @@ void amf_n1::security_mode_complete_handle(
// Find UE context
std
::
shared_ptr
<
ue_ngap_context
>
unc
=
{};
if
(
!
amf_n2_inst
->
is_
ran_ue_id_2_ue_ngap_context
(
ran_ue_ngap_id
,
unc
))
{
if
(
!
amf_n2_inst
->
ran_ue_id_2_ue_ngap_context
(
ran_ue_ngap_id
,
unc
))
{
Logger
::
amf_n1
().
warn
(
"No UE NGAP context with ran_ue_ngap_id ("
GNB_UE_NGAP_ID_FMT
")"
,
ran_ue_ngap_id
);
...
...
@@ -4223,8 +4225,8 @@ bool amf_n1::find_ue_context(
string
supi
=
"imsi-"
+
nc
->
imsi
;
Logger
::
amf_n1
().
debug
(
"Key for PDU Session Context SUPI (%s)"
,
supi
.
c_str
());
string
ue_context_key
=
"app_ue_ranid_"
+
to_string
(
nc
->
ran_ue_ngap_id
)
+
":amfid_"
+
to_string
(
nc
->
amf_ue_ngap_id
);
string
ue_context_key
=
conv
::
get_ue_context_key
(
nc
->
ran_ue_ngap_id
,
nc
->
amf_ue_ngap_id
);
if
(
!
amf_app_inst
->
is_ran_amf_id_2_ue_context
(
ue_context_key
))
{
Logger
::
amf_n1
().
error
(
"No UE context with key %s"
,
ue_context_key
.
c_str
());
...
...
@@ -4246,8 +4248,8 @@ bool amf_n1::find_ue_context(
bool
amf_n1
::
find_ue_context
(
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
,
std
::
shared_ptr
<
ue_context
>&
uc
)
{
string
ue_context_key
=
"app_ue_ranid_"
+
to_string
(
ran_ue_ngap_id
)
+
":amfid_"
+
to_string
(
amf_ue_ngap_id
);
string
ue_context_key
=
conv
::
get_ue_context_key
(
ran_ue_ngap_id
,
amf_ue_ngap_id
);
if
(
!
amf_app_inst
->
is_ran_amf_id_2_ue_context
(
ue_context_key
))
{
Logger
::
amf_n1
().
error
(
"No UE context with key %s"
,
ue_context_key
.
c_str
());
...
...
@@ -4772,16 +4774,23 @@ bool amf_n1::get_slice_selection_subscription_data_from_conf_file(
// For now, use the common NSSAIs, supported by AMF and gNB, as subscribed
// NSSAIs
// Get UE context
std
::
shared_ptr
<
ue_context
>
uc
=
{};
if
(
!
find_ue_context
(
nc
->
ran_ue_ngap_id
,
nc
->
amf_ue_ngap_id
,
uc
))
{
Logger
::
amf_n1
().
warn
(
"Cannot find the UE context"
);
return
false
;
}
// Get UE NGAP Context
std
::
shared_ptr
<
ue_ngap_context
>
unc
=
{};
if
(
!
amf_n2_inst
->
ran_ue_id_2_ue_ngap_context
(
nc
->
ran_ue_ngap_id
,
unc
))
{
Logger
::
amf_n1
().
error
(
"No existed UE NGAP context associated with "
"ran_ue_ngap_id "
GNB_UE_NGAP_ID_FMT
,
nc
->
ran_ue_ngap_id
);
return
false
;
}
// Get gNB Context
std
::
shared_ptr
<
ue_ngap_context
>
unc
=
amf_n2_inst
->
ran_ue_id_2_ue_ngap_context
(
nc
->
ran_ue_ngap_id
);
std
::
shared_ptr
<
gnb_context
>
gc
=
{};
if
(
!
amf_n2_inst
->
is_assoc_id_2_gnb_context
(
unc
->
gnb_assoc_id
,
gc
))
{
Logger
::
amf_n1
().
error
(
...
...
src/amf-app/amf_n2.cpp
View file @
f7222ed1
...
...
@@ -249,7 +249,7 @@ void amf_n2::handle_itti_message(itti_paging& itti_msg) {
std
::
shared_ptr
<
ue_ngap_context
>
unc
=
{};
if
(
!
is_
ran_ue_id_2_ue_ngap_context
(
itti_msg
.
ran_ue_ngap_id
,
unc
))
{
if
(
!
ran_ue_id_2_ue_ngap_context
(
itti_msg
.
ran_ue_ngap_id
,
unc
))
{
Logger
::
amf_n2
().
error
(
"No UE NGAP context with ran_ue_ngap_id ("
GNB_UE_NGAP_ID_FMT
")"
,
itti_msg
.
ran_ue_ngap_id
);
...
...
@@ -602,7 +602,7 @@ void amf_n2::handle_itti_message(itti_initial_ue_message& init_ue_msg) {
}
std
::
shared_ptr
<
ue_ngap_context
>
unc
=
{};
if
(
!
is_
ran_ue_id_2_ue_ngap_context
(
ran_ue_ngap_id
,
unc
))
{
if
(
!
ran_ue_id_2_ue_ngap_context
(
ran_ue_ngap_id
,
unc
))
{
Logger
::
amf_n2
().
debug
(
"Create a new UE NGAP context with ran_ue_ngap_id "
GNB_UE_NGAP_ID_FMT
,
ran_ue_ngap_id
);
...
...
@@ -711,7 +711,7 @@ void amf_n2::handle_itti_message(itti_ul_nas_transport& ul_nas_transport) {
}
std
::
shared_ptr
<
ue_ngap_context
>
unc
=
{};
if
(
!
is_
ran_ue_id_2_ue_ngap_context
(
ran_ue_ngap_id
,
unc
))
{
if
(
!
ran_ue_id_2_ue_ngap_context
(
ran_ue_ngap_id
,
unc
))
{
Logger
::
amf_n2
().
error
(
"UE with ran_ue_ngap_id ("
GNB_UE_NGAP_ID_FMT
") is not attached to gnb with assoc_id "
...
...
@@ -774,7 +774,7 @@ void amf_n2::handle_itti_message(itti_dl_nas_transport& dl_nas_transport) {
std
::
shared_ptr
<
ue_ngap_context
>
unc
=
{};
if
(
!
amf_n2_inst
->
is_
ran_ue_id_2_ue_ngap_context
(
if
(
!
amf_n2_inst
->
ran_ue_id_2_ue_ngap_context
(
dl_nas_transport
.
ran_ue_ngap_id
,
unc
))
{
Logger
::
amf_n2
().
error
(
"No UE NGAP context with ran_ue_ngap_id ("
GNB_UE_NGAP_ID_FMT
")"
,
...
...
@@ -810,8 +810,7 @@ void amf_n2::handle_itti_message(itti_initial_context_setup_request& itti_msg) {
Logger
::
amf_n2
().
debug
(
"Handle Initial Context Setup Request ..."
);
std
::
shared_ptr
<
ue_ngap_context
>
unc
=
{};
if
(
!
amf_n2_inst
->
is_ran_ue_id_2_ue_ngap_context
(
itti_msg
.
ran_ue_ngap_id
,
unc
))
{
if
(
!
amf_n2_inst
->
ran_ue_id_2_ue_ngap_context
(
itti_msg
.
ran_ue_ngap_id
,
unc
))
{
Logger
::
amf_n2
().
error
(
"No UE NGAP context with ran_ue_ngap_id ("
GNB_UE_NGAP_ID_FMT
")"
,
itti_msg
.
ran_ue_ngap_id
);
...
...
@@ -948,8 +947,7 @@ void amf_n2::handle_itti_message(
Logger
::
amf_n2
().
debug
(
"Handle PDU Session Resource Setup Request ..."
);
std
::
shared_ptr
<
ue_ngap_context
>
unc
=
{};
if
(
!
amf_n2_inst
->
is_ran_ue_id_2_ue_ngap_context
(
itti_msg
.
ran_ue_ngap_id
,
unc
))
{
if
(
!
amf_n2_inst
->
ran_ue_id_2_ue_ngap_context
(
itti_msg
.
ran_ue_ngap_id
,
unc
))
{
Logger
::
amf_n2
().
error
(
"No UE NGAP context with ran_ue_ngap_id ("
GNB_UE_NGAP_ID_FMT
")"
,
itti_msg
.
ran_ue_ngap_id
);
...
...
@@ -1030,8 +1028,7 @@ void amf_n2::handle_itti_message(
Logger
::
amf_n2
().
debug
(
"Handle PDU Session Resource Modify Request ..."
);
std
::
shared_ptr
<
ue_ngap_context
>
unc
=
{};
if
(
!
amf_n2_inst
->
is_ran_ue_id_2_ue_ngap_context
(
itti_msg
.
ran_ue_ngap_id
,
unc
))
{
if
(
!
amf_n2_inst
->
ran_ue_id_2_ue_ngap_context
(
itti_msg
.
ran_ue_ngap_id
,
unc
))
{
Logger
::
amf_n2
().
error
(
"No UE NGAP context with ran_ue_ngap_id ("
GNB_UE_NGAP_ID_FMT
")"
,
itti_msg
.
ran_ue_ngap_id
);
...
...
@@ -1088,8 +1085,7 @@ void amf_n2::handle_itti_message(
Logger
::
amf_n2
().
debug
(
"Handle PDU Session Resource Release Command ..."
);
std
::
shared_ptr
<
ue_ngap_context
>
unc
=
{};
if
(
!
amf_n2_inst
->
is_ran_ue_id_2_ue_ngap_context
(
itti_msg
.
ran_ue_ngap_id
,
unc
))
{
if
(
!
amf_n2_inst
->
ran_ue_id_2_ue_ngap_context
(
itti_msg
.
ran_ue_ngap_id
,
unc
))
{
Logger
::
amf_n2
().
error
(
"No UE NGAP context with ran_ue_ngap_id ("
GNB_UE_NGAP_ID_FMT
")"
,
itti_msg
.
ran_ue_ngap_id
);
...
...
@@ -1161,8 +1157,7 @@ void amf_n2::handle_itti_message(itti_ue_context_release_command& itti_msg) {
Logger
::
amf_n2
().
debug
(
"Handling UE Context Release Command ..."
);
std
::
shared_ptr
<
ue_ngap_context
>
unc
=
{};
if
(
!
amf_n2_inst
->
is_ran_ue_id_2_ue_ngap_context
(
itti_msg
.
ran_ue_ngap_id
,
unc
))
{
if
(
!
amf_n2_inst
->
ran_ue_id_2_ue_ngap_context
(
itti_msg
.
ran_ue_ngap_id
,
unc
))
{
Logger
::
amf_n2
().
error
(
"No UE NGAP context with ran_ue_ngap_id ("
GNB_UE_NGAP_ID_FMT
")"
,
itti_msg
.
ran_ue_ngap_id
);
...
...
@@ -1432,7 +1427,7 @@ bool amf_n2::handle_itti_message(itti_handover_required& itti_msg) {
gc
->
gnb_name
.
c_str
(),
gc
->
globalRanNodeId
);
std
::
shared_ptr
<
ue_ngap_context
>
unc
=
{};
if
(
!
is_
ran_ue_id_2_ue_ngap_context
(
ran_ue_ngap_id
,
unc
))
{
if
(
!
ran_ue_id_2_ue_ngap_context
(
ran_ue_ngap_id
,
unc
))
{
Logger
::
amf_n2
().
error
(
"No UE NGAP context with ran_ue_ngap_id ("
GNB_UE_NGAP_ID_FMT
")"
,
ran_ue_ngap_id
);
...
...
@@ -2070,7 +2065,7 @@ void amf_n2::handle_itti_message(itti_rereoute_nas& itti_msg) {
std
::
shared_ptr
<
ue_ngap_context
>
unc
=
{};
if
(
!
is_
ran_ue_id_2_ue_ngap_context
(
itti_msg
.
ran_ue_ngap_id
,
unc
))
{
if
(
!
ran_ue_id_2_ue_ngap_context
(
itti_msg
.
ran_ue_ngap_id
,
unc
))
{
Logger
::
amf_n2
().
error
(
"No UE NGAP context with ran_ue_ngap_id "
GNB_UE_NGAP_ID_FMT
,
itti_msg
.
ran_ue_ngap_id
);
...
...
@@ -2138,7 +2133,7 @@ bool amf_n2::is_ran_ue_id_2_ue_ngap_context(
}
//------------------------------------------------------------------------------
bool
amf_n2
::
is_
ran_ue_id_2_ue_ngap_context
(
bool
amf_n2
::
ran_ue_id_2_ue_ngap_context
(
const
uint32_t
&
ran_ue_ngap_id
,
std
::
shared_ptr
<
ue_ngap_context
>&
unc
)
const
{
std
::
shared_lock
lock
(
m_ranid2uecontext
);
...
...
@@ -2150,14 +2145,14 @@ bool amf_n2::is_ran_ue_id_2_ue_ngap_context(
}
return
false
;
}
/*
//------------------------------------------------------------------------------
std::shared_ptr<ue_ngap_context> amf_n2::ran_ue_id_2_ue_ngap_context(
const uint32_t& ran_ue_ngap_id) const {
std::shared_lock lock(m_ranid2uecontext);
return ranid2uecontext.at(ran_ue_ngap_id);
}
*/
//------------------------------------------------------------------------------
void
amf_n2
::
set_ran_ue_ngap_id_2_ue_ngap_context
(
const
uint32_t
&
ran_ue_ngap_id
,
...
...
@@ -2181,7 +2176,7 @@ void amf_n2::remove_ue_context_with_ran_ue_ngap_id(
// Remove NAS context if still available
std
::
shared_ptr
<
ue_ngap_context
>
unc
=
{};
if
(
!
is_
ran_ue_id_2_ue_ngap_context
(
ran_ue_ngap_id
,
unc
))
{
if
(
!
ran_ue_id_2_ue_ngap_context
(
ran_ue_ngap_id
,
unc
))
{
Logger
::
amf_n2
().
error
(
"No UE NGAP context with ran_ue_ngap_id ("
GNB_UE_NGAP_ID_FMT
")"
,
ran_ue_ngap_id
);
...
...
@@ -2379,7 +2374,7 @@ bool amf_n2::get_common_NSSAI(
// Get UE NGAP Context
std
::
shared_ptr
<
ue_ngap_context
>
unc
=
{};
if
(
!
is_
ran_ue_id_2_ue_ngap_context
(
ran_ue_ngap_id
,
unc
))
{
if
(
!
ran_ue_id_2_ue_ngap_context
(
ran_ue_ngap_id
,
unc
))
{
Logger
::
amf_n2
().
error
(
"No UE NGAP context with ran_ue_ngap_id ("
GNB_UE_NGAP_ID_FMT
")"
,
ran_ue_ngap_id
);
...
...
src/amf-app/amf_n2.hpp
View file @
f7222ed1
...
...
@@ -229,26 +229,26 @@ class amf_n2 : public ngap::ngap_app {
* @param [const uint32_t&] ran_ue_ngap_id: RAN UE NGAP ID
* @return shared pointer to the UE NGAP context
*/
std
::
shared_ptr
<
ue_ngap_context
>
ran_ue_id_2_ue_ngap_context
(
const
uint32_t
&
ran_ue_ngap_id
)
const
;
//
std::shared_ptr<ue_ngap_context> ran_ue_id_2_ue_ngap_context(
//
const uint32_t& ran_ue_ngap_id) const;
/*
* Verify whether a UE NGAP context associated with a RAN UE NGAP ID exist
* @param [const uint32_t&] ran_ue_ngap_id: RAN UE NGAP ID
* @param [std::shared_ptr<ue_ngap_context>&] unc: shared pointer to the
* existing UE NGAP context
* @return true if exist, otherwise return false
*/
bool
is_ran_ue_id_2_ue_ngap_context
(
const
uint32_t
&
ran_ue_ngap_id
)
const
;
bool
ran_ue_id_2_ue_ngap_context
(
const
uint32_t
&
ran_ue_ngap_id
,
std
::
shared_ptr
<
ue_ngap_context
>&
unc
)
const
;
/*
* Verify whether a UE NGAP context associated with a RAN UE NGAP ID exist
* @param [const uint32_t&] ran_ue_ngap_id: RAN UE NGAP ID
* @param [std::shared_ptr<ue_ngap_context>&] unc: shared pointer to the UE
* NGAP context
* @return true if exist, otherwise return false
*/
bool
is_ran_ue_id_2_ue_ngap_context
(
const
uint32_t
&
ran_ue_ngap_id
,
std
::
shared_ptr
<
ue_ngap_context
>&
unc
)
const
;
bool
is_ran_ue_id_2_ue_ngap_context
(
const
uint32_t
&
ran_ue_ngap_id
)
const
;
/*
* Store UE NGAP context associated with a RAN UE NGAP ID
...
...
src/amf-app/amf_sbi.cpp
View file @
f7222ed1
...
...
@@ -199,8 +199,8 @@ void amf_sbi::handle_itti_message(
//------------------------------------------------------------------------------
void
amf_sbi
::
handle_itti_message
(
itti_nsmf_pdusession_update_sm_context
&
itti_msg
)
{
string
ue_context_key
=
"app_ue_ranid_"
+
to_string
(
itti_msg
.
ran_ue_ngap_id
)
+
":amfid_"
+
to_string
(
itti_msg
.
amf_ue_ngap_id
);
string
ue_context_key
=
conv
::
get_ue_context_key
(
itti_msg
.
ran_ue_ngap_id
,
itti_msg
.
amf_ue_ngap_id
);
std
::
shared_ptr
<
ue_context
>
uc
=
{};
if
(
!
amf_app_inst
->
is_ran_amf_id_2_ue_context
(
ue_context_key
))
{
Logger
::
amf_sbi
().
error
(
...
...
@@ -294,9 +294,9 @@ void amf_sbi::handle_itti_message(itti_nsmf_pdusession_create_sm_context& smf) {
return
;
}
std
::
string
supi
=
"imsi-"
+
nc
->
imsi
;
string
ue_context_key
=
"app_ue_ranid_"
+
to_string
(
nc
->
ran_ue_ngap_id
)
+
":amfid_"
+
to_string
(
nc
->
amf_ue_ngap_id
);
std
::
string
supi
=
"imsi-"
+
nc
->
imsi
;
string
ue_context_key
=
conv
::
get_ue_context_key
(
nc
->
ran_ue_ngap_id
,
nc
->
amf_ue_ngap_id
);
std
::
shared_ptr
<
ue_context
>
uc
=
{};
Logger
::
amf_sbi
().
info
(
"Find ue_context in amf_app using UE Context Key: %s"
,
...
...
src/common/conversions.cpp
View file @
f7222ed1
...
...
@@ -469,3 +469,22 @@ bool conv::check_octet_string(const OCTET_STRING_t& octet_str) {
if
(
!
octet_str
.
buf
or
(
octet_str
.
size
==
0
))
return
false
;
return
true
;
}
//------------------------------------------------------------------------------
std
::
string
conv
::
get_ue_context_key
(
const
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
)
{
return
(
"app_ue_ranid_"
+
std
::
to_string
(
ran_ue_ngap_id
)
+
":amfid_"
+
std
::
to_string
(
amf_ue_ngap_id
));
}
//------------------------------------------------------------------------------
std
::
string
conv
::
get_serving_network_name
(
const
std
::
string
&
mnc
,
const
std
::
string
&
mcc
)
{
std
::
string
snn
=
{};
if
(
mnc
.
length
()
==
2
)
// TODO: remove hardcoded value
snn
=
"5G:mnc0"
+
mnc
+
".mcc"
+
mcc
+
".3gppnetwork.org"
;
else
snn
=
"5G:mnc"
+
mnc
+
".mcc"
+
mcc
+
".3gppnetwork.org"
;
return
snn
;
}
src/common/conversions.hpp
View file @
f7222ed1
...
...
@@ -91,5 +91,10 @@ class conv {
static
bool
check_bstring
(
const
bstring
&
b_str
);
static
bool
check_octet_string
(
const
OCTET_STRING_t
&
octet_str
);
static
std
::
string
get_ue_context_key
(
const
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
);
static
std
::
string
get_serving_network_name
(
const
std
::
string
&
mnc
,
const
std
::
string
&
mcc
);
};
#endif
/* FILE_CONVERSIONS_HPP_SEEN */
src/oai-amf/main.cpp
View file @
f7222ed1
...
...
@@ -115,7 +115,6 @@ int main(int argc, char** argv) {
itti_inst
->
start
(
amf_cfg
.
itti
.
itti_timer_sched_params
);
amf_app_inst
=
new
amf_app
(
amf_cfg
);
amf_app_inst
->
allRegistredModulesInit
(
modules
);
Logger
::
amf_app
().
debug
(
"Initiating AMF server endpoints"
);
// AMF HTTP1 server
...
...
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