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

create multipart message (N1N2MessageTranfer) to convey Json/N1/N2 content;...

create multipart message (N1N2MessageTranfer) to convey Json/N1/N2 content; add new function to create N2 SM info
parent 028e90e8
This diff is collapsed.
...@@ -20,8 +20,10 @@ ...@@ -20,8 +20,10 @@
*/ */
/*! \file smf_app.hpp /*! \file smf_app.hpp
\brief
\author Lionel GAUTHIER, Tien-Thinh NGUYEN \author Lionel GAUTHIER, Tien-Thinh NGUYEN
\date 2018 \company Eurecom
\date 2019
\email: lionel.gauthier@eurecom.fr, tien-thinh.nguyen@eurecom.fr \email: lionel.gauthier@eurecom.fr, tien-thinh.nguyen@eurecom.fr
*/ */
......
...@@ -21,10 +21,11 @@ ...@@ -21,10 +21,11 @@
/*! \file smf_config.cpp /*! \file smf_config.cpp
\brief \brief
\author Lionel Gauthier \author Lionel GAUTHIER, Tien-Thinh NGUYEN
\company Eurecom \company Eurecom
\email: lionel.gauthier@eurecom.fr \date 2019
*/ \email: lionel.gauthier@eurecom.fr, tien-thinh.nguyen@eurecom.fr
*/
#include "3gpp_29.274.hpp" #include "3gpp_29.274.hpp"
#include "common_defs.h" #include "common_defs.h"
...@@ -641,9 +642,11 @@ bool smf_config::is_dotted_dnn_handled(const std::string& dnn, const pdu_session ...@@ -641,9 +642,11 @@ bool smf_config::is_dotted_dnn_handled(const std::string& dnn, const pdu_session
{ {
Logger::smf_app().debug( "requested dnn: %s", dnn.c_str()); Logger::smf_app().debug( "requested dnn: %s", dnn.c_str());
for (int i = 0; i < smf_cfg.num_apn; i++) { for (int i = 0; i < smf_cfg.num_apn; i++) {
Logger::smf_app().debug( "apn_label: %s", smf_cfg.apn[i].apn_label.c_str()); Logger::smf_app().debug( "apn_label: %s, apn: %s", smf_cfg.apn[i].apn_label.c_str(),smf_cfg.apn[i].apn.c_str() );
//if (0 == dnn.compare(smf_cfg.apn[i].apn_label)) { //if (0 == dnn.compare(smf_cfg.apn[i].apn_label)) {
if (0 == dnn.compare(smf_cfg.apn[i].apn)) { if (0 == dnn.compare(smf_cfg.apn[i].apn)) {
Logger::smf_app().debug( "DNN matched! \n");
Logger::smf_app().debug( "pdu session type %d, pdn_type %d \n", pdn_session_type.pdu_session_type, smf_cfg.apn[i].pdn_type.pdn_type);
if (pdn_session_type.pdu_session_type == smf_cfg.apn[i].pdn_type.pdn_type) { if (pdn_session_type.pdu_session_type == smf_cfg.apn[i].pdn_type.pdn_type) {
return true; return true;
} }
......
...@@ -21,9 +21,10 @@ ...@@ -21,9 +21,10 @@
/*! \file smf_config.hpp /*! \file smf_config.hpp
* \brief * \brief
* \author Lionel Gauthier \author Lionel GAUTHIER, Tien-Thinh NGUYEN
* \company Eurecom \company Eurecom
* \email: lionel.gauthier@eurecom.fr \date 2019
\email: lionel.gauthier@eurecom.fr, tien-thinh.nguyen@eurecom.fr
*/ */
#ifndef FILE_SMF_CONFIG_HPP_SEEN #ifndef FILE_SMF_CONFIG_HPP_SEEN
...@@ -258,12 +259,12 @@ public: ...@@ -258,12 +259,12 @@ public:
n4.port = pfcp::default_port; n4.port = pfcp::default_port;
n11.thread_rd_sched_params.sched_priority = 90; n11.thread_rd_sched_params.sched_priority = 90;
n11.port = 8080; n11.port = 80;
amf_addr.ipv4_addr.s_addr = INADDR_ANY; amf_addr.ipv4_addr.s_addr = INADDR_ANY;
amf_addr.port = 8080; amf_addr.port = 80;
amf_addr.ipv4_addr.s_addr = INADDR_ANY; amf_addr.ipv4_addr.s_addr = INADDR_ANY;
udm_addr.port = 8080; udm_addr.port = 80;
}; };
~smf_config(); ~smf_config();
......
...@@ -21,9 +21,10 @@ ...@@ -21,9 +21,10 @@
/*! \file smf_context.cpp /*! \file smf_context.cpp
\brief \brief
\author Lionel Gauthier \author Lionel GAUTHIER, Tien-Thinh NGUYEN
\company Eurecom \company Eurecom
\email: lionel.gauthier@eurecom.fr \date 2019
\email: lionel.gauthier@eurecom.fr, tien-thinh.nguyen@eurecom.fr
*/ */
#include "itti.hpp" #include "itti.hpp"
...@@ -272,46 +273,7 @@ void smf_context::handle_itti_msg (itti_n4_session_deletion_response& sdresp) ...@@ -272,46 +273,7 @@ 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) 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<smf_pdu_session> ppc = {};
ebi_t ebi;
if (find_pdu_session(pdr_id, ppc, ebi)) {
downlink_data_report_procedure* p = new downlink_data_report_procedure(req);
std::shared_ptr<smf_procedure> sproc = std::shared_ptr<smf_procedure>(p);
insert_procedure(sproc);
if (p->run(shared_from_this(), ppc, ebi)) {
// TODO handle error code
Logger::smf_app().info( "S5S8 DOWNLINK_DATA_REPORT procedure failed");
remove_procedure(p);
} else {
}
}
}
}
}
// 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");
}
}
*/
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -364,7 +326,7 @@ void smf_context::handle_amf_msg (std::shared_ptr<itti_n11_create_sm_context_req ...@@ -364,7 +326,7 @@ void smf_context::handle_amf_msg (std::shared_ptr<itti_n11_create_sm_context_req
//Step 1. get necessary information //Step 1. get necessary information
std::string dnn = sm_context_req_msg.get_dnn(); std::string dnn = sm_context_req_msg.get_dnn();
snssai_t snssai = sm_context_req_msg.get_snssai(); snssai_t snssai = sm_context_req_msg.get_snssai();
request_type_t request_type = sm_context_req_msg.get_request_type(); std::string request_type = sm_context_req_msg.get_request_type();
supi_t supi = sm_context_req_msg.get_supi(); supi_t supi = sm_context_req_msg.get_supi();
supi64_t supi64 = smf_supi_to_u64(supi); supi64_t supi64 = smf_supi_to_u64(supi);
uint32_t pdu_session_id = sm_context_req_msg.get_pdu_session_id(); uint32_t pdu_session_id = sm_context_req_msg.get_pdu_session_id();
...@@ -386,6 +348,7 @@ void smf_context::handle_amf_msg (std::shared_ptr<itti_n11_create_sm_context_req ...@@ -386,6 +348,7 @@ void smf_context::handle_amf_msg (std::shared_ptr<itti_n11_create_sm_context_req
itti_n11_create_sm_context_response *sm_context_resp = new itti_n11_create_sm_context_response(TASK_SMF_APP, TASK_SMF_N11, smreq->http_response); itti_n11_create_sm_context_response *sm_context_resp = new itti_n11_create_sm_context_response(TASK_SMF_APP, TASK_SMF_N11, smreq->http_response);
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); 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->res.set_supi(supi); sm_context_resp->res.set_supi(supi);
sm_context_resp->res.set_supi_prefix(sm_context_req_msg.get_supi_prefix());
sm_context_resp->res.set_cause(REQUEST_ACCEPTED); sm_context_resp->res.set_cause(REQUEST_ACCEPTED);
sm_context_resp->res.set_pdu_session_id(pdu_session_id); sm_context_resp->res.set_pdu_session_id(pdu_session_id);
sm_context_resp->res.set_snssai(snssai); sm_context_resp->res.set_snssai(snssai);
...@@ -543,15 +506,16 @@ void smf_context::handle_amf_msg (std::shared_ptr<itti_n11_create_sm_context_req ...@@ -543,15 +506,16 @@ void smf_context::handle_amf_msg (std::shared_ptr<itti_n11_create_sm_context_req
to_json(jsonData, smContextCreatedData); to_json(jsonData, smContextCreatedData);
std::string resBody = jsonData.dump(); std::string resBody = jsonData.dump();
std::string smContextRef = sm_context_req_msg.get_supi_prefix() + "-" + smf_supi_to_string(sm_context_req_msg.get_supi());
//headers: Location: //headers: Location:
//Contains the URI of the newly created resource, according to the structure: {apiRoot}/nsmf-pdusession/{apiVersion}/sm-contexts/{smContextRef} //Contains the URI of the newly created resource, according to the structure: {apiRoot}/nsmf-pdusession/{apiVersion}/sm-contexts/{smContextRef}
std::string uri = sm_context_req_msg.get_api_root() + std::to_string(smreq->scid); //smContextRef //std::string uri = sm_context_req_msg.get_api_root() + "/" + std::to_string(smreq->scid); //smContextRef
std::string uri = sm_context_req_msg.get_api_root() + "/" + smContextRef.c_str(); //smContextRef
sm_context_resp->http_response.headers().add<Pistache::Http::Header::Location>(uri); sm_context_resp->http_response.headers().add<Pistache::Http::Header::Location>(uri);
sm_context_resp->http_response.send(Pistache::Http::Code::Created, resBody); sm_context_resp->http_response.send(Pistache::Http::Code::Created, resBody);
Logger::smf_app().info( "Create a procedure to process this message!");
session_create_sm_context_procedure* proc = new session_create_sm_context_procedure(sp); session_create_sm_context_procedure* proc = new session_create_sm_context_procedure(sp);
std::shared_ptr<smf_procedure> sproc = std::shared_ptr<smf_procedure>(proc); std::shared_ptr<smf_procedure> sproc = std::shared_ptr<smf_procedure>(proc);
...@@ -560,6 +524,8 @@ void smf_context::handle_amf_msg (std::shared_ptr<itti_n11_create_sm_context_req ...@@ -560,6 +524,8 @@ void smf_context::handle_amf_msg (std::shared_ptr<itti_n11_create_sm_context_req
// error ! // error !
Logger::smf_app().info( "PDU SESSION CREATE SM CONTEXT REQUEST procedure failed"); Logger::smf_app().info( "PDU SESSION CREATE SM CONTEXT REQUEST procedure failed");
remove_procedure(proc); remove_procedure(proc);
//TODO: [Verify] To send PDU Session Establishment Reject to AMF
} }
}else{ //if request is rejected }else{ //if request is rejected
......
...@@ -21,9 +21,10 @@ ...@@ -21,9 +21,10 @@
/*! \file smf_context.hpp /*! \file smf_context.hpp
\brief \brief
\author Lionel Gauthier \author Lionel GAUTHIER, Tien-Thinh NGUYEN
\company Eurecom \company Eurecom
\email: lionel.gauthier@eurecom.fr \date 2019
\email: lionel.gauthier@eurecom.fr, tien-thinh.nguyen@eurecom.fr
*/ */
#ifndef FILE_SMF_CONTEXT_HPP_SEEN #ifndef FILE_SMF_CONTEXT_HPP_SEEN
#define FILE_SMF_CONTEXT_HPP_SEEN #define FILE_SMF_CONTEXT_HPP_SEEN
......
...@@ -19,11 +19,12 @@ ...@@ -19,11 +19,12 @@
* contact@openairinterface.org * contact@openairinterface.org
*/ */
/*! \file smf_msg.hpp /*! \file smf_msg.cpp
\brief \brief
\author \author Tien-Thinh NGUYEN
\company Eurecom \company Eurecom
\email: \date 2019
\email: tien-thinh.nguyen@eurecom.fr
*/ */
#include "smf_msg.hpp" #include "smf_msg.hpp"
...@@ -55,6 +56,20 @@ void pdu_session_msg::set_supi(supi_t const& supi) ...@@ -55,6 +56,20 @@ void pdu_session_msg::set_supi(supi_t const& supi)
m_supi = supi; m_supi = supi;
} }
//-----------------------------------------------------------------------------
std::string pdu_session_msg::get_supi_prefix() const
{
return m_supi_prefix;
}
//-----------------------------------------------------------------------------
void pdu_session_msg::set_supi_prefix(std::string const& prefix)
{
m_supi_prefix = prefix;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
pdu_session_id_t pdu_session_msg::get_pdu_session_id() const pdu_session_id_t pdu_session_msg::get_pdu_session_id() const
{ {
...@@ -115,13 +130,13 @@ void pdu_session_create_sm_context_request::set_serving_nf_id(std::string const& ...@@ -115,13 +130,13 @@ void pdu_session_create_sm_context_request::set_serving_nf_id(std::string const&
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
request_type_t pdu_session_create_sm_context_request::get_request_type() const std::string pdu_session_create_sm_context_request::get_request_type() const
{ {
return m_request_type; return m_request_type;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void pdu_session_create_sm_context_request::set_request_type(request_type_t const& request_type) void pdu_session_create_sm_context_request::set_request_type(std::string const& request_type)
{ {
m_request_type = request_type; m_request_type = request_type;
} }
......
...@@ -21,9 +21,10 @@ ...@@ -21,9 +21,10 @@
/*! \file smf_msg.hpp /*! \file smf_msg.hpp
\brief \brief
\author \author Tien-Thinh NGUYEN
\company Eurecom \company Eurecom
\email: \date 2019
\email: tien-thinh.nguyen@eurecom.fr
*/ */
#ifndef FILE_SMF_MSG_HPP_SEEN #ifndef FILE_SMF_MSG_HPP_SEEN
#define FILE_SMF_MSG_HPP_SEEN #define FILE_SMF_MSG_HPP_SEEN
...@@ -60,6 +61,9 @@ public: ...@@ -60,6 +61,9 @@ public:
supi_t get_supi() const; supi_t get_supi() const;
void set_supi(supi_t const& value); void set_supi(supi_t const& value);
std::string get_supi_prefix() const;
void set_supi_prefix(std::string const& value);
pdu_session_id_t get_pdu_session_id() const; 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(pdu_session_id_t const value);
...@@ -75,6 +79,7 @@ public: ...@@ -75,6 +79,7 @@ public:
private: private:
std::string m_api_root; std::string m_api_root;
supi_t m_supi; supi_t m_supi;
std::string m_supi_prefix;
pdu_session_id_t m_pdu_session_id; pdu_session_id_t m_pdu_session_id;
std::string m_dnn; std::string m_dnn;
snssai_t m_snssai; snssai_t m_snssai;
...@@ -221,8 +226,8 @@ public: ...@@ -221,8 +226,8 @@ public:
std::string get_serving_nf_id() const; std::string get_serving_nf_id() const;
void set_serving_nf_id(std::string const& value); void set_serving_nf_id(std::string const& value);
request_type_t get_request_type() const; std::string get_request_type() const;
void set_request_type(request_type_t const& value); void set_request_type(std::string const& value);
void set_dnn_selection_mode(std::string const& value); void set_dnn_selection_mode(std::string const& value);
std::string get_dnn_selection_mode() const; std::string get_dnn_selection_mode() const;
...@@ -252,7 +257,7 @@ private: ...@@ -252,7 +257,7 @@ private:
//Guami m_Guami; //Guami m_Guami;
//std::string m_ServiceName; //std::string m_ServiceName;
//PlmnId m_ServingNetwork; //PlmnId m_ServingNetwork;
request_type_t m_request_type; std::string m_request_type;
//RefToBinaryData m_N1SmMsg; //RefToBinaryData m_N1SmMsg;
std::string m_an_type; std::string m_an_type;
//std::string m_SecondAnType; //std::string m_SecondAnType;
......
...@@ -21,9 +21,10 @@ ...@@ -21,9 +21,10 @@
/*! \file smf_n10.cpp /*! \file smf_n10.cpp
\brief \brief
\author \author Tien-Thinh NGUYEN
\company Eurecom \company Eurecom
\email: \date 2019
\email: tien-thinh.nguyen@eurecom.fr
*/ */
#include "smf.h" #include "smf.h"
......
...@@ -20,9 +20,10 @@ ...@@ -20,9 +20,10 @@
*/ */
/*! \file smf_n10.hpp /*! \file smf_n10.hpp
\author \author Tien-Thinh NGUYEN
\date 2019 \company Eurecom
\email: \date 2019
\email: tien-thinh.nguyen@eurecom.fr
*/ */
#ifndef FILE_SMF_N10_HPP_SEEN #ifndef FILE_SMF_N10_HPP_SEEN
......
...@@ -21,9 +21,10 @@ ...@@ -21,9 +21,10 @@
/*! \file smf_n11.cpp /*! \file smf_n11.cpp
\brief \brief
\author \author Lionel GAUTHIER, Tien-Thinh NGUYEN
\company Eurecom \company Eurecom
\email: \date 2019
\email: lionel.gauthier@eurecom.fr, tien-thinh.nguyen@eurecom.fr
*/ */
#include "smf.h" #include "smf.h"
...@@ -112,101 +113,148 @@ smf_n11::smf_n11 () ...@@ -112,101 +113,148 @@ smf_n11::smf_n11 ()
Logger::smf_n11().startup( "Started" ); Logger::smf_n11().startup( "Started" );
} }
//------------------------------------------------------------------------------
void smf_n11::send_msg_to_amf(std::shared_ptr<itti_n11_create_sm_context_response> sm_context_res) void smf_n11::send_msg_to_amf(std::shared_ptr<itti_n11_create_sm_context_response> sm_context_res)
{ {
//Transfer N1/N2 message via AMF by using N_amf_Communication_N1N2MessageTransfer (see TS29518_Namf_Communication.yaml) //Transfer N1/N2 message via AMF by using N_amf_Communication_N1N2MessageTransfer (see TS29518_Namf_Communication.yaml)
//use curl to send data for the moment //use curl to send data for the moment
nlohmann::json jsonData; nlohmann::json message_transfer_req_data;
std::string n1_message; std::string n1_message;
curl_global_init(CURL_GLOBAL_DEFAULT); //Curl multipart
struct curl_slist *headers = NULL; CURL *curl = curl_easy_init();
headers = curl_slist_append(headers, "Accept: application/json");
headers = curl_slist_append(headers, "Content-Type: application/json");
headers = curl_slist_append(headers, "charsets: utf-8");
supi64_t supi64 = smf_supi_to_u64(sm_context_res->res.get_supi()); //get supi and put into URL
std::string supi_str;
supi_t supi = sm_context_res->res.get_supi();
supi_str = sm_context_res->res.get_supi_prefix() + "-" + smf_supi_to_string (supi);
CURL *curl = curl_easy_init(); std::string url = std::string(inet_ntoa (*((struct in_addr *)&smf_cfg.amf_addr.ipv4_addr))) + ":" + std::to_string(smf_cfg.amf_addr.port) + "/namf-comm/v1/ue-contexts/" + supi_str.c_str() +"/n1-n2-messages";
//hardcoded for the moment, should get from NRF/configuration file Logger::smf_n11().debug("[SMF N11: N1N2MessageTransfer] Sending Communication_N1N2MessageTransfer to AMF, AMF's URL: %s", url.c_str());
std::string url = std::string(inet_ntoa (*((struct in_addr *)&smf_cfg.amf_addr.ipv4_addr))) + ":" + std::to_string(smf_cfg.amf_addr.port) + "/namf-comm/v1/ue-contexts/" + std::to_string(supi64) +"/n1-n2-messages";
Logger::smf_n11().debug("[Send Communication_N1N2MessageTransfer to AMF] AMF's URL: %s ", url.c_str()); std::string ngap_msg_str;
//N1 SM container //N1 SM container & N2 SM Information
if (sm_context_res->res.get_cause() != REQUEST_ACCEPTED) { //PDU Session Establishment Reject //TODO: should uncomment these lines when including UPF in the test
Logger::smf_n11().debug("[Send Communication_N1N2MessageTransfer to AMF] PDU Session Establishment Reject\n"); // if (sm_context_res->res.get_cause() != REQUEST_ACCEPTED) { //PDU Session Establishment Reject
smf_app_inst->create_n1_sm_container(sm_context_res, PDU_SESSION_ESTABLISHMENT_REJECT, n1_message); //need cause? // Logger::smf_n11().debug("[SMF N11: N1N2MessageTransfer] PDU Session Establishment Reject\n");
} else { //PDU Session Establishment Accept // smf_app_inst->create_n1_sm_container(sm_context_res, PDU_SESSION_ESTABLISHMENT_REJECT, n1_message); //need cause?
Logger::smf_n11().debug("[Send Communication_N1N2MessageTransfer to AMF] PDU Session Establishment Accept \n"); // } else { //PDU Session Establishment Accept
Logger::smf_n11().debug("[SMF N11: N1N2MessageTransfer] PDU Session Establishment Accept \n");
smf_app_inst->create_n1_sm_container(sm_context_res, PDU_SESSION_ESTABLISHMENT_ACCEPT, n1_message); //need cause? smf_app_inst->create_n1_sm_container(sm_context_res, PDU_SESSION_ESTABLISHMENT_ACCEPT, n1_message); //need cause?
}
//TODO: N2 SM Information (Step 11, section 4.3.2.2.1 @ 3GPP TS 23.502)
smf_app_inst->create_n2_sm_information(sm_context_res, 1, 1, ngap_msg_str);
// }
//fill the content
std::string n1_msg_hex; std::string n1_msg_hex;
smf_app_inst->convert_string_2_hex(n1_message, n1_msg_hex); smf_app_inst->convert_string_2_hex(n1_message, n1_msg_hex);
Logger::smf_n11().debug("[SMF N11: N1N2MessageTransfer] n1MessageContent: %s\n ", n1_msg_hex.c_str());
jsonData["n1MessageContainer"]["n1MessageClass"] = "SM"; std::string n2_msg_hex;
jsonData["n1MessageContainer"]["n1MessageContent"]["contentId"] = n1_msg_hex; smf_app_inst->convert_string_2_hex(ngap_msg_str, n2_msg_hex);
Logger::smf_n11().debug("n1MessageContent: %s\n ", n1_msg_hex.c_str()); Logger::smf_n11().debug("[SMF N11: N1N2MessageTransfer] n2SMInformation %s\n ", n2_msg_hex.c_str());
//TODO: fill the content of N1N2MessageTransferReqData
//jsonData["n2InfoContainer"]["n2InformationClass"] = "SM";
//jsonData["n2InfoContainer"]["smInfo"]["PduSessionId"] = 123;
//jsonData["n2InfoContainer"]["smInfo"]["n2InfoContent"]["ngapMessageType"] = 123; //NGAP message
//jsonData["n2InfoContainer"]["smInfo"]["n2InfoContent"]["ngapIeType"] = "PDU_RES_SETUP_REQ"; //NGAP message
//jsonData["n2InfoContainer"]["smInfo"]["n2InfoContent"]["ngapData"]["contentId"] = "NGAP DATA"; //NGAP message
//jsonData["n2InfoContainer"]["ranInfo"] = "SM";
jsonData["ppi"] = 1;
jsonData["pduSessionId"] = sm_context_res->res.get_pdu_session_id();
//jsonData["arp"]["priorityLevel"] = 1;
//jsonData["arp"]["preemptCap"] = "NOT_PREEMPT";
//jsonData["arp"]["preemptVuln"] = "NOT_PREEMPTABLE";
std::string body = jsonData.dump();
message_transfer_req_data["n1MessageContainer"]["n1MessageClass"] = "SM";
message_transfer_req_data["n1MessageContainer"]["n1MessageContent"]["contentId"] = "n1SmMsg"; //part 2
//TODO: fill the content of N1N2MessageTransferReqData
message_transfer_req_data["n2InfoContainer"]["n2InformationClass"] = "SM";
message_transfer_req_data["n2InfoContainer"]["smInfo"]["PduSessionId"] = 1;
//N2InfoContent (section 6.1.6.2.27@3GPP TS 29.518)
//message_transfer_req_data["n2InfoContainer"]["smInfo"]["n2InfoContent"]["ngapMessageType"] = 123; //NGAP message -to be verified: doesn't exist in tester
message_transfer_req_data["n2InfoContainer"]["smInfo"]["n2InfoContent"]["ngapIeType"] = "PDU_RES_SETUP_REQ"; //NGAP message
message_transfer_req_data["n2InfoContainer"]["smInfo"]["n2InfoContent"]["ngapData"]["contentId"] = "n2SmMsg"; //part 3
//message_transfer_req_data["n2InfoContainer"]["smInfo"]["nasPdu"] = ;
//message_transfer_req_data["n2InfoContainer"]["smInfo"]["sNssai"] = ;
message_transfer_req_data["n2InfoContainer"]["ranInfo"] = "SM";
message_transfer_req_data["ppi"] = 1;
message_transfer_req_data["pduSessionId"] = sm_context_res->res.get_pdu_session_id();
//message_transfer_req_data["arp"]["priorityLevel"] = 1;
//message_transfer_req_data["arp"]["preemptCap"] = "NOT_PREEMPT";
//message_transfer_req_data["arp"]["preemptVuln"] = "NOT_PREEMPTABLE";
std::string json_part = message_transfer_req_data.dump();
Logger::smf_n11().debug("[SMF N11: N1N2MessageTransfer] Sending message to AMF....\n ");
if(curl) { if(curl) {
CURLcode res;
CURLcode res;
struct curl_slist *headers = NULL;
struct curl_slist *slist = NULL;
curl_mime *mime;
curl_mime *alt;
curl_mimepart *part;
headers = curl_slist_append(headers, "charsets: utf-8");
headers = curl_slist_append(headers, "content-type: multipart/related");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_URL, url.c_str() ); curl_easy_setopt(curl, CURLOPT_URL, url.c_str() );
curl_easy_setopt(curl, CURLOPT_HTTPGET,1); curl_easy_setopt(curl, CURLOPT_HTTPGET,1);
curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, AMF_CURL_TIMEOUT_MS); curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, AMF_CURL_TIMEOUT_MS);
mime = curl_mime_init(curl);
alt = curl_mime_init(curl);
//part with N1N2MessageTransferReqData (JsonData)
part = curl_mime_addpart(mime);
curl_mime_data(part, json_part.c_str(), CURL_ZERO_TERMINATED);
curl_mime_type(part, "application/json");
//N1 SM Container
part = curl_mime_addpart(mime);
curl_mime_data(part, n1_msg_hex.c_str(), CURL_ZERO_TERMINATED);
curl_mime_type(part, "application/vnd.3gpp.5gnas");
curl_mime_name (part, "n1SmMsg");
//N2 SM Information
part = curl_mime_addpart(mime);
curl_mime_data(part, n2_msg_hex.c_str(), CURL_ZERO_TERMINATED);
curl_mime_type(part, "application/vnd.3gpp.ngap");
curl_mime_name (part, "n2SmMsg");
curl_easy_setopt(curl, CURLOPT_MIMEPOST, mime);
res = curl_easy_perform(curl);
// Response information. // Response information.
long httpCode(0); long httpCode(0);
std::unique_ptr<std::string> httpData(new std::string());
std::unique_ptr<std::string> httpData(new std::string());
/*
// Hook up data handling function. // Hook up data handling function.
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &callback); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &callback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, httpData.get()); curl_easy_setopt(curl, CURLOPT_WRITEDATA, httpData.get());
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body.c_str()); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body.c_str());
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)body.length()); curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)body.length());
*/
int numRetries = 0; int numRetries = 0;
while (numRetries < AMF_NUMBER_RETRIES){ while (numRetries < AMF_NUMBER_RETRIES){
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode); curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode);
Logger::smf_n11().debug("[send_msg_to_amf] Response from AMF, Http Code: %d ", httpCode); Logger::smf_n11().debug("[SMF N11: N1N2MessageTransfer] Response from AMF, Http Code: %d ", httpCode);
if (httpCode == HTTP_STATUS_OK) if (httpCode == HTTP_STATUS_OK)
{ {
Logger::smf_n11().debug("[send_msg_to_amf] Got successful response from AMF, URL: %s ", url.c_str()); Logger::smf_n11().debug("[SMF N11: N1N2MessageTransfer] Got successful response from AMF, URL: %s ", url.c_str());
break; break;
} }
else else
{ {
Logger::smf_n10().warn("[send_msg_to_amf] Couldn't GET response from AMF, URL %s, retry ...", url.c_str()); Logger::smf_n10().warn("[SMF N11: N1N2MessageTransfer] Couldn't GET response from AMF, URL %s, retry ...", url.c_str());
//retry //retry
numRetries++; numRetries++;
} }
} }
curl_slist_free_all(headers);
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_mime_free(mime);
} }
//TODO: process the response if necessary //TODO: process the response if necessary
} }
......
...@@ -20,9 +20,10 @@ ...@@ -20,9 +20,10 @@
*/ */
/*! \file smf_n11.hpp /*! \file smf_n11.hpp
\author \author Lionel GAUTHIER, Tien-Thinh NGUYEN
\date 2019 \company Eurecom
\email: \date 2019
\email: lionel.gauthier@eurecom.fr, tien-thinh.nguyen@eurecom.fr
*/ */
#ifndef FILE_SMF_N11_HPP_SEEN #ifndef FILE_SMF_N11_HPP_SEEN
......
...@@ -21,9 +21,10 @@ ...@@ -21,9 +21,10 @@
/*! \file smf_n4.cpp /*! \file smf_n4.cpp
\brief \brief
\author Lionel Gauthier \author Lionel GAUTHIER, Tien-Thinh NGUYEN
\company Eurecom \company Eurecom
\email: lionel.gauthier@eurecom.fr \date 2019
\email: lionel.gauthier@eurecom.fr, tien-thinh.nguyen@eurecom.fr
*/ */
#include "common_defs.h" #include "common_defs.h"
......
...@@ -20,9 +20,10 @@ ...@@ -20,9 +20,10 @@
*/ */
/*! \file smf_n4.hpp /*! \file smf_n4.hpp
\author Lionel GAUTHIER \author Lionel GAUTHIER, Tien-Thinh NGUYEN
\date 2019 \company Eurecom
\email: lionel.gauthier@eurecom.fr \date 2019
\email: lionel.gauthier@eurecom.fr, tien-thinh.nguyen@eurecom.fr
*/ */
#ifndef FILE_SMF_N4_HPP_SEEN #ifndef FILE_SMF_N4_HPP_SEEN
......
...@@ -19,6 +19,14 @@ ...@@ -19,6 +19,14 @@
* contact@openairinterface.org * contact@openairinterface.org
*/ */
/*! \file smf_procedure.cpp
\author Lionel GAUTHIER, Tien-Thinh NGUYEN
\company Eurecom
\date 2019
\email: lionel.gauthier@eurecom.fr, tien-thinh.nguyen@eurecom.fr
*/
#include "3gpp_29.244.h" #include "3gpp_29.244.h"
#include "3gpp_29.274.h" #include "3gpp_29.274.h"
#include "common_defs.h" #include "common_defs.h"
...@@ -81,6 +89,7 @@ int sx_session_restore_procedure::run() ...@@ -81,6 +89,7 @@ int sx_session_restore_procedure::run()
int session_create_sm_context_procedure::run(std::shared_ptr<itti_n11_create_sm_context_request> sm_context_req, std::shared_ptr<itti_n11_create_sm_context_response> sm_context_resp, std::shared_ptr<smf::smf_context> pc) int session_create_sm_context_procedure::run(std::shared_ptr<itti_n11_create_sm_context_request> sm_context_req, std::shared_ptr<itti_n11_create_sm_context_response> sm_context_resp, std::shared_ptr<smf::smf_context> pc)
{ {
Logger::smf_app().info("[SMF Procedure] Create SM Context Request");
// TODO check if compatible with ongoing procedures if any // TODO check if compatible with ongoing procedures if any
pfcp::node_id_t up_node_id = {}; 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)) { if (not pfcp_associations::get_instance().select_up_node(up_node_id, NODE_SELECTION_CRITERIA_MIN_PFCP_SESSIONS)) {
......
...@@ -18,16 +18,17 @@ ...@@ -18,16 +18,17 @@
* For more information about the OpenAirInterface (OAI) Software Alliance: * For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org * contact@openairinterface.org
*/ */
#ifndef FILE_SMF_PROCEDURE_HPP_SEEN
#define FILE_SMF_PROCEDURE_HPP_SEEN
/*! \file smf_procedure.hpp /*! \file smf_procedure.hpp
\brief \author Lionel GAUTHIER, Tien-Thinh NGUYEN
\author Lionel Gauthier
\company Eurecom \company Eurecom
\email: lionel.gauthier@eurecom.fr \date 2019
\email: lionel.gauthier@eurecom.fr, tien-thinh.nguyen@eurecom.fr
*/ */
#ifndef FILE_SMF_PROCEDURE_HPP_SEEN
#define FILE_SMF_PROCEDURE_HPP_SEEN
#include "3gpp_29.244.hpp" #include "3gpp_29.244.hpp"
#include "3gpp_29.274.hpp" #include "3gpp_29.274.hpp"
#include "itti_msg_n11.hpp" #include "itti_msg_n11.hpp"
......
This diff is collapsed.
#ifndef MULTIPARTPARSER_H
#define MULTIPARTPARSER_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stddef.h>
#include <stdint.h>
#include <sys/types.h>
typedef struct multipartparser multipartparser;
typedef struct multipartparser_callbacks multipartparser_callbacks;
typedef int (*multipart_cb) (multipartparser*);
typedef int (*multipart_data_cb) (multipartparser*, const char* data, size_t size);
struct multipartparser {
/** PRIVATE **/
char boundary[70];
int boundary_length;
int index;
uint16_t state;
/** PUBLIC **/
void* data;
};
struct multipartparser_callbacks {
multipart_cb on_body_begin;
multipart_cb on_part_begin;
multipart_data_cb on_header_field;
multipart_data_cb on_header_value;
multipart_cb on_headers_complete;
multipart_data_cb on_data;
multipart_cb on_part_end;
multipart_cb on_body_end;
};
void multipartparser_init(multipartparser* parser, const char* boundary);
void multipartparser_callbacks_init(multipartparser_callbacks* callbacks);
size_t multipartparser_execute(multipartparser* parser,
multipartparser_callbacks* callbacks,
const char* data,
size_t size);
#ifdef __cplusplus
}
#endif
#endif // MULTIPARTPARSER_H
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