Add License information in every source file or script.
[sim/o1-interface.git] / ntsimulator / src / ntsimulator-manager / simulator-operations.h
1 /*************************************************************************
2 *
3 * Copyright 2019 highstreet technologies GmbH and others
4 *
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
8 *
9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
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 ***************************************************************************/
17
18 #ifndef SRC_NTSIMULATOR_MANAGER_SIMULATOR_OPERATIONS_H_
19 #define SRC_NTSIMULATOR_MANAGER_SIMULATOR_OPERATIONS_H_
20
21 #include <curl/curl.h>
22 #include <stdlib.h>
23 #include <stdbool.h>
24 #include <stdio.h>
25
26 #include "sysrepo.h"
27 #include "sysrepo/values.h"
28
29 #include <cjson/cJSON.h>
30
31 #define CURL_MEM_SIZE 2048
32
33
34 /**
35  * Storing the device information
36 */
37
38 typedef struct device {
39         char *device_id;
40         int netconf_port;
41         bool is_mounted;
42         char *operational_state;
43         struct device *next;
44 } device_t;
45
46 typedef struct device_stack {
47         device_t *head;
48         size_t stack_size;
49 } device_stack_t;
50
51 #define URL_AND_CREDENTIALS_MAX_LEN 400
52
53 typedef struct controller
54 {
55         char url[URL_AND_CREDENTIALS_MAX_LEN];
56         char credentials[URL_AND_CREDENTIALS_MAX_LEN];
57         char url_for_keystore_add[URL_AND_CREDENTIALS_MAX_LEN];
58         char url_for_private_key_add[URL_AND_CREDENTIALS_MAX_LEN];
59         char url_for_trusted_ca_add[URL_AND_CREDENTIALS_MAX_LEN];
60 } controller_t;
61
62
63 device_stack_t *new_device_stack(void);
64 void push_device(device_stack_t *theStack, char *dev_id, int port);
65 void pop_device(device_stack_t *theStack);
66 int get_netconf_port_next(device_stack_t *theStack);
67 int get_netconf_port_base(void);
68 char *get_id_last_device(device_stack_t *theStack);
69 int get_current_number_of_devices(device_stack_t *theStack);
70 int get_current_number_of_mounted_devices(device_stack_t *theStack);
71
72
73 /**
74  * cURL utilities
75 */
76
77 struct MemoryStruct {
78   char *memory;
79   size_t size;
80 };
81
82 int _init_curl(void);
83 int cleanup_curl(void);
84
85 int _init_curl_odl(void);
86 int cleanup_curl_odl(void);
87
88 int start_device(device_stack_t *theStack);
89 int stop_device(device_stack_t *theStack);
90
91 int mount_device(device_stack_t *theStack, controller_t controller_details);
92 int unmount_device(device_stack_t *theStack, controller_t controller_details);
93
94 char* get_docker_container_operational_state(device_stack_t *theStack, char *container_id);
95 int get_docker_containers_operational_state_curl(device_stack_t *theStack);
96
97 char* get_docker_container_resource_stats();
98
99 int notification_delay_period_changed(int period);
100 int ves_heartbeat_period_changed(int period);
101 int ves_ip_changed(char *new_ip);
102 int ves_port_changed(int new_port);
103 int ves_registration_changed(cJSON_bool new_bool);
104 int is_netconf_available_changed(cJSON_bool new_bool);
105 int is_ves_available_changed(cJSON_bool new_bool);
106
107
108
109 int add_key_pair_to_odl(controller_t *controller_list, int controller_list_size);
110
111
112 #endif /* SRC_NTSIMULATOR_MANAGER_SIMULATOR_OPERATIONS_H_ */