Commit 803292a9 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Add network-initiated service request procedure/ code cleanup

parent e20bc2a9
......@@ -300,7 +300,8 @@ class itti_n11_n1n2_message_transfer_response_status : public itti_n11_msg {
dest),
scid(0),
response_code(0),
msg_type(0) {
msg_type(0),
procedure_type(session_management_procedures_type_e::PROCEDURE_TYPE_UNKNOWN) {
}
itti_n11_n1n2_message_transfer_response_status(
const itti_n11_n1n2_message_transfer_response_status &i)
......@@ -308,7 +309,8 @@ class itti_n11_n1n2_message_transfer_response_status : public itti_n11_msg {
itti_n11_msg(i),
scid(i.scid),
response_code(i.response_code),
msg_type(i.msg_type) {
msg_type(i.msg_type),
procedure_type(i.procedure_type) {
}
itti_n11_n1n2_message_transfer_response_status(
const itti_n11_n1n2_message_transfer_response_status &i,
......@@ -317,7 +319,8 @@ class itti_n11_n1n2_message_transfer_response_status : public itti_n11_msg {
itti_n11_msg(i, orig, dest),
scid(i.scid),
response_code(i.response_code),
msg_type(i.msg_type) {
msg_type(i.msg_type),
procedure_type(i.procedure_type) {
}
const char* get_msg_name() {
return "N11_SESSION_N1N2_MESSAGE_TRANSFER_RESPONSE_STATUS";
......@@ -339,10 +342,15 @@ class itti_n11_n1n2_message_transfer_response_status : public itti_n11_msg {
msg_type = type;
}
;
void set_procedure_type(session_management_procedures_type_e type) {
procedure_type = type;
}
;
scid_t scid; //SM Context ID
int16_t response_code;
std::string cause;
uint8_t msg_type;
session_management_procedures_type_e procedure_type;
};
......@@ -396,8 +404,8 @@ class itti_n11_release_sm_context_request : public itti_n11_msg {
class itti_n11_release_sm_context_response : public itti_n11_msg {
public:
itti_n11_release_sm_context_response(const task_id_t orig,
const task_id_t dest,
Pistache::Http::ResponseWriter &response)
const task_id_t dest,
Pistache::Http::ResponseWriter &response)
:
itti_n11_msg(N11_SESSION_RELEASE_SM_CONTEXT_RESPONSE, orig, dest),
http_response(response.clone()),
......@@ -427,5 +435,30 @@ class itti_n11_release_sm_context_response : public itti_n11_msg {
};
//-----------------------------------------------------------------------------
class itti_n11_session_report_request : public itti_n11_msg {
public:
itti_n11_session_report_request(const task_id_t orig, const task_id_t dest)
:
itti_n11_msg(N11_SESSION_REPORT_RESPONSE, orig, dest),
res() {
}
itti_n11_session_report_request(const itti_n11_session_report_request &i)
:
itti_n11_msg(i) {
}
itti_n11_session_report_request(const itti_n11_session_report_request &i,
const task_id_t orig, const task_id_t dest)
:
itti_n11_msg(i, orig, dest),
res(i.res) {
}
const char* get_msg_name() {
return "N11_SESSION_REPORT_RESPONSE";
}
;
smf::pdu_session_report_response res;
};
#endif /* ITTI_MSG_N11_HPP_INCLUDED_ */
......@@ -109,22 +109,23 @@ enum class http_response_codes_e {
//From 23.502
enum class session_management_procedures_type_e {
PDU_SESSION_ESTABLISHMENT_UE_REQUESTED = 0,
SERVICE_REQUEST_UE_TRIGGERED_STEP1 = 1,
SERVICE_REQUEST_UE_TRIGGERED_STEP2 = 2,
SERVICE_REQUEST_NETWORK_TRIGGERED = 3,
PDU_SESSION_MODIFICATION_UE_INITIATED_STEP1 = 4,
PDU_SESSION_MODIFICATION_UE_INITIATED_STEP2 = 5,
PDU_SESSION_MODIFICATION_UE_INITIATED_STEP3 = 6,
PDU_SESSION_MODIFICATION_SMF_REQUESTED = 7,
PDU_SESSION_MODIFICATION_AN_REQUESTED = 8,
PDU_SESSION_RELEASE_UE_REQUESTED_STEP1 = 9,
PDU_SESSION_RELEASE_UE_REQUESTED_STEP2 = 10,
PDU_SESSION_RELEASE_UE_REQUESTED_STEP3 = 11,
PDU_SESSION_RELEASE_SMF_INITIATED = 12,
PDU_SESSION_RELEASE_AMF_INITIATED = 13,
PDU_SESSION_RELEASE_AN_INITIATED = 14,
PDU_SESSION_TEST = 15
PROCEDURE_TYPE_UNKNOWN = 0,
PDU_SESSION_ESTABLISHMENT_UE_REQUESTED = 1,
SERVICE_REQUEST_UE_TRIGGERED_STEP1 = 2,
SERVICE_REQUEST_UE_TRIGGERED_STEP2 = 3,
SERVICE_REQUEST_NETWORK_TRIGGERED = 4,
PDU_SESSION_MODIFICATION_UE_INITIATED_STEP1 = 5,
PDU_SESSION_MODIFICATION_UE_INITIATED_STEP2 = 6,
PDU_SESSION_MODIFICATION_UE_INITIATED_STEP3 = 7,
PDU_SESSION_MODIFICATION_SMF_REQUESTED = 8,
PDU_SESSION_MODIFICATION_AN_REQUESTED = 9,
PDU_SESSION_RELEASE_UE_REQUESTED_STEP1 = 10,
PDU_SESSION_RELEASE_UE_REQUESTED_STEP2 = 11,
PDU_SESSION_RELEASE_UE_REQUESTED_STEP3 = 12,
PDU_SESSION_RELEASE_SMF_INITIATED = 13,
PDU_SESSION_RELEASE_AMF_INITIATED = 14,
PDU_SESSION_RELEASE_AN_INITIATED = 15,
PDU_SESSION_TEST = 16
};
static const std::vector<std::string> session_management_procedures_type_e2str =
......@@ -190,9 +191,12 @@ static const std::vector<std::string> multipart_related_content_part_e2str = {
#define AMF_NUMBER_RETRIES 3
#define UDM_CURL_TIMEOUT_MS 100L
#define UDM_NUMBER_RETRIES 3
constexpr auto CURL_MIME_BOUNDARY = "----Boundary";
//for N1N2
#define BUF_LEN 512
//for PFCP
constexpr uint64_t SECONDS_SINCE_FIRST_EPOCH = 2208988800;
#endif
......@@ -116,6 +116,7 @@ typedef enum {
N11_SESSION_N1N2_MESSAGE_TRANSFER_RESPONSE_STATUS,
N11_SESSION_RELEASE_SM_CONTEXT_REQUEST,
N11_SESSION_RELEASE_SM_CONTEXT_RESPONSE,
N11_SESSION_REPORT_RESPONSE,
NX_TRIGGER_SESSION_MODIFICATION,
UDP_INIT,
UDP_DATA_REQ,
......
......@@ -383,28 +383,57 @@ void smf_app::handle_itti_msg(
Logger::smf_app().info("Process N1N2MessageTransfer Response");
//Update PDU Session accordingly
//TODO: to be completed (process cause)
pdu_session_status_e status = { pdu_session_status_e::PDU_SESSION_INACTIVE };
upCnx_state_e state = { upCnx_state_e::UPCNX_STATE_DEACTIVATED };
if ((static_cast<http_response_codes_e>(m.response_code)
== http_response_codes_e::HTTP_RESPONSE_CODE_OK)
or (static_cast<http_response_codes_e>(m.response_code)
== http_response_codes_e::HTTP_RESPONSE_CODE_ACCEPTED)) {
if (m.msg_type == PDU_SESSION_ESTABLISHMENT_REJECT) {
status = pdu_session_status_e::PDU_SESSION_INACTIVE;
} else if (m.msg_type == PDU_SESSION_ESTABLISHMENT_ACCEPT) {
status = pdu_session_status_e::PDU_SESSION_ESTABLISHMENT_PENDING;
state = upCnx_state_e::UPCNX_STATE_ACTIVATING;
switch (m.procedure_type) {
case session_management_procedures_type_e::PDU_SESSION_ESTABLISHMENT_UE_REQUESTED: {
pdu_session_status_e status =
{ pdu_session_status_e::PDU_SESSION_INACTIVE };
upCnx_state_e state = { upCnx_state_e::UPCNX_STATE_DEACTIVATED };
if ((static_cast<http_response_codes_e>(m.response_code)
== http_response_codes_e::HTTP_RESPONSE_CODE_OK)
or (static_cast<http_response_codes_e>(m.response_code)
== http_response_codes_e::HTTP_RESPONSE_CODE_ACCEPTED)) {
if (m.msg_type == PDU_SESSION_ESTABLISHMENT_REJECT) {
status = pdu_session_status_e::PDU_SESSION_INACTIVE;
} else if (m.msg_type == PDU_SESSION_ESTABLISHMENT_ACCEPT) {
status = pdu_session_status_e::PDU_SESSION_ESTABLISHMENT_PENDING;
state = upCnx_state_e::UPCNX_STATE_ACTIVATING;
}
update_pdu_session_status(m.scid, status);
update_pdu_session_upCnx_state(m.scid, state);
Logger::smf_app().debug(
"Got successful response from AMF (Response code %d), set session status to %s",
m.response_code,
pdu_session_status_e2str[static_cast<int>(status)].c_str());
} else {
//TODO:
Logger::smf_app().debug("Got response from AMF (Response code %d)",
m.response_code);
}
}
break;
case session_management_procedures_type_e::SERVICE_REQUEST_NETWORK_TRIGGERED: {
if ((static_cast<http_response_codes_e>(m.response_code)
== http_response_codes_e::HTTP_RESPONSE_CODE_OK)
or (static_cast<http_response_codes_e>(m.response_code)
== http_response_codes_e::HTTP_RESPONSE_CODE_ACCEPTED)) {
//TODO:
Logger::smf_app().debug(
"Got successful response from AMF (Response code %d)",
m.response_code);
} else {
//TODO:
Logger::smf_app().debug("Got response from AMF (Response code %d)",
m.response_code);
//send failure indication to UPF
}
}
break;
default: {
}
update_pdu_session_status(m.scid, status);
update_pdu_session_upCnx_state(m.scid, state);
Logger::smf_app().debug(
"Got successful response from AMF (Response code %d), set session status to %s",
m.response_code,
pdu_session_status_e2str[static_cast<int>(status)].c_str());
} else {
//TODO:
Logger::smf_app().debug("Got response from AMF (Response code %d)",
m.response_code);
}
}
......@@ -516,6 +545,7 @@ void smf_app::handle_pdu_session_create_sm_context_request(
//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();
......@@ -628,6 +658,7 @@ void smf_app::handle_pdu_session_create_sm_context_request(
"Create a new SMF context with SUPI " SUPI_64_FMT "", supi64);
sc = std::shared_ptr<smf_context>(new smf_context());
sc.get()->set_supi(supi);
sc.get()->set_supi_prefix(supi_prefix);
set_supi_2_smf_context(supi64, sc);
}
......@@ -894,10 +925,10 @@ void smf_app::handle_pdu_session_release_sm_context_request(
}
//------------------------------------------------------------------------------
void smf_app::trigger_pdu_session_modification(supi_t &supi, std::string &dnn,
pdu_session_id_t pdu_session_id,
snssai_t &snssai,
pfcp::qfi_t &qfi) {
void smf_app::trigger_pdu_session_modification(const supi_t &supi, const std::string &dnn,
const pdu_session_id_t pdu_session_id,
const snssai_t &snssai,
const pfcp::qfi_t &qfi) {
//SMF-requested session modification, see section 4.3.3.2@3GPP TS 23.502
//The SMF may decide to modify PDU Session. This procedure also may be
//triggered based on locally configured policy or triggered from the (R)AN (see clause 4.2.6 and clause 4.9.1).
......@@ -1007,22 +1038,22 @@ bool smf_app::use_local_configuration_subscription_data(
}
//------------------------------------------------------------------------------
bool smf_app::is_supi_dnn_snssai_subscription_data(supi_t &supi,
std::string &dnn,
snssai_t &snssai) {
bool smf_app::is_supi_dnn_snssai_subscription_data(const supi_t &supi,
const std::string &dnn,
const snssai_t &snssai) const {
//TODO: should be implemented
return false; //Session Management Subscription from UDM isn't available
}
//------------------------------------------------------------------------------
bool smf_app::is_create_sm_context_request_valid() {
bool smf_app::is_create_sm_context_request_valid() const {
//TODO: should be implemented
return true;
}
//---------------------------------------------------------------------------------------------
void smf_app::convert_string_2_hex(std::string &input_str,
void smf_app::convert_string_2_hex(const std::string &input_str,
std::string &output_str) {
Logger::smf_app().debug("Convert string to Hex");
unsigned char *data = (unsigned char*) malloc(input_str.length() + 1);
......@@ -1052,7 +1083,7 @@ void smf_app::convert_string_2_hex(std::string &input_str,
}
//---------------------------------------------------------------------------------------------
unsigned char* smf_app::format_string_as_hex(std::string &str) {
unsigned char* smf_app::format_string_as_hex(const std::string &str) {
unsigned int str_len = str.length();
char *data = (char*) malloc(str_len + 1);
memset(data, 0, str_len + 1);
......@@ -1192,7 +1223,7 @@ void smf_app::timer_t3591_timeout(timer_id_t timer_id, uint64_t arg2_user) {
}
//---------------------------------------------------------------------------------------------
n2_sm_info_type_e smf_app::n2_sm_info_type_str2e(std::string &n2_info_type) {
n2_sm_info_type_e smf_app::n2_sm_info_type_str2e(const std::string &n2_info_type) const {
std::size_t number_of_types = n2_sm_info_type_e2str.size();
for (auto i = 0; i < number_of_types; ++i) {
if (n2_info_type.compare(n2_sm_info_type_e2str[i]) == 0) {
......@@ -1202,7 +1233,7 @@ n2_sm_info_type_e smf_app::n2_sm_info_type_str2e(std::string &n2_info_type) {
}
bool smf_app::get_session_management_subscription_data(
supi64_t &supi, std::string &dnn, snssai_t &snssai,
const supi64_t &supi, const std::string &dnn, const snssai_t &snssai,
std::shared_ptr<session_management_subscription> subscription) {
Logger::smf_app().debug(
......
......@@ -392,16 +392,16 @@ class smf_app {
/*
* Trigger pdu session modification
* @param [supi_t &] supi
* @param [std::string &] dnn
* @param [pdu_session_id_t] pdu_session_id
* @param [snssai_t &] snssai
* @param [pfcp::qfi_t &] qfi
* @param [const supi_t &] supi
* @param [const std::string &] dnn
* @param [const pdu_session_id_t] pdu_session_id
* @param [const snssai_t &] snssai
* @param [const pfcp::qfi_t &] qfi
* @return void
*/
void trigger_pdu_session_modification(supi_t &supi, std::string &dnn,
pdu_session_id_t pdu_session_id,
snssai_t &snssai, pfcp::qfi_t &qfi);
void trigger_pdu_session_modification(const supi_t &supi, const std::string &dnn,
const pdu_session_id_t pdu_session_id,
const snssai_t &snssai, const pfcp::qfi_t &qfi);
/*
* Verify if SM Context is existed for this Supi
......@@ -412,7 +412,7 @@ class smf_app {
/*
* Create/Update SMF context with the corresponding supi
* @param [supi_t] supi
* @param [const supi_t&] supi
* @param [std::shared_ptr<smf_context>] sc Shared_ptr Pointer to an SMF context
* @return True if existed, otherwise false
*/
......@@ -428,7 +428,7 @@ class smf_app {
/*
* Check whether SMF uses local configuration instead of retrieving Session Management Data from UDM
* @param [std::string] dnn_selection_mode
* @param [const std::string&] dnn_selection_mode
* @return True if SMF uses the local configuration to check the validity of the UE request, False otherwise
*/
bool use_local_configuration_subscription_data(
......@@ -436,24 +436,25 @@ class smf_app {
/*
* Verify whether the Session Management Data is existed
* @param [supi_t] SUPI
* @param [std::string] DNN
* @param [snssai_t] S-NSSAI
* @param [const supi_t&] SUPI
* @param [const std::string&] DNN
* @param [const snssai_t&] S-NSSAI
* @return True if SMF uses the local configuration to check the validity of the UE request, False otherwise
*/
bool is_supi_dnn_snssai_subscription_data(supi_t &supi, std::string &dnn,
snssai_t &snssai);
bool is_supi_dnn_snssai_subscription_data(const supi_t &supi,
const std::string &dnn,
const snssai_t &snssai) const;
/*
* Get the Session Management Subscription data from local configuration
* @param [supi_t &] SUPI
* @param [std::string &] DNN
* @param [snssai_t &] S-NSSAI
* @param [std::shared_ptr<session_management_subscription>] subscription: store subscription data if exist
* @return True if local configuration for this session management subscription exists, False otherwise
*/
* Get the Session Management Subscription data from local configuration
* @param [const supi_t &] SUPI
* @param [const std::string &] DNN
* @param [const snssai_t &] S-NSSAI
* @param [std::shared_ptr<session_management_subscription>] subscription: store subscription data if exist
* @return True if local configuration for this session management subscription exists, False otherwise
*/
bool get_session_management_subscription_data(
supi64_t &supi, std::string &dnn, snssai_t &snssai,
const supi64_t &supi, const std::string &dnn, const snssai_t &snssai,
std::shared_ptr<session_management_subscription> subscription);
/*
......@@ -461,23 +462,23 @@ class smf_app {
* @param [..]
* @return True if the request is valid, otherwise False
*/
bool is_create_sm_context_request_valid();
bool is_create_sm_context_request_valid() const;
/*
* Convert a string to hex representing this string
* @param [std::string&] input_str Input string
* @param [const std::string&] input_str Input string
* @param [std::string&] output_str String represents string in hex format
* @return void
*/
void convert_string_2_hex(std::string &input_str, std::string &output_str);
void convert_string_2_hex(const std::string &input_str,
std::string &output_str);
/*
* Represent a string as hex
* @param [std::string&] str: input string
* @param [std::string&] output_str String represents string in hex format
* @return void
* @param [const std::string&] str: input string
* @return String represents string in hex format
*/
unsigned char* format_string_as_hex(std::string &str);
unsigned char* format_string_as_hex(const std::string &str);
/*
* Update PDU session status
......@@ -490,10 +491,10 @@ class smf_app {
/*
* Convert N2 Info type representing by a string to n2_sm_info_type_e
* @param [std::string] n2_info_type
* @param [const std::string] n2_info_type
* @return representing of N2 info type in a form of emum
*/
n2_sm_info_type_e n2_sm_info_type_str2e(std::string &n2_info_type);
n2_sm_info_type_e n2_sm_info_type_str2e(const std::string &n2_info_type) const;
/*
* Update PDU session UpCnxState
......
......@@ -43,6 +43,7 @@
#include "3gpp_29.502.h"
#include "3gpp_24.501.h"
#include "SmContextCreatedData.h"
#include "smf_pfcp_association.hpp"
extern "C" {
#include "Ngap_PDUSessionResourceSetupResponseTransfer.h"
......@@ -433,7 +434,7 @@ bool smf_pdu_session::get_default_qos_rule(QOSRulesIE &qos_rule) const {
}
//------------------------------------------------------------------------------
bool smf_pdu_session::get_qos_rule(uint8_t rule_id,
bool smf_pdu_session::get_qos_rule(const uint8_t rule_id,
QOSRulesIE &qos_rule) const {
Logger::smf_app().info("Find QoS Rule with Rule Id %d", (uint8_t) rule_id);
if (qos_rules.count(rule_id) > 0) {
......@@ -468,7 +469,7 @@ void smf_pdu_session::update_qos_rule(const QOSRulesIE &qos_rule) {
}
//------------------------------------------------------------------------------
void smf_pdu_session::mark_qos_rule_to_be_synchronised(uint8_t rule_id) {
void smf_pdu_session::mark_qos_rule_to_be_synchronised(const uint8_t rule_id) {
if ((rule_id >= QOS_RULE_IDENTIFIER_FIRST )
and (rule_id <= QOS_RULE_IDENTIFIER_LAST )) {
......@@ -639,6 +640,153 @@ void smf_context::handle_itti_msg(itti_n4_session_deletion_response &sdresp) {
//------------------------------------------------------------------------------
void smf_context::handle_itti_msg(
std::shared_ptr<itti_n4_session_report_request> &req) {
pfcp::report_type_t report_type;
if (req->pfcp_ies.get(report_type)) {
pfcp::pdr_id_t pdr_id;
// Downlink Data Report
if (report_type.dldr) {
pfcp::downlink_data_report data_report;
if (req->pfcp_ies.get(data_report)) {
pfcp::pdr_id_t pdr_id;
if (data_report.get(pdr_id)) {
std::shared_ptr<dnn_context> sd = { };
std::shared_ptr<smf_pdu_session> sp = { };
pfcp::qfi_t qfi = { };
if (find_pdu_session(pdr_id, qfi, sd, sp)) {/*
downlink_data_report_procedure *proc =
new downlink_data_report_procedure(shared_from_this(), sp);
std::shared_ptr<smf_procedure> sproc =
std::shared_ptr<smf_procedure>(proc);
insert_procedure(sproc);
if (proc->run(pdr_id, qfi)) {
// error !
Logger::smf_app().info(
"Downlink Data Report Request procedure failed");
remove_procedure(proc);
}
*/
//Step 1. send N4 Data Report Ack to UPF
pfcp::node_id_t up_node_id = { };
if (not pfcp_associations::get_instance().select_up_node(
up_node_id, NODE_SELECTION_CRITERIA_MIN_PFCP_SESSIONS)) {
// TODO
Logger::smf_app().info("REMOTE_PEER_NOT_RESPONDING");
return;
}
itti_n4_session_report_response *n4_ser =
new itti_n4_session_report_response(TASK_SMF_APP, TASK_SMF_N4);
n4_ser->seid = req->seid;
n4_ser->trxn_id = req->trxn_id;
n4_ser->r_endpoint = endpoint(up_node_id.u1.ipv4_address,
pfcp::default_port);
std::shared_ptr<itti_n4_session_report_response> n4_report_ack =
std::shared_ptr<itti_n4_session_report_response>(n4_ser);
Logger::smf_app().info(
"Sending ITTI message %s to task TASK_SMF_N4",
n4_ser->get_msg_name());
int ret = itti_inst->send_msg(n4_report_ack);
if (RETURNok != ret) {
Logger::smf_app().error(
"Could not send ITTI message %s to task TASK_SMF_N4",
n4_ser->get_msg_name());
return;
}
//Step 2. Send N1N2MessageTranfer to AMF
pdu_session_report_response session_report_msg = { };
//set the required IEs
session_report_msg.set_supi(supi); //supi
session_report_msg.set_snssai(sd.get()->nssai); //s-nssai
session_report_msg.set_dnn(sd.get()->dnn_in_use); //dnn
session_report_msg.set_pdu_session_type(
sp.get()->get_pdn_type().pdn_type); //pdu session type
//get supi and put into URL
std::string supi_prefix = { };
get_supi_prefix(supi_prefix);
std::string supi_str = supi_prefix + "-" + smf_supi_to_string(supi);
std::string url = std::string(
inet_ntoa(*((struct in_addr*) &smf_cfg.amf_addr.ipv4_addr)))
+ ":" + std::to_string(smf_cfg.amf_addr.port)
+ fmt::format(NAMF_COMMUNICATION_N1N2_MESSAGE_TRANSFER_URL,
supi_str.c_str());
session_report_msg.set_amf_url(url);
//QFIs, QoS profiles, CN Tunnel
smf_qos_flow flow = { };
sp.get()->get_qos_flow(qfi, flow);
//ADD QoS Flow to be updated
qos_flow_context_updated qcu = { };
qcu.set_qfi(qfi);
qcu.set_ul_fteid(flow.ul_fteid);
qcu.set_qos_profile(flow.qos_profile);
session_report_msg.add_qos_flow_context_updated(qcu);
// Create N2 SM Information: PDU Session Resource Setup Request Transfer IE
//N2 SM Information
smf_n1_n2 smf_n1_n2_inst = { };
std::string n2_sm_info, n2_sm_info_hex;
smf_n1_n2_inst.create_n2_sm_information(
session_report_msg, 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);
session_report_msg.set_n2_sm_information(n2_sm_info_hex);
//Fill the json part
session_report_msg.n1n2_message_transfer_data["n2InfoContainer"]["n2InformationClass"] =
N1N2_MESSAGE_CLASS;
session_report_msg.n1n2_message_transfer_data["n2InfoContainer"]["smInfo"]["PduSessionId"] =
session_report_msg.get_pdu_session_id();
//N2InfoContent (section 6.1.6.2.27@3GPP TS 29.518)
session_report_msg.n1n2_message_transfer_data["n2InfoContainer"]["smInfo"]["n2InfoContent"]["ngapIeType"] =
"PDU_RES_SETUP_REQ"; //NGAP message type
session_report_msg.n1n2_message_transfer_data["n2InfoContainer"]["smInfo"]["n2InfoContent"]["ngapData"]["contentId"] =
N2_SM_CONTENT_ID; //NGAP part
session_report_msg.n1n2_message_transfer_data["n2InfoContainer"]["smInfo"]["sNssai"]["sst"] =
session_report_msg.get_snssai().sST;
session_report_msg.n1n2_message_transfer_data["n2InfoContainer"]["smInfo"]["sNssai"]["sd"] =
session_report_msg.get_snssai().sD;
itti_n11_session_report_request *itti_n11 =
new itti_n11_session_report_request(TASK_SMF_APP, TASK_SMF_N11);
std::shared_ptr<itti_n11_session_report_request> itti_n11_report =
std::shared_ptr<itti_n11_session_report_request>(itti_n11);
itti_n11_report->res = session_report_msg;
//send ITTI message to N11 interface to trigger N1N2MessageTransfer towards AMFs
Logger::smf_app().info(
"Sending ITTI message %s to task TASK_SMF_N11",
itti_n11_report->get_msg_name());
ret = itti_inst->send_msg(itti_n11_report);
if (RETURNok != ret) {
Logger::smf_app().error(
"Could not send ITTI message %s to task TASK_SMF_N11",
itti_n11_report->get_msg_name());
}
}
}
}
}
// Usage Report
if (report_type.usar) {
Logger::smf_app().debug("TODO PFCP_SESSION_REPORT_REQUEST/Usage Report");
}
// Error Indication Report
if (report_type.erir) {
Logger::smf_app().debug(
"TODO PFCP_SESSION_REPORT_REQUEST/Error Indication Report");
}
// User Plane Inactivity Report
if (report_type.upir) {
Logger::smf_app().debug(
"TODO PFCP_SESSION_REPORT_REQUEST/User Plane Inactivity Report");
}
}
}
//------------------------------------------------------------------------------
......@@ -1959,7 +2107,8 @@ void smf_context::handle_pdu_session_update_sm_context_request(
//PDU Session Establishment procedure
//PDU Session Resource Setup Unsuccessful Transfer
case n2_sm_info_type_e::PDU_RES_SETUP_FAIL: {
Logger::smf_app().info("PDU Session Resource Setup Unsuccessful Transfer");
Logger::smf_app().info(
"PDU Session Resource Setup Unsuccessful Transfer");
//Ngap_PDUSessionResourceSetupUnsuccessfulTransfer
std::shared_ptr<Ngap_PDUSessionResourceSetupUnsuccessfulTransfer_t> decoded_msg =
......@@ -1981,20 +2130,20 @@ void smf_context::handle_pdu_session_update_sm_context_request(
//Logger::smf_app().info("PDU Session Resource Setup Unsuccessful Transfer cause %d",decoded_msg->cause );
problem_details.setCause(
pdu_session_application_error_e2str[PDU_SESSION_APPLICATION_ERROR_UE_NOT_RESPONDING]);
pdu_session_application_error_e2str[PDU_SESSION_APPLICATION_ERROR_UE_NOT_RESPONDING]);
smContextUpdateError.setError(problem_details);
refToBinaryData.setContentId(N1_SM_CONTENT_ID);
smContextUpdateError.setN1SmMsg(refToBinaryData);
//PDU Session Establishment Reject, 24.501 cause "#26 Insufficient resources"
smf_n1_n2_inst.create_n1_sm_container(
smreq->req, PDU_SESSION_ESTABLISHMENT_REJECT, n1_sm_msg,
cause_value_5gsm_e::CAUSE_26_INSUFFICIENT_RESOURCES);
smf_app_inst->convert_string_2_hex(n1_sm_msg, n1_sm_msg_hex);
smf_n11_inst->send_pdu_session_update_sm_context_response(
smreq->http_response, smContextUpdateError,
Pistache::Http::Code::Forbidden, n1_sm_msg_hex);
//TODO: Need release established resources?
return;
refToBinaryData.setContentId(N1_SM_CONTENT_ID);
smContextUpdateError.setN1SmMsg(refToBinaryData);
//PDU Session Establishment Reject, 24.501 cause "#26 Insufficient resources"
smf_n1_n2_inst.create_n1_sm_container(
smreq->req, PDU_SESSION_ESTABLISHMENT_REJECT, n1_sm_msg,
cause_value_5gsm_e::CAUSE_26_INSUFFICIENT_RESOURCES);
smf_app_inst->convert_string_2_hex(n1_sm_msg, n1_sm_msg_hex);
smf_n11_inst->send_pdu_session_update_sm_context_response(
smreq->http_response, smContextUpdateError,
Pistache::Http::Code::Forbidden, n1_sm_msg_hex);
//TODO: Need release established resources?
return;
}
break;
......@@ -2463,8 +2612,8 @@ void smf_context::insert_dnn_subscription(
}
//------------------------------------------------------------------------------
bool smf_context::is_dnn_snssai_subscription_data(std::string &dnn,
snssai_t &snssai) {
bool smf_context::is_dnn_snssai_subscription_data(const std::string &dnn,
const snssai_t &snssai) {
if (dnn_subscriptions.count((uint8_t) snssai.sST) > 0) {
std::shared_ptr<session_management_subscription> ss = dnn_subscriptions.at(
(uint8_t) snssai.sST);
......@@ -2533,7 +2682,7 @@ void smf_context::set_supi(const supi_t &s) {
}
//-----------------------------------------------------------------------------
std::size_t smf_context::get_number_dnn_contexts() {
std::size_t smf_context::get_number_dnn_contexts() const {
return dnns.size();
}
......@@ -2547,6 +2696,35 @@ scid_t smf_context::get_scid() const {
return scid;
}
//-----------------------------------------------------------------------------
void smf_context::get_supi_prefix(std::string &prefix) const {
prefix = supi_prefix;
}
//-----------------------------------------------------------------------------
void smf_context::set_supi_prefix(std::string const &prefix) {
supi_prefix = prefix;
}
//-----------------------------------------------------------------------------
bool smf_context::find_pdu_session(const pfcp::pdr_id_t &pdr_id,
pfcp::qfi_t &qfi,
std::shared_ptr<dnn_context> &sd,
std::shared_ptr<smf_pdu_session> &sp) {
for (auto it : dnns) {
for (auto session : it.get()->pdu_sessions) {
smf_qos_flow flow = { };
if (session->find_qos_flow(pdr_id, flow)) {
qfi.qfi = flow.qfi.qfi;
sp = session;
sd = it;
return true;
}
}
}
return false;
}
//------------------------------------------------------------------------------
bool dnn_context::find_pdu_session(
const uint32_t pdu_session_id,
......@@ -2569,7 +2747,7 @@ void dnn_context::insert_pdu_session(std::shared_ptr<smf_pdu_session> &sp) {
pdu_sessions.push_back(sp);
}
size_t dnn_context::get_number_pdu_sessions() {
size_t dnn_context::get_number_pdu_sessions() const {
return pdu_sessions.size();
}
......
......@@ -328,10 +328,10 @@ class smf_pdu_session : public std::enable_shared_from_this<smf_pdu_session> {
/*
* Mark a QoS Rule to be synchronised with UE
* @param [uint8_t ]: rule_id: QoS Rule ID to be synchronised with UE
* @param [const uint8_t ]: rule_id: QoS Rule ID to be synchronised with UE
* @return void
*/
void mark_qos_rule_to_be_synchronised(uint8_t rule_id);
void mark_qos_rule_to_be_synchronised(const uint8_t rule_id);
/*
* Get all QoS Rules to be synchronised with UE
......@@ -363,7 +363,7 @@ class smf_pdu_session : public std::enable_shared_from_this<smf_pdu_session> {
* @param [QOSRulesIE &] qos_rule
* @return bool: Return true if Rule exist, otherwise return false
*/
bool get_qos_rule(uint8_t rule_id, QOSRulesIE &qos_rule) const;
bool get_qos_rule(const uint8_t rule_id, QOSRulesIE &qos_rule) const;
/*
* Update QoS Rule
......@@ -412,7 +412,7 @@ class smf_pdu_session : public std::enable_shared_from_this<smf_pdu_session> {
timer_id_t timer_T3591;
timer_id_t timer_T3592;
pfcp::qfi_t default_qfi; //Default QFI for this session
pfcp::qfi_t default_qfi; //Default QFI for this session
std::map<uint8_t, smf_qos_flow> qos_flows; // QFI <-> QoS Flow
std::map<uint8_t, QOSRulesIE> qos_rules; // QRI <-> QoS Rules
std::vector<uint8_t> qos_rules_to_be_synchronised;
......@@ -441,7 +441,8 @@ class session_management_subscription {
* @return void
*/
void insert_dnn_configuration(
const std::string &dnn, std::shared_ptr<dnn_configuration_t> &dnn_configuration);
const std::string &dnn,
std::shared_ptr<dnn_configuration_t> &dnn_configuration);
/*
* Find a DNN configuration
......@@ -450,7 +451,8 @@ class session_management_subscription {
* @return void
*/
void find_dnn_configuration(
const std::string &dnn, std::shared_ptr<dnn_configuration_t> &dnn_configuration) const;
const std::string &dnn,
std::shared_ptr<dnn_configuration_t> &dnn_configuration) const;
/*
* Verify whether DNN configuration with a given DNN exist
......@@ -509,7 +511,7 @@ class dnn_context {
* @param void
* @return size_t: number of PDU sessions
*/
size_t get_number_pdu_sessions();
size_t get_number_pdu_sessions() const;
/*
* Represent DNN Context as a string object
......@@ -536,6 +538,7 @@ class smf_context : public std::enable_shared_from_this<smf_context> {
pending_procedures(),
dnn_subscriptions(),
scid(0) {
supi_prefix = { };
}
smf_context(smf_context &b) = delete;
......@@ -663,11 +666,11 @@ class smf_context : public std::enable_shared_from_this<smf_context> {
/*
* Verify whether a subscription data exist with a given dnn and snssai
* @param [std::string &] dnn: DNN
* @param [const std::string &] dnn: DNN
* @param [const snssai_t&] snssai: single NSSAI
*@return bool: Return true if a subscription data corresponding with dnn and snssai exist, otherwise return false
*/
bool is_dnn_snssai_subscription_data(std::string &dnn, snssai_t &snssai);
bool is_dnn_snssai_subscription_data(const std::string &dnn, const snssai_t &snssai);
/*
* Find a session management subscription from a SMF context
......@@ -714,7 +717,7 @@ class smf_context : public std::enable_shared_from_this<smf_context> {
* @param
* @return std::size_t: the number of contexts
*/
std::size_t get_number_dnn_contexts();
std::size_t get_number_dnn_contexts() const;
/*
* Set SM Context ID
......@@ -730,9 +733,25 @@ class smf_context : public std::enable_shared_from_this<smf_context> {
*/
scid_t get_scid() const;
/*
* Get Supi prefix
* @param [const std::string &] prefix: Supi prefix (e.g., imsi)
* @return void
*/
void get_supi_prefix(std::string &prefix) const;
/*
* Get Supi prefix
* @param [const std::string &] prefix: Supi prefix (e.g., imsi)
* @return void
*/
void set_supi_prefix(std::string const &value);
/*
* Get the default QoS Rule for all QFIs
* @param [QOSRulesIE] qos_rule
* @param [const uint8_t] pdu_session_type: PDU session type (e.g., Ipv4, Ipv6)
* @return void
*/
void get_default_qos_rule(QOSRulesIE &qos_rule, uint8_t pdu_session_type);
......@@ -768,13 +787,26 @@ class smf_context : public std::enable_shared_from_this<smf_context> {
void get_session_ambr(Ngap_PDUSessionAggregateMaximumBitRate_t &session_ambr,
const snssai_t &snssai, const std::string &dnn);
/*
* Find the PDU Session, QFI associated with a given PDR_ID
* @param [const pfcp::pdr_id_t &] pdr_id: PDR ID
* @param [pfcp::qfi_t &] qfi: QFI
* @param [std::shared_ptr<dnn_context> &] sd: pointer to the DNN context
* @param [std::shared_ptr<smf_pdu_session> &] sp: pointer to the PDU session
* @return bool: return true if found, otherwise return false
*/
bool find_pdu_session(const pfcp::pdr_id_t &pdr_id, pfcp::qfi_t &qfi,
std::shared_ptr<dnn_context> &sd,
std::shared_ptr<smf_pdu_session> &sp);
private:
std::vector<std::shared_ptr<dnn_context>> dnns;
std::vector<std::shared_ptr<smf_procedure>> pending_procedures;
// snssai-sst <-> session management subscription
std::map<uint8_t, std::shared_ptr<session_management_subscription>> dnn_subscriptions;
supi_t supi;
scid_t scid; //SM Context ID
std::string supi_prefix;
scid_t scid; //SM Context ID
// Big recursive lock
mutable std::recursive_mutex m_context;
......
......@@ -78,7 +78,7 @@ pdu_session_msg_type_t pdu_session_msg::get_msg_type() const {
}
//-----------------------------------------------------------------------------
void pdu_session_msg::set_msg_type(pdu_session_msg_type_t const &msg_type) {
void pdu_session_msg::set_msg_type(const pdu_session_msg_type_t &msg_type) {
m_msg_type = msg_type;
}
......@@ -88,7 +88,7 @@ supi_t pdu_session_msg::get_supi() const {
}
//-----------------------------------------------------------------------------
void pdu_session_msg::set_supi(supi_t const &supi) {
void pdu_session_msg::set_supi(const supi_t &supi) {
m_supi = supi;
}
......@@ -98,7 +98,7 @@ std::string pdu_session_msg::get_supi_prefix() const {
}
//-----------------------------------------------------------------------------
void pdu_session_msg::set_supi_prefix(std::string const &prefix) {
void pdu_session_msg::set_supi_prefix(const std::string &prefix) {
m_supi_prefix = prefix;
}
......@@ -109,7 +109,7 @@ pdu_session_id_t pdu_session_msg::get_pdu_session_id() const {
//-----------------------------------------------------------------------------
void pdu_session_msg::set_pdu_session_id(
pdu_session_id_t const pdu_session_id) {
const pdu_session_id_t pdu_session_id) {
m_pdu_session_id = pdu_session_id;
}
......@@ -119,7 +119,7 @@ std::string pdu_session_msg::get_dnn() const {
}
//-----------------------------------------------------------------------------
void pdu_session_msg::set_dnn(std::string const &dnn) {
void pdu_session_msg::set_dnn(const std::string &dnn) {
m_dnn = dnn;
}
......@@ -129,12 +129,12 @@ snssai_t pdu_session_msg::get_snssai() const {
}
//-----------------------------------------------------------------------------
void pdu_session_msg::set_snssai(snssai_t const &snssai) {
void pdu_session_msg::set_snssai(const snssai_t &snssai) {
m_snssai = snssai;
}
//-----------------------------------------------------------------------------
void pdu_session_msg::set_api_root(std::string const &value) {
void pdu_session_msg::set_api_root(const std::string &value) {
m_api_root = value;
}
......@@ -148,7 +148,7 @@ uint8_t pdu_session_msg::get_pdu_session_type() const {
}
//-----------------------------------------------------------------------------
void pdu_session_msg::set_pdu_session_type(uint8_t const &pdu_session_type) {
void pdu_session_msg::set_pdu_session_type(const uint8_t &pdu_session_type) {
m_pdu_session_type = pdu_session_type;
}
......@@ -158,7 +158,7 @@ procedure_transaction_id_t pdu_session_msg::get_pti() const {
}
//-----------------------------------------------------------------------------
void pdu_session_msg::set_pti(procedure_transaction_id_t const &pti) {
void pdu_session_msg::set_pti(const procedure_transaction_id_t &pti) {
m_pti = pti;
}
......@@ -169,7 +169,7 @@ extended_protocol_discriminator_t pdu_session_create_sm_context::get_epd() const
//-----------------------------------------------------------------------------
void pdu_session_create_sm_context::set_epd(
extended_protocol_discriminator_t const &epd) {
const extended_protocol_discriminator_t &epd) {
m_epd = epd;
}
......@@ -180,7 +180,7 @@ uint8_t pdu_session_create_sm_context::get_message_type() const {
//-----------------------------------------------------------------------------
void pdu_session_create_sm_context::set_message_type(
uint8_t const &message_type) {
const uint8_t &message_type) {
m_message_type = message_type;
}
......@@ -202,7 +202,7 @@ std::string pdu_session_create_sm_context_request::get_serving_nf_id() const {
//-----------------------------------------------------------------------------
void pdu_session_create_sm_context_request::set_serving_nf_id(
std::string const &serving_nf_id) {
const std::string &serving_nf_id) {
m_serving_nf_id = serving_nf_id;
}
......@@ -213,13 +213,13 @@ std::string pdu_session_create_sm_context_request::get_request_type() const {
//-----------------------------------------------------------------------------
void pdu_session_create_sm_context_request::set_request_type(
std::string const &request_type) {
const std::string &request_type) {
m_request_type = request_type;
}
//-----------------------------------------------------------------------------
void pdu_session_create_sm_context_request::set_dnn_selection_mode(
std::string const &dnn_selection_mode) {
const std::string &dnn_selection_mode) {
m_dnn_selection_mode = dnn_selection_mode;
}
......@@ -277,7 +277,7 @@ std::string pdu_session_create_sm_context_response::get_n2_sm_information() cons
//-----------------------------------------------------------------------------
void pdu_session_create_sm_context_response::set_n2_sm_information(
std::string const &value) {
const std::string &value) {
m_n2_sm_information = value;
m_n2_sm_info_is_set = true;
}
......@@ -289,7 +289,7 @@ std::string pdu_session_create_sm_context_response::get_n1_sm_message() const {
//-----------------------------------------------------------------------------
void pdu_session_create_sm_context_response::set_n1_sm_message(
std::string const &value) {
const std::string &value) {
m_n1_sm_message = value;
m_n1_sm_msg_is_set = true;
}
......@@ -306,7 +306,7 @@ bool pdu_session_create_sm_context_response::n2_sm_info_is_set() const {
//-----------------------------------------------------------------------------
void pdu_session_create_sm_context_response::set_amf_url(
std::string const &value) {
const std::string &value) {
amf_url = value;
}
......@@ -322,7 +322,7 @@ std::string pdu_session_update_sm_context::get_n2_sm_information() const {
//-----------------------------------------------------------------------------
void pdu_session_update_sm_context::set_n2_sm_information(
std::string const &value) {
const std::string &value) {
m_n2_sm_information = value;
m_n2_sm_info_is_set = true;
}
......@@ -334,7 +334,7 @@ std::string pdu_session_update_sm_context::get_n2_sm_info_type() const {
//-----------------------------------------------------------------------------
void pdu_session_update_sm_context::set_n2_sm_info_type(
std::string const &value) {
const std::string &value) {
m_n2_sm_info_type = value;
m_n2_sm_info_is_set = true;
}
......@@ -346,7 +346,7 @@ std::string pdu_session_update_sm_context::get_n1_sm_message() const {
//-----------------------------------------------------------------------------
void pdu_session_update_sm_context::set_n1_sm_message(
std::string const &value) {
const std::string &value) {
m_n1_sm_message = value;
m_n1_sm_msg_is_set = true;
}
......@@ -362,12 +362,12 @@ bool pdu_session_update_sm_context::n2_sm_info_is_set() const {
}
//-----------------------------------------------------------------------------
void pdu_session_update_sm_context_request::add_qfi(pfcp::qfi_t const &qfi) {
void pdu_session_update_sm_context_request::add_qfi(const pfcp::qfi_t &qfi) {
qfis.push_back(qfi);
}
//-----------------------------------------------------------------------------
void pdu_session_update_sm_context_request::add_qfi(uint8_t const &q) {
void pdu_session_update_sm_context_request::add_qfi(const uint8_t &q) {
pfcp::qfi_t qfi(q);
qfis.push_back(qfi);
}
......@@ -381,7 +381,7 @@ void pdu_session_update_sm_context_request::get_qfis(
}
//-----------------------------------------------------------------------------
void pdu_session_update_sm_context_request::set_dl_fteid(fteid_t const &t) {
void pdu_session_update_sm_context_request::set_dl_fteid(const fteid_t &t) {
dl_fteid = t;
}
......@@ -392,7 +392,7 @@ void pdu_session_update_sm_context_request::get_dl_fteid(fteid_t &t) {
//-----------------------------------------------------------------------------
void pdu_session_update_sm_context_request::set_upCnx_state(
std::string const &value) {
const std::string &value) {
m_upCnx_state = value;
m_upCnx_state_is_set = true;
}
......@@ -404,7 +404,7 @@ bool pdu_session_update_sm_context_request::upCnx_state_is_set() const {
//-----------------------------------------------------------------------------
void pdu_session_update_sm_context_request::set_rat_type(
std::string const &value) {
const std::string &value) {
m_rat_type = value;
m_rat_type_is_set = true;
}
......@@ -416,7 +416,7 @@ bool pdu_session_update_sm_context_request::rat_type_is_set() const {
//-----------------------------------------------------------------------------
void pdu_session_update_sm_context_request::set_an_type(
std::string const &value) {
const std::string &value) {
m_an_type = value;
m_an_type_is_set = true;
}
......@@ -432,7 +432,7 @@ bool pdu_session_update_sm_context_request::release_is_set() const {
}
//-----------------------------------------------------------------------------
void pdu_session_update_sm_context_request::set_release(bool const value) {
void pdu_session_update_sm_context_request::set_release(bool value) {
m_release = value;
m_release_is_set = true;
}
......@@ -461,8 +461,7 @@ void pdu_session_update_sm_context_response::add_qos_flow_context_updated(
flow.qfi.qfi);
} else {
Logger::smf_app().error(
"Failed to add a QoS Flow Context (QFI %d), invalid QFI",
flow.qfi.qfi);
"Failed to add a QoS Flow Context (QFI %d), invalid QFI", flow.qfi.qfi);
}
}
......@@ -516,7 +515,7 @@ Pistache::Http::Code pdu_session_modification_network_requested::get_http_code()
//-----------------------------------------------------------------------------
void pdu_session_modification_network_requested::set_amf_url(
std::string const &value) {
const std::string &value) {
amf_url = value;
}
......@@ -527,12 +526,12 @@ std::string pdu_session_modification_network_requested::get_amf_url() const {
//-----------------------------------------------------------------------------
void pdu_session_modification_network_requested::add_qfi(
pfcp::qfi_t const &qfi) {
const pfcp::qfi_t &qfi) {
qfis.push_back(qfi);
}
//-----------------------------------------------------------------------------
void pdu_session_modification_network_requested::add_qfi(uint8_t const &q) {
void pdu_session_modification_network_requested::add_qfi(const uint8_t &q) {
pfcp::qfi_t qfi(q);
qfis.push_back(qfi);
}
......@@ -545,3 +544,100 @@ void pdu_session_modification_network_requested::get_qfis(
}
}
//-----------------------------------------------------------------------------
void pdu_session_report_response::set_amf_url(const std::string &value) {
amf_url = value;
}
//-----------------------------------------------------------------------------
std::string pdu_session_report_response::get_amf_url() const {
return amf_url;
}
//-----------------------------------------------------------------------------
void pdu_session_report_response::add_qos_flow_context_updated(
const qos_flow_context_updated &flow) {
if ((flow.qfi.qfi >= QOS_FLOW_IDENTIFIER_FIRST )
and (flow.qfi.qfi <= QOS_FLOW_IDENTIFIER_LAST )) {
qos_flow_context_updateds.erase(flow.qfi.qfi);
qos_flow_context_updateds.insert(
std::pair<uint8_t, qos_flow_context_updated>((uint8_t) flow.qfi.qfi,
flow));
Logger::smf_app().trace(
"A QoS Flow Context (QFI %d) has been added successfully",
flow.qfi.qfi);
} else {
Logger::smf_app().error(
"Failed to add a QoS Flow Context (QFI %d), invalid QFI", flow.qfi.qfi);
}
}
//-----------------------------------------------------------------------------
bool pdu_session_report_response::get_qos_flow_context_updated(
const pfcp::qfi_t &qfi, qos_flow_context_updated &flow) {
for (auto it : qos_flow_context_updateds) {
if (it.second.qfi == qfi) {
flow = it.second;
return true;
}
}
return false;
}
//-----------------------------------------------------------------------------
void pdu_session_report_response::get_all_qos_flow_context_updateds(
std::map<uint8_t, qos_flow_context_updated> &all_flows) {
for (auto it : qos_flow_context_updateds) {
all_flows.insert(
std::pair<uint8_t, qos_flow_context_updated>((uint8_t) it.first,
it.second));
}
}
//-----------------------------------------------------------------------------
std::string pdu_session_report_response::get_n2_sm_information() const {
return m_n2_sm_information;
}
//-----------------------------------------------------------------------------
void pdu_session_report_response::set_n2_sm_information(
const std::string &value) {
m_n2_sm_information = value;
m_n2_sm_info_is_set = true;
}
//-----------------------------------------------------------------------------
std::string pdu_session_report_response::get_n2_sm_info_type() const {
return m_n2_sm_info_type;
}
//-----------------------------------------------------------------------------
void pdu_session_report_response::set_n2_sm_info_type(
const std::string &value) {
m_n2_sm_info_type = value;
m_n2_sm_info_is_set = true;
}
//-----------------------------------------------------------------------------
std::string pdu_session_report_response::get_n1_sm_message() const {
return m_n1_sm_message;
}
//-----------------------------------------------------------------------------
void pdu_session_report_response::set_n1_sm_message(
const std::string &value) {
m_n1_sm_message = value;
m_n1_sm_msg_is_set = true;
}
//-----------------------------------------------------------------------------
bool pdu_session_report_response::n1_sm_msg_is_set() const {
return m_n1_sm_msg_is_set;
}
//-----------------------------------------------------------------------------
bool pdu_session_report_response::n2_sm_info_is_set() const {
return m_n2_sm_info_is_set;
}
......@@ -124,23 +124,23 @@ class pdu_session_msg {
virtual ~pdu_session_msg() = default;
pdu_session_msg_type_t get_msg_type() const;
void set_msg_type(pdu_session_msg_type_t const &value);
void set_msg_type(const pdu_session_msg_type_t &value);
supi_t get_supi() const;
void set_supi(supi_t const &value);
void set_supi(const supi_t &value);
std::string get_supi_prefix() const;
void set_supi_prefix(std::string const &value);
void set_supi_prefix(const std::string &value);
pdu_session_id_t get_pdu_session_id() const;
void set_pdu_session_id(pdu_session_id_t const value);
void set_pdu_session_id(const pdu_session_id_t value);
std::string get_dnn() const;
void set_dnn(std::string const &value);
void set_dnn(const std::string &value);
snssai_t get_snssai() const;
void set_snssai(snssai_t const &value);
void set_api_root(std::string const &value);
void set_snssai(const snssai_t &value);
void set_api_root(const std::string &value);
std::string get_api_root() const;
uint8_t get_pdu_session_type() const;
void set_pdu_session_type(uint8_t const &pdu_session_type);
void set_pdu_session_type(const uint8_t &pdu_session_type);
procedure_transaction_id_t get_pti() const;
void set_pti(procedure_transaction_id_t const &pti);
void set_pti(const procedure_transaction_id_t &pti);
private:
pdu_session_msg_type_t m_msg_type;
......@@ -182,9 +182,9 @@ class pdu_session_create_sm_context : public pdu_session_msg {
}
extended_protocol_discriminator_t get_epd() const;
void set_epd(extended_protocol_discriminator_t const &epd);
void set_epd(const extended_protocol_discriminator_t &epd);
uint8_t get_message_type() const;
void set_message_type(uint8_t const &message_type);
void set_message_type(const uint8_t &message_type);
private:
extended_protocol_discriminator_t m_epd;
......@@ -210,12 +210,12 @@ class pdu_session_create_sm_context_request :
}
std::string get_n1_sm_message() const;
void set_n1_sm_message(std::string const &value);
void set_n1_sm_message(const std::string &value);
std::string get_serving_nf_id() const;
void set_serving_nf_id(std::string const &value);
void set_serving_nf_id(const std::string &value);
std::string get_request_type() const;
void set_request_type(std::string const &value);
void set_dnn_selection_mode(std::string const &value);
void set_request_type(const std::string &value);
void set_dnn_selection_mode(const std::string &value);
std::string get_dnn_selection_mode() const;
private:
......@@ -267,12 +267,12 @@ class pdu_session_create_sm_context_response :
void set_qos_flow_context(const qos_flow_context_updated &qos_flow);
qos_flow_context_updated get_qos_flow_context() const;
std::string get_n2_sm_information() const;
void set_n2_sm_information(std::string const &value);
void set_n2_sm_information(const std::string &value);
std::string get_n1_sm_message() const;
void set_n1_sm_message(std::string const &value);
void set_n1_sm_message(const std::string &value);
bool n1_sm_msg_is_set() const;
bool n2_sm_info_is_set() const;
void set_amf_url(std::string const &value);
void set_amf_url(const std::string &value);
std::string get_amf_url() const;
nlohmann::json n1n2_message_transfer_data; //N1N2MessageTransferReqData from oai::amf::model
......@@ -312,9 +312,9 @@ class pdu_session_update_sm_context : public pdu_session_msg {
std::string get_n2_sm_information() const;
void set_n2_sm_information(std::string const &value);
std::string get_n2_sm_info_type() const;
void set_n2_sm_info_type(std::string const &value);
void set_n2_sm_info_type(const std::string &value);
std::string get_n1_sm_message() const;
void set_n1_sm_message(std::string const &value);
void set_n1_sm_message(const std::string &value);
bool n1_sm_msg_is_set() const;
bool n2_sm_info_is_set() const;
......@@ -345,19 +345,19 @@ class pdu_session_update_sm_context_request :
}
;
void add_qfi(pfcp::qfi_t const &qfi);
void add_qfi(uint8_t const &qfi);
void add_qfi(const pfcp::qfi_t &qfi);
void add_qfi(const uint8_t &qfi);
void get_qfis(std::vector<pfcp::qfi_t> &q);
void set_dl_fteid(fteid_t const &t);
void set_dl_fteid(const fteid_t &t);
void get_dl_fteid(fteid_t &t);
void set_upCnx_state(std::string const &value);
void set_upCnx_state(const std::string &value);
bool upCnx_state_is_set() const;
void set_rat_type(std::string const &value);
void set_rat_type(const std::string &value);
bool rat_type_is_set() const;
void set_an_type(std::string const &value);
void set_an_type(const std::string &value);
bool an_type_is_set() const;
bool release_is_set() const;
void set_release(bool const value);
void set_release(bool value);
private:
std::vector<pfcp::qfi_t> qfis;
......@@ -456,10 +456,10 @@ class pdu_session_modification_network_requested :
void set_http_code(Pistache::Http::Code code);
Pistache::Http::Code get_http_code();
void set_amf_url(std::string const &value);
void set_amf_url(const std::string &value);
std::string get_amf_url() const;
void add_qfi(pfcp::qfi_t const &qfi);
void add_qfi(uint8_t const &qfi);
void add_qfi(const pfcp::qfi_t &qfi);
void add_qfi(const uint8_t &qfi);
void get_qfis(std::vector<pfcp::qfi_t> &q);
nlohmann::json n1n2_message_transfer_data; //N1N2MessageTransferReqData from oai::amf::model
......@@ -472,6 +472,55 @@ class pdu_session_modification_network_requested :
std::map<uint8_t, qos_flow_context_updated> qos_flow_context_updateds;
};
//---------------------------------------------------------------------------------------
class pdu_session_report_response : public pdu_session_msg {
public:
public:
pdu_session_report_response()
:
pdu_session_msg() {
m_n2_sm_info_is_set = false;
m_n1_sm_msg_is_set = false;
}
;
pdu_session_report_response(pdu_session_msg_type_t msg_type)
:
pdu_session_msg(msg_type) {
m_n2_sm_info_is_set = false;
m_n1_sm_msg_is_set = false;
}
;
void set_amf_url(std::string const &value);
std::string get_amf_url() const;
void add_qos_flow_context_updated(const qos_flow_context_updated &qos_flow);
bool get_qos_flow_context_updated(const pfcp::qfi_t &qfi,
qos_flow_context_updated &qos_flow);
void get_all_qos_flow_context_updateds(
std::map<uint8_t, qos_flow_context_updated> &all_flows);
std::string get_n2_sm_information() const;
void set_n2_sm_information(const std::string &value);
std::string get_n2_sm_info_type() const;
void set_n2_sm_info_type(const std::string &value);
std::string get_n1_sm_message() const;
void set_n1_sm_message(const std::string &value);
bool n1_sm_msg_is_set() const;
bool n2_sm_info_is_set() const;
nlohmann::json n1n2_message_transfer_data; //N1N2MessageTransferReqData from oai::amf::model
private:
supi_t m_supi;
std::string m_supi_prefix;
std::string amf_url;
std::map<uint8_t, qos_flow_context_updated> qos_flow_context_updateds;
std::string m_n1_sm_message;
bool m_n1_sm_msg_is_set;
std::string m_n2_sm_information;
bool m_n2_sm_info_is_set;
std::string m_n2_sm_info_type;
};
}
#endif
......@@ -101,7 +101,7 @@ smf_n10::smf_n10() {
//------------------------------------------------------------------------------
bool smf_n10::get_sm_data(
supi64_t &supi, std::string &dnn, snssai_t &snssai,
const supi64_t &supi, const std::string &dnn, const snssai_t &snssai,
std::shared_ptr<session_management_subscription> subscription) {
//retrieve a UE's Session Management Subscription Data (TS29503_Nudm_SDM.yaml: /{supi}/sm-data)
//use curl to send data for the moment
......@@ -114,7 +114,6 @@ bool smf_n10::get_sm_data(
headers = curl_slist_append(headers, "charsets: utf-8");
CURL *curl = curl_easy_init();
// std::string url = std::string(inet_ntoa (*((struct in_addr *)&smf_cfg.udm_addr.ipv4_addr))) + ":" + std::to_string(smf_cfg.udm_addr.port) + "/nudm-sdm/v2/" + std::to_string(supi) +"/sm-data";
std::string url = std::string(
inet_ntoa(*((struct in_addr*) &smf_cfg.udm_addr.ipv4_addr))) + ":"
+ std::to_string(smf_cfg.udm_addr.port)
......@@ -148,7 +147,6 @@ bool smf_n10::get_sm_data(
== http_response_codes_e::HTTP_RESPONSE_CODE_OK) {
Logger::smf_n10().debug("Got successful response from UDM, URL: %s ",
url.c_str());
//Logger::smf_n10().debug("[get_sm_data] Http Data from UDM: %s ", *httpData.get());
try {
jsonData = nlohmann::json::parse(*httpData.get());
//curl_easy_cleanup(curl);
......
......@@ -50,15 +50,15 @@ class smf_n10 {
/*
* Get SM subscription data from UDM
* @param [supi64_t &] supi
* @param [std::string &] dnn
* @param [snssai_t &] snssai
* @param [const supi64_t &] supi
* @param [const std::string &] dnn
* @param [const snssai_t &] snssai
* @param [std::shared_ptr<session_management_subscription>] subscription
* @return bool: True if successful, otherwise false
*
*/
bool get_sm_data(
supi64_t &supi, std::string &dnn, snssai_t &snssai,
const supi64_t &supi, const std::string &dnn, const snssai_t &snssai,
std::shared_ptr<session_management_subscription> subscription);
/*
......
......@@ -103,6 +103,12 @@ void smf_n11_task(void *args_p) {
shared_msg));
break;
case N11_SESSION_REPORT_RESPONSE:
//TODO
smf_n11_inst->send_n1n2_message_transfer_request(
std::static_pointer_cast<itti_n11_session_report_request>(
shared_msg));
break;
case TERMINATE:
if (itti_msg_terminate *terminate =
dynamic_cast<itti_msg_terminate*>(msg)) {
......@@ -139,7 +145,6 @@ void smf_n11::send_n1n2_message_transfer_request(
smf_n1_n2 smf_n1_n2_inst = { };
std::string n1_message = sm_context_res->res.get_n1_sm_message();
std::string json_part = sm_context_res->res.n1n2_message_transfer_data.dump();
std::string boundary = "----Boundary";
std::string body;
//add N2 content if available
......@@ -148,11 +153,11 @@ void smf_n11::send_n1n2_message_transfer_request(
if (n2_sm_found > 0) {
std::string n2_message = sm_context_res->res.get_n2_sm_information();
//prepare the body content for Curl
create_multipart_related_content(body, json_part, boundary, n1_message,
create_multipart_related_content(body, json_part, CURL_MIME_BOUNDARY, n1_message,
n2_message);
} else {
//prepare the body content for Curl
create_multipart_related_content(body, json_part, boundary, n1_message,
create_multipart_related_content(body, json_part, CURL_MIME_BOUNDARY, n1_message,
multipart_related_content_part_e::NAS);
}
......@@ -168,8 +173,9 @@ void smf_n11::send_n1n2_message_transfer_request(
CURLcode res = { };
struct curl_slist *headers = nullptr;
//headers = curl_slist_append(headers, "charsets: utf-8");
headers = curl_slist_append(
headers, "content-type: multipart/related; boundary=----Boundary"); //TODO: update Boundary
std::string content_type = "content-type: multipart/related; boundary="
+ std::string(CURL_MIME_BOUNDARY);
headers = curl_slist_append(headers, content_type.c_str());
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_URL,
sm_context_res->res.get_amf_url().c_str());
......@@ -210,6 +216,8 @@ void smf_n11::send_n1n2_message_transfer_request(
TASK_SMF_APP);
itti_msg->set_response_code(httpCode);
itti_msg->set_scid(sm_context_res->scid);
itti_msg->set_procedure_type(
session_management_procedures_type_e::PDU_SESSION_ESTABLISHMENT_UE_REQUESTED);
itti_msg->set_cause(response_data["cause"]);
if (sm_context_res->res.get_cause() == REQUEST_ACCEPTED) {
itti_msg->set_msg_type(PDU_SESSION_ESTABLISHMENT_ACCEPT);
......@@ -244,7 +252,6 @@ void smf_n11::send_n1n2_message_transfer_request(
smf_n1_n2 smf_n1_n2_inst = { };
std::string n1_message = sm_context_res->msg.get_n1_sm_message();
std::string json_part = sm_context_res->msg.n1n2_message_transfer_data.dump();
std::string boundary = "----Boundary";
std::string body;
//add N2 content if available
......@@ -253,11 +260,11 @@ void smf_n11::send_n1n2_message_transfer_request(
if (n2_sm_found > 0) {
std::string n2_message = sm_context_res->msg.get_n2_sm_information();
//prepare the body content for Curl
create_multipart_related_content(body, json_part, boundary, n1_message,
create_multipart_related_content(body, json_part, CURL_MIME_BOUNDARY, n1_message,
n2_message);
} else {
//prepare the body content for Curl
create_multipart_related_content(body, json_part, boundary, n1_message,
create_multipart_related_content(body, json_part, CURL_MIME_BOUNDARY, n1_message,
multipart_related_content_part_e::NAS);
}
......@@ -273,8 +280,9 @@ void smf_n11::send_n1n2_message_transfer_request(
CURLcode res = { };
struct curl_slist *headers = nullptr;
//headers = curl_slist_append(headers, "charsets: utf-8");
headers = curl_slist_append(
headers, "content-type: multipart/related; boundary=----Boundary"); //TODO: update Boundary
std::string content_type = "content-type: multipart/related; boundary="
+ std::string(CURL_MIME_BOUNDARY);
headers = curl_slist_append(headers, content_type.c_str());
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_URL,
sm_context_res->msg.get_amf_url().c_str());
......@@ -303,8 +311,6 @@ void smf_n11::send_n1n2_message_transfer_request(
response_data = json::parse(*httpData.get());
} catch (json::exception &e) {
Logger::smf_n11().warn("Could not get the cause from the response");
//Set the default Cause
//response_data["cause"] = "504 Gateway Timeout";
}
Logger::smf_n11().debug("Response from AMF, Http Code: %d", httpCode);
......@@ -316,6 +322,106 @@ void smf_n11::send_n1n2_message_transfer_request(
}
//------------------------------------------------------------------------------
void smf_n11::send_n1n2_message_transfer_request(
std::shared_ptr<itti_n11_session_report_request> report_msg) {
Logger::smf_n11().debug(
"Send Communication_N1N2MessageTransfer to AMF (Network-initiated Service Request)");
smf_n1_n2 smf_n1_n2_inst = { };
std::string n2_message = report_msg->res.get_n2_sm_information();
std::string json_part = report_msg->res.n1n2_message_transfer_data.dump();
std::string body;
//add N1 content if available
auto n1_sm_found = report_msg->res.n1n2_message_transfer_data.count(
"n1MessageContainer");
if (n1_sm_found > 0) {
std::string n1_message = report_msg->res.get_n1_sm_message();
//prepare the body content for Curl
create_multipart_related_content(body, json_part, CURL_MIME_BOUNDARY, n1_message,
n2_message);
} else {
create_multipart_related_content(body, json_part, CURL_MIME_BOUNDARY, n2_message,
multipart_related_content_part_e::NGAP);
}
unsigned int str_len = body.length();
char *data = (char*) malloc(str_len + 1);
memset(data, 0, str_len + 1);
memcpy((void*) data, (void*) body.c_str(), str_len);
curl_global_init(CURL_GLOBAL_ALL);
CURL *curl = curl_easy_init();
if (curl) {
CURLcode res = { };
struct curl_slist *headers = nullptr;
//headers = curl_slist_append(headers, "charsets: utf-8");
std::string content_type = "content-type: multipart/related; boundary="
+ std::string(CURL_MIME_BOUNDARY);
headers = curl_slist_append(headers, content_type.c_str());
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_URL, report_msg->res.get_amf_url().c_str());
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1);
curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, AMF_CURL_TIMEOUT_MS);
curl_easy_setopt(curl, CURLOPT_INTERFACE, smf_cfg.sbi.if_name.c_str());
// Response information.
long httpCode = { 0 };
std::unique_ptr<std::string> httpData(new std::string());
// Hook up data handling function
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &callback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, httpData.get());
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, body.length());
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
res = curl_easy_perform(curl);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode);
//get cause from the response
json response_data = { };
try {
response_data = json::parse(*httpData.get());
} catch (json::exception &e) {
Logger::smf_n11().warn("Could not get the cause from the response");
//Set the default Cause
response_data["cause"] = "504 Gateway Timeout";
}
Logger::smf_n11().debug("Response from AMF, Http Code: %d, cause %s",
httpCode, response_data["cause"].dump().c_str());
//send response to APP to process
itti_n11_n1n2_message_transfer_response_status *itti_msg =
new itti_n11_n1n2_message_transfer_response_status(TASK_SMF_N11,
TASK_SMF_APP);
itti_msg->set_response_code(httpCode);
itti_msg->set_procedure_type(
session_management_procedures_type_e::SERVICE_REQUEST_NETWORK_TRIGGERED);
itti_msg->set_cause(response_data["cause"]);
std::shared_ptr<itti_n11_n1n2_message_transfer_response_status> i =
std::shared_ptr<itti_n11_n1n2_message_transfer_response_status>(
itti_msg);
int ret = itti_inst->send_msg(i);
if (RETURNok != ret) {
Logger::smf_n11().error(
"Could not send ITTI message %s to task TASK_SMF_APP",
i->get_msg_name());
}
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
}
curl_global_cleanup();
free_wrapper((void**) &data);
}
//------------------------------------------------------------------------------
void smf_n11::send_pdu_session_update_sm_context_response(
std::shared_ptr<itti_n11_update_sm_context_response> sm_context_res) {
......@@ -326,19 +432,18 @@ void smf_n11::send_pdu_session_update_sm_context_response(
case session_management_procedures_type_e::PDU_SESSION_TEST: {
Logger::smf_n11().debug("PDU_SESSION_TEST");
std::string boundary = "----Boundary";
std::string json_part =
sm_context_res->res.sm_context_updated_data.dump();
std::string n1_message = sm_context_res->res.get_n1_sm_message();
std::string n2_message = sm_context_res->res.get_n2_sm_information();
std::string body;
create_multipart_related_content(body, json_part, boundary, n1_message,
create_multipart_related_content(body, json_part, CURL_MIME_BOUNDARY, n1_message,
n2_message);
sm_context_res->http_response.headers()
.add<Pistache::Http::Header::ContentType>(
Pistache::Http::Mime::MediaType(
"multipart/related; boundary=" + boundary));
"multipart/related; boundary=" + std::string(CURL_MIME_BOUNDARY)));
sm_context_res->http_response.send(Pistache::Http::Code::Ok, body);
}
break;
......@@ -358,19 +463,18 @@ void smf_n11::send_pdu_session_update_sm_context_response(
case session_management_procedures_type_e::PDU_SESSION_MODIFICATION_UE_INITIATED_STEP1: {
Logger::smf_n11().info("PDU_SESSION_MODIFICATION_UE_INITIATED (step 1)");
std::string boundary = "----Boundary";
std::string json_part =
sm_context_res->res.sm_context_updated_data.dump();
std::string n1_message = sm_context_res->res.get_n1_sm_message();
std::string n2_message = sm_context_res->res.get_n2_sm_information();
std::string body;
create_multipart_related_content(body, json_part, boundary, n1_message,
create_multipart_related_content(body, json_part, CURL_MIME_BOUNDARY, n1_message,
n2_message);
sm_context_res->http_response.headers()
.add<Pistache::Http::Header::ContentType>(
Pistache::Http::Mime::MediaType(
"multipart/related; boundary=" + boundary));
"multipart/related; boundary=" + std::string(CURL_MIME_BOUNDARY)));
sm_context_res->http_response.send(Pistache::Http::Code::Ok, body);
}
......@@ -391,18 +495,17 @@ void smf_n11::send_pdu_session_update_sm_context_response(
case session_management_procedures_type_e::SERVICE_REQUEST_UE_TRIGGERED_STEP1: {
Logger::smf_n11().info("SERVICE_REQUEST_UE_TRIGGERED (step 1)");
std::string boundary = "----Boundary";
std::string json_part =
sm_context_res->res.sm_context_updated_data.dump();
std::string n2_message = sm_context_res->res.get_n2_sm_information();
std::string body;
create_multipart_related_content(body, json_part, boundary, n2_message,
create_multipart_related_content(body, json_part, CURL_MIME_BOUNDARY, n2_message,
multipart_related_content_part_e::NGAP);
sm_context_res->http_response.headers()
.add<Pistache::Http::Header::ContentType>(
Pistache::Http::Mime::MediaType(
"multipart/related; boundary=" + boundary));
"multipart/related; boundary=" + std::string(CURL_MIME_BOUNDARY)));
sm_context_res->http_response.send(Pistache::Http::Code::Ok, body);
}
......@@ -424,19 +527,18 @@ void smf_n11::send_pdu_session_update_sm_context_response(
case session_management_procedures_type_e::PDU_SESSION_RELEASE_UE_REQUESTED_STEP1: {
Logger::smf_n11().info("PDU_SESSION_RELEASE_UE_REQUESTED (step 1)");
std::string boundary = "----Boundary";
std::string json_part =
sm_context_res->res.sm_context_updated_data.dump();
std::string n1_message = sm_context_res->res.get_n1_sm_message();
std::string n2_message = sm_context_res->res.get_n2_sm_information();
std::string body;
create_multipart_related_content(body, json_part, boundary, n1_message,
create_multipart_related_content(body, json_part, CURL_MIME_BOUNDARY, n1_message,
n2_message);
sm_context_res->http_response.headers()
.add<Pistache::Http::Header::ContentType>(
Pistache::Http::Mime::MediaType(
"multipart/related; boundary=" + boundary));
"multipart/related; boundary=" + std::string(CURL_MIME_BOUNDARY)));
sm_context_res->http_response.send(Pistache::Http::Code::Ok, body);
}
break;
......@@ -463,7 +565,7 @@ void smf_n11::send_pdu_session_update_sm_context_response(
//------------------------------------------------------------------------------
void smf_n11::send_pdu_session_update_sm_context_response(
Pistache::Http::ResponseWriter &httpResponse,
oai::smf_server::model::SmContextUpdateError &smContextUpdateError,
const oai::smf_server::model::SmContextUpdateError &smContextUpdateError,
Pistache::Http::Code code) {
Logger::smf_n11().debug("Send PDUSession_UpdateSMContext Response to AMF.");
......@@ -477,57 +579,52 @@ void smf_n11::send_pdu_session_update_sm_context_response(
} else {
httpResponse.send(code);
}
}
//------------------------------------------------------------------------------
void smf_n11::send_pdu_session_update_sm_context_response(
Pistache::Http::ResponseWriter &httpResponse,
oai::smf_server::model::SmContextUpdateError &smContextUpdateError,
const oai::smf_server::model::SmContextUpdateError &smContextUpdateError,
Pistache::Http::Code code, std::string &n1_sm_msg) {
Logger::smf_n11().debug("Send PDUSession_UpdateSMContext Response to AMF.");
std::string boundary = "----Boundary";
nlohmann::json json_part = { };
to_json(json_part, smContextUpdateError);
std::string json_str = json_part.dump();
std::string body;
create_multipart_related_content(body, json_str, boundary, n1_sm_msg,
create_multipart_related_content(body, json_str, CURL_MIME_BOUNDARY, n1_sm_msg,
multipart_related_content_part_e::NAS);
httpResponse.headers().add<Pistache::Http::Header::ContentType>(
Pistache::Http::Mime::MediaType(
"multipart/related; boundary=" + boundary));
"multipart/related; boundary=" + std::string(CURL_MIME_BOUNDARY)));
httpResponse.send(code, body);
}
//------------------------------------------------------------------------------
void smf_n11::send_pdu_session_create_sm_context_response(
Pistache::Http::ResponseWriter &httpResponse,
oai::smf_server::model::SmContextCreateError &smContextCreateError,
const oai::smf_server::model::SmContextCreateError &smContextCreateError,
Pistache::Http::Code code, std::string &n1_sm_msg) {
Logger::smf_n11().debug("Send PDUSession_CreateSMContext Response to AMF.");
std::string boundary = "----Boundary";
nlohmann::json json_part = { };
to_json(json_part, smContextCreateError);
std::string json_str = json_part.dump();
std::string body;
create_multipart_related_content(body, json_str, boundary, n1_sm_msg,
create_multipart_related_content(body, json_str, CURL_MIME_BOUNDARY, n1_sm_msg,
multipart_related_content_part_e::NAS);
httpResponse.headers().add<Pistache::Http::Header::ContentType>(
Pistache::Http::Mime::MediaType(
"multipart/related; boundary=" + boundary));
"multipart/related; boundary=" + std::string(CURL_MIME_BOUNDARY)));
httpResponse.send(code, body);
}
//------------------------------------------------------------------------------
void smf_n11::send_pdu_session_update_sm_context_response(
Pistache::Http::ResponseWriter &httpResponse,
oai::smf_server::model::SmContextUpdatedData &smContextUpdatedData,
const oai::smf_server::model::SmContextUpdatedData &smContextUpdatedData,
Pistache::Http::Code code) {
Logger::smf_n11().debug("Send PDUSession_UpdateSMContext Response to AMF.");
nlohmann::json json_data = { };
......@@ -539,13 +636,12 @@ void smf_n11::send_pdu_session_update_sm_context_response(
} else {
httpResponse.send(code);
}
}
//------------------------------------------------------------------------------
void smf_n11::send_pdu_session_create_sm_context_response(
Pistache::Http::ResponseWriter &httpResponse,
oai::smf_server::model::SmContextCreatedData &smContextCreatedData,
const oai::smf_server::model::SmContextCreatedData &smContextCreatedData,
Pistache::Http::Code code) {
Logger::smf_n11().debug("Send PDUSession_CreateSMContext Response to AMF.");
nlohmann::json json_data = { };
......@@ -557,7 +653,6 @@ void smf_n11::send_pdu_session_create_sm_context_response(
} else {
httpResponse.send(code);
}
}
//------------------------------------------------------------------------------
......@@ -576,7 +671,7 @@ void smf_n11::send_pdu_session_release_sm_context_response(
//------------------------------------------------------------------------------
void smf_n11::send_pdu_session_release_sm_context_response(
Pistache::Http::ResponseWriter &httpResponse,
oai::smf_server::model::ProblemDetails &problem,
const oai::smf_server::model::ProblemDetails &problem,
Pistache::Http::Code code) {
Logger::smf_n11().debug("Send PDUSession_ReleaseSMContext Response to AMF.");
......@@ -593,10 +688,10 @@ void smf_n11::send_pdu_session_release_sm_context_response(
//------------------------------------------------------------------------------
void smf_n11::create_multipart_related_content(std::string &body,
std::string &json_part,
std::string &boundary,
std::string &n1_message,
std::string &n2_message) {
const std::string &json_part,
const std::string boundary,
const std::string &n1_message,
const std::string &n2_message) {
//format string as hex
unsigned char *n1_msg_hex = smf_app_inst->format_string_as_hex(n1_message);
......@@ -614,8 +709,6 @@ void smf_n11::create_multipart_related_content(std::string &body,
+ CRLF);
body.append(CRLF);
body.append(std::string((char*) n1_msg_hex, n1_message.length() / 2) + CRLF);
//body.append(n1_message + CRLF);
body.append("--" + boundary + CRLF);
body.append(
"Content-Type: application/vnd.3gpp.ngap" + CRLF + "Content-Id: n2SmMsg"
......@@ -627,8 +720,8 @@ void smf_n11::create_multipart_related_content(std::string &body,
//------------------------------------------------------------------------------
void smf_n11::create_multipart_related_content(
std::string &body, std::string &json_part, std::string &boundary,
std::string &message, multipart_related_content_part_e content_type) {
std::string &body, const std::string &json_part, const std::string boundary,
const std::string &message, const multipart_related_content_part_e content_type) {
//format string as hex
unsigned char *msg_hex = smf_app_inst->format_string_as_hex(message);
......
......@@ -67,6 +67,14 @@ class smf_n11 {
void send_n1n2_message_transfer_request(
std::shared_ptr<itti_nx_trigger_pdu_session_modification> sm_context_res);
/*
* Send N1N2 Message Transfer Request to AMF
* @param [std::shared_ptr<itti_n11_session_report_request>] n11_msg: Content of message to be sent
* @return void
*/
void send_n1n2_message_transfer_request(
std::shared_ptr<itti_n11_session_report_request> report_msg);
/*
* Send update session response to AMF
* @param [std::shared_ptr<itti_n11_update_sm_context_response> sm_context_res] sm_context_res
......@@ -86,75 +94,75 @@ class smf_n11 {
/*
* Send update session response to AMF
* @param [Pistache::Http::ResponseWriter] httpResponse
* @param [ oai::smf_server::model::SmContextUpdateError] SmContextUpdateError
* @param [const oai::smf_server::model::SmContextUpdateError] SmContextUpdateError
* @param [Pistache::Http::Code] code, response code
* @return void
*/
void send_pdu_session_update_sm_context_response(
Pistache::Http::ResponseWriter &httpResponse,
oai::smf_server::model::SmContextUpdateError &smContextUpdateError,
const oai::smf_server::model::SmContextUpdateError &smContextUpdateError,
Pistache::Http::Code code);
/*
* Send Update session response to AMF
* @param [Pistache::Http::ResponseWriter] httpResponse
* @param [ oai::smf_server::model::SmContextUpdatedData] smContextUpdatedData
* @param [const oai::smf_server::model::SmContextUpdatedData] smContextUpdatedData
* @param [Pistache::Http::Code] code, response code
* @return void
*/
void send_pdu_session_update_sm_context_response(
Pistache::Http::ResponseWriter &httpResponse,
oai::smf_server::model::SmContextUpdatedData &smContextUpdatedData,
const oai::smf_server::model::SmContextUpdatedData &smContextUpdatedData,
Pistache::Http::Code code);
/*
* Send create session response to AMF
* @param [Pistache::Http::ResponseWriter] httpResponse
* @param [ oai::smf_server::model::SmContextCreateError] smContextCreateError
* @param [const oai::smf_server::model::SmContextCreateError] smContextCreateError
* @param [Pistache::Http::Code] code, response code
* @return void
*/
void send_pdu_session_create_sm_context_response(
Pistache::Http::ResponseWriter &httpResponse,
oai::smf_server::model::SmContextCreateError &smContextCreateError,
const oai::smf_server::model::SmContextCreateError &smContextCreateError,
Pistache::Http::Code code);
/*
* Send create session response to AMF
* @param [Pistache::Http::ResponseWriter] httpResponse
* @param [ oai::smf_server::model::SmContextCreateError] smContextCreateError
* @param [const oai::smf_server::model::SmContextCreateError] smContextCreateError
* @param [Pistache::Http::Code] code, response code
* @param [std::string] n1_sm_msg, N1 SM message content
* @return void
*/
void send_pdu_session_create_sm_context_response(
Pistache::Http::ResponseWriter &httpResponse,
oai::smf_server::model::SmContextCreateError &smContextCreateError,
const oai::smf_server::model::SmContextCreateError &smContextCreateError,
Pistache::Http::Code code, std::string &n1_sm_msg);
/*
* Send update session response to AMF
* @param [Pistache::Http::ResponseWriter] httpResponse
* @param [ oai::smf_server::model::SmContextUpdateError] smContextUpdateError
* @param [const oai::smf_server::model::SmContextUpdateError] smContextUpdateError
* @param [Pistache::Http::Code] code, response code
* @param [std::string] n1_sm_msg, N1 SM message content
* @return void
*/
void send_pdu_session_update_sm_context_response(
Pistache::Http::ResponseWriter &httpResponse,
oai::smf_server::model::SmContextUpdateError &smContextUpdateError,
const oai::smf_server::model::SmContextUpdateError &smContextUpdateError,
Pistache::Http::Code code, std::string &n1_sm_msg);
/*
* Send create session response to AMF
* @param [Pistache::Http::ResponseWriter] httpResponse
* @param [ oai::smf_server::model::SmContextCreatedData] smContextCreatedData
* @param [const oai::smf_server::model::SmContextCreatedData] smContextCreatedData
* @param [Pistache::Http::Code] code, response code
* @return void
*/
void send_pdu_session_create_sm_context_response(
Pistache::Http::ResponseWriter &httpResponse,
oai::smf_server::model::SmContextCreatedData &smContextCreatedData,
const oai::smf_server::model::SmContextCreatedData &smContextCreatedData,
Pistache::Http::Code code);
/*
......@@ -169,13 +177,13 @@ class smf_n11 {
/*
* Send release session response to AMF
* @param [Pistache::Http::ResponseWriter] httpResponse
* @param [oai::smf_server::model::ProblemDetails] problem
* @param [const oai::smf_server::model::ProblemDetails] problem
* @param [Pistache::Http::Code] code, response code
* @return void
*/
void send_pdu_session_release_sm_context_response(
Pistache::Http::ResponseWriter &httpResponse,
oai::smf_server::model::ProblemDetails &problem,
const oai::smf_server::model::ProblemDetails &problem,
Pistache::Http::Code code);
/*
......@@ -188,10 +196,10 @@ class smf_n11 {
* @return void
*/
void create_multipart_related_content(std::string &body,
std::string &json_part,
std::string &boundary,
std::string &n1_message,
std::string &n2_message);
const std::string &json_part,
const std::string boundary,
const std::string &n1_message,
const std::string &n2_message);
/*
* Create HTTP body content for multipart/related message
......@@ -203,8 +211,8 @@ class smf_n11 {
* @return void
*/
void create_multipart_related_content(
std::string &body, std::string &json_part, std::string &boundary,
std::string &message, multipart_related_content_part_e content_type);
std::string &body, const std::string &json_part, const std::string boundary,
const std::string &message, const multipart_related_content_part_e content_type);
};
......
......@@ -1554,7 +1554,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
//------------------------------------------------------------------------------
int smf_n1_n2::decode_n1_sm_container(nas_message_t &nas_msg,
std::string &n1_sm_msg) {
const std::string &n1_sm_msg) {
Logger::smf_app().info("Decode NAS message from N1 SM Container.");
//step 1. Decode NAS message (for instance, ... only served as an example)
......@@ -1592,7 +1592,7 @@ int smf_n1_n2::decode_n1_sm_container(nas_message_t &nas_msg,
//---------------------------------------------------------------------------------------------
int smf_n1_n2::decode_n2_sm_information(
std::shared_ptr<Ngap_PDUSessionResourceSetupResponseTransfer_t> &ngap_IE,
std::string &n2_sm_info) {
const std::string &n2_sm_info) {
Logger::smf_app().info(
"Decode NGAP message (PDUSessionResourceSetupResponseTransfer) from N2 SM Information");
unsigned int data_len = n2_sm_info.length();
......@@ -1627,7 +1627,7 @@ int smf_n1_n2::decode_n2_sm_information(
//---------------------------------------------------------------------------------------------
int smf_n1_n2::decode_n2_sm_information(
std::shared_ptr<Ngap_PDUSessionResourceModifyResponseTransfer_t> &ngap_IE,
std::string &n2_sm_info) {
const std::string &n2_sm_info) {
Logger::smf_app().info(
"Decode NGAP message (Ngap_PDUSessionResourceModifyResponseTransfer) from N2 SM Information");
......@@ -1657,7 +1657,7 @@ int smf_n1_n2::decode_n2_sm_information(
//---------------------------------------------------------------------------------------------
int smf_n1_n2::decode_n2_sm_information(
std::shared_ptr<Ngap_PDUSessionResourceReleaseResponseTransfer_t> &ngap_IE,
std::string &n2_sm_info) {
const std::string &n2_sm_info) {
Logger::smf_app().info(
"Decode NGAP message (Ngap_PDUSessionResourceReleaseResponseTransfer) from N2 SM Information");
......@@ -1689,7 +1689,7 @@ int smf_n1_n2::decode_n2_sm_information(
//---------------------------------------------------------------------------------------------
int smf_n1_n2::decode_n2_sm_information(
std::shared_ptr<Ngap_PDUSessionResourceSetupUnsuccessfulTransfer_t> &ngap_IE,
std::string &n2_sm_info) {
const std::string &n2_sm_info) {
Logger::smf_app().info(
"Decode NGAP message (Ngap_PDUSessionResourceSetupUnsuccessfulTransfer) from N2 SM Information");
......
......@@ -98,20 +98,20 @@ class smf_n1_n2 {
/*
* Decode N1 SM Container into the NAS mesasge (using NAS lib)
* @param [nas_message_t&] nas_msg Store NAS message after decoded
* @param [std::string&] n1_sm_msg N1 SM Container from AMF
* @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, std::string &n1_sm_msg);
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 [std::string&] n2_sm_info N2 SM Information
* @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,
std::string &n2_sm_info);
const std::string &n2_sm_info);
/*
* Decode N2 SM Information Ngap_PDUSessionResourceModifyResponseTransfer_t
......@@ -121,7 +121,7 @@ class smf_n1_n2 {
*/
int decode_n2_sm_information(
std::shared_ptr<Ngap_PDUSessionResourceModifyResponseTransfer_t> &ngap_IE,
std::string &n2_sm_info);
const std::string &n2_sm_info);
/*
* Decode N2 SM Information Ngap_PDUSessionResourceReleaseResponseTransfer_t
......@@ -131,7 +131,7 @@ class smf_n1_n2 {
*/
int decode_n2_sm_information(
std::shared_ptr<Ngap_PDUSessionResourceReleaseResponseTransfer_t> &ngap_IE,
std::string &n2_sm_info);
const std::string &n2_sm_info);
/*
* Decode N2 SM Information Ngap_PDUSessionResourceSetupUnsuccessfulTransfer
......@@ -141,7 +141,7 @@ class smf_n1_n2 {
*/
int decode_n2_sm_information(
std::shared_ptr<Ngap_PDUSessionResourceSetupUnsuccessfulTransfer_t> &ngap_IE,
std::string &n2_sm_info);
const std::string &n2_sm_info);
};
......
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