Commit 2febba0a authored by Niuhaiwen's avatar Niuhaiwen

fix some bug about data format and ip address

parent c5f54b5f
......@@ -224,7 +224,7 @@ void *http_server_thread_fn(void *arg)
struct event_base *base = NULL;
struct evhttp *http_server = NULL;
char *http_addr = "192.168.199.235";
char *http_addr = "192.168.199.50";
int http_port = 8081;
/* Initialize the event library */
......
......@@ -1326,7 +1326,7 @@ bool smf_app::handle_nf_status_notification(
strftime(buffer, 80, "%Y-%m-%d %H:%M:%S", info);
json_data["time"] = buffer;
my_json json_data_arr = nlohmann::json::array();
json_data_arr.push_back(json_data);
//json_data_arr.push_back(json_data);
int number=0;
for (int i = 0; i <= nf_num;i++)
{
......@@ -1343,12 +1343,37 @@ bool smf_app::handle_nf_status_notification(
if(nf_status_json_arr[i]["nfType"].dump().compare(json_data["nfType"].dump().c_str())==0)
{
Logger::smf_app().error("the nftype is exist");
if(nf_status_json_arr[i]["nfInstanceId"].dump().compare(json_data["nfInstanceId"].dump().c_str())==0)
{
nf_status_json_arr[i]["nfInstanceName"]=json_data["nfInstanceName"];
nf_status_json_arr[i]["nfEvent"]=json_data["nfEvent"];
nf_status_json_arr[i]["nfStatus"]=json_data["nfStatus"];
nf_status_json_arr[i]["nfInstanceId"]=json_data["nfInstanceId"];
nf_status_json_arr[i]["ipv4Addresses"]=json_data["ipv4Addresses"];
nf_status_json_arr[i]["time"]=json_data["time"];
printf("the Instance ID same\n");
}
//printf("the json nfEvent is %s\n",json_data["nfEvent"].dump().c_str());
else
{
printf("the json nfEvent is %s\n",json_data["nfEvent"].dump().c_str());
if(strstr(json_data["nfEvent"].dump().c_str(),"NF_DEREGISTERED") == NULL)
{
nf_status_json_arr[i]["nfInstanceName"]=json_data["nfInstanceName"];
nf_status_json_arr[i]["nfEvent"]=json_data["nfEvent"];
nf_status_json_arr[i]["nfStatus"]=json_data["nfStatus"];
nf_status_json_arr[i]["nfInstanceId"]=json_data["nfInstanceId"];
nf_status_json_arr[i]["ipv4Addresses"]=json_data["ipv4Addresses"];
nf_status_json_arr[i]["time"]=json_data["time"];
printf("the Instance ID different\n");
}
}
json_data["nfInstanceName"]=nf_status_json_arr[i]["nfInstanceName"];
json_data["nfEvent"]=nf_status_json_arr[i]["nfEvent"];
json_data["nfStatus"]=nf_status_json_arr[i]["nfStatus"];
json_data["nfInstanceId"]=nf_status_json_arr[i]["nfInstanceId"];
json_data["ipv4Addresses"]=nf_status_json_arr[i]["ipv4Addresses"];
json_data["time"]=nf_status_json_arr[i]["time"];
}
else
{
......@@ -1365,11 +1390,11 @@ bool smf_app::handle_nf_status_notification(
" nf_status_json_arr [%d] %s \n", i,
nf_status_json_arr[i].dump().c_str());
}
json_data_arr.push_back(json_data);
Logger::smf_app().error("nf_num %d",nf_num);
//nf_status_json_arr.push_back(json_data);
nf_status_arr_len = nf_status_json_arr.dump().length();
Logger::smf_app().error(
"nf_status_json_data %s \n",nf_status_json_arr.dump().c_str());
//Logger::smf_app().error("nf_status_json_data %s \n",nf_status_json_arr.dump().c_str());
memset(nf_status_arr,'\0',1000);
memcpy(nf_status_arr,nf_status_json_arr.dump().c_str(),nf_status_arr_len);
Logger::smf_app().error(
......
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