blob: 189431b506d2cc977e269f2df224dc5b7553d60f [file] [log] [blame]
romanc1d2b092023-02-02 08:58:27 +01001/**
romane028ef92023-02-24 16:33:08 +01002 * @file server_config.h
romanc1d2b092023-02-02 08:58:27 +01003 * @author Roman Janota <janota@cesnet.cz>
4 * @brief libnetconf2 server configuration
5 *
6 * @copyright
7 * Copyright (c) 2015 - 2021 CESNET, z.s.p.o.
8 *
9 * This source code is licensed under BSD 3-Clause License (the "License").
10 * You may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * https://opensource.org/licenses/BSD-3-Clause
14 */
15
16#ifndef NC_CONFIG_SERVER_H_
17#define NC_CONFIG_SERVER_H_
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23#include <libyang/libyang.h>
24#include <stdint.h>
25
26#include "netconf.h"
27#include "session.h"
28#include "session_p.h"
29
30/**
31 * @brief Configure server based on the given data.
32 *
33 * Expected data is a validated instance of a ietf-netconf-server YANG data.
34 * The data must be in the diff format and supported operations are: create, replace,
35 * delete and none. Context must already have implemented the required modules, see
36 * ::nc_config_load_modules().
37 *
38 * @param[in] data ietf-netconf-server YANG data.
39 * @return 0 on success, 1 on error.
40 */
41int nc_server_config_setup(const struct lyd_node *data);
42
43/**
44 * @brief Configure server based on the given ietf-netconf-server YANG data.
45 * Wrapper around ::nc_config_setup_server() hiding work with parsing the data.
46 *
47 * @param[in] ctx libyang context.
48 * @param[in] path Path to the file with YANG data in XML format.
49 * @return 0 on success, 1 on error.
50 */
51int nc_server_config_setup_path(const struct ly_ctx *ctx, const char *path);
52
53/**
54 * @brief Implements all the required modules and their features in the context.
55 * Needs to be called before any other configuration functions.
56 *
57 * If ctx is :
58 * - NULL: a new context will be created and if the call is successful you have to free it,
59 * - non NULL: modules will simply be implemented.
60 *
61 * Implemented modules: ietf-netconf-server, ietf-x509-cert-to-name, ietf-crypto-types,
62 * ietf-tcp-common, ietf-ssh-common, iana-ssh-encryption-algs, iana-ssh-key-exchange-algs,
63 * iana-ssh-mac-algs, iana-ssh-public-key-algs, ietf-keystore, ietf-ssh-server, ietf-truststore,
64 * ietf-tls-server and libnetconf2-netconf-server.
65 *
66 * @param[in, out] ctx Optional context in which the modules will be implemented. Created if ctx is null.
67 * @return 0 on success, 1 on error.
68 */
69int nc_server_config_load_modules(struct ly_ctx **ctx);
70
71/**
72 * @brief Configures the listen subtree in the ietf-netconf-server module.
73 *
74 * @param[in] op Operation to be done on the subtree. Only does something if the operation is NC_OP_DELETE.
75 * @return 0 on success, 1 on error.
76 */
romane028ef92023-02-24 16:33:08 +010077int nc_server_config_listen(NC_OPERATION op);
romanc1d2b092023-02-02 08:58:27 +010078
roman45cec4e2023-02-17 10:21:39 +010079/**
80 * @brief Deletes every key stored in the keystore.
81 */
82void nc_server_config_del_keystore(void);
83
romanc1d2b092023-02-02 08:58:27 +010084#ifdef __cplusplus
85}
86#endif
87
88#endif /* NC_SESSION_SERVER_H_ */