Commit 53cbf6ec authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

code cleanup

parent cac0624f
#
# Copyright (c) 2015, EURECOM (www.eurecom.fr)
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# The views and conclusions contained in the software and documentation are those
# of the authors and should not be interpreted as representing official policies,
# either expressed or implied, of the FreeBSD Project.
#
# see https://clang.llvm.org/docs/ClangFormatStyleOptions.html for explanation
# of style options
BasedOnStyle: Google
Language: Cpp
IndentWidth: 2
ColumnLimit: 80
IncludeBlocks: Preserve
SortIncludes: false
# alignment
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments: true
---
Language: Cpp
# BasedOnStyle: Google
AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: true
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
DerivePointerAlignment: false
PointerAlignment: Left
# function style
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortFunctionsOnASingleLine: Inline
AlwaysBreakAfterReturnType: None
IndentWrappedFunctionNames: false
# template style
#AlwaysBreakTemplateDeclarations: Yes
# preprocessor style
IndentPPDirectives: None
# block style
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
KeepEmptyLinesAtTheStartOfBlocks: false
# break style
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: true
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: false
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: true
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeCategories:
- Regex: '^<.*\.h>'
Priority: 1
- Regex: '^<.*'
Priority: 2
- Regex: '.*'
Priority: 3
IncludeIsMainRegex: '([-_](test|unittest))?$'
IndentCaseLabels: true
IndentWidth: 2
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
ReflowComments: true
# spacing style
UseTab: Never
SpaceAfterCStyleCast: true
SpaceAfterTemplateKeyword: false
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: false
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
#SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
#SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
# class style
BreakConstructorInitializers: BeforeColon
#BreakInheritanceList: BeforeColon
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
# case statements
IndentCaseLabels: true
# cpp
Cpp11BracedListStyle: true
FixNamespaceComments: true
NamespaceIndentation: None
SortUsingDeclarations: true
# todo
# AlwaysBreakBeforeMultilineStrings: bool
# PenaltyBreakAssignment (unsigned)
# PenaltyBreakBeforeFirstCallParameter (unsigned)
# PenaltyBreakComment (unsigned)
# PenaltyBreakFirstLessLess (unsigned)
# PenaltyBreakString (unsigned)
# PenaltyBreakTemplateDeclaration (unsigned)
# PenaltyExcessCharacter (unsigned)
# PenaltyReturnTypeOnItsOwnLine (unsigned)
Standard: Auto
TabWidth: 8
UseTab: Never
...
......@@ -554,9 +554,6 @@ void smf_app::handle_pdu_session_create_sm_context_request(
"Handle a PDU Session Create SM Context Request from an AMF (HTTP version %d)",
smreq->http_version);
//handle PDU Session Create SM Context Request as specified in section 4.3.2 3GPP TS 23.502
oai::smf_server::model::SmContextCreateError smContextCreateError = { };
oai::smf_server::model::ProblemDetails problem_details = { };
oai::smf_server::model::RefToBinaryData refToBinaryData = { };
std::string n1_sm_message, n1_sm_message_hex;
nas_message_t decoded_nas_msg = { };
cause_value_5gsm_e cause_n1 = { cause_value_5gsm_e::CAUSE_0_UNKNOWN };
......@@ -572,19 +569,15 @@ void smf_app::handle_pdu_session_create_sm_context_request(
//Failed to decode, send reply to AMF with PDU Session Establishment Reject
if (decoder_rc != RETURNok) {
Logger::smf_app().warn("N1 SM container cannot be decoded correctly!");
problem_details.setCause(
pdu_session_application_error_e2str[PDU_SESSION_APPLICATION_ERROR_N1_SM_ERROR]);
smContextCreateError.setError(problem_details);
refToBinaryData.setContentId(N1_SM_CONTENT_ID);
smContextCreateError.setN1SmMsg(refToBinaryData);
if (smf_n1::get_instance().create_n1_pdu_session_establishment_reject(
smreq->req, n1_sm_message,
cause_value_5gsm_e::CAUSE_95_SEMANTICALLY_INCORRECT_MESSAGE)) {
smf_app_inst->convert_string_2_hex(n1_sm_message, n1_sm_message_hex);
//trigger to send reply to AMF
trigger_http_response(http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
smContextCreateError, n1_sm_message_hex,
smreq->pid);
trigger_create_context_error_response(http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
PDU_SESSION_APPLICATION_ERROR_N1_SM_ERROR, n1_sm_message_hex,
smreq->pid);
} else {
//trigger to send reply to AMF
trigger_http_response(
......@@ -627,19 +620,14 @@ void smf_app::handle_pdu_session_create_sm_context_request(
cause_n1 = cause_value_5gsm_e::CAUSE_28_UNKNOWN_PDU_SESSION_TYPE;
}
if (pdu_session_type.pdu_session_type != PDU_SESSION_TYPE_E_IPV4) {
problem_details.setCause(
pdu_session_application_error_e2str[PDU_SESSION_APPLICATION_ERROR_PDUTYPE_DENIED]);
smContextCreateError.setError(problem_details);
refToBinaryData.setContentId(N1_SM_CONTENT_ID);
smContextCreateError.setN1SmMsg(refToBinaryData);
//PDU Session Establishment Reject
if (smf_n1::get_instance().create_n1_pdu_session_establishment_reject(smreq->req,
n1_sm_message, cause_n1)) {
smf_app_inst->convert_string_2_hex(n1_sm_message, n1_sm_message_hex);
//trigger to send reply to AMF
trigger_http_response(http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
smContextCreateError, n1_sm_message_hex,
smreq->pid);
trigger_create_context_error_response(http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
PDU_SESSION_APPLICATION_ERROR_PDUTYPE_DENIED, n1_sm_message_hex,
smreq->pid);
} else {
trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_500_INTERNAL_SERVER_ERROR,
......@@ -678,20 +666,15 @@ void smf_app::handle_pdu_session_create_sm_context_request(
|| (pti.procedure_transaction_id > PROCEDURE_TRANSACTION_IDENTITY_LAST )) {
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]);
smContextCreateError.setError(problem_details);
refToBinaryData.setContentId(N1_SM_CONTENT_ID);
smContextCreateError.setN1SmMsg(refToBinaryData);
//PDU Session Establishment Reject including cause "#81 Invalid PTI value" (section 7.3.1 @3GPP TS 24.501)
if (smf_n1::get_instance().create_n1_pdu_session_establishment_reject(
smreq->req, n1_sm_message,
cause_value_5gsm_e::CAUSE_81_INVALID_PTI_VALUE)) {
smf_app_inst->convert_string_2_hex(n1_sm_message, n1_sm_message_hex);
//trigger to send reply to AMF
trigger_http_response(http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
smContextCreateError, n1_sm_message_hex,
smreq->pid);
trigger_create_context_error_response(http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
PDU_SESSION_APPLICATION_ERROR_N1_SM_ERROR, n1_sm_message_hex,
smreq->pid);
} else {
trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_500_INTERNAL_SERVER_ERROR,
......@@ -717,11 +700,6 @@ void smf_app::handle_pdu_session_create_sm_context_request(
if (message_type != PDU_SESSION_ESTABLISHMENT_REQUEST) {
Logger::smf_app().warn("Invalid message type (message type = %d)",
message_type);
problem_details.setCause(
pdu_session_application_error_e2str[PDU_SESSION_APPLICATION_ERROR_N1_SM_ERROR]);
smContextCreateError.setError(problem_details);
refToBinaryData.setContentId(N1_SM_CONTENT_ID);
smContextCreateError.setN1SmMsg(refToBinaryData);
//PDU Session Establishment Reject
//(24.501 (section 7.4)) implementation dependent->do similar to UE: response with a 5GSM STATUS message including cause "#98 message type not compatible with protocol state."
if (smf_n1::get_instance().create_n1_pdu_session_establishment_reject(
......@@ -730,9 +708,9 @@ void smf_app::handle_pdu_session_create_sm_context_request(
cause_value_5gsm_e::CAUSE_98_MESSAGE_TYPE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE)) {
smf_app_inst->convert_string_2_hex(n1_sm_message, n1_sm_message_hex);
//trigger to send reply to AMF
trigger_http_response(http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
smContextCreateError, n1_sm_message_hex,
smreq->pid);
trigger_create_context_error_response(http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
PDU_SESSION_APPLICATION_ERROR_N1_SM_ERROR, n1_sm_message_hex,
smreq->pid);
} else {
trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_500_INTERNAL_SERVER_ERROR,
......@@ -758,20 +736,15 @@ void smf_app::handle_pdu_session_create_sm_context_request(
Logger::smf_app().warn(
"Received a PDU Session Create SM Context Request: unknown requested DNN %s, ignore message!",
dnn.c_str());
problem_details.setCause(
pdu_session_application_error_e2str[PDU_SESSION_APPLICATION_ERROR_DNN_DENIED]);
smContextCreateError.setError(problem_details);
refToBinaryData.setContentId(N1_SM_CONTENT_ID);
smContextCreateError.setN1SmMsg(refToBinaryData);
//PDU Session Establishment Reject, 24.501 cause "#27 Missing or unknown DNN"
if (smf_n1::get_instance().create_n1_pdu_session_establishment_reject(
smreq->req, n1_sm_message,
cause_value_5gsm_e::CAUSE_27_MISSING_OR_UNKNOWN_DNN)) {
smf_app_inst->convert_string_2_hex(n1_sm_message, n1_sm_message_hex);
//trigger to send reply to AMF
trigger_http_response(http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
smContextCreateError, n1_sm_message_hex,
smreq->pid);
trigger_create_context_error_response(http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
PDU_SESSION_APPLICATION_ERROR_DNN_DENIED, n1_sm_message_hex,
smreq->pid);
} else {
trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_500_INTERNAL_SERVER_ERROR,
......@@ -844,11 +817,6 @@ void smf_app::handle_pdu_session_create_sm_context_request(
// Cannot retrieve information from UDM, reject PDU session establishment
Logger::smf_app().warn(
"Received a PDU Session Create SM Context Request, couldn't retrieve the Session Management Subscription from UDM, ignore message!");
problem_details.setCause(
pdu_session_application_error_e2str[PDU_SESSION_APPLICATION_ERROR_SUBSCRIPTION_DENIED]);
smContextCreateError.setError(problem_details);
refToBinaryData.setContentId(N1_SM_CONTENT_ID);
smContextCreateError.setN1SmMsg(refToBinaryData);
//PDU Session Establishment Reject, with cause "29 User authentication or authorization failed"
if (smf_n1::get_instance().create_n1_pdu_session_establishment_reject(
smreq->req,
......@@ -856,9 +824,10 @@ void smf_app::handle_pdu_session_create_sm_context_request(
cause_value_5gsm_e::CAUSE_29_USER_AUTHENTICATION_OR_AUTHORIZATION_FAILED)) {
smf_app_inst->convert_string_2_hex(n1_sm_message, n1_sm_message_hex);
//trigger to send reply to AMF
trigger_http_response(
trigger_create_context_error_response (
http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
smContextCreateError, n1_sm_message_hex, smreq->pid);
PDU_SESSION_APPLICATION_ERROR_SUBSCRIPTION_DENIED, n1_sm_message_hex, smreq->pid);
} else {
trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_500_INTERNAL_SERVER_ERROR,
......@@ -906,8 +875,6 @@ void smf_app::handle_pdu_session_update_sm_context_request(
Logger::smf_app().info(
"Handle a PDU Session Update SM Context Request from an AMF (HTTP version %d)",
smreq->http_version);
oai::smf_server::model::SmContextUpdateError smContextUpdateError = { };
oai::smf_server::model::ProblemDetails problem_details = { };
//Step 1. get supi, dnn, nssai, pdu_session id from sm_context
//SM Context ID - uint32_t in our case
......@@ -917,12 +884,10 @@ void smf_app::handle_pdu_session_update_sm_context_request(
} catch (const std::exception &err) {
Logger::smf_app().warn(
"Received a PDU Session Update SM Context Request, couldn't retrieve the corresponding SMF context, ignore message!");
problem_details.setCause(
pdu_session_application_error_e2str[PDU_SESSION_APPLICATION_ERROR_CONTEXT_NOT_FOUND]);
smContextUpdateError.setError(problem_details);
//trigger to send reply to AMF
trigger_http_response(http_status_code_e::HTTP_STATUS_CODE_404_NOT_FOUND,
smContextUpdateError, smreq->pid);
trigger_update_context_error_response(http_status_code_e::HTTP_STATUS_CODE_404_NOT_FOUND,
PDU_SESSION_APPLICATION_ERROR_CONTEXT_NOT_FOUND, smreq->pid);
return;
}
......@@ -933,12 +898,9 @@ void smf_app::handle_pdu_session_update_sm_context_request(
} else {
Logger::smf_app().warn(
"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);
//trigger to send reply to AMF
trigger_http_response(http_status_code_e::HTTP_STATUS_CODE_404_NOT_FOUND,
smContextUpdateError, smreq->pid);
trigger_update_context_error_response(http_status_code_e::HTTP_STATUS_CODE_404_NOT_FOUND,
PDU_SESSION_APPLICATION_ERROR_CONTEXT_NOT_FOUND, smreq->pid);
return;
}
......@@ -960,12 +922,10 @@ void smf_app::handle_pdu_session_update_sm_context_request(
Logger::smf_app().warn(
"Received PDU Session Update SM Context Request with Supi " SUPI_64_FMT "couldn't retrieve the corresponding SMF context, ignore message!",
supi64);
problem_details.setCause(
pdu_session_application_error_e2str[PDU_SESSION_APPLICATION_ERROR_CONTEXT_NOT_FOUND]);
smContextUpdateError.setError(problem_details);
//trigger to send reply to AMF
trigger_http_response(http_status_code_e::HTTP_STATUS_CODE_404_NOT_FOUND,
smContextUpdateError, smreq->pid);
trigger_update_context_error_response(http_status_code_e::HTTP_STATUS_CODE_404_NOT_FOUND,
PDU_SESSION_APPLICATION_ERROR_CONTEXT_NOT_FOUND, smreq->pid);
return;
}
......@@ -977,12 +937,10 @@ void smf_app::handle_pdu_session_update_sm_context_request(
//Error, DNN context doesn't exist, send PDUSession_SMUpdateContext Response to AMF
Logger::smf_app().warn(
"Received PDU Session Update SM Context Request, couldn't retrieve the corresponding SMF context, ignore message!");
problem_details.setCause(
pdu_session_application_error_e2str[PDU_SESSION_APPLICATION_ERROR_CONTEXT_NOT_FOUND]);
smContextUpdateError.setError(problem_details);
//trigger to send reply to AMF
trigger_http_response(http_status_code_e::HTTP_STATUS_CODE_404_NOT_FOUND,
smContextUpdateError, smreq->pid);
trigger_update_context_error_response(http_status_code_e::HTTP_STATUS_CODE_404_NOT_FOUND,
PDU_SESSION_APPLICATION_ERROR_CONTEXT_NOT_FOUND, smreq->pid);
return;
}
}
......@@ -1240,8 +1198,8 @@ bool smf_app::use_local_configuration_subscription_data(
//------------------------------------------------------------------------------
bool smf_app::is_supi_dnn_snssai_subscription_data(
const supi_t &supi, const std::string &dnn, const snssai_t &snssai) const {
//TODO: should be implemented
return false; //Session Management Subscription from UDM isn't available
// TODO: should be implemented
return false; // Session Management Subscription from UDM isn't available
}
//------------------------------------------------------------------------------
......@@ -1524,19 +1482,27 @@ void smf_app::add_promise(
}
//---------------------------------------------------------------------------------------------
void smf_app::trigger_http_response(
const uint32_t &http_code,
const oai::smf_server::model::SmContextCreateError &smContextCreateError,
void smf_app::trigger_create_context_error_response(
const uint32_t &http_code, const uint8_t &cause,
const std::string &n1_sm_msg, uint32_t &promise_id) {
Logger::smf_app().debug(
"Send ITTI msg to SMF APP to trigger the response of Server");
oai::smf_server::model::SmContextCreateError sm_context = {};
oai::smf_server::model::ProblemDetails problem_details = {};
oai::smf_server::model::RefToBinaryData refToBinaryData = {};
Logger::smf_app().warn("Create SmContextCreateError");
problem_details.setCause(pdu_session_application_error_e2str[cause]);
sm_context.setError(problem_details);
refToBinaryData.setContentId(N1_SM_CONTENT_ID);
sm_context.setN1SmMsg(refToBinaryData);
std::shared_ptr<itti_n11_create_sm_context_response> itti_msg =
std::make_shared<itti_n11_create_sm_context_response>(TASK_SMF_N11,
TASK_SMF_APP,
promise_id);
pdu_session_create_sm_context_response sm_context_response = { };
nlohmann::json json_data = { };
to_json(json_data, smContextCreateError);
std::make_shared<itti_n11_create_sm_context_response>(
TASK_SMF_N11, TASK_SMF_APP, promise_id);
pdu_session_create_sm_context_response sm_context_response = {};
nlohmann::json json_data = {};
to_json(json_data, sm_context);
sm_context_response.set_json_data(json_data);
sm_context_response.set_json_format("application/problem+json");
sm_context_response.set_n1_sm_message(n1_sm_msg);
......@@ -1551,19 +1517,22 @@ void smf_app::trigger_http_response(
}
//---------------------------------------------------------------------------------------------
void smf_app::trigger_http_response(
const uint32_t &http_code,
const oai::smf_server::model::SmContextUpdateError &smContextUpdateError,
uint32_t &promise_id) {
void smf_app::trigger_update_context_error_response(const uint32_t &http_code,
const uint8_t &cause,
uint32_t &promise_id) {
Logger::smf_app().debug(
"Send ITTI msg to SMF APP to trigger the response of API Server");
oai::smf_server::model::SmContextUpdateError smContextUpdateError = {};
oai::smf_server::model::ProblemDetails problem_details = {};
problem_details.setCause(pdu_session_application_error_e2str[cause]);
smContextUpdateError.setError(problem_details);
std::shared_ptr<itti_n11_update_sm_context_response> itti_msg =
std::make_shared<itti_n11_update_sm_context_response>(TASK_SMF_N11,
TASK_SMF_APP,
promise_id);
pdu_session_update_sm_context_response sm_context_response = { };
nlohmann::json json_data = { };
std::make_shared<itti_n11_update_sm_context_response>(
TASK_SMF_N11, TASK_SMF_APP, promise_id);
pdu_session_update_sm_context_response sm_context_response = {};
nlohmann::json json_data = {};
to_json(json_data, smContextUpdateError);
sm_context_response.set_json_data(json_data);
sm_context_response.set_json_format("application/problem+json");
......@@ -1575,24 +1544,25 @@ void smf_app::trigger_http_response(
"Could not send ITTI message %s to task TASK_SMF_APP",
itti_msg->get_msg_name());
}
}
//---------------------------------------------------------------------------------------------
void smf_app::trigger_http_response(
const uint32_t &http_code,
const oai::smf_server::model::SmContextUpdateError &smContextUpdateError,
void smf_app::trigger_update_context_error_response(
const uint32_t &http_code, const uint8_t &cause,
const std::string &n1_sm_msg, uint32_t &promise_id) {
Logger::smf_app().debug(
"Send ITTI msg to SMF APP to trigger the response of HTTP Server");
oai::smf_server::model::SmContextUpdateError smContextUpdateError = {};
oai::smf_server::model::ProblemDetails problem_details = {};
problem_details.setCause(pdu_session_application_error_e2str[cause]);
smContextUpdateError.setError(problem_details);
std::shared_ptr<itti_n11_update_sm_context_response> itti_msg =
std::make_shared<itti_n11_update_sm_context_response>(TASK_SMF_N11,
TASK_SMF_APP,
promise_id);
pdu_session_update_sm_context_response sm_context_response = { };
nlohmann::json json_data = { };
std::make_shared<itti_n11_update_sm_context_response>(
TASK_SMF_N11, TASK_SMF_APP, promise_id);
pdu_session_update_sm_context_response sm_context_response = {};
nlohmann::json json_data = {};
to_json(json_data, smContextUpdateError);
sm_context_response.set_json_data(json_data);
sm_context_response.set_json_format("application/problem+json");
......@@ -1605,7 +1575,6 @@ void smf_app::trigger_http_response(
"Could not send ITTI message %s to task TASK_SMF_APP",
itti_msg->get_msg_name());
}
}
//---------------------------------------------------------------------------------------------
......
......@@ -636,43 +636,44 @@ class smf_app {
/*
* To trigger the response to the HTTP server by set the value of the corresponding promise to ready
* @param [const uint32_t &] http_code: Status code of HTTP response
* @param [const oai::smf_server::model::SmContextCreateError &] smContextCreateError: store the json content of response message
* @param [const uint8_t&] cause: Error cause
* @param [const std::string &] n1_sm_msg: N1 SM message
* @param [uint32_t &] promise_id: Promise Id
* @return void
*/
void trigger_http_response(
void trigger_create_context_error_response(
const uint32_t &http_code,
const oai::smf_server::model::SmContextCreateError &smContextCreateError,
const uint8_t &cause,
const std::string &n1_sm_msg, uint32_t &promise_id);
/*
* To trigger the response to the HTTP server by set the value of the corresponding promise to ready
* @param [const uint32_t &] http_code: Status code of HTTP response
* @param [const oai::smf_server::model::SmContextCreateError &] smContextCreateError: store the json content of response message
* @param [const uint8_t &] cause: Error cause
* @param [uint32_t &] promise_id: Promise Id
* @param [uint8_t] msg_type: Type of HTTP message (Update/Release)
* @return void
*/
void trigger_http_response(
void trigger_update_context_error_response(
const uint32_t &http_code,
const oai::smf_server::model::SmContextUpdateError &smContextUpdateError,
const uint8_t &cause,
uint32_t &promise_id);
/*
* To trigger the response to the HTTP server by set the value of the corresponding promise to ready
* @param [const uint32_t &] http_code: Status code of HTTP response
* @param [const oai::smf_server::model::SmContextUpdateError &] smContextUpdateError: store the json content of response message
* @param [const uint8_t &] cause: cause
* @param [const std::string &] n1_sm_msg: N1 SM message
* @param [uint32_t &] promise_id: Promise Id
* @param [uint8_t] msg_type: Type of HTTP message (Update/Release)
* @return void
*/
void trigger_http_response(
void trigger_update_context_error_response(
const uint32_t &http_code,
const oai::smf_server::model::SmContextUpdateError &smContextUpdateError,
const uint8_t &cause,
const std::string &n1_sm_msg, uint32_t &promise_id);
/*
* To trigger the response to the HTTP server by set the value of the corresponding promise to ready
* @param [const uint32_t &] http_code: Status code of HTTP response
......
......@@ -40,7 +40,6 @@
#include "smf_n2.hpp"
#include "smf_paa_dynamic.hpp"
#include "smf_procedure.hpp"
#include "ProblemDetails.h"
#include "3gpp_29.500.h"
#include "3gpp_29.502.h"
#include "3gpp_24.501.h"
......@@ -1167,9 +1166,6 @@ void smf_context::handle_pdu_session_create_sm_context_request(
"Handle a PDU Session Create SM Context Request message from AMF (HTTP version %d)",
smreq->http_version);
oai::smf_server::model::SmContextCreateError smContextCreateError = { };
oai::smf_server::model::ProblemDetails problem_details = { };
oai::smf_server::model::RefToBinaryData refToBinaryData = { };
std::string n1_sm_message, n1_sm_msg_hex;
bool request_accepted = true;
......@@ -1186,20 +1182,15 @@ void smf_context::handle_pdu_session_create_sm_context_request(
// Not a valid request...
Logger::smf_app().warn(
"Received a PDU Session Create SM Context Request, the request is not valid!");
problem_details.setCause(
pdu_session_application_error_e2str[PDU_SESSION_APPLICATION_ERROR_SUBSCRIPTION_DENIED]);
smContextCreateError.setError(problem_details);
refToBinaryData.setContentId(N1_SM_CONTENT_ID);
smContextCreateError.setN1SmMsg(refToBinaryData);
if (smf_n1::get_instance().create_n1_pdu_session_establishment_reject(
smreq->req,
n1_sm_message,
cause_value_5gsm_e::CAUSE_29_USER_AUTHENTICATION_OR_AUTHORIZATION_FAILED)) {
smf_app_inst->convert_string_2_hex(n1_sm_message, n1_sm_msg_hex);
//trigger to send reply to AMF
smf_app_inst->trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_401_UNAUTHORIZED,
smContextCreateError, n1_sm_msg_hex, smreq->pid);
smf_app_inst->trigger_create_context_error_response(
http_status_code_e::HTTP_STATUS_CODE_401_UNAUTHORIZED,
PDU_SESSION_APPLICATION_ERROR_SUBSCRIPTION_DENIED, n1_sm_msg_hex, smreq->pid);
} else {
smf_app_inst->trigger_http_response(
......@@ -1353,20 +1344,16 @@ void smf_context::handle_pdu_session_create_sm_context_request(
default:
Logger::smf_app().error("Unknown PDN type %d", sp->pdu_session_type.pdu_session_type);
problem_details.setCause(
pdu_session_application_error_e2str[PDU_SESSION_APPLICATION_ERROR_PDUTYPE_DENIED]);
smContextCreateError.setError(problem_details);
refToBinaryData.setContentId(N1_SM_CONTENT_ID);
smContextCreateError.setN1SmMsg(refToBinaryData);
//PDU Session Establishment Reject
if (smf_n1::get_instance().create_n1_pdu_session_establishment_reject(
smreq->req, n1_sm_message,
cause_value_5gsm_e::CAUSE_28_UNKNOWN_PDU_SESSION_TYPE)) {
smf_app_inst->convert_string_2_hex(n1_sm_message, n1_sm_msg_hex);
//trigger to send reply to AMF
smf_app_inst->trigger_http_response(
//trigger to send reply to AMF
smf_app_inst->trigger_create_context_error_response(
http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
smContextCreateError, n1_sm_msg_hex, smreq->pid);
PDU_SESSION_APPLICATION_ERROR_PDUTYPE_DENIED, n1_sm_msg_hex, smreq->pid);
} else {
smf_app_inst->trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_500_INTERNAL_SERVER_ERROR,
......@@ -1538,10 +1525,6 @@ void smf_context::handle_pdu_session_update_sm_context_request(
"Handle a PDU Session Update SM Context Request message from an AMF (HTTP version %d)",
smreq->http_version);
pdu_session_update_sm_context_request sm_context_req_msg = smreq->req;
oai::smf_server::model::SmContextUpdateError smContextUpdateError = { };
oai::smf_server::model::SmContextUpdatedData smContextUpdatedData = { };
oai::smf_server::model::ProblemDetails problem_details = { };
oai::smf_server::model::RefToBinaryData refToBinaryData = { };
std::string n1_sm_msg, n1_sm_msg_hex;
std::string n2_sm_info, n2_sm_info_hex;
bool update_upf = false;
......@@ -1561,13 +1544,10 @@ void smf_context::handle_pdu_session_update_sm_context_request(
if (!find_dnn or !find_pdu) {
//error, send reply to AMF with error code "Context Not Found"
Logger::smf_app().warn("DNN or PDU session context does not exist!");
problem_details.setCause(
pdu_session_application_error_e2str[PDU_SESSION_APPLICATION_ERROR_CONTEXT_NOT_FOUND]);
smContextUpdateError.setError(problem_details);
//trigger to send reply to AMF
smf_app_inst->trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_404_NOT_FOUND,
smContextUpdateError, smreq->pid);
smf_app_inst->trigger_update_context_error_response(
http_status_code_e::HTTP_STATUS_CODE_404_NOT_FOUND,
PDU_SESSION_APPLICATION_ERROR_CONTEXT_NOT_FOUND, smreq->pid);
return;
}
......@@ -1604,13 +1584,9 @@ void smf_context::handle_pdu_session_update_sm_context_request(
if (decoder_rc != RETURNok) {
//error, send reply to AMF with error code!!
Logger::smf_app().warn("N1 SM container cannot be decoded correctly!");
problem_details.setCause(
pdu_session_application_error_e2str[PDU_SESSION_APPLICATION_ERROR_N1_SM_ERROR]);
smContextUpdateError.setError(problem_details);
//trigger to send reply to AMF
smf_app_inst->trigger_http_response(
smf_app_inst->trigger_update_context_error_response(
http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
smContextUpdateError, smreq->pid);
PDU_SESSION_APPLICATION_ERROR_N1_SM_ERROR, smreq->pid);
return;
}
......@@ -1986,19 +1962,14 @@ void smf_context::handle_pdu_session_update_sm_context_request(
== pdu_session_status_e::PDU_SESSION_INACTIVE) {
Logger::smf_app().warn(
"PDU Session status: INACTIVE, send PDU Session Release Reject to UE!");
problem_details.setCause(
pdu_session_application_error_e2str[PDU_SESSION_APPLICATION_ERROR_NETWORK_FAILURE]); //TODO: which cause?
smContextUpdateError.setError(problem_details);
refToBinaryData.setContentId(N1_SM_CONTENT_ID);
smContextUpdateError.setN1SmMsg(refToBinaryData);
if (smf_n1::get_instance().create_n1_pdu_session_release_reject(
sm_context_req_msg, n1_sm_msg,
cause_value_5gsm_e::CAUSE_43_INVALID_PDU_SESSION_IDENTITY)) {
smf_app_inst->convert_string_2_hex(n1_sm_msg, n1_sm_msg_hex);
//trigger to send reply to AMF
smf_app_inst->trigger_http_response(
smf_app_inst->trigger_update_context_error_response(
http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
smContextUpdateError, n1_sm_msg_hex, smreq->pid);
PDU_SESSION_APPLICATION_ERROR_NETWORK_FAILURE, n1_sm_msg_hex, smreq->pid);
} else {
smf_app_inst->trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_500_INTERNAL_SERVER_ERROR,
......@@ -2165,11 +2136,6 @@ void smf_context::handle_pdu_session_update_sm_context_request(
//error, send error to AMF
Logger::smf_app().warn(
"Decode N2 SM (Ngap_PDUSessionResourceSetupResponseTransfer) failed!");
problem_details.setCause(
pdu_session_application_error_e2str[PDU_SESSION_APPLICATION_ERROR_N2_SM_ERROR]);
smContextUpdateError.setError(problem_details);
refToBinaryData.setContentId(N1_SM_CONTENT_ID);
smContextUpdateError.setN1SmMsg(refToBinaryData);
//PDU Session Establishment Reject
//24.501: response with a 5GSM STATUS message including cause "#95 Semantically incorrect message"
if (smf_n1::get_instance().create_n1_pdu_session_establishment_reject(
......@@ -2177,9 +2143,10 @@ void smf_context::handle_pdu_session_update_sm_context_request(
cause_value_5gsm_e::CAUSE_95_SEMANTICALLY_INCORRECT_MESSAGE)) {
smf_app_inst->convert_string_2_hex(n1_sm_msg, n1_sm_msg_hex); //TODO: need N1SM?
//trigger to send reply to AMF
smf_app_inst->trigger_http_response(
smf_app_inst->trigger_update_context_error_response(
http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
smContextUpdateError, smreq->pid);
PDU_SESSION_APPLICATION_ERROR_N2_SM_ERROR, smreq->pid);
} else {
smf_app_inst->trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_500_INTERNAL_SERVER_ERROR,
......@@ -2244,32 +2211,25 @@ void smf_context::handle_pdu_session_update_sm_context_request(
if (decode_status == RETURNerror) {
Logger::smf_app().warn(
"Decode N2 SM (Ngap_PDUSessionResourceSetupUnsuccessfulTransfer) failed!");
problem_details.setCause(
pdu_session_application_error_e2str[PDU_SESSION_APPLICATION_ERROR_N2_SM_ERROR]);
smContextUpdateError.setError(problem_details);
//trigger to send reply to AMF
smf_app_inst->trigger_http_response(
smf_app_inst->trigger_update_context_error_response(
http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
smContextUpdateError, smreq->pid);
PDU_SESSION_APPLICATION_ERROR_N2_SM_ERROR, smreq->pid);
return;
}
//Logger::smf_app().info("PDU Session Resource Setup Unsuccessful Transfer cause %d",decoded_msg->cause );
problem_details.setCause(
pdu_session_application_error_e2str[PDU_SESSION_APPLICATION_ERROR_UE_NOT_RESPONDING]);
smContextUpdateError.setError(problem_details);
refToBinaryData.setContentId(N1_SM_CONTENT_ID);
smContextUpdateError.setN1SmMsg(refToBinaryData);
//PDU Session Establishment Reject, 24.501 cause "#26 Insufficient resources"
if (smf_n1::get_instance().create_n1_pdu_session_establishment_reject(
smreq->req, n1_sm_msg,
cause_value_5gsm_e::CAUSE_26_INSUFFICIENT_RESOURCES)) {
smf_app_inst->convert_string_2_hex(n1_sm_msg, n1_sm_msg_hex);
//trigger to send reply to AMF
smf_app_inst->trigger_http_response(
smf_app_inst->trigger_update_context_error_response(
http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
smContextUpdateError, n1_sm_msg_hex, smreq->pid);
PDU_SESSION_APPLICATION_ERROR_UE_NOT_RESPONDING, n1_sm_msg_hex, smreq->pid);
//TODO: Need release established resources?
} else {
smf_app_inst->trigger_http_response(
......@@ -2296,13 +2256,10 @@ void smf_context::handle_pdu_session_update_sm_context_request(
if (decode_status == RETURNerror) {
Logger::smf_app().warn(
"Decode N2 SM (Ngap_PDUSessionResourceModifyResponseTransfer) failed!");
problem_details.setCause(
pdu_session_application_error_e2str[PDU_SESSION_APPLICATION_ERROR_N2_SM_ERROR]);
smContextUpdateError.setError(problem_details);
//trigger to send reply to AMF
smf_app_inst->trigger_http_response(
smf_app_inst->trigger_update_context_error_response(
http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
smContextUpdateError, smreq->pid);
PDU_SESSION_APPLICATION_ERROR_N2_SM_ERROR, smreq->pid);
return;
}
......@@ -2367,13 +2324,11 @@ void smf_context::handle_pdu_session_update_sm_context_request(
if (decode_status == RETURNerror) {
Logger::smf_app().warn(
"Decode N2 SM (Ngap_PDUSessionResourceReleaseResponseTransfer) failed!");
problem_details.setCause(
pdu_session_application_error_e2str[PDU_SESSION_APPLICATION_ERROR_N2_SM_ERROR]);
smContextUpdateError.setError(problem_details);
//trigger to send reply to AMF
smf_app_inst->trigger_http_response(
smf_app_inst->trigger_update_context_error_response(
http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
smContextUpdateError, smreq->pid);
PDU_SESSION_APPLICATION_ERROR_N2_SM_ERROR, smreq->pid);
return;
}
......@@ -2488,21 +2443,15 @@ void smf_context::handle_pdu_session_update_sm_context_request(
//send error to AMF according to the procedure
switch (procedure_type) {
case session_management_procedures_type_e::PDU_SESSION_ESTABLISHMENT_UE_REQUESTED: {
problem_details.setCause(
pdu_session_application_error_e2str[PDU_SESSION_APPLICATION_ERROR_PEER_NOT_RESPONDING]);
smContextUpdateError.setError(problem_details);
//TODO: need to verify with/without N1 SM
refToBinaryData.setContentId(N1_SM_CONTENT_ID);
smContextUpdateError.setN1SmMsg(refToBinaryData);
//PDU Session Establishment Reject
if (smf_n1::get_instance().create_n1_pdu_session_establishment_reject(
sm_context_req_msg, n1_sm_msg,
cause_value_5gsm_e::CAUSE_38_NETWORK_FAILURE)) {
smf_app_inst->convert_string_2_hex(n1_sm_msg, n1_sm_msg_hex);
//trigger to send reply to AMF
smf_app_inst->trigger_http_response(
smf_app_inst->trigger_update_context_error_response(
http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
smContextUpdateError, smreq->pid);
PDU_SESSION_APPLICATION_ERROR_PEER_NOT_RESPONDING, smreq->pid);
} else {
smf_app_inst->trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_500_INTERNAL_SERVER_ERROR,
......@@ -2517,25 +2466,19 @@ void smf_context::handle_pdu_session_update_sm_context_request(
case session_management_procedures_type_e::PDU_SESSION_MODIFICATION_UE_INITIATED_STEP2:
case session_management_procedures_type_e::PDU_SESSION_RELEASE_AMF_INITIATED:
case session_management_procedures_type_e::PDU_SESSION_RELEASE_UE_REQUESTED_STEP1: {
problem_details.setCause(
pdu_session_application_error_e2str[PDU_SESSION_APPLICATION_ERROR_PEER_NOT_RESPONDING]);
smContextUpdateError.setError(problem_details);
//trigger to send reply to AMF
smf_app_inst->trigger_http_response(
smf_app_inst->trigger_update_context_error_response(
http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
smContextUpdateError, smreq->pid);
PDU_SESSION_APPLICATION_ERROR_PEER_NOT_RESPONDING, smreq->pid);
}
break;
default: {
//TODO: to be updated
problem_details.setCause(
pdu_session_application_error_e2str[PDU_SESSION_APPLICATION_ERROR_PEER_NOT_RESPONDING]);
smContextUpdateError.setError(problem_details);
//trigger to send reply to AMF
smf_app_inst->trigger_http_response(
smf_app_inst->trigger_update_context_error_response(
http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
smContextUpdateError, smreq->pid);
PDU_SESSION_APPLICATION_ERROR_PEER_NOT_RESPONDING, smreq->pid);
}
}
return;
......@@ -2627,10 +2570,6 @@ void smf_context::handle_pdu_session_modification_network_requested(
Logger::smf_app().info(
"Handle a PDU Session Modification Request (SMF-Requested)");
oai::smf_server::model::SmContextUpdateError smContextUpdateError = { };
oai::smf_server::model::SmContextUpdatedData smContextUpdatedData = { };
oai::smf_server::model::ProblemDetails problem_details = { };
oai::smf_server::model::RefToBinaryData refToBinaryData = { };
std::string n1_sm_msg, n1_sm_msg_hex;
std::string n2_sm_info, n2_sm_info_hex;
......
......@@ -959,16 +959,10 @@ void session_update_sm_context_procedure::handle_itti_msg(
} else {
Logger::smf_app().info(
"PDU Session Update SM Context, rejected by UPF");
//send response to AMF
oai::smf_server::model::SmContextUpdateError smContextUpdateError = { };
oai::smf_server::model::ProblemDetails problem_details = { };
problem_details.setCause(
pdu_session_application_error_e2str[PDU_SESSION_APPLICATION_ERROR_NETWORK_FAILURE]);
smContextUpdateError.setError(problem_details);
//trigger to send reply to AMF
smf_app_inst->trigger_http_response(
smf_app_inst->trigger_update_context_error_response(
http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
smContextUpdateError, n11_triggered_pending->pid);
PDU_SESSION_APPLICATION_ERROR_NETWORK_FAILURE, n11_triggered_pending->pid);
return;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment