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

Merge branch 'fix_n11' into 'develop'

Fix n11

See merge request oai/cn5g/oai-cn5g-amf!23
parents 2a6d9ce7 1acbf231
......@@ -71,9 +71,6 @@ extern void msg_str_2_msg_hex(std::string msg, bstring& b);
extern void convert_string_2_hex(std::string& input, std::string& output);
extern void print_buffer(
const std::string app, const std::string commit, uint8_t* buf, int len);
extern bool multipart_parser(
std::string input, std::string& jsonData, std::string& n1sm,
std::string& n2sm);
extern unsigned char* format_string_as_hex(std::string str);
extern char* bstring2charString(bstring b);
......@@ -591,19 +588,11 @@ void amf_n11::curl_http_client(
// free curl before returning
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
// TODO: To be verified
psc.get()->smf_context_location =
"/nsmf-pdusession/v2/sm-contexts/1"; // try to fix bugs for
// no-response from SMF when
// requesting
// /nsmf-pdusession/v2/sm-contexts
// (first pdu session
// establishment request)
return;
}
if (response.size() > 0) {
number_parts = multipart_parser(response, json_data_response, n1sm, n2sm);
number_parts = parser.parse(response, json_data_response, n1sm, n2sm);
}
if ((static_cast<http_response_codes_e>(httpCode) !=
......@@ -673,7 +662,10 @@ void amf_n11::curl_http_client(
} catch (nlohmann::json::exception& e) {
Logger::amf_n11().warn(
"Could not get Json content from the response");
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
// TODO:
return;
}
itti_n1n2_message_transfer_request* itti_msg =
......
......@@ -386,12 +386,18 @@ bool DownLinkNasTransportMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
//------------------------------------------------------------------------------
unsigned long DownLinkNasTransportMsg::getAmfUeNgapId() {
return amfUeNgapId->getAMF_UE_NGAP_ID();
if (amfUeNgapId)
return amfUeNgapId->getAMF_UE_NGAP_ID();
else
return 0;
}
//------------------------------------------------------------------------------
uint32_t DownLinkNasTransportMsg::getRanUeNgapId() {
return ranUeNgapId->getRanUeNgapId();
if (ranUeNgapId)
return ranUeNgapId->getRanUeNgapId();
else
return 0;
}
//------------------------------------------------------------------------------
......@@ -403,7 +409,10 @@ bool DownLinkNasTransportMsg::getOldAmfName(std::string& name) {
//------------------------------------------------------------------------------
uint8_t DownLinkNasTransportMsg::getRanPagingPriority() {
return ranPagingPriority->getRANPagingPriority();
if (ranPagingPriority)
return ranPagingPriority->getRANPagingPriority();
else
return 0;
}
//------------------------------------------------------------------------------
......@@ -415,7 +424,10 @@ bool DownLinkNasTransportMsg::getNasPdu(uint8_t*& nas, size_t& sizeofnas) {
//------------------------------------------------------------------------------
uint8_t DownLinkNasTransportMsg::getIndex2Rat_Frequency_SelectionPriority() {
return indexToRFSP->getIndexToRFSP();
if (indexToRFSP)
return indexToRFSP->getIndexToRFSP();
else
return 0;
}
} // namespace ngap
......@@ -29,9 +29,8 @@ include_directories(${SRC_TOP_DIR}/utils/bstr)
add_library (AMF_UTILS STATIC
${CMAKE_CURRENT_SOURCE_DIR}/backtrace.c
${CMAKE_CURRENT_SOURCE_DIR}/conversions.c
${CMAKE_CURRENT_SOURCE_DIR}/dynamic_memory_check.c
${CMAKE_CURRENT_SOURCE_DIR}/dynamic_memory_check.c
${CMAKE_CURRENT_SOURCE_DIR}/hex_string_convert.cpp
${CMAKE_CURRENT_SOURCE_DIR}/http_multi_parser.cpp
${CMAKE_CURRENT_SOURCE_DIR}/if.cpp
${CMAKE_CURRENT_SOURCE_DIR}/string.cpp
${CMAKE_CURRENT_SOURCE_DIR}/thread_sched.cpp
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <iostream>
#include <string>
#include "mime_parser.hpp"
uint8_t multipart_parser(
std::string input, std::string& jsonData, std::string& n1sm,
std::string& n2sm) {
// simple parser
mime_parser sp = {};
sp.parse(input);
std::vector<mime_part> parts = {};
sp.get_mime_parts(parts);
uint8_t size = parts.size();
// at least 2 parts for Json data and N1 (+ N2)
if (size < 2) {
return size;
}
jsonData = parts[0].body;
n1sm = parts[1].body;
bool is_ngap = false;
if (size > 2) {
n2sm = parts[2].body;
} else {
n2sm = "null";
}
return size;
}
......@@ -72,6 +72,25 @@ bool mime_parser::parse(const std::string& str) {
return true;
}
//------------------------------------------------------------------------------
uint8_t mime_parser::parse(
std::string input, std::string& jsonData, std::string& n1sm,
std::string& n2sm) {
if (!parse(input)) return 0;
uint8_t size = mime_parts.size();
if (size > 0) {
jsonData = mime_parts[0].body;
}
if (size > 1) {
n1sm = mime_parts[1].body;
}
if (size > 2) {
n2sm = mime_parts[2].body;
}
return size;
}
//------------------------------------------------------------------------------
void mime_parser::get_mime_parts(std::vector<mime_part>& parts) const {
for (auto it : mime_parts) {
parts.push_back(it);
......
......@@ -50,6 +50,10 @@ class mime_parser {
*/
bool parse(const std::string& str);
uint8_t parse(
std::string input, std::string& jsonData, std::string& n1sm,
std::string& n2sm);
/*
* Get vector of Mime parts
* @param [std::vector<mime_part> &] parts: store vector of Mime parts
......
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