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
e1765115
Commit
e1765115
authored
Apr 04, 2022
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'fix_deregistration' into 'develop'
Fix deregistration See merge request oai/cn5g/oai-cn5g-amf!101
parents
596cead1
1479b781
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
425 additions
and
269 deletions
+425
-269
src/amf-app/amf_app.cpp
src/amf-app/amf_app.cpp
+17
-0
src/amf-app/amf_app.hpp
src/amf-app/amf_app.hpp
+4
-0
src/amf-app/amf_n1.cpp
src/amf-app/amf_n1.cpp
+310
-215
src/amf-app/amf_n1.hpp
src/amf-app/amf_n1.hpp
+1
-0
src/amf-app/amf_n11.cpp
src/amf-app/amf_n11.cpp
+33
-14
src/amf-app/amf_n2.cpp
src/amf-app/amf_n2.cpp
+26
-10
src/itti/itti_msg.hpp
src/itti/itti_msg.hpp
+3
-3
src/itti/msgs/itti_msg_n11.hpp
src/itti/msgs/itti_msg_n11.hpp
+6
-2
src/nas/ies/_5GSDeregistrationType.cpp
src/nas/ies/_5GSDeregistrationType.cpp
+14
-14
src/nas/ies/_5GSDeregistrationType.hpp
src/nas/ies/_5GSDeregistrationType.hpp
+2
-2
src/nas/msgs/DeregistrationRequest.cpp
src/nas/msgs/DeregistrationRequest.cpp
+9
-9
No files found.
src/amf-app/amf_app.cpp
View file @
e1765115
...
@@ -872,6 +872,11 @@ void amf_app::trigger_nf_deregistration() {
...
@@ -872,6 +872,11 @@ void amf_app::trigger_nf_deregistration() {
}
}
}
}
void
amf_app
::
add_promise
(
uint32_t
pid
,
boost
::
shared_ptr
<
boost
::
promise
<
uint32_t
>>&
p
)
{
std
::
unique_lock
lock
(
m_curl_handle_responses_smf
);
curl_handle_responses_smf
.
emplace
(
pid
,
p
);
}
//---------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
void
amf_app
::
add_promise
(
void
amf_app
::
add_promise
(
uint32_t
id
,
boost
::
shared_ptr
<
boost
::
promise
<
std
::
string
>>&
p
)
{
uint32_t
id
,
boost
::
shared_ptr
<
boost
::
promise
<
std
::
string
>>&
p
)
{
...
@@ -886,6 +891,18 @@ void amf_app::add_promise(
...
@@ -886,6 +891,18 @@ void amf_app::add_promise(
curl_handle_responses_n11
.
emplace
(
pid
,
p
);
curl_handle_responses_n11
.
emplace
(
pid
,
p
);
}
}
void
amf_app
::
trigger_process_response
(
uint32_t
pid
,
uint32_t
http_code
)
{
Logger
::
amf_app
().
debug
(
"Trigger process response: Set promise with ID %u "
"to ready"
,
pid
);
std
::
unique_lock
lock
(
m_curl_handle_responses_smf
);
if
(
curl_handle_responses_smf
.
count
(
pid
)
>
0
)
{
curl_handle_responses_smf
[
pid
]
->
set_value
(
http_code
);
// Remove this promise from list
curl_handle_responses_smf
.
erase
(
pid
);
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void
amf_app
::
trigger_process_response
(
uint32_t
pid
,
std
::
string
n2_sm
)
{
void
amf_app
::
trigger_process_response
(
uint32_t
pid
,
std
::
string
n2_sm
)
{
Logger
::
amf_app
().
debug
(
Logger
::
amf_app
().
debug
(
...
...
src/amf-app/amf_app.hpp
View file @
e1765115
...
@@ -83,6 +83,10 @@ class amf_app {
...
@@ -83,6 +83,10 @@ class amf_app {
std
::
map
<
std
::
string
,
std
::
shared_ptr
<
ue_context
>>
supi2ue_ctx
;
std
::
map
<
std
::
string
,
std
::
shared_ptr
<
ue_context
>>
supi2ue_ctx
;
mutable
std
::
shared_mutex
m_supi2ue_ctx
;
mutable
std
::
shared_mutex
m_supi2ue_ctx
;
mutable
std
::
shared_mutex
m_curl_handle_responses_smf
;
std
::
map
<
uint32_t
,
boost
::
shared_ptr
<
boost
::
promise
<
uint32_t
>>>
curl_handle_responses_smf
;
mutable
std
::
shared_mutex
m_curl_handle_responses_n2_sm
;
mutable
std
::
shared_mutex
m_curl_handle_responses_n2_sm
;
std
::
map
<
uint32_t
,
boost
::
shared_ptr
<
boost
::
promise
<
std
::
string
>>>
std
::
map
<
uint32_t
,
boost
::
shared_ptr
<
boost
::
promise
<
std
::
string
>>>
curl_handle_responses_n2_sm
;
curl_handle_responses_n2_sm
;
...
...
src/amf-app/amf_n1.cpp
View file @
e1765115
...
@@ -213,22 +213,21 @@ void amf_n1::handle_itti_message(itti_downlink_nas_transfer& itti_msg) {
...
@@ -213,22 +213,21 @@ void amf_n1::handle_itti_message(itti_downlink_nas_transfer& itti_msg) {
if
(
itti_msg
.
is_n2sm_set
)
{
if
(
itti_msg
.
is_n2sm_set
)
{
// PDU Session Resource Release Command
// PDU Session Resource Release Command
if
(
itti_msg
.
n2sm_info_type
.
compare
(
"PDU_RES_REL_CMD"
)
==
0
)
{
if
(
itti_msg
.
n2sm_info_type
.
compare
(
"PDU_RES_REL_CMD"
)
==
0
)
{
itti_pdu_session_resource_release_command
*
release_command
=
std
::
shared_ptr
<
itti_pdu_session_resource_release_command
>
new
itti_pdu_session_resource_release_command
(
release_command
=
std
::
make_shared
<
itti_pdu_session_resource_release_command
>
(
TASK_AMF_N1
,
TASK_AMF_N2
);
TASK_AMF_N1
,
TASK_AMF_N2
);
release_command
->
nas
=
protected_nas
;
release_command
->
nas
=
protected_nas
;
release_command
->
n2sm
=
itti_msg
.
n2sm
;
release_command
->
n2sm
=
itti_msg
.
n2sm
;
release_command
->
amf_ue_ngap_id
=
amf_ue_ngap_id
;
release_command
->
amf_ue_ngap_id
=
amf_ue_ngap_id
;
release_command
->
ran_ue_ngap_id
=
ran_ue_ngap_id
;
release_command
->
ran_ue_ngap_id
=
ran_ue_ngap_id
;
release_command
->
pdu_session_id
=
itti_msg
.
pdu_session_id
;
release_command
->
pdu_session_id
=
itti_msg
.
pdu_session_id
;
std
::
shared_ptr
<
itti_pdu_session_resource_release_command
>
i
=
std
::
shared_ptr
<
itti_pdu_session_resource_release_command
>
(
int
ret
=
itti_inst
->
send_msg
(
release_command
);
release_command
);
int
ret
=
itti_inst
->
send_msg
(
i
);
if
(
0
!=
ret
)
{
if
(
0
!=
ret
)
{
Logger
::
amf_n1
().
error
(
Logger
::
amf_n1
().
error
(
"Could not send ITTI message %s to task TASK_AMF_N2"
,
"Could not send ITTI message %s to task TASK_AMF_N2"
,
i
->
get_msg_name
());
release_command
->
get_msg_name
());
}
}
// PDU Session Resource Modify Request
// PDU Session Resource Modify Request
}
else
if
(
itti_msg
.
n2sm_info_type
.
compare
(
"PDU_RES_MOD_REQ"
)
==
0
)
{
}
else
if
(
itti_msg
.
n2sm_info_type
.
compare
(
"PDU_RES_MOD_REQ"
)
==
0
)
{
...
@@ -281,21 +280,20 @@ void amf_n1::handle_itti_message(itti_downlink_nas_transfer& itti_msg) {
...
@@ -281,21 +280,20 @@ void amf_n1::handle_itti_message(itti_downlink_nas_transfer& itti_msg) {
if
(
uc
.
get
()
->
isUeContextRequest
)
{
if
(
uc
.
get
()
->
isUeContextRequest
)
{
// PDU SESSION RESOURCE SETUP_REQUEST
// PDU SESSION RESOURCE SETUP_REQUEST
itti_pdu_session_resource_setup_request
*
psrsr
=
std
::
shared_ptr
<
itti_pdu_session_resource_setup_request
>
psrsr
=
new
itti_pdu_session_resource_setup_request
(
std
::
make_shared
<
itti_pdu_session_resource_setup_request
>
(
TASK_AMF_N1
,
TASK_AMF_N2
);
TASK_AMF_N1
,
TASK_AMF_N2
);
psrsr
->
nas
=
protected_nas
;
psrsr
->
nas
=
protected_nas
;
psrsr
->
n2sm
=
itti_msg
.
n2sm
;
psrsr
->
n2sm
=
itti_msg
.
n2sm
;
psrsr
->
amf_ue_ngap_id
=
amf_ue_ngap_id
;
psrsr
->
amf_ue_ngap_id
=
amf_ue_ngap_id
;
psrsr
->
ran_ue_ngap_id
=
ran_ue_ngap_id
;
psrsr
->
ran_ue_ngap_id
=
ran_ue_ngap_id
;
psrsr
->
pdu_session_id
=
itti_msg
.
pdu_session_id
;
psrsr
->
pdu_session_id
=
itti_msg
.
pdu_session_id
;
std
::
shared_ptr
<
itti_pdu_session_resource_setup_request
>
i
=
std
::
shared_ptr
<
itti_pdu_session_resource_setup_request
>
(
psrsr
);
int
ret
=
itti_inst
->
send_msg
(
psrsr
);
int
ret
=
itti_inst
->
send_msg
(
i
);
if
(
0
!=
ret
)
{
if
(
0
!=
ret
)
{
Logger
::
amf_n1
().
error
(
Logger
::
amf_n1
().
error
(
"Could not send ITTI message %s to task TASK_AMF_N2"
,
"Could not send ITTI message %s to task TASK_AMF_N2"
,
i
->
get_msg_name
());
psrsr
->
get_msg_name
());
}
}
}
else
{
}
else
{
// send using InitialContextSetupRequest
// send using InitialContextSetupRequest
...
@@ -307,8 +305,9 @@ void amf_n1::handle_itti_message(itti_downlink_nas_transfer& itti_msg) {
...
@@ -307,8 +305,9 @@ void amf_n1::handle_itti_message(itti_downlink_nas_transfer& itti_msg) {
comUt
::
print_buffer
(
"amf_n1"
,
"kamf"
,
kamf
,
32
);
comUt
::
print_buffer
(
"amf_n1"
,
"kamf"
,
kamf
,
32
);
bstring
kgnb_bs
=
blk2bstr
(
kgnb
,
32
);
bstring
kgnb_bs
=
blk2bstr
(
kgnb
,
32
);
itti_initial_context_setup_request
*
csr
=
std
::
shared_ptr
<
itti_initial_context_setup_request
>
csr
=
new
itti_initial_context_setup_request
(
TASK_AMF_N1
,
TASK_AMF_N2
);
std
::
make_shared
<
itti_initial_context_setup_request
>
(
TASK_AMF_N1
,
TASK_AMF_N2
);
csr
->
ran_ue_ngap_id
=
ran_ue_ngap_id
;
csr
->
ran_ue_ngap_id
=
ran_ue_ngap_id
;
csr
->
amf_ue_ngap_id
=
amf_ue_ngap_id
;
csr
->
amf_ue_ngap_id
=
amf_ue_ngap_id
;
csr
->
kgnb
=
kgnb_bs
;
csr
->
kgnb
=
kgnb_bs
;
...
@@ -317,29 +316,27 @@ void amf_n1::handle_itti_message(itti_downlink_nas_transfer& itti_msg) {
...
@@ -317,29 +316,27 @@ void amf_n1::handle_itti_message(itti_downlink_nas_transfer& itti_msg) {
csr
->
is_pdu_exist
=
true
;
csr
->
is_pdu_exist
=
true
;
csr
->
n2sm
=
itti_msg
.
n2sm
;
csr
->
n2sm
=
itti_msg
.
n2sm
;
csr
->
is_sr
=
false
;
// TODO: for Service Request procedure
csr
->
is_sr
=
false
;
// TODO: for Service Request procedure
std
::
shared_ptr
<
itti_initial_context_setup_request
>
i
=
std
::
shared_ptr
<
itti_initial_context_setup_request
>
(
csr
);
int
ret
=
itti_inst
->
send_msg
(
csr
);
int
ret
=
itti_inst
->
send_msg
(
i
);
if
(
0
!=
ret
)
{
if
(
0
!=
ret
)
{
Logger
::
amf_n1
().
error
(
Logger
::
amf_n1
().
error
(
"Could not send ITTI message %s to task TASK_AMF_N2"
,
"Could not send ITTI message %s to task TASK_AMF_N2"
,
i
->
get_msg_name
());
csr
->
get_msg_name
());
}
}
}
}
}
}
}
else
{
}
else
{
itti_dl_nas_transport
*
dnt
=
std
::
shared_ptr
<
itti_dl_nas_transport
>
dnt
=
new
itti_dl_nas_transport
(
TASK_AMF_N1
,
TASK_AMF_N2
);
std
::
make_shared
<
itti_dl_nas_transport
>
(
TASK_AMF_N1
,
TASK_AMF_N2
);
dnt
->
nas
=
protected_nas
;
dnt
->
nas
=
protected_nas
;
dnt
->
amf_ue_ngap_id
=
amf_ue_ngap_id
;
dnt
->
amf_ue_ngap_id
=
amf_ue_ngap_id
;
dnt
->
ran_ue_ngap_id
=
ran_ue_ngap_id
;
dnt
->
ran_ue_ngap_id
=
ran_ue_ngap_id
;
std
::
shared_ptr
<
itti_dl_nas_transport
>
i
=
std
::
shared_ptr
<
itti_dl_nas_transport
>
(
dnt
);
int
ret
=
itti_inst
->
send_msg
(
dnt
);
int
ret
=
itti_inst
->
send_msg
(
i
);
if
(
0
!=
ret
)
{
if
(
0
!=
ret
)
{
Logger
::
amf_n1
().
error
(
Logger
::
amf_n1
().
error
(
"Could not send ITTI message %s to task TASK_AMF_N2"
,
"Could not send ITTI message %s to task TASK_AMF_N2"
,
i
->
get_msg_name
());
dnt
->
get_msg_name
());
}
}
}
}
}
}
...
@@ -672,16 +669,16 @@ bool amf_n1::check_security_header_type(
...
@@ -672,16 +669,16 @@ bool amf_n1::check_security_header_type(
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void
amf_n1
::
identity_response_handle
(
void
amf_n1
::
identity_response_handle
(
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
,
bstring
plain_msg
)
{
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
,
bstring
plain_msg
)
{
IdentityResponse
*
ir
=
new
IdentityResponse
();
auto
identity_response
=
std
::
make_unique
<
IdentityResponse
>
();
if
(
!
i
r
->
decodefrombuffer
(
if
(
!
i
dentity_response
->
decodefrombuffer
(
NULL
,
(
uint8_t
*
)
bdata
(
plain_msg
),
blength
(
plain_msg
)))
{
NULL
,
(
uint8_t
*
)
bdata
(
plain_msg
),
blength
(
plain_msg
)))
{
Logger
::
amf_n1
().
error
(
"Decode Identity Response error"
);
Logger
::
amf_n1
().
error
(
"Decode Identity Response error"
);
return
;
return
;
}
}
string
supi
=
""
;
string
supi
=
""
;
if
(
i
r
->
ie_mobility_id
)
{
if
(
i
dentity_response
->
ie_mobility_id
)
{
nas
::
SUCI_imsi_t
imsi
;
nas
::
SUCI_imsi_t
imsi
;
i
r
->
ie_mobility_id
->
getSuciWithSupiImsi
(
imsi
);
i
dentity_response
->
ie_mobility_id
->
getSuciWithSupiImsi
(
imsi
);
supi
=
imsi
.
mcc
+
imsi
.
mnc
+
imsi
.
msin
;
supi
=
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)"
,
supi
.
c_str
());
}
}
...
@@ -750,18 +747,18 @@ void amf_n1::service_request_handle(
...
@@ -750,18 +747,18 @@ void amf_n1::service_request_handle(
nas
[
1
]
=
PLAIN_5GS_MSG
;
nas
[
1
]
=
PLAIN_5GS_MSG
;
nas
[
2
]
=
SERVICE_REJECT
;
nas
[
2
]
=
SERVICE_REJECT
;
nas
[
3
]
=
_5GMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED
;
nas
[
3
]
=
_5GMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED
;
itti_dl_nas_transport
*
dnt
=
new
itti_dl_nas_transport
(
TASK_AMF_N1
,
TASK_AMF_N2
);
std
::
shared_ptr
<
itti_dl_nas_transport
>
dnt
=
std
::
make_shared
<
itti_dl_nas_transport
>
(
TASK_AMF_N1
,
TASK_AMF_N2
);
dnt
->
nas
=
blk2bstr
(
nas
,
4
);
dnt
->
nas
=
blk2bstr
(
nas
,
4
);
dnt
->
amf_ue_ngap_id
=
amf_ue_ngap_id
;
dnt
->
amf_ue_ngap_id
=
amf_ue_ngap_id
;
dnt
->
ran_ue_ngap_id
=
ran_ue_ngap_id
;
dnt
->
ran_ue_ngap_id
=
ran_ue_ngap_id
;
std
::
shared_ptr
<
itti_dl_nas_transport
>
i
=
std
::
shared_ptr
<
itti_dl_nas_transport
>
(
dnt
);
int
ret
=
itti_inst
->
send_msg
(
dnt
);
int
ret
=
itti_inst
->
send_msg
(
i
);
if
(
0
!=
ret
)
{
if
(
0
!=
ret
)
{
Logger
::
amf_n1
().
error
(
Logger
::
amf_n1
().
error
(
"Could not send ITTI message %s to task TASK_AMF_N2"
,
"Could not send ITTI message %s to task TASK_AMF_N2"
,
i
->
get_msg_name
());
dnt
->
get_msg_name
());
}
}
return
;
return
;
}
}
...
@@ -772,11 +769,14 @@ void amf_n1::service_request_handle(
...
@@ -772,11 +769,14 @@ void amf_n1::service_request_handle(
Logger
::
amf_n1
().
error
(
"No Security Context found"
);
Logger
::
amf_n1
().
error
(
"No Security Context found"
);
return
;
return
;
}
}
std
::
unique_ptr
<
ServiceRequest
>
serReq
=
std
::
make_unique
<
ServiceRequest
>
();
std
::
unique_ptr
<
ServiceRequest
>
service_request
=
serReq
->
decodefrombuffer
(
nullptr
,
(
uint8_t
*
)
bdata
(
nas
),
blength
(
nas
));
std
::
make_unique
<
ServiceRequest
>
();
service_request
->
decodefrombuffer
(
nullptr
,
(
uint8_t
*
)
bdata
(
nas
),
blength
(
nas
));
bdestroy
(
nas
);
bdestroy
(
nas
);
std
::
unique_ptr
<
ServiceAccept
>
serApt
=
std
::
make_unique
<
ServiceAccept
>
();
std
::
unique_ptr
<
ServiceAccept
>
service_accept
=
serApt
->
setHeader
(
PLAIN_5GS_MSG
);
std
::
make_unique
<
ServiceAccept
>
();
service_accept
->
setHeader
(
PLAIN_5GS_MSG
);
string
supi
=
"imsi-"
+
nc
.
get
()
->
imsi
;
string
supi
=
"imsi-"
+
nc
.
get
()
->
imsi
;
uc
.
get
()
->
supi
=
supi
;
uc
.
get
()
->
supi
=
supi
;
supi2amfId
[
supi
]
=
amf_ue_ngap_id
;
supi2amfId
[
supi
]
=
amf_ue_ngap_id
;
...
@@ -809,11 +809,12 @@ void amf_n1::service_request_handle(
...
@@ -809,11 +809,12 @@ void amf_n1::service_request_handle(
amf_app_inst
->
set_supi_2_ue_context
(
supi
,
uc
);
amf_app_inst
->
set_supi_2_ue_context
(
supi
,
uc
);
// Get PDU session status from Service Request
// Get PDU session status from Service Request
uint16_t
pdu_session_status
=
(
uint16_t
)
serReq
->
getPduSessionStatus
();
uint16_t
pdu_session_status
=
(
uint16_t
)
service_request
->
getPduSessionStatus
();
if
(
pdu_session_status
==
0
)
{
if
(
pdu_session_status
==
0
)
{
// Get PDU Session Status from NAS Message Container if available
// Get PDU Session Status from NAS Message Container if available
bstring
plain_msg
;
bstring
plain_msg
;
if
(
ser
Req
->
getNasMessageContainer
(
plain_msg
))
{
if
(
ser
vice_request
->
getNasMessageContainer
(
plain_msg
))
{
uint8_t
*
buf_nas
=
(
uint8_t
*
)
bdata
(
plain_msg
);
uint8_t
*
buf_nas
=
(
uint8_t
*
)
bdata
(
plain_msg
);
uint8_t
message_type
=
*
(
buf_nas
+
2
);
uint8_t
message_type
=
*
(
buf_nas
+
2
);
Logger
::
amf_n1
().
debug
(
"NAS message type 0x%x"
,
message_type
);
Logger
::
amf_n1
().
debug
(
"NAS message type 0x%x"
,
message_type
);
...
@@ -827,13 +828,14 @@ void amf_n1::service_request_handle(
...
@@ -827,13 +828,14 @@ void amf_n1::service_request_handle(
case
SERVICE_REQUEST
:
{
case
SERVICE_REQUEST
:
{
Logger
::
nas_mm
().
debug
(
Logger
::
nas_mm
().
debug
(
"NAS Message Container contains a Service Request, handling ..."
);
"NAS Message Container contains a Service Request, handling ..."
);
std
::
unique_ptr
<
ServiceRequest
>
ser
ReqN
as
=
std
::
unique_ptr
<
ServiceRequest
>
ser
vice_request_n
as
=
std
::
make_unique
<
ServiceRequest
>
();
std
::
make_unique
<
ServiceRequest
>
();
ser
ReqN
as
->
decodefrombuffer
(
ser
vice_request_n
as
->
decodefrombuffer
(
nullptr
,
(
uint8_t
*
)
bdata
(
plain_msg
),
blength
(
plain_msg
));
nullptr
,
(
uint8_t
*
)
bdata
(
plain_msg
),
blength
(
plain_msg
));
bdestroy
(
plain_msg
);
bdestroy
(
plain_msg
);
if
(
serReqNas
->
getPduSessionStatus
()
>
0
)
{
if
(
service_request_nas
->
getPduSessionStatus
()
>
0
)
{
pdu_session_status
=
(
uint16_t
)
serReqNas
->
getPduSessionStatus
();
pdu_session_status
=
(
uint16_t
)
service_request_nas
->
getPduSessionStatus
();
}
}
}
break
;
}
break
;
...
@@ -851,9 +853,9 @@ void amf_n1::service_request_handle(
...
@@ -851,9 +853,9 @@ void amf_n1::service_request_handle(
// No PDU Sessions To Be Activated
// No PDU Sessions To Be Activated
if
(
pdu_session_to_be_activated
.
size
()
==
0
)
{
if
(
pdu_session_to_be_activated
.
size
()
==
0
)
{
Logger
::
amf_n1
().
debug
(
"There is no PDU session to be activated"
);
Logger
::
amf_n1
().
debug
(
"There is no PDU session to be activated"
);
ser
A
pt
->
setPDU_session_status
(
0x0000
);
ser
vice_acce
pt
->
setPDU_session_status
(
0x0000
);
uint8_t
buffer
[
BUFFER_SIZE_256
];
uint8_t
buffer
[
BUFFER_SIZE_256
];
int
encoded_size
=
ser
A
pt
->
encode2buffer
(
buffer
,
BUFFER_SIZE_256
);
int
encoded_size
=
ser
vice_acce
pt
->
encode2buffer
(
buffer
,
BUFFER_SIZE_256
);
bstring
protectedNas
;
bstring
protectedNas
;
encode_nas_message_protected
(
encode_nas_message_protected
(
secu
,
false
,
INTEGRITY_PROTECTED_AND_CIPHERED
,
NAS_MESSAGE_DOWNLINK
,
secu
,
false
,
INTEGRITY_PROTECTED_AND_CIPHERED
,
NAS_MESSAGE_DOWNLINK
,
...
@@ -866,21 +868,21 @@ void amf_n1::service_request_handle(
...
@@ -866,21 +868,21 @@ void amf_n1::service_request_handle(
Authentication_5gaka
::
derive_kgnb
(
ulcount
,
0x01
,
kamf
,
kgnb
);
Authentication_5gaka
::
derive_kgnb
(
ulcount
,
0x01
,
kamf
,
kgnb
);
bstring
kgnb_bs
=
blk2bstr
(
kgnb
,
32
);
bstring
kgnb_bs
=
blk2bstr
(
kgnb
,
32
);
itti_initial_context_setup_request
*
itti_msg
=
std
::
shared_ptr
<
itti_initial_context_setup_request
>
itti_msg
=
new
itti_initial_context_setup_request
(
TASK_AMF_N1
,
TASK_AMF_N2
);
std
::
make_shared
<
itti_initial_context_setup_request
>
(
TASK_AMF_N1
,
TASK_AMF_N2
);
itti_msg
->
ran_ue_ngap_id
=
ran_ue_ngap_id
;
itti_msg
->
ran_ue_ngap_id
=
ran_ue_ngap_id
;
itti_msg
->
amf_ue_ngap_id
=
amf_ue_ngap_id
;
itti_msg
->
amf_ue_ngap_id
=
amf_ue_ngap_id
;
itti_msg
->
nas
=
protectedNas
;
itti_msg
->
nas
=
protectedNas
;
itti_msg
->
kgnb
=
kgnb_bs
;
itti_msg
->
kgnb
=
kgnb_bs
;
itti_msg
->
is_sr
=
true
;
// Service Request indicator
itti_msg
->
is_sr
=
true
;
// Service Request indicator
itti_msg
->
is_pdu_exist
=
false
;
itti_msg
->
is_pdu_exist
=
false
;
std
::
shared_ptr
<
itti_initial_context_setup_request
>
i
=
std
::
shared_ptr
<
itti_initial_context_setup_request
>
(
itti_msg
);
int
ret
=
itti_inst
->
send_msg
(
itti_msg
);
int
ret
=
itti_inst
->
send_msg
(
i
);
if
(
0
!=
ret
)
{
if
(
0
!=
ret
)
{
Logger
::
amf_n1
().
error
(
Logger
::
amf_n1
().
error
(
"Could not send ITTI message %s to task TASK_AMF_N2"
,
"Could not send ITTI message %s to task TASK_AMF_N2"
,
i
->
get_msg_name
());
i
tti_msg
->
get_msg_name
());
}
}
return
;
return
;
...
@@ -891,8 +893,9 @@ void amf_n1::service_request_handle(
...
@@ -891,8 +893,9 @@ void amf_n1::service_request_handle(
std
::
shared_ptr
<
pdu_session_context
>
psc
=
{};
std
::
shared_ptr
<
pdu_session_context
>
psc
=
{};
serApt
->
setPDU_session_status
(
serReq
->
getPduSessionStatus
());
service_accept
->
setPDU_session_status
(
serApt
->
setPDU_session_reactivation_result
(
0x0000
);
service_request
->
getPduSessionStatus
());
service_accept
->
setPDU_session_reactivation_result
(
0x0000
);
uint8_t
pdu_session_id
=
pdu_session_to_be_activated
.
at
(
0
);
uint8_t
pdu_session_id
=
pdu_session_to_be_activated
.
at
(
0
);
if
(
!
amf_app_inst
->
find_pdu_session_context
(
supi
,
pdu_session_id
,
psc
))
{
if
(
!
amf_app_inst
->
find_pdu_session_context
(
supi
,
pdu_session_id
,
psc
))
{
...
@@ -902,7 +905,7 @@ void amf_n1::service_request_handle(
...
@@ -902,7 +905,7 @@ void amf_n1::service_request_handle(
}
}
uint8_t
buffer
[
BUFFER_SIZE_256
];
uint8_t
buffer
[
BUFFER_SIZE_256
];
int
encoded_size
=
ser
A
pt
->
encode2buffer
(
buffer
,
BUFFER_SIZE_256
);
int
encoded_size
=
ser
vice_acce
pt
->
encode2buffer
(
buffer
,
BUFFER_SIZE_256
);
bstring
protectedNas
;
bstring
protectedNas
;
encode_nas_message_protected
(
encode_nas_message_protected
(
secu
,
false
,
INTEGRITY_PROTECTED_AND_CIPHERED
,
NAS_MESSAGE_DOWNLINK
,
secu
,
false
,
INTEGRITY_PROTECTED_AND_CIPHERED
,
NAS_MESSAGE_DOWNLINK
,
...
@@ -914,8 +917,10 @@ void amf_n1::service_request_handle(
...
@@ -914,8 +917,10 @@ void amf_n1::service_request_handle(
comUt
::
print_buffer
(
"amf_n1"
,
"kamf"
,
kamf
,
32
);
comUt
::
print_buffer
(
"amf_n1"
,
"kamf"
,
kamf
,
32
);
Authentication_5gaka
::
derive_kgnb
(
ulcount
,
0x01
,
kamf
,
kgnb
);
Authentication_5gaka
::
derive_kgnb
(
ulcount
,
0x01
,
kamf
,
kgnb
);
bstring
kgnb_bs
=
blk2bstr
(
kgnb
,
32
);
bstring
kgnb_bs
=
blk2bstr
(
kgnb
,
32
);
itti_initial_context_setup_request
*
itti_msg
=
new
itti_initial_context_setup_request
(
TASK_AMF_N1
,
TASK_AMF_N2
);
std
::
shared_ptr
<
itti_initial_context_setup_request
>
itti_msg
=
std
::
make_shared
<
itti_initial_context_setup_request
>
(
TASK_AMF_N1
,
TASK_AMF_N2
);
itti_msg
->
ran_ue_ngap_id
=
ran_ue_ngap_id
;
itti_msg
->
ran_ue_ngap_id
=
ran_ue_ngap_id
;
itti_msg
->
amf_ue_ngap_id
=
amf_ue_ngap_id
;
itti_msg
->
amf_ue_ngap_id
=
amf_ue_ngap_id
;
itti_msg
->
nas
=
protectedNas
;
itti_msg
->
nas
=
protectedNas
;
...
@@ -930,13 +935,12 @@ void amf_n1::service_request_handle(
...
@@ -930,13 +935,12 @@ void amf_n1::service_request_handle(
itti_msg
->
isn2sm_avaliable
=
false
;
itti_msg
->
isn2sm_avaliable
=
false
;
Logger
::
amf_n1
().
error
(
"Cannot get PDU session information"
);
Logger
::
amf_n1
().
error
(
"Cannot get PDU session information"
);
}
}
std
::
shared_ptr
<
itti_initial_context_setup_request
>
i
=
std
::
shared_ptr
<
itti_initial_context_setup_request
>
(
itti_msg
);
int
ret
=
itti_inst
->
send_msg
(
itti_msg
);
int
ret
=
itti_inst
->
send_msg
(
i
);
if
(
0
!=
ret
)
{
if
(
0
!=
ret
)
{
Logger
::
amf_n1
().
error
(
Logger
::
amf_n1
().
error
(
"Could not send ITTI message %s to task TASK_AMF_N2"
,
"Could not send ITTI message %s to task TASK_AMF_N2"
,
i
->
get_msg_name
());
i
tti_msg
->
get_msg_name
());
}
}
}
}
}
}
...
@@ -946,10 +950,11 @@ void amf_n1::registration_request_handle(
...
@@ -946,10 +950,11 @@ void amf_n1::registration_request_handle(
bool
isNasSig
,
std
::
shared_ptr
<
nas_context
>&
nc
,
uint32_t
ran_ue_ngap_id
,
bool
isNasSig
,
std
::
shared_ptr
<
nas_context
>&
nc
,
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
,
std
::
string
snn
,
bstring
reg
)
{
long
amf_ue_ngap_id
,
std
::
string
snn
,
bstring
reg
)
{
// Decode registration request message
// Decode registration request message
std
::
unique_ptr
<
RegistrationRequest
>
reg
Req
=
std
::
unique_ptr
<
RegistrationRequest
>
reg
istration_request
=
std
::
make_unique
<
RegistrationRequest
>
();
std
::
make_unique
<
RegistrationRequest
>
();
regReq
->
decodefrombuffer
(
nullptr
,
(
uint8_t
*
)
bdata
(
reg
),
blength
(
reg
));
registration_request
->
decodefrombuffer
(
nullptr
,
(
uint8_t
*
)
bdata
(
reg
),
blength
(
reg
));
nc
->
registration_request
=
blk2bstr
((
uint8_t
*
)
bdata
(
reg
),
blength
(
reg
));
nc
->
registration_request
=
blk2bstr
((
uint8_t
*
)
bdata
(
reg
),
blength
(
reg
));
nc
->
registration_request_is_set
=
true
;
nc
->
registration_request_is_set
=
true
;
bdestroy
(
reg
);
// free buffer
bdestroy
(
reg
);
// free buffer
...
@@ -964,11 +969,11 @@ void amf_n1::registration_request_handle(
...
@@ -964,11 +969,11 @@ void amf_n1::registration_request_handle(
// Check 5gs Mobility Identity (Mandatory IE)
// Check 5gs Mobility Identity (Mandatory IE)
std
::
string
guti
;
std
::
string
guti
;
uint8_t
mobility_id_type
=
reg
Req
->
getMobilityIdentityType
();
uint8_t
mobility_id_type
=
reg
istration_request
->
getMobilityIdentityType
();
switch
(
mobility_id_type
)
{
switch
(
mobility_id_type
)
{
case
SUCI
:
{
case
SUCI
:
{
nas
::
SUCI_imsi_t
imsi
;
nas
::
SUCI_imsi_t
imsi
;
if
(
!
reg
Req
->
getSuciSupiFormatImsi
(
imsi
))
{
if
(
!
reg
istration_request
->
getSuciSupiFormatImsi
(
imsi
))
{
Logger
::
amf_n1
().
warn
(
"No SUCI and IMSI for SUPI Format"
);
Logger
::
amf_n1
().
warn
(
"No SUCI and IMSI for SUPI Format"
);
}
else
{
}
else
{
if
(
!
nc
.
get
())
{
if
(
!
nc
.
get
())
{
...
@@ -1031,7 +1036,7 @@ void amf_n1::registration_request_handle(
...
@@ -1031,7 +1036,7 @@ void amf_n1::registration_request_handle(
}
break
;
}
break
;
case
_5G_GUTI
:
{
case
_5G_GUTI
:
{
guti
=
reg
Req
->
get_5g_guti
();
guti
=
reg
istration_request
->
get_5g_guti
();
Logger
::
amf_n1
().
debug
(
"Decoded GUTI from registration request message"
);
Logger
::
amf_n1
().
debug
(
"Decoded GUTI from registration request message"
);
if
(
!
guti
.
compare
(
"error"
))
{
if
(
!
guti
.
compare
(
"error"
))
{
Logger
::
amf_n1
().
warn
(
"No GUTI IE"
);
Logger
::
amf_n1
().
warn
(
"No GUTI IE"
);
...
@@ -1148,7 +1153,8 @@ void amf_n1::registration_request_handle(
...
@@ -1148,7 +1153,8 @@ void amf_n1::registration_request_handle(
// Check 5GS_Registration_type IE (Mandatory IE)
// Check 5GS_Registration_type IE (Mandatory IE)
uint8_t
reg_type
=
0
;
uint8_t
reg_type
=
0
;
bool
is_follow_on_req_pending
=
false
;
bool
is_follow_on_req_pending
=
false
;
if
(
!
regReq
->
get5GSRegistrationType
(
is_follow_on_req_pending
,
reg_type
))
{
if
(
!
registration_request
->
get5GSRegistrationType
(
is_follow_on_req_pending
,
reg_type
))
{
Logger
::
amf_n1
().
error
(
"Missing Mandatory IE 5GS Registration type..."
);
Logger
::
amf_n1
().
error
(
"Missing Mandatory IE 5GS Registration type..."
);
response_registration_reject_msg
(
response_registration_reject_msg
(
_5GMM_CAUSE_INVALID_MANDATORY_INFO
,
ran_ue_ngap_id
,
amf_ue_ngap_id
);
_5GMM_CAUSE_INVALID_MANDATORY_INFO
,
ran_ue_ngap_id
,
amf_ue_ngap_id
);
...
@@ -1159,11 +1165,11 @@ void amf_n1::registration_request_handle(
...
@@ -1159,11 +1165,11 @@ void amf_n1::registration_request_handle(
// Check ngKSI (Mandatory IE)
// Check ngKSI (Mandatory IE)
uint8_t
ngKSI
=
0
;
uint8_t
ngKSI
=
0
;
if
(
!
reg
Req
->
getngKSI
(
ngKSI
))
{
if
(
!
reg
istration_request
->
getngKSI
(
ngKSI
))
{
Logger
::
amf_n1
().
error
(
"Missing Mandatory IE ngKSI..."
);
Logger
::
amf_n1
().
error
(
"Missing Mandatory IE ngKSI..."
);
response_registration_reject_msg
(
response_registration_reject_msg
(
_5GMM_CAUSE_INVALID_MANDATORY_INFO
,
ran_ue_ngap_id
,
amf_ue_ngap_id
);
_5GMM_CAUSE_INVALID_MANDATORY_INFO
,
ran_ue_ngap_id
,
amf_ue_ngap_id
);
free_wrapper
((
void
**
)
&
reg
Req
);
free_wrapper
((
void
**
)
&
reg
istration_request
);
return
;
return
;
}
}
nc
.
get
()
->
ngKsi
=
ngKSI
;
nc
.
get
()
->
ngKsi
=
ngKSI
;
...
@@ -1171,7 +1177,7 @@ void amf_n1::registration_request_handle(
...
@@ -1171,7 +1177,7 @@ void amf_n1::registration_request_handle(
// Get non-current native NAS key set identity (Optional IE), used for
// Get non-current native NAS key set identity (Optional IE), used for
// inter-system change from S1 to N1 Get 5GMM Capability IE (optional), not
// inter-system change from S1 to N1 Get 5GMM Capability IE (optional), not
// included for periodic registration updating procedure
// included for periodic registration updating procedure
uint8_t
_5g_mm_cap
=
reg
Req
->
get5GMMCapability
();
uint8_t
_5g_mm_cap
=
reg
istration_request
->
get5GMMCapability
();
if
(
_5g_mm_cap
==
-
1
)
{
if
(
_5g_mm_cap
==
-
1
)
{
Logger
::
amf_n1
().
warn
(
"No Optional IE 5GMMCapability available"
);
Logger
::
amf_n1
().
warn
(
"No Optional IE 5GMMCapability available"
);
}
}
...
@@ -1184,11 +1190,12 @@ void amf_n1::registration_request_handle(
...
@@ -1184,11 +1190,12 @@ void amf_n1::registration_request_handle(
uint8_t
security_cap_eea
=
{
0
};
uint8_t
security_cap_eea
=
{
0
};
uint8_t
security_cap_eia
=
{
0
};
uint8_t
security_cap_eia
=
{
0
};
if
(
!
reg
Req
->
getUeSecurityCapability
(
if
(
!
reg
istration_request
->
getUeSecurityCapability
(
encrypt_alg
,
integrity_alg
,
security_cap_eea
,
security_cap_eia
))
{
encrypt_alg
,
integrity_alg
,
security_cap_eea
,
security_cap_eia
))
{
Logger
::
amf_n1
().
warn
(
"No Optional IE UESecurityCapability available"
);
Logger
::
amf_n1
().
warn
(
"No Optional IE UESecurityCapability available"
);
}
else
{
}
else
{
nc
.
get
()
->
ueSecurityCaplen
=
regReq
->
ie_ue_security_capability
->
getLength
();
nc
.
get
()
->
ueSecurityCaplen
=
registration_request
->
ie_ue_security_capability
->
getLength
();
}
}
nc
.
get
()
->
ueSecurityCapEnc
=
encrypt_alg
;
nc
.
get
()
->
ueSecurityCapEnc
=
encrypt_alg
;
...
@@ -1198,7 +1205,7 @@ void amf_n1::registration_request_handle(
...
@@ -1198,7 +1205,7 @@ void amf_n1::registration_request_handle(
nc
.
get
()
->
ueSecurityCapEIA
=
security_cap_eia
;
nc
.
get
()
->
ueSecurityCapEIA
=
security_cap_eia
;
// Get Requested NSSAI (Optional IE), if provided
// Get Requested NSSAI (Optional IE), if provided
if
(
!
reg
Req
->
getRequestedNssai
(
nc
.
get
()
->
requestedNssai
))
{
if
(
!
reg
istration_request
->
getRequestedNssai
(
nc
.
get
()
->
requestedNssai
))
{
Logger
::
amf_n1
().
debug
(
"No Optional IE RequestedNssai available"
);
Logger
::
amf_n1
().
debug
(
"No Optional IE RequestedNssai available"
);
}
}
...
@@ -1217,7 +1224,8 @@ void amf_n1::registration_request_handle(
...
@@ -1217,7 +1224,8 @@ void amf_n1::registration_request_handle(
// available in UE
// available in UE
bstring
nas_msg
;
bstring
nas_msg
;
bool
is_messagecontainer
=
regReq
->
getNasMessageContainer
(
nas_msg
);
bool
is_messagecontainer
=
registration_request
->
getNasMessageContainer
(
nas_msg
);
if
(
is_messagecontainer
)
{
if
(
is_messagecontainer
)
{
std
::
unique_ptr
<
RegistrationRequest
>
registration_request_msg_container
=
std
::
unique_ptr
<
RegistrationRequest
>
registration_request_msg_container
=
...
@@ -1315,7 +1323,8 @@ void amf_n1::registration_request_handle(
...
@@ -1315,7 +1323,8 @@ void amf_n1::registration_request_handle(
case
MOBILITY_REGISTRATION_UPDATING
:
{
case
MOBILITY_REGISTRATION_UPDATING
:
{
Logger
::
amf_n1
().
debug
(
"Handling Mobility Registration Update..."
);
Logger
::
amf_n1
().
debug
(
"Handling Mobility Registration Update..."
);
run_mobility_registration_update_procedure
(
run_mobility_registration_update_procedure
(
nc
,
regReq
->
getUplinkDataStatus
(),
regReq
->
getPduSessionStatus
());
nc
,
registration_request
->
getUplinkDataStatus
(),
registration_request
->
getPduSessionStatus
());
}
break
;
}
break
;
case
PERIODIC_REGISTRATION_UPDATING
:
{
case
PERIODIC_REGISTRATION_UPDATING
:
{
...
@@ -1324,7 +1333,7 @@ void amf_n1::registration_request_handle(
...
@@ -1324,7 +1333,7 @@ void amf_n1::registration_request_handle(
run_periodic_registration_update_procedure
(
nc
,
nas_msg
);
run_periodic_registration_update_procedure
(
nc
,
nas_msg
);
else
else
run_periodic_registration_update_procedure
(
run_periodic_registration_update_procedure
(
nc
,
reg
Req
->
getPduSessionStatus
());
nc
,
reg
istration_request
->
getPduSessionStatus
());
}
break
;
}
break
;
case
EMERGENCY_REGISTRATION
:
{
case
EMERGENCY_REGISTRATION
:
{
...
@@ -1353,7 +1362,13 @@ bool amf_n1::generate_authentication_vector() {
...
@@ -1353,7 +1362,13 @@ bool amf_n1::generate_authentication_vector() {
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
bool
amf_n1
::
is_amf_ue_id_2_nas_context
(
const
long
&
amf_ue_ngap_id
)
const
{
bool
amf_n1
::
is_amf_ue_id_2_nas_context
(
const
long
&
amf_ue_ngap_id
)
const
{
std
::
shared_lock
lock
(
m_amfueid2nas_context
);
std
::
shared_lock
lock
(
m_amfueid2nas_context
);
return
bool
{
amfueid2nas_context
.
count
(
amf_ue_ngap_id
)
>
0
};
// return bool{amfueid2nas_context.count(amf_ue_ngap_id) > 0};
if
(
amfueid2nas_context
.
count
(
amf_ue_ngap_id
)
>
0
)
{
if
(
amfueid2nas_context
.
at
(
amf_ue_ngap_id
).
get
()
!=
nullptr
)
{
return
true
;
}
}
return
false
;
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
...
@@ -1370,10 +1385,22 @@ void amf_n1::set_amf_ue_ngap_id_2_nas_context(
...
@@ -1370,10 +1385,22 @@ void amf_n1::set_amf_ue_ngap_id_2_nas_context(
amfueid2nas_context
[
amf_ue_ngap_id
]
=
nc
;
amfueid2nas_context
[
amf_ue_ngap_id
]
=
nc
;
}
}
//------------------------------------------------------------------------------
void
amf_n1
::
remove_amf_ue_ngap_id_2_nas_context
(
const
long
&
amf_ue_ngap_id
)
{
std
::
shared_lock
lock
(
m_amfueid2nas_context
);
amfueid2nas_context
[
amf_ue_ngap_id
]
=
nullptr
;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
bool
amf_n1
::
is_guti_2_nas_context
(
const
std
::
string
&
guti
)
const
{
bool
amf_n1
::
is_guti_2_nas_context
(
const
std
::
string
&
guti
)
const
{
std
::
shared_lock
lock
(
m_guti2nas_context
);
std
::
shared_lock
lock
(
m_guti2nas_context
);
return
bool
{
guti2nas_context
.
count
(
guti
)
>
0
};
// return bool{guti2nas_context.count(guti) > 0};
if
(
guti2nas_context
.
count
(
guti
)
>
0
)
{
if
(
guti2nas_context
.
at
(
guti
).
get
()
!=
nullptr
)
{
return
true
;
}
}
return
false
;
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
...
@@ -1393,30 +1420,30 @@ void amf_n1::set_guti_2_nas_context(
...
@@ -1393,30 +1420,30 @@ void amf_n1::set_guti_2_nas_context(
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void
amf_n1
::
itti_send_dl_nas_buffer_to_task_n2
(
void
amf_n1
::
itti_send_dl_nas_buffer_to_task_n2
(
bstring
&
b
,
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
)
{
bstring
&
b
,
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
)
{
itti_dl_nas_transport
*
msg
=
std
::
shared_ptr
<
itti_dl_nas_transport
>
msg
=
new
itti_dl_nas_transport
(
TASK_AMF_N1
,
TASK_AMF_N2
);
std
::
make_shared
<
itti_dl_nas_transport
>
(
TASK_AMF_N1
,
TASK_AMF_N2
);
msg
->
ran_ue_ngap_id
=
ran_ue_ngap_id
;
msg
->
ran_ue_ngap_id
=
ran_ue_ngap_id
;
msg
->
amf_ue_ngap_id
=
amf_ue_ngap_id
;
msg
->
amf_ue_ngap_id
=
amf_ue_ngap_id
;
msg
->
nas
=
b
;
msg
->
nas
=
b
;
std
::
shared_ptr
<
itti_dl_nas_transport
>
i
=
std
::
shared_ptr
<
itti_dl_nas_transport
>
(
msg
);
int
ret
=
itti_inst
->
send_msg
(
msg
);
int
ret
=
itti_inst
->
send_msg
(
i
);
if
(
0
!=
ret
)
{
if
(
0
!=
ret
)
{
Logger
::
amf_n1
().
error
(
Logger
::
amf_n1
().
error
(
"Could not send ITTI message %s to task TASK_AMF_N2"
,
"Could not send ITTI message %s to task TASK_AMF_N2"
,
i
->
get_msg_name
());
msg
->
get_msg_name
());
}
}
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void
amf_n1
::
response_registration_reject_msg
(
void
amf_n1
::
response_registration_reject_msg
(
uint8_t
cause_value
,
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
)
{
uint8_t
cause_value
,
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
)
{
std
::
unique_ptr
<
RegistrationReject
>
registration
Rej
=
std
::
unique_ptr
<
RegistrationReject
>
registration
_reject
=
std
::
make_unique
<
RegistrationReject
>
();
std
::
make_unique
<
RegistrationReject
>
();
registration
Rej
->
setHeader
(
PLAIN_5GS_MSG
);
registration
_reject
->
setHeader
(
PLAIN_5GS_MSG
);
registration
Rej
->
set_5GMM_Cause
(
cause_value
);
registration
_reject
->
set_5GMM_Cause
(
cause_value
);
uint8_t
buffer
[
BUFFER_SIZE_1024
]
=
{
0
};
uint8_t
buffer
[
BUFFER_SIZE_1024
]
=
{
0
};
int
encoded_size
=
registrationRej
->
encode2buffer
(
buffer
,
BUFFER_SIZE_1024
);
int
encoded_size
=
registration_reject
->
encode2buffer
(
buffer
,
BUFFER_SIZE_1024
);
comUt
::
print_buffer
(
comUt
::
print_buffer
(
"amf_n1"
,
"Registration-Reject message buffer"
,
buffer
,
encoded_size
);
"amf_n1"
,
"Registration-Reject message buffer"
,
buffer
,
encoded_size
);
if
(
!
encoded_size
)
{
if
(
!
encoded_size
)
{
...
@@ -1476,24 +1503,24 @@ void amf_n1::run_registration_procedure(std::shared_ptr<nas_context>& nc) {
...
@@ -1476,24 +1503,24 @@ void amf_n1::run_registration_procedure(std::shared_ptr<nas_context>& nc) {
}
else
if
(
nc
.
get
()
->
is_5g_guti_present
)
{
}
else
if
(
nc
.
get
()
->
is_5g_guti_present
)
{
Logger
::
amf_n1
().
debug
(
"Start to run UE Identification Request procedure"
);
Logger
::
amf_n1
().
debug
(
"Start to run UE Identification Request procedure"
);
nc
.
get
()
->
is_auth_vectors_present
=
false
;
nc
.
get
()
->
is_auth_vectors_present
=
false
;
std
::
unique_ptr
<
IdentityRequest
>
ir
=
std
::
make_unique
<
IdentityRequest
>
();
std
::
unique_ptr
<
IdentityRequest
>
identity_request
=
ir
->
setHeader
(
PLAIN_5GS_MSG
);
std
::
make_unique
<
IdentityRequest
>
();
ir
->
set_5GS_Identity_Type
(
SUCI
);
identity_request
->
setHeader
(
PLAIN_5GS_MSG
);
identity_request
->
set_5GS_Identity_Type
(
SUCI
);
uint8_t
buffer
[
100
];
uint8_t
buffer
[
100
];
int
encoded_size
=
i
r
->
encode2buffer
(
buffer
,
100
);
int
encoded_size
=
i
dentity_request
->
encode2buffer
(
buffer
,
100
);
itti_dl_nas_transport
*
dnt
=
std
::
shared_ptr
<
itti_dl_nas_transport
>
dnt
=
new
itti_dl_nas_transport
(
TASK_AMF_N1
,
TASK_AMF_N2
);
std
::
make_shared
<
itti_dl_nas_transport
>
(
TASK_AMF_N1
,
TASK_AMF_N2
);
dnt
->
nas
=
blk2bstr
(
buffer
,
encoded_size
);
dnt
->
nas
=
blk2bstr
(
buffer
,
encoded_size
);
dnt
->
amf_ue_ngap_id
=
nc
.
get
()
->
amf_ue_ngap_id
;
dnt
->
amf_ue_ngap_id
=
nc
.
get
()
->
amf_ue_ngap_id
;
dnt
->
ran_ue_ngap_id
=
nc
.
get
()
->
ran_ue_ngap_id
;
dnt
->
ran_ue_ngap_id
=
nc
.
get
()
->
ran_ue_ngap_id
;
std
::
shared_ptr
<
itti_dl_nas_transport
>
i
=
std
::
shared_ptr
<
itti_dl_nas_transport
>
(
dnt
);
int
ret
=
itti_inst
->
send_msg
(
dnt
);
int
ret
=
itti_inst
->
send_msg
(
i
);
if
(
0
!=
ret
)
{
if
(
0
!=
ret
)
{
Logger
::
amf_n1
().
error
(
Logger
::
amf_n1
().
error
(
"Could not send ITTI message %s to task TASK_AMF_N2"
,
"Could not send ITTI message %s to task TASK_AMF_N2"
,
i
->
get_msg_name
());
dnt
->
get_msg_name
());
}
}
}
}
}
}
...
@@ -1945,25 +1972,25 @@ bool amf_n1::start_authentication_procedure(
...
@@ -1945,25 +1972,25 @@ bool amf_n1::start_authentication_procedure(
}
}
nc
.
get
()
->
is_common_procedure_for_authentication_running
=
true
;
nc
.
get
()
->
is_common_procedure_for_authentication_running
=
true
;
std
::
unique_ptr
<
AuthenticationRequest
>
auth
Req
=
std
::
unique_ptr
<
AuthenticationRequest
>
auth
_request
=
std
::
make_unique
<
AuthenticationRequest
>
();
std
::
make_unique
<
AuthenticationRequest
>
();
auth
Req
->
setHeader
(
PLAIN_5GS_MSG
);
auth
_request
->
setHeader
(
PLAIN_5GS_MSG
);
auth
Req
->
setngKSI
(
NAS_KEY_SET_IDENTIFIER_NATIVE
,
ngksi
);
auth
_request
->
setngKSI
(
NAS_KEY_SET_IDENTIFIER_NATIVE
,
ngksi
);
uint8_t
abba
[
2
];
uint8_t
abba
[
2
];
abba
[
0
]
=
0x00
;
abba
[
0
]
=
0x00
;
abba
[
1
]
=
0x00
;
abba
[
1
]
=
0x00
;
auth
Req
->
setABBA
(
2
,
abba
);
auth
_request
->
setABBA
(
2
,
abba
);
uint8_t
*
rand
=
nc
.
get
()
->
_5g_av
[
vindex
].
rand
;
uint8_t
*
rand
=
nc
.
get
()
->
_5g_av
[
vindex
].
rand
;
if
(
rand
)
auth
Req
->
setAuthentication_Parameter_RAND
(
rand
);
if
(
rand
)
auth
_request
->
setAuthentication_Parameter_RAND
(
rand
);
Logger
::
amf_n1
().
debug
(
"Sending Authentication request with RAND"
);
Logger
::
amf_n1
().
debug
(
"Sending Authentication request with RAND"
);
printf
(
"0x"
);
printf
(
"0x"
);
for
(
int
i
=
0
;
i
<
16
;
i
++
)
printf
(
"%x"
,
rand
[
i
]);
for
(
int
i
=
0
;
i
<
16
;
i
++
)
printf
(
"%x"
,
rand
[
i
]);
printf
(
"
\n
"
);
printf
(
"
\n
"
);
uint8_t
*
autn
=
nc
.
get
()
->
_5g_av
[
vindex
].
autn
;
uint8_t
*
autn
=
nc
.
get
()
->
_5g_av
[
vindex
].
autn
;
if
(
autn
)
auth
Req
->
setAuthentication_Parameter_AUTN
(
autn
);
if
(
autn
)
auth
_request
->
setAuthentication_Parameter_AUTN
(
autn
);
uint8_t
buffer
[
1024
]
=
{
0
};
uint8_t
buffer
[
1024
]
=
{
0
};
int
encoded_size
=
auth
Req
->
encode2buffer
(
buffer
,
1024
);
int
encoded_size
=
auth
_request
->
encode2buffer
(
buffer
,
1024
);
if
(
!
encoded_size
)
{
if
(
!
encoded_size
)
{
Logger
::
nas_mm
().
error
(
"Encode Authentication Request message error"
);
Logger
::
nas_mm
().
error
(
"Encode Authentication Request message error"
);
return
false
;
return
false
;
...
@@ -2024,13 +2051,14 @@ void amf_n1::authentication_response_handle(
...
@@ -2024,13 +2051,14 @@ void amf_n1::authentication_response_handle(
nc
.
get
()
->
is_common_procedure_for_authentication_running
=
false
;
nc
.
get
()
->
is_common_procedure_for_authentication_running
=
false
;
// MM state: COMMON-PROCEDURE-INITIATED -> DEREGISTRED
// MM state: COMMON-PROCEDURE-INITIATED -> DEREGISTRED
// Decode AUTHENTICATION RESPONSE message
// Decode AUTHENTICATION RESPONSE message
AuthenticationResponse
*
auth
=
new
AuthenticationResponse
();
auto
auth_response
=
std
::
make_unique
<
AuthenticationResponse
>
();
auth
->
decodefrombuffer
(
auth_response
->
decodefrombuffer
(
nullptr
,
(
uint8_t
*
)
bdata
(
plain_msg
),
blength
(
plain_msg
));
nullptr
,
(
uint8_t
*
)
bdata
(
plain_msg
),
blength
(
plain_msg
));
bstring
resStar
;
bstring
resStar
;
bool
isAuthOk
=
true
;
bool
isAuthOk
=
true
;
// Get response RES*
// Get response RES*
if
(
!
auth
->
getAuthenticationResponseParameter
(
resStar
))
{
if
(
!
auth
_response
->
getAuthenticationResponseParameter
(
resStar
))
{
Logger
::
amf_n1
().
warn
(
Logger
::
amf_n1
().
warn
(
"Cannot receive AuthenticationResponseParameter (RES*)"
);
"Cannot receive AuthenticationResponseParameter (RES*)"
);
}
else
{
}
else
{
...
@@ -2112,10 +2140,11 @@ void amf_n1::authentication_failure_handle(
...
@@ -2112,10 +2140,11 @@ void amf_n1::authentication_failure_handle(
nc
=
amf_ue_id_2_nas_context
(
amf_ue_ngap_id
);
nc
=
amf_ue_id_2_nas_context
(
amf_ue_ngap_id
);
nc
.
get
()
->
is_common_procedure_for_authentication_running
=
false
;
nc
.
get
()
->
is_common_procedure_for_authentication_running
=
false
;
// 1. decode AUTHENTICATION FAILURE message
// 1. decode AUTHENTICATION FAILURE message
AuthenticationFailure
*
authFail
=
new
AuthenticationFailure
();
auto
auth_failure
=
std
::
make_unique
<
AuthenticationFailure
>
();
authFail
->
decodefrombuffer
(
auth_failure
->
decodefrombuffer
(
NULL
,
(
uint8_t
*
)
bdata
(
plain_msg
),
blength
(
plain_msg
));
NULL
,
(
uint8_t
*
)
bdata
(
plain_msg
),
blength
(
plain_msg
));
uint8_t
mm_cause
=
auth
Fail
->
get5GMmCause
();
uint8_t
mm_cause
=
auth
_failure
->
get5GMmCause
();
if
(
mm_cause
==
-
1
)
{
if
(
mm_cause
==
-
1
)
{
Logger
::
amf_n1
().
error
(
"Missing mandatory IE 5G_MM_CAUSE"
);
Logger
::
amf_n1
().
error
(
"Missing mandatory IE 5G_MM_CAUSE"
);
response_registration_reject_msg
(
response_registration_reject_msg
(
...
@@ -2127,7 +2156,7 @@ void amf_n1::authentication_failure_handle(
...
@@ -2127,7 +2156,7 @@ void amf_n1::authentication_failure_handle(
case
_5GMM_CAUSE_SYNCH_FAILURE
:
{
case
_5GMM_CAUSE_SYNCH_FAILURE
:
{
Logger
::
amf_n1
().
debug
(
"Initial new authentication procedure"
);
Logger
::
amf_n1
().
debug
(
"Initial new authentication procedure"
);
bstring
auts
;
bstring
auts
;
if
(
!
auth
Fail
->
getAutsInAuthFailPara
(
auts
))
{
if
(
!
auth
_failure
->
getAutsInAuthFailPara
(
auts
))
{
Logger
::
amf_n1
().
warn
(
Logger
::
amf_n1
().
warn
(
"IE Authentication Failure Parameter (AUTS) not received"
);
"IE Authentication Failure Parameter (AUTS) not received"
);
}
}
...
@@ -2444,18 +2473,17 @@ void amf_n1::security_mode_complete_handle(
...
@@ -2444,18 +2473,17 @@ void amf_n1::security_mode_complete_handle(
// IE: UEAggregateMaximumBitRate
// IE: UEAggregateMaximumBitRate
// AllowedNSSAI
// AllowedNSSAI
itti_dl_nas_transport
*
dnt
=
std
::
shared_ptr
<
itti_dl_nas_transport
>
dnt
=
new
itti_dl_nas_transport
(
TASK_AMF_N1
,
TASK_AMF_N2
);
std
::
make_shared
<
itti_dl_nas_transport
>
(
TASK_AMF_N1
,
TASK_AMF_N2
);
dnt
->
nas
=
protectedNas
;
dnt
->
nas
=
protectedNas
;
dnt
->
amf_ue_ngap_id
=
amf_ue_ngap_id
;
dnt
->
amf_ue_ngap_id
=
amf_ue_ngap_id
;
dnt
->
ran_ue_ngap_id
=
ran_ue_ngap_id
;
dnt
->
ran_ue_ngap_id
=
ran_ue_ngap_id
;
std
::
shared_ptr
<
itti_dl_nas_transport
>
i
=
std
::
shared_ptr
<
itti_dl_nas_transport
>
(
dnt
);
int
ret
=
itti_inst
->
send_msg
(
dnt
);
int
ret
=
itti_inst
->
send_msg
(
i
);
if
(
0
!=
ret
)
{
if
(
0
!=
ret
)
{
Logger
::
amf_n1
().
error
(
Logger
::
amf_n1
().
error
(
"Could not send ITTI message %s to task TASK_AMF_N2"
,
"Could not send ITTI message %s to task TASK_AMF_N2"
,
i
->
get_msg_name
());
dnt
->
get_msg_name
());
}
}
}
else
{
}
else
{
...
@@ -2470,21 +2498,21 @@ void amf_n1::security_mode_complete_handle(
...
@@ -2470,21 +2498,21 @@ void amf_n1::security_mode_complete_handle(
// Authentication_5gaka::derive_kgnb(ulcount, 0x01, kamf, kgnb);
// Authentication_5gaka::derive_kgnb(ulcount, 0x01, kamf, kgnb);
bstring
kgnb_bs
=
blk2bstr
(
kgnb
,
32
);
bstring
kgnb_bs
=
blk2bstr
(
kgnb
,
32
);
itti_initial_context_setup_request
*
itti_msg
=
std
::
shared_ptr
<
itti_initial_context_setup_request
>
itti_msg
=
new
itti_initial_context_setup_request
(
TASK_AMF_N1
,
TASK_AMF_N2
);
std
::
make_shared
<
itti_initial_context_setup_request
>
(
TASK_AMF_N1
,
TASK_AMF_N2
);
itti_msg
->
ran_ue_ngap_id
=
ran_ue_ngap_id
;
itti_msg
->
ran_ue_ngap_id
=
ran_ue_ngap_id
;
itti_msg
->
amf_ue_ngap_id
=
amf_ue_ngap_id
;
itti_msg
->
amf_ue_ngap_id
=
amf_ue_ngap_id
;
itti_msg
->
kgnb
=
kgnb_bs
;
itti_msg
->
kgnb
=
kgnb_bs
;
itti_msg
->
nas
=
protectedNas
;
itti_msg
->
nas
=
protectedNas
;
itti_msg
->
is_pdu_exist
=
false
;
// no pdu context
itti_msg
->
is_pdu_exist
=
false
;
// no pdu context
itti_msg
->
is_sr
=
false
;
// TODO: for Service Request procedure
itti_msg
->
is_sr
=
false
;
// TODO: for Service Request procedure
std
::
shared_ptr
<
itti_initial_context_setup_request
>
i
=
std
::
shared_ptr
<
itti_initial_context_setup_request
>
(
itti_msg
);
int
ret
=
itti_inst
->
send_msg
(
itti_msg
);
int
ret
=
itti_inst
->
send_msg
(
i
);
if
(
0
!=
ret
)
{
if
(
0
!=
ret
)
{
Logger
::
amf_n1
().
error
(
Logger
::
amf_n1
().
error
(
"Could not send ITTI message %s to task TASK_AMF_N2"
,
"Could not send ITTI message %s to task TASK_AMF_N2"
,
i
->
get_msg_name
());
i
tti_msg
->
get_msg_name
());
}
}
}
}
}
}
...
@@ -2760,39 +2788,106 @@ void amf_n1::ue_initiate_de_registration_handle(
...
@@ -2760,39 +2788,106 @@ void amf_n1::ue_initiate_de_registration_handle(
return
;
return
;
}
}
// decode NAS msg
// Decode NAS message
DeregistrationRequest
*
deregReq
=
new
DeregistrationRequest
();
auto
dereg_request
=
std
::
make_unique
<
DeregistrationRequest
>
();
deregReq
->
decodefrombuffer
(
NULL
,
(
uint8_t
*
)
bdata
(
nas
),
blength
(
nas
));
dereg_request
->
decodefrombuffer
(
NULL
,
(
uint8_t
*
)
bdata
(
nas
),
blength
(
nas
));
/*
_5gs_deregistration_type_t type = {};
deregReq->getDeregistrationType(type);
uint8_t deregType = 0;
deregReq->getDeregistrationType(deregType);
Logger::amf_n1().debug("Deregistration Type %X", deregType);
*/
// TODO: validate 5G Mobile Identity
// TODO: validate 5G Mobile Identity
uint8_t
mobile_id_type
=
0
;
uint8_t
mobile_id_type
=
0
;
dereg
Req
->
getMobilityIdentityType
(
mobile_id_type
);
dereg
_request
->
getMobilityIdentityType
(
mobile_id_type
);
Logger
::
amf_n1
().
debug
(
"5G Mobile Identity %X"
,
mobile_id_type
);
Logger
::
amf_n1
().
debug
(
"5G Mobile Identity %X"
,
mobile_id_type
);
switch
(
mobile_id_type
)
{
switch
(
mobile_id_type
)
{
case
_5G_GUTI
:
{
case
_5G_GUTI
:
{
Logger
::
amf_n1
().
debug
(
Logger
::
amf_n1
().
debug
(
"5G Mobile Identity, GUTI %s"
,
dereg
Req
->
get_5g_guti
().
c_str
());
"5G Mobile Identity, GUTI %s"
,
dereg
_request
->
get_5g_guti
().
c_str
());
}
break
;
}
break
;
default:
{
default:
{
}
}
}
}
// Send request to SMF to release the established PDU sessions if needed
// Get list of PDU sessions
std
::
vector
<
std
::
shared_ptr
<
pdu_session_context
>>
sessions_ctx
;
std
::
shared_ptr
<
ue_context
>
uc
=
{};
if
(
!
find_ue_context
(
nc
,
uc
))
{
Logger
::
amf_n1
().
warn
(
"Cannot find the UE context"
);
return
;
}
if
(
uc
.
get
()
!=
nullptr
)
{
if
(
uc
->
get_pdu_sessions_context
(
sessions_ctx
))
{
// Send Nsmf_PDUSession_ReleaseSMContext to SMF to release the PDU session
std
::
map
<
uint32_t
,
boost
::
shared_future
<
uint32_t
>>
smf_responses
;
for
(
auto
session
:
sessions_ctx
)
{
std
::
shared_ptr
<
itti_nsmf_pdusession_release_sm_context
>
itti_msg
=
std
::
make_shared
<
itti_nsmf_pdusession_release_sm_context
>
(
TASK_AMF_N1
,
TASK_AMF_N11
);
// Generate a promise and associate this promise to the ITTI message
uint32_t
promise_id
=
amf_app_inst
->
generate_promise_id
();
Logger
::
amf_n1
().
debug
(
"Promise ID generated %d"
,
promise_id
);
boost
::
shared_ptr
<
boost
::
promise
<
uint32_t
>>
p
=
boost
::
make_shared
<
boost
::
promise
<
uint32_t
>>
();
boost
::
shared_future
<
uint32_t
>
f
=
p
->
get_future
();
// Store the future to be processed later
smf_responses
.
emplace
(
promise_id
,
f
);
amf_app_inst
->
add_promise
(
promise_id
,
p
);
itti_msg
->
supi
=
uc
->
supi
;
itti_msg
->
pdu_session_id
=
session
->
pdu_session_id
;
itti_msg
->
promise_id
=
promise_id
;
itti_msg
->
context_location
=
session
->
smf_context_location
;
int
ret
=
itti_inst
->
send_msg
(
itti_msg
);
if
(
0
!=
ret
)
{
Logger
::
amf_n1
().
error
(
"Could not send ITTI message %s to task TASK_AMF_N11"
,
itti_msg
->
get_msg_name
());
}
}
// Wait for the response from SMF
while
(
!
smf_responses
.
empty
())
{
boost
::
future_status
status
;
// wait for timeout or ready
status
=
smf_responses
.
begin
()
->
second
.
wait_for
(
boost
::
chrono
::
milliseconds
(
FUTURE_STATUS_TIMEOUT_MS
));
if
(
status
==
boost
::
future_status
::
ready
)
{
assert
(
smf_responses
.
begin
()
->
second
.
is_ready
());
assert
(
smf_responses
.
begin
()
->
second
.
has_value
());
assert
(
!
smf_responses
.
begin
()
->
second
.
has_exception
());
// Wait for the result from APP and send reply to AMF
uint32_t
http_response_code
=
smf_responses
.
begin
()
->
second
.
get
();
// TODO: process response code
}
smf_responses
.
erase
(
smf_responses
.
begin
());
}
}
else
{
Logger
::
amf_n1
().
debug
(
"No PDU session available"
);
}
}
// Check Deregistration type
uint8_t
deregType
=
0
;
dereg_request
->
getDeregistrationType
(
deregType
);
Logger
::
amf_n1
().
debug
(
"Deregistration Type 0x%x"
,
deregType
);
// If UE switch-off, don't need to send Deregistration Accept
if
((
deregType
&
0b00001000
)
==
0
)
{
// Prepare DeregistrationAccept
// Prepare DeregistrationAccept
DeregistrationAccept
*
deregAccept
=
new
DeregistrationAccept
();
auto
dereg_accept
=
std
::
make_unique
<
DeregistrationAccept
>
();
deregA
ccept
->
setHeader
(
PLAIN_5GS_MSG
);
dereg_a
ccept
->
setHeader
(
PLAIN_5GS_MSG
);
uint8_t
buffer
[
BUFFER_SIZE_512
]
=
{
0
};
uint8_t
buffer
[
BUFFER_SIZE_512
]
=
{
0
};
int
encoded_size
=
deregA
ccept
->
encode2buffer
(
buffer
,
BUFFER_SIZE_512
);
int
encoded_size
=
dereg_a
ccept
->
encode2buffer
(
buffer
,
BUFFER_SIZE_512
);
comUt
::
print_buffer
(
comUt
::
print_buffer
(
"amf_n1"
,
"De-registration Accept message buffer"
,
buffer
,
encoded_size
);
"amf_n1"
,
"De-registration Accept message buffer"
,
buffer
,
encoded_size
);
if
(
encoded_size
<
1
)
{
if
(
encoded_size
<
1
)
{
Logger
::
nas_mm
().
error
(
"Encode De-registration Accept message error!"
);
Logger
::
nas_mm
().
error
(
"Encode De-registration Accept message error!"
);
return
;
return
;
...
@@ -2800,6 +2895,7 @@ void amf_n1::ue_initiate_de_registration_handle(
...
@@ -2800,6 +2895,7 @@ void amf_n1::ue_initiate_de_registration_handle(
bstring
b
=
blk2bstr
(
buffer
,
encoded_size
);
bstring
b
=
blk2bstr
(
buffer
,
encoded_size
);
itti_send_dl_nas_buffer_to_task_n2
(
b
,
ran_ue_ngap_id
,
amf_ue_ngap_id
);
itti_send_dl_nas_buffer_to_task_n2
(
b
,
ran_ue_ngap_id
,
amf_ue_ngap_id
);
}
set_5gmm_state
(
nc
,
_5GMM_DEREGISTERED
);
set_5gmm_state
(
nc
,
_5GMM_DEREGISTERED
);
...
@@ -2813,6 +2909,9 @@ void amf_n1::ue_initiate_de_registration_handle(
...
@@ -2813,6 +2909,9 @@ void amf_n1::ue_initiate_de_registration_handle(
stacs
.
update_5gmm_state
(
nc
.
get
()
->
imsi
,
"5GMM-DEREGISTERED"
);
stacs
.
update_5gmm_state
(
nc
.
get
()
->
imsi
,
"5GMM-DEREGISTERED"
);
}
}
// Remove NC context
remove_amf_ue_ngap_id_2_nas_context
(
amf_ue_ngap_id
);
// TODO: AMF to AN: N2 UE Context Release Request
// TODO: AMF to AN: N2 UE Context Release Request
// AMF sends N2 UE Release command to NG-RAN with Cause set to Deregistration
// AMF sends N2 UE Release command to NG-RAN with Cause set to Deregistration
// to release N2 signalling connection
// to release N2 signalling connection
...
@@ -2820,20 +2919,19 @@ void amf_n1::ue_initiate_de_registration_handle(
...
@@ -2820,20 +2919,19 @@ void amf_n1::ue_initiate_de_registration_handle(
Logger
::
ngap
().
debug
(
Logger
::
ngap
().
debug
(
"Sending ITTI UE Context Release Command to TASK_AMF_N2"
);
"Sending ITTI UE Context Release Command to TASK_AMF_N2"
);
itti_ue_context_release_command
*
itti_msg
=
std
::
shared_ptr
<
itti_ue_context_release_command
>
itti_msg
=
new
itti_ue_context_release_command
(
TASK_AMF_N1
,
TASK_AMF_N2
);
std
::
make_shared
<
itti_ue_context_release_command
>
(
TASK_AMF_N1
,
TASK_AMF_N2
);
itti_msg
->
amf_ue_ngap_id
=
amf_ue_ngap_id
;
itti_msg
->
amf_ue_ngap_id
=
amf_ue_ngap_id
;
itti_msg
->
ran_ue_ngap_id
=
ran_ue_ngap_id
;
itti_msg
->
ran_ue_ngap_id
=
ran_ue_ngap_id
;
itti_msg
->
cause
.
setChoiceOfCause
(
Ngap_Cause_PR_nas
);
itti_msg
->
cause
.
setChoiceOfCause
(
Ngap_Cause_PR_nas
);
itti_msg
->
cause
.
setValue
(
2
);
// cause nas(2)--deregister
itti_msg
->
cause
.
setValue
(
2
);
// cause nas(2)--deregister
std
::
shared_ptr
<
itti_ue_context_release_command
>
i
=
std
::
shared_ptr
<
itti_ue_context_release_command
>
(
itti_msg
);
int
ret
=
itti_inst
->
send_msg
(
itti_msg
);
int
ret
=
itti_inst
->
send_msg
(
i
);
if
(
0
!=
ret
)
{
if
(
0
!=
ret
)
{
Logger
::
ngap
().
error
(
Logger
::
ngap
().
error
(
"Could not send ITTI message %s to task TASK_AMF_N2"
,
"Could not send ITTI message %s to task TASK_AMF_N2"
,
i
->
get_msg_name
());
i
tti_msg
->
get_msg_name
());
}
}
}
}
...
@@ -2842,16 +2940,16 @@ void amf_n1::ul_nas_transport_handle(
...
@@ -2842,16 +2940,16 @@ void amf_n1::ul_nas_transport_handle(
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
,
bstring
nas
,
plmn_t
plmn
)
{
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
,
bstring
nas
,
plmn_t
plmn
)
{
// Decode UL_NAS_TRANSPORT message
// Decode UL_NAS_TRANSPORT message
Logger
::
amf_n1
().
debug
(
"Handling UL NAS Transport"
);
Logger
::
amf_n1
().
debug
(
"Handling UL NAS Transport"
);
ULNASTransport
*
ulNas
=
new
ULNASTransport
();
auto
ul_nas
=
std
::
make_unique
<
ULNASTransport
>
();
ul
N
as
->
decodefrombuffer
(
NULL
,
(
uint8_t
*
)
bdata
(
nas
),
blength
(
nas
));
ul
_n
as
->
decodefrombuffer
(
NULL
,
(
uint8_t
*
)
bdata
(
nas
),
blength
(
nas
));
uint8_t
payload_type
=
ul
N
as
->
getPayloadContainerType
();
uint8_t
payload_type
=
ul
_n
as
->
getPayloadContainerType
();
uint8_t
pdu_session_id
=
ul
N
as
->
getPduSessionId
();
uint8_t
pdu_session_id
=
ul
_n
as
->
getPduSessionId
();
uint8_t
request_type
=
ul
N
as
->
getRequestType
();
uint8_t
request_type
=
ul
_n
as
->
getRequestType
();
// SNSSAI
// SNSSAI
SNSSAI_t
snssai
=
{};
SNSSAI_t
snssai
=
{};
if
(
!
ul
Nas
->
getSnssai
(
snssai
))
{
// If no SNSSAI in this message, use the on
e
if
(
!
ul
_nas
->
getSnssai
(
snssai
))
{
// If no SNSSAI in this message, use th
e
//
in Registration Request
// one
in Registration Request
Logger
::
amf_n1
().
debug
(
Logger
::
amf_n1
().
debug
(
"No Requested NSSAI available in ULNASTransport, use NSSAI from "
"No Requested NSSAI available in ULNASTransport, use NSSAI from "
"Requested NSSAI!"
);
"Requested NSSAI!"
);
...
@@ -2878,7 +2976,7 @@ void amf_n1::ul_nas_transport_handle(
...
@@ -2878,7 +2976,7 @@ void amf_n1::ul_nas_transport_handle(
bstring
dnn
=
bfromcstr
(
"default"
);
bstring
dnn
=
bfromcstr
(
"default"
);
bstring
sm_msg
;
bstring
sm_msg
;
if
(
ul
N
as
->
getDnn
(
dnn
))
{
if
(
ul
_n
as
->
getDnn
(
dnn
))
{
}
else
{
}
else
{
dnn
=
bfromcstr
(
"default"
);
dnn
=
bfromcstr
(
"default"
);
}
}
...
@@ -2886,12 +2984,14 @@ void amf_n1::ul_nas_transport_handle(
...
@@ -2886,12 +2984,14 @@ void amf_n1::ul_nas_transport_handle(
"amf_n1"
,
"Decoded DNN Bit String"
,
(
uint8_t
*
)
bdata
(
dnn
),
blength
(
dnn
));
"amf_n1"
,
"Decoded DNN Bit String"
,
(
uint8_t
*
)
bdata
(
dnn
),
blength
(
dnn
));
switch
(
payload_type
)
{
switch
(
payload_type
)
{
case
N1_SM_INFORMATION
:
{
case
N1_SM_INFORMATION
:
{
if
(
!
ul
N
as
->
getPayloadContainer
(
sm_msg
))
{
if
(
!
ul
_n
as
->
getPayloadContainer
(
sm_msg
))
{
Logger
::
amf_n1
().
error
(
"Cannot decode Payload Container"
);
Logger
::
amf_n1
().
error
(
"Cannot decode Payload Container"
);
return
;
return
;
}
}
itti_nsmf_pdusession_create_sm_context
*
itti_msg
=
new
itti_nsmf_pdusession_create_sm_context
(
TASK_AMF_N1
,
TASK_AMF_N11
);
std
::
shared_ptr
<
itti_nsmf_pdusession_create_sm_context
>
itti_msg
=
std
::
make_shared
<
itti_nsmf_pdusession_create_sm_context
>
(
TASK_AMF_N1
,
TASK_AMF_N11
);
itti_msg
->
ran_ue_ngap_id
=
ran_ue_ngap_id
;
itti_msg
->
ran_ue_ngap_id
=
ran_ue_ngap_id
;
itti_msg
->
amf_ue_ngap_id
=
amf_ue_ngap_id
;
itti_msg
->
amf_ue_ngap_id
=
amf_ue_ngap_id
;
itti_msg
->
req_type
=
request_type
;
itti_msg
->
req_type
=
request_type
;
...
@@ -2902,13 +3002,12 @@ void amf_n1::ul_nas_transport_handle(
...
@@ -2902,13 +3002,12 @@ void amf_n1::ul_nas_transport_handle(
itti_msg
->
snssai
.
sD
=
std
::
to_string
(
snssai
.
sd
);
itti_msg
->
snssai
.
sD
=
std
::
to_string
(
snssai
.
sd
);
itti_msg
->
plmn
.
mnc
=
plmn
.
mnc
;
itti_msg
->
plmn
.
mnc
=
plmn
.
mnc
;
itti_msg
->
plmn
.
mcc
=
plmn
.
mcc
;
itti_msg
->
plmn
.
mcc
=
plmn
.
mcc
;
std
::
shared_ptr
<
itti_nsmf_pdusession_create_sm_context
>
i
=
std
::
shared_ptr
<
itti_nsmf_pdusession_create_sm_context
>
(
itti_msg
);
int
ret
=
itti_inst
->
send_msg
(
itti_msg
);
int
ret
=
itti_inst
->
send_msg
(
i
);
if
(
0
!=
ret
)
{
if
(
0
!=
ret
)
{
Logger
::
amf_n1
().
error
(
Logger
::
amf_n1
().
error
(
"Could not send ITTI message %s to task TASK_AMF_N11"
,
"Could not send ITTI message %s to task TASK_AMF_N11"
,
i
->
get_msg_name
());
i
tti_msg
->
get_msg_name
());
}
}
}
break
;
}
break
;
...
@@ -2971,9 +3070,9 @@ void amf_n1::run_mobility_registration_update_procedure(
...
@@ -2971,9 +3070,9 @@ void amf_n1::run_mobility_registration_update_procedure(
std
::
shared_ptr
<
nas_context
>
nc
,
uint16_t
uplink_data_status
,
std
::
shared_ptr
<
nas_context
>
nc
,
uint16_t
uplink_data_status
,
uint16_t
pdu_session_status
)
{
uint16_t
pdu_session_status
)
{
// Encoding REGISTRATION ACCEPT
// Encoding REGISTRATION ACCEPT
auto
reg
A
ccept
=
std
::
make_unique
<
RegistrationAccept
>
();
auto
reg
_a
ccept
=
std
::
make_unique
<
RegistrationAccept
>
();
initialize_registration_accept
(
reg
A
ccept
);
initialize_registration_accept
(
reg
_a
ccept
);
reg
A
ccept
->
set_5GS_Network_Feature_Support
(
reg
_a
ccept
->
set_5GS_Network_Feature_Support
(
0x00
,
0x00
);
// TODO: remove hardcoded values
0x00
,
0x00
);
// TODO: remove hardcoded values
std
::
shared_ptr
<
pdu_session_context
>
psc
=
{};
std
::
shared_ptr
<
pdu_session_context
>
psc
=
{};
...
@@ -2983,12 +3082,12 @@ void amf_n1::run_mobility_registration_update_procedure(
...
@@ -2983,12 +3082,12 @@ void amf_n1::run_mobility_registration_update_procedure(
return
;
return
;
}
}
reg
A
ccept
->
set5G_GUTI
(
reg
_a
ccept
->
set5G_GUTI
(
amf_cfg
.
guami
.
mcc
,
amf_cfg
.
guami
.
mnc
,
amf_cfg
.
guami
.
regionID
,
amf_cfg
.
guami
.
mcc
,
amf_cfg
.
guami
.
mnc
,
amf_cfg
.
guami
.
regionID
,
amf_cfg
.
guami
.
AmfSetID
,
amf_cfg
.
guami
.
AmfPointer
,
uc
.
get
()
->
tmsi
);
amf_cfg
.
guami
.
AmfSetID
,
amf_cfg
.
guami
.
AmfPointer
,
uc
.
get
()
->
tmsi
);
uint8_t
buffer
[
BUFFER_SIZE_1024
]
=
{
0
};
uint8_t
buffer
[
BUFFER_SIZE_1024
]
=
{
0
};
int
encoded_size
=
reg
A
ccept
->
encode2buffer
(
buffer
,
BUFFER_SIZE_1024
);
int
encoded_size
=
reg
_a
ccept
->
encode2buffer
(
buffer
,
BUFFER_SIZE_1024
);
comUt
::
print_buffer
(
comUt
::
print_buffer
(
"amf_n1"
,
"Registration-Accept Message Buffer"
,
buffer
,
encoded_size
);
"amf_n1"
,
"Registration-Accept Message Buffer"
,
buffer
,
encoded_size
);
if
(
!
encoded_size
)
{
if
(
!
encoded_size
)
{
...
@@ -3030,8 +3129,10 @@ void amf_n1::run_mobility_registration_update_procedure(
...
@@ -3030,8 +3129,10 @@ void amf_n1::run_mobility_registration_update_procedure(
Authentication_5gaka
::
derive_kgnb
(
ulcount
,
0x01
,
kamf
,
kgnb
);
Authentication_5gaka
::
derive_kgnb
(
ulcount
,
0x01
,
kamf
,
kgnb
);
comUt
::
print_buffer
(
"amf_n1"
,
"kamf"
,
kamf
,
32
);
comUt
::
print_buffer
(
"amf_n1"
,
"kamf"
,
kamf
,
32
);
bstring
kgnb_bs
=
blk2bstr
(
kgnb
,
32
);
bstring
kgnb_bs
=
blk2bstr
(
kgnb
,
32
);
itti_initial_context_setup_request
*
itti_msg
=
new
itti_initial_context_setup_request
(
TASK_AMF_N1
,
TASK_AMF_N2
);
std
::
shared_ptr
<
itti_initial_context_setup_request
>
itti_msg
=
std
::
make_shared
<
itti_initial_context_setup_request
>
(
TASK_AMF_N1
,
TASK_AMF_N2
);
itti_msg
->
ran_ue_ngap_id
=
nc
.
get
()
->
ran_ue_ngap_id
;
itti_msg
->
ran_ue_ngap_id
=
nc
.
get
()
->
ran_ue_ngap_id
;
itti_msg
->
amf_ue_ngap_id
=
nc
.
get
()
->
amf_ue_ngap_id
;
itti_msg
->
amf_ue_ngap_id
=
nc
.
get
()
->
amf_ue_ngap_id
;
itti_msg
->
kgnb
=
kgnb_bs
;
itti_msg
->
kgnb
=
kgnb_bs
;
...
@@ -3043,13 +3144,11 @@ void amf_n1::run_mobility_registration_update_procedure(
...
@@ -3043,13 +3144,11 @@ void amf_n1::run_mobility_registration_update_procedure(
itti_msg
->
n2sm
=
psc
.
get
()
->
n2sm
;
itti_msg
->
n2sm
=
psc
.
get
()
->
n2sm
;
}
}
std
::
shared_ptr
<
itti_initial_context_setup_request
>
i
=
int
ret
=
itti_inst
->
send_msg
(
itti_msg
);
std
::
shared_ptr
<
itti_initial_context_setup_request
>
(
itti_msg
);
int
ret
=
itti_inst
->
send_msg
(
i
);
if
(
0
!=
ret
)
{
if
(
0
!=
ret
)
{
Logger
::
amf_n1
().
error
(
Logger
::
amf_n1
().
error
(
"Could not send ITTI message %s to task TASK_AMF_N2"
,
"Could not send ITTI message %s to task TASK_AMF_N2"
,
i
->
get_msg_name
());
i
tti_msg
->
get_msg_name
());
}
}
}
}
...
@@ -3058,8 +3157,8 @@ void amf_n1::run_periodic_registration_update_procedure(
...
@@ -3058,8 +3157,8 @@ void amf_n1::run_periodic_registration_update_procedure(
std
::
shared_ptr
<
nas_context
>
nc
,
uint16_t
pdu_session_status
)
{
std
::
shared_ptr
<
nas_context
>
nc
,
uint16_t
pdu_session_status
)
{
// Experimental procedure
// Experimental procedure
// Encoding REGISTRATION ACCEPT
// Encoding REGISTRATION ACCEPT
auto
reg
A
ccept
=
std
::
make_unique
<
RegistrationAccept
>
();
auto
reg
_a
ccept
=
std
::
make_unique
<
RegistrationAccept
>
();
initialize_registration_accept
(
reg
A
ccept
);
initialize_registration_accept
(
reg
_a
ccept
);
// Get UE context
// Get UE context
std
::
shared_ptr
<
ue_context
>
uc
=
{};
std
::
shared_ptr
<
ue_context
>
uc
=
{};
...
@@ -3068,21 +3167,21 @@ void amf_n1::run_periodic_registration_update_procedure(
...
@@ -3068,21 +3167,21 @@ void amf_n1::run_periodic_registration_update_procedure(
return
;
return
;
}
}
reg
A
ccept
->
set5G_GUTI
(
reg
_a
ccept
->
set5G_GUTI
(
amf_cfg
.
guami
.
mcc
,
amf_cfg
.
guami
.
mnc
,
amf_cfg
.
guami
.
regionID
,
amf_cfg
.
guami
.
mcc
,
amf_cfg
.
guami
.
mnc
,
amf_cfg
.
guami
.
regionID
,
amf_cfg
.
guami
.
AmfSetID
,
amf_cfg
.
guami
.
AmfPointer
,
uc
.
get
()
->
tmsi
);
amf_cfg
.
guami
.
AmfSetID
,
amf_cfg
.
guami
.
AmfPointer
,
uc
.
get
()
->
tmsi
);
if
(
pdu_session_status
==
0x0000
)
{
if
(
pdu_session_status
==
0x0000
)
{
reg
A
ccept
->
setPDU_session_status
(
0x0000
);
reg
_a
ccept
->
setPDU_session_status
(
0x0000
);
}
else
{
}
else
{
reg
A
ccept
->
setPDU_session_status
(
pdu_session_status
);
reg
_a
ccept
->
setPDU_session_status
(
pdu_session_status
);
Logger
::
amf_n1
().
debug
(
Logger
::
amf_n1
().
debug
(
"PDU Session Status 0x%02x"
,
htonl
(
pdu_session_status
));
"PDU Session Status 0x%02x"
,
htonl
(
pdu_session_status
));
}
}
reg
A
ccept
->
set_5GS_Network_Feature_Support
(
0x01
,
0x00
);
reg
_a
ccept
->
set_5GS_Network_Feature_Support
(
0x01
,
0x00
);
uint8_t
buffer
[
BUFFER_SIZE_1024
]
=
{
0
};
uint8_t
buffer
[
BUFFER_SIZE_1024
]
=
{
0
};
int
encoded_size
=
reg
A
ccept
->
encode2buffer
(
buffer
,
BUFFER_SIZE_1024
);
int
encoded_size
=
reg
_a
ccept
->
encode2buffer
(
buffer
,
BUFFER_SIZE_1024
);
comUt
::
print_buffer
(
comUt
::
print_buffer
(
"amf_n1"
,
"Registration-Accept Message Buffer"
,
buffer
,
encoded_size
);
"amf_n1"
,
"Registration-Accept Message Buffer"
,
buffer
,
encoded_size
);
if
(
!
encoded_size
)
{
if
(
!
encoded_size
)
{
...
@@ -3101,18 +3200,17 @@ void amf_n1::run_periodic_registration_update_procedure(
...
@@ -3101,18 +3200,17 @@ void amf_n1::run_periodic_registration_update_procedure(
secu
,
false
,
INTEGRITY_PROTECTED_AND_CIPHERED
,
NAS_MESSAGE_DOWNLINK
,
secu
,
false
,
INTEGRITY_PROTECTED_AND_CIPHERED
,
NAS_MESSAGE_DOWNLINK
,
buffer
,
encoded_size
,
protectedNas
);
buffer
,
encoded_size
,
protectedNas
);
itti_dl_nas_transport
*
itti_msg
=
std
::
shared_ptr
<
itti_dl_nas_transport
>
itti_msg
=
new
itti_dl_nas_transport
(
TASK_AMF_N1
,
TASK_AMF_N2
);
std
::
make_shared
<
itti_dl_nas_transport
>
(
TASK_AMF_N1
,
TASK_AMF_N2
);
itti_msg
->
ran_ue_ngap_id
=
nc
.
get
()
->
ran_ue_ngap_id
;
itti_msg
->
ran_ue_ngap_id
=
nc
.
get
()
->
ran_ue_ngap_id
;
itti_msg
->
amf_ue_ngap_id
=
nc
.
get
()
->
amf_ue_ngap_id
;
itti_msg
->
amf_ue_ngap_id
=
nc
.
get
()
->
amf_ue_ngap_id
;
itti_msg
->
nas
=
protectedNas
;
itti_msg
->
nas
=
protectedNas
;
std
::
shared_ptr
<
itti_dl_nas_transport
>
i
=
std
::
shared_ptr
<
itti_dl_nas_transport
>
(
itti_msg
);
int
ret
=
itti_inst
->
send_msg
(
itti_msg
);
int
ret
=
itti_inst
->
send_msg
(
i
);
if
(
0
!=
ret
)
{
if
(
0
!=
ret
)
{
Logger
::
amf_n1
().
error
(
Logger
::
amf_n1
().
error
(
"Could not send ITTI message %s to task TASK_AMF_N2"
,
"Could not send ITTI message %s to task TASK_AMF_N2"
,
i
->
get_msg_name
());
i
tti_msg
->
get_msg_name
());
}
}
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
...
@@ -3121,15 +3219,15 @@ void amf_n1::run_periodic_registration_update_procedure(
...
@@ -3121,15 +3219,15 @@ void amf_n1::run_periodic_registration_update_procedure(
// Experimental procedure
// Experimental procedure
// decoding REGISTRATION request
// decoding REGISTRATION request
std
::
unique_ptr
<
RegistrationRequest
>
reg
Req
=
std
::
unique_ptr
<
RegistrationRequest
>
reg
istration_request
=
std
::
make_unique
<
RegistrationRequest
>
();
std
::
make_unique
<
RegistrationRequest
>
();
reg
Req
->
decodefrombuffer
(
reg
istration_request
->
decodefrombuffer
(
nullptr
,
(
uint8_t
*
)
bdata
(
nas_msg
),
blength
(
nas_msg
));
nullptr
,
(
uint8_t
*
)
bdata
(
nas_msg
),
blength
(
nas_msg
));
bdestroy
(
nas_msg
);
// free buffer
bdestroy
(
nas_msg
);
// free buffer
// Encoding REGISTRATION ACCEPT
// Encoding REGISTRATION ACCEPT
auto
reg
A
ccept
=
std
::
make_unique
<
RegistrationAccept
>
();
auto
reg
_a
ccept
=
std
::
make_unique
<
RegistrationAccept
>
();
initialize_registration_accept
(
reg
A
ccept
);
initialize_registration_accept
(
reg
_a
ccept
);
// Get UE context
// Get UE context
std
::
shared_ptr
<
ue_context
>
uc
=
{};
std
::
shared_ptr
<
ue_context
>
uc
=
{};
...
@@ -3138,23 +3236,23 @@ void amf_n1::run_periodic_registration_update_procedure(
...
@@ -3138,23 +3236,23 @@ void amf_n1::run_periodic_registration_update_procedure(
return
;
return
;
}
}
reg
A
ccept
->
set5G_GUTI
(
reg
_a
ccept
->
set5G_GUTI
(
amf_cfg
.
guami
.
mcc
,
amf_cfg
.
guami
.
mnc
,
amf_cfg
.
guami
.
regionID
,
amf_cfg
.
guami
.
mcc
,
amf_cfg
.
guami
.
mnc
,
amf_cfg
.
guami
.
regionID
,
amf_cfg
.
guami
.
AmfSetID
,
amf_cfg
.
guami
.
AmfPointer
,
uc
.
get
()
->
tmsi
);
amf_cfg
.
guami
.
AmfSetID
,
amf_cfg
.
guami
.
AmfPointer
,
uc
.
get
()
->
tmsi
);
uint16_t
pdu_session_status
=
0xffff
;
uint16_t
pdu_session_status
=
0xffff
;
pdu_session_status
=
reg
Req
->
getPduSessionStatus
();
pdu_session_status
=
reg
istration_request
->
getPduSessionStatus
();
if
(
pdu_session_status
==
0x0000
)
{
if
(
pdu_session_status
==
0x0000
)
{
reg
A
ccept
->
setPDU_session_status
(
0x0000
);
reg
_a
ccept
->
setPDU_session_status
(
0x0000
);
}
else
{
}
else
{
reg
A
ccept
->
setPDU_session_status
(
pdu_session_status
);
reg
_a
ccept
->
setPDU_session_status
(
pdu_session_status
);
Logger
::
amf_n1
().
debug
(
Logger
::
amf_n1
().
debug
(
"PDU Session Status 0x%02x"
,
htonl
(
pdu_session_status
));
"PDU Session Status 0x%02x"
,
htonl
(
pdu_session_status
));
}
}
reg
A
ccept
->
set_5GS_Network_Feature_Support
(
0x01
,
0x00
);
reg
_a
ccept
->
set_5GS_Network_Feature_Support
(
0x01
,
0x00
);
uint8_t
buffer
[
BUFFER_SIZE_1024
]
=
{
0
};
uint8_t
buffer
[
BUFFER_SIZE_1024
]
=
{
0
};
int
encoded_size
=
reg
A
ccept
->
encode2buffer
(
buffer
,
BUFFER_SIZE_1024
);
int
encoded_size
=
reg
_a
ccept
->
encode2buffer
(
buffer
,
BUFFER_SIZE_1024
);
comUt
::
print_buffer
(
comUt
::
print_buffer
(
"amf_n1"
,
"Registration-Accept Message Buffer"
,
buffer
,
encoded_size
);
"amf_n1"
,
"Registration-Accept Message Buffer"
,
buffer
,
encoded_size
);
if
(
!
encoded_size
)
{
if
(
!
encoded_size
)
{
...
@@ -3173,18 +3271,17 @@ void amf_n1::run_periodic_registration_update_procedure(
...
@@ -3173,18 +3271,17 @@ void amf_n1::run_periodic_registration_update_procedure(
secu
,
false
,
INTEGRITY_PROTECTED_AND_CIPHERED
,
NAS_MESSAGE_DOWNLINK
,
secu
,
false
,
INTEGRITY_PROTECTED_AND_CIPHERED
,
NAS_MESSAGE_DOWNLINK
,
buffer
,
encoded_size
,
protectedNas
);
buffer
,
encoded_size
,
protectedNas
);
itti_dl_nas_transport
*
itti_msg
=
std
::
shared_ptr
<
itti_dl_nas_transport
>
itti_msg
=
new
itti_dl_nas_transport
(
TASK_AMF_N1
,
TASK_AMF_N2
);
std
::
make_shared
<
itti_dl_nas_transport
>
(
TASK_AMF_N1
,
TASK_AMF_N2
);
itti_msg
->
ran_ue_ngap_id
=
nc
.
get
()
->
ran_ue_ngap_id
;
itti_msg
->
ran_ue_ngap_id
=
nc
.
get
()
->
ran_ue_ngap_id
;
itti_msg
->
amf_ue_ngap_id
=
nc
.
get
()
->
amf_ue_ngap_id
;
itti_msg
->
amf_ue_ngap_id
=
nc
.
get
()
->
amf_ue_ngap_id
;
itti_msg
->
nas
=
protectedNas
;
itti_msg
->
nas
=
protectedNas
;
std
::
shared_ptr
<
itti_dl_nas_transport
>
i
=
std
::
shared_ptr
<
itti_dl_nas_transport
>
(
itti_msg
);
int
ret
=
itti_inst
->
send_msg
(
itti_msg
);
int
ret
=
itti_inst
->
send_msg
(
i
);
if
(
0
!=
ret
)
{
if
(
0
!=
ret
)
{
Logger
::
amf_n1
().
error
(
Logger
::
amf_n1
().
error
(
"Could not send ITTI message %s to task TASK_AMF_N2"
,
"Could not send ITTI message %s to task TASK_AMF_N2"
,
i
->
get_msg_name
());
i
tti_msg
->
get_msg_name
());
}
}
}
}
...
@@ -3701,7 +3798,6 @@ void amf_n1::implicit_deregistration_timer_timeout(
...
@@ -3701,7 +3798,6 @@ void amf_n1::implicit_deregistration_timer_timeout(
std
::
shared_ptr
<
itti_ue_context_release_command
>
itti_msg_cxt_release
=
std
::
shared_ptr
<
itti_ue_context_release_command
>
itti_msg_cxt_release
=
std
::
make_shared
<
itti_ue_context_release_command
>
(
std
::
make_shared
<
itti_ue_context_release_command
>
(
TASK_AMF_N1
,
TASK_AMF_N2
);
TASK_AMF_N1
,
TASK_AMF_N2
);
itti_msg_cxt_release
->
amf_ue_ngap_id
=
nc
.
get
()
->
amf_ue_ngap_id
;
itti_msg_cxt_release
->
amf_ue_ngap_id
=
nc
.
get
()
->
amf_ue_ngap_id
;
itti_msg_cxt_release
->
ran_ue_ngap_id
=
nc
.
get
()
->
ran_ue_ngap_id
;
itti_msg_cxt_release
->
ran_ue_ngap_id
=
nc
.
get
()
->
ran_ue_ngap_id
;
itti_msg_cxt_release
->
cause
.
setChoiceOfCause
(
Ngap_Cause_PR_nas
);
itti_msg_cxt_release
->
cause
.
setChoiceOfCause
(
Ngap_Cause_PR_nas
);
...
@@ -4426,7 +4522,6 @@ bool amf_n1::reroute_nas_via_an(
...
@@ -4426,7 +4522,6 @@ bool amf_n1::reroute_nas_via_an(
std
::
shared_ptr
<
itti_rereoute_nas
>
itti_msg
=
std
::
shared_ptr
<
itti_rereoute_nas
>
itti_msg
=
std
::
make_shared
<
itti_rereoute_nas
>
(
TASK_AMF_N1
,
TASK_AMF_N2
);
std
::
make_shared
<
itti_rereoute_nas
>
(
TASK_AMF_N1
,
TASK_AMF_N2
);
itti_msg
->
ran_ue_ngap_id
=
nc
->
ran_ue_ngap_id
;
itti_msg
->
ran_ue_ngap_id
=
nc
->
ran_ue_ngap_id
;
itti_msg
->
amf_ue_ngap_id
=
nc
->
amf_ue_ngap_id
;
itti_msg
->
amf_ue_ngap_id
=
nc
->
amf_ue_ngap_id
;
itti_msg
->
amf_set_id
=
amf_set_id
;
itti_msg
->
amf_set_id
=
amf_set_id
;
...
...
src/amf-app/amf_n1.hpp
View file @
e1765115
...
@@ -148,6 +148,7 @@ class amf_n1 {
...
@@ -148,6 +148,7 @@ class amf_n1 {
void
set_amf_ue_ngap_id_2_nas_context
(
void
set_amf_ue_ngap_id_2_nas_context
(
const
long
&
amf_ue_ngap_id
,
std
::
shared_ptr
<
nas_context
>
nc
);
const
long
&
amf_ue_ngap_id
,
std
::
shared_ptr
<
nas_context
>
nc
);
void
remove_amf_ue_ngap_id_2_nas_context
(
const
long
&
amf_ue_ngap_id
);
// TODO
// TODO
void
run_registration_procedure
(
std
::
shared_ptr
<
nas_context
>&
nc
);
void
run_registration_procedure
(
std
::
shared_ptr
<
nas_context
>&
nc
);
...
...
src/amf-app/amf_n11.cpp
View file @
e1765115
...
@@ -105,6 +105,14 @@ void amf_n11_task(void*) {
...
@@ -105,6 +105,14 @@ void amf_n11_task(void*) {
amf_n11_inst
->
handle_itti_message
(
ref
(
*
m
));
amf_n11_inst
->
handle_itti_message
(
ref
(
*
m
));
}
break
;
}
break
;
case
NSMF_PDU_SESSION_RELEASE_SM_CTX
:
{
Logger
::
amf_n11
().
info
(
"Receive Nsmf_PDUSessionReleaseSMContext, handling ..."
);
itti_nsmf_pdusession_release_sm_context
*
m
=
dynamic_cast
<
itti_nsmf_pdusession_release_sm_context
*>
(
msg
);
amf_n11_inst
->
handle_itti_message
(
ref
(
*
m
));
}
break
;
case
PDU_SESSION_RESOURCE_SETUP_RESPONSE
:
{
case
PDU_SESSION_RESOURCE_SETUP_RESPONSE
:
{
Logger
::
amf_n11
().
info
(
Logger
::
amf_n11
().
info
(
"Receive PDU Session Resource Setup response, handling ..."
);
"Receive PDU Session Resource Setup response, handling ..."
);
...
@@ -550,6 +558,7 @@ void amf_n11::handle_itti_message(
...
@@ -550,6 +558,7 @@ void amf_n11::handle_itti_message(
string
smf_addr
=
{};
string
smf_addr
=
{};
std
::
string
smf_api_version
=
{};
std
::
string
smf_api_version
=
{};
std
::
string
remote_uri
=
{};
if
(
!
psc
.
get
()
->
smf_available
)
{
if
(
!
psc
.
get
()
->
smf_available
)
{
Logger
::
amf_n11
().
error
(
"No SMF is available for this PDU session"
);
Logger
::
amf_n11
().
error
(
"No SMF is available for this PDU session"
);
...
@@ -558,24 +567,34 @@ void amf_n11::handle_itti_message(
...
@@ -558,24 +567,34 @@ void amf_n11::handle_itti_message(
smf_api_version
=
psc
->
smf_api_version
;
smf_api_version
=
psc
->
smf_api_version
;
}
}
string
remote_uri
=
psc
.
get
()
->
location
+
"
release"
;
remote_uri
=
psc
.
get
()
->
smf_context_location
+
"/
release"
;
nlohmann
::
json
pdu_session_release_request
;
nlohmann
::
json
pdu_session_release_request
;
pdu_session_release_request
[
"supi"
]
=
itti_msg
.
supi
.
c_str
();
pdu_session_release_request
[
"supi"
]
=
itti_msg
.
supi
.
c_str
();
pdu_session_release_request
[
"dnn"
]
=
psc
.
get
()
->
dnn
.
c_str
();
pdu_session_release_request
[
"dnn"
]
=
psc
.
get
()
->
dnn
.
c_str
();
pdu_session_release_request
[
"sNssai"
][
"sst"
]
=
pdu_session_release_request
[
"sNssai"
][
"sst"
]
=
psc
.
get
()
->
snssai
.
sST
;
1
;
// TODO: check hardcoded value
pdu_session_release_request
[
"sNssai"
][
"sd"
]
=
psc
.
get
()
->
snssai
.
sD
;
pdu_session_release_request
[
"sNssai"
][
"sd"
]
=
"0"
;
// TODO: check hardcoded value
pdu_session_release_request
[
"pduSessionId"
]
=
psc
.
get
()
->
pdu_session_id
;
pdu_session_release_request
[
"pduSessionId"
]
=
psc
.
get
()
->
pdu_session_id
;
pdu_session_release_request
[
"cause"
]
=
"REL_DUE_TO_REACTIVATION"
;
pdu_session_release_request
[
"cause"
]
=
"REL_DUE_TO_REACTIVATION"
;
// TODO:
pdu_session_release_request
[
"ngApCause"
]
=
"radioNetwork"
;
pdu_session_release_request
[
"ngApCause"
]
=
"radioNetwork"
;
std
::
string
json_part
=
pdu_session_release_request
.
dump
();
std
::
string
msg_body
=
pdu_session_release_request
.
dump
();
uint8_t
http_version
=
1
;
uint8_t
http_version
=
1
;
if
(
amf_cfg
.
support_features
.
use_http2
)
http_version
=
2
;
if
(
amf_cfg
.
support_features
.
use_http2
)
http_version
=
2
;
nlohmann
::
json
response_json
=
{};
uint32_t
response_code
=
0
;
// curl_http_client(
// remote_uri, json_part, "", "", itti_msg.supi,
// psc.get()->pdu_session_id, http_version);
curl_http_client
(
curl_http_client
(
remote_uri
,
json_part
,
""
,
""
,
itti_msg
.
supi
,
psc
.
get
()
->
pdu_session_id
,
remote_uri
,
"POST"
,
msg_body
,
response_json
,
response_code
,
http_version
);
http_version
);
// Notify to the result
if
(
itti_msg
.
promise_id
>
0
)
{
amf_app_inst
->
trigger_process_response
(
itti_msg
.
promise_id
,
response_code
);
return
;
}
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
...
...
src/amf-app/amf_n2.cpp
View file @
e1765115
...
@@ -1338,6 +1338,7 @@ void amf_n2::handle_itti_message(itti_ue_context_release_complete& itti_msg) {
...
@@ -1338,6 +1338,7 @@ void amf_n2::handle_itti_message(itti_ue_context_release_complete& itti_msg) {
Logger
::
amf_n2
().
debug
(
"Handle UE Context Release Complete ..."
);
Logger
::
amf_n2
().
debug
(
"Handle UE Context Release Complete ..."
);
unsigned
long
amf_ue_ngap_id
=
itti_msg
.
ueCtxRelCmpl
->
getAmfUeNgapId
();
unsigned
long
amf_ue_ngap_id
=
itti_msg
.
ueCtxRelCmpl
->
getAmfUeNgapId
();
uint32_t
ran_ue_ngap_id
=
itti_msg
.
ueCtxRelCmpl
->
getRanUeNgapId
();
uint32_t
ran_ue_ngap_id
=
itti_msg
.
ueCtxRelCmpl
->
getRanUeNgapId
();
// Change UE status from CM-CONNECTED to CM-IDLE
// Change UE status from CM-CONNECTED to CM-IDLE
std
::
shared_ptr
<
nas_context
>
nc
;
std
::
shared_ptr
<
nas_context
>
nc
;
if
(
amf_n1_inst
->
is_amf_ue_id_2_nas_context
(
amf_ue_ngap_id
))
if
(
amf_n1_inst
->
is_amf_ue_id_2_nas_context
(
amf_ue_ngap_id
))
...
@@ -1347,6 +1348,7 @@ void amf_n2::handle_itti_message(itti_ue_context_release_complete& itti_msg) {
...
@@ -1347,6 +1348,7 @@ void amf_n2::handle_itti_message(itti_ue_context_release_complete& itti_msg) {
"No existed nas_context with amf_ue_ngap_id("
AMF_UE_NGAP_ID_FMT
")"
,
"No existed nas_context with amf_ue_ngap_id("
AMF_UE_NGAP_ID_FMT
")"
,
amf_ue_ngap_id
);
amf_ue_ngap_id
);
}
}
if
(
nc
.
get
()
!=
nullptr
)
{
amf_n1_inst
->
set_5gcm_state
(
nc
,
CM_IDLE
);
amf_n1_inst
->
set_5gcm_state
(
nc
,
CM_IDLE
);
// Start/reset the Mobile Reachable Timer
// Start/reset the Mobile Reachable Timer
...
@@ -1357,6 +1359,7 @@ void amf_n2::handle_itti_message(itti_ue_context_release_complete& itti_msg) {
...
@@ -1357,6 +1359,7 @@ void amf_n2::handle_itti_message(itti_ue_context_release_complete& itti_msg) {
amf_n1_inst
->
set_mobile_reachable_timer
(
nc
,
tid
);
amf_n1_inst
->
set_mobile_reachable_timer
(
nc
,
tid
);
amf_n1_inst
->
set_mobile_reachable_timer_timeout
(
nc
,
false
);
amf_n1_inst
->
set_mobile_reachable_timer_timeout
(
nc
,
false
);
}
// TODO: User Location Information IE
// TODO: User Location Information IE
// TODO: Information on Recommended Cells & RAN Nodes for Paging IE
// TODO: Information on Recommended Cells & RAN Nodes for Paging IE
...
@@ -2137,7 +2140,14 @@ void amf_n2::send_handover_preparation_failure(
...
@@ -2137,7 +2140,14 @@ void amf_n2::send_handover_preparation_failure(
bool
amf_n2
::
is_ran_ue_id_2_ue_ngap_context
(
bool
amf_n2
::
is_ran_ue_id_2_ue_ngap_context
(
const
uint32_t
&
ran_ue_ngap_id
)
const
{
const
uint32_t
&
ran_ue_ngap_id
)
const
{
std
::
shared_lock
lock
(
m_ranid2uecontext
);
std
::
shared_lock
lock
(
m_ranid2uecontext
);
return
bool
{
ranid2uecontext
.
count
(
ran_ue_ngap_id
)
>
0
};
if
(
ranid2uecontext
.
count
(
ran_ue_ngap_id
)
>
0
)
{
if
(
ranid2uecontext
.
at
(
ran_ue_ngap_id
).
get
()
!=
nullptr
)
{
return
true
;
}
}
return
false
;
// return bool{ranid2uecontext.count(ran_ue_ngap_id) > 0};
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
...
@@ -2165,7 +2175,13 @@ std::shared_ptr<ue_ngap_context> amf_n2::amf_ue_id_2_ue_ngap_context(
...
@@ -2165,7 +2175,13 @@ std::shared_ptr<ue_ngap_context> amf_n2::amf_ue_id_2_ue_ngap_context(
bool
amf_n2
::
is_amf_ue_id_2_ue_ngap_context
(
bool
amf_n2
::
is_amf_ue_id_2_ue_ngap_context
(
const
unsigned
long
&
amf_ue_ngap_id
)
const
{
const
unsigned
long
&
amf_ue_ngap_id
)
const
{
std
::
shared_lock
lock
(
m_amfueid2uecontext
);
std
::
shared_lock
lock
(
m_amfueid2uecontext
);
return
bool
{
amfueid2uecontext
.
count
(
amf_ue_ngap_id
)
>
0
};
// return bool{amfueid2uecontext.count(amf_ue_ngap_id) > 0};
if
(
amfueid2uecontext
.
count
(
amf_ue_ngap_id
)
>
0
)
{
if
(
amfueid2uecontext
.
at
(
amf_ue_ngap_id
).
get
()
!=
nullptr
)
{
return
true
;
}
}
return
false
;
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
...
...
src/itti/itti_msg.hpp
View file @
e1765115
...
@@ -72,7 +72,10 @@ typedef enum {
...
@@ -72,7 +72,10 @@ typedef enum {
PDU_SESSION_RESOURCE_SETUP_REQUEST
,
PDU_SESSION_RESOURCE_SETUP_REQUEST
,
PDU_SESSION_RESOURCE_MODIFY_REQUEST
,
PDU_SESSION_RESOURCE_MODIFY_REQUEST
,
PDU_SESSION_RESOURCE_RELEASE_COMMAND
,
PDU_SESSION_RESOURCE_RELEASE_COMMAND
,
PDU_SESSION_RESOURCE_SETUP_RESPONSE
,
NSMF_PDU_SESSION_RELEASE_SM_CTX
,
UE_CONTEXT_RELEASE_REQUEST
,
UE_CONTEXT_RELEASE_REQUEST
,
UE_CONTEXT_RELEASE_COMMAND
,
UE_CONTEXT_RELEASE_COMPLETE
,
UE_CONTEXT_RELEASE_COMPLETE
,
UE_RADIO_CAP_IND
,
UE_RADIO_CAP_IND
,
UL_NAS_DATA_IND
,
// task amf_n1 message id
UL_NAS_DATA_IND
,
// task amf_n1 message id
...
@@ -95,13 +98,10 @@ typedef enum {
...
@@ -95,13 +98,10 @@ typedef enum {
SBI_NOTIFICATION_DATA
,
SBI_NOTIFICATION_DATA
,
SBI_NOTIFY_SUBSCRIBED_EVENT
,
SBI_NOTIFY_SUBSCRIBED_EVENT
,
SBI_N1_MESSAGE_NOTIFICATION
,
SBI_N1_MESSAGE_NOTIFICATION
,
UE_CONTEXT_RELEASE_COMMAND
,
NSMF_PDU_SESSION_RELEASE_SM_CTX
,
HANDOVER_REQUIRED
,
HANDOVER_REQUIRED
,
HANDOVER_REQUEST_ACK
,
HANDOVER_REQUEST_ACK
,
HANDOVER_NOTIFY
,
HANDOVER_NOTIFY
,
UPLINK_RAN_STATUS_TRANSFER
,
UPLINK_RAN_STATUS_TRANSFER
,
PDU_SESSION_RESOURCE_SETUP_RESPONSE
,
PAGING
,
PAGING
,
TIME_OUT
,
TIME_OUT
,
HEALTH_PING
,
HEALTH_PING
,
...
...
src/itti/msgs/itti_msg_n11.hpp
View file @
e1765115
...
@@ -119,11 +119,15 @@ class itti_nsmf_pdusession_release_sm_context : public itti_msg_n11 {
...
@@ -119,11 +119,15 @@ class itti_nsmf_pdusession_release_sm_context : public itti_msg_n11 {
:
itti_msg_n11
(
i
)
{
:
itti_msg_n11
(
i
)
{
supi
=
i
.
supi
;
supi
=
i
.
supi
;
pdu_session_id
=
i
.
pdu_session_id
;
pdu_session_id
=
i
.
pdu_session_id
;
promise_id
=
i
.
promise_id
;
context_location
=
i
.
context_location
;
}
}
public:
public:
std
::
string
supi
;
std
::
string
supi
;
uint8_t
pdu_session_id
;
uint8_t
pdu_session_id
;
uint32_t
promise_id
;
std
::
string
context_location
;
};
};
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
...
...
src/nas/ies/_5GSDeregistrationType.cpp
View file @
e1765115
...
@@ -47,7 +47,7 @@ _5GSDeregistrationType::_5GSDeregistrationType(
...
@@ -47,7 +47,7 @@ _5GSDeregistrationType::_5GSDeregistrationType(
_5gs_deregistration_type_t
type
)
{
_5gs_deregistration_type_t
type
)
{
u1
.
b
=
0
;
u1
.
b
=
0
;
u1
.
bf
.
switch_off
=
type
.
switch_off
;
u1
.
bf
.
switch_off
=
type
.
switch_off
;
u1
.
bf
.
dereg_required
=
type
.
dereg
_required
;
u1
.
bf
.
re_registration_required
=
type
.
re_registration
_required
;
u1
.
bf
.
access_type
=
type
.
access_type
;
u1
.
bf
.
access_type
=
type
.
access_type
;
u1
.
bf
.
iei
=
type
.
iei
;
u1
.
bf
.
iei
=
type
.
iei
;
}
}
...
@@ -59,7 +59,7 @@ _5GSDeregistrationType::~_5GSDeregistrationType() {}
...
@@ -59,7 +59,7 @@ _5GSDeregistrationType::~_5GSDeregistrationType() {}
void
_5GSDeregistrationType
::
set
(
_5gs_deregistration_type_t
type
)
{
void
_5GSDeregistrationType
::
set
(
_5gs_deregistration_type_t
type
)
{
u1
.
b
=
0
;
u1
.
b
=
0
;
u1
.
bf
.
switch_off
=
type
.
switch_off
;
u1
.
bf
.
switch_off
=
type
.
switch_off
;
u1
.
bf
.
dereg_required
=
type
.
dereg
_required
;
u1
.
bf
.
re_registration_required
=
type
.
re_registration
_required
;
u1
.
bf
.
access_type
=
type
.
access_type
;
u1
.
bf
.
access_type
=
type
.
access_type
;
u1
.
bf
.
iei
=
type
.
iei
;
u1
.
bf
.
iei
=
type
.
iei
;
}
}
...
@@ -67,7 +67,7 @@ void _5GSDeregistrationType::set(_5gs_deregistration_type_t type) {
...
@@ -67,7 +67,7 @@ void _5GSDeregistrationType::set(_5gs_deregistration_type_t type) {
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void
_5GSDeregistrationType
::
get
(
_5gs_deregistration_type_t
&
type
)
{
void
_5GSDeregistrationType
::
get
(
_5gs_deregistration_type_t
&
type
)
{
type
.
switch_off
=
u1
.
bf
.
switch_off
;
type
.
switch_off
=
u1
.
bf
.
switch_off
;
type
.
dereg_required
=
u1
.
bf
.
dereg
_required
;
type
.
re_registration_required
=
u1
.
bf
.
re_registration
_required
;
type
.
access_type
=
u1
.
bf
.
access_type
;
type
.
access_type
=
u1
.
bf
.
access_type
;
type
.
iei
=
u1
.
bf
.
iei
;
type
.
iei
=
u1
.
bf
.
iei
;
}
}
...
...
src/nas/ies/_5GSDeregistrationType.hpp
View file @
e1765115
...
@@ -35,7 +35,7 @@ namespace nas {
...
@@ -35,7 +35,7 @@ namespace nas {
typedef
struct
_5gs_deregistration_type_s
{
typedef
struct
_5gs_deregistration_type_s
{
uint8_t
iei
:
4
;
uint8_t
iei
:
4
;
uint8_t
switch_off
:
1
;
uint8_t
switch_off
:
1
;
uint8_t
dereg
_required
:
1
;
uint8_t
re_registration
_required
:
1
;
uint8_t
access_type
:
2
;
uint8_t
access_type
:
2
;
}
_5gs_deregistration_type_t
;
}
_5gs_deregistration_type_t
;
...
@@ -58,7 +58,7 @@ class _5GSDeregistrationType {
...
@@ -58,7 +58,7 @@ class _5GSDeregistrationType {
struct
{
struct
{
uint8_t
iei
:
4
;
uint8_t
iei
:
4
;
uint8_t
switch_off
:
1
;
uint8_t
switch_off
:
1
;
uint8_t
dereg
_required
:
1
;
uint8_t
re_registration
_required
:
1
;
uint8_t
access_type
:
2
;
uint8_t
access_type
:
2
;
}
bf
;
}
bf
;
uint8_t
b
;
uint8_t
b
;
...
...
src/nas/msgs/DeregistrationRequest.cpp
View file @
e1765115
...
@@ -37,10 +37,10 @@ using namespace nas;
...
@@ -37,10 +37,10 @@ using namespace nas;
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
DeregistrationRequest
::
DeregistrationRequest
()
{
DeregistrationRequest
::
DeregistrationRequest
()
{
plain_header
=
NULL
;
plain_header
=
nullptr
;
ie_deregistrationtype
=
NULL
;
ie_deregistrationtype
=
nullptr
;
ie_ngKSI
=
NULL
;
ie_ngKSI
=
nullptr
;
ie_5gs_mobility_id
=
NULL
;
ie_5gs_mobility_id
=
nullptr
;
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
...
@@ -72,13 +72,13 @@ void DeregistrationRequest::setngKSI(uint8_t tsc, uint8_t key_set_id) {
...
@@ -72,13 +72,13 @@ void DeregistrationRequest::setngKSI(uint8_t tsc, uint8_t key_set_id) {
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void
DeregistrationRequest
::
getDeregistrationType
(
uint8_t
&
dereg_type
)
{
void
DeregistrationRequest
::
getDeregistrationType
(
uint8_t
&
dereg_type
)
{
ie_deregistrationtype
->
get
(
dereg_type
);
i
f
(
ie_deregistrationtype
)
i
e_deregistrationtype
->
get
(
dereg_type
);
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void
DeregistrationRequest
::
getDeregistrationType
(
void
DeregistrationRequest
::
getDeregistrationType
(
_5gs_deregistration_type_t
&
type
)
{
_5gs_deregistration_type_t
&
type
)
{
ie_deregistrationtype
->
get
(
type
);
i
f
(
ie_deregistrationtype
)
i
e_deregistrationtype
->
get
(
type
);
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
...
@@ -99,8 +99,8 @@ void DeregistrationRequest::setSUCI_SUPI_format_IMSI(
...
@@ -99,8 +99,8 @@ void DeregistrationRequest::setSUCI_SUPI_format_IMSI(
uint8_t
protection_sch_id
,
const
string
msin
)
{
uint8_t
protection_sch_id
,
const
string
msin
)
{
if
(
protection_sch_id
!=
NULL_SCHEME
)
{
if
(
protection_sch_id
!=
NULL_SCHEME
)
{
Logger
::
nas_mm
().
error
(
Logger
::
nas_mm
().
error
(
"
encoding suci and supi format for imsi error, please choose righ
t "
"
Encoding SUCI and SUPI format for IMSI error, please choose correc
t "
"
interfac
e"
);
"
protection schem
e"
);
return
;
return
;
}
else
{
}
else
{
ie_5gs_mobility_id
=
ie_5gs_mobility_id
=
...
@@ -184,7 +184,7 @@ int DeregistrationRequest::encode2buffer(uint8_t* buf, int len) {
...
@@ -184,7 +184,7 @@ int DeregistrationRequest::encode2buffer(uint8_t* buf, int len) {
return
0
;
return
0
;
}
}
}
else
{
}
else
{
Logger
::
nas_mm
().
error
(
"Encoding IE Deregistration
t
Type error"
);
Logger
::
nas_mm
().
error
(
"Encoding IE Deregistration Type error"
);
return
0
;
return
0
;
}
}
if
(
int
size
=
ie_5gs_mobility_id
->
encode2buffer
(
if
(
int
size
=
ie_5gs_mobility_id
->
encode2buffer
(
...
...
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