Commit c63a4711 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Add function to convert from OpenApi to smf internal structure (Pdu session...

Add function to convert from OpenApi to smf internal structure (Pdu session create sm context request)
parent 5d3c8624
......@@ -31,6 +31,7 @@
#include "HsmfUpdatedData.h"
#include "ProblemDetails.h"
#include "ReleaseData.h"
#include "smf.h"
namespace oai {
namespace smf_server {
......@@ -44,7 +45,7 @@ class IndividualPDUSessionHSMFApi {
virtual ~IndividualPDUSessionHSMFApi() {}
void init();
const std::string base = "/nsmf-pdusession/";
const std::string base = NSMF_PDU_SESSION_BASE;
private:
void setupRoutes();
......
......@@ -59,6 +59,7 @@
#include "SmContextMessage.h"
#include "SmContextCreateError.h"
#include "SmContextCreatedData.h"
#include "smf.h"
namespace oai {
namespace smf_server {
......@@ -72,7 +73,7 @@ class IndividualSMContextApi {
virtual ~IndividualSMContextApi() {}
void init();
const std::string base = "/nsmf-pdusession/";
const std::string base = NSMF_PDU_SESSION_BASE;
private:
void setupRoutes();
......
......@@ -29,6 +29,7 @@
#include "PduSessionCreateError.h"
#include "PduSessionCreatedData.h"
#include "ProblemDetails.h"
#include "smf.h"
namespace oai {
namespace smf_server {
......@@ -42,7 +43,7 @@ class PDUSessionsCollectionApi {
virtual ~PDUSessionsCollectionApi() {}
void init();
const std::string base = "/nsmf-pdusession/";
const std::string base = NSMF_PDU_SESSION_BASE;
private:
void setupRoutes();
......
......@@ -69,7 +69,7 @@ void SMContextsCollectionApi::setupRoutes() {
using namespace Pistache::Rest;
Routes::Post(
*router, base + smf_cfg.sbi_api_version + "/sm-contexts",
*router, base + smf_cfg.sbi_api_version + NSMF_PDU_SESSION_SM_CONTEXT_CREATE_URL,
Routes::bind(&SMContextsCollectionApi::post_sm_contexts_handler, this));
// Default handler, called when a route is not found
......
......@@ -50,6 +50,7 @@
#include "ProblemDetails.h"
#include "SmContextCreateError.h"
#include "SmContextCreatedData.h"
#include "smf.h"
namespace oai {
namespace smf_server {
......@@ -63,7 +64,7 @@ class SMContextsCollectionApi {
virtual ~SMContextsCollectionApi() {}
void init();
const std::string base = "/nsmf-pdusession/";
const std::string base = NSMF_PDU_SESSION_BASE;
private:
void setupRoutes();
......
......@@ -39,6 +39,7 @@
#include "3gpp_29.502.h"
#include <nghttp2/asio_http2_server.h>
#include "smf_config.hpp"
#include "3gpp_conversions.hpp"
extern smf::smf_config smf_cfg;
......@@ -60,102 +61,20 @@ void SMContextsCollectionApiImpl::post_sm_contexts(
Pistache::Http::ResponseWriter& response) {
Logger::smf_api_server().info("PDU Session Create SM Context Request.");
// Assign the necessary informations to
// smf::pdu_session_create_sm_context_request and pass this message to SMF to
// handle this message decode NAS should be done in SMF APP
SmContextCreateData smContextCreateData = smContextMessage.getJsonData();
std::string n1_sm_msg = smContextMessage.getBinaryDataN1SmMessage();
Logger::smf_api_server().debug("N1 SM message: %s", n1_sm_msg.c_str());
// Step 2. Create a pdu_session_create_sm_context_request message and store
// Create a pdu_session_create_sm_context_request message and store
// the necessary information
Logger::smf_api_server().debug(
"Create a pdu_session_create_sm_context_request message and store the "
"necessary information");
smf::pdu_session_create_sm_context_request sm_context_req_msg = {};
// set N1 SM Message
sm_context_req_msg.set_n1_sm_message(n1_sm_msg);
// set api root to be used as location header in HTTP response
sm_context_req_msg.set_api_root(
m_address + base + smf_cfg.sbi_api_version + "/sm-contexts");
// supi
supi_t supi = {.length = 0};
std::size_t pos = smContextCreateData.getSupi().find("-");
std::string supi_str = smContextCreateData.getSupi().substr(pos + 1);
std::string supi_prefix = smContextCreateData.getSupi().substr(0, pos);
smf_string_to_supi(&supi, supi_str.c_str());
sm_context_req_msg.set_supi(supi);
sm_context_req_msg.set_supi_prefix(supi_prefix);
Logger::smf_api_server().debug(
"SUPI %s, SUPI Prefix %s, IMSI %s", smContextCreateData.getSupi().c_str(),
supi_prefix.c_str(), supi_str.c_str());
// dnn
Logger::smf_api_server().debug(
"DNN %s", smContextCreateData.getDnn().c_str());
sm_context_req_msg.set_dnn(smContextCreateData.getDnn().c_str());
// S-Nssai
Logger::smf_api_server().debug(
"S-NSSAI SST %d, SD %s", smContextCreateData.getSNssai().getSst(),
smContextCreateData.getSNssai().getSd().c_str());
snssai_t snssai(
smContextCreateData.getSNssai().getSst(),
smContextCreateData.getSNssai().getSd());
sm_context_req_msg.set_snssai(snssai);
// PDU session ID
Logger::smf_api_server().debug(
"PDU Session ID %d", smContextCreateData.getPduSessionId());
sm_context_req_msg.set_pdu_session_id(smContextCreateData.getPduSessionId());
// AMF ID (ServingNFId)
Logger::smf_api_server().debug(
"ServingNfId %s", smContextCreateData.getServingNfId().c_str());
sm_context_req_msg.set_serving_nf_id(
smContextCreateData.getServingNfId()
.c_str()); // TODO: should be verified that AMF ID is stored in GUAMI
// or ServingNfId
// Request Type
Logger::smf_api_server().debug(
"RequestType %s", smContextCreateData.getRequestType().c_str());
sm_context_req_msg.set_request_type(smContextCreateData.getRequestType());
// PCF ID
// Priority Access
// User Location Information
// Access Type
// PEI
// GPSI
// UE presence in LADN service area
// Guami
// servingNetwork
// anType
// UETimeZone
// SMContextStatusUri
sm_context_req_msg.set_sm_context_status_uri(
smContextCreateData.getSmContextStatusUri());
// PCFId
// DNN Selection Mode
Logger::smf_api_server().debug(
"SelMode %s", smContextCreateData.getSelMode().c_str());
sm_context_req_msg.set_dnn_selection_mode(
smContextCreateData.getSelMode().c_str());
xgpp_conv::sm_context_create_data_from_openapi(
smContextMessage, sm_context_req_msg);
// Subscription for PDU Session Status Notification
// Trace requirement
// SSC mode (Optional)
// 5GSM capability (Optional)
// Maximum number of supported (Optional)
// Maximum number of supported packet filters (Optional)
// Always-on PDU session requested (Optional)
// SM PDU DN request container (Optional)
// Extended protocol configuration options (Optional) e.g, FOR DHCP
// Set api root to be used as location header in HTTP response
sm_context_req_msg.set_api_root(
m_address + base + smf_cfg.sbi_api_version +
NSMF_PDU_SESSION_SM_CONTEXT_CREATE_URL);
boost::shared_ptr<
boost::promise<smf::pdu_session_create_sm_context_response> >
......@@ -169,7 +88,7 @@ void SMContextsCollectionApiImpl::post_sm_contexts(
Logger::smf_api_server().debug("Promise ID generated %d", promise_id);
m_smf_app->add_promise(promise_id, p);
// Step 3. Handle the pdu_session_create_sm_context_request message in smf_app
// Handle the pdu_session_create_sm_context_request message in smf_app
std::shared_ptr<itti_n11_create_sm_context_request> itti_msg =
std::make_shared<itti_n11_create_sm_context_request>(
TASK_SMF_N11, TASK_SMF_APP, promise_id);
......@@ -177,7 +96,7 @@ void SMContextsCollectionApiImpl::post_sm_contexts(
itti_msg->http_version = 1;
m_smf_app->handle_pdu_session_create_sm_context_request(itti_msg);
// wait for the result from APP and send reply to AMF
// Wait for the result from APP and send reply to AMF
smf::pdu_session_create_sm_context_response sm_context_response = f.get();
Logger::smf_api_server().debug("Got result for promise ID %d", promise_id);
......
......@@ -41,6 +41,7 @@
#include "mime_parser.hpp"
#include "3gpp_29.500.h"
#include "smf_config.hpp"
#include "smf.h"
using namespace nghttp2::asio_http2;
using namespace nghttp2::asio_http2::server;
......@@ -292,7 +293,7 @@ void smf_http2_server::create_sm_contexts_handler(
// set api root to be used as location header in HTTP response
sm_context_req_msg.set_api_root(
// m_address + ":" + std::to_string(m_port) +
"/nsmf-pdusession/" + smf_cfg.sbi_api_version + "/sm-contexts");
NSMF_PDU_SESSION_BASE + smf_cfg.sbi_api_version + NSMF_PDU_SESSION_SM_CONTEXT_CREATE_URL);
// supi
supi_t supi = {.length = 0};
......
......@@ -32,6 +32,7 @@
#include <stdbool.h>
#include <ctype.h>
#include <inttypes.h>
#include "SmContextCreateData.h"
//------------------------------------------------------------------------------
void xgpp_conv::paa_to_pfcp_ue_ip_address(
......@@ -84,7 +85,7 @@ void xgpp_conv::pdn_ip_to_pfcp_ue_ip_address(
}
}
void xgpp_conv::protocol_configuration_options_nas_to_core(
void xgpp_conv::pco_nas_to_core(
const protocol_configuration_options_nas_t& pco_nas,
protocol_configuration_options_t& pco) {
pco.ext = pco_nas.ext;
......@@ -119,7 +120,7 @@ void xgpp_conv::protocol_configuration_options_nas_to_core(
}
}
void xgpp_conv::protocol_configuration_options_core_to_nas(
void xgpp_conv::pco_core_to_nas(
const protocol_configuration_options_t& pco,
protocol_configuration_options_nas_t& pco_nas) {
pco_nas.ext = pco.ext;
......@@ -143,3 +144,88 @@ void xgpp_conv::protocol_configuration_options_core_to_nas(
pco.protocol_or_container_ids[i].protocol_id_contents.length());
}
}
void xgpp_conv::sm_context_create_data_from_openapi(
const oai::smf_server::model::SmContextMessage& scd,
smf::pdu_session_create_sm_context_request& pcr) {
Logger::smf_app().debug(
"Convert SmContextMessage (OpenAPI) to "
"pdu_session_create_sm_context_request");
oai::smf_server::model::SmContextCreateData context_data = scd.getJsonData();
std::string n1_sm_msg = scd.getBinaryDataN1SmMessage();
//N1 SM Message
pcr.set_n1_sm_message(n1_sm_msg);
Logger::smf_app().debug("N1 SM message: %s", n1_sm_msg.c_str());
// supi
supi_t supi = {.length = 0};
std::size_t pos = context_data.getSupi().find("-");
std::string supi_str = context_data.getSupi().substr(pos + 1);
std::string supi_prefix = context_data.getSupi().substr(0, pos);
smf_string_to_supi(&supi, supi_str.c_str());
pcr.set_supi(supi);
pcr.set_supi_prefix(supi_prefix);
Logger::smf_app().debug(
"SUPI %s, SUPI Prefix %s, IMSI %s", context_data.getSupi().c_str(),
supi_prefix.c_str(), supi_str.c_str());
// dnn
Logger::smf_app().debug("DNN %s", context_data.getDnn().c_str());
pcr.set_dnn(context_data.getDnn().c_str());
// S-Nssai
Logger::smf_app().debug(
"S-NSSAI SST %d, SD %s", context_data.getSNssai().getSst(),
context_data.getSNssai().getSd().c_str());
snssai_t snssai(
context_data.getSNssai().getSst(), context_data.getSNssai().getSd());
pcr.set_snssai(snssai);
// PDU session ID
Logger::smf_app().debug("PDU Session ID %d", context_data.getPduSessionId());
pcr.set_pdu_session_id(context_data.getPduSessionId());
// AMF ID (ServingNFId)
Logger::smf_app().debug(
"ServingNfId %s", context_data.getServingNfId().c_str());
pcr.set_serving_nf_id(context_data.getServingNfId()
.c_str()); // TODO: should be verified that AMF ID
// is stored in GUAMI or ServingNfId
// Request Type
Logger::smf_app().debug(
"RequestType %s", context_data.getRequestType().c_str());
pcr.set_request_type(context_data.getRequestType());
// PCF ID
// Priority Access
// User Location Information
// Access Type
// PEI
// GPSI
// UE presence in LADN service area
// Guami
// servingNetwork
// anType
// UETimeZone
// SMContextStatusUri
pcr.set_sm_context_status_uri(context_data.getSmContextStatusUri());
// PCFId
// DNN Selection Mode
Logger::smf_app().debug("SelMode %s", context_data.getSelMode().c_str());
pcr.set_dnn_selection_mode(context_data.getSelMode().c_str());
// Subscription for PDU Session Status Notification
// Trace requirement
// SSC mode (Optional)
// 5GSM capability (Optional)
// Maximum number of supported (Optional)
// Maximum number of supported packet filters (Optional)
// Always-on PDU session requested (Optional)
// SM PDU DN request container (Optional)
// Extended protocol configuration options (Optional) e.g, FOR DHCP
}
......@@ -34,6 +34,8 @@
#include "endpoint.hpp"
#include "3gpp_24.008.h"
#include "nas_lib.h"
#include "SmContextMessage.h"
#include "smf_msg.hpp"
namespace xgpp_conv {
......@@ -44,13 +46,17 @@ void pdn_ip_to_pfcp_ue_ip_address(
const struct in_addr& ipv4_address, const struct in6_addr ipv6_address,
pfcp::ue_ip_address_t& ue_ip_address);
void protocol_configuration_options_nas_to_core(
void pco_nas_to_core(
const protocol_configuration_options_nas_t& pco_nas,
protocol_configuration_options_t& pco);
void protocol_configuration_options_core_to_nas(
void pco_core_to_nas(
const protocol_configuration_options_t& pco,
protocol_configuration_options_nas_t& pco_nas);
void sm_context_create_data_from_openapi(
const oai::smf_server::model::SmContextMessage& scd,
smf::pdu_session_create_sm_context_request& pcr);
} // namespace xgpp_conv
#endif /* FILE_3GPP_CONVERSIONS_HPP_SEEN */
......@@ -25,6 +25,10 @@ include_directories(${SRC_TOP_DIR}/common/utils)
include_directories(${SRC_TOP_DIR}/common/utils/bstr)
include_directories(${SRC_TOP_DIR}/itti)
include_directories(${SRC_TOP_DIR}/common/nas)
include_directories(${SRC_TOP_DIR}/api-server/model)
include_directories(${SRC_TOP_DIR}/smf_app)
include_directories(${SRC_TOP_DIR}/nas/ies)
include_directories(${SRC_TOP_DIR}/ngap/asn1c)
include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include)
set(CN_UTILS_SRC STATIC
......
......@@ -729,7 +729,7 @@ void smf_app::handle_pdu_session_create_sm_context_request(
// >
// 0) {
protocol_configuration_options_t pco = {};
xgpp_conv::protocol_configuration_options_nas_to_core(
xgpp_conv::pco_nas_to_core(
decoded_nas_msg.plain.sm.pdu_session_establishment_request
.extendedprotocolconfigurationoptions,
pco);
......
......@@ -221,7 +221,7 @@ bool smf_n1::create_n1_pdu_session_establishment_accept(
protocol_configuration_options_t pco_res = {};
sm_context_res.get_epco(pco_res);
// sm_msg->pdu_session_establishment_accept.
xgpp_conv::protocol_configuration_options_core_to_nas(
xgpp_conv::pco_core_to_nas(
pco_res, sm_msg->pdu_session_establishment_accept
.extendedprotocolconfigurationoptions);
......
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