Commit 75a0d250 authored by Niuhaiwen's avatar Niuhaiwen

fix some bug

parent 5726bbd5
......@@ -137,15 +137,14 @@ void ausf_app::register_nf_instance(std::shared_ptr<itti_sbi_register_nf_instanc
msg->profile.to_json(json_data);
std::string url =
std::string(inet_ntoa(*((struct in_addr*) &ausf_cfg.nrf_addr.ipv4_addr))) +
std::string(inet_ntoa(*((struct in_addr*) &ausf_cfg.nnrf_addr.ipv4_addr))) +
":" + std::to_string(ausf_cfg.nrf_addr.port) + "/nnrf-nfm/" +
ausf_cfg.nrf_addr.api_version + "/nf-instances/" +
ausf_cfg.nnrf_addr.api_version + "/nf-instances/" +
msg->profile.get_nf_instance_id();
Logger::ausf_app().debug(
"Send NF Instance Registration to NRF, NRF URL %s", url.c_str());
std::string body = json_data.dump();
Logger::ausf_app().debug("Send NF Instance Registration to NRF, msg body
: \n % s ", body.c_str());
Logger::ausf_app().debug("Send NF Instance Registration to NRF, msg body:\n % s ", body.c_str());
curl_global_init(CURL_GLOBAL_ALL);
CURL* curl = curl = curl_easy_init();
......@@ -158,7 +157,7 @@ void ausf_app::register_nf_instance(std::shared_ptr<itti_sbi_register_nf_instanc
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1);
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PUT");
curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, NRF_CURL_TIMEOUT_MS);
curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, 100L);
if (msg->http_version == 2) {
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
......@@ -186,7 +185,7 @@ void ausf_app::register_nf_instance(std::shared_ptr<itti_sbi_register_nf_instanc
nlohmann::json response_data = {};
try {
response_data = nlohmann::json::parse(*httpData.get());
} catch (json::exception& e) {
} catch (nlohmann::json::exception& e) {
Logger::ausf_app().warn(
"NF Instance Registration, could not parse json from the NRF "
"response");
......@@ -220,3 +219,9 @@ void ausf_app::register_nf_instance(std::shared_ptr<itti_sbi_register_nf_instanc
}
curl_global_cleanup();
}
static std::size_t callback(
const char* in, std::size_t size, std::size_t num, std::string* out) {
const std::size_t totalBytes(size * num);
out->append(in, totalBytes);
return totalBytes;
}
......@@ -24,6 +24,7 @@ namespace ausf_application{
void generate_uuid();
void timer_nrf_heartbeat_timeout(timer_id_t timer_id, uint64_t arg2_user);
void register_nf_instance(std::shared_ptr<itti_sbi_register_nf_instance_request> msg);
static std::size_t callback(const char *in, std::size_t size, std::size_t num, std::string *out);
private:
std::string ausf_instance_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