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

Use ITTI to send N1 Message Notification message to AMF App to process

parent f5e31641
This diff is collapsed.
...@@ -83,6 +83,7 @@ class amf_app { ...@@ -83,6 +83,7 @@ class amf_app {
// itti handlers // itti handlers
void handle_itti_message(itti_nas_signalling_establishment_request& itti_msg); void handle_itti_message(itti_nas_signalling_establishment_request& itti_msg);
void handle_itti_message(itti_n1n2_message_transfer_request& itti_msg); void handle_itti_message(itti_n1n2_message_transfer_request& itti_msg);
void handle_itti_message(itti_sbi_n1_message_notification& itti_msg);
bool is_amf_ue_id_2_ue_context(const long& amf_ue_ngap_id) const; bool is_amf_ue_id_2_ue_context(const long& amf_ue_ngap_id) const;
std::shared_ptr<ue_context> amf_ue_id_2_ue_context( std::shared_ptr<ue_context> amf_ue_id_2_ue_context(
...@@ -161,17 +162,6 @@ class amf_app { ...@@ -161,17 +162,6 @@ class amf_app {
std::shared_ptr<itti_sbi_notification_data>& msg, std::shared_ptr<itti_sbi_notification_data>& msg,
oai::amf::model::ProblemDetails& problem_details, uint32_t& http_code); oai::amf::model::ProblemDetails& problem_details, uint32_t& http_code);
/*
* Handle N1 Message Notification
* @param [std::shared_ptr<itti_sbi_n1_message_notification>& ] msg: message
* @param [oai::amf::model::ProblemDetails& ] problem_details
* @param [uint8_t&] http_code
* @return true if handle sucessfully, otherwise return false
*/
bool handle_n1_message_notification(
std::shared_ptr<itti_sbi_n1_message_notification>& msg,
oai::amf::model::ProblemDetails& problem_details, uint32_t& http_code);
/* /*
* Generate a random UUID for SMF instance * Generate a random UUID for SMF instance
* @param [void] * @param [void]
......
...@@ -47,26 +47,32 @@ void GNB_ID::setValue(uint32_t gnbId) { ...@@ -47,26 +47,32 @@ void GNB_ID::setValue(uint32_t gnbId) {
uint8_t len = 0; uint8_t len = 0;
for (uint32_t i = 0x00000001; i <= 0x00000400; i = i << 1, len++) { for (uint32_t i = 0x00000001; i <= 0x00000400; i = i << 1, len++) {
if ((i & gnbId)) { if ((i & gnbId)) {
gNBId.biteslen = 32 - len; gNBId.bit_length = 32 - len;
break; break;
} }
} }
if (!((gNBId.biteslen >= 22) && (gNBId.biteslen <= 32))) { if (!((gNBId.bit_length >= 22) && (gNBId.bit_length <= 32))) {
cout << "[warning][gNBID length out of range]" << endl; cout << "[warning][gNBID length out of range]" << endl;
} }
} }
//------------------------------------------------------------------------------
void GNB_ID::setValue(uint32_t id, uint8_t bit_length) {
gNBId.id = id;
gNBId.bit_length = bit_length;
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool GNB_ID::encode2bitstring(Ngap_GNB_ID_t& gnbid) { bool GNB_ID::encode2bitstring(Ngap_GNB_ID_t& gnbid) {
gnbid.present = Ngap_GNB_ID_PR_gNB_ID; gnbid.present = Ngap_GNB_ID_PR_gNB_ID;
if (!(gNBId.biteslen % 8)) if (!(gNBId.bit_length % 8))
gnbid.choice.gNB_ID.size = gNBId.biteslen / 8; gnbid.choice.gNB_ID.size = gNBId.bit_length / 8;
else else
gnbid.choice.gNB_ID.size = gNBId.biteslen / 8 + 1; gnbid.choice.gNB_ID.size = gNBId.bit_length / 8 + 1;
// printf("m_gNBId.size(%d)\n",m_gNBId.size); // printf("m_gNBId.size(%d)\n",m_gNBId.size);
gnbid.choice.gNB_ID.bits_unused = 32 - gNBId.biteslen; gnbid.choice.gNB_ID.bits_unused = 32 - gNBId.bit_length;
gnbid.choice.gNB_ID.buf = (uint8_t*) calloc(1, 4 * sizeof(uint8_t)); gnbid.choice.gNB_ID.buf = (uint8_t*) calloc(1, 4 * sizeof(uint8_t));
if (!gnbid.choice.gNB_ID.buf) return false; if (!gnbid.choice.gNB_ID.buf) return false;
gnbid.choice.gNB_ID.buf[3] = gNBId.id & 0x000000ff; gnbid.choice.gNB_ID.buf[3] = gNBId.id & 0x000000ff;
......
...@@ -45,10 +45,12 @@ class GNB_ID { ...@@ -45,10 +45,12 @@ class GNB_ID {
void setValue(uint32_t gnbId); void setValue(uint32_t gnbId);
long getValue(); long getValue();
void setValue(uint32_t id, uint8_t bit_length);
private: private:
struct gNBId_s { struct gNBId_s {
uint32_t id; uint32_t id;
uint8_t biteslen; uint8_t bit_length;
} gNBId; // 22bits to 32bits } gNBId; // 22bits to 32bits
}; };
......
...@@ -14,8 +14,11 @@ ...@@ -14,8 +14,11 @@
#include "N1MessageNotifyApiImpl.h" #include "N1MessageNotifyApiImpl.h"
#include "itti_msg_sbi.hpp" #include "itti_msg_sbi.hpp"
#include "conversions.hpp" #include "conversions.hpp"
#include "itti.hpp"
using namespace amf_application; using namespace amf_application;
extern itti_mw* itti_inst;
namespace oai { namespace oai {
namespace amf { namespace amf {
namespace api { namespace api {
...@@ -47,15 +50,17 @@ void N1MessageNotifyApiImpl::receive_n1_message_notification( ...@@ -47,15 +50,17 @@ void N1MessageNotifyApiImpl::receive_n1_message_notification(
oai::amf::model::ProblemDetails problem_details = {}; oai::amf::model::ProblemDetails problem_details = {};
uint32_t http_code = {0}; uint32_t http_code = {0};
if (m_amf_app->handle_n1_message_notification(
itti_msg, problem_details, http_code)) { // Send response
response.send(Pistache::Http::Code(http_code)); response.send(Pistache::Http::Code::No_Content);
} else { // TODO: problem
response.headers().add<Pistache::Http::Header::ContentType>(
Pistache::Http::Mime::MediaType("application/problem+json")); // Process N1 Notification Message at AMF APP
nlohmann::json json_data = {}; int ret = itti_inst->send_msg(itti_msg);
to_json(json_data, problem_details); if (0 != ret) {
response.send(Pistache::Http::Code(http_code), json_data.dump().c_str()); Logger::amf_server().error(
"Could not send ITTI message %s to task TASK_AMF_N2",
itti_msg->get_msg_name());
} }
} }
......
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