Commit 0252ffd4 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Use different classes for N1 and N2 related functionalities

parent 4620a1e2
......@@ -49,7 +49,8 @@ add_library (SMF STATIC
smf_app.cpp
smf_config.cpp
smf_context.cpp
smf_n1_n2.cpp
smf_n1.cpp
smf_n2.cpp
smf_pfcp_association.cpp
smf_pco.cpp
smf_procedure.cpp
......
......@@ -44,7 +44,7 @@
#include "3gpp_24.007.h"
#include "smf.h"
#include "3gpp_24.501.h"
#include "smf_n1_n2.hpp"
#include "smf_n1.hpp"
#include "smf_paa_dynamic.hpp"
#include "smf_n4.hpp"
#include "smf_n10.hpp"
......@@ -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::RefToBinaryData refToBinaryData = { };
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 = { };
cause_value_5gsm_e cause_n1 = { cause_value_5gsm_e::CAUSE_0_UNKNOWN };
pdu_session_type_t pdu_session_type = { .pdu_session_type =
......@@ -557,7 +557,7 @@ void smf_app::handle_pdu_session_create_sm_context_request(
//Step 1. Decode NAS and get the necessary information
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);
if (decoder_rc != RETURNok) {
//error, send reply to AMF with PDU Session Establishment Reject
......@@ -567,7 +567,7 @@ void smf_app::handle_pdu_session_create_sm_context_request(
smContextCreateError.setError(problem_details);
refToBinaryData.setContentId(N1_SM_CONTENT_ID);
smContextCreateError.setN1SmMsg(refToBinaryData);
if (smf_n1_n2_inst.create_n1_sm_container(
if (smf_n1_inst.create_n1_sm_container(
smreq->req, PDU_SESSION_ESTABLISHMENT_REJECT, 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);
......@@ -625,7 +625,7 @@ void smf_app::handle_pdu_session_create_sm_context_request(
refToBinaryData.setContentId(N1_SM_CONTENT_ID);
smContextCreateError.setN1SmMsg(refToBinaryData);
//PDU Session Establishment Reject
if (smf_n1_n2_inst.create_n1_sm_container(smreq->req,
if (smf_n1_inst.create_n1_sm_container(smreq->req,
PDU_SESSION_ESTABLISHMENT_REJECT,
n1_sm_message, cause_n1)) {
smf_app_inst->convert_string_2_hex(n1_sm_message, n1_sm_message_hex);
......@@ -677,7 +677,7 @@ void smf_app::handle_pdu_session_create_sm_context_request(
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_n2_inst.create_n1_sm_container(
if (smf_n1_inst.create_n1_sm_container(
smreq->req, PDU_SESSION_ESTABLISHMENT_REJECT, 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);
......@@ -717,7 +717,7 @@ void smf_app::handle_pdu_session_create_sm_context_request(
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_n2_inst.create_n1_sm_container(
if (smf_n1_inst.create_n1_sm_container(
smreq->req,
PDU_SESSION_ESTABLISHMENT_REJECT,
n1_sm_message,
......@@ -759,7 +759,7 @@ void smf_app::handle_pdu_session_create_sm_context_request(
refToBinaryData.setContentId(N1_SM_CONTENT_ID);
smContextCreateError.setN1SmMsg(refToBinaryData);
//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_sm_container(
smreq->req, PDU_SESSION_ESTABLISHMENT_REJECT, 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);
......@@ -851,7 +851,7 @@ void smf_app::handle_pdu_session_create_sm_context_request(
refToBinaryData.setContentId(N1_SM_CONTENT_ID);
smContextCreateError.setN1SmMsg(refToBinaryData);
//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_sm_container(
smreq->req,
PDU_SESSION_ESTABLISHMENT_REJECT,
n1_sm_message,
......
This diff is collapsed.
......@@ -42,7 +42,6 @@
#include "logger.hpp"
#include "smf_app.hpp"
#include "smf_config.hpp"
#include "smf_n1_n2.hpp"
#include "mime_parser.hpp"
extern "C" {
......@@ -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);
mime_parser parser = {};
smf_n1_n2 smf_n1_n2_inst = { };
std::string n1_message = sm_context_res->res.get_n1_sm_message();
nlohmann::json json_data = {};
std::string body;
......@@ -248,7 +246,6 @@ void smf_n11::send_n1n2_message_transfer_request(
mime_parser parser = {};
std::string body;
smf_n1_n2 smf_n1_n2_inst = { };
nlohmann::json json_data = {};
std::string json_part;
std::string n1_message = sm_session_modification->msg.get_n1_sm_message();
......@@ -337,7 +334,6 @@ void smf_n11::send_n1n2_message_transfer_request(
"Send Communication_N1N2MessageTransfer to AMF (Network-initiated Service Request)");
mime_parser parser = {};
smf_n1_n2 smf_n1_n2_inst = { };
std::string n2_message = report_msg->res.get_n2_sm_information();
nlohmann::json json_data = {};
std::string body;
......
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_n2.hpp
* \brief
\author Tien-Thinh NGUYEN
\company Eurecom
\date 2019
\email: tien-thinh.nguyen@eurecom.fr
*/
#ifndef FILE_SMF_N1_N2_HPP_SEEN
#define FILE_SMF_N1_N2_HPP_SEEN
#include <map>
#include <set>
#include <shared_mutex>
#include <string>
#include <thread>
#include "pistache/endpoint.h"
#include "pistache/http.h"
#include "pistache/router.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_app.hpp"
#include "3gpp_29.502.h"
#include "SmContextCreateData.h"
#include "SmContextCreateError.h"
extern "C" {
#include "nas_message.h"
#include "Ngap_NGAP-PDU.h"
#include "Ngap_PDUSessionResourceSetupResponseTransfer.h"
#include "Ngap_PDUSessionResourceModifyResponseTransfer.h"
#include "Ngap_PDUSessionResourceReleaseResponseTransfer.h"
#include "Ngap_PDUSessionResourceSetupUnsuccessfulTransfer.h"
}
namespace smf {
class smf_n1_n2 {
private:
public:
smf_n1_n2() {
}
;
smf_n1_n2(smf_n1_n2 const&) = delete;
void operator=(smf_n1_n2 const&) = delete;
/*
* Create N1 SM Container to send to AMF (using NAS lib)
* @param [pdu_session_msg&] msg
* @param [uint8_t] msg_type Type of N1 message
* @param [std::string&] nas_msg_str store NAS message in form of string
* @param [uint8_t] sm_cause store NAS Cause
* @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,
std::string &nas_msg_str,
cause_value_5gsm_e sm_cause);
/*
* Create N2 SM Information to send to AMF (using NAS lib)
* @param [std::shared_ptr<itti_n11_create_sm_context_response>] sm_context_res
* @param [uint8_t] msg_type Type of N2 message
* @param [std::string&] ngap_msg_str store NGAP message in form of string
* @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,
n2_sm_info_type_e ngap_ie_type,
std::string &ngap_msg_str);
/*
* 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);
/*
* Decode N2 SM Information Ngap_PDUSessionResourceSetupResponseTransfer
* @param [std::shared_ptr<Ngap_PDUSessionResourceSetupResponseTransfer_t>&] ngap_IE Store decoded NGAP message
* @param [const std::string&] n2_sm_info N2 SM Information
* @return status of the decode process
*/
int decode_n2_sm_information(
std::shared_ptr<Ngap_PDUSessionResourceSetupResponseTransfer_t> &ngap_IE,
const std::string &n2_sm_info);
/*
* Decode N2 SM Information Ngap_PDUSessionResourceModifyResponseTransfer_t
* @param [std::shared_ptr<Ngap_PDUSessionResourceModifyResponseTransfer_t>&] ngap_IE Store decoded NGAP message
* @param [std::string&] n2_sm_info N2 SM Information
* @return status of the decode process
*/
int decode_n2_sm_information(
std::shared_ptr<Ngap_PDUSessionResourceModifyResponseTransfer_t> &ngap_IE,
const std::string &n2_sm_info);
/*
* Decode N2 SM Information Ngap_PDUSessionResourceReleaseResponseTransfer_t
* @param [std::shared_ptr<Ngap_PDUSessionResourceReleaseResponseTransfer_t>&] ngap_IE Store decoded NGAP message
* @param [std::string&] n2_sm_info N2 SM Information
* @return status of the decode process
*/
int decode_n2_sm_information(
std::shared_ptr<Ngap_PDUSessionResourceReleaseResponseTransfer_t> &ngap_IE,
const std::string &n2_sm_info);
/*
* Decode N2 SM Information Ngap_PDUSessionResourceSetupUnsuccessfulTransfer
* @param [std::shared_ptr<Ngap_PDUSessionResourceSetupUnsuccessfulTransfer_t>&] ngap_IE Store decoded NGAP message
* @param [std::string&] n2_sm_info N2 SM Information
* @return status of the decode process
*/
int decode_n2_sm_information(
std::shared_ptr<Ngap_PDUSessionResourceSetupUnsuccessfulTransfer_t> &ngap_IE,
const std::string &n2_sm_info);
};
} // namespace smf
#endif /* FILE_SMF_N1_N2_HPP_SEEN */
......@@ -43,7 +43,8 @@
#include "smf_config.hpp"
#include "smf_pfcp_association.hpp"
#include "smf_context.hpp"
#include "smf_n1_n2.hpp"
#include "smf_n1.hpp"
#include "smf_n2.hpp"
#include "smf_n11.hpp"
#include "SmContextCreatedData.h"
......@@ -370,7 +371,8 @@ void session_create_sm_context_procedure::handle_itti_msg(
//fill content for N1N2MessageTransfer (including N1, N2 SM)
// 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 n2_sm_info, n2_sm_info_hex;
......@@ -386,7 +388,7 @@ void session_create_sm_context_procedure::handle_itti_msg(
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_sm_container(n11_triggered_pending->res,
PDU_SESSION_ESTABLISHMENT_REJECT,
n1_sm_msg, cause_n1);
smf_app_inst->convert_string_2_hex(n1_sm_msg, n1_sm_msg_hex);
......@@ -404,13 +406,13 @@ void session_create_sm_context_procedure::handle_itti_msg(
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_sm_container(n11_triggered_pending->res,
PDU_SESSION_ESTABLISHMENT_ACCEPT,
n1_sm_msg, cause_n1);
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);
//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_sm_information(
n11_triggered_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);
......@@ -864,7 +866,8 @@ void session_update_sm_context_procedure::handle_itti_msg(
itti_n4_session_modification_response &resp,
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 n2_sm_info, n2_sm_info_hex;
......@@ -1055,13 +1058,13 @@ void session_update_sm_context_procedure::handle_itti_msg(
//FOR TESTING PURPOSE
case session_management_procedures_type_e::PDU_SESSION_TEST: {
//N1 SM
smf_n1_n2_inst.create_n1_sm_container(
smf_n1_inst.create_n1_sm_container(
n11_triggered_pending->res, PDU_SESSION_MODIFICATION_REQUEST,
n1_sm_msg, cause_value_5gsm_e::CAUSE_0_UNKNOWN);
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);
//N2 SM Information
smf_n1_n2_inst.create_n2_sm_information(
smf_n2_inst.create_n2_sm_information(
n11_triggered_pending->res, 1, n2_sm_info_type_e::PDU_RES_MOD_RSP,
n2_sm_info);
smf_app_inst->convert_string_2_hex(n2_sm_info, n2_sm_info_hex);
......@@ -1096,7 +1099,7 @@ void session_update_sm_context_procedure::handle_itti_msg(
// Create N2 SM Information: PDU Session Resource Setup Request Transfer IE
//N2 SM Information
smf_n1_n2_inst.create_n2_sm_information(
smf_n2_inst.create_n2_sm_information(
n11_triggered_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);
......@@ -1156,7 +1159,7 @@ void session_update_sm_context_procedure::handle_itti_msg(
Logger::smf_app().info("PDU Session Release UE-initiated (Step 1))");
//N1 SM
smf_n1_n2_inst.create_n1_sm_container(
smf_n1_inst.create_n1_sm_container(
n11_triggered_pending->res, PDU_SESSION_RELEASE_COMMAND, n1_sm_msg,
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);
......@@ -1165,7 +1168,7 @@ void session_update_sm_context_procedure::handle_itti_msg(
//include N2 SM Resource Release Request only when User Plane connection is activated
if (sps->get_upCnx_state() == upCnx_state_e::UPCNX_STATE_ACTIVATED) {
//N2 SM Information
smf_n1_n2_inst.create_n2_sm_information(
smf_n2_inst.create_n2_sm_information(
n11_triggered_pending->res, 1, n2_sm_info_type_e::PDU_RES_REL_CMD,
n2_sm_info);
smf_app_inst->convert_string_2_hex(n2_sm_info, 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