Commit 3a113978 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

update process PDU session establishment msg

parent 24bb6b7b
......@@ -17,8 +17,8 @@
extern "C" {
#include "nas_message.h"
#include "mmData.h"
#include "common_types.h"
#include "common_defs.h"
//#include "common_types.h"
//#include "common_defs.h"
}
namespace oai {
......@@ -34,18 +34,19 @@ SMContextsCollectionApiImpl::SMContextsCollectionApiImpl(std::shared_ptr<Pistach
void SMContextsCollectionApiImpl::post_sm_contexts(const SmContextMessage &smContextMessage, Pistache::Http::ResponseWriter &response) {
Logger::smf_api_server().info("post_sm_contexts...");
//decode NAS message and assign the necessary informations to pgwc::pdu_session_create_sm_context_request and pass to SMF to handle this message
nas_message_decode_status_t decode_status = {0};
nas_message_t decoded_nas_msg;
memset (&decoded_nas_msg, 0, sizeof (nas_message_t));
int decoder_rc = RETURNok;
unsigned char data[100] = {'\0'}; //hardcoded for the moment
Logger::smf_api_server().info("post_sm_contexts...");
SmContextCreateData smContextCreateData = smContextMessage.getJsonData();
std::string n1SmMessage = smContextMessage.getBinaryDataN1SmMessage();
//Decode and process nas message
//Decode and process nas message
//bsafe (disable temporarily warning for strncpy)
//std::strncpy((char *)data, n1SmMessage.c_str(), sizeof(data));
......@@ -70,23 +71,51 @@ void SMContextsCollectionApiImpl::post_sm_contexts(const SmContextMessage &smCon
decoded_nas_msg.header.message_authentication_code);
//Get the value from AMF
//pgwc::pdu_session_create_sm_context_request create_sm_context_request_msg;
pgwc::pdu_session_create_sm_context_request *sm_context_req = new pgwc::pdu_session_create_sm_context_request();
std::shared_ptr<pgwc::pdu_session_create_sm_context_request> sm_context_req_msg = std::shared_ptr<pgwc::pdu_session_create_sm_context_request>(sm_context_req);
//supi
supi_t supi = {.length = 0};
smf_string_to_supi(&supi, smContextCreateData.getSupi().c_str());
sm_context_req_msg->set_supi(supi);
//dnn
sm_context_req_msg->set_dnn(smContextCreateData.getDnn());
//S-Nssai
snssai_t snssai(smContextCreateData.getSNssai().getSst(), smContextCreateData.getSNssai().getSd());
sm_context_req_msg->set_snssai(snssai);
//PDU session ID
sm_context_req_msg->set_pdu_session_id(smContextCreateData.getPduSessionId());
//AMF ID
sm_context_req_msg->set_serving_nf_id(smContextCreateData.getServingNfId()); //TODO: should be verified that AMF ID is stored in GUAMI or ServingNfId
//Request Type
sm_context_req_msg->set_request_type(smContextCreateData.getRequestType());
supi_t supi = {.length = 0};
smf_string_to_supi(&supi, smContextCreateData.getSupi().c_str());
//supi64_t supi64 = smf_supi_to_u64(supi);
sm_context_req_msg->set_supi(supi);
//PCF ID
// Priority Access
//User Location Information
//Access Type
// PEI
//GPSI
// UE presence in LADN service area
// DNN Selection Mode
sm_context_req_msg->set_dnn_selection_mode(smContextCreateData.getSelMode());
//Subscription for PDU Session Status Notification
// Trace requirement
//From N1 Container (NAS)
//Extended protocol discriminator (Mandatory)
//PDU session ID (Mandatory)
//PTI (Mandatory)
//Message type (Mandatory) (PDU SESSION ESTABLISHMENT REQUEST message identity)
//Integrity protection maximum data rate (Mandatory)
//PDU session type (Optional)
//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
sm_context_req_msg->set_dnn_selection_mode(smContextCreateData.getSelMode());
//handle the message from pwg_app
......
#ifndef FILE_3GPP_24_501_H_SEEN
#define FILE_3GPP_24_501_H_SEEN
#include <stdint.h>
#include <stdbool.h>
//#include <stdint.h>
//#include <stdbool.h>
// 9.3.1 Security header type
#define SECURITY_HEADER_TYPE_NOT_PROTECTED 0b0000
......
#include "bstrlib.h"
#ifndef FILE_MM_DATA_H_SEEN
#define FILE_MM_DATA_H_SEEN
//#include "bstrlib.h"
#include "common_types.h"
#include "securityDef.h"
......@@ -41,3 +44,4 @@ typedef struct fivegmm_security_context_s {
uint8_t activated;
} fivegmm_security_context_t;
#endif
#include "common_types.h"
#include "nas_message.h"
//#include "log.h"
#include "gcc_diag.h"
#include "TLVDecoder.h"
#include "TLVEncoder.h"
#include <stdlib.h>
#include <string.h>
//#include "nas_itti_messaging.h"
#include "secu_defs.h"
#include "mmData.h"
#include "dynamic_memory_check.h"
/****************************************************************************/
/******************* L O C A L D E F I N I T I O N S *******************/
......
......@@ -290,8 +290,7 @@ file(GLOB SMF_API_SERVER_src_files
${SMF_API_SERVER_DIR}/api/*.cpp
${SMF_API_SERVER_DIR}/impl/*.cpp
)
set(SMF_API_SERVER_include_files
${SMF_API_SERVER_DIR}/api
${SMF_API_SERVER_DIR}/impl
......@@ -317,10 +316,10 @@ file(GLOB NAS_src_files
${SRC_TOP_DIR}/utils/obj_hashtable.c
${SRC_TOP_DIR}/utils/TLVDecoder.c
${SRC_TOP_DIR}/utils/TLVEncoder.c
${SRC_TOP_DIR}/utils/dynamic_memory_check.c
${SRC_TOP_DIR}/utils/backtrace.c
${SRC_TOP_DIR}/utils/bstr/*.c
${SRC_TOP_DIR}/nas/security/*.c
${SRC_TOP_DIR}/common/nas/dynamic_memory_check.c
${SRC_TOP_DIR}/common/nas/backtrace.c
${SRC_TOP_DIR}/common/*.c
)
......@@ -359,17 +358,6 @@ include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include)
include_directories(${SMF_API_SERVER_include_files})
include_directories(${NAS_include_files})
#include_directories(${SRC_TOP_DIR}/nas)
#include_directories(${SRC_TOP_DIR}/nas/msg)
#include_directories(${SRC_TOP_DIR}/nas/ies)
#include_directories(${SRC_TOP_DIR}/nas/network)
#include_directories(${SRC_TOP_DIR}/nas/mm/msg)
#include_directories(${SRC_TOP_DIR}/nas/mm)
#include_directories(${SRC_TOP_DIR}/nas/sm)
#include_directories(${SRC_TOP_DIR}/nas/sm/msg)
#include_directories(${SMF_API_SERVER_include_files})
add_executable(spgwc
${SRC_TOP_DIR}/oai_spgwc/main.cpp
${SRC_TOP_DIR}/oai_spgwc/options.cpp
......
......@@ -135,9 +135,9 @@ int main(int argc, char **argv)
sgwc_app_inst = new sgwc_app(Options::getlibconfigConfig());
//SMF API server
Pistache::Address addr(Pistache::Ipv4::any(), Pistache::Port(8080));
SMFApiServer smfApiServer(addr, pgw_app_inst);
smfApiServer.init(2);
//Pistache::Address addr(Pistache::Ipv4::any(), Pistache::Port(8080));
//SMFApiServer smfApiServer(addr, pgw_app_inst);
//smfApiServer.init(2);
//smfApiServer.start();
//smfApiServer.shutdown();
// std::thread smf_api_manager(&SMFApiServer::start, smfApiServer);
......
......@@ -39,11 +39,6 @@
#include "SmContextCreateError.h"
#include "3gpp_29.502.h"
extern "C" {
#include "sm_msg.h"
#include "PDUSessionEstablishmentRequest.h"
}
#include <stdexcept>
#include <iostream>
#include <cstdlib>
......@@ -698,22 +693,23 @@ void pgw_app::send_create_session_response(Pistache::Http::ResponseWriter& httpR
void pgw_app::handle_amf_msg(std::shared_ptr<pdu_session_create_sm_context_request>& sm_context_req_msg, Pistache::Http::ResponseWriter &httpResponse){
//handle PDU Session Create SM Context Request as specified in section 4.3.2 3GPP TS 23.502
Logger::pgwc_app().info("Handle AMF message");
//Step 1. get necessary information
Logger::pgwc_app().debug("Handle AMF message, supi " SUPI_64_FMT " ", sm_context_req_msg->get_supi());
std::string dnn = sm_context_req_msg->get_dnn();
snssai_t snssai = sm_context_req_msg->get_snssai();
std::string requestType = sm_context_req_msg->get_request_type();
supi_t supi = sm_context_req_msg->get_supi();
supi64_t supi64 = smf_supi_to_u64(supi);
oai::smf::model::ProblemDetails problem_details;
pdu_session_establishment_request_msg pdu_session_establishment_request = sm_context_req_msg->get_nas_msg() ;
pdu_session_type_t pdu_session_type = {.pdu_session_type = (uint8_t)pdu_session_establishment_request._pdusessiontype};
Logger::pgwc_app().debug("Handle AMF message, supi " SUPI_64_FMT " ", supi64);
//pdu_session_establishment_request_msg pdu_session_establishment_request = sm_context_req_msg->get_nas_msg() ;
//pdu_session_type_t pdu_session_type = {.pdu_session_type = (uint8_t)pdu_session_establishment_request._pdusessiontype};
pdu_session_type_t pdu_session_type = {.pdu_session_type = 0}; //to be removed
Logger::pgwc_app().debug("Handle AMF message, _pdusessiontype: %d", pdu_session_type.pdu_session_type);
......
......@@ -41,10 +41,6 @@
#include "pistache/router.h"
#include "smf_msg.hpp"
extern "C" {
#include "sm_msg.h"
}
#include <map>
#include <set>
#include <shared_mutex>
......
......@@ -995,7 +995,7 @@ void pgw_context::handle_amf_msg (std::shared_ptr<pdu_session_create_sm_context_
std::string requestType = sm_context_req_msg->get_request_type();
supi_t supi = sm_context_req_msg->get_supi();
supi64_t supi64 = smf_supi_to_u64(supi);
uint32_t pdu_session_id = sm_context_req_msg->get_pdu_sessionId();
uint32_t pdu_session_id = sm_context_req_msg->get_pdu_session_id();
oai::smf::model::SmContextCreateError smContextCreateError;
oai::smf::model::ProblemDetails problem_details;
......@@ -1053,7 +1053,7 @@ void pgw_context::handle_amf_msg (std::shared_ptr<pdu_session_create_sm_context_
p->pdn_type.pdn_type = PDN_TYPE_E_IPV4; //TODO: should be removed after get the correct information from NAS_MSG
p->pdu_session_id = pdu_session_id; //should check also nas_msg.pdusessionidentity ??
//amf id
p->amf_id = sm_context_req_msg->get_serving_nfId();
p->amf_id = sm_context_req_msg->get_serving_nf_id();
sp = std::shared_ptr<pgw_pdn_connection>(p);
sd->insert_pdn_connection(sp);
} else{
......@@ -1076,7 +1076,7 @@ void pgw_context::handle_amf_msg (std::shared_ptr<pdu_session_create_sm_context_
//protocol configuration options IE in the PDU SESSION ESTABLISHMENT REQUEST
//Extended protocol configuration options: See subclause 10.5.6.3A in 3GPP TS 24.008.
ExtendedProtocolConfigurationOptions extended_protocol_options = (sm_context_req_msg->get_nas_msg()).extendedprotocolconfigurationoptions;
//ExtendedProtocolConfigurationOptions extended_protocol_options = (sm_context_req_msg->get_nas_msg()).extendedprotocolconfigurationoptions;
//TODO: PCO
protocol_configuration_options_t pco_resp = {};
protocol_configuration_options_ids_t pco_ids = {
......
......@@ -48,16 +48,9 @@
#include "SmContextCreateError.h"
#include "smf_msg.hpp"
extern "C" {
#include "sm_msg.h"
#include "PDUSessionEstablishmentRequest.h"
}
namespace pgwc {
class pgw_eps_bearer {
public:
pgw_eps_bearer() {
......
......@@ -349,7 +349,7 @@ int session_establishment_procedure::run(std::shared_ptr<pdu_session_create_sm_c
b.far_id_ul.second = far_id;
b.pdr_id_ul = pdr_id;
//b.ebi = it.eps_bearer_id;
b.ebi = sm_context_req->get_pdu_sessionId();
b.ebi = sm_context_req->get_pdu_session_id();
pgw_eps_bearer b2 = b;
ppc->add_eps_bearer(b2);
......
......@@ -32,58 +32,58 @@ using namespace pgwc;
supi_t pdu_session_create_sm_context_request::get_supi() const
{
return m_Supi;
return m_supi;
}
void pdu_session_create_sm_context_request::set_supi(supi_t const& value)
void pdu_session_create_sm_context_request::set_supi(supi_t const& supi)
{
m_Supi = value;
m_supi = supi;
}
int32_t pdu_session_create_sm_context_request::get_pdu_sessionId() const
int32_t pdu_session_create_sm_context_request::get_pdu_session_id() const
{
return m_pdu_session_id;
}
void pdu_session_create_sm_context_request::set_pdu_sessionId(int32_t const value)
void pdu_session_create_sm_context_request::set_pdu_session_id(int32_t const pdu_session_id)
{
m_pdu_session_id = pdu_session_id;
}
std::string pdu_session_create_sm_context_request::get_dnn() const
{
return m_Dnn;
return m_dnn;
}
void pdu_session_create_sm_context_request::set_dnn(std::string const& value)
void pdu_session_create_sm_context_request::set_dnn(std::string const& dnn)
{
m_Dnn = value;
m_dnn = dnn;
}
snssai_t pdu_session_create_sm_context_request::get_snssai() const
{
return m_SNssai;
return m_snssai;
}
void pdu_session_create_sm_context_request::set_snssai(snssai_t const& value)
void pdu_session_create_sm_context_request::set_snssai(snssai_t const& snssai)
{
m_SNssai = value;
m_snssai = snssai;
}
std::string pdu_session_create_sm_context_request::get_serving_nfId() const
std::string pdu_session_create_sm_context_request::get_serving_nf_id() const
{
return m_ServingNfId;
return m_serving_nf_id;
}
void pdu_session_create_sm_context_request::set_serving_nfId(std::string const& value)
void pdu_session_create_sm_context_request::set_serving_nf_id(std::string const& serving_nf_id)
{
m_serving_nf_id = serving_nf_id;
}
std::string pdu_session_create_sm_context_request::get_request_type() const
{
return m_request_type;
}
void pdu_session_create_sm_context_request::set_request_type(std::string const& value)
void pdu_session_create_sm_context_request::set_request_type(std::string const& request_type)
{
m_request_type = request_type;
}
/*
pdu_session_establishment_request_msg pdu_session_create_sm_context_request::get_nas_msg() const
{
return nas_msg;
......@@ -93,19 +93,20 @@ void pdu_session_create_sm_context_request::set_nas_msg(pdu_session_establishmen
{
nas_msg = value;
}
void pdu_session_create_sm_context_request::set_dnn_selection_mode (std::string const& value)
*/
void pdu_session_create_sm_context_request::set_dnn_selection_mode (std::string const& dnn_selection_mode)
{
m_SelMode = value;
m_dnn_selection_mode = dnn_selection_mode;
}
std::string pdu_session_create_sm_context_request::get_dnn_selection_mode () const
{
return m_SelMode;
return m_dnn_selection_mode;
}
uint8_t pdu_session_create_sm_context_request::get_pdu_session_type ()
{
return (uint8_t)nas_msg._pdusessiontype;
//return (uint8_t)nas_msg._pdusessiontype;
return m_pdu_session_type;
}
......
......@@ -29,26 +29,20 @@
#define FILE_SMF_MSG_HPP_SEEN
#include "smf.h"
//#include "pistache/endpoint.h"
#include "pistache/http.h"
//#include "pistache/router.h"
extern "C" {
#include "PDUSessionEstablishmentRequest.h"
}
namespace pgwc {
class pdu_session_create_sm_context_request {
public:
pdu_session_create_sm_context_request(): nas_msg(), m_Supi(), m_UnauthenticatedSupi(true), m_PduSessionId(), m_Dnn(), m_SNssai() {}
//pdu_session_create_sm_context_request(): nas_msg(), m_Supi(), m_UnauthenticatedSupi(true), m_PduSessionId(), m_Dnn(), m_SNssai() {}
pdu_session_create_sm_context_request(): m_supi(), m_unauthenticated_supi(true), m_pdu_session_id(), m_dnn(), m_snssai() {}
supi_t get_supi() const;
void set_supi(supi_t const& value);
int32_t get_pdu_sessionId() const;
void set_pdu_sessionId(int32_t const value);
int32_t get_pdu_session_id() const;
void set_pdu_session_id(int32_t const value);
std::string get_dnn() const;
void set_dnn(std::string const& value);
......@@ -56,14 +50,14 @@ public:
snssai_t get_snssai() const;
void set_snssai(snssai_t const& value);
std::string get_serving_nfId() const;
void set_serving_nfId(std::string const& value);
std::string get_serving_nf_id() const;
void set_serving_nf_id(std::string const& value);
std::string get_request_type() const;
void set_request_type(std::string const& value);
pdu_session_establishment_request_msg get_nas_msg() const;
void set_nas_msg(pdu_session_establishment_request_msg const& value);
// pdu_session_establishment_request_msg get_nas_msg() const;
// void set_nas_msg(pdu_session_establishment_request_msg const& value);
void set_dnn_selection_mode (std::string const& value);
std::string get_dnn_selection_mode () const;
......@@ -72,25 +66,25 @@ public:
private:
pdu_session_establishment_request_msg nas_msg;
supi_t m_Supi;
bool m_UnauthenticatedSupi;
//pdu_session_establishment_request_msg nas_msg;
supi_t m_supi;
bool m_unauthenticated_supi;
//std::string m_Pei;
//std::string m_Gpsi;
int32_t m_PduSessionId;
std::string m_Dnn;
snssai_t m_SNssai;
int32_t m_pdu_session_id;
std::string m_dnn;
snssai_t m_snssai;
//Snssai m_HplmnSnssai;
std::string m_ServingNfId; //AMF Id
std::string m_serving_nf_id; //AMF Id
//Guami m_Guami;
//std::string m_ServiceName;
//PlmnId m_ServingNetwork;
std::string m_RequestType;
std::string m_request_type;
//RefToBinaryData m_N1SmMsg;
std::string m_AnType;
std::string m_an_type;
//std::string m_SecondAnType;
std::string m_RatType;
std::string m_PresenceInLadn;
std::string m_rat_type;
std::string m_presence_in_ladn;
//UserLocation m_UeLocation;
//std::string m_UeTimeZone;
//UserLocation m_AddUeLocation;
......@@ -105,7 +99,7 @@ private:
//std::string m_PcfId;
//std::string m_NrfUri;
//std::string m_SupportedFeatures;
std::string m_SelMode;
std::string m_dnn_selection_mode;//SelMode
//std::vector<BackupAmfInfo> m_BackupAmfInfo;
//TraceData m_TraceData;
//std::string m_UdmGroupId;
......@@ -118,10 +112,11 @@ private:
//bool m_InvokeNef;
// bool m_MaPduIndication;
//RefToBinaryData m_N2SmInfo;
std::string m_SmContextRef;
};
//std::string m_SmContextRef;
//NAS
uint8_t m_pdu_session_type;
};
class pdu_session_create_sm_context_response {
......
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