be44555292c05e4df4cda714379f6ee5d3564d31
[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_HOSTNAME                        "HOSTNAME"
27 #define ENV_VAR_DOCKER_ENGINE_VERSION           "DOCKER_ENGINE_VERSION"
28 #define ENV_VAR_IPV6ENABLED                     "IPv6_ENABLED"
29 #define ENV_VAR_HOST_IP                         "NETCONF_NTS_HOST_IP"
30 #define ENV_VAR_HOST_BASE_PORT                  "NETCONF_NTS_HOST_BASE_PORT"
31 #define ENV_VAR_SSH_CONNECTIONS                 "SSH_CONNECTIONS"
32 #define ENV_VAR_TLS_CONNECTIONS                 "TLS_CONNECTIONS"
33
34 #define ENV_VAR_SDN_CONTROLLER_IP               "SDN_CONTROLLER_IP"
35 #define ENV_VAR_SDN_CONTROLLER_PORT             "SDN_CONTROLLER_PORT"
36 #define ENV_VAR_SDN_CONTROLLER_CALLHOME_PORT    "SDN_CONTROLLER_CALLHOME_PORT"
37 #define ENV_VAR_SDN_CONTROLLER_USERNAME         "SDN_CONTROLLER_USERNAME"
38 #define ENV_VAR_SDN_CONTROLLER_PASSWORD         "SDN_CONTROLLER_PASSWORD"
39
40 #define ENV_VAR_VES_ENDPOINT_PROTOCOL           "VES_ENDPOINT_PROTOCOL"
41 #define ENV_VAR_VES_ENDPOINT_IP                 "VES_ENDPOINT_IP"
42 #define ENV_VAR_VES_ENDPOINT_PORT               "VES_ENDPOINT_PORT"
43 #define ENV_VAR_VES_ENDPOINT_AUTH_METHOD        "VES_ENDPOINT_AUTH_METHOD"
44 #define ENV_VAR_VES_ENDPOINT_USERNAME           "VES_ENDPOINT_USERNAME"
45 #define ENV_VAR_VES_ENDPOINT_PASSWORD           "VES_ENDPOINT_PASSWORD"
46 #define ENV_VAR_VES_ENDPOINT_CERTIFICATE        "VES_ENDPOINT_CERTIFICATE"
47
48 typedef struct {
49     char *path;
50     int count;
51 } custom_list_instances_t;
52
53 typedef struct {
54     char *path;
55     int values_count;
56     char **values;
57     int index;
58 } restrict_schema_t;
59
60 typedef struct {
61     bool container_init;
62     bool nc_server_init;
63
64     bool no_rand;
65     unsigned int fixed_seed;
66     bool operational_only;
67     int verbosity_level;
68     bool loop;
69     bool test_mode;
70
71     bool manager;
72     bool network_function;
73
74     bool exhaustive_test;
75     bool print_root_paths;
76     char *print_structure_xpath;
77     bool populate_all;
78     bool enable_features;
79 } framework_arguments_t;
80
81 typedef struct {
82     int docker_excluded_modules_count;
83     char **docker_excluded_modules;
84
85     int docker_excluded_features_count;
86     char **docker_excluded_features;
87
88     int debug_max_string_size;
89
90     int populate_excluded_modules_count;
91     char **populate_excluded_modules;
92
93     int default_list_instances;
94
95     int custom_list_instances_count;
96     custom_list_instances_t *custom_list_instances;
97
98     int restrict_schema_count;
99     restrict_schema_t *restrict_schema;
100 } framework_config_t;
101
102 typedef struct {
103     char *docker_engine_version;
104
105     char *ip_v4;
106     char *ip_v6;
107     bool ip_v6_enabled;
108
109     char *hostname;
110     char *host_ip;
111     uint16_t host_base_port;
112     uint16_t ssh_connections;
113     uint16_t tls_connections;
114     uint16_t ftp_connections;
115     uint16_t sftp_connections;
116
117     char *sdn_controller_ip;
118     uint16_t sdn_controller_port;
119     uint16_t sdn_controller_callhome_port;
120     char *sdn_controller_username;
121     char *sdn_controller_password;
122
123     char *ves_endpoint_protocol;
124     char *ves_endpoint_ip;
125     uint16_t ves_endpoint_port;
126     char *ves_endpoint_auth_method;
127     char *ves_endpoint_username;
128     char *ves_endpoint_password;
129     char *ves_endpoint_certificate;
130 } framework_environment_t;
131
132 extern framework_arguments_t framework_arguments;
133 extern framework_config_t framework_config;
134 extern framework_environment_t framework_environment;
135
136 volatile sig_atomic_t framework_sigint;
137
138 void framework_init(int argc, char **argv);
139 void framework_free(void);
140
141 //docker-related functions
142 bool framework_is_docker_excluded_module(const char *module);
143 bool framework_is_docker_excluded_feature(const char *feature);
144
145 //populate-related functions
146 bool framework_is_populate_excluded_module(const char *module);
147
148 int framework_populate_get_instance_count(const char *path);
149 char *framework_populate_get_restrict_schema(const char *path);     //returns null if there is no restricted entry, value otherwise. value must be freed