Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
oai
cn5g
oai-cn5g-smf
Commits
6a4351b4
Commit
6a4351b4
authored
May 11, 2020
by
Tien-Thinh Nguyen
Browse files
Update UE-requested Service Request/Code cleanup
parent
dd228492
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
src/api-server/api/IndividualSMContextApi.cpp
View file @
6a4351b4
...
...
@@ -184,7 +184,7 @@ void IndividualSMContextApi::update_sm_context_handler(
free_wrapper
((
void
**
)
&
data
);
uint8_t
size
=
g_parts
.
size
();
Logger
::
smf_api_server
().
debug
(
"Number of
g_
parts %d"
,
g_parts
.
size
());
Logger
::
smf_api_server
().
debug
(
"Number of
MIME
parts %d"
,
g_parts
.
size
());
part
p0
=
{
};
part
p1
=
{
};
...
...
src/common/smf.h
View file @
6a4351b4
...
...
@@ -189,7 +189,9 @@ static const std::vector<std::string> multipart_related_content_part_e2str = {
//for CURL
#define AMF_CURL_TIMEOUT_MS 100L
#define AMF_NUMBER_RETRIES 3
#define UDM_CURL_TIMEOUT_MS 100L
#define UDM_NUMBER_RETRIES 3
//for N1N2
#define BUF_LEN 512
#endif
src/smf_app/smf_app.cpp
View file @
6a4351b4
...
...
@@ -494,12 +494,6 @@ void smf_app::handle_pdu_session_create_sm_context_request(
return
;
}
Logger
::
smf_app
().
debug
(
"NAS information: Extended Protocol Discriminator %d, Security Header Type %d, Message Type %d"
,
decoded_nas_msg
.
header
.
extended_protocol_discriminator
,
decoded_nas_msg
.
header
.
security_header_type
,
decoded_nas_msg
.
plain
.
sm
.
header
.
message_type
);
//Extended protocol discriminator (Mandatory)
smreq
->
req
.
set_epd
(
decoded_nas_msg
.
header
.
extended_protocol_discriminator
);
//PDUSessionIdentity
...
...
@@ -517,7 +511,7 @@ void smf_app::handle_pdu_session_create_sm_context_request(
==
PDU_SESSION_ESTABLISHMENT_REQUEST
)
{
//TODO: Disable this command temporarily since can't get this info from tester
Logger
::
smf_app
().
debug
(
"
NAS, pdu_s
ession
_t
ype %d"
,
"
PDU S
ession
T
ype %d"
,
decoded_nas_msg
.
plain
.
sm
.
pdu_session_establishment_request
.
_pdusessiontype
.
pdu_session_type_value
);
pdu_session_type
.
pdu_session_type
=
decoded_nas_msg
.
plain
.
sm
...
...
@@ -565,7 +559,7 @@ void smf_app::handle_pdu_session_create_sm_context_request(
uint8_t
message_type
=
decoded_nas_msg
.
plain
.
sm
.
header
.
message_type
;
std
::
string
request_type
=
smreq
->
req
.
get_request_type
();
Logger
::
smf_app
().
info
(
"Handle a PDU Session Create SM Context Request message from AMF,
supi
"
SUPI_64_FMT
",
dnn
%s,
snssai_sst %d, snssai_sd
%s"
,
"Handle a PDU Session Create SM Context Request message from AMF,
SUPI
"
SUPI_64_FMT
",
DNN
%s,
SNSSAI SST %d, SD
%s"
,
supi64
,
dnn
.
c_str
(),
snssai
.
sST
,
snssai
.
sD
.
c_str
());
//If no DNN information from UE, set to default value
...
...
@@ -577,7 +571,7 @@ void smf_app::handle_pdu_session_create_sm_context_request(
//check pti
if
((
pti
.
procedure_transaction_id
==
PROCEDURE_TRANSACTION_IDENTITY_UNASSIGNED
)
||
(
pti
.
procedure_transaction_id
>
PROCEDURE_TRANSACTION_IDENTITY_LAST
))
{
Logger
::
smf_app
().
warn
(
"
Invalid PTI value (pti = %d)"
,
Logger
::
smf_app
().
warn
(
"Invalid PTI value (pti = %d)"
,
pti
.
procedure_transaction_id
);
problem_details
.
setCause
(
pdu_session_application_error_e2str
[
PDU_SESSION_APPLICATION_ERROR_N1_SM_ERROR
]);
...
...
@@ -599,7 +593,7 @@ void smf_app::handle_pdu_session_create_sm_context_request(
//check pdu session id
if
((
pdu_session_id
==
PDU_SESSION_IDENTITY_UNASSIGNED
)
||
(
pdu_session_id
>
PDU_SESSION_IDENTITY_LAST
))
{
Logger
::
smf_app
().
warn
(
"
Invalid PDU Session ID value (%d)"
,
Logger
::
smf_app
().
warn
(
"Invalid PDU Session ID value (%d)"
,
pdu_session_id
);
//section 7.3.2@3GPP TS 24.501; NAS N1 SM message: ignore the message
return
;
...
...
@@ -630,7 +624,7 @@ void smf_app::handle_pdu_session_create_sm_context_request(
//check request type
if
(
request_type
.
compare
(
"INITIAL_REQUEST"
)
!=
0
)
{
Logger
::
smf_app
().
warn
(
"Invalid request type (request type = %s)"
,
"INITIAL_REQUEST"
);
request_type
.
c_str
()
);
//TODO:
//return
}
...
...
@@ -703,7 +697,6 @@ void smf_app::handle_pdu_session_create_sm_context_request(
std
::
shared_ptr
<
session_management_subscription
>
subscription
=
std
::
shared_ptr
<
session_management_subscription
>
(
s
);
if
(
smf_n10_inst
->
get_sm_data
(
supi64
,
dnn
,
snssai
,
subscription
))
{
Logger
::
smf_app
().
debug
(
"Update DNN subscription info"
);
//update dnn_context with subscription info
sc
.
get
()
->
insert_dnn_subscription
(
snssai
,
subscription
);
}
else
{
...
...
@@ -782,7 +775,7 @@ void smf_app::handle_pdu_session_update_sm_context_request(
scf
=
scid_2_smf_context
(
scid
);
}
else
{
Logger
::
smf_app
().
warn
(
"Context associated with this id "
SCID_FMT
" does not exit!"
,
scid
);
"
SM
Context associated with this id "
SCID_FMT
" does not exit!"
,
scid
);
problem_details
.
setCause
(
pdu_session_application_error_e2str
[
PDU_SESSION_APPLICATION_ERROR_CONTEXT_NOT_FOUND
]);
smContextUpdateError
.
setError
(
problem_details
);
...
...
src/smf_app/smf_config.cpp
View file @
6a4351b4
...
...
@@ -741,15 +741,15 @@ smf_config::~smf_config() {
//------------------------------------------------------------------------------
bool
smf_config
::
is_dotted_dnn_handled
(
const
std
::
string
&
dnn
,
const
pdu_session_type_t
&
pdn_session_type
)
{
Logger
::
smf_app
().
debug
(
"
r
equested
dnn
: %s"
,
dnn
.
c_str
());
Logger
::
smf_app
().
debug
(
"
R
equested
DNN
: %s"
,
dnn
.
c_str
());
for
(
int
i
=
0
;
i
<
smf_cfg
.
num_apn
;
i
++
)
{
Logger
::
smf_app
().
debug
(
"
apn_
label: %s,
ap
n: %s"
,
Logger
::
smf_app
().
debug
(
"
DNN
label: %s,
dn
n: %s"
,
smf_cfg
.
apn
[
i
].
apn_label
.
c_str
(),
smf_cfg
.
apn
[
i
].
apn
.
c_str
());
//if (0 == dnn.compare(smf_cfg.apn[i].apn_label)) {
if
(
0
==
dnn
.
compare
(
smf_cfg
.
apn
[
i
].
apn
))
{
Logger
::
smf_app
().
debug
(
"DNN matched!"
);
Logger
::
smf_app
().
debug
(
"
pdu s
ession
t
ype %d,
pdn_t
ype %d"
,
Logger
::
smf_app
().
debug
(
"
PDU S
ession
T
ype %d,
PDN T
ype %d"
,
pdn_session_type
.
pdu_session_type
,
smf_cfg
.
apn
[
i
].
pdn_type
.
pdn_type
);
if
(
pdn_session_type
.
pdu_session_type
...
...
src/smf_app/smf_context.cpp
View file @
6a4351b4
...
...
@@ -78,7 +78,7 @@ std::string smf_qos_flow::toString() const {
.
append
(
"
\n
"
);
s
.
append
(
"
\t
PDR ID DL:
\t\t\t
"
).
append
(
std
::
to_string
(
pdr_id_dl
.
rule_id
))
.
append
(
"
\n
"
);
s
.
append
(
"
\t
P
RECEDENCE
:
\t\t\t
"
).
append
(
std
::
to_string
(
precedence
.
precedence
))
s
.
append
(
"
\t
P
recedence
:
\t\t\t
"
).
append
(
std
::
to_string
(
precedence
.
precedence
))
.
append
(
"
\n
"
);
if
(
far_id_ul
.
first
)
{
s
.
append
(
"
\t
FAR ID UL:
\t\t\t
"
).
append
(
...
...
@@ -169,11 +169,11 @@ void smf_pdu_session::add_qos_flow(const smf_qos_flow &flow) {
qos_flows
.
erase
(
flow
.
qfi
.
qfi
);
qos_flows
.
insert
(
std
::
pair
<
uint8_t
,
smf_qos_flow
>
((
uint8_t
)
flow
.
qfi
.
qfi
,
flow
));
Logger
::
smf_app
().
trace
(
"
smf_pdu_session::add_qos_flow(%d)
success"
,
Logger
::
smf_app
().
trace
(
"
QoS Flow (flow Id %d) has been added
success
fully
"
,
flow
.
qfi
.
qfi
);
}
else
{
Logger
::
smf_app
().
error
(
"smf_pdu_session::add_qos_flow(%d) failed, invalid QFI"
,
flow
.
qfi
.
qfi
);
Logger
::
smf_app
().
error
(
"Failed to add QoS flow (flow Id %d), invalid QFI"
,
flow
.
qfi
.
qfi
);
}
}
...
...
@@ -227,6 +227,12 @@ void smf_pdu_session::set_default_qos_flow(const pfcp::qfi_t &qfi) {
default_qfi
.
qfi
=
qfi
.
qfi
;
}
//------------------------------------------------------------------------------
bool
smf_pdu_session
::
get_default_qos_flow
(
smf_qos_flow
&
flow
)
{
Logger
::
smf_app
().
debug
(
"Get default QoS Flow of this PDU session."
);
return
get_qos_flow
(
default_qfi
,
flow
);
}
//------------------------------------------------------------------------------
void
smf_pdu_session
::
get_qos_flows
(
std
::
vector
<
smf_qos_flow
>
&
flows
)
{
flows
.
clear
();
...
...
@@ -339,8 +345,7 @@ std::string smf_pdu_session::toString() const {
"
\n
"
);
s
.
append
(
"
\t
Default QFI:
\t\t\t
"
).
append
(
std
::
to_string
(
default_qfi
.
qfi
))
.
append
(
"
\n
"
);
s
.
append
(
"
\t
SEID:
\t\t\t
"
).
append
(
std
::
to_string
(
seid
)).
append
(
"
\n
"
);
s
.
append
(
"
\t
SEID:
\t\t\t\t
"
).
append
(
std
::
to_string
(
seid
)).
append
(
"
\n
"
);
return
s
;
}
...
...
@@ -361,6 +366,8 @@ pdu_session_status_e smf_pdu_session::get_pdu_session_status() const {
//------------------------------------------------------------------------------
void
smf_pdu_session
::
set_upCnx_state
(
const
upCnx_state_e
&
state
)
{
Logger
::
smf_app
().
info
(
"Set upCnxState to %s"
,
upCnx_state_e2str
[
static_cast
<
int
>
(
state
)].
c_str
());
upCnx_state
=
state
;
}
...
...
@@ -477,17 +484,17 @@ void smf_pdu_session::add_qos_rule(const QOSRulesIE &qos_rule) {
if
((
rule_id
>=
QOS_RULE_IDENTIFIER_FIRST
)
and
(
rule_id
<=
QOS_RULE_IDENTIFIER_LAST
))
{
if
(
qos_rules
.
count
(
rule_id
)
>
0
)
{
Logger
::
smf_app
().
error
(
"smf_pdu_session::add_qos_rule(%d) failed, rule existed"
,
rule_id
);
Logger
::
smf_app
().
error
(
"Failed to add rule (Id %d), rule existed"
,
rule_id
);
}
else
{
qos_rules
.
insert
(
std
::
pair
<
uint8_t
,
QOSRulesIE
>
(
rule_id
,
qos_rule
));
Logger
::
smf_app
().
trace
(
"
smf_pdu_session::add_qos_rule(%d)
success"
,
Logger
::
smf_app
().
trace
(
"
Rule (Id %d) has been added
success
fully
"
,
rule_id
);
}
}
else
{
Logger
::
smf_app
().
error
(
"
smf_pdu_session::add_qos_rule(
%d) failed
,
invalid
R
ule Id"
,
rule_id
);
"
Failed to add rule (Id
%d) failed
:
invalid
r
ule Id"
,
rule_id
);
}
}
...
...
@@ -503,7 +510,7 @@ void session_management_subscription::insert_dnn_configuration(
//------------------------------------------------------------------------------
void
session_management_subscription
::
find_dnn_configuration
(
std
::
string
dnn
,
std
::
shared_ptr
<
dnn_configuration_t
>
&
dnn_configuration
)
{
Logger
::
smf_app
().
info
(
"
f
ind
_dnn_
configuration with
dnn
%s"
,
dnn
.
c_str
());
Logger
::
smf_app
().
info
(
"
F
ind
DNN
configuration with
DNN
%s"
,
dnn
.
c_str
());
if
(
dnn_configurations
.
count
(
dnn
)
>
0
)
{
dnn_configuration
=
dnn_configurations
.
at
(
dnn
);
}
...
...
@@ -595,7 +602,11 @@ void smf_context::handle_itti_msg(itti_n4_session_deletion_response &sdresp) {
"Received N4 SESSION DELETION RESPONSE sender teid "
TEID_FMT
" pfcp_tx_id %"
PRIX64
", smf_procedure not found, discarded!"
,
sdresp
.
seid
,
sdresp
.
trxn_id
);
}
std
::
cout
<<
toString
()
<<
std
::
endl
;
Logger
::
smf_app
().
info
(
"Handle N4 SESSION DELETION RESPONSE with SMF context %s"
,
toString
().
c_str
());
}
//------------------------------------------------------------------------------
...
...
@@ -607,17 +618,14 @@ void smf_context::handle_itti_msg(
std
::
string
smf_context
::
toString
()
const
{
std
::
unique_lock
<
std
::
recursive_mutex
>
lock
(
m_context
);
std
::
string
s
=
{
};
s
.
append
(
"
\n
"
);
s
.
append
(
"SMF CONTEXT:
\n
"
);
s
.
append
(
"
\t
IMSI:
\t\t\t\t
"
).
append
(
imsi
.
toString
()).
append
(
"
\n
"
);
s
.
append
(
"
\t
IMSI UNAUTHENTICATED:
\t\t
"
).
append
(
std
::
to_string
(
imsi_unauthenticated_indicator
)).
append
(
"
\n
"
);
s
.
append
(
"
\t
SUPI:
\t\t\t\t
"
).
append
(
smf_supi_to_string
(
supi
).
c_str
()).
append
(
"
\n
"
);
for
(
auto
it
:
dnns
)
{
s
.
append
(
it
->
toString
());
}
s
.
append
(
"
\t
SUPI:
\t\t\t\t
"
).
append
(
smf_supi_to_string
(
supi
)).
append
(
"
\n
"
);
//s.append("\tIMSI:\t"+toString(p.msisdn));
//apns.reserve(MAX_APN_PER_UE);
// s.append("\n");
return
s
;
}
...
...
@@ -625,7 +633,8 @@ std::string smf_context::toString() const {
void
smf_context
::
get_default_qos
(
const
snssai_t
&
snssai
,
const
std
::
string
&
dnn
,
subscribed_default_qos_t
&
default_qos
)
{
Logger
::
smf_app
().
info
(
"get_default_qos, key %d"
,
(
uint8_t
)
snssai
.
sST
);
Logger
::
smf_app
().
info
(
"Get default QoS for a PDU Session, key %d"
,
(
uint8_t
)
snssai
.
sST
);
//get the default QoS profile
std
::
shared_ptr
<
session_management_subscription
>
ss
=
{
};
std
::
shared_ptr
<
dnn_configuration_t
>
sdc
=
{
};
...
...
@@ -644,8 +653,9 @@ void smf_context::get_default_qos(const snssai_t &snssai,
void
smf_context
::
get_default_qos_rule
(
QOSRulesIE
&
qos_rule
,
uint8_t
pdu_session_type
)
{
//TODO, update according to PDU Session type
Logger
::
smf_app
().
info
(
"Get default QoS rule (PDU session type %d)"
,
pdu_session_type
);
Logger
::
smf_app
().
info
(
"Get default QoS rule for a PDU Session (PDU session type %d)"
,
pdu_session_type
);
//see section 9.11.4.13 @ 3GPP TS 24.501 and section 5.7.1.4 @ 3GPP TS 23.501
qos_rule
.
qosruleidentifer
=
0x01
;
//be updated later on
qos_rule
.
ruleoperationcode
=
CREATE_NEW_QOS_RULE
;
...
...
@@ -749,7 +759,8 @@ void smf_context::get_default_qos_flow_description(
void
smf_context
::
get_session_ambr
(
SessionAMBR
&
session_ambr
,
const
snssai_t
&
snssai
,
const
std
::
string
&
dnn
)
{
Logger
::
smf_app
().
debug
(
"Get AMBR info from the DNN configuration"
);
Logger
::
smf_app
().
debug
(
"Get AMBR info from the subscription information (DNN %s)"
,
dnn
.
c_str
());
std
::
shared_ptr
<
session_management_subscription
>
ss
=
{
};
std
::
shared_ptr
<
dnn_configuration_t
>
sdc
=
{
};
...
...
@@ -759,7 +770,7 @@ void smf_context::get_session_ambr(SessionAMBR &session_ambr,
ss
.
get
()
->
find_dnn_configuration
(
dnn
,
sdc
);
if
(
nullptr
!=
sdc
.
get
())
{
Logger
::
smf_app
().
debug
(
"Default AMBR info from the
DNN configur
ation, downlink %s, uplink %s"
,
"Default AMBR info from the
subscription inform
ation, downlink %s, uplink %s"
,
(
sdc
.
get
()
->
session_ambr
).
downlink
.
c_str
(),
(
sdc
.
get
()
->
session_ambr
).
uplink
.
c_str
());
...
...
@@ -830,6 +841,9 @@ void smf_context::get_session_ambr(SessionAMBR &session_ambr,
}
}
}
else
{
Logger
::
smf_app
().
debug
(
"Could not get default info from the subscription information, use default value instead."
);
//use default value
session_ambr
.
session_ambr_for_downlink
=
1
;
session_ambr
.
uint_for_session_ambr_for_downlink
=
...
...
@@ -845,7 +859,8 @@ void smf_context::get_session_ambr(SessionAMBR &session_ambr,
void
smf_context
::
get_session_ambr
(
Ngap_PDUSessionAggregateMaximumBitRate_t
&
session_ambr
,
const
snssai_t
&
snssai
,
const
std
::
string
&
dnn
)
{
Logger
::
smf_app
().
debug
(
"Get AMBR info from the DNN configuration"
);
Logger
::
smf_app
().
debug
(
"Get AMBR info from the subscription information (DNN %s)"
,
dnn
.
c_str
());
std
::
shared_ptr
<
session_management_subscription
>
ss
=
{
};
std
::
shared_ptr
<
dnn_configuration_t
>
sdc
=
{
};
...
...
@@ -1015,7 +1030,7 @@ void smf_context::handle_pdu_session_create_sm_context_request(
bool
find_pdu
=
sd
.
get
()
->
find_pdu_session
(
pdu_session_id
,
sp
);
if
(
nullptr
==
sp
.
get
())
{
Logger
::
smf_app
().
debug
(
"Create a new PDN connection
!
"
);
Logger
::
smf_app
().
debug
(
"Create a new PDN connection"
);
sp
=
std
::
shared_ptr
<
smf_pdu_session
>
(
new
smf_pdu_session
());
sp
.
get
()
->
pdn_type
.
pdn_type
=
smreq
->
req
.
get_pdu_session_type
();
sp
.
get
()
->
pdu_session_id
=
pdu_session_id
;
...
...
@@ -1058,6 +1073,7 @@ void smf_context::handle_pdu_session_create_sm_context_request(
//smf_app_inst->process_pco_request(extended_protocol_options, pco_resp, pco_ids);
//Step 7. Address allocation based on PDN type
Logger
::
smf_app
().
debug
(
"UE address allocation"
);
switch
(
sp
->
pdn_type
.
pdn_type
)
{
case
PDN_TYPE_E_IPV4
:
{
if
(
!
pco_ids
.
ci_ipv4_address_allocation_via_dhcpv4
)
{
//use SM NAS signalling
...
...
@@ -1166,7 +1182,7 @@ void smf_context::handle_pdu_session_create_sm_context_request(
//TODO: PDU Session authentication/authorization (Optional)
//see section 4.3.2.3@3GPP TS 23.502 and section 6.3.1@3GPP TS 24.501
Logger
::
smf_app
().
info
(
"Create a procedure to process this message
!
"
);
Logger
::
smf_app
().
info
(
"Create a procedure to process this message
.
"
);
session_create_sm_context_procedure
*
proc
=
new
session_create_sm_context_procedure
(
sp
);
std
::
shared_ptr
<
smf_procedure
>
sproc
=
std
::
shared_ptr
<
smf_procedure
>
(
proc
);
...
...
@@ -1264,7 +1280,7 @@ void smf_context::handle_pdu_session_create_sm_context_request(
void
smf_context
::
handle_pdu_session_update_sm_context_request
(
std
::
shared_ptr
<
itti_n11_update_sm_context_request
>
smreq
)
{
Logger
::
smf_app
().
info
(
"Handle a PDU Session Update SM Context Request message from AMF"
);
"Handle a PDU Session Update SM Context Request message from
an
AMF"
);
pdu_session_update_sm_context_request
sm_context_req_msg
=
smreq
->
req
;
smf_n1_n2
smf_n1_n2_inst
=
{
};
oai
::
smf_server
::
model
::
SmContextUpdateError
smContextUpdateError
=
{
};
...
...
@@ -1836,13 +1852,13 @@ void smf_context::handle_pdu_session_update_sm_context_request(
//1 - UE-Requested PDU Session Establishment procedure (Section 4.3.2.2.1@3GPP TS 23.502)
//2 - UE Triggered Service Request Procedure (step 2)
Logger
::
smf_app
().
info
(
"PDU
_RES_SETUP_RSP
"
);
Logger
::
smf_app
().
info
(
"PDU
Session Resource Setup Response Transfer
"
);
if
(
sm_context_req_msg
.
rat_type_is_set
()
and
sm_context_req_msg
.
an_type_is_set
())
{
procedure_type
=
session_management_procedures_type_e
::
SERVICE_REQUEST_UE_TRIGGERED_STEP2
;
Logger
::
smf_app
().
info
(
"UE
Triggered Service Request, processing N2 SM Information"
);
"UE
-
Triggered Service Request, processing N2 SM Information"
);
}
else
{
procedure_type
=
session_management_procedures_type_e
::
PDU_SESSION_ESTABLISHMENT_UE_REQUESTED
;
...
...
@@ -1888,9 +1904,9 @@ void smf_context::handle_pdu_session_update_sm_context_request(
decoded_msg
->
dLQosFlowPerTNLInformation
.
uPTransportLayerInformation
.
choice
.
gTPTunnel
->
transportLayerAddress
.
buf
,
4
);
Logger
::
smf_app
().
debug
(
"
g
TP_TEID "
"0x%"
PRIx32
" "
,
Logger
::
smf_app
().
debug
(
"
DL G
TP_
F-
TEID
(AN F-TEID)
"
"0x%"
PRIx32
" "
,
htonl
(
dl_teid
.
teid_gre_key
));
Logger
::
smf_app
().
debug
(
"uPTransportLayerInformation IP Addr %s"
,
Logger
::
smf_app
().
debug
(
"uPTransportLayerInformation
(AN
IP Addr
)
%s"
,
conv
::
toString
(
dl_teid
.
ipv4_address
).
c_str
());
smreq
->
req
.
set_dl_fteid
(
dl_teid
);
...
...
@@ -2030,12 +2046,10 @@ void smf_context::handle_pdu_session_update_sm_context_request(
if
(
!
sm_context_req_msg
.
n1_sm_msg_is_set
()
and
!
sm_context_req_msg
.
n2_sm_info_is_set
()
and
sm_context_req_msg
.
upCnx_state_is_set
())
{
Logger
::
smf_app
().
info
(
"SERVICE_REQUEST_UE_TRIGGERED_STEP1"
);
Logger
::
smf_app
().
info
(
"Service Request (UE-triggered)"
);
Logger
::
smf_app
().
info
(
"Service Request (UE-triggered, step 1)"
);
procedure_type
=
session_management_procedures_type_e
::
SERVICE_REQUEST_UE_TRIGGERED_STEP1
;
//if request accepted-> set unCnxState to ACTIVATING
//Update upCnxState
sp
.
get
()
->
set_upCnx_state
(
upCnx_state_e
::
UPCNX_STATE_ACTIVATING
);
...
...
@@ -2044,9 +2058,45 @@ void smf_context::handle_pdu_session_update_sm_context_request(
sp
.
get
()
->
get_qos_flows
(
qos_flows
);
for
(
auto
i
:
qos_flows
)
{
smreq
->
req
.
add_qfi
(
i
.
qfi
.
qfi
);
qos_flow_context_updated
qcu
=
{
};
qcu
.
set_cause
(
REQUEST_ACCEPTED
);
qcu
.
set_qfi
(
i
.
qfi
);
qcu
.
set_ul_fteid
(
i
.
ul_fteid
);
qcu
.
set_qos_profile
(
i
.
qos_profile
);
sm_context_resp_pending
->
res
.
add_qos_flow_context_updated
(
qcu
);
}
//need update UPF
update_upf
=
true
;
sm_context_resp_pending
->
session_procedure_type
=
procedure_type
;
// Create N2 SM Information: PDU Session Resource Setup Request Transfer IE
//N2 SM Information
smf_n1_n2_inst
.
create_n2_sm_information
(
sm_context_resp_pending
->
res
,
1
,
n2_sm_info_type_e
::
PDU_RES_SETUP_REQ
,
n2_sm_info
);
smf_app_inst
->
convert_string_2_hex
(
n2_sm_info
,
n2_sm_info_hex
);
sm_context_resp_pending
->
res
.
set_n2_sm_information
(
n2_sm_info_hex
);
//fill the content of SmContextUpdatedData
sm_context_resp_pending
->
res
.
sm_context_updated_data
=
{
};
sm_context_resp_pending
->
res
.
sm_context_updated_data
[
"n2InfoContainer"
][
"n2InformationClass"
]
=
N1N2_MESSAGE_CLASS
;
sm_context_resp_pending
->
res
.
sm_context_updated_data
[
"n2InfoContainer"
][
"smInfo"
][
"PduSessionId"
]
=
sm_context_resp_pending
->
res
.
get_pdu_session_id
();
sm_context_resp_pending
->
res
.
sm_context_updated_data
[
"n2InfoContainer"
][
"smInfo"
][
"n2InfoContent"
][
"ngapData"
][
"contentId"
]
=
N2_SM_CONTENT_ID
;
sm_context_resp_pending
->
res
.
sm_context_updated_data
[
"n2InfoContainer"
][
"smInfo"
][
"n2InfoContent"
][
"ngapIeType"
]
=
"PDU_RES_SETUP_REQ"
;
//NGAP message
sm_context_resp_pending
->
res
.
sm_context_updated_data
[
"upCnxState"
]
=
"ACTIVATING"
;
//Update upCnxState to ACTIVATING
sp
.
get
()
->
set_upCnx_state
(
upCnx_state_e
::
UPCNX_STATE_ACTIVATING
);
//do not need update UPF
update_upf
=
false
;
//TODO: If new UPF is used, need to send N4 Session Modification Request/Response to new/old UPF
//Accept the activation of UP connection and continue to using the current UPF
//TODO: Accept the activation of UP connection and select a new UPF
...
...
@@ -2340,19 +2390,18 @@ void smf_context::handle_pdu_session_modification_network_requested(
void
smf_context
::
insert_dnn_subscription
(
const
snssai_t
&
snssai
,
std
::
shared_ptr
<
session_management_subscription
>
&
ss
)
{
Logger
::
smf_app
().
info
(
"Insert dnn subscription, key: %d"
,
(
uint8_t
)
snssai
.
sST
);
//std::unique_lock<std::recursive_mutex> lock(m_context);
//dnn_subscriptions.insert (std::make_pair <const uint8_t, std::shared_ptr<session_management_subscription> >((uint8_t)snssai.sST, ss));
dnn_subscriptions
[(
uint8_t
)
snssai
.
sST
]
=
ss
;
Logger
::
smf_app
().
info
(
"Inserted DNN Subscription, key: %d"
,
(
uint8_t
)
snssai
.
sST
);
}
//------------------------------------------------------------------------------
bool
smf_context
::
find_dnn_subscription
(
const
snssai_t
&
snssai
,
std
::
shared_ptr
<
session_management_subscription
>
&
ss
)
{
Logger
::
smf_app
().
info
(
"
f
ind
_dnn_s
ubscription: %d, map size %d"
,
Logger
::
smf_app
().
info
(
"
F
ind
a DNN S
ubscription
with key
: %d, map size %d"
,
(
uint8_t
)
snssai
.
sST
,
dnn_subscriptions
.
size
());
//std::unique_lock<std::recursive_mutex> lock(m_context);
if
(
dnn_subscriptions
.
count
((
uint8_t
)
snssai
.
sST
)
>
0
)
{
...
...
@@ -2360,9 +2409,8 @@ bool smf_context::find_dnn_subscription(
return
true
;
}
Logger
::
smf_app
().
info
(
"find_dnn_subscription: cannot find DNN subscription for SNSSAI %d"
,
(
uint8_t
)
snssai
.
sST
);
Logger
::
smf_app
().
info
(
"DNN subscription (SNSSAI %d) not found"
,
(
uint8_t
)
snssai
.
sST
);
return
false
;
}
...
...
src/smf_app/smf_context.hpp
View file @
6a4351b4
...
...
@@ -200,6 +200,13 @@ class smf_pdu_session : public std::enable_shared_from_this<smf_pdu_session> {
*/
void
set_default_qos_flow
(
const
pfcp
::
qfi_t
&
qfi
);
/*
* Get the default QoS flow of this PDU Session
* @param [smf_qos_flow &] flow: Default QoS flow
* @return bool: Return true if the default QoS flow exist
*/
bool
get_default_qos_flow
(
smf_qos_flow
&
flow
);
/*
* Find a QoS flow by its PDR ID
* @param [const pfcp::pdr_id_t &] pdr_id: PDR ID
...
...
src/smf_app/smf_msg.cpp
View file @
6a4351b4
...
...
@@ -457,11 +457,11 @@ void pdu_session_update_sm_context_response::add_qos_flow_context_updated(
std
::
pair
<
uint8_t
,
qos_flow_context_updated
>
((
uint8_t
)
flow
.
qfi
.
qfi
,
flow
));
Logger
::
smf_app
().
trace
(
"
pdu_session_update_sm_context_response::add_qos_flow_context(%d)
success"
,
"
A QoS Flow Context (QFI %d) has been added
success
fully
"
,
flow
.
qfi
.
qfi
);
}
else
{
Logger
::
smf_app
().
error
(
"
pdu_session_update_sm_context_response::add_qos_f
low
_c
ontext
(%d) failed
, invalid QFI"
,
"
Failed to add a QoS F
low
C
ontext
(QFI %d)
, invalid QFI"
,
flow
.
qfi
.
qfi
);
}
}
...
...
src/smf_app/smf_msg.hpp
View file @
6a4351b4
...
...
@@ -423,9 +423,7 @@ class pdu_session_release_sm_context_request : public pdu_session_msg {
}
;
private:
};
class
pdu_session_release_sm_context_response
:
public
pdu_session_msg
{
...
...
src/smf_app/smf_n10.cpp
View file @
6a4351b4
...
...
@@ -119,7 +119,7 @@ bool smf_n10::get_sm_data(
inet_ntoa
(
*
((
struct
in_addr
*
)
&
smf_cfg
.
udm_addr
.
ipv4_addr
)))
+
":"
+
std
::
to_string
(
smf_cfg
.
udm_addr
.
port
)
+
fmt
::
format
(
NUDM_SDM_GET_SM_DATA_URL
,
std
::
to_string
(
supi
));
Logger
::
smf_n10
().
debug
(
"
[get_sm_data]
UDM's URL: %s "
,
url
.
c_str
());
Logger
::
smf_n10
().
debug
(
"UDM's URL: %s "
,
url
.
c_str
());
if
(
curl
)
{
CURLcode
res
=
{
};
...
...
@@ -142,13 +142,13 @@ bool smf_n10::get_sm_data(
while
(
numRetries
<
UDM_NUMBER_RETRIES
)
{
res
=
curl_easy_perform
(
curl
);
curl_easy_getinfo
(
curl
,
CURLINFO_RESPONSE_CODE
,
&
httpCode
);
Logger
::
smf_n10
().
debug
(
"
[get_sm_data]
Response from UDM, H
ttp
Code: %d "
,
Logger
::
smf_n10
().
debug
(
"Response from UDM, H
TTP
Code: %d "
,
httpCode
);
if
(
static_cast
<
http_response_codes_e
>
(
httpCode
)
==
http_response_codes_e
::
HTTP_RESPONSE_CODE_OK
)
{
Logger
::
smf_n10
().
debug
(
"
[get_sm_data]
Got successful response from UDM, URL: %s "
,
"Got successful response from UDM, URL: %s "
,
url
.
c_str
());
//Logger::smf_n10().debug("[get_sm_data] Http Data from UDM: %s ", *httpData.get());
try
{
...
...
@@ -157,12 +157,12 @@ bool smf_n10::get_sm_data(
break
;
}
catch
(
json
::
exception
&
e
)
{
Logger
::
smf_n10
().
warn
(
"
[get_sm_data]
Could
n'
t
P
arse json data from UDM"
);
"Could
no
t
p
arse json data from UDM"
);
}
numRetries
++
;
}
else
{
Logger
::
smf_n10
().
warn
(
"
[get_sm_data] Couldn't GET
response from UDM, URL %s, retry ..."
,
"
Could not get
response from UDM, URL %s, retry ..."
,
url
.
c_str
());
//retry
numRetries
++
;
...
...
@@ -173,13 +173,13 @@ bool smf_n10::get_sm_data(
//process the response
if
(
!
jsonData
.
empty
())
{
Logger
::
smf_n10
().
debug
(
"
[get_sm_data] GET r
esponse from UDM %s"
,
Logger
::
smf_n10
().
debug
(
"
R
esponse from UDM %s"
,
jsonData
.
dump
().
c_str
());
//retrieve SessionManagementSubscription and store in the context
for
(
nlohmann
::
json
::
iterator
it
=
jsonData
[
"dnnConfigurations"
].
begin
();
it
!=
jsonData
[
"dnnConfigurations"
].
end
();
++
it
)
{
Logger
::
smf_n10
().
debug
(
"
[get_sm_data]
DNN %s"
,
it
.
key
().
c_str
());
Logger
::
smf_n10
().
debug
(
"DNN %s"
,
it
.
key
().
c_str
());
try
{
std
::
shared_ptr
<
dnn_configuration_t
>
dnn_configuration
=
std
::
make_shared
<
dnn_configuration_t
>
();
...
...
@@ -188,7 +188,7 @@ bool smf_n10::get_sm_data(
pdu_session_type_e
::
PDU_SESSION_TYPE_E_IPV4
);
std
::
string
default_session_type
=
it
.
value
()[
"pduSessionTypes"
][
"defaultSessionType"
];
Logger
::
smf_n10
().
debug
(
"
[get_sm_data] d
efault
_
session
_
type %s"
,
Logger
::
smf_n10
().
debug
(
"
D
efault
session
type %s"
,
default_session_type
.
c_str
());
if
(
default_session_type
.
compare
(
"IPV4"
)
==
0
)
{
pdu_session_type
.
pdu_session_type
=
...
...
@@ -206,7 +206,7 @@ bool smf_n10::get_sm_data(
//Ssc_Mode
ssc_mode_t
ssc_mode
(
ssc_mode_e
::
SSC_MODE_1
);
std
::
string
default_ssc_mode
=
it
.
value
()[
"sscModes"
][
"defaultSscMode"
];
Logger
::
smf_n10
().
debug
(
"
[get_sm_data] d
efault
Ssc
Mode %s"
,
Logger
::
smf_n10
().
debug
(
"
D
efault
SSC
Mode %s"
,
default_ssc_mode
.
c_str
());
if
(
default_ssc_mode
.
compare
(
"SSC_MODE_1"
)
==
0
)
{
dnn_configuration
->
ssc_modes
.
default_ssc_mode
=
ssc_mode_t
(
...
...
@@ -236,15 +236,14 @@ bool smf_n10::get_sm_data(
dnn_configuration
->
session_ambr
.
downlink
=
it
.
value
()[
"sessionAmbr"
][
"downlink"
];
Logger
::
smf_n10
().
debug
(
"
[get_sm_data] sessionAmbr u
plink %s,
d
ownlink %s"
,
"
Session AMBR U
plink %s,
D
ownlink %s"
,
dnn_configuration
->
session_ambr
.
uplink
.
c_str
(),
dnn_configuration
->
session_ambr
.
downlink
.
c_str
());
//sdc = std::shared_ptr<dnn_configuration_t> (dnn_configuration);
subscription
->
insert_dnn_configuration
(
it
.
key
(),
dnn_configuration
);
}
catch
(
nlohmann
::
json
::
exception
&
e
)
{
Logger
::
smf_n10
().
warn
(
"
[get_sm_data] e
xception message %s, exception id %d "
,
e
.
what
(),
"
E
xception message %s, exception id %d "
,
e
.
what
(),
e
.
id
);
return
false
;
}
...
...
src/smf_app/smf_n11.cpp
View file @
6a4351b4
...
...
@@ -443,7 +443,7 @@ void smf_n11::send_n1n2_message_transfer_request(
//------------------------------------------------------------------------------
void
smf_n11
::
send_pdu_session_update_sm_context_response
(
std
::
shared_ptr
<
itti_n11_update_sm_context_response
>
sm_context_res
)
{
Logger
::
smf_n11
().
debug
(
"Send PDUSessionUpdateContextResponse to AMF
"
);
Logger
::
smf_n11
().
debug
(
"Send PDUSession
_
Update
SM
Context
Response to AMF
.
"
);
switch
(
sm_context_res
->
session_procedure_type
)
{
...
...
@@ -591,7 +591,7 @@ void smf_n11::send_pdu_session_update_sm_context_response(
Pistache
::
Http
::
Code
code
)
{
Logger
::
smf_n11
().
debug
(
"
[SMF N11]
Send PDUSessionUpdateContextResponse to AMF
!
"
);
"Send PDUSession
_
Update
SM
Context
Response to AMF
.
"
);
nlohmann
::
json
json_data
=
{
};
to_json
(
json_data
,
smContextUpdateError
);
...
...
@@ -611,7 +611,7 @@ void smf_n11::send_pdu_session_update_sm_context_response(
oai
::
smf_server
::
model
::
SmContextUpdateError
&
smContextUpdateError
,
Pistache
::
Http
::
Code
code
,
std
::
string
&
n1_sm_msg
)
{
Logger
::
smf_n11
().
debug
(
"
[SMF N11]
Send PDUSessionUpdateContextResponse to AMF
!
"
);
"Send PDUSession
_
Update
SM
Context
Response to AMF
.
"
);
std
::
string
boundary
=
"----Boundary"
;
nlohmann
::
json
json_part
=
{
};
...
...
@@ -634,7 +634,7 @@ void smf_n11::send_pdu_session_create_sm_context_response(
oai
::
smf_server
::
model
::
SmContextCreateError
&
smContextCreateError
,
Pistache
::
Http
::
Code
code
,
std
::
string
&
n1_sm_msg
)
{
Logger
::
smf_n11
().
debug
(
"
[SMF N11]
Send PDUSessionCreateContextResponse to AMF
!
"
);
"Send PDUSession
_
Create
SM
Context
Response to AMF
.
"
);
std
::
string
boundary
=
"----Boundary"
;
nlohmann
::
json
json_part
=
{
};
...
...
@@ -657,7 +657,7 @@ void smf_n11::send_pdu_session_update_sm_context_response(