Commit 35a96ac9 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

prepare to use NGAP lib to decode N2 SM Information

parent b187b9c8
......@@ -11,7 +11,9 @@
*/
#include "IndividualSMContextApiImpl.h"
extern "C" {
#include "Ngap_NGAP-PDU.h"
}
namespace oai {
namespace smf_server {
namespace api {
......@@ -38,13 +40,35 @@ void IndividualSMContextApiImpl::update_sm_context(const std::string &smContextR
//Get the SmContextUpdateData from this message and process in smf_app
smf::pdu_session_update_sm_context_request sm_context_req_msg = {};
//TODO: initialize necessary values for sm context req from smContextUpdateData and smContextRef
//decode NGAP message and assign the necessary informations to pdu_session_update_sm_context_request
//and pass this message to SMF to handle this message
Ngap_NGAP_PDU_t decoded_ngap_msg = {};
std::string n2_sm_information = (smContextUpdateData.getN2SmInfo()).getContentId();
std::string n2_sm_msg_hex;
m_smf_app->convert_string_2_hex(n2_sm_information, n2_sm_msg_hex);
Logger::smf_api_server().debug("smContextMessage, n2 sm information %s",n2_sm_information.c_str());
//Step1. Decode N2 SM information into decoded ngap msg
int decoder_rc = m_smf_app->decode_ngap_message(decoded_ngap_msg, n2_sm_msg_hex);
if (decoder_rc != RETURNok) {
//TODO: error, should send reply to AMF with error code!!
}
//Step 2. TODO: initialize necessary values for sm context req from smContextUpdateData
//Step 3. Handle the itti_n11_update_sm_context_request message in smf_app
std::shared_ptr<itti_n11_update_sm_context_request> itti_msg = std::make_shared<itti_n11_update_sm_context_request>(TASK_SMF_N11, TASK_SMF_APP, response, smContextRef);
itti_msg->req = sm_context_req_msg;
itti_msg->scid = smContextRef;
m_smf_app->handle_amf_msg(itti_msg);
}
}
......
......@@ -155,8 +155,7 @@ void SMContextsCollectionApiImpl::post_sm_contexts(const SmContextMessage &smCon
//SM PDU DN request container (Optional)
//Extended protocol configuration options (Optional) e.g, FOR DHCP
//Step 3. Handle the pdu_session_create_sm_context_request message in pwg_app
//m_smf_app->handle_amf_msg(sm_context_req_msg, response);
//Step 3. Handle the pdu_session_create_sm_context_request message in smf_app
//itti_n11_create_sm_context_request *itti_msg = new itti_n11_create_sm_context_request(TASK_SMF_N11, TASK_SMF_APP, response);
//itti_msg->req = sm_context_req_msg;
......
......@@ -473,7 +473,7 @@ void smf_app::handle_amf_msg (std::shared_ptr<itti_n11_update_sm_context_request
oai::smf_server::model::RefToBinaryData binary_data;
std::string n1_container; //N1 SM container
//SM Context ID, N2 SM information, Request Type
//Step 0. get supi, dnn, pdu_session id from sm_context
//SM Context ID - uint32_t in our case
scid_t scid;
try {
......@@ -485,13 +485,18 @@ void smf_app::handle_amf_msg (std::shared_ptr<itti_n11_update_sm_context_request
}*/
catch (const std::exception& err) {
//TODO: reject with invalid context
//TODO: send reject with invalid context
}
//Step 1. get necessary information (N2 SM information)
supi_t supi = smreq->req.get_supi();
auto sm_context = scid_2_smf_context(scid);
supi_t supi = std::get<0>(sm_context);
std::string dnn = std::get<1>(sm_context);
pdu_session_id_t pdu_session_id = std::get<2>(sm_context);
supi64_t supi64 = smf_supi_to_u64(supi);
//Step 1. get necessary information (N2 SM information)
//Step 2. find the smf context
std::shared_ptr<smf_context> sc;
......@@ -3033,7 +3038,18 @@ int smf_app::decode_nas_message_n1_sm_container(nas_message_t& nas_msg, std::str
return decoder_rc;
}
//---------------------------------------------------------------------------------------------
int smf_app::decode_ngap_message(Ngap_NGAP_PDU_t& ngap_msg, std::string& n2_sm_info){
//TODO: should work with BUPT to finish this function
Logger::smf_app().info("Decode NGAP message from N2 SM Information\n");
//step 1. Decode NGAP message (for instance, ... only served as an example)
int decoder_rc = RETURNok;
return decoder_rc;
}
//---------------------------------------------------------------------------------------------
void smf_app::convert_string_2_hex(std::string& input_str, std::string& output_str){
unsigned char *data = (unsigned char *) malloc (input_str.length() + 1);
......
......@@ -44,6 +44,7 @@
extern "C"{
#include "nas_message.h"
#include "mmData.h"
#include "Ngap_NGAP-PDU.h"
}
#include <map>
......@@ -238,6 +239,14 @@ public:
*/
void convert_string_2_hex(std::string& input_str, std::string& output_str);
/*
* Decode N2 SM Information (using NGAP lib)
* @param [Ngap_NGAP_PDU_t&] ngap_msg Store decoded NGAP message
* @param [std::string&] n2_sm_info N2 SM Information from AMF
* @return status of the decode process
*/
int decode_ngap_message(Ngap_NGAP_PDU_t& ngap_msg, std::string& n2_sm_info);
};
}
#include "smf_config.hpp"
......
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