Add supoprt for D release use-case.
[sim/o1-interface.git] / ntsimulator / ntsim-ng / utils / nc_client.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 #define NC_ENABLED_SSH
21 #define NC_ENABLED_TLS
22 #include <libyang/libyang.h>
23 #include <libnetconf2/session.h>
24 #include <libnetconf2/session_client.h>
25 #include <sysrepo.h>
26
27 // void nc_client_init(void);   --imported from libnetconf2, must be called on app init
28 // void nc_client_destroy(void);   --imported from libnetconf2, must be called on app deinit
29
30 typedef struct {
31     struct nc_session *session;
32     struct lyd_node *edit_batch_root;
33
34     char *password;
35 } nc_client_t;
36
37 nc_client_t *nc_client_ssh_connect(const char *host, uint16_t port, const char *username, const char *password);
38 nc_client_t *nc_client_tls_connect(const char *host, uint16_t port);
39 int nc_client_disconnect(nc_client_t *client);
40
41 struct lyd_node *nc_client_send_rpc(nc_client_t *client, struct lyd_node *data, int timeout);
42
43 struct lyd_node *nc_client_get_batch(nc_client_t *client, const char *xpath, int timeout);
44 int nc_client_edit_batch(nc_client_t *client, struct lyd_node *data, int timeout);
45
46 int nc_client_set_item_str(nc_client_t *client, const char *xpath, const char *value);
47 int nc_client_edit_apply_changes(nc_client_t *client, int timeout);
48
49 int lyd_utils_dup(sr_session_ctx_t *session, const char *xpath_s, const char *xpath_d, struct lyd_node **tree);