1 /*************************************************************************
3 * Copyright 2019 highstreet technologies GmbH and others
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 ***************************************************************************/
18 #ifndef EXAMPLES_NTSIMULATOR_UTILS_H_
19 #define EXAMPLES_NTSIMULATOR_UTILS_H_
22 #include "sysrepo/values.h"
23 #include "sysrepo/xpath.h"
25 #include <curl/curl.h>
29 #include <cjson/cJSON.h>
34 #define NETCONF_CONNECTIONS_PER_DEVICE 10
36 #define PREPARE_ADD_NEW_VALUE(v, num) {\
40 #define CREATE_NEW_VALUE(rc, v, num) {\
41 rc = sr_realloc_values(num, num+1, &v);\
42 if (SR_ERR_OK != rc) {\
48 void set_curl_common_info_ves(CURL *curl);
50 long random_at_most(long max);
51 void getCurrentDateAndTime(char *date_and_time);
52 int getSecondsFromLastQuarterInterval(void);
53 int getSecondsFromLastDayInterval(void);
54 void getPreviousQuarterInterval(int number_of_intervals, char *date_and_time);
55 void getPreviousDayPmTimestamp(int number_of_intervals, char *date_and_time);
56 long int getMicrosecondsSinceEpoch(void);
57 void prepare_ves_message_curl(CURL *curl);
59 cJSON* vesCreateCommonEventHeader(char *domain, char *event_type, char *source_name, int seq_id);
60 cJSON* vesCreateHeartbeatFields(int heartbeat_interval);
61 cJSON* vesCreatePnfRegistrationFields(int port, bool is_tls);
62 cJSON* vesCreateFaultFields(char *alarm_condition, char *alarm_object, char *severity, char *date_time, char *specific_problem);
64 char* readConfigFileInString(void);
65 void writeConfigFile(char *config);
67 int getFaultNotificationDelayPeriodFromConfigJson(void);
68 int getVesHeartbeatPeriodFromConfigJson(void);
69 char* getVesAuthMethodFromConfigJson(void);
70 char* getVesIpFromConfigJson(void);
71 int getVesPortFromConfigJson(void);
72 int getVesRegistrationFromConfigJson(void);
73 int getNetconfAvailableFromConfigJson(void);
74 int getVesAvailableFromConfigJson(void);
76 void generateRandomMacAddress(char *mac_address);
78 #endif /* EXAMPLES_NTSIMULATOR_UTILS_H_ */