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 {
// itti handlers
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_sbi_n1_message_notification& itti_msg);
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(
......@@ -161,17 +162,6 @@ class amf_app {
std::shared_ptr<itti_sbi_notification_data>& msg,
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
* @param [void]
......
......@@ -47,26 +47,32 @@ void GNB_ID::setValue(uint32_t gnbId) {
uint8_t len = 0;
for (uint32_t i = 0x00000001; i <= 0x00000400; i = i << 1, len++) {
if ((i & gnbId)) {
gNBId.biteslen = 32 - len;
gNBId.bit_length = 32 - len;
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;
}
}
//------------------------------------------------------------------------------
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) {
gnbid.present = Ngap_GNB_ID_PR_gNB_ID;
if (!(gNBId.biteslen % 8))
gnbid.choice.gNB_ID.size = gNBId.biteslen / 8;
if (!(gNBId.bit_length % 8))
gnbid.choice.gNB_ID.size = gNBId.bit_length / 8;
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);
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));
if (!gnbid.choice.gNB_ID.buf) return false;
gnbid.choice.gNB_ID.buf[3] = gNBId.id & 0x000000ff;
......
......@@ -45,10 +45,12 @@ class GNB_ID {
void setValue(uint32_t gnbId);
long getValue();
void setValue(uint32_t id, uint8_t bit_length);
private:
struct gNBId_s {
uint32_t id;
uint8_t biteslen;
uint8_t bit_length;
} gNBId; // 22bits to 32bits
};
......
......@@ -14,8 +14,11 @@
#include "N1MessageNotifyApiImpl.h"
#include "itti_msg_sbi.hpp"
#include "conversions.hpp"
#include "itti.hpp"
using namespace amf_application;
extern itti_mw* itti_inst;
namespace oai {
namespace amf {
namespace api {
......@@ -47,15 +50,17 @@ void N1MessageNotifyApiImpl::receive_n1_message_notification(
oai::amf::model::ProblemDetails problem_details = {};
uint32_t http_code = {0};
if (m_amf_app->handle_n1_message_notification(
itti_msg, problem_details, http_code)) {
response.send(Pistache::Http::Code(http_code));
} else {
response.headers().add<Pistache::Http::Header::ContentType>(
Pistache::Http::Mime::MediaType("application/problem+json"));
nlohmann::json json_data = {};
to_json(json_data, problem_details);
response.send(Pistache::Http::Code(http_code), json_data.dump().c_str());
// Send response
response.send(Pistache::Http::Code::No_Content);
// TODO: problem
// Process N1 Notification Message at AMF APP
int ret = itti_inst->send_msg(itti_msg);
if (0 != ret) {
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