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
c84bc571
Commit
c84bc571
authored
Apr 25, 2021
by
yangjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test the project of the university of information engineering
parent
558a4917
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
567 additions
and
27 deletions
+567
-27
src/amf-app/amf_app.cpp
src/amf-app/amf_app.cpp
+16
-0
src/amf-app/amf_app.hpp
src/amf-app/amf_app.hpp
+1
-0
src/amf-app/amf_n1.cpp
src/amf-app/amf_n1.cpp
+240
-6
src/amf-app/amf_n1.hpp
src/amf-app/amf_n1.hpp
+8
-0
src/contexts/nas_context.cpp
src/contexts/nas_context.cpp
+1
-1
src/itti/itti_msg.hpp
src/itti/itti_msg.hpp
+1
-0
src/itti/msgs/itti_msg_amf_app.hpp
src/itti/msgs/itti_msg_amf_app.hpp
+12
-0
src/nas/ies/_5GSDeregistrationType.cpp
src/nas/ies/_5GSDeregistrationType.cpp
+3
-1
src/nas/msgs/DeregistrationRequest.cpp
src/nas/msgs/DeregistrationRequest.cpp
+35
-13
src/nas/msgs/DeregistrationRequest.hpp
src/nas/msgs/DeregistrationRequest.hpp
+1
-0
src/nas/msgs/RegistrationRequest.cpp
src/nas/msgs/RegistrationRequest.cpp
+7
-6
src/sbi/amf_server/AMFApiServer.cpp
src/sbi/amf_server/AMFApiServer.cpp
+7
-0
src/sbi/amf_server/AMFApiServer.hpp
src/sbi/amf_server/AMFApiServer.hpp
+9
-0
src/sbi/amf_server/api/TestSignallingApi.cpp
src/sbi/amf_server/api/TestSignallingApi.cpp
+68
-0
src/sbi/amf_server/api/TestSignallingApi.h
src/sbi/amf_server/api/TestSignallingApi.h
+51
-0
src/sbi/amf_server/impl/TestSignallingApiImpl.cpp
src/sbi/amf_server/impl/TestSignallingApiImpl.cpp
+63
-0
src/sbi/amf_server/impl/TestSignallingApiImpl.h
src/sbi/amf_server/impl/TestSignallingApiImpl.h
+44
-0
No files found.
src/amf-app/amf_app.cpp
View file @
c84bc571
...
...
@@ -118,6 +118,13 @@ void amf_app_task(void*) {
amf_app_inst
->
handle_itti_message
(
ref
(
*
m
));
}
break
;
case
TEST_SIGNALLING_NETWORK_INITIATED_DEREGISTRAATION
:
{
Logger
::
amf_app
().
debug
(
"Received TEST_SIGNALLING_NETWORK_INITIATED_DEREGISTRAATION"
);
itti_test_signalling_network_initiated_deregistration
*
m
=
dynamic_cast
<
itti_test_signalling_network_initiated_deregistration
*>
(
msg
);
amf_app_inst
->
handle_itti_message
(
ref
(
*
m
));
}
break
;
case
TIME_OUT
:
if
(
itti_msg_timeout
*
to
=
dynamic_cast
<
itti_msg_timeout
*>
(
msg
))
{
switch
(
to
->
arg1_user
)
{
...
...
@@ -208,6 +215,15 @@ void amf_app::handle_itti_message(
}
}
//------------------------------------------------------------------------------
void
amf_app
::
handle_itti_message
(
itti_test_signalling_network_initiated_deregistration
&
itti_msg
)
{
amf_n1_inst
->
network_initiate_de_registration_handle
(
itti_msg
.
ran_ue_ngap_id
,
itti_msg
.
amf_ue_ngap_id
);
}
//------------------------------------------------------------------------------
void
amf_app
::
handle_itti_message
(
...
...
src/amf-app/amf_app.hpp
View file @
c84bc571
...
...
@@ -56,6 +56,7 @@ class amf_app {
void
handle_itti_message
(
itti_nas_signalling_establishment_request
&
itti_msg
);
void
handle_itti_message
(
itti_n1n2_message_transfer_request
&
itti_msg
);
void
handle_itti_message
(
itti_paging_n1n2_message_transfer
&
itti_msg
);
void
handle_itti_message
(
itti_test_signalling_network_initiated_deregistration
&
itti_msg
);
// context management
std
::
map
<
long
,
std
::
shared_ptr
<
ue_context
>>
amf_ue_ngap_id2ue_ctx
;
mutable
std
::
shared_mutex
m_amf_ue_ngap_id2ue_ctx
;
...
...
src/amf-app/amf_n1.cpp
View file @
c84bc571
...
...
@@ -949,9 +949,18 @@ void amf_n1::registration_request_handle(bool isNasSig,
if
(
!
regReq
->
getUeSecurityCapability
(
encrypt_alg
,
integrity_alg
))
{
Logger
::
amf_n1
().
warn
(
"No Optional IE UESecurityCapability available"
);
}
else
{
nc
.
get
()
->
ueSecurityCaplen
=
regReq
->
ie_ue_security_capability
->
getLenght
();
}
nc
.
get
()
->
ueSecurityCapEnc
=
encrypt_alg
;
nc
.
get
()
->
ueSecurityCapInt
=
integrity_alg
;
nc
.
get
()
->
ueSecurityCaplen
=
regReq
->
ie_ue_security_capability
->
getLenght
();
uint16_t
pdu_session_status
=
0xffff
;
pdu_session_status
=
regReq
->
getPduSessionStatus
();
bool
is_messagecontainer
=
false
;
bstring
nas_msg
;
is_messagecontainer
=
regReq
->
getNasMessageContainer
(
nas_msg
);
// Get Requested NSSAI (Optional IE), if provided
std
::
vector
<
SNSSAI_t
>
requestedNssai
=
{};
...
...
@@ -977,11 +986,21 @@ void amf_n1::registration_request_handle(bool isNasSig,
}
break
;
case
MOBILITY_REGISTRATION_UPDATING
:
{
Logger
::
amf_n1
().
error
(
"Network handling mobility registration ..."
);
run_mobility_registration_update_procedure
(
nc
);
//run_mobility_registration_update_procedure(nc);
if
(
is_messagecontainer
)
run_periodic_registration_update_procedure
(
nc
,
nas_msg
);
else
run_periodic_registration_update_procedure
(
nc
,
pdu_session_status
);
}
break
;
case
PERIODIC_REGISTRATION_UPDATING
:
{
Logger
::
amf_n1
().
error
(
"Network doesn't support periodic registration, reject ..."
);
// Logger::amf_n1().error(
// "Network doesn't support periodic registration, reject ...");
Logger
::
amf_n1
().
debug
(
"Network handling periodic registration ..."
);
if
(
is_messagecontainer
)
run_periodic_registration_update_procedure
(
nc
,
nas_msg
);
else
run_periodic_registration_update_procedure
(
nc
,
pdu_session_status
);
}
break
;
case
EMERGENCY_REGISTRATION
:
{
if
(
!
amf_cfg
.
is_emergency_support
.
compare
(
"false"
))
{
...
...
@@ -2109,7 +2128,7 @@ void amf_n1::security_mode_complete_handle(uint32_t ran_ue_ngap_id,
// TODO: remove hardcoded values
regAccept
->
set_5GS_Network_Feature_Support
(
0x01
,
0x00
);
regAccept
->
setT3512_Value
(
0x5
,
0x
1e
);
regAccept
->
setT3512_Value
(
0x5
,
0x
01
);
uint8_t
buffer
[
BUFFER_SIZE_1024
]
=
{
0
};
int
encoded_size
=
regAccept
->
encode2buffer
(
buffer
,
BUFFER_SIZE_1024
);
print_buffer
(
"amf_n1"
,
"Registration-Accept message buffer"
,
buffer
,
...
...
@@ -2522,6 +2541,46 @@ void amf_n1::ue_initiate_de_registration_handle(uint32_t ran_ue_ngap_id,
}
}
//------------------------------------------------------------------------------
void
amf_n1
::
network_initiate_de_registration_handle
(
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
)
{
Logger
::
amf_n1
().
debug
(
"Handling network-initiated De-registration Request"
);
std
::
shared_ptr
<
nas_context
>
nc
;
if
(
is_amf_ue_id_2_nas_context
(
amf_ue_ngap_id
))
nc
=
amf_ue_id_2_nas_context
(
amf_ue_ngap_id
);
else
{
Logger
::
amf_n1
().
warn
(
"No existed nas_context with amf_ue_ngap_id(0x%x)"
,
amf_ue_ngap_id
);
return
;
}
// encode NAS msg
DeregistrationRequest
*
deregReq
=
new
DeregistrationRequest
();
deregReq
->
setHeader
(
PLAIN_5GS_MSG
,
DEREGISTRATION_REQUEST_UE_TERMINATED
);
deregReq
->
setDeregistrationType
(
0x05
);
uint8_t
buffer
[
BUFFER_SIZE_512
]
=
{
0
};
int
encoded_size
=
deregReq
->
encode2buffer
(
buffer
,
BUFFER_SIZE_512
);
print_buffer
(
"amf_n1"
,
"De-registration Request message buffer"
,
buffer
,
encoded_size
);
if
(
encoded_size
<
1
)
{
Logger
::
nas_mm
().
error
(
"Encode De-registration Request message error"
);
return
;
}
bstring
b
=
blk2bstr
(
buffer
,
encoded_size
);
itti_send_dl_nas_buffer_to_task_n2
(
b
,
ran_ue_ngap_id
,
amf_ue_ngap_id
);
set_5gmm_state
(
nc
,
_5GMM_DEREGISTERED
);
if
(
nc
.
get
()
->
is_stacs_available
)
{
stacs
.
update_5gmm_state
(
nc
.
get
()
->
imsi
,
"5GMM-DEREGISTERED"
);
}
}
//------------------------------------------------------------------------------
void
amf_n1
::
ul_nas_transport_handle
(
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
,
bstring
nas
)
{
...
...
@@ -2707,7 +2766,7 @@ void amf_n1::run_mobility_registration_update_procedure(
// encoding REGISTRATION ACCEPT
RegistrationAccept
*
regAccept
=
new
RegistrationAccept
();
regAccept
->
setHeader
(
PLAIN_5GS_MSG
);
regAccept
->
set_5GS_Registration_Result
(
false
,
false
,
fals
e
,
0x01
);
regAccept
->
set_5GS_Registration_Result
(
false
,
false
,
tru
e
,
0x01
);
regAccept
->
set5G_GUTI
(
amf_cfg
.
guami
.
mcc
,
amf_cfg
.
guami
.
mnc
,
amf_cfg
.
guami
.
regionID
,
amf_cfg
.
guami
.
AmfSetID
,
amf_cfg
.
guami
.
AmfPointer
,
0x264a34c0
);
...
...
@@ -2792,6 +2851,181 @@ void amf_n1::run_mobility_registration_update_procedure(
}
}
//------------------------------------------------------------------------------
void
amf_n1
::
run_periodic_registration_update_procedure
(
std
::
shared_ptr
<
nas_context
>
nc
,
uint16_t
pdu_session_status
)
{
// encoding REGISTRATION ACCEPT
RegistrationAccept
*
regAccept
=
new
RegistrationAccept
();
regAccept
->
setHeader
(
PLAIN_5GS_MSG
);
regAccept
->
set_5GS_Registration_Result
(
false
,
false
,
false
,
0x01
);
regAccept
->
set5G_GUTI
(
amf_cfg
.
guami
.
mcc
,
amf_cfg
.
guami
.
mnc
,
amf_cfg
.
guami
.
regionID
,
amf_cfg
.
guami
.
AmfSetID
,
amf_cfg
.
guami
.
AmfPointer
,
0x264a34c0
);
regAccept
->
setT3512_Value
(
0x5
,
0x1e
);
std
::
vector
<
p_tai_t
>
tai_list
;
p_tai_t
item0
;
item0
.
type
=
0x00
;
nas_plmn_t
plmn
;
plmn
.
mcc
=
amf_cfg
.
plmn_list
[
0
].
mcc
;
plmn
.
mnc
=
amf_cfg
.
plmn_list
[
0
].
mnc
;
item0
.
plmn_list
.
push_back
(
plmn
);
item0
.
tac_list
.
push_back
(
amf_cfg
.
plmn_list
[
0
].
tac
);
tai_list
.
push_back
(
item0
);
regAccept
->
setTaiList
(
tai_list
);
//
// std::vector<struct SNSSAI_s> nssai;
// SNSSAI_t snssai;
// snssai.sst = 0;
// snssai.sd = -1;
// snssai.mHplmnSst = -1;
// snssai.mHplmnSd = -1;
// nssai.push_back(snssai);
// regAccept->setALLOWED_NSSAI(nssai);
if
(
pdu_session_status
==
0x0000
)
{
regAccept
->
setPDU_session_status
(
0x0000
);
}
else
{
regAccept
->
setPDU_session_status
(
pdu_session_status
);
Logger
::
amf_n1
().
debug
(
"setting pdu session status 0x%02x"
,
htonl
(
pdu_session_status
));
// serApt->setPDU_session_status(0x2000);
}
regAccept
->
set_5GS_Network_Feature_Support
(
0x01
,
0x00
);
uint8_t
buffer
[
1024
]
=
{
0
};
int
encoded_size
=
regAccept
->
encode2buffer
(
buffer
,
1024
);
print_buffer
(
"amf_n1"
,
"Registration-Accept Message Buffer"
,
buffer
,
encoded_size
);
if
(
!
encoded_size
)
{
Logger
::
nas_mm
().
error
(
"Encode Registration-Accept message error"
);
return
;
}
else
{
delete
regAccept
;
}
nas_secu_ctx
*
secu
=
nc
.
get
()
->
security_ctx
;
// protect nas message
bstring
protectedNas
;
encode_nas_message_protected
(
secu
,
false
,
INTEGRITY_PROTECTED_AND_CIPHERED
,
NAS_MESSAGE_DOWNLINK
,
buffer
,
encoded_size
,
protectedNas
);
string
supi
=
"imsi-"
+
nc
.
get
()
->
imsi
;
Logger
::
amf_n1
().
debug
(
"Key for pdu session context SUPI (%s)"
,
supi
.
c_str
());
std
::
shared_ptr
<
pdu_session_context
>
psc
;
if
(
amf_n11_inst
->
is_supi_to_pdu_ctx
(
supi
))
{
psc
=
amf_n11_inst
->
supi_to_pdu_ctx
(
supi
);
}
else
{
Logger
::
amf_n1
().
error
(
"Cannot get pdu_session_context with SUPI (%s)"
,
supi
.
c_str
());
}
itti_dl_nas_transport
*
itti_msg
=
new
itti_dl_nas_transport
(
TASK_AMF_N1
,
TASK_AMF_N2
);
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
->
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
(
i
);
if
(
0
!=
ret
)
{
Logger
::
amf_n1
().
error
(
"Could not send ITTI message %s to task TASK_AMF_N2"
,
i
->
get_msg_name
());
}
}
//------------------------------------------------------------------------------
void
amf_n1
::
run_periodic_registration_update_procedure
(
std
::
shared_ptr
<
nas_context
>
nc
,
bstring
&
nas_msg
)
{
// decoding REGISTRATION request
RegistrationRequest
*
regReq
=
new
RegistrationRequest
();
regReq
->
decodefrombuffer
(
nullptr
,
(
uint8_t
*
)
bdata
(
nas_msg
),
blength
(
nas_msg
));
bdestroy
(
nas_msg
);
// free buffer
// encoding REGISTRATION ACCEPT
RegistrationAccept
*
regAccept
=
new
RegistrationAccept
();
regAccept
->
setHeader
(
PLAIN_5GS_MSG
);
regAccept
->
set_5GS_Registration_Result
(
false
,
false
,
false
,
0x01
);
regAccept
->
set5G_GUTI
(
amf_cfg
.
guami
.
mcc
,
amf_cfg
.
guami
.
mnc
,
amf_cfg
.
guami
.
regionID
,
amf_cfg
.
guami
.
AmfSetID
,
amf_cfg
.
guami
.
AmfPointer
,
0x264a34c0
);
regAccept
->
setT3512_Value
(
0x5
,
0x1e
);
std
::
vector
<
p_tai_t
>
tai_list
;
p_tai_t
item0
;
item0
.
type
=
0x00
;
nas_plmn_t
plmn
;
plmn
.
mcc
=
amf_cfg
.
plmn_list
[
0
].
mcc
;
plmn
.
mnc
=
amf_cfg
.
plmn_list
[
0
].
mnc
;
item0
.
plmn_list
.
push_back
(
plmn
);
item0
.
tac_list
.
push_back
(
amf_cfg
.
plmn_list
[
0
].
tac
);
tai_list
.
push_back
(
item0
);
regAccept
->
setTaiList
(
tai_list
);
//
// std::vector<struct SNSSAI_s> nssai;
// SNSSAI_t snssai;
// snssai.sst = 0;
// snssai.sd = -1;
// snssai.mHplmnSst = -1;
// snssai.mHplmnSd = -1;
// nssai.push_back(snssai);
// regAccept->setALLOWED_NSSAI(nssai);
uint16_t
pdu_session_status
=
0xffff
;
pdu_session_status
=
regReq
->
getPduSessionStatus
();
if
(
pdu_session_status
==
0x0000
)
{
regAccept
->
setPDU_session_status
(
0x0000
);
}
else
{
regAccept
->
setPDU_session_status
(
pdu_session_status
);
Logger
::
amf_n1
().
debug
(
"setting pdu session status 0x%02x"
,
htonl
(
pdu_session_status
));
// serApt->setPDU_session_status(0x2000);
}
delete
regReq
;
regAccept
->
set_5GS_Network_Feature_Support
(
0x01
,
0x00
);
uint8_t
buffer
[
1024
]
=
{
0
};
int
encoded_size
=
regAccept
->
encode2buffer
(
buffer
,
1024
);
print_buffer
(
"amf_n1"
,
"Registration-Accept Message Buffer"
,
buffer
,
encoded_size
);
if
(
!
encoded_size
)
{
Logger
::
nas_mm
().
error
(
"Encode Registration-Accept message error"
);
return
;
}
else
{
delete
regAccept
;
}
nas_secu_ctx
*
secu
=
nc
.
get
()
->
security_ctx
;
// protect nas message
bstring
protectedNas
;
encode_nas_message_protected
(
secu
,
false
,
INTEGRITY_PROTECTED_AND_CIPHERED
,
NAS_MESSAGE_DOWNLINK
,
buffer
,
encoded_size
,
protectedNas
);
string
supi
=
"imsi-"
+
nc
.
get
()
->
imsi
;
Logger
::
amf_n1
().
debug
(
"Key for pdu session context SUPI (%s)"
,
supi
.
c_str
());
std
::
shared_ptr
<
pdu_session_context
>
psc
;
if
(
amf_n11_inst
->
is_supi_to_pdu_ctx
(
supi
))
{
psc
=
amf_n11_inst
->
supi_to_pdu_ctx
(
supi
);
}
else
{
Logger
::
amf_n1
().
error
(
"Cannot get pdu_session_context with SUPI (%s)"
,
supi
.
c_str
());
}
itti_dl_nas_transport
*
itti_msg
=
new
itti_dl_nas_transport
(
TASK_AMF_N1
,
TASK_AMF_N2
);
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
->
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
(
i
);
if
(
0
!=
ret
)
{
Logger
::
amf_n1
().
error
(
"Could not send ITTI message %s to task TASK_AMF_N2"
,
i
->
get_msg_name
());
}
}
//------------------------------------------------------------------------------
void
amf_n1
::
set_5gmm_state
(
std
::
shared_ptr
<
nas_context
>
nc
,
_5gmm_state_t
state
)
{
...
...
src/amf-app/amf_n1.hpp
View file @
c84bc571
...
...
@@ -104,6 +104,11 @@ class amf_n1 {
void
run_initial_registration_procedure
();
void
run_mobility_registration_update_procedure
(
std
::
shared_ptr
<
nas_context
>
nc
);
void
run_periodic_registration_update_procedure
(
std
::
shared_ptr
<
nas_context
>
nc
,
uint16_t
);
void
run_periodic_registration_update_procedure
(
std
::
shared_ptr
<
nas_context
>
nc
,
bstring
&
nas_msg
);
// authentication
bool
auth_vectors_generator
(
std
::
shared_ptr
<
nas_context
>&
nc
);
...
...
@@ -159,6 +164,9 @@ class amf_n1 {
void
set_5gmm_state
(
std
::
shared_ptr
<
nas_context
>
nc
,
_5gmm_state_t
state
);
void
get_5gmm_state
(
std
::
shared_ptr
<
nas_context
>
nc
,
_5gmm_state_t
&
state
);
void
network_initiate_de_registration_handle
(
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
);
private:
// nas message handlers
void
ue_initiate_de_registration_handle
(
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
,
bstring
nas
);
...
...
src/contexts/nas_context.cpp
View file @
c84bc571
...
...
@@ -42,7 +42,7 @@ nas_context::nas_context() {
is_common_procedure_for_security_mode_control_running
=
false
;
is_common_procedure_for_nas_transport_running
=
false
;
auts
=
NULL
;
ueSecurityCaplen
=
0
;
ueSecurityCaplen
=
2
;
}
//------------------------------------------------------------------------------
...
...
src/itti/itti_msg.hpp
View file @
c84bc571
...
...
@@ -83,6 +83,7 @@ typedef enum {
UPLINKRANSTATUSTRANSFER
,
PDU_SESS_RES_SET_RESP
,
PAGING_N1N2_MESSAGE_TRANSFER
,
TEST_SIGNALLING_NETWORK_INITIATED_DEREGISTRAATION
,
PAGING
,
TIME_OUT
,
HEALTH_PING
,
...
...
src/itti/msgs/itti_msg_amf_app.hpp
View file @
c84bc571
...
...
@@ -72,5 +72,17 @@ class itti_paging_n1n2_message_transfer : public itti_msg_amf_app {
plmn_t
plmn
;
};
class
itti_test_signalling_network_initiated_deregistration
:
public
itti_msg_amf_app
{
public:
itti_test_signalling_network_initiated_deregistration
(
const
task_id_t
origin
,
const
task_id_t
destination
)
:
itti_msg_amf_app
(
TEST_SIGNALLING_NETWORK_INITIATED_DEREGISTRAATION
,
origin
,
destination
)
{}
itti_test_signalling_network_initiated_deregistration
(
const
itti_test_signalling_network_initiated_deregistration
&
i
)
:
itti_msg_amf_app
(
i
)
{}
public:
uint32_t
ran_ue_ngap_id
;
long
amf_ue_ngap_id
;
};
#endif
src/nas/ies/_5GSDeregistrationType.cpp
View file @
c84bc571
...
...
@@ -83,13 +83,15 @@ void _5GSDeregistrationType::get(uint8_t& type) {
//------------------------------------------------------------------------------
int
_5GSDeregistrationType
::
encode2buffer
(
uint8_t
*
buf
,
int
len
)
{
Logger
::
nas_mm
().
error
(
"Encoding 5GSDeregistrationType IE"
);
Logger
::
nas_mm
().
debug
(
"Encoding 5GSDeregistrationType (0x%x)"
,
u1
.
b
);
if
(
len
<
1
)
{
Logger
::
nas_mm
().
error
(
"encoding 5GSDeregistrationType error(len is less than one)"
);
return
-
1
;
}
*
buf
=
u1
.
b
;
return
0
;
}
//------------------------------------------------------------------------------
...
...
src/nas/msgs/DeregistrationRequest.cpp
View file @
c84bc571
...
...
@@ -51,6 +51,14 @@ void DeregistrationRequest::setHeader(uint8_t security_header_type) {
EPD_5GS_MM_MSG
,
security_header_type
,
DEREGISTRATION_REQUEST_UE_ORIGINATING
);
}
//------------------------------------------------------------------------------
void
DeregistrationRequest
::
setHeader
(
uint8_t
security_header_type
,
uint8_t
msg_type
)
{
plain_header
=
new
NasMmPlainHeader
();
plain_header
->
setHeader
(
EPD_5GS_MM_MSG
,
security_header_type
,
msg_type
);
}
//------------------------------------------------------------------------------
void
DeregistrationRequest
::
setDeregistrationType
(
uint8_t
dereg_type
)
{
...
...
@@ -161,11 +169,11 @@ int DeregistrationRequest::encode2buffer(uint8_t* buf, int len) {
Logger
::
nas_mm
().
error
(
"Mandatory IE missing Deregistration Type"
);
return
0
;
}
if
(
!
ie_ngKSI
)
{
if
(
(
!
ie_ngKSI
)
&&
(
plain_header
->
getMessageType
()
==
DEREGISTRATION_REQUEST_UE_ORIGINATING
)
)
{
Logger
::
nas_mm
().
error
(
"Mandatory IE missing ie_ngKSI"
);
return
0
;
}
if
(
!
ie_5gs_mobility_id
)
{
if
(
(
!
ie_5gs_mobility_id
)
&&
(
plain_header
->
getMessageType
()
==
DEREGISTRATION_REQUEST_UE_ORIGINATING
)
)
{
Logger
::
nas_mm
().
error
(
"Mandatory IE missing ie_5gs_mobility_id"
);
return
0
;
}
...
...
@@ -173,27 +181,41 @@ int DeregistrationRequest::encode2buffer(uint8_t* buf, int len) {
encoded_size
+=
3
;
if
(
!
(
ie_deregistrationtype
->
encode2buffer
(
buf
+
encoded_size
,
len
-
encoded_size
)))
{
if
(
!
(
ie_ngKSI
->
encode2buffer
(
buf
+
encoded_size
,
len
-
encoded_size
)))
{
if
(
plain_header
->
getMessageType
()
==
DEREGISTRATION_REQUEST_UE_ORIGINATING
)
{
if
(
!
(
ie_ngKSI
->
encode2buffer
(
buf
+
encoded_size
,
len
-
encoded_size
)))
{
encoded_size
+=
1
;
}
else
{
Logger
::
nas_mm
().
error
(
"Encoding IE ie_ngKSI error"
);
return
0
;
}
}
else
{
encoded_size
+=
1
;
}
else
{
Logger
::
nas_mm
().
error
(
"Encoding IE ie_ngKSI error"
);
return
0
;
}
}
else
{
Logger
::
nas_mm
().
error
(
"Encoding IE Deregistrationt Type error"
);
return
0
;
}
if
(
int
size
=
ie_5gs_mobility_id
->
encode2buffer
(
buf
+
encoded_size
,
len
-
encoded_size
))
{
encoded_size
+=
size
;
}
else
{
Logger
::
nas_mm
().
error
(
"Encoding IE ie_5gs_mobility_id error"
);
return
0
;
if
(
plain_header
->
getMessageType
()
==
DEREGISTRATION_REQUEST_UE_ORIGINATING
)
{
if
(
int
size
=
ie_5gs_mobility_id
->
encode2buffer
(
buf
+
encoded_size
,
len
-
encoded_size
))
{
encoded_size
+=
size
;
}
else
{
Logger
::
nas_mm
().
error
(
"Encoding IE ie_5gs_mobility_id error"
);
return
0
;
}
}
*
(
buf
+
encoded_size
)
=
0x58
;
encoded_size
+=
1
;
*
(
buf
+
encoded_size
)
=
74
;
encoded_size
+=
1
;
Logger
::
nas_mm
().
debug
(
"Encoded DeregistrationRequest message len (%d)"
,
encoded_size
);
return
1
;
return
encoded_size
;
}
//------------------------------------------------------------------------------
...
...
src/nas/msgs/DeregistrationRequest.hpp
View file @
c84bc571
...
...
@@ -41,6 +41,7 @@ class DeregistrationRequest {
int
encode2buffer
(
uint8_t
*
buf
,
int
len
);
int
decodefrombuffer
(
NasMmPlainHeader
*
header
,
uint8_t
*
buf
,
int
len
);
void
setHeader
(
uint8_t
security_header_type
);
void
setHeader
(
uint8_t
security_header_type
,
uint8_t
msg_type
);
void
setDeregistrationType
(
uint8_t
dereg_type
);
void
setDeregistrationType
(
_5gs_deregistration_type_t
type
);
void
setngKSI
(
uint8_t
tsc
,
uint8_t
key_set_id
);
...
...
src/nas/msgs/RegistrationRequest.cpp
View file @
c84bc571
...
...
@@ -231,8 +231,9 @@ bool RegistrationRequest::getUeSecurityCapability(uint8_t& ea, uint8_t& ia) {
ea
=
ie_ue_security_capability
->
getEASel
();
ia
=
ie_ue_security_capability
->
getIASel
();
}
else
{
return
-
1
;
return
false
;
}
return
true
;
}
//------------------------------------------------------------------------------
...
...
@@ -299,7 +300,7 @@ uint16_t RegistrationRequest::getPduSessionStatus() {
if
(
ie_PDU_session_status
)
{
return
ie_PDU_session_status
->
getValue
();
}
else
{
return
-
1
;
return
0
;
}
}
...
...
@@ -386,9 +387,9 @@ void RegistrationRequest::setEPS_NAS_Message_Container(bstring value) {
bool
RegistrationRequest
::
getEpsNasMessageContainer
(
bstring
&
epsNas
)
{
if
(
ie_eps_nas_message_container
)
{
ie_eps_nas_message_container
->
getValue
(
epsNas
);
return
0
;
return
true
;
}
else
{
return
-
1
;
return
false
;
}
}
...
...
@@ -486,9 +487,9 @@ void RegistrationRequest::setNAS_Message_Container(bstring value) {
bool
RegistrationRequest
::
getNasMessageContainer
(
bstring
&
nas
)
{
if
(
ie_nas_message_container
)
{
ie_nas_message_container
->
getValue
(
nas
);
return
0
;
return
true
;
}
else
{
return
-
1
;
return
false
;
}
}
...
...
src/sbi/amf_server/AMFApiServer.cpp
View file @
c84bc571
...
...
@@ -17,6 +17,8 @@ void AMFApiServer::init(size_t thr) {
m_nonUEN2MessagesCollectionDocumentApiImpl
->
init
();
m_nonUEN2MessagesSubscriptionsCollectionDocumentApiImpl
->
init
();
m_subscriptionsCollectionDocumentApiImpl
->
init
();
m_testSignallingApiImpl
->
init
();
Logger
::
amf_server
().
debug
(
"Initiate AMF server endpoints done!"
);
}
...
...
@@ -53,6 +55,11 @@ void AMFApiServer::start() {
if
(
m_subscriptionsCollectionDocumentApiImpl
!=
nullptr
)
Logger
::
amf_server
().
debug
(
"AMF handler for SubscriptionsCollectionDocumentApiImpl"
);
if
(
m_testSignallingApiImpl
!=
nullptr
)
Logger
::
amf_server
().
debug
(
"AMF handler for TestSignallingApiImpl"
);
m_httpEndpoint
->
setHandler
(
m_router
->
handler
());
m_httpEndpoint
->
serve
();
}
...
...
src/sbi/amf_server/AMFApiServer.hpp
View file @
c84bc571
...
...
@@ -17,6 +17,8 @@
#include "NonUEN2MessagesSubscriptionsCollectionDocumentApiImpl.h"
#include "SubscriptionsCollectionDocumentApiImpl.h"
#include "TestSignallingApiImpl.h"
#define PISTACHE_SERVER_THREADS 2
#define PISTACHE_SERVER_MAX_PAYLOAD 32768
...
...
@@ -59,6 +61,10 @@ class AMFApiServer {
m_subscriptionsCollectionDocumentApiImpl
=
std
::
make_shared
<
SubscriptionsCollectionDocumentApiImpl
>
(
m_router
,
amf_app_inst
);
m_testSignallingApiImpl
=
std
::
make_shared
<
TestSignallingApiImpl
>
(
m_router
,
amf_app_inst
);
}
void
init
(
size_t
thr
=
1
);
...
...
@@ -88,4 +94,7 @@ class AMFApiServer {
m_nonUEN2MessagesSubscriptionsCollectionDocumentApiImpl
;
std
::
shared_ptr
<
SubscriptionsCollectionDocumentApiImpl
>
m_subscriptionsCollectionDocumentApiImpl
;
std
::
shared_ptr
<
TestSignallingApiImpl
>
m_testSignallingApiImpl
;
};
src/sbi/amf_server/api/TestSignallingApi.cpp
0 → 100644
View file @
c84bc571
#include "TestSignallingApi.h"
namespace
oai
{
namespace
amf
{
namespace
api
{
TestSignallingApi
::
TestSignallingApi
(
std
::
shared_ptr
<
Pistache
::
Rest
::
Router
>
rtr
)
{
router
=
rtr
;
}
void
TestSignallingApi
::
init
()
{
setupRoutes
();
}
void
TestSignallingApi
::
setupRoutes
()
{
using
namespace
Pistache
::
Rest
;
Routes
::
Post
(
*
router
,
base
+
"/test-signalling/network-initiated-deregistration/:subscriptionId"
,
Routes
::
bind
(
&
TestSignallingApi
::
test_signalling_network_initiated_deregistration_handler
,
this
));
// Default handler, called when a route is not found
router
->
addCustomHandler
(
Routes
::
bind
(
&
TestSignallingApi
::
test_signalling_api_default_handler
,
this
));
}
void
TestSignallingApi
::
test_signalling_network_initiated_deregistration_handler
(
const
Pistache
::
Rest
::
Request
&
request
,
Pistache
::
Http
::
ResponseWriter
response
)
{
// Getting the path params
auto
subscriptionId
=
request
.
param
(
":subscriptionId"
).
as
<
std
::
string
>
();
try
{
this
->
test_signalling_network_initiated_deregistration
(
subscriptionId
,
response
);
}
catch
(
nlohmann
::
detail
::
exception
&
e
)
{
// send a 400 error
response
.
send
(
Pistache
::
Http
::
Code
::
Bad_Request
,
e
.
what
());
return
;
}
catch
(
std
::
exception
&
e
)
{
// send a 500 error
response
.
send
(
Pistache
::
Http
::
Code
::
Internal_Server_Error
,
e
.
what
());
return
;
}
}
void
TestSignallingApi
::
test_signalling_api_default_handler
(
const
Pistache
::
Rest
::
Request
&
,
Pistache
::
Http
::
ResponseWriter
response
)
{
response
.
send
(
Pistache
::
Http
::
Code
::
Not_Found
,
"The requested method does not exist"
);
}
}
// namespace api
}
// namespace amf
}
// namespace oai
src/sbi/amf_server/api/TestSignallingApi.h
0 → 100644
View file @
c84bc571
#ifndef _TESTSIGNALLING_API_H_
#define _TESTSIGNALLING_API_H_
#include <pistache/http.h>
#include <pistache/router.h>
#include <pistache/http_headers.h>
#include <pistache/optional.h>
#include <nlohmann/json.hpp>
#include "ProblemDetails.h"
#include <string>
namespace
oai
{
namespace
amf
{
namespace
api
{
class
TestSignallingApi
{
public:
TestSignallingApi
(
std
::
shared_ptr
<
Pistache
::
Rest
::
Router
>
);
virtual
~
TestSignallingApi
()
{}
void
init
();
const
std
::
string
base
=
"/namf-test/v1"
;
private:
void
setupRoutes
();
void
test_signalling_network_initiated_deregistration_handler
(
const
Pistache
::
Rest
::
Request
&
request
,
Pistache
::
Http
::
ResponseWriter
response
);
void
test_signalling_api_default_handler
(
const
Pistache
::
Rest
::
Request
&
request
,
Pistache
::
Http
::
ResponseWriter
response
);
std
::
shared_ptr
<
Pistache
::
Rest
::
Router
>
router
;
virtual
void
test_signalling_network_initiated_deregistration
(
const
std
::
string
&
subscriptionId
,
Pistache
::
Http
::
ResponseWriter
&
response
)
=
0
;
};
}
// namespace api
}
// namespace amf
}
// namespace oai
#endif
src/sbi/amf_server/impl/TestSignallingApiImpl.cpp
0 → 100644
View file @
c84bc571
#include "TestSignallingApiImpl.h"
#include "itti.hpp"
#include "amf_n11.hpp"
#include "pdu_session_context.hpp"
using
namespace
amf_application
;
//using namespace ngap;
extern
itti_mw
*
itti_inst
;
extern
amf_n11
*
amf_n11_inst
;
namespace
oai
{
namespace
amf
{
namespace
api
{
TestSignallingApiImpl
::
TestSignallingApiImpl
(
std
::
shared_ptr
<
Pistache
::
Rest
::
Router
>
rtr
,
amf_application
::
amf_app
*
amf_app_inst
)
:
TestSignallingApi
(
rtr
),
m_amf_app
(
amf_app_inst
)
{}
void
TestSignallingApiImpl
::
test_signalling_network_initiated_deregistration
(
const
std
::
string
&
subscriptionId
,
Pistache
::
Http
::
ResponseWriter
&
response
)
{
response
.
send
(
Pistache
::
Http
::
Code
::
Ok
,
"test_signalling_network_initiated_deregistration ok!
\n
"
);
std
::
string
supi
=
subscriptionId
;
Logger
::
amf_server
().
debug
(
"Key for PDU Session context: SUPI (%s)"
,
supi
.
c_str
());
std
::
shared_ptr
<
pdu_session_context
>
psc
;
if
(
amf_n11_inst
->
is_supi_to_pdu_ctx
(
supi
))
{
psc
=
amf_n11_inst
->
supi_to_pdu_ctx
(
supi
);
itti_test_signalling_network_initiated_deregistration
*
itti_msg
=
new
itti_test_signalling_network_initiated_deregistration
(
AMF_SERVER
,
TASK_AMF_APP
);
itti_msg
->
ran_ue_ngap_id
=
psc
.
get
()
->
ran_ue_ngap_id
;
itti_msg
->
amf_ue_ngap_id
=
psc
.
get
()
->
amf_ue_ngap_id
;
std
::
shared_ptr
<
itti_test_signalling_network_initiated_deregistration
>
i
=
std
::
shared_ptr
<
itti_test_signalling_network_initiated_deregistration
>
(
itti_msg
);
int
ret
=
itti_inst
->
send_msg
(
i
);
if
(
0
!=
ret
)
{
Logger
::
amf_server
().
error
(
"Could not send ITTI message %s to task TASK_AMF_APP"
,
i
->
get_msg_name
());
}
}
else
{
Logger
::
amf_server
().
error
(
"Cannot get pdu_session_context with SUPI (%s)"
,
supi
.
c_str
());
}
}
}
// namespace api
}
// namespace amf
}
// namespace oai
src/sbi/amf_server/impl/TestSignallingApiImpl.h
0 → 100644
View file @
c84bc571
#ifndef _TESTSIGNALLING_API_IMPL_H_
#define _TESTSIGNALLING_API_IMPL_H_
#include <pistache/endpoint.h>
#include <pistache/http.h>
#include <pistache/router.h>
#include <memory>
#include <TestSignallingApi.h>
#include <pistache/optional.h>
#include "ProblemDetails.h"
#include <string>
#include "amf_app.hpp"
namespace
oai
{
namespace
amf
{
namespace
api
{
class
TestSignallingApiImpl
:
public
oai
::
amf
::
api
::
TestSignallingApi
{
public:
TestSignallingApiImpl
(
std
::
shared_ptr
<
Pistache
::
Rest
::
Router
>
,
amf_application
::
amf_app
*
amf_app_inst
);
~
TestSignallingApiImpl
()
{}
void
test_signalling_network_initiated_deregistration
(
const
std
::
string
&
subscriptionId
,
Pistache
::
Http
::
ResponseWriter
&
response
);
private:
amf_application
::
amf_app
*
m_amf_app
;
};
}
// namespace api
}
// namespace amf
}
// namespace oai
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment