blob: ceee1300f627a20542992437eb0881c74db13662 [file] [log] [blame]
Alex Stancu29ce3682019-11-02 10:38:59 +02001/*
2 * utils.h
3 *
4 * Created on: Feb 19, 2019
5 * Author: parallels
6 */
7
8#ifndef EXAMPLES_NTSIMULATOR_UTILS_H_
9#define EXAMPLES_NTSIMULATOR_UTILS_H_
10
11#include "sysrepo.h"
12#include "sysrepo/values.h"
13#include "sysrepo/xpath.h"
14
15#include <curl/curl.h>
16#include <stdlib.h>
17#include <stdbool.h>
18#include <stdio.h>
19#include <cjson/cJSON.h>
20
21#define TRUE 1
22#define FALSE 0
23
24#define NETCONF_CONNECTIONS_PER_DEVICE 10
25
26#define PREPARE_ADD_NEW_VALUE(v, num) {\
27 num++;\
28 }
29
30#define CREATE_NEW_VALUE(rc, v, num) {\
31 rc = sr_realloc_values(num, num+1, &v);\
32 if (SR_ERR_OK != rc) {\
33 return rc;\
34 }\
35 num++;\
36 }
37
38void set_curl_common_info_ves(CURL *curl);
39
40long random_at_most(long max);
41void getCurrentDateAndTime(char *date_and_time);
42int getSecondsFromLastQuarterInterval(void);
43int getSecondsFromLastDayInterval(void);
44void getPreviousQuarterInterval(int number_of_intervals, char *date_and_time);
45void getPreviousDayPmTimestamp(int number_of_intervals, char *date_and_time);
46long int getMicrosecondsSinceEpoch(void);
47void prepare_ves_message_curl(CURL *curl);
48
49cJSON* vesCreateCommonEventHeader(char *domain, char *event_type, char *source_name, int seq_id);
50cJSON* vesCreateHeartbeatFields(int heartbeat_interval);
51cJSON* vesCreatePnfRegistrationFields(int port, bool is_tls);
52cJSON* vesCreateFaultFields(char *alarm_condition, char *alarm_object, char *severity, char *date_time, char *specific_problem);
53
54char* readConfigFileInString(void);
55void writeConfigFile(char *config);
56
57int getFaultNotificationDelayPeriodFromConfigJson(void);
58int getVesHeartbeatPeriodFromConfigJson(void);
59char* getVesAuthMethodFromConfigJson(void);
60char* getVesIpFromConfigJson(void);
61int getVesPortFromConfigJson(void);
62int getVesRegistrationFromConfigJson(void);
63int getNetconfAvailableFromConfigJson(void);
64int getVesAvailableFromConfigJson(void);
65
66void generateRandomMacAddress(char *mac_address);
67
68#endif /* EXAMPLES_NTSIMULATOR_UTILS_H_ */