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