Commit 191dd292 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen
Browse files

Fix issue for Simple Parser

parent d6bf9462
......@@ -96,9 +96,12 @@ void IndividualSMContextApi::release_sm_context_handler(
Logger::smf_api_server().debug("Request body: %s\n", request.body().c_str());
SmContextReleaseMessage smContextReleaseMessage = {};
// simple parser
// Simple parser
mime_parser sp = {};
sp.parse(request.body());
if (!sp.parse(request.body())) {
response.send(Pistache::Http::Code::Bad_Request);
return;
}
std::vector<mime_part> parts = {};
sp.get_mime_parts(parts);
......@@ -178,9 +181,12 @@ void IndividualSMContextApi::update_sm_context_handler(
Logger::smf_api_server().debug("Request body: %s\n", request.body().c_str());
SmContextUpdateMessage smContextUpdateMessage = {};
// simple parser
// Simple parser
mime_parser sp = {};
sp.parse(request.body());
if (!sp.parse(request.body())) {
response.send(Pistache::Http::Code::Bad_Request);
return;
}
std::vector<mime_part> parts = {};
sp.get_mime_parts(parts);
......
......@@ -88,25 +88,28 @@ void SMContextsCollectionApi::post_sm_contexts_handler(
SmContextMessage smContextMessage = {};
SmContextCreateData smContextCreateData = {};
// simple parser
// Simple parser
mime_parser sp = {};
sp.parse(request.body());
if (!sp.parse(request.body())) {
response.send(Pistache::Http::Code::Bad_Request);
return;
}
std::vector<mime_part> parts = {};
sp.get_mime_parts(parts);
uint8_t size = parts.size();
Logger::smf_api_server().debug("Number of MIME parts %d", size);
// at least 2 parts for Json data and N1 (+ N2)
// At least 2 parts for Json data and N1 (+ N2)
if (size < 2) {
response.send(Pistache::Http::Code::Bad_Request);
return;
}
// step 2. process the request
// Step 2. process the request
try {
nlohmann::json::parse(parts[0].body.c_str()).get_to(smContextCreateData);
smContextMessage.setJsonData(smContextCreateData);
// must include N1 NAS msg
// Must include N1 NAS msg
if (parts[1].content_type.compare("application/vnd.3gpp.5gnas") == 0) {
smContextMessage.setBinaryDataN1SmMessage(parts[1].body);
} else {
......
......@@ -53,7 +53,7 @@ void SubscriptionsCollectionApi::create_individual_subcription_handler(
Pistache::Http::ResponseWriter response) {
// Getting the body param
NsmfEventExposure nsmfEventExposure;
NsmfEventExposure nsmfEventExposure = {};
try {
nlohmann::json::parse(request.body()).get_to(nsmfEventExposure);
......
......@@ -85,7 +85,13 @@ void smf_http2_server::start() {
// simple parser
mime_parser sp = {};
sp.parse(msg);
if (!sp.parse(msg)) {
// send reply!!!
response.write_head(
http_status_code_e::HTTP_STATUS_CODE_400_BAD_REQUEST);
response.end();
return;
}
std::vector<mime_part> parts = {};
sp.get_mime_parts(parts);
......@@ -176,7 +182,13 @@ void smf_http2_server::start() {
// simple parser
mime_parser sp = {};
sp.parse(msg);
if (!sp.parse(msg)) {
// send reply!!!
response.write_head(
http_status_code_e::HTTP_STATUS_CODE_400_BAD_REQUEST);
response.end();
return;
}
std::vector<mime_part> parts = {};
sp.get_mime_parts(parts);
......@@ -235,7 +247,13 @@ void smf_http2_server::start() {
// simple parser
mime_parser sp = {};
sp.parse(msg);
if (!sp.parse(msg)) {
// send reply!!!
response.write_head(
http_status_code_e::HTTP_STATUS_CODE_400_BAD_REQUEST);
response.end();
return;
}
std::vector<mime_part> parts = {};
sp.get_mime_parts(parts);
......
......@@ -65,6 +65,7 @@ std::string Utility::home_network_gprs(const plmn_t& plmn) {
s.append(".mnc");
if (mnc_len == 2) s.append("0");
if (mnc < 10) s.append("0");
s.append(std::to_string(mnc));
s.append(".mcc");
s.append(std::to_string(mcc));
......
......@@ -43,6 +43,7 @@ typedef struct mime_part {
class mime_parser {
public:
mime_parser() { mime_parts = {}; }
/*
* Parse the input string into different Mime parts
* @param [const std::string &] str: input string
......
......@@ -345,9 +345,9 @@ smf_app::smf_app(const std::string& config_file)
start_upf_association(*it);
}
// Trigger NFStatusNotify subscription to be noticed when a new UPF becomes
// available (if this option is enabled)
if (smf_cfg.discover_upf) {
// Trigger NFStatusNotify subscription to be noticed when a new UPF becomes
// available (if this option is enabled)
trigger_upf_status_notification_subscribe();
}
......
......@@ -659,7 +659,14 @@ class smf_app {
*/
void timer_nrf_heartbeat_timeout(timer_id_t timer_id, uint64_t arg2_user);
/*
* will be executed when NRF Deregistration timer expires
* @param [timer_id_t] timer_id
* @param [uint64_t] arg2_user
* @return void
*/
void timer_nrf_deregistration(timer_id_t timer_id, uint64_t arg2_user);
/*
* To start an association with a UPF (SMF-initiated association)
* @param [const pfcp::node_id_t] node_id: UPF Node ID
......
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