-/*
- * heartbeat.c
- *
- * Created on: Oct 24, 2019
- * Author: parallels
- */
+/*************************************************************************
+*
+* Copyright 2019 highstreet technologies GmbH and others
+*
+* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+*
+* 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.
+***************************************************************************/
#include <stdio.h>
#include <stdlib.h>
return SR_ERR_OK;
}
-//static void prepare_ves_message_curl(void)
-//{
-// curl_easy_reset(curl);
-// set_curl_common_info();
-//
-// char *ves_ip = getVesIpFromConfigJson();
-// int ves_port = getVesPortFromConfigJson();
-//
-// char url[100];
-// sprintf(url, "http://%s:%d/eventListener/v7", ves_ip, ves_port);
-// curl_easy_setopt(curl, CURLOPT_URL, url);
-//
-// free(ves_ip);
-//
-//// curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
-//
-// return;
-//}
/*
* Heartbeat payload example
*
prepare_ves_message_curl(curl);
cJSON *postDataJson = cJSON_CreateObject();
+ if (postDataJson == NULL)
+ {
+ printf("Could not create JSON object: postDataJson\n");
+ return 1;
+ }
cJSON *event = cJSON_CreateObject();
if (event == NULL)
if (commonEventHeader == NULL)
{
printf("Could not create JSON object: commonEventHeader\n");
+ cJSON_Delete(postDataJson);
return 1;
}
cJSON_AddItemToObject(event, "commonEventHeader", commonEventHeader);
if (heartbeatFields == NULL)
{
printf("Could not create JSON object: heartbeatFields\n");
+ cJSON_Delete(postDataJson);
return 1;
}
cJSON_AddItemToObject(event, "heartbeatFields", heartbeatFields);
if (res != CURLE_OK)
{
- printf("Failed to send cURL...\n");
return SR_ERR_OPERATION_FAILED;
}
prepare_ves_message_curl(curl);
cJSON *postDataJson = cJSON_CreateObject();
+ if (postDataJson == NULL)
+ {
+ printf("Could not create JSON object: postDataJson\n");
+ return 1;
+ }
cJSON *event = cJSON_CreateObject();
if (event == NULL)
{
printf("Could not create JSON object: event\n");
+ cJSON_Delete(postDataJson);
return 1;
}
cJSON_AddItemToObject(postDataJson, "event", event);
if (commonEventHeader == NULL)
{
printf("Could not create JSON object: commonEventHeader\n");
+ cJSON_Delete(postDataJson);
return 1;
}
cJSON_AddItemToObject(event, "commonEventHeader", commonEventHeader);
if (pnfRegistrationFields == NULL)
{
printf("Could not create JSON object: pnfRegistrationFields\n");
+ cJSON_Delete(postDataJson);
return 1;
}
cJSON_AddItemToObject(event, "pnfRegistrationFields", pnfRegistrationFields);