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
0952db8d
Commit
0952db8d
authored
Feb 07, 2023
by
Tien Thinh NGUYEN
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code cleanup for Service Request
parent
5fd4ea92
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
134 additions
and
112 deletions
+134
-112
src/amf-app/amf_n1.cpp
src/amf-app/amf_n1.cpp
+15
-13
src/nas/msgs/ServiceRequest.cpp
src/nas/msgs/ServiceRequest.cpp
+105
-88
src/nas/msgs/ServiceRequest.hpp
src/nas/msgs/ServiceRequest.hpp
+14
-11
No files found.
src/amf-app/amf_n1.cpp
View file @
0952db8d
...
...
@@ -919,9 +919,9 @@ void amf_n1::service_request_handle(
amf_app_inst
->
set_supi_2_ue_context
(
supi
,
uc
);
// Get PDU session status from Service Request
uint16_t
pdu_session_status
=
(
uint16_t
)
service_request
->
getPduSessionStatus
();
if
(
pdu_session_status
==
0
)
{
uint16_t
pdu_session_status
=
0
;
if
(
!
service_request
->
GetPduSessionStatus
(
pdu_session_status
)
or
(
pdu_session_status
==
0
)
)
{
// Get PDU Session Status from NAS Message Container if available
bstring
plain_msg
=
nullptr
;
if
(
service_request
->
GetNasMessageContainer
(
plain_msg
))
{
...
...
@@ -950,17 +950,19 @@ void amf_n1::service_request_handle(
nullptr
,
(
uint8_t
*
)
bdata
(
plain_msg
),
blength
(
plain_msg
));
bdestroy_wrapper
(
&
plain_msg
);
if
(
service_request_nas
->
getPduSessionStatus
()
>
0
)
{
pdu_session_status
=
(
uint16_t
)
service_request_nas
->
getPduSessionStatus
();
if
(
!
service_request_nas
->
GetPduSessionStatus
(
pdu_session_status
))
{
Logger
::
nas_mm
().
debug
(
"IE PDU Session Status is not present"
);
}
/*
// Trigger UE Connectivity Status Notify
Logger::amf_n1().debug(
"Signal the UE Connectivity Status Event notification
for SUPI "
"%s",
supi.c_str());
event_sub.ue_connectivity_state(supi, CM_CONNECTED, 1);
*/
// Trigger UE Connectivity Status Notify
Logger
::
amf_n1
().
debug
(
"Signal the UE Connectivity Status Event notification for SUPI "
"%s"
,
supi
.
c_str
());
event_sub
.
ue_connectivity_state
(
supi
,
CM_CONNECTED
,
1
);
}
break
;
default:
...
...
@@ -1017,7 +1019,7 @@ void amf_n1::service_request_handle(
std
::
shared_ptr
<
pdu_session_context
>
psc
=
{};
service_accept
->
SetPduSessionStatus
(
service_request
->
getPduSessionStatus
()
);
service_accept
->
SetPduSessionStatus
(
pdu_session_status
);
service_accept
->
SetPduSessionReactivationResult
(
0x0000
);
uint8_t
pdu_session_id
=
pdu_session_to_be_activated
.
at
(
0
);
...
...
src/nas/msgs/ServiceRequest.cpp
View file @
0952db8d
...
...
@@ -30,8 +30,8 @@ using namespace nas;
ServiceRequest
::
ServiceRequest
()
:
NasMmPlainHeader
(
EPD_5GS_MM_MSG
,
SERVICE_REQUEST
)
{
ie_uplink_data_status
=
std
::
nullopt
;
ie_
PDU
_session_status
=
std
::
nullopt
;
ie_allowed_
PDU
_session_status
=
std
::
nullopt
;
ie_
pdu
_session_status
=
std
::
nullopt
;
ie_allowed_
pdu
_session_status
=
std
::
nullopt
;
ie_nas_message_container
=
std
::
nullopt
;
}
...
...
@@ -45,43 +45,117 @@ void ServiceRequest::SetHeader(uint8_t security_header_type) {
//------------------------------------------------------------------------------
void
ServiceRequest
::
SetNgKsi
(
uint8_t
tsc
,
uint8_t
key_set_id
)
{
ie_ngKSI
.
Set
(
false
);
// 4 lower bits
ie_ngKSI
.
SetNasKeyIdentifier
(
key_set_id
);
ie_ngKSI
.
SetTypeOfSecurityContext
(
tsc
);
ie_ng_ksi
.
Set
(
false
);
// 4 lower bits
ie_ng_ksi
.
SetNasKeyIdentifier
(
key_set_id
);
ie_ng_ksi
.
SetTypeOfSecurityContext
(
tsc
);
}
//------------------------------------------------------------------------------
void
ServiceRequest
::
GetNgKsi
(
uint8_t
&
ng_ksi
)
const
{
ng_ksi
=
(
ie_ng_ksi
.
GetTypeOfSecurityContext
())
|
ie_ng_ksi
.
GetNasKeyIdentifier
();
}
//------------------------------------------------------------------------------
void
ServiceRequest
::
SetServiceType
(
uint8_t
value
)
{
ie_service_type
.
Set
(
true
,
value
);
ie_service_type
.
Set
(
true
,
value
);
// 4 higher bit
}
//------------------------------------------------------------------------------
void
ServiceRequest
::
GetServiceType
(
uint8_t
&
value
)
{
ie_service_type
.
GetValue
(
value
);
}
//------------------------------------------------------------------------------
void
ServiceRequest
::
Set5gSTmsi
(
uint16_t
amf_set_id
,
uint8_t
amf_pointer
,
string
tmsi
)
{
uint16_t
amf_set_id
,
uint8_t
amf_pointer
,
st
d
::
st
ring
tmsi
)
{
ie_5g_s_tmsi
.
Set5gSTmsi
(
amf_set_id
,
amf_pointer
,
tmsi
);
}
//------------------------------------------------------------------------------
bool
ServiceRequest
::
Get5gSTmsi
(
uint16_t
&
amf_set_id
,
uint8_t
&
amf_pointer
,
string
&
tmsi
)
const
{
return
ie_5g_s_tmsi
.
Get5gSTmsi
(
amf_set_id
,
amf_pointer
,
tmsi
);
}
//------------------------------------------------------------------------------
void
ServiceRequest
::
SetUplinkDataStatus
(
uint16_t
value
)
{
ie_uplink_data_status
=
std
::
make_optional
<
UplinkDataStatus
>
(
value
);
}
//------------------------------------------------------------------------------
bool
ServiceRequest
::
GetUplinkDataStatus
(
uint16_t
&
value
)
const
{
if
(
ie_uplink_data_status
.
has_value
())
{
value
=
ie_uplink_data_status
.
value
().
GetValue
();
return
true
;
}
else
{
return
false
;
}
}
//------------------------------------------------------------------------------
void
ServiceRequest
::
SetPduSessionStatus
(
uint16_t
value
)
{
ie_PDU_session_status
=
std
::
make_optional
<
PDUSessionStatus
>
(
value
);
ie_pdu_session_status
=
std
::
make_optional
<
PDUSessionStatus
>
(
value
);
}
//------------------------------------------------------------------------------
bool
ServiceRequest
::
GetPduSessionStatus
(
uint16_t
&
value
)
const
{
if
(
ie_pdu_session_status
.
has_value
())
{
value
=
ie_pdu_session_status
.
value
().
GetValue
();
return
true
;
}
else
{
return
false
;
}
}
//------------------------------------------------------------------------------
std
::
optional
<
uint16_t
>
ServiceRequest
::
GetPduSessionStatus
()
const
{
if
(
ie_pdu_session_status
.
has_value
())
{
return
std
::
optional
<
uint16_t
>
(
ie_pdu_session_status
.
value
().
GetValue
());
}
return
std
::
nullopt
;
}
//------------------------------------------------------------------------------
void
ServiceRequest
::
SetAllowedPduSessionStatus
(
uint16_t
value
)
{
ie_allowed_
PDU
_session_status
=
ie_allowed_
pdu
_session_status
=
std
::
make_optional
<
AllowedPDUSessionStatus
>
(
value
);
}
//------------------------------------------------------------------------------
bool
ServiceRequest
::
GetAllowedPduSessionStatus
(
uint16_t
&
value
)
const
{
if
(
ie_allowed_pdu_session_status
.
has_value
())
{
value
=
ie_allowed_pdu_session_status
.
value
().
GetValue
();
return
true
;
}
else
{
return
false
;
}
}
//------------------------------------------------------------------------------
std
::
optional
<
uint16_t
>
ServiceRequest
::
GetAllowedPduSessionStatus
()
const
{
if
(
ie_allowed_pdu_session_status
.
has_value
())
{
return
std
::
optional
<
uint16_t
>
(
ie_allowed_pdu_session_status
.
value
().
GetValue
());
}
return
std
::
nullopt
;
}
//------------------------------------------------------------------------------
void
ServiceRequest
::
SetNasMessageContainer
(
bstring
value
)
{
ie_nas_message_container
=
std
::
make_optional
<
NasMessageContainer
>
(
value
);
}
//------------------------------------------------------------------------------
bool
ServiceRequest
::
GetNasMessageContainer
(
bstring
&
nas
)
const
{
if
(
ie_nas_message_container
.
has_value
())
{
ie_nas_message_container
.
value
().
GetValue
(
nas
);
return
true
;
}
else
{
return
false
;
}
}
//------------------------------------------------------------------------------
int
ServiceRequest
::
Encode
(
uint8_t
*
buf
,
int
len
)
{
Logger
::
nas_mm
().
debug
(
"Encoding ServiceRequest message..."
);
...
...
@@ -98,13 +172,13 @@ int ServiceRequest::Encode(uint8_t* buf, int len) {
encoded_size
+=
encoded_ie_size
;
// ngKSI and Service Type
int
size
=
ie_ng
KSI
.
Encode
(
buf
+
encoded_size
,
len
-
encoded_size
);
int
size
=
ie_ng
_ksi
.
Encode
(
buf
+
encoded_size
,
len
-
encoded_size
);
if
(
size
==
KEncodeDecodeError
)
{
Logger
::
nas_mm
().
error
(
"Encoding
ie_n
gKSI error"
);
Logger
::
nas_mm
().
error
(
"Encoding
N
gKSI error"
);
return
KEncodeDecodeError
;
}
if
(
size
!=
0
)
{
Logger
::
nas_mm
().
error
(
"Encoding
ie_n
gKSI error"
);
Logger
::
nas_mm
().
error
(
"Encoding
N
gKSI error"
);
return
KEncodeDecodeError
;
}
...
...
@@ -140,29 +214,29 @@ int ServiceRequest::Encode(uint8_t* buf, int len) {
}
// PDU session status
if
(
!
ie_
PDU
_session_status
.
has_value
())
{
Logger
::
nas_mm
().
warn
(
"IE ie_
PDU
_session_status is not available"
);
if
(
!
ie_
pdu
_session_status
.
has_value
())
{
Logger
::
nas_mm
().
warn
(
"IE ie_
pdu
_session_status is not available"
);
}
else
{
size
=
ie_
PDU
_session_status
.
value
().
Encode
(
size
=
ie_
pdu
_session_status
.
value
().
Encode
(
buf
+
encoded_size
,
len
-
encoded_size
);
if
(
size
!=
KEncodeDecodeError
)
{
encoded_size
+=
size
;
}
else
{
Logger
::
nas_mm
().
error
(
"Encoding ie_
PDU
_session_status error"
);
Logger
::
nas_mm
().
error
(
"Encoding ie_
pdu
_session_status error"
);
return
KEncodeDecodeError
;
}
}
// Allowed PDU session status
if
(
!
ie_allowed_
PDU
_session_status
.
has_value
())
{
Logger
::
nas_mm
().
warn
(
"IE ie_allowed_
PDU
_session_status is not available"
);
if
(
!
ie_allowed_
pdu
_session_status
.
has_value
())
{
Logger
::
nas_mm
().
warn
(
"IE ie_allowed_
pdu
_session_status is not available"
);
}
else
{
size
=
ie_allowed_
PDU
_session_status
.
value
().
Encode
(
size
=
ie_allowed_
pdu
_session_status
.
value
().
Encode
(
buf
+
encoded_size
,
len
-
encoded_size
);
if
(
size
!=
KEncodeDecodeError
)
{
encoded_size
+=
size
;
}
else
{
Logger
::
nas_mm
().
error
(
"Encoding ie_allowed_
PDU
_session_status error"
);
Logger
::
nas_mm
().
error
(
"Encoding ie_allowed_
pdu
_session_status error"
);
return
KEncodeDecodeError
;
}
}
...
...
@@ -202,7 +276,7 @@ int ServiceRequest::Decode(NasMmPlainHeader* header, uint8_t* buf, int len) {
// ngKSI + Service type
decoded_result
=
ie_ng
KSI
.
Decode
(
buf
+
decoded_size
,
len
-
decoded_size
,
false
,
false
);
ie_ng
_ksi
.
Decode
(
buf
+
decoded_size
,
len
-
decoded_size
,
false
,
false
);
if
(
decoded_result
==
KEncodeDecodeError
)
return
KEncodeDecodeError
;
decoded_result
=
ie_service_type
.
Decode
(
buf
+
decoded_size
,
len
-
decoded_size
,
true
,
false
);
...
...
@@ -234,31 +308,31 @@ int ServiceRequest::Decode(NasMmPlainHeader* header, uint8_t* buf, int len) {
case
kIeiPduSessionStatus
:
{
Logger
::
nas_mm
().
debug
(
"Decoding ie_
PDU
_session_status (IEI 0x%x)"
,
kIeiPduSessionStatus
);
PDUSessionStatus
ie_
PDU
_session_status_tmp
=
{};
if
((
decoded_result
=
ie_
PDU
_session_status_tmp
.
Decode
(
"Decoding ie_
pdu
_session_status (IEI 0x%x)"
,
kIeiPduSessionStatus
);
PDUSessionStatus
ie_
pdu
_session_status_tmp
=
{};
if
((
decoded_result
=
ie_
pdu
_session_status_tmp
.
Decode
(
buf
+
decoded_size
,
len
-
decoded_size
,
true
))
==
KEncodeDecodeError
)
return
decoded_result
;
decoded_size
+=
decoded_result
;
ie_
PDU
_session_status
=
std
::
optional
<
PDUSessionStatus
>
(
ie_
PDU
_session_status_tmp
);
ie_
pdu
_session_status
=
std
::
optional
<
PDUSessionStatus
>
(
ie_
pdu
_session_status_tmp
);
octet
=
*
(
buf
+
decoded_size
);
Logger
::
nas_mm
().
debug
(
"Next IEI (0x%x)"
,
octet
);
}
break
;
case
kIeiAllowedPduSessionStatus
:
{
Logger
::
nas_mm
().
debug
(
"Decoding ie_allowed_
PDU
_session_status, IEI 0x%x"
,
"Decoding ie_allowed_
pdu
_session_status, IEI 0x%x"
,
kIeiAllowedPduSessionStatus
);
AllowedPDUSessionStatus
ie_allowed_
PDU
_session_status_tmp
=
{};
if
((
decoded_result
=
ie_allowed_
PDU
_session_status_tmp
.
Decode
(
AllowedPDUSessionStatus
ie_allowed_
pdu
_session_status_tmp
=
{};
if
((
decoded_result
=
ie_allowed_
pdu
_session_status_tmp
.
Decode
(
buf
+
decoded_size
,
len
-
decoded_size
,
true
))
==
KEncodeDecodeError
)
return
decoded_result
;
decoded_size
+=
decoded_result
;
ie_allowed_
PDU
_session_status
=
std
::
optional
<
AllowedPDUSessionStatus
>
(
ie_allowed_
PDU
_session_status_tmp
);
ie_allowed_
pdu
_session_status
=
std
::
optional
<
AllowedPDUSessionStatus
>
(
ie_allowed_
pdu
_session_status_tmp
);
octet
=
*
(
buf
+
decoded_size
);
Logger
::
nas_mm
().
debug
(
"Next IEI (0x%x)"
,
octet
);
}
break
;
...
...
@@ -289,60 +363,3 @@ int ServiceRequest::Decode(NasMmPlainHeader* header, uint8_t* buf, int len) {
"Decoded ServiceRequest message len (%d)"
,
decoded_size
);
return
decoded_size
;
}
//------------------------------------------------------------------------------
bool
ServiceRequest
::
GetNgKSI
(
uint8_t
&
ng_ksi
)
{
ng_ksi
=
(
ie_ngKSI
.
GetTypeOfSecurityContext
())
|
ie_ngKSI
.
GetNasKeyIdentifier
();
return
true
;
}
//------------------------------------------------------------------------------
uint16_t
ServiceRequest
::
GetUplinkDataStatus
()
{
if
(
ie_uplink_data_status
)
{
return
ie_uplink_data_status
->
GetValue
();
}
else
{
return
-
1
;
}
}
//------------------------------------------------------------------------------
uint16_t
ServiceRequest
::
GetPduSessionStatus
()
{
if
(
ie_PDU_session_status
)
{
return
ie_PDU_session_status
->
GetValue
();
}
else
{
return
0
;
}
}
//------------------------------------------------------------------------------
uint16_t
ServiceRequest
::
GetAllowedPduSessionStatus
()
{
if
(
ie_allowed_PDU_session_status
)
{
return
ie_allowed_PDU_session_status
->
GetValue
();
}
else
{
return
0
;
}
}
//------------------------------------------------------------------------------
bool
ServiceRequest
::
GetNasMessageContainer
(
bstring
&
nas
)
{
if
(
ie_nas_message_container
)
{
ie_nas_message_container
->
GetValue
(
nas
);
return
true
;
}
else
{
return
false
;
}
}
//------------------------------------------------------------------------------
uint8_t
ServiceRequest
::
GetServiceType
()
{
uint8_t
value
=
0
;
ie_service_type
.
GetValue
(
value
);
return
value
;
}
//------------------------------------------------------------------------------
bool
ServiceRequest
::
Get5gSTmsi
(
uint16_t
&
amf_set_id
,
uint8_t
&
amf_pointer
,
string
&
tmsi
)
{
return
ie_5g_s_tmsi
.
Get5gSTmsi
(
amf_set_id
,
amf_pointer
,
tmsi
);
}
src/nas/msgs/ServiceRequest.hpp
View file @
0952db8d
...
...
@@ -38,35 +38,38 @@ class ServiceRequest : public NasMmPlainHeader {
int
Decode
(
NasMmPlainHeader
*
header
,
uint8_t
*
buf
,
int
len
);
void
SetNgKsi
(
uint8_t
tsc
,
uint8_t
key_set_id
);
bool
GetNgKSI
(
uint8_t
&
ng_ksi
)
;
void
GetNgKsi
(
uint8_t
&
ng_ksi
)
const
;
void
SetServiceType
(
uint8_t
value
);
uint8_t
GetServiceType
(
);
void
GetServiceType
(
uint8_t
&
value
);
void
Set5gSTmsi
(
uint16_t
amf_set_id
,
uint8_t
amf_pointer
,
string
tmsi
);
bool
Get5gSTmsi
(
uint16_t
&
amf_set_id
,
uint8_t
&
amf_pointer
,
string
&
tmsi
);
void
Set5gSTmsi
(
uint16_t
amf_set_id
,
uint8_t
amf_pointer
,
std
::
string
tmsi
);
bool
Get5gSTmsi
(
uint16_t
&
amf_set_id
,
uint8_t
&
amf_pointer
,
std
::
string
&
tmsi
)
const
;
void
SetUplinkDataStatus
(
uint16_t
value
);
uint16_t
GetUplinkDataStatus
()
;
bool
GetUplinkDataStatus
(
uint16_t
&
value
)
const
;
void
SetPduSessionStatus
(
uint16_t
value
);
uint16_t
GetPduSessionStatus
();
bool
GetPduSessionStatus
(
uint16_t
&
value
)
const
;
std
::
optional
<
uint16_t
>
GetPduSessionStatus
()
const
;
void
SetAllowedPduSessionStatus
(
uint16_t
value
);
uint16_t
GetAllowedPduSessionStatus
();
bool
GetAllowedPduSessionStatus
(
uint16_t
&
value
)
const
;
std
::
optional
<
uint16_t
>
GetAllowedPduSessionStatus
()
const
;
void
SetNasMessageContainer
(
bstring
value
);
bool
GetNasMessageContainer
(
bstring
&
nas
);
bool
GetNasMessageContainer
(
bstring
&
nas
)
const
;
private:
NasKeySetIdentifier
ie_ng
KSI
;
// Mandatory
NasKeySetIdentifier
ie_ng
_ksi
;
// Mandatory
ServiceType
ie_service_type
;
// Mandatory
_5GSMobileIdentity
ie_5g_s_tmsi
;
// Mandatory
std
::
optional
<
UplinkDataStatus
>
ie_uplink_data_status
;
// Optional
std
::
optional
<
PDUSessionStatus
>
ie_
PDU
_session_status
;
// Optional
std
::
optional
<
PDUSessionStatus
>
ie_
pdu
_session_status
;
// Optional
std
::
optional
<
AllowedPDUSessionStatus
>
ie_allowed_
PDU
_session_status
;
// Optional
ie_allowed_
pdu
_session_status
;
// Optional
std
::
optional
<
NasMessageContainer
>
ie_nas_message_container
;
// Optional
};
...
...
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