Commit 2aec7a14 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Merge branch 'separate_n1_n2' into 'develop'

Separate n1 n2

See merge request oai/cn5g/oai-cn5g-smf!25
parents 4620a1e2 aff44ff8
...@@ -62,6 +62,8 @@ void Logger::_init(const char *app, const bool log_stdout, ...@@ -62,6 +62,8 @@ void Logger::_init(const char *app, const bool log_stdout,
m_udp = new _Logger("udp ", m_sinks, ss.str().c_str()); m_udp = new _Logger("udp ", m_sinks, ss.str().c_str());
m_pfcp = new _Logger("pfcp ", m_sinks, ss.str().c_str()); m_pfcp = new _Logger("pfcp ", m_sinks, ss.str().c_str());
m_pfcp_switch = new _Logger("pfcp_sw ", m_sinks, ss.str().c_str()); m_pfcp_switch = new _Logger("pfcp_sw ", m_sinks, ss.str().c_str());
m_smf_n1 = new _Logger("smf_n1 ", m_sinks, ss.str().c_str());
m_smf_n2 = new _Logger("smf_n2 ", m_sinks, ss.str().c_str());
m_smf_n4 = new _Logger("smf_n4 ", m_sinks, ss.str().c_str()); m_smf_n4 = new _Logger("smf_n4 ", m_sinks, ss.str().c_str());
m_smf_n10 = new _Logger("smf_n10 ", m_sinks, ss.str().c_str()); m_smf_n10 = new _Logger("smf_n10 ", m_sinks, ss.str().c_str());
m_smf_n11 = new _Logger("smf_n11 ", m_sinks, ss.str().c_str()); m_smf_n11 = new _Logger("smf_n11 ", m_sinks, ss.str().c_str());
......
...@@ -107,6 +107,13 @@ class Logger { ...@@ -107,6 +107,13 @@ class Logger {
static _Logger& pfcp_switch() { static _Logger& pfcp_switch() {
return *singleton().m_pfcp_switch; return *singleton().m_pfcp_switch;
} }
static _Logger& smf_n1() {
return *singleton().m_smf_n1;
}
static _Logger& smf_n2() {
return *singleton().m_smf_n2;
}
static _Logger& smf_n4() { static _Logger& smf_n4() {
return *singleton().m_smf_n4; return *singleton().m_smf_n4;
} }
...@@ -146,6 +153,8 @@ class Logger { ...@@ -146,6 +153,8 @@ class Logger {
_Logger *m_udp; _Logger *m_udp;
_Logger *m_pfcp; _Logger *m_pfcp;
_Logger *m_pfcp_switch; _Logger *m_pfcp_switch;
_Logger *m_smf_n1;
_Logger *m_smf_n2;
_Logger *m_smf_n4; _Logger *m_smf_n4;
_Logger *m_smf_n10; _Logger *m_smf_n10;
_Logger *m_smf_n11; _Logger *m_smf_n11;
......
...@@ -49,7 +49,8 @@ add_library (SMF STATIC ...@@ -49,7 +49,8 @@ add_library (SMF STATIC
smf_app.cpp smf_app.cpp
smf_config.cpp smf_config.cpp
smf_context.cpp smf_context.cpp
smf_n1_n2.cpp smf_n1.cpp
smf_n2.cpp
smf_pfcp_association.cpp smf_pfcp_association.cpp
smf_pco.cpp smf_pco.cpp
smf_procedure.cpp smf_procedure.cpp
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
#include "3gpp_24.007.h" #include "3gpp_24.007.h"
#include "smf.h" #include "smf.h"
#include "3gpp_24.501.h" #include "3gpp_24.501.h"
#include "smf_n1_n2.hpp" #include "smf_n1.hpp"
#include "smf_paa_dynamic.hpp" #include "smf_paa_dynamic.hpp"
#include "smf_n4.hpp" #include "smf_n4.hpp"
#include "smf_n10.hpp" #include "smf_n10.hpp"
...@@ -548,7 +548,7 @@ void smf_app::handle_pdu_session_create_sm_context_request( ...@@ -548,7 +548,7 @@ void smf_app::handle_pdu_session_create_sm_context_request(
oai::smf_server::model::ProblemDetails problem_details = { }; oai::smf_server::model::ProblemDetails problem_details = { };
oai::smf_server::model::RefToBinaryData refToBinaryData = { }; oai::smf_server::model::RefToBinaryData refToBinaryData = { };
std::string n1_sm_message, n1_sm_message_hex; std::string n1_sm_message, n1_sm_message_hex;
smf_n1_n2 smf_n1_n2_inst = { }; smf_n1 smf_n1_inst = { };
nas_message_t decoded_nas_msg = { }; nas_message_t decoded_nas_msg = { };
cause_value_5gsm_e cause_n1 = { cause_value_5gsm_e::CAUSE_0_UNKNOWN }; cause_value_5gsm_e cause_n1 = { cause_value_5gsm_e::CAUSE_0_UNKNOWN };
pdu_session_type_t pdu_session_type = { .pdu_session_type = pdu_session_type_t pdu_session_type = { .pdu_session_type =
...@@ -557,7 +557,7 @@ void smf_app::handle_pdu_session_create_sm_context_request( ...@@ -557,7 +557,7 @@ void smf_app::handle_pdu_session_create_sm_context_request(
//Step 1. Decode NAS and get the necessary information //Step 1. Decode NAS and get the necessary information
std::string n1_sm_msg = smreq->req.get_n1_sm_message(); std::string n1_sm_msg = smreq->req.get_n1_sm_message();
int decoder_rc = smf_n1_n2_inst.decode_n1_sm_container(decoded_nas_msg, int decoder_rc = smf_n1_inst.decode_n1_sm_container(decoded_nas_msg,
n1_sm_msg); n1_sm_msg);
if (decoder_rc != RETURNok) { if (decoder_rc != RETURNok) {
//error, send reply to AMF with PDU Session Establishment Reject //error, send reply to AMF with PDU Session Establishment Reject
...@@ -567,9 +567,9 @@ void smf_app::handle_pdu_session_create_sm_context_request( ...@@ -567,9 +567,9 @@ void smf_app::handle_pdu_session_create_sm_context_request(
smContextCreateError.setError(problem_details); smContextCreateError.setError(problem_details);
refToBinaryData.setContentId(N1_SM_CONTENT_ID); refToBinaryData.setContentId(N1_SM_CONTENT_ID);
smContextCreateError.setN1SmMsg(refToBinaryData); smContextCreateError.setN1SmMsg(refToBinaryData);
if (smf_n1_n2_inst.create_n1_sm_container( if (smf_n1_inst.create_n1_pdu_session_establishment_reject(
smreq->req, PDU_SESSION_ESTABLISHMENT_REJECT, n1_sm_message, smreq->req, n1_sm_message,
cause_value_5gsm_e::CAUSE_95_SEMANTICALLY_INCORRECT_MESSAGE)) { cause_value_5gsm_e::CAUSE_95_SEMANTICALLY_INCORRECT_MESSAGE)) {
smf_app_inst->convert_string_2_hex(n1_sm_message, n1_sm_message_hex); smf_app_inst->convert_string_2_hex(n1_sm_message, n1_sm_message_hex);
//trigger to send reply to AMF //trigger to send reply to AMF
trigger_http_response(http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN, trigger_http_response(http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
...@@ -625,9 +625,8 @@ void smf_app::handle_pdu_session_create_sm_context_request( ...@@ -625,9 +625,8 @@ void smf_app::handle_pdu_session_create_sm_context_request(
refToBinaryData.setContentId(N1_SM_CONTENT_ID); refToBinaryData.setContentId(N1_SM_CONTENT_ID);
smContextCreateError.setN1SmMsg(refToBinaryData); smContextCreateError.setN1SmMsg(refToBinaryData);
//PDU Session Establishment Reject //PDU Session Establishment Reject
if (smf_n1_n2_inst.create_n1_sm_container(smreq->req, if (smf_n1_inst.create_n1_pdu_session_establishment_reject(smreq->req,
PDU_SESSION_ESTABLISHMENT_REJECT, n1_sm_message, cause_n1)) {
n1_sm_message, cause_n1)) {
smf_app_inst->convert_string_2_hex(n1_sm_message, n1_sm_message_hex); smf_app_inst->convert_string_2_hex(n1_sm_message, n1_sm_message_hex);
//trigger to send reply to AMF //trigger to send reply to AMF
trigger_http_response(http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN, trigger_http_response(http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
...@@ -677,9 +676,9 @@ void smf_app::handle_pdu_session_create_sm_context_request( ...@@ -677,9 +676,9 @@ void smf_app::handle_pdu_session_create_sm_context_request(
refToBinaryData.setContentId(N1_SM_CONTENT_ID); refToBinaryData.setContentId(N1_SM_CONTENT_ID);
smContextCreateError.setN1SmMsg(refToBinaryData); smContextCreateError.setN1SmMsg(refToBinaryData);
//PDU Session Establishment Reject including cause "#81 Invalid PTI value" (section 7.3.1 @3GPP TS 24.501) //PDU Session Establishment Reject including cause "#81 Invalid PTI value" (section 7.3.1 @3GPP TS 24.501)
if (smf_n1_n2_inst.create_n1_sm_container( if (smf_n1_inst.create_n1_pdu_session_establishment_reject(
smreq->req, PDU_SESSION_ESTABLISHMENT_REJECT, n1_sm_message, smreq->req, n1_sm_message,
cause_value_5gsm_e::CAUSE_81_INVALID_PTI_VALUE)) { cause_value_5gsm_e::CAUSE_81_INVALID_PTI_VALUE)) {
smf_app_inst->convert_string_2_hex(n1_sm_message, n1_sm_message_hex); smf_app_inst->convert_string_2_hex(n1_sm_message, n1_sm_message_hex);
//trigger to send reply to AMF //trigger to send reply to AMF
trigger_http_response(http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN, trigger_http_response(http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
...@@ -717,12 +716,10 @@ void smf_app::handle_pdu_session_create_sm_context_request( ...@@ -717,12 +716,10 @@ void smf_app::handle_pdu_session_create_sm_context_request(
smContextCreateError.setN1SmMsg(refToBinaryData); smContextCreateError.setN1SmMsg(refToBinaryData);
//PDU Session Establishment Reject //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." //(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_n2_inst.create_n1_sm_container( if (smf_n1_inst.create_n1_pdu_session_establishment_reject(
smreq->req, smreq->req,
PDU_SESSION_ESTABLISHMENT_REJECT, n1_sm_message,
n1_sm_message, cause_value_5gsm_e::CAUSE_98_MESSAGE_TYPE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE)) {
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); smf_app_inst->convert_string_2_hex(n1_sm_message, n1_sm_message_hex);
//trigger to send reply to AMF //trigger to send reply to AMF
trigger_http_response(http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN, trigger_http_response(http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
...@@ -759,9 +756,9 @@ void smf_app::handle_pdu_session_create_sm_context_request( ...@@ -759,9 +756,9 @@ void smf_app::handle_pdu_session_create_sm_context_request(
refToBinaryData.setContentId(N1_SM_CONTENT_ID); refToBinaryData.setContentId(N1_SM_CONTENT_ID);
smContextCreateError.setN1SmMsg(refToBinaryData); smContextCreateError.setN1SmMsg(refToBinaryData);
//PDU Session Establishment Reject, 24.501 cause "#27 Missing or unknown DNN" //PDU Session Establishment Reject, 24.501 cause "#27 Missing or unknown DNN"
if (smf_n1_n2_inst.create_n1_sm_container( if (smf_n1_inst.create_n1_pdu_session_establishment_reject(
smreq->req, PDU_SESSION_ESTABLISHMENT_REJECT, n1_sm_message, smreq->req, n1_sm_message,
cause_value_5gsm_e::CAUSE_27_MISSING_OR_UNKNOWN_DNN)) { cause_value_5gsm_e::CAUSE_27_MISSING_OR_UNKNOWN_DNN)) {
smf_app_inst->convert_string_2_hex(n1_sm_message, n1_sm_message_hex); smf_app_inst->convert_string_2_hex(n1_sm_message, n1_sm_message_hex);
//trigger to send reply to AMF //trigger to send reply to AMF
trigger_http_response(http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN, trigger_http_response(http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
...@@ -851,12 +848,11 @@ void smf_app::handle_pdu_session_create_sm_context_request( ...@@ -851,12 +848,11 @@ void smf_app::handle_pdu_session_create_sm_context_request(
refToBinaryData.setContentId(N1_SM_CONTENT_ID); refToBinaryData.setContentId(N1_SM_CONTENT_ID);
smContextCreateError.setN1SmMsg(refToBinaryData); smContextCreateError.setN1SmMsg(refToBinaryData);
//PDU Session Establishment Reject, with cause "29 User authentication or authorization failed" //PDU Session Establishment Reject, with cause "29 User authentication or authorization failed"
if (smf_n1_n2_inst.create_n1_sm_container( if (smf_n1_inst.create_n1_pdu_session_establishment_reject(
smreq->req, smreq->req,
PDU_SESSION_ESTABLISHMENT_REJECT,
n1_sm_message, n1_sm_message,
cause_value_5gsm_e::CAUSE_29_USER_AUTHENTICATION_OR_AUTHORIZATION_FAILED)) { 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); smf_app_inst->convert_string_2_hex(n1_sm_message, n1_sm_message_hex);
//trigger to send reply to AMF //trigger to send reply to AMF
trigger_http_response( trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN, http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
......
This diff is collapsed.
This diff is collapsed.
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file smf_n1.hpp
* \brief
\author Tien-Thinh NGUYEN
\company Eurecom
\date 2019
\email: tien-thinh.nguyen@eurecom.fr
*/
#ifndef FILE_SMF_N1_HPP_SEEN
#define FILE_SMF_N1_HPP_SEEN
#include <string>
#include "smf.h"
#include "smf_context.hpp"
#include "smf_msg.hpp"
#include "3gpp_29.502.h"
extern "C" {
#include "nas_message.h"
}
namespace smf {
class smf_n1 {
private:
public:
smf_n1() {
}
;
smf_n1(smf_n1 const&) = delete;
void operator=(smf_n1 const&) = delete;
/*
* Create N1 SM Container: PDU Session Establishment Accept
* @param [pdu_session_create_sm_context_response] sm_context_res: include necessary information for encoding NGAP msg
* @param [std::string&] ngap_msg_str store the created NGAP message in form of string
* @param [uint8_t] sm_cause store NAS Cause
* @return boolean: True if the NGAP message has been created successfully, otherwise return false
*
*/
bool create_n1_pdu_session_establishment_accept(pdu_session_create_sm_context_response &sm_context_res,
std::string &nas_msg_str,
cause_value_5gsm_e sm_cause);
/*
* Create N1 SM Container: PDU Session Establishment Reject
* @param [pdu_session_msg] msg: include necessary information for encoding NGAP msg
* @param [std::string&] ngap_msg_str store the created NGAP message in form of string
* @param [uint8_t] sm_cause store NAS Cause
* @return boolean: True if the NGAP message has been created successfully, otherwise return false
*
*/
bool create_n1_pdu_session_establishment_reject(pdu_session_msg &msg,
std::string &nas_msg_str,
cause_value_5gsm_e sm_cause);
//TODO: separate into 4 functions (verify if necessary)
/*
bool create_n1_pdu_session_establishment_accept(pdu_session_create_sm_context_response &sm_context_res,
std::string &nas_msg_str,
cause_value_5gsm_e sm_cause);
bool create_n1_pdu_session_establishment_reject(pdu_session_create_sm_context_request &msg, uint8_t msg_type,
std::string &nas_msg_str,
cause_value_5gsm_e sm_cause);
bool create_n1_pdu_session_establishment_reject(pdu_session_update_sm_context_response &msg, uint8_t msg_type,
std::string &nas_msg_str,
cause_value_5gsm_e sm_cause);
bool create_n1_pdu_session_establishment_reject(pdu_session_update_sm_context_request &msg, uint8_t msg_type,
std::string &nas_msg_str,
cause_value_5gsm_e sm_cause);
*/
//For testing purpose
bool create_n1_pdu_session_modification_request(pdu_session_update_sm_context_response &msg,
std::string &nas_msg_str,
cause_value_5gsm_e sm_cause);
/*
* Create N1 SM Container: PDU Session Modification Command
* Included in PDU Session Update SM Context Response (PDU Session Modification UE-Initiated procedure - step 1)
* @param [pdu_session_msg] msg: include necessary information for encoding NGAP msg
* @param [std::string&] ngap_msg_str store the created NGAP message in form of string
* @param [uint8_t] sm_cause store NAS Cause
* @return boolean: True if the NGAP message has been created successfully, otherwise return false
*
*/
bool create_n1_pdu_session_modification_command(pdu_session_update_sm_context_response &msg,
std::string &nas_msg_str,
cause_value_5gsm_e sm_cause);
/*
* Create N1 SM Container: PDU Session Modification Command
* Included in N1N2MessageTransfer Request (PDU Session Modification SMF-Requested, step 1 (from SMF to AMF))
* @param [pdu_session_msg] msg: include necessary information for encoding NGAP msg
* @param [std::string&] ngap_msg_str store the created NGAP message in form of string
* @param [uint8_t] sm_cause store NAS Cause
* @return boolean: True if the NGAP message has been created successfully, otherwise return false
*
*/
bool create_n1_pdu_session_modification_command(pdu_session_modification_network_requested &msg,
std::string &nas_msg_str,
cause_value_5gsm_e sm_cause);
/*
* Create N1 SM Container: PDU Session Release Reject
* Included in PDU Session Update SM Context Response (PDU Session Release UE-Initiated, step 1)
* @param [pdu_session_msg] msg: include necessary information for encoding NGAP msg
* @param [std::string&] ngap_msg_str store the created NGAP message in form of string
* @param [uint8_t] sm_cause store NAS Cause
* @return boolean: True if the NGAP message has been created successfully, otherwise return false
*
*/
bool create_n1_pdu_session_release_reject(pdu_session_update_sm_context_request &sm_context_res,
std::string &nas_msg_str,
cause_value_5gsm_e sm_cause);
/*
* Create N1 SM Container: PDU Session Release Command
* Included in PDU Session Update SM Context Response (PDU Session Release UE-Initiated, step 1)
* @param [pdu_session_msg] msg: include necessary information for encoding NGAP msg
* @param [std::string&] ngap_msg_str store the created NGAP message in form of string
* @param [uint8_t] sm_cause store NAS Cause
* @return boolean: True if the NGAP message has been created successfully, otherwise return false
*
*/
bool create_n1_pdu_session_release_command(pdu_session_update_sm_context_response &msg,
std::string &nas_msg_str,
cause_value_5gsm_e sm_cause);
/*
* Create N1 SM Container: PDU Session Release Command
* Included in N1N2MessageTransfer Request (PDU Session Release SMF-Requested, step 1)
* @param [pdu_session_msg] msg: include necessary information for encoding NGAP msg
* @param [std::string&] ngap_msg_str store the created NGAP message in form of string
* @param [uint8_t] sm_cause store NAS Cause
* @return boolean: True if the NGAP message has been created successfully, otherwise return false
*
*/
bool create_n1_pdu_session_release_command(pdu_session_modification_network_requested &msg,
std::string &nas_msg_str,
cause_value_5gsm_e sm_cause);
/*
* Decode N1 SM Container into the NAS mesasge (using NAS lib)
* @param [nas_message_t&] nas_msg Store NAS message after decoded
* @param [const std::string&] n1_sm_msg N1 SM Container
* @return status of the decode process
*/
int decode_n1_sm_container(nas_message_t &nas_msg, const std::string &n1_sm_msg);
};
} // namespace smf
#endif /* FILE_SMF_N1_HPP_SEEN */
...@@ -42,7 +42,6 @@ ...@@ -42,7 +42,6 @@
#include "logger.hpp" #include "logger.hpp"
#include "smf_app.hpp" #include "smf_app.hpp"
#include "smf_config.hpp" #include "smf_config.hpp"
#include "smf_n1_n2.hpp"
#include "mime_parser.hpp" #include "mime_parser.hpp"
extern "C" { extern "C" {
...@@ -129,7 +128,6 @@ void smf_n11::send_n1n2_message_transfer_request( ...@@ -129,7 +128,6 @@ void smf_n11::send_n1n2_message_transfer_request(
Logger::smf_n11().debug("Send Communication_N1N2MessageTransfer to AMF (HTTP version %d)", sm_context_res->http_version); Logger::smf_n11().debug("Send Communication_N1N2MessageTransfer to AMF (HTTP version %d)", sm_context_res->http_version);
mime_parser parser = {}; mime_parser parser = {};
smf_n1_n2 smf_n1_n2_inst = { };
std::string n1_message = sm_context_res->res.get_n1_sm_message(); std::string n1_message = sm_context_res->res.get_n1_sm_message();
nlohmann::json json_data = {}; nlohmann::json json_data = {};
std::string body; std::string body;
...@@ -248,7 +246,6 @@ void smf_n11::send_n1n2_message_transfer_request( ...@@ -248,7 +246,6 @@ void smf_n11::send_n1n2_message_transfer_request(
mime_parser parser = {}; mime_parser parser = {};
std::string body; std::string body;
smf_n1_n2 smf_n1_n2_inst = { };
nlohmann::json json_data = {}; nlohmann::json json_data = {};
std::string json_part; std::string json_part;
std::string n1_message = sm_session_modification->msg.get_n1_sm_message(); std::string n1_message = sm_session_modification->msg.get_n1_sm_message();
...@@ -337,7 +334,6 @@ void smf_n11::send_n1n2_message_transfer_request( ...@@ -337,7 +334,6 @@ void smf_n11::send_n1n2_message_transfer_request(
"Send Communication_N1N2MessageTransfer to AMF (Network-initiated Service Request)"); "Send Communication_N1N2MessageTransfer to AMF (Network-initiated Service Request)");
mime_parser parser = {}; mime_parser parser = {};
smf_n1_n2 smf_n1_n2_inst = { };
std::string n2_message = report_msg->res.get_n2_sm_information(); std::string n2_message = report_msg->res.get_n2_sm_information();
nlohmann::json json_data = {}; nlohmann::json json_data = {};
std::string body; std::string body;
......
This diff is collapsed.
This diff is collapsed.
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
* contact@openairinterface.org * contact@openairinterface.org
*/ */
/*! \file smf_n1_n2.hpp /*! \file smf_n2.hpp
* \brief * \brief
\author Tien-Thinh NGUYEN \author Tien-Thinh NGUYEN
\company Eurecom \company Eurecom
...@@ -27,24 +27,12 @@ ...@@ -27,24 +27,12 @@
\email: tien-thinh.nguyen@eurecom.fr \email: tien-thinh.nguyen@eurecom.fr
*/ */
#ifndef FILE_SMF_N1_N2_HPP_SEEN #ifndef FILE_SMF_N2_HPP_SEEN
#define FILE_SMF_N1_N2_HPP_SEEN #define FILE_SMF_N2_HPP_SEEN
#include <map>
#include <set>
#include <shared_mutex>
#include <string> #include <string>
#include <thread>
#include "pistache/endpoint.h"
#include "pistache/http.h"
#include "pistache/router.h"
#include "smf.h" #include "smf.h"
#include "3gpp_29.274.h"
#include "itti_msg_n4.hpp"
#include "itti_msg_n11.hpp"
#include "smf_context.hpp"
#include "smf_pco.hpp"
#include "smf_msg.hpp" #include "smf_msg.hpp"
#include "smf_app.hpp" #include "smf_app.hpp"
#include "3gpp_29.502.h" #include "3gpp_29.502.h"
...@@ -52,8 +40,6 @@ ...@@ -52,8 +40,6 @@
#include "SmContextCreateError.h" #include "SmContextCreateError.h"
extern "C" { extern "C" {
#include "nas_message.h"
#include "Ngap_NGAP-PDU.h"
#include "Ngap_PDUSessionResourceSetupResponseTransfer.h" #include "Ngap_PDUSessionResourceSetupResponseTransfer.h"
#include "Ngap_PDUSessionResourceModifyResponseTransfer.h" #include "Ngap_PDUSessionResourceModifyResponseTransfer.h"
#include "Ngap_PDUSessionResourceReleaseResponseTransfer.h" #include "Ngap_PDUSessionResourceReleaseResponseTransfer.h"
...@@ -62,47 +48,98 @@ extern "C" { ...@@ -62,47 +48,98 @@ extern "C" {
namespace smf { namespace smf {
class smf_n1_n2 { class smf_n2 {
private: private:
public: public:
smf_n1_n2() { smf_n2() {
} }
; ;
smf_n1_n2(smf_n1_n2 const&) = delete; smf_n2(smf_n2 const&) = delete;
void operator=(smf_n1_n2 const&) = delete; void operator=(smf_n2 const&) = delete;
/* /*
* Create N1 SM Container to send to AMF (using NAS lib) * Create N2 SM Information: PDU Session Resource Setup Request Transfer
* @param [pdu_session_msg&] msg * This IE is included in N1N2MessageTransfer Request (Accept, PDU Session Establishment procedure - UE initiated)
* @param [uint8_t] msg_type Type of N1 message * @param [pdu_session_create_sm_context_response] sm_context_res: include necessary information for encoding NGAP msg
* @param [std::string&] nas_msg_str store NAS message in form of string * @param [std::string&] ngap_msg_str store the created NGAP message in form of string
* @param [uint8_t] sm_cause store NAS Cause * @return boolean: True if the NGAP message has been created successfully, otherwise return false
* @return boolean: True if the NAS message has been created successfully, otherwise return false *
*/ */
bool create_n1_sm_container(pdu_session_msg &msg, uint8_t msg_type, bool create_n2_pdu_session_resource_setup_request_transfer(pdu_session_create_sm_context_response &sm_context_res, n2_sm_info_type_e ngap_info_type,
std::string &nas_msg_str, std::string &ngap_msg_str);
cause_value_5gsm_e sm_cause);
/* /*
* Create N2 SM Information to send to AMF (using NAS lib) * Create N2 SM Information: PDU Session Resource Setup Request Transfer
* @param [std::shared_ptr<itti_n11_create_sm_context_response>] sm_context_res * This IE is included in PDU Session Update SM Context Response​ (Service Request, step 2)
* @param [uint8_t] msg_type Type of N2 message * @param [pdu_session_update_sm_context_response] sm_context_res: include necessary information for encoding NGAP msg
* @param [std::string&] ngap_msg_str store NGAP message in form of string * @param [std::string&] ngap_msg_str store the created NGAP message in form of string
* @return boolean: True if the NGAP message has been created successfully, otherwise return false * @return boolean: True if the NGAP message has been created successfully, otherwise return false
* *
*/ */
bool create_n2_sm_information(pdu_session_msg &msg, uint8_t ngap_msg_type, bool create_n2_pdu_session_resource_setup_request_transfer(pdu_session_update_sm_context_response &sm_context_res, n2_sm_info_type_e ngap_info_type,
n2_sm_info_type_e ngap_ie_type, std::string &ngap_msg_str);
std::string &ngap_msg_str);
/*
* Create N2 SM Information: PDU Session Resource Setup Request Transfer
* This IE is included in N1N2MessageTranfer (N4 Data Report)
* @param [pdu_session_report_response] msg: include necessary information for encoding NGAP msg
* @param [std::string&] ngap_msg_str store the created NGAP message in form of string
* @return boolean: True if the NGAP message has been created successfully, otherwise return false
*
*/
bool create_n2_pdu_session_resource_setup_request_transfer(pdu_session_report_response &msg, n2_sm_info_type_e ngap_info_type,
std::string &ngap_msg_str);
/*
* Create N2 SM Information: PDU Session Resource Modify Request Transfer IE
* This IE is included in PDU Session Update SM Context Response (PDU Session Modification procedure, UE-initiated, step 1)
* @param [pdu_session_update_sm_context_response] sm_context_res: include necessary information for encoding NGAP msg
* @param [std::string&] ngap_msg_str store the created NGAP message in form of string
* @return boolean: True if the NGAP message has been created successfully, otherwise return false
*
*/
bool create_n2_pdu_session_resource_modify_request_transfer(pdu_session_update_sm_context_response &sm_context_res, n2_sm_info_type_e ngap_info_type,
std::string &ngap_msg_str);
/* /*
* Decode N1 SM Container into the NAS mesasge (using NAS lib) * Create N2 SM Information: PDU Session Resource Modify Request Transfer IE
* @param [nas_message_t&] nas_msg Store NAS message after decoded * This IE is included in N1N2MessageTransfer Request (PDU Session Modification procedure, SMF-requested, step 1)
* @param [const std::string&] n1_sm_msg N1 SM Container * @param [pdu_session_update_sm_context_response] sm_context_res: include necessary information for encoding NGAP msg
* @return status of the decode process * @param [std::string&] ngap_msg_str store the created NGAP message in form of string
* @return boolean: True if the NGAP message has been created successfully, otherwise return false
*
*/ */
int decode_n1_sm_container(nas_message_t &nas_msg, const std::string &n1_sm_msg); bool create_n2_pdu_session_resource_modify_request_transfer(pdu_session_modification_network_requested &msg, n2_sm_info_type_e ngap_info_type,
std::string &ngap_msg_str);
/*
* Create N2 SM Information: PDU Session Resource Modify Response Transfer IE
*
* @param [pdu_session_update_sm_context_response] sm_context_res: include necessary information for encoding NGAP msg
* @param [std::string&] ngap_msg_str store the created NGAP message in form of string
* @return boolean: True if the NGAP message has been created successfully, otherwise return false
*
*/
bool create_n2_pdu_session_resource_modify_response_transfer(pdu_session_update_sm_context_response &sm_context_res, n2_sm_info_type_e ngap_info_type,
std::string &ngap_msg_str);
// bool create_n2_pdu_session_resource_modify_response_transfer(pdu_session_modification_network_requested &msg, n2_sm_info_type_e ngap_info_type,
// std::string &ngap_msg_str);
/*
* Create N2 SM Information: PDU Session Resource Release Command Transfer IE
* This IE is included in the following messages:
* PDU Session Update SM Context Response (PDU Session Release UE-Initiated: section 4.3.4@3GPP TS 23.502, step 1)
* N1N2MessageTransfer Request​ (PDU Session Release SMF-Requested, step 1)
* @param [pdu_session_update_sm_context_response] sm_context_res: include necessary information for encoding NGAP msg
* @param [std::string&] ngap_msg_str store the created NGAP message in form of string
* @return boolean: True if the NGAP message has been created successfully, otherwise return false
*
*/
bool create_n2_pdu_session_resource_release_command_transfer(pdu_session_update_sm_context_response &sm_context_res, n2_sm_info_type_e ngap_info_type,
std::string &ngap_msg_str);
/* /*
* Decode N2 SM Information Ngap_PDUSessionResourceSetupResponseTransfer * Decode N2 SM Information Ngap_PDUSessionResourceSetupResponseTransfer
...@@ -144,9 +181,8 @@ class smf_n1_n2 { ...@@ -144,9 +181,8 @@ class smf_n1_n2 {
std::shared_ptr<Ngap_PDUSessionResourceSetupUnsuccessfulTransfer_t> &ngap_IE, std::shared_ptr<Ngap_PDUSessionResourceSetupUnsuccessfulTransfer_t> &ngap_IE,
const std::string &n2_sm_info); const std::string &n2_sm_info);
}; };
} // namespace smf } // namespace smf
#endif /* FILE_SMF_N1_N2_HPP_SEEN */ #endif /* FILE_SMF_N2_HPP_SEEN */
...@@ -43,7 +43,8 @@ ...@@ -43,7 +43,8 @@
#include "smf_config.hpp" #include "smf_config.hpp"
#include "smf_pfcp_association.hpp" #include "smf_pfcp_association.hpp"
#include "smf_context.hpp" #include "smf_context.hpp"
#include "smf_n1_n2.hpp" #include "smf_n1.hpp"
#include "smf_n2.hpp"
#include "smf_n11.hpp" #include "smf_n11.hpp"
#include "SmContextCreatedData.h" #include "SmContextCreatedData.h"
...@@ -370,7 +371,8 @@ void session_create_sm_context_procedure::handle_itti_msg( ...@@ -370,7 +371,8 @@ void session_create_sm_context_procedure::handle_itti_msg(
//fill content for N1N2MessageTransfer (including N1, N2 SM) //fill content for N1N2MessageTransfer (including N1, N2 SM)
// Create N1 SM container & N2 SM Information // Create N1 SM container & N2 SM Information
smf_n1_n2 smf_n1_n2_inst = { }; smf_n1 smf_n1_inst = { };
smf_n2 smf_n2_inst = { };
std::string n1_sm_msg, n1_sm_msg_hex; std::string n1_sm_msg, n1_sm_msg_hex;
std::string n2_sm_info, n2_sm_info_hex; std::string n2_sm_info, n2_sm_info_hex;
...@@ -386,9 +388,8 @@ void session_create_sm_context_procedure::handle_itti_msg( ...@@ -386,9 +388,8 @@ void session_create_sm_context_procedure::handle_itti_msg(
cause_value_5gsm_e::CAUSE_50_PDU_SESSION_TYPE_IPV4_ONLY_ALLOWED; cause_value_5gsm_e::CAUSE_50_PDU_SESSION_TYPE_IPV4_ONLY_ALLOWED;
} }
smf_n1_n2_inst.create_n1_sm_container(n11_triggered_pending->res, smf_n1_inst.create_n1_pdu_session_establishment_reject(n11_triggered_pending->res,
PDU_SESSION_ESTABLISHMENT_REJECT, n1_sm_msg, cause_n1);
n1_sm_msg, cause_n1);
smf_app_inst->convert_string_2_hex(n1_sm_msg, n1_sm_msg_hex); smf_app_inst->convert_string_2_hex(n1_sm_msg, n1_sm_msg_hex);
n11_triggered_pending->res.set_n1_sm_message(n1_sm_msg_hex); n11_triggered_pending->res.set_n1_sm_message(n1_sm_msg_hex);
...@@ -404,15 +405,15 @@ void session_create_sm_context_procedure::handle_itti_msg( ...@@ -404,15 +405,15 @@ void session_create_sm_context_procedure::handle_itti_msg(
cause_value_5gsm_e::CAUSE_50_PDU_SESSION_TYPE_IPV4_ONLY_ALLOWED; cause_value_5gsm_e::CAUSE_50_PDU_SESSION_TYPE_IPV4_ONLY_ALLOWED;
} }
smf_n1_n2_inst.create_n1_sm_container(n11_triggered_pending->res, smf_n1_inst.create_n1_pdu_session_establishment_accept(n11_triggered_pending->res,
PDU_SESSION_ESTABLISHMENT_ACCEPT, n1_sm_msg, cause_n1);
n1_sm_msg, cause_n1);
smf_app_inst->convert_string_2_hex(n1_sm_msg, n1_sm_msg_hex); smf_app_inst->convert_string_2_hex(n1_sm_msg, n1_sm_msg_hex);
n11_triggered_pending->res.set_n1_sm_message(n1_sm_msg_hex); n11_triggered_pending->res.set_n1_sm_message(n1_sm_msg_hex);
//N2 SM Information (Step 11, section 4.3.2.2.1 @ 3GPP TS 23.502): PDUSessionRessourceSetupRequestTransfer IE //N2 SM Information (Step 11, section 4.3.2.2.1 @ 3GPP TS 23.502): PDUSessionRessourceSetupRequestTransfer IE
smf_n1_n2_inst.create_n2_sm_information( smf_n2_inst.create_n2_pdu_session_resource_setup_request_transfer(
n11_triggered_pending->res, 1, n2_sm_info_type_e::PDU_RES_SETUP_REQ, n11_triggered_pending->res, n2_sm_info_type_e::PDU_RES_SETUP_REQ,
n2_sm_info); n2_sm_info);
smf_app_inst->convert_string_2_hex(n2_sm_info, n2_sm_info_hex); smf_app_inst->convert_string_2_hex(n2_sm_info, n2_sm_info_hex);
n11_triggered_pending->res.set_n2_sm_information(n2_sm_info_hex); n11_triggered_pending->res.set_n2_sm_information(n2_sm_info_hex);
} }
...@@ -864,7 +865,8 @@ void session_update_sm_context_procedure::handle_itti_msg( ...@@ -864,7 +865,8 @@ void session_update_sm_context_procedure::handle_itti_msg(
itti_n4_session_modification_response &resp, itti_n4_session_modification_response &resp,
std::shared_ptr<smf::smf_context> sc) { std::shared_ptr<smf::smf_context> sc) {
smf_n1_n2 smf_n1_n2_inst = { }; smf_n1 smf_n1_inst = { };
smf_n2 smf_n2_inst = { };
std::string n1_sm_msg, n1_sm_msg_hex; std::string n1_sm_msg, n1_sm_msg_hex;
std::string n2_sm_info, n2_sm_info_hex; std::string n2_sm_info, n2_sm_info_hex;
...@@ -1055,14 +1057,13 @@ void session_update_sm_context_procedure::handle_itti_msg( ...@@ -1055,14 +1057,13 @@ void session_update_sm_context_procedure::handle_itti_msg(
//FOR TESTING PURPOSE //FOR TESTING PURPOSE
case session_management_procedures_type_e::PDU_SESSION_TEST: { case session_management_procedures_type_e::PDU_SESSION_TEST: {
//N1 SM //N1 SM
smf_n1_n2_inst.create_n1_sm_container( smf_n1_inst.create_n1_pdu_session_modification_request(
n11_triggered_pending->res, PDU_SESSION_MODIFICATION_REQUEST, n11_triggered_pending->res, n1_sm_msg, cause_value_5gsm_e::CAUSE_0_UNKNOWN);
n1_sm_msg, cause_value_5gsm_e::CAUSE_0_UNKNOWN);
smf_app_inst->convert_string_2_hex(n1_sm_msg, n1_sm_msg_hex); smf_app_inst->convert_string_2_hex(n1_sm_msg, n1_sm_msg_hex);
n11_triggered_pending->res.set_n1_sm_message(n1_sm_msg_hex); n11_triggered_pending->res.set_n1_sm_message(n1_sm_msg_hex);
//N2 SM Information //N2 SM Information
smf_n1_n2_inst.create_n2_sm_information( smf_n2_inst.create_n2_pdu_session_resource_modify_response_transfer(
n11_triggered_pending->res, 1, n2_sm_info_type_e::PDU_RES_MOD_RSP, n11_triggered_pending->res, n2_sm_info_type_e::PDU_RES_MOD_RSP,
n2_sm_info); n2_sm_info);
smf_app_inst->convert_string_2_hex(n2_sm_info, n2_sm_info_hex); smf_app_inst->convert_string_2_hex(n2_sm_info, n2_sm_info_hex);
n11_triggered_pending->res.set_n2_sm_information(n2_sm_info_hex); n11_triggered_pending->res.set_n2_sm_information(n2_sm_info_hex);
...@@ -1096,9 +1097,10 @@ void session_update_sm_context_procedure::handle_itti_msg( ...@@ -1096,9 +1097,10 @@ void session_update_sm_context_procedure::handle_itti_msg(
// Create N2 SM Information: PDU Session Resource Setup Request Transfer IE // Create N2 SM Information: PDU Session Resource Setup Request Transfer IE
//N2 SM Information //N2 SM Information
smf_n1_n2_inst.create_n2_sm_information( smf_n2_inst.create_n2_pdu_session_resource_setup_request_transfer(
n11_triggered_pending->res, 1, n2_sm_info_type_e::PDU_RES_SETUP_REQ, n11_triggered_pending->res, n2_sm_info_type_e::PDU_RES_SETUP_REQ,
n2_sm_info); n2_sm_info);
smf_app_inst->convert_string_2_hex(n2_sm_info, n2_sm_info_hex); smf_app_inst->convert_string_2_hex(n2_sm_info, n2_sm_info_hex);
n11_triggered_pending->res.set_n2_sm_information(n2_sm_info_hex); n11_triggered_pending->res.set_n2_sm_information(n2_sm_info_hex);
...@@ -1156,8 +1158,8 @@ void session_update_sm_context_procedure::handle_itti_msg( ...@@ -1156,8 +1158,8 @@ void session_update_sm_context_procedure::handle_itti_msg(
Logger::smf_app().info("PDU Session Release UE-initiated (Step 1))"); Logger::smf_app().info("PDU Session Release UE-initiated (Step 1))");
//N1 SM //N1 SM
smf_n1_n2_inst.create_n1_sm_container( smf_n1_inst.create_n1_pdu_session_release_command(
n11_triggered_pending->res, PDU_SESSION_RELEASE_COMMAND, n1_sm_msg, n11_triggered_pending->res, n1_sm_msg,
cause_value_5gsm_e::CAUSE_26_INSUFFICIENT_RESOURCES); //TODO: check Cause cause_value_5gsm_e::CAUSE_26_INSUFFICIENT_RESOURCES); //TODO: check Cause
smf_app_inst->convert_string_2_hex(n1_sm_msg, n1_sm_msg_hex); smf_app_inst->convert_string_2_hex(n1_sm_msg, n1_sm_msg_hex);
n11_triggered_pending->res.set_n1_sm_message(n1_sm_msg_hex); n11_triggered_pending->res.set_n1_sm_message(n1_sm_msg_hex);
...@@ -1165,8 +1167,8 @@ void session_update_sm_context_procedure::handle_itti_msg( ...@@ -1165,8 +1167,8 @@ void session_update_sm_context_procedure::handle_itti_msg(
//include N2 SM Resource Release Request only when User Plane connection is activated //include N2 SM Resource Release Request only when User Plane connection is activated
if (sps->get_upCnx_state() == upCnx_state_e::UPCNX_STATE_ACTIVATED) { if (sps->get_upCnx_state() == upCnx_state_e::UPCNX_STATE_ACTIVATED) {
//N2 SM Information //N2 SM Information
smf_n1_n2_inst.create_n2_sm_information( smf_n2_inst.create_n2_pdu_session_resource_release_command_transfer(
n11_triggered_pending->res, 1, n2_sm_info_type_e::PDU_RES_REL_CMD, n11_triggered_pending->res, n2_sm_info_type_e::PDU_RES_REL_CMD,
n2_sm_info); n2_sm_info);
smf_app_inst->convert_string_2_hex(n2_sm_info, n2_sm_info_hex); smf_app_inst->convert_string_2_hex(n2_sm_info, n2_sm_info_hex);
n11_triggered_pending->res.set_n2_sm_information(n2_sm_info_hex); n11_triggered_pending->res.set_n2_sm_information(n2_sm_info_hex);
......
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