Make CallHome address different that the SDN Controller RESTCONF address.
[sim/o1-interface.git] / ntsimulator / ntsim-ng / utils / nts_utils.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 <stdint.h>
21 #include <cjson/cJSON.h>
22 #include <sysrepo.h>
23
24 typedef enum {
25     UNKNOWN_MAPPING = 0,
26     DOCKER_MAPPING = 1,
27     HOST_MAPPING = 2,
28 } nts_mount_point_addressing_method_t;
29
30 typedef struct {
31     char *protocol;
32     char *ip;
33     uint16_t port;
34     char *auth_method;
35     char *username;
36     char *password;
37
38     char *url;
39 } ves_details_t;
40
41 typedef struct {   
42     char *ip;
43     uint16_t port;
44     char *nc_callhome_ip;
45     uint16_t nc_callhome_port;
46     char *username;
47     char *password;
48
49     char *protocol;
50     char *base_url;
51     char *auth_method;
52 } controller_details_t;
53
54 cJSON* ves_create_common_event_header(const char *domain, const char *event_type, const char *hostname, int port, const char *priority, int seq_id);
55
56 nts_mount_point_addressing_method_t nts_mount_point_addressing_method_get(sr_session_ctx_t *current_session);
57
58 ves_details_t *ves_endpoint_details_get(sr_session_ctx_t *current_session);
59 void ves_details_free(ves_details_t *instance);
60
61 controller_details_t *controller_details_get(sr_session_ctx_t *current_session);
62 void controller_details_free(controller_details_t *instance);
63
64 int nts_utils_populate_info(sr_session_ctx_t *current_session, const char *function_type);
65
66 int nts_vercmp(const char *ver1, const char *ver2);