Make CallHome address different that the SDN Controller RESTCONF address.
[sim/o1-interface.git] / ntsimulator / ntsim-ng / core / framework.h
1 /*************************************************************************
2 *
3 * Copyright 2020 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 #pragma once
19
20 #include <argp.h>
21 #include <stdbool.h>
22 #include <stdint.h>
23 #include <unistd.h>
24 #include <signal.h>
25
26 #define NTS_VERSION_FALLBACK                            "1.2.0"
27
28 #define ENV_VAR_NTS_MANUAL                              "NTS_MANUAL"
29 #define ENV_VAR_NTS_BUILD_VERSION                       "NTS_BUILD_VERSION"
30 #define ENV_VAR_NTS_BUILD_TIME                          "NTS_BUILD_DATE"
31 #define ENV_VAR_NTS_FUNCTION_TYPE                       "NTS_FUNCTION_TYPE"
32 #define ENV_VAR_NTS_NF_STANDALONE_START_FEATURES        "NTS_NF_STANDALONE_START_FEATURES"
33 #define ENV_VAR_NTS_NF_MOUNT_POINT_ADDRESSING_METHOD    "NTS_NF_MOUNT_POINT_ADDRESSING_METHOD"
34
35 #define ENV_VAR_DOCKER_REPOSITORY                       "DOCKER_REPOSITORY"
36 #define ENV_VAR_DOCKER_ENGINE_VERSION                   "DOCKER_ENGINE_VERSION"
37 #define ENV_VAR_HOSTNAME                                "HOSTNAME"
38 #define ENV_VAR_IPV6ENABLED                             "IPv6_ENABLED"
39 #define ENV_VAR_SSH_CONNECTIONS                         "SSH_CONNECTIONS"
40 #define ENV_VAR_TLS_CONNECTIONS                         "TLS_CONNECTIONS"
41
42 #define ENV_VAR_HOST_IP                                 "NTS_HOST_IP"
43 #define ENV_VAR_HOST_BASE_PORT                          "NTS_HOST_BASE_PORT"
44 #define ENV_VAR_HOST_NETCONF_SSH_BASE_PORT              "NTS_HOST_NETCONF_SSH_BASE_PORT"
45 #define ENV_VAR_HOST_NETCONF_TLS_BASE_PORT              "NTS_HOST_NETCONF_TLS_BASE_PORT"
46 #define ENV_VAR_HOST_TRANSFER_FTP_BASE_PORT             "NTS_HOST_TRANSFER_FTP_BASE_PORT"
47 #define ENV_VAR_HOST_TRANSFER_SFTP_BASE_PORT            "NTS_HOST_TRANSFER_SFTP_BASE_PORT"
48
49 #define ENV_VAR_SDN_CONTROLLER_PROTOCOL                 "SDN_CONTROLLER_PROTOCOL"
50 #define ENV_VAR_SDN_CONTROLLER_IP                       "SDN_CONTROLLER_IP"
51 #define ENV_VAR_SDN_CONTROLLER_PORT                     "SDN_CONTROLLER_PORT"
52 #define ENV_VAR_SDN_CONTROLLER_CALLHOME_IP              "SDN_CONTROLLER_CALLHOME_IP"
53 #define ENV_VAR_SDN_CONTROLLER_CALLHOME_PORT            "SDN_CONTROLLER_CALLHOME_PORT"
54 #define ENV_VAR_SDN_CONTROLLER_USERNAME                 "SDN_CONTROLLER_USERNAME"
55 #define ENV_VAR_SDN_CONTROLLER_PASSWORD                 "SDN_CONTROLLER_PASSWORD"
56
57 #define ENV_VAR_VES_COMMON_HEADER_VERSION               "VES_COMMON_HEADER_VERSION"
58 #define ENV_VAR_VES_ENDPOINT_PROTOCOL                   "VES_ENDPOINT_PROTOCOL"
59 #define ENV_VAR_VES_ENDPOINT_IP                         "VES_ENDPOINT_IP"
60 #define ENV_VAR_VES_ENDPOINT_PORT                       "VES_ENDPOINT_PORT"
61 #define ENV_VAR_VES_ENDPOINT_AUTH_METHOD                "VES_ENDPOINT_AUTH_METHOD"
62 #define ENV_VAR_VES_ENDPOINT_USERNAME                   "VES_ENDPOINT_USERNAME"
63 #define ENV_VAR_VES_ENDPOINT_PASSWORD                   "VES_ENDPOINT_PASSWORD"
64 #define ENV_VAR_VES_ENDPOINT_CERTIFICATE                "VES_ENDPOINT_CERTIFICATE"
65
66 typedef enum {
67     NTS_MODE_DEFAULT = 0,
68     NTS_MODE_CONTAINER_INIT,
69     NTS_MODE_SUPERVISOR,
70     NTS_MODE_MANAGER,
71     NTS_MODE_NETWORK_FUNCTION,
72     NTS_MODE_BLANK,
73     NTS_MODE_GENERATE_DATA,
74     NTS_MODE_TEST,
75 } nts_mode_t;
76
77 typedef struct {
78     nts_mode_t nts_mode;
79
80     int argc;
81     char **argv;    //no-copy
82
83     bool no_rand;
84     unsigned int fixed_seed;
85     int verbosity_level;
86     
87     bool print_root_paths;
88     char *print_structure_xpath;
89 } framework_arguments_t;
90
91 typedef struct {
92     struct  {
93         bool manual;
94         char *version;
95         char *build_time;
96         char *function_type;
97         char *nf_standalone_start_features;
98         char *nf_mount_point_addressing_method;
99     } nts;
100
101     struct {
102         char *docker_repository;
103         char *docker_engine_version;
104
105         char *hostname;
106         char *ip_v4;
107         char *ip_v6;
108         bool ip_v6_enabled;
109         uint16_t ssh_connections;
110         uint16_t tls_connections;
111         uint16_t ftp_connections;
112         uint16_t sftp_connections;
113     } settings;
114
115     struct {
116         char *ip;
117         uint16_t base_port;
118         uint16_t ssh_base_port;
119         uint16_t tls_base_port;
120         uint16_t ftp_base_port;
121         uint16_t sftp_base_port;
122     } host;
123
124     struct {
125         char *protocol;
126         char *ip;
127         uint16_t port;
128         char *callhome_ip;
129         uint16_t callhome_port;
130         char *username;
131         char *password;
132         bool port_absent;
133     } sdn_controller;
134
135     struct {
136         char *common_header_version;
137
138         char *protocol;
139         char *ip;
140         uint16_t port;
141         char *auth_method;
142         char *username;
143         char *password;
144         char *certificate;
145         bool port_absent;
146     } ves_endpoint;
147 } framework_environment_t;
148
149 typedef struct {
150     char *name;
151     char *path;
152     char **args;
153     int args_count;
154     bool nomanual;
155     bool autorestart;
156     char *stdout_path;
157     char *stderr_path;
158 } supervisor_rules_t;
159
160 typedef struct {
161     char *path;
162     int count;
163 } custom_list_instances_t;
164
165 typedef struct {
166     char *path;
167     int values_count;
168     char **values;
169     int index;
170 } restrict_schema_t;
171
172 typedef struct {
173     struct {
174         int excluded_modules_count;
175         char **excluded_modules;
176
177         int excluded_features_count;
178         char **excluded_features;
179     } docker;
180
181     struct {
182         int rules_count;
183         supervisor_rules_t *rules;
184     } supervisor;
185
186     struct {
187         int debug_max_string_size;
188
189         int excluded_modules_count;
190         char **excluded_modules;
191
192         int default_list_instances;
193
194         int custom_list_instances_count;
195         custom_list_instances_t *custom_list_instances;
196
197         int restrict_schema_count;
198         restrict_schema_t *restrict_schema;
199     } datastore_generate;
200
201     struct {
202         bool random_generation_enabled;
203
204         int preg_operational_count;
205         char **preg_operational;
206
207         int preg_running_count;
208         char **preg_running;
209     } datastore_populate;   
210 } framework_config_t;
211
212 extern framework_arguments_t framework_arguments;
213 extern framework_environment_t framework_environment;
214 extern framework_config_t framework_config;
215
216 volatile sig_atomic_t framework_sigint;
217
218 int framework_init(int argc, char **argv);
219 void framework_free(void);