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

Update N1MessageNotifyHandler

parent a83f7e5e
...@@ -482,12 +482,13 @@ bool amf_app::handle_event_exposure_delete(const std::string& subscription_id) { ...@@ -482,12 +482,13 @@ bool amf_app::handle_event_exposure_delete(const std::string& subscription_id) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool amf_app::handle_nf_status_notification( bool amf_app::handle_nf_status_notification(
std::shared_ptr<itti_sbi_notification_data>& msg, std::shared_ptr<itti_sbi_notification_data>& msg,
oai::amf::model::ProblemDetails& problem_details, uint8_t& http_code) { oai::amf::model::ProblemDetails& problem_details, uint32_t& http_code) {
Logger::amf_app().info( Logger::amf_app().info(
"Handle a NF status notification from NRF (HTTP version " "Handle a NF status notification from NRF (HTTP version "
"%d)", "%d)",
msg->http_version); msg->http_version);
// TODO // TODO
http_code = 204; // HTTP_STATUS_CODE_204_NO_CONTENT;
return true; return true;
} }
...@@ -496,10 +497,11 @@ bool amf_app::handle_n1_message_notification( ...@@ -496,10 +497,11 @@ bool amf_app::handle_n1_message_notification(
std::shared_ptr<itti_sbi_n1_message_notification>& msg, std::shared_ptr<itti_sbi_n1_message_notification>& msg,
oai::amf::model::ProblemDetails& problem_details, uint32_t& http_code) { oai::amf::model::ProblemDetails& problem_details, uint32_t& http_code) {
Logger::amf_app().info( Logger::amf_app().info(
"Handle a NF status notification from NRF (HTTP version " "Handle a N1 Message Notification from the initial AMF (HTTP version "
"%d)", "%d)",
msg->http_version); msg->http_version);
// TODO // TODO
http_code = 204; // HTTP_STATUS_CODE_204_NO_CONTENT;
return true; return true;
} }
......
...@@ -154,12 +154,12 @@ class amf_app { ...@@ -154,12 +154,12 @@ class amf_app {
* Handle NF status notification (e.g., when an UPF becomes available) * Handle NF status notification (e.g., when an UPF becomes available)
* @param [std::shared_ptr<itti_sbi_notification_data>& ] msg: message * @param [std::shared_ptr<itti_sbi_notification_data>& ] msg: message
* @param [oai::amf::model::ProblemDetails& ] problem_details * @param [oai::amf::model::ProblemDetails& ] problem_details
* @param [uint8_t&] http_code * @param [uint32_t&] http_code
* @return true if handle sucessfully, otherwise return false * @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::amf::model::ProblemDetails& problem_details, uint8_t& http_code); oai::amf::model::ProblemDetails& problem_details, uint32_t& http_code);
/* /*
* Handle N1 Message Notification * Handle N1 Message Notification
......
...@@ -124,11 +124,13 @@ class itti_sbi_n1_message_notification : public itti_sbi_msg { ...@@ -124,11 +124,13 @@ class itti_sbi_n1_message_notification : public itti_sbi_msg {
: itti_sbi_msg(SBI_N1_MESSAGE_NOTIFICATION, orig, dest), : itti_sbi_msg(SBI_N1_MESSAGE_NOTIFICATION, orig, dest),
notification_msg(), notification_msg(),
ue_id(), ue_id(),
n1sm(),
http_version(1) {} http_version(1) {}
itti_sbi_n1_message_notification(const itti_sbi_n1_message_notification& i) itti_sbi_n1_message_notification(const itti_sbi_n1_message_notification& i)
: itti_sbi_msg(i), : itti_sbi_msg(i),
notification_msg(i.notification_msg), notification_msg(i.notification_msg),
ue_id(i.ue_id), ue_id(i.ue_id),
n1sm(i.n1sm),
http_version(1) {} http_version(1) {}
itti_sbi_n1_message_notification( itti_sbi_n1_message_notification(
const itti_sbi_n1_message_notification& i, const task_id_t orig, const itti_sbi_n1_message_notification& i, const task_id_t orig,
...@@ -136,10 +138,12 @@ class itti_sbi_n1_message_notification : public itti_sbi_msg { ...@@ -136,10 +138,12 @@ class itti_sbi_n1_message_notification : public itti_sbi_msg {
: itti_sbi_msg(i, orig, dest), : itti_sbi_msg(i, orig, dest),
notification_msg(i.notification_msg), notification_msg(i.notification_msg),
ue_id(i.ue_id), ue_id(i.ue_id),
n1sm(i.n1sm),
http_version(i.http_version) {} http_version(i.http_version) {}
const char* get_msg_name() { return "SBI_N1_MESSAGE_NOTIFICATION"; }; const char* get_msg_name() { return "SBI_N1_MESSAGE_NOTIFICATION"; };
oai::amf::model::N1MessageNotification notification_msg; oai::amf::model::N1MessageNotification notification_msg;
std::string ue_id; std::string ue_id;
std::string n1sm;
uint8_t http_version; uint8_t http_version;
}; };
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "mime_parser.hpp" #include "mime_parser.hpp"
#include "logger.hpp" #include "logger.hpp"
#include "amf_config.hpp" #include "amf_config.hpp"
#include "mime_parser.hpp"
extern config::amf_config amf_cfg; extern config::amf_config amf_cfg;
...@@ -58,12 +59,33 @@ void N1MessageNotifyApi::n1_message_notify_handler( ...@@ -58,12 +59,33 @@ void N1MessageNotifyApi::n1_message_notify_handler(
"Received a N1MessageNotification with ue_ctx_id %s", "Received a N1MessageNotification with ue_ctx_id %s",
ueContextId.c_str()); ueContextId.c_str());
N1MessageNotification n1MessageNotification; N1MessageNotification n1MessageNotification = {};
// simple parser
mime_parser sp = {};
sp.parse(request.body());
std::vector<mime_part> parts = {};
sp.get_mime_parts(parts);
uint8_t size = parts.size();
Logger::amf_server().debug("Number of MIME parts %d", size);
// 2 parts for Json data and N1
if (size != 2) {
response.send(Pistache::Http::Code::Bad_Request);
Logger::amf_server().debug("Bad request: should have 2 MIME parts");
return;
}
Logger::amf_server().debug(
"Request body, part 1: \n%s", parts[0].body.c_str());
Logger::amf_server().debug(
"Request body, part 2: \n %s", parts[1].body.c_str());
try { try {
nlohmann::json::parse(request.body()).get_to(n1MessageNotification); nlohmann::json::parse(parts[0].body.c_str()).get_to(n1MessageNotification);
this->receive_n1_message_notification( this->receive_n1_message_notification(
ueContextId, n1MessageNotification, response); ueContextId, n1MessageNotification, parts[1].body, response);
} catch (nlohmann::detail::exception& e) { } catch (nlohmann::detail::exception& e) {
// send a 400 error // send a 400 error
response.send(Pistache::Http::Code::Bad_Request, e.what()); response.send(Pistache::Http::Code::Bad_Request, e.what());
......
...@@ -56,7 +56,7 @@ class N1MessageNotifyApi { ...@@ -56,7 +56,7 @@ class N1MessageNotifyApi {
virtual void receive_n1_message_notification( virtual void receive_n1_message_notification(
const std::string& ueContextId, const std::string& ueContextId,
const N1MessageNotification& notificationData, const N1MessageNotification& notificationData, std::string& n1sm_str,
Pistache::Http::ResponseWriter& response) = 0; Pistache::Http::ResponseWriter& response) = 0;
}; };
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "N1MessageNotifyApiImpl.h" #include "N1MessageNotifyApiImpl.h"
#include "itti_msg_sbi.hpp" #include "itti_msg_sbi.hpp"
#include "conversions.hpp"
using namespace amf_application; using namespace amf_application;
namespace oai { namespace oai {
...@@ -28,12 +29,10 @@ N1MessageNotifyApiImpl::N1MessageNotifyApiImpl( ...@@ -28,12 +29,10 @@ N1MessageNotifyApiImpl::N1MessageNotifyApiImpl(
void N1MessageNotifyApiImpl::receive_n1_message_notification( void N1MessageNotifyApiImpl::receive_n1_message_notification(
const std::string& ueContextId, const std::string& ueContextId,
const N1MessageNotification& notificationData, const N1MessageNotification& notificationData, std::string& n1sm_str,
Pistache::Http::ResponseWriter& response) { Pistache::Http::ResponseWriter& response) {
Logger::amf_server().debug("Receive N1MessageNotify, handling..."); Logger::amf_server().debug("Receive N1MessageNotify, handling...");
Pistache::Http::Code code = Pistache::Http::Code::Ok;
std::string supi = ueContextId; std::string supi = ueContextId;
Logger::amf_server().debug("SUPI (%s)", supi.c_str()); Logger::amf_server().debug("SUPI (%s)", supi.c_str());
...@@ -43,13 +42,14 @@ void N1MessageNotifyApiImpl::receive_n1_message_notification( ...@@ -43,13 +42,14 @@ void N1MessageNotifyApiImpl::receive_n1_message_notification(
TASK_AMF_SBI, TASK_AMF_APP); TASK_AMF_SBI, TASK_AMF_APP);
itti_msg->notification_msg = notificationData; itti_msg->notification_msg = notificationData;
itti_msg->ue_id = supi; itti_msg->ue_id = supi;
itti_msg->n1sm = n1sm_str;
itti_msg->http_version = 1; itti_msg->http_version = 1;
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( if (m_amf_app->handle_n1_message_notification(
itti_msg, problem_details, http_code)) { itti_msg, problem_details, http_code)) {
response.send(Pistache::Http::Code(204)); response.send(Pistache::Http::Code(http_code));
} else { } else {
response.headers().add<Pistache::Http::Header::ContentType>( response.headers().add<Pistache::Http::Header::ContentType>(
Pistache::Http::Mime::MediaType("application/problem+json")); Pistache::Http::Mime::MediaType("application/problem+json"));
......
...@@ -49,7 +49,7 @@ class N1MessageNotifyApiImpl : public N1MessageNotifyApi { ...@@ -49,7 +49,7 @@ class N1MessageNotifyApiImpl : public N1MessageNotifyApi {
void receive_n1_message_notification( void receive_n1_message_notification(
const std::string& ueContextId, const std::string& ueContextId,
const N1MessageNotification& notificationData, const N1MessageNotification& notificationData, std::string& n1sm_str,
Pistache::Http::ResponseWriter& response); Pistache::Http::ResponseWriter& response);
private: private:
......
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