Commit 0162e7a8 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Merge branch 'fix_itti' into 'develop'

Fix itti

See merge request oai/cn5g/oai-cn5g-smf!67
parents 2a0dd9c8 2114e592
...@@ -516,7 +516,7 @@ void xgpp_conv::sm_context_request_from_nas( ...@@ -516,7 +516,7 @@ void xgpp_conv::sm_context_request_from_nas(
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void xgpp_conv::create_sm_context_response_from_ct_request( void xgpp_conv::create_sm_context_response_from_ctx_request(
const std::shared_ptr<itti_n11_create_sm_context_request>& ctx_request, const std::shared_ptr<itti_n11_create_sm_context_request>& ctx_request,
std::shared_ptr<itti_n11_create_sm_context_response>& ctx_response) { std::shared_ptr<itti_n11_create_sm_context_response>& ctx_response) {
ctx_response->http_version = ctx_request->http_version; ctx_response->http_version = ctx_request->http_version;
...@@ -535,7 +535,7 @@ void xgpp_conv::create_sm_context_response_from_ct_request( ...@@ -535,7 +535,7 @@ void xgpp_conv::create_sm_context_response_from_ct_request(
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void xgpp_conv::update_sm_context_response_from_ct_request( void xgpp_conv::update_sm_context_response_from_ctx_request(
const std::shared_ptr<itti_n11_update_sm_context_request>& ct_request, const std::shared_ptr<itti_n11_update_sm_context_request>& ct_request,
std::shared_ptr<itti_n11_update_sm_context_response>& ct_response) { std::shared_ptr<itti_n11_update_sm_context_response>& ct_response) {
ct_response->res.set_http_code( ct_response->res.set_http_code(
......
...@@ -161,11 +161,11 @@ void smf_event_exposure_notification_from_openapi( ...@@ -161,11 +161,11 @@ void smf_event_exposure_notification_from_openapi(
void sm_context_request_from_nas( void sm_context_request_from_nas(
const nas_message_t& nm, smf::pdu_session_create_sm_context_request& pcr); const nas_message_t& nm, smf::pdu_session_create_sm_context_request& pcr);
void create_sm_context_response_from_ct_request( void create_sm_context_response_from_ctx_request(
const std::shared_ptr<itti_n11_create_sm_context_request>& ct_request, const std::shared_ptr<itti_n11_create_sm_context_request>& ct_request,
std::shared_ptr<itti_n11_create_sm_context_response>& ct_response); std::shared_ptr<itti_n11_create_sm_context_response>& ct_response);
void update_sm_context_response_from_ct_request( void update_sm_context_response_from_ctx_request(
const std::shared_ptr<itti_n11_update_sm_context_request>& ct_request, const std::shared_ptr<itti_n11_update_sm_context_request>& ct_request,
std::shared_ptr<itti_n11_update_sm_context_response>& ct_response); std::shared_ptr<itti_n11_update_sm_context_response>& ct_response);
......
...@@ -32,6 +32,11 @@ ...@@ -32,6 +32,11 @@
#include <ctype.h> #include <ctype.h>
#include <inttypes.h> #include <inttypes.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include "logger.hpp"
extern "C" {
#include "dynamic_memory_check.h"
}
static const char hex_to_ascii_table[16] = { static const char hex_to_ascii_table[16] = {
'0', '1', '2', '3', '4', '5', '6', '7', '0', '1', '2', '3', '4', '5', '6', '7',
...@@ -185,3 +190,32 @@ std::string conv::toString(const struct in6_addr& in6addr) { ...@@ -185,3 +190,32 @@ std::string conv::toString(const struct in6_addr& in6addr) {
} }
return s; return s;
} }
//---------------------------------------------------------------------------------------------
void conv::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);
memset(data, 0, input_str.length() + 1);
memcpy((void*) data, (void*) input_str.c_str(), input_str.length());
#if DEBUG_IS_ON
Logger::smf_app().debug("Input: ");
for (int i = 0; i < input_str.length(); i++) {
printf("%02x ", data[i]);
}
printf("\n");
#endif
char* datahex = (char*) malloc(input_str.length() * 2 + 1);
memset(datahex, 0, input_str.length() * 2 + 1);
for (int i = 0; i < input_str.length(); i++)
sprintf(datahex + i * 2, "%02x", data[i]);
output_str = reinterpret_cast<char*>(datahex);
Logger::smf_app().debug("Output: \n %s ", output_str.c_str());
// free memory
free_wrapper((void**) &data);
free_wrapper((void**) &datahex);
}
...@@ -63,5 +63,14 @@ class conv { ...@@ -63,5 +63,14 @@ class conv {
const uint8_t digit1, const uint8_t digit2, const uint8_t digit3); const uint8_t digit1, const uint8_t digit2, const uint8_t digit3);
static std::string mncToString( static std::string mncToString(
const uint8_t digit1, const uint8_t digit2, const uint8_t digit3); const uint8_t digit1, const uint8_t digit2, const uint8_t digit3);
/*
* Convert a string to hex representing this string
* @param [const std::string&] input_str Input string
* @param [std::string&] output_str String represents string in hex format
* @return void
*/
static void convert_string_2_hex(
const std::string& input_str, std::string& output_str);
}; };
#endif /* FILE_CONVERSIONS_HPP_SEEN */ #endif /* FILE_CONVERSIONS_HPP_SEEN */
This diff is collapsed.
...@@ -43,9 +43,6 @@ ...@@ -43,9 +43,6 @@
#include "itti_msg_n11.hpp" #include "itti_msg_n11.hpp"
#include "itti_msg_n4.hpp" #include "itti_msg_n4.hpp"
#include "itti_msg_sbi.hpp" #include "itti_msg_sbi.hpp"
#include "pistache/endpoint.h"
#include "pistache/http.h"
#include "pistache/router.h"
#include "smf.h" #include "smf.h"
#include "smf_context.hpp" #include "smf_context.hpp"
#include "smf_msg.hpp" #include "smf_msg.hpp"
...@@ -432,13 +429,6 @@ class smf_app { ...@@ -432,13 +429,6 @@ class smf_app {
*/ */
scid_t generate_smf_context_ref(); scid_t generate_smf_context_ref();
/*
* Generate an Event Exposure Subscription ID in a form of string
* @param [std::string &] sub_id: Store the generated reference
* @return void
*/
void generate_ev_subscription_id(std::string& sub_id);
/* /*
* Generate an Event Exposure Subscription ID * Generate an Event Exposure Subscription ID
* @param [void] * @param [void]
...@@ -493,6 +483,30 @@ class smf_app { ...@@ -493,6 +483,30 @@ class smf_app {
bool scid_2_smf_context( bool scid_2_smf_context(
const scid_t& scid, std::shared_ptr<smf_context_ref>& scf) const; const scid_t& scid, std::shared_ptr<smf_context_ref>& scf) const;
/*
* Verify if SM Context is existed for this Supi
* @param [supi_t] supi
* @return True if existed, otherwise false
*/
bool is_supi_2_smf_context(const supi64_t& supi) const;
/*
* Create/Update SMF context with the corresponding 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
*/
void set_supi_2_smf_context(
const supi64_t& supi, std::shared_ptr<smf_context> sc);
/*
* Get SM Context
* @param [supi_t] Supi
* @return Shared pointer to SM context
*/
std::shared_ptr<smf_context> supi_2_smf_context(const supi64_t& supi) const;
/* /*
* Handle PDUSession_CreateSMContextRequest from AMF * Handle PDUSession_CreateSMContextRequest from AMF
* @param [std::shared_ptr<itti_n11_create_sm_context_request>&] Request * @param [std::shared_ptr<itti_n11_create_sm_context_request>&] Request
...@@ -527,6 +541,13 @@ class smf_app { ...@@ -527,6 +541,13 @@ class smf_app {
evsub_id_t handle_event_exposure_subscription( evsub_id_t handle_event_exposure_subscription(
std::shared_ptr<itti_sbi_event_exposure_request> msg); std::shared_ptr<itti_sbi_event_exposure_request> msg);
/*
* Handle NF status notification (e.g., when an UPF becomes available)
* @param [std::shared_ptr<itti_sbi_notification_data>& ] msg: message
* @param [oai::smf_server::model::ProblemDetails& ] problem_details
* @param [uint8_t&] http_code
* @return true if handle sucessfully, otherwise return false
*/
bool handle_nf_status_notification( bool handle_nf_status_notification(
std::shared_ptr<itti_sbi_notification_data>& msg, std::shared_ptr<itti_sbi_notification_data>& msg,
oai::smf_server::model::ProblemDetails& problem_details, oai::smf_server::model::ProblemDetails& problem_details,
...@@ -546,30 +567,6 @@ class smf_app { ...@@ -546,30 +567,6 @@ class smf_app {
const pdu_session_id_t pdu_session_id, const snssai_t& snssai, const pdu_session_id_t pdu_session_id, const snssai_t& snssai,
const pfcp::qfi_t& qfi, const uint8_t& http_version); const pfcp::qfi_t& qfi, const uint8_t& http_version);
/*
* Verify if SM Context is existed for this Supi
* @param [supi_t] supi
* @return True if existed, otherwise false
*/
bool is_supi_2_smf_context(const supi64_t& supi) const;
/*
* Create/Update SMF context with the corresponding 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
*/
void set_supi_2_smf_context(
const supi64_t& supi, std::shared_ptr<smf_context> sc);
/*
* Get SM Context
* @param [supi_t] Supi
* @return Shared pointer to SM context
*/
std::shared_ptr<smf_context> supi_2_smf_context(const supi64_t& supi) const;
/* /*
* Check whether SMF uses local configuration instead of retrieving Session * Check whether SMF uses local configuration instead of retrieving Session
* Management Data from UDM * Management Data from UDM
...@@ -613,15 +610,6 @@ class smf_app { ...@@ -613,15 +610,6 @@ class smf_app {
*/ */
bool is_create_sm_context_request_valid() const; bool is_create_sm_context_request_valid() const;
/*
* Convert a string to hex representing this 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(
const std::string& input_str, std::string& output_str);
/* /*
* Update PDU session status * Update PDU session status
* @param [const scid_t &] id SM Context ID * @param [const scid_t &] id SM Context ID
...@@ -741,7 +729,6 @@ class smf_app { ...@@ -741,7 +729,6 @@ class smf_app {
* @param [const uint32_t &] http_code: Status code of HTTP response * @param [const uint32_t &] http_code: Status code of HTTP response
* @param [const uint8_t &] cause: Error cause * @param [const uint8_t &] cause: Error cause
* @param [uint32_t &] promise_id: Promise Id * @param [uint32_t &] promise_id: Promise Id
* @param [uint8_t] msg_type: Type of HTTP message (Update/Release)
* @return void * @return void
*/ */
void trigger_update_context_error_response( void trigger_update_context_error_response(
...@@ -754,7 +741,6 @@ class smf_app { ...@@ -754,7 +741,6 @@ class smf_app {
* @param [const uint8_t &] cause: cause * @param [const uint8_t &] cause: cause
* @param [const std::string &] n1_sm_msg: N1 SM message * @param [const std::string &] n1_sm_msg: N1 SM message
* @param [uint32_t &] promise_id: Promise Id * @param [uint32_t &] promise_id: Promise Id
* @param [uint8_t] msg_type: Type of HTTP message (Update/Release)
* @return void * @return void
*/ */
void trigger_update_context_error_response( void trigger_update_context_error_response(
...@@ -772,6 +758,42 @@ class smf_app { ...@@ -772,6 +758,42 @@ class smf_app {
void trigger_http_response( void trigger_http_response(
const uint32_t& http_code, uint32_t& promise_id, uint8_t msg_type); const uint32_t& http_code, uint32_t& promise_id, uint8_t msg_type);
/*
* To trigger the session create sm context response by set the value of the
* corresponding promise to ready
* @param [pdu_session_create_sm_context_response&] sm_context_response:
* response message
* @param [uint32_t &] promise_id: Promise Id
* @return void
*/
void trigger_session_create_sm_context_response(
pdu_session_create_sm_context_response& sm_context_response,
uint32_t& pid);
/*
* To trigger the session update sm context response by set the value of the
* corresponding promise to ready
* @param [pdu_session_update_sm_context_response&] sm_context_response:
* response message
* @param [uint32_t &] promise_id: Promise Id
* @return void
*/
void trigger_session_update_sm_context_response(
pdu_session_update_sm_context_response& sm_context_response,
uint32_t& pid);
/*
* To trigger the session release sm context response by set the value of the
* corresponding promise to ready
* @param [pdu_session_release_sm_context_response&] sm_context_response:
* response message
* @param [uint32_t &] promise_id: Promise Id
* @return void
*/
void trigger_session_release_sm_context_response(
pdu_session_release_sm_context_response& sm_context_response,
uint32_t& pid);
/* /*
* Add an Event Subscription to the list * Add an Event Subscription to the list
* @param [const evsub_id_t&] sub_id: Subscription ID * @param [const evsub_id_t&] sub_id: Subscription ID
......
This diff is collapsed.
...@@ -43,9 +43,6 @@ ...@@ -43,9 +43,6 @@
#include "common_root_types.h" #include "common_root_types.h"
#include "itti.hpp" #include "itti.hpp"
#include "msg_pfcp.hpp" #include "msg_pfcp.hpp"
#include "pistache/endpoint.h"
#include "pistache/http.h"
#include "pistache/router.h"
#include "smf_event.hpp" #include "smf_event.hpp"
#include "smf_procedure.hpp" #include "smf_procedure.hpp"
#include "uint_generator.hpp" #include "uint_generator.hpp"
...@@ -561,7 +558,6 @@ class smf_context : public std::enable_shared_from_this<smf_context> { ...@@ -561,7 +558,6 @@ class smf_context : public std::enable_shared_from_this<smf_context> {
: m_context(), : m_context(),
pending_procedures(), pending_procedures(),
dnn_subscriptions(), dnn_subscriptions(),
scid(0),
event_sub(), event_sub(),
plmn() { plmn() {
supi_prefix = {}; supi_prefix = {};
...@@ -925,20 +921,6 @@ class smf_context : public std::enable_shared_from_this<smf_context> { ...@@ -925,20 +921,6 @@ class smf_context : public std::enable_shared_from_this<smf_context> {
*/ */
std::size_t get_number_dnn_contexts() const; std::size_t get_number_dnn_contexts() const;
/*
* Set SM Context ID
* @param [const scid_t &] id: SM Context Id
* @return void
*/
void set_scid(const scid_t& id);
/*
* Get SM Context ID
* @param [void
* @return scid_t: SM Context Id
*/
scid_t get_scid() const;
/* /*
* Get Supi prefix * Get Supi prefix
* @param [const std::string &] prefix: Supi prefix (e.g., imsi) * @param [const std::string &] prefix: Supi prefix (e.g., imsi)
...@@ -1067,7 +1049,6 @@ class smf_context : public std::enable_shared_from_this<smf_context> { ...@@ -1067,7 +1049,6 @@ class smf_context : public std::enable_shared_from_this<smf_context> {
dnn_subscriptions; dnn_subscriptions;
supi_t supi; supi_t supi;
std::string supi_prefix; std::string supi_prefix;
scid_t scid; // SM Context ID
plmn_t plmn; plmn_t plmn;
// AMF IP addr // AMF IP addr
......
...@@ -405,7 +405,7 @@ void session_create_sm_context_procedure::handle_itti_msg( ...@@ -405,7 +405,7 @@ void session_create_sm_context_procedure::handle_itti_msg(
smf_n1::get_instance().create_n1_pdu_session_establishment_reject( smf_n1::get_instance().create_n1_pdu_session_establishment_reject(
n11_triggered_pending->res, n1_sm_msg, cause_n1); n11_triggered_pending->res, n1_sm_msg, cause_n1);
smf_app_inst->convert_string_2_hex(n1_sm_msg, n1_sm_msg_hex); conv::convert_string_2_hex(n1_sm_msg, n1_sm_msg_hex);
n11_triggered_pending->res.set_n1_sm_message(n1_sm_msg_hex); n11_triggered_pending->res.set_n1_sm_message(n1_sm_msg_hex);
} else { // PDU Session Establishment Accept } else { // PDU Session Establishment Accept
...@@ -422,7 +422,7 @@ void session_create_sm_context_procedure::handle_itti_msg( ...@@ -422,7 +422,7 @@ void session_create_sm_context_procedure::handle_itti_msg(
smf_n1::get_instance().create_n1_pdu_session_establishment_accept( smf_n1::get_instance().create_n1_pdu_session_establishment_accept(
n11_triggered_pending->res, n1_sm_msg, cause_n1); n11_triggered_pending->res, n1_sm_msg, cause_n1);
smf_app_inst->convert_string_2_hex(n1_sm_msg, n1_sm_msg_hex); conv::convert_string_2_hex(n1_sm_msg, n1_sm_msg_hex);
n11_triggered_pending->res.set_n1_sm_message(n1_sm_msg_hex); n11_triggered_pending->res.set_n1_sm_message(n1_sm_msg_hex);
// N2 SM Information (Step 11, section 4.3.2.2.1 @ 3GPP TS 23.502): // N2 SM Information (Step 11, section 4.3.2.2.1 @ 3GPP TS 23.502):
// PDUSessionRessourceSetupRequestTransfer IE // PDUSessionRessourceSetupRequestTransfer IE
...@@ -431,7 +431,7 @@ void session_create_sm_context_procedure::handle_itti_msg( ...@@ -431,7 +431,7 @@ void session_create_sm_context_procedure::handle_itti_msg(
n11_triggered_pending->res, n2_sm_info_type_e::PDU_RES_SETUP_REQ, n11_triggered_pending->res, n2_sm_info_type_e::PDU_RES_SETUP_REQ,
n2_sm_info); n2_sm_info);
smf_app_inst->convert_string_2_hex(n2_sm_info, n2_sm_info_hex); conv::convert_string_2_hex(n2_sm_info, n2_sm_info_hex);
n11_triggered_pending->res.set_n2_sm_information(n2_sm_info_hex); n11_triggered_pending->res.set_n2_sm_information(n2_sm_info_hex);
} }
...@@ -1149,7 +1149,7 @@ void session_update_sm_context_procedure::handle_itti_msg( ...@@ -1149,7 +1149,7 @@ void session_update_sm_context_procedure::handle_itti_msg(
n11_triggered_pending->res, n2_sm_info_type_e::PDU_RES_SETUP_REQ, n11_triggered_pending->res, n2_sm_info_type_e::PDU_RES_SETUP_REQ,
n2_sm_info); n2_sm_info);
smf_app_inst->convert_string_2_hex(n2_sm_info, n2_sm_info_hex); conv::convert_string_2_hex(n2_sm_info, n2_sm_info_hex);
n11_triggered_pending->res.set_n2_sm_information(n2_sm_info_hex); n11_triggered_pending->res.set_n2_sm_information(n2_sm_info_hex);
// fill the content of SmContextUpdatedData // fill the content of SmContextUpdatedData
...@@ -1210,7 +1210,7 @@ void session_update_sm_context_procedure::handle_itti_msg( ...@@ -1210,7 +1210,7 @@ void session_update_sm_context_procedure::handle_itti_msg(
n11_triggered_pending->res, n1_sm_msg, n11_triggered_pending->res, n1_sm_msg,
cause_value_5gsm_e::CAUSE_26_INSUFFICIENT_RESOURCES); // TODO: check cause_value_5gsm_e::CAUSE_26_INSUFFICIENT_RESOURCES); // TODO: check
// Cause // Cause
smf_app_inst->convert_string_2_hex(n1_sm_msg, n1_sm_msg_hex); conv::convert_string_2_hex(n1_sm_msg, n1_sm_msg_hex);
n11_triggered_pending->res.set_n1_sm_message(n1_sm_msg_hex); n11_triggered_pending->res.set_n1_sm_message(n1_sm_msg_hex);
// include N2 SM Resource Release Request only when User Plane connection // include N2 SM Resource Release Request only when User Plane connection
...@@ -1221,7 +1221,7 @@ void session_update_sm_context_procedure::handle_itti_msg( ...@@ -1221,7 +1221,7 @@ void session_update_sm_context_procedure::handle_itti_msg(
.create_n2_pdu_session_resource_release_command_transfer( .create_n2_pdu_session_resource_release_command_transfer(
n11_triggered_pending->res, n2_sm_info_type_e::PDU_RES_REL_CMD, n11_triggered_pending->res, n2_sm_info_type_e::PDU_RES_REL_CMD,
n2_sm_info); n2_sm_info);
smf_app_inst->convert_string_2_hex(n2_sm_info, n2_sm_info_hex); conv::convert_string_2_hex(n2_sm_info, n2_sm_info_hex);
n11_triggered_pending->res.set_n2_sm_information(n2_sm_info_hex); n11_triggered_pending->res.set_n2_sm_information(n2_sm_info_hex);
// fill the content of SmContextUpdatedData // fill the content of SmContextUpdatedData
......
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