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

Update SMF_APP

parent a414fe4f
......@@ -35,6 +35,7 @@
#include "SmContextCreateData.h"
#include "SmContextUpdateData.h"
#include "SmContextReleaseData.h"
#include "3gpp_29.500.h"
//------------------------------------------------------------------------------
void xgpp_conv::paa_to_pfcp_ue_ip_address(
......@@ -60,6 +61,7 @@ void xgpp_conv::paa_to_pfcp_ue_ip_address(
default:;
}
}
//------------------------------------------------------------------------------
void xgpp_conv::pdn_ip_to_pfcp_ue_ip_address(
const pdu_session_type_t& pdu_session_type,
......@@ -87,6 +89,7 @@ void xgpp_conv::pdn_ip_to_pfcp_ue_ip_address(
}
}
//------------------------------------------------------------------------------
void xgpp_conv::pco_nas_to_core(
const protocol_configuration_options_nas_t& pco_nas,
protocol_configuration_options_t& pco) {
......@@ -122,6 +125,7 @@ void xgpp_conv::pco_nas_to_core(
}
}
//------------------------------------------------------------------------------
void xgpp_conv::pco_core_to_nas(
const protocol_configuration_options_t& pco,
protocol_configuration_options_nas_t& pco_nas) {
......@@ -147,6 +151,7 @@ void xgpp_conv::pco_core_to_nas(
}
}
//------------------------------------------------------------------------------
void xgpp_conv::sm_context_create_from_openapi(
const oai::smf_server::model::SmContextMessage& scd,
smf::pdu_session_create_sm_context_request& pcr) {
......@@ -231,6 +236,7 @@ void xgpp_conv::sm_context_create_from_openapi(
// Extended protocol configuration options (Optional) e.g, FOR DHCP
}
//------------------------------------------------------------------------------
void xgpp_conv::sm_context_update_from_openapi(
const oai::smf_server::model::SmContextUpdateMessage& scu,
smf::pdu_session_update_sm_context_request& pur) {
......@@ -302,6 +308,7 @@ void xgpp_conv::sm_context_update_from_openapi(
// ACK), User location
}
//------------------------------------------------------------------------------
void xgpp_conv::sm_context_release_from_openapi(
const oai::smf_server::model::SmContextReleaseMessage& srm,
smf::pdu_session_release_sm_context_request& prr) {
......@@ -332,6 +339,7 @@ void xgpp_conv::sm_context_release_from_openapi(
// ismfReleaseOnly:
}
//------------------------------------------------------------------------------
void xgpp_conv::data_notification_from_openapi(
const oai::smf_server::model::NotificationData& nd,
smf::data_notification_msg& dn_msg) {
......@@ -354,6 +362,7 @@ void xgpp_conv::data_notification_from_openapi(
dn_msg.set_profile(p);
}
//------------------------------------------------------------------------------
void xgpp_conv::smf_event_exposure_notification_from_openapi(
const oai::smf_server::model::NsmfEventExposure& nee,
smf::event_exposure_msg& eem) {
......@@ -399,3 +408,88 @@ void xgpp_conv::smf_event_exposure_notification_from_openapi(
// event_subscriptions.push_back(event_subscription);
//}
}
//------------------------------------------------------------------------------
void xgpp_conv::sm_context_request_from_nas(
const nas_message_t& nas_msg,
smf::pdu_session_create_sm_context_request& pcr) {
pdu_session_type_t pdu_session_type = {.pdu_session_type =
PDU_SESSION_TYPE_E_IPV4};
// Extended Protocol Discriminator
pcr.set_epd(nas_msg.header.extended_protocol_discriminator);
// Message Type
pcr.set_message_type(nas_msg.plain.sm.header.message_type);
// TODO: Integrity protection maximum data rate (Mandatory)
// PDU session type (Optional)
if (nas_msg.plain.sm.header.message_type ==
PDU_SESSION_ESTABLISHMENT_REQUEST) {
Logger::smf_app().debug(
"PDU Session Type %d",
nas_msg.plain.sm.pdu_session_establishment_request._pdusessiontype
.pdu_session_type_value);
pdu_session_type.pdu_session_type =
nas_msg.plain.sm.pdu_session_establishment_request._pdusessiontype
.pdu_session_type_value;
}
pcr.set_pdu_session_type(pdu_session_type.pdu_session_type);
// TODO: SSCMode
// TODO: store UE 5GSM Capability
// TODO: MaximumNumberOfSupportedPacketFilters
// TODO: AlwaysonPDUSessionRequested
// TODO: SMPDUDNRequestContainer
// ExtendedProtocolConfigurationOptions
protocol_configuration_options_t pco = {};
pco_nas_to_core(
nas_msg.plain.sm.pdu_session_establishment_request
.extendedprotocolconfigurationoptions,
pco);
pcr.set_epco(pco);
// PTI
procedure_transaction_id_t pti = {
.procedure_transaction_id =
nas_msg.plain.sm.header.procedure_transaction_identity};
pcr.set_pti(pti);
}
//------------------------------------------------------------------------------
void xgpp_conv::create_sm_context_response_from_ct_request(
const std::shared_ptr<itti_n11_create_sm_context_request>& ctx_request,
std::shared_ptr<itti_n11_create_sm_context_response>& ctx_response) {
ctx_response->http_version = ctx_request->http_version;
ctx_response->res.set_http_code(http_status_code_e::HTTP_STATUS_CODE_200_OK);
ctx_response->res.set_supi(ctx_request->req.get_supi());
ctx_response->res.set_supi_prefix(ctx_request->req.get_supi_prefix());
ctx_response->res.set_cause(REQUEST_ACCEPTED);
ctx_response->res.set_pdu_session_id(ctx_request->req.get_pdu_session_id());
ctx_response->res.set_snssai(ctx_request->req.get_snssai());
ctx_response->res.set_dnn(ctx_request->req.get_dnn());
ctx_response->res.set_pdu_session_type(
ctx_request->req.get_pdu_session_type());
ctx_response->res.set_pti(ctx_request->req.get_pti());
ctx_response->set_scid(ctx_request->scid);
}
//------------------------------------------------------------------------------
void xgpp_conv::update_sm_context_response_from_ct_request(
const std::shared_ptr<itti_n11_update_sm_context_request>& ct_request,
std::shared_ptr<itti_n11_update_sm_context_response>& ct_response) {
ct_response->res.set_http_code(
http_status_code_e::HTTP_STATUS_CODE_200_OK); // default status code
ct_response->res.set_supi(ct_request->req.get_supi());
ct_response->res.set_supi_prefix(
ct_request->req.get_supi_prefix());
ct_response->res.set_cause(REQUEST_ACCEPTED);
ct_response->res.set_pdu_session_id(
ct_request->req.get_pdu_session_id());
ct_response->res.set_snssai(ct_request->req.get_snssai());
ct_response->res.set_dnn(ct_request->req.get_dnn());
}
......@@ -40,6 +40,11 @@
#include "NotificationData.h"
#include "NsmfEventExposure.h"
#include "smf_msg.hpp"
#include "itti_msg_n11.hpp"
extern "C" {
#include "nas_message.h"
}
namespace xgpp_conv {
......@@ -146,6 +151,24 @@ void smf_event_exposure_notification_from_openapi(
const oai::smf_server::model::NsmfEventExposure& nee,
smf::event_exposure_msg& eem);
/*
* Convert NAS to SM Context Request msg
* @param [const nas_message_t&] nm: NAS msg
* @param [smf::pdu_session_create_sm_context_request&] pcr: PDU
* SessionCreateSMContextRequest msg
* @return void
*/
void sm_context_request_from_nas(
const nas_message_t& nm, smf::pdu_session_create_sm_context_request& pcr);
void create_sm_context_response_from_ct_request(
const std::shared_ptr<itti_n11_create_sm_context_request>& ct_request,
std::shared_ptr<itti_n11_create_sm_context_response>& ct_response);
void update_sm_context_response_from_ct_request(
const std::shared_ptr<itti_n11_update_sm_context_request>& ct_request,
std::shared_ptr<itti_n11_update_sm_context_response>& ct_response);
} // namespace xgpp_conv
#endif /* FILE_3GPP_CONVERSIONS_HPP_SEEN */
......@@ -27,7 +27,14 @@ 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)
include_directories(${SRC_TOP_DIR}/nas/ies)
include_directories(${SRC_TOP_DIR}/nas/sm/msg)
include_directories(${SRC_TOP_DIR}/nas/mm)
include_directories(${SRC_TOP_DIR}/nas/mm/msg)
include_directories(${SRC_TOP_DIR}/nas/sm)
include_directories(${SRC_TOP_DIR}/nas/sm/msg)
#include_directories(${SRC_TOP_DIR}/nas/security)
include_directories(${SRC_TOP_DIR}/ngap/asn1c)
include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include)
......
......@@ -354,7 +354,6 @@ smf_app::smf_app(const std::string& config_file)
}
//------------------------------------------------------------------------------
// From SPGWU
void smf_app::start_upf_association(const pfcp::node_id_t& node_id) {
std::time_t time_epoch = std::time(nullptr);
uint64_t tv_ntp = time_epoch + SECONDS_SINCE_FIRST_EPOCH;
......@@ -452,7 +451,6 @@ void smf_app::handle_itti_msg(
//------------------------------------------------------------------------------
void smf_app::handle_itti_msg(
itti_n11_n1n2_message_transfer_response_status& m) {
// see TS29518_Namf_Communication.yaml
Logger::smf_app().info("Process N1N2MessageTransfer Response");
switch (m.procedure_type) {
......@@ -487,6 +485,7 @@ void smf_app::handle_itti_msg(
"Got response from AMF (response code %d)", m.response_code);
}
} break;
case session_management_procedures_type_e::
SERVICE_REQUEST_NETWORK_TRIGGERED: {
Logger::smf_app().debug(
......@@ -527,6 +526,7 @@ void smf_app::handle_itti_msg(
}
}
} break;
default: {
Logger::smf_app().warn("Unknown procedure type %d", m.procedure_type);
}
......@@ -658,28 +658,8 @@ void smf_app::handle_pdu_session_create_sm_context_request(
return;
}
// Fill the mandatory IEs
smreq->req.set_epd(decoded_nas_msg.header.extended_protocol_discriminator);
pdu_session_id_t pdu_session_id =
decoded_nas_msg.plain.sm.header.pdu_session_identity;
procedure_transaction_id_t pti = {
.procedure_transaction_id =
decoded_nas_msg.plain.sm.header.procedure_transaction_identity};
smreq->req.set_message_type(decoded_nas_msg.plain.sm.header.message_type);
// TODO: Integrity protection maximum data rate (Mandatory)
// PDU session type (Optional)
if (decoded_nas_msg.plain.sm.header.message_type ==
PDU_SESSION_ESTABLISHMENT_REQUEST) {
Logger::smf_app().debug(
"PDU Session Type %d",
decoded_nas_msg.plain.sm.pdu_session_establishment_request
._pdusessiontype.pdu_session_type_value);
pdu_session_type.pdu_session_type =
decoded_nas_msg.plain.sm.pdu_session_establishment_request
._pdusessiontype.pdu_session_type_value;
}
smreq->req.set_pdu_session_type(pdu_session_type.pdu_session_type);
// Get necessary info from NAS
xgpp_conv::sm_context_request_from_nas(decoded_nas_msg, smreq->req);
// TODO: Support IPv4 only for now
if (pdu_session_type.pdu_session_type == PDU_SESSION_TYPE_E_IPV6) {
......@@ -707,55 +687,22 @@ void smf_app::handle_pdu_session_create_sm_context_request(
return;
}
// TODO: SSCMode
// TODO: store UE 5GSM Capability
// TODO: MaximumNumberOfSupportedPacketFilters
// TODO: AlwaysonPDUSessionRequested
// TODO: SMPDUDNRequestContainer
// TODO: ExtendedProtocolConfigurationOptions
Logger::smf_app().debug(
"pco ext %d, spare %d, configuration protocol %d,number_ids %d",
decoded_nas_msg.plain.sm.pdu_session_establishment_request
.extendedprotocolconfigurationoptions.ext,
decoded_nas_msg.plain.sm.pdu_session_establishment_request
.extendedprotocolconfigurationoptions.spare,
decoded_nas_msg.plain.sm.pdu_session_establishment_request
.extendedprotocolconfigurationoptions.configuration_protocol,
decoded_nas_msg.plain.sm.pdu_session_establishment_request
.extendedprotocolconfigurationoptions.num_protocol_or_container_id);
// if (decoded_nas_msg.plain.sm.pdu_session_establishment_request
// .extendedprotocolconfigurationoptions.num_protocol_or_container_id
// >
// 0) {
protocol_configuration_options_t pco = {};
xgpp_conv::pco_nas_to_core(
decoded_nas_msg.plain.sm.pdu_session_establishment_request
.extendedprotocolconfigurationoptions,
pco);
smreq->req.set_epco(pco);
// }
// Get necessary information
supi_t supi = smreq->req.get_supi();
std::string supi_prefix = smreq->req.get_supi_prefix();
supi64_t supi64 = smf_supi_to_u64(supi);
std::string dnn = smreq->req.get_dnn();
snssai_t snssai = smreq->req.get_snssai();
uint8_t message_type = decoded_nas_msg.plain.sm.header.message_type;
std::string request_type = smreq->req.get_request_type();
// Get SUPI, SNSSAI
supi_t supi = smreq->req.get_supi();
std::string supi_prefix = smreq->req.get_supi_prefix();
supi64_t supi64 = smf_supi_to_u64(supi);
snssai_t snssai = smreq->req.get_snssai();
Logger::smf_app().info(
"Handle a PDU Session Create SM Context Request message from AMF, "
"SUPI " SUPI_64_FMT ", DNN %s, SNSSAI SST %d, SD %s",
supi64, dnn.c_str(), snssai.sST, snssai.sD.c_str());
// If no DNN information from UE, set to default value
if (dnn.length() == 0) {
dnn == smf_cfg.get_default_dnn();
}
"SUPI " SUPI_64_FMT ", SNSSAI SST %d, SD %s",
supi64, snssai.sST, snssai.sD.c_str());
// Step 2. Verify Procedure transaction id, pdu session id, message type,
// request type, etc. check pti
// request type, etc.
// Check PTI
procedure_transaction_id_t pti = {
.procedure_transaction_id =
decoded_nas_msg.plain.sm.header.procedure_transaction_identity};
if ((pti.procedure_transaction_id ==
PROCEDURE_TRANSACTION_IDENTITY_UNASSIGNED) ||
(pti.procedure_transaction_id > PROCEDURE_TRANSACTION_IDENTITY_LAST)) {
......@@ -779,9 +726,10 @@ void smf_app::handle_pdu_session_create_sm_context_request(
}
return;
}
smreq->req.set_pti(pti);
// check pdu session id
// Check pdu session id
pdu_session_id_t pdu_session_id =
decoded_nas_msg.plain.sm.header.pdu_session_identity;
if ((pdu_session_id == PDU_SESSION_IDENTITY_UNASSIGNED) ||
(pdu_session_id > PDU_SESSION_IDENTITY_LAST)) {
Logger::smf_app().warn("Invalid PDU Session ID value (%d)", pdu_session_id);
......@@ -793,7 +741,8 @@ void smf_app::handle_pdu_session_create_sm_context_request(
return;
}
// check message type
// Check message type
uint8_t message_type = decoded_nas_msg.plain.sm.header.message_type;
if (message_type != PDU_SESSION_ESTABLISHMENT_REQUEST) {
Logger::smf_app().warn(
"Invalid message type (message type = %d)", message_type);
......@@ -819,7 +768,8 @@ void smf_app::handle_pdu_session_create_sm_context_request(
return;
}
// check request type
// Check request type
std::string request_type = smreq->req.get_request_type();
if (request_type.compare("INITIAL_REQUEST") != 0) {
Logger::smf_app().warn(
"Invalid request type (request type = %s)", request_type.c_str());
......@@ -829,6 +779,12 @@ void smf_app::handle_pdu_session_create_sm_context_request(
return;
}
// If no DNN information from UE, set to default value
std::string dnn = smreq->req.get_dnn();
if (dnn.length() == 0) {
dnn == smf_cfg.get_default_dnn();
}
// TODO: For the moment, not support PDU session authentication and
// authorization by the external DN
......@@ -1075,7 +1031,6 @@ void smf_app::handle_pdu_session_update_sm_context_request(
//------------------------------------------------------------------------------
void smf_app::handle_pdu_session_release_sm_context_request(
std::shared_ptr<itti_n11_release_sm_context_request> smreq) {
// handle PDU Session Release SM Context Request
Logger::smf_app().info(
"Handle a PDU Session Release SM Context Request from an AMF");
......
......@@ -46,6 +46,7 @@
#include "smf_paa_dynamic.hpp"
#include "smf_pfcp_association.hpp"
#include "smf_procedure.hpp"
#include "3gpp_conversions.hpp"
extern "C" {
#include "Ngap_AssociatedQosFlowItem.h"
......@@ -1197,12 +1198,12 @@ void smf_context::handle_pdu_session_create_sm_context_request(
bool request_accepted = true;
// Step 1. get necessary information
std::string dnn = smreq->req.get_dnn();
snssai_t snssai = smreq->req.get_snssai();
std::string request_type = smreq->req.get_request_type();
supi_t supi = smreq->req.get_supi();
supi64_t supi64 = smf_supi_to_u64(supi);
uint32_t pdu_session_id = smreq->req.get_pdu_session_id();
std::string dnn = smreq->req.get_dnn();
snssai_t snssai = smreq->req.get_snssai();
// std::string request_type = smreq->req.get_request_type();
// supi_t supi = smreq->req.get_supi();
supi64_t supi64 = smf_supi_to_u64(smreq->req.get_supi());
uint32_t pdu_session_id = smreq->req.get_pdu_session_id();
// Step 2. check the validity of the UE request, if valid send PDU Session
// Accept, otherwise send PDU Session Reject to AMF
......@@ -1220,7 +1221,6 @@ void smf_context::handle_pdu_session_create_sm_context_request(
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(
http_status_code_e::HTTP_STATUS_CODE_500_INTERNAL_SERVER_ERROR,
......@@ -1240,18 +1240,24 @@ void smf_context::handle_pdu_session_create_sm_context_request(
std::shared_ptr<itti_n11_create_sm_context_response> sm_context_resp_pending =
std::shared_ptr<itti_n11_create_sm_context_response>(sm_context_resp);
sm_context_resp->http_version = smreq->http_version;
sm_context_resp->res.set_http_code(
http_status_code_e::HTTP_STATUS_CODE_200_OK);
sm_context_resp->res.set_supi(supi);
sm_context_resp->res.set_supi_prefix(smreq->req.get_supi_prefix());
sm_context_resp->res.set_cause(REQUEST_ACCEPTED);
sm_context_resp->res.set_pdu_session_id(pdu_session_id);
sm_context_resp->res.set_snssai(snssai);
sm_context_resp->res.set_dnn(dnn);
sm_context_resp->res.set_pdu_session_type(smreq->req.get_pdu_session_type());
sm_context_resp->res.set_pti(smreq->req.get_pti());
sm_context_resp->set_scid(smreq->scid);
// Assign necessary information for the response
xgpp_conv::create_sm_context_response_from_ct_request(
smreq, sm_context_resp_pending);
/*
sm_context_resp->http_version = smreq->http_version;
sm_context_resp->res.set_http_code(
http_status_code_e::HTTP_STATUS_CODE_200_OK);
sm_context_resp->res.set_supi(supi);
sm_context_resp->res.set_supi_prefix(smreq->req.get_supi_prefix());
sm_context_resp->res.set_cause(REQUEST_ACCEPTED);
sm_context_resp->res.set_pdu_session_id(pdu_session_id);
sm_context_resp->res.set_snssai(snssai);
sm_context_resp->res.set_dnn(dnn);
sm_context_resp->res.set_pdu_session_type(smreq->req.get_pdu_session_type());
sm_context_resp->res.set_pti(smreq->req.get_pti());
sm_context_resp->set_scid(smreq->scid);
*/
// Step 3. find pdu_session
std::shared_ptr<dnn_context> sd = {};
......@@ -1298,12 +1304,6 @@ void smf_context::handle_pdu_session_create_sm_context_request(
// rules for this PDU session from PCF For the moment, SMF uses the local
// policy (e.g., default QoS rule)
// address allocation based on PDN type
// IP Address pool is controlled by SMF
// Step 6. paa
bool set_paa = false;
paa_t paa = {};
// Step 6. PCO
// section 6.2.4.2, TS 24.501
// If the UE wants to use DHCPv4 for IPv4 address assignment, it shall
......@@ -1324,7 +1324,10 @@ void smf_context::handle_pdu_session_create_sm_context_request(
smf_app_inst->process_pco_request(pco_req, pco_resp, pco_ids);
sm_context_resp_pending->res.set_epco(pco_resp);
// Step 7. Address allocation based on PDN type
// Step 7. Address allocation based on PDN type, IP Address pool is controlled
// by SMF
bool set_paa = false;
paa_t paa = {};
Logger::smf_app().debug("UE Address Allocation");
switch (sp->pdu_session_type.pdu_session_type) {
case PDU_SESSION_TYPE_E_IPV4: {
......@@ -1490,7 +1493,7 @@ void smf_context::handle_pdu_session_create_sm_context_request(
// for (SUPI, DNN, S-NSSAI)
}
// step 10. if error when establishing the pdu session,
// Step 10. if error when establishing the pdu session,
// send ITTI message to APP to trigger N1N2MessageTransfer towards AMFs (PDU
// Session Establishment Reject)
if (sm_context_resp->res.get_cause() != REQUEST_ACCEPTED) {
......@@ -1513,7 +1516,6 @@ void smf_context::handle_pdu_session_create_sm_context_request(
case PDU_SESSION_TYPE_E_RESERVED:
default:;
}
// sm_context_resp->res.clear_paa(); //TODO:
}
// clear the created context??
// TODO:
......@@ -1612,7 +1614,7 @@ void smf_context::handle_pdu_session_update_sm_context_request(
std::shared_ptr<itti_n11_update_sm_context_response> sm_context_resp_pending =
std::shared_ptr<itti_n11_update_sm_context_response>(n11_sm_context_resp);
sm_context_resp_pending->res.set_http_code(
/* sm_context_resp_pending->res.set_http_code(
http_status_code_e::HTTP_STATUS_CODE_200_OK); // default status code
n11_sm_context_resp->res.set_supi(sm_context_req_msg.get_supi());
n11_sm_context_resp->res.set_supi_prefix(
......@@ -1622,9 +1624,12 @@ void smf_context::handle_pdu_session_update_sm_context_request(
sm_context_req_msg.get_pdu_session_id());
n11_sm_context_resp->res.set_snssai(sm_context_req_msg.get_snssai());
n11_sm_context_resp->res.set_dnn(sm_context_req_msg.get_dnn());
*/
n11_sm_context_resp->res.set_pdu_session_type(
sp.get()->get_pdu_session_type().pdu_session_type);
xgpp_conv::update_sm_context_response_from_ct_request(smreq, sm_context_resp_pending);
// Step 2.1. Decode N1 (if content is available)
if (sm_context_req_msg.n1_sm_msg_is_set()) {
nas_message_t decoded_nas_msg = {};
......
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