blob: f0bc71cd81248b165e5a38a9804ad973e8c76664 [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
roman3f9b65c2023-06-05 14:26:58 +02007 * Copyright (c) 2023 CESNET, z.s.p.o.
romanc1d2b092023-02-02 08:58:27 +01008 *
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
romand348b942023-10-13 14:32:19 +020023#include <stdarg.h>
romanc1d2b092023-02-02 08:58:27 +010024#include <stdint.h>
25
roman3f9b65c2023-06-05 14:26:58 +020026#include <libyang/libyang.h>
27
romanc1d2b092023-02-02 08:58:27 +010028#include "session.h"
romanc1d2b092023-02-02 08:58:27 +010029
30/**
roman8ba6efa2023-07-12 15:27:52 +020031 * @defgroup server_config Server Configuration
32 * @ingroup server
33 *
34 * @brief Server-side configuration creation and application
35 * @{
36 */
37
38/**
roman35120972023-08-08 10:39:12 +020039 * @} Server Configuration
40 */
41
42/**
43 * @defgroup server_config_functions Server Configuration Functions
44 * @ingroup server_config
45 *
46 * @brief Server-side configuration functions
47 * @{
48 */
49
50/**
51 * @brief Implements all the required modules and their features in the context.
52 * Needs to be called before any other configuration functions.
53 *
54 * If ctx is :
55 * - NULL: a new context will be created and if the call is successful you have to free it,
56 * - non NULL: modules will simply be implemented.
57 *
58 * Implemented modules: ietf-netconf-server, ietf-x509-cert-to-name, ietf-crypto-types,
59 * ietf-tcp-common, ietf-ssh-common, iana-ssh-encryption-algs, iana-ssh-key-exchange-algs,
60 * iana-ssh-mac-algs, iana-ssh-public-key-algs, ietf-keystore, ietf-ssh-server, ietf-truststore,
61 * ietf-tls-server and libnetconf2-netconf-server.
62 *
roman6430c152023-10-12 11:28:47 +020063 * @param[in, out] ctx Optional context in which the modules will be implemented. Created if *ctx is null.
roman35120972023-08-08 10:39:12 +020064 * @return 0 on success, 1 on error.
65 */
66int nc_server_config_load_modules(struct ly_ctx **ctx);
67
68/**
roman6430c152023-10-12 11:28:47 +020069 * @brief Configure server based on the given diff.
romanc1d2b092023-02-02 08:58:27 +010070 *
roman6430c152023-10-12 11:28:47 +020071 * Context must already have implemented the required modules, see ::nc_server_config_load_modules().
romanc1d2b092023-02-02 08:58:27 +010072 *
roman6430c152023-10-12 11:28:47 +020073 * @param[in] diff YANG diff belonging to either ietf-netconf-server, ietf-keystore or ietf-truststore modules.
Roytakb2794852023-10-18 14:30:22 +020074 * The top level node HAS to have an operation (create, replace, delete or none).
romanc1d2b092023-02-02 08:58:27 +010075 * @return 0 on success, 1 on error.
76 */
romanf6f37a52023-05-25 14:27:51 +020077int nc_server_config_setup_diff(const struct lyd_node *diff);
romanc1d2b092023-02-02 08:58:27 +010078
79/**
romanf02273a2023-05-25 09:44:11 +020080 * @brief Configure server based on the given data.
81 *
romanf02273a2023-05-25 09:44:11 +020082 * Behaves as if all the nodes in data had the replace operation. That means that the current configuration will be deleted
roman6430c152023-10-12 11:28:47 +020083 * and just the given data will be applied.
roman0f5fa422023-08-07 09:03:24 +020084 * Context must already have implemented the required modules, see ::nc_server_config_load_modules().
romanf02273a2023-05-25 09:44:11 +020085 *
roman6430c152023-10-12 11:28:47 +020086 * @param[in] data YANG data belonging to either ietf-netconf-server, ietf-keystore or ietf-truststore modules.
Roytakb2794852023-10-18 14:30:22 +020087 * This data __must be valid__. No node can have an operation attribute.
romanf02273a2023-05-25 09:44:11 +020088 * @return 0 on success, 1 on error.
89 */
romanf6f37a52023-05-25 14:27:51 +020090int nc_server_config_setup_data(const struct lyd_node *data);
romanf02273a2023-05-25 09:44:11 +020091
92/**
roman6430c152023-10-12 11:28:47 +020093 * @brief Configure server based on the given data stored in a file.
94 *
roman0f5fa422023-08-07 09:03:24 +020095 * Wrapper around ::nc_server_config_setup_data() hiding work with parsing the data.
roman6430c152023-10-12 11:28:47 +020096 * Context must already have implemented the required modules, see ::nc_server_config_load_modules().
romanc1d2b092023-02-02 08:58:27 +010097 *
98 * @param[in] ctx libyang context.
roman6430c152023-10-12 11:28:47 +020099 * @param[in] path Path to a file with ietf-netconf-server, ietf-keystore or ietf-truststore YANG data.
Roytakb2794852023-10-18 14:30:22 +0200100 * This data __must be valid__. No node can have an operation attribute.
romanc1d2b092023-02-02 08:58:27 +0100101 * @return 0 on success, 1 on error.
102 */
103int nc_server_config_setup_path(const struct ly_ctx *ctx, const char *path);
104
roman2eab4742023-06-06 10:00:26 +0200105#ifdef NC_ENABLED_SSH_TLS
106
romanc1d2b092023-02-02 08:58:27 +0100107/**
roman6430c152023-10-12 11:28:47 +0200108 * @brief Creates new YANG configuration data nodes for address and port.
roman9b1379c2023-03-31 10:11:10 +0200109 *
roman9b1379c2023-03-31 10:11:10 +0200110 * @param[in] ctx libyang context.
111 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman35120972023-08-08 10:39:12 +0200112 * If an endpoint with this identifier already exists, its contents might be changed.
roman3f9b65c2023-06-05 14:26:58 +0200113 * @param[in] transport Either SSH or TLS transport for the given endpoint.
114 * @param[in] address New listening address.
115 * @param[in] port New listening port.
roman9b1379c2023-03-31 10:11:10 +0200116 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
117 * Otherwise the new YANG data will be added to the previous data and may override it.
118 * @return 0 on success, non-zero otherwise.
roman45cec4e2023-02-17 10:21:39 +0100119 */
Roytakb2794852023-10-18 14:30:22 +0200120int nc_server_config_add_address_port(const struct ly_ctx *ctx, const char *endpt_name, NC_TRANSPORT_IMPL transport,
roman142718b2023-06-29 09:15:29 +0200121 const char *address, uint16_t port, struct lyd_node **config);
roman3f9b65c2023-06-05 14:26:58 +0200122
roman8ba6efa2023-07-12 15:27:52 +0200123#endif /* NC_ENABLED_SSH_TLS */
124
125/**
romand0b78372023-09-14 10:06:03 +0200126 * @brief Creates new YANG data nodes for a UNIX socket.
127 *
128 * @param[in] ctx libyang context.
129 * @param[in] endpt_name Arbitrary identifier of the endpoint.
130 * If an endpoint with this identifier already exists, its contents might be changed.
131 * @param[in] path Path to the socket.
132 * @param[in] mode New mode, use -1 for default.
133 * @param[in] uid New uid, use -1 for default
134 * @param[in] gid New gid, use -1 for default
135 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
136 * Otherwise the new YANG data will be added to the previous data and may override it.
137 * @return 0 on success, non-zero otherwise.
138 */
Roytakb2794852023-10-18 14:30:22 +0200139int nc_server_config_add_unix_socket(const struct ly_ctx *ctx, const char *endpt_name, const char *path,
romand0b78372023-09-14 10:06:03 +0200140 mode_t mode, uid_t uid, gid_t gid, struct lyd_node **config);
141
142/**
roman8ba6efa2023-07-12 15:27:52 +0200143 * @brief Deletes an endpoint from the YANG data.
144 *
145 * @param[in] endpt_name Optional identifier of an endpoint to be deleted.
146 * If NULL, all of the endpoints will be deleted.
roman35120972023-08-08 10:39:12 +0200147 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200148 * @return 0 on success, non-zero otherwise.
149 */
Roytakb2794852023-10-18 14:30:22 +0200150int nc_server_config_del_endpt(const char *endpt_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200151
152#ifdef NC_ENABLED_SSH_TLS
153
154/**
155 * @brief Creates new YANG data nodes for an asymmetric key in the keystore.
156 *
157 * @param[in] ctx libyang context.
roman13145912023-08-17 15:36:54 +0200158 * @param[in] ti Transport in which the key pair will be used. Either SSH or TLS.
roman12c3d522023-07-26 13:39:30 +0200159 * @param[in] asym_key_name Identifier of the asymmetric key pair.
160 * This identifier is used to reference the key pair.
roman8ba6efa2023-07-12 15:27:52 +0200161 * @param[in] privkey_path Path to a private key file.
162 * @param[in] pubkey_path Optional path a public key file.
163 * If not supplied, it will be generated from the private key.
164 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
165 * Otherwise the new YANG data will be added to the previous data and may override it.
166 * @return 0 on success, non-zero otherwise.
167 */
Roytakb2794852023-10-18 14:30:22 +0200168int nc_server_config_add_keystore_asym_key(const struct ly_ctx *ctx, NC_TRANSPORT_IMPL ti, const char *asym_key_name,
roman13145912023-08-17 15:36:54 +0200169 const char *privkey_path, const char *pubkey_path, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200170
171/**
172 * @brief Deletes a keystore's asymmetric key from the YANG data.
173 *
roman12c3d522023-07-26 13:39:30 +0200174 * @param[in] asym_key_name Optional identifier of the asymmetric key to be deleted.
roman8ba6efa2023-07-12 15:27:52 +0200175 * If NULL, all of the asymmetric keys in the keystore will be deleted.
176 * @param[in,out] config Configuration YANG data tree.
177 * @return 0 on success, non-zero otherwise.
178 */
Roytakb2794852023-10-18 14:30:22 +0200179int nc_server_config_del_keystore_asym_key(const char *asym_key_name, struct lyd_node **config);
roman12c3d522023-07-26 13:39:30 +0200180
181/**
182 * @brief Creates new YANG data nodes for a certificate in the keystore.
183 *
roman6430c152023-10-12 11:28:47 +0200184 * A certificate can not exist without its asymmetric key, so you must create an asymmetric key
185 * with the same identifier you pass to this function.
roman12c3d522023-07-26 13:39:30 +0200186 *
187 * @param[in] ctx libyang context.
188 * @param[in] asym_key_name Arbitrary identifier of the asymmetric key.
189 * If an asymmetric key pair with this name already exists, its contents will be changed.
190 * @param[in] cert_name Arbitrary identifier of the key pair's certificate.
191 * If a certificate with this name already exists, its contents will be changed.
192 * @param[in] cert_path Path to the PEM encoded certificate file.
193 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
194 * Otherwise the new YANG data will be added to the previous data and may override it.
195 * @return 0 on success, non-zero otherwise.
196 */
Roytakb2794852023-10-18 14:30:22 +0200197int nc_server_config_add_keystore_cert(const struct ly_ctx *ctx, const char *asym_key_name, const char *cert_name,
roman12c3d522023-07-26 13:39:30 +0200198 const char *cert_path, struct lyd_node **config);
199
200/**
201 * @brief Deletes a keystore's certificate from the YANG data.
202 *
203 * @param[in] asym_key_name Identifier of an existing asymmetric key pair.
204 * @param[in] cert_name Optional identifier of a certificate to be deleted.
205 * If NULL, all of the certificates belonging to the asymmetric key pair will be deleted.
206 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
207 * Otherwise the new YANG data will be added to the previous data and may override it.
208 * @return 0 on success, non-zero otherwise.
209 */
Roytakb2794852023-10-18 14:30:22 +0200210int nc_server_config_del_keystore_cert(const char *asym_key_name, const char *cert_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200211
212/**
213 * @brief Creates new YANG data nodes for a public key in the truststore.
214 *
215 * @param[in] ctx libyang context.
roman12c3d522023-07-26 13:39:30 +0200216 * @param[in] pub_bag_name Arbitrary identifier of the public key bag.
roman8ba6efa2023-07-12 15:27:52 +0200217 * This name is used to reference the public keys in the bag.
218 * If a public key bag with this name already exists, its contents will be changed.
219 * @param[in] pubkey_name Arbitrary identifier of the public key.
roman12c3d522023-07-26 13:39:30 +0200220 * If a public key with this name already exists in the given bag, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +0200221 * @param[in] pubkey_path Path to a file containing a public key.
222 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
223 * Otherwise the new YANG data will be added to the previous data and may override it.
224 * @return 0 on success, non-zero otherwise.
225 */
romand348b942023-10-13 14:32:19 +0200226int nc_server_config_add_truststore_pubkey(const struct ly_ctx *ctx, const char *pub_bag_name, const char *pubkey_name,
227 const char *pubkey_path, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200228
229/**
230 * @brief Deletes a truststore's public key from the YANG data.
231 *
roman12c3d522023-07-26 13:39:30 +0200232 * @param[in] pub_bag_name Identifier of an existing public key bag.
roman8ba6efa2023-07-12 15:27:52 +0200233 * @param[in] pubkey_name Optional identifier of a public key to be deleted.
234 * If NULL, all of the public keys in the given bag will be deleted.
235 * @param[in,out] config Configuration YANG data tree.
236 * @return 0 on success, non-zero otherwise.
237 */
Roytakb2794852023-10-18 14:30:22 +0200238int nc_server_config_del_truststore_pubkey(const char *pub_bag_name, const char *pubkey_name, struct lyd_node **config);
roman12c3d522023-07-26 13:39:30 +0200239
240/**
241 * @brief Creates new YANG data nodes for a certificate in the truststore.
242 *
243 * @param[in] ctx libyang context.
244 * @param[in] cert_bag_name Arbitrary identifier of the certificate bag.
245 * This name is used to reference the certificates in the bag.
246 * If a certificate bag with this name already exists, its contents will be changed.
247 * @param[in] cert_name Arbitrary identifier of the certificate.
248 * If a certificate with this name already exists in the given bag, its contents will be changed.
249 * @param[in] cert_path Path to a file containing a PEM encoded certificate.
250 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
251 * Otherwise the new YANG data will be added to the previous data and may override it.
252 * @return 0 on success, non-zero otherwise.
253 */
Roytakb2794852023-10-18 14:30:22 +0200254int nc_server_config_add_truststore_cert(const struct ly_ctx *ctx, const char *cert_bag_name, const char *cert_name,
roman12c3d522023-07-26 13:39:30 +0200255 const char *cert_path, struct lyd_node **config);
256
257/**
258 * @brief Deletes a truststore's certificate from the YANG data.
259 *
260 * @param[in] cert_bag_name Identifier of an existing certificate bag.
261 * @param[in] cert_name Optional identifier of a certificate to be deleted.
262 * If NULL, all of the certificates in the given bag will be deleted.
263 * @param[in,out] config Configuration YANG data tree.
264 * @return 0 on success, non-zero otherwise.
265 */
Roytakb2794852023-10-18 14:30:22 +0200266int nc_server_config_del_truststore_cert(const char *cert_bag_name,
roman12c3d522023-07-26 13:39:30 +0200267 const char *cert_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200268
269/**
roman35120972023-08-08 10:39:12 +0200270 * @} Server Configuration Functions
roman8ba6efa2023-07-12 15:27:52 +0200271 */
272
273/**
274 * @defgroup server_config_ssh SSH Server Configuration
275 * @ingroup server_config
276 *
277 * @brief SSH server configuration creation and deletion
278 * @{
279 */
280
roman3f9b65c2023-06-05 14:26:58 +0200281/**
282 * @brief Creates new YANG configuration data nodes for a hostkey.
283 *
284 * @param[in] ctx libyang context.
285 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200286 * If an endpoint with this identifier already exists, its hostkey might be changed.
roman3f9b65c2023-06-05 14:26:58 +0200287 * @param[in] hostkey_name Arbitrary identifier of the hostkey.
roman142718b2023-06-29 09:15:29 +0200288 * If a hostkey with this identifier already exists, its contents will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200289 * @param[in] privkey_path Path to a file containing a private key.
290 * The private key has to be in a PEM format. Only RSA and ECDSA keys are supported.
roman35120972023-08-08 10:39:12 +0200291 * @param[in] pubkey_path Optional path to a file containing a public key. If NULL, public key will be
roman3f9b65c2023-06-05 14:26:58 +0200292 * generated from the private key.
293 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
294 * Otherwise the new YANG data will be added to the previous data and may override it.
295 * @return 0 on success, non-zero otherwise.
296 */
Roytakb2794852023-10-18 14:30:22 +0200297int nc_server_config_add_ssh_hostkey(const struct ly_ctx *ctx, const char *endpt_name, const char *hostkey_name,
roman8ba6efa2023-07-12 15:27:52 +0200298 const char *privkey_path, const char *pubkey_path, struct lyd_node **config);
299
300/**
301 * @brief Deletes a hostkey from the YANG data.
302 *
303 * @param[in] ctx libyang context.
304 * @param[in] endpt_name Identifier of an existing endpoint.
305 * @param[in] hostkey_name Optional identifier of the hostkey to be deleted.
306 * If NULL, all of the hostkeys on this endpoint will be deleted.
307 * @param[in,out] config Configuration YANG data tree.
308 * @return 0 on success, non-zero otherwise.
309 */
Roytakb2794852023-10-18 14:30:22 +0200310int nc_server_config_del_ssh_hostkey(const struct ly_ctx *ctx, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +0200311 const char *hostkey_name, struct lyd_node **config);
312
313/**
romand348b942023-10-13 14:32:19 +0200314 * @brief Creates new YANG data nodes for a reference to an asymmetric key located in the keystore.
315 *
316 * This asymmetric key pair will be used as the SSH hostkey.
317 *
318 * @param[in] ctx libyang context.
319 * @param[in] endpt_name Arbitrary identifier of an endpoint.
320 * If an endpoint with this identifier already exists, its contents will be changed.
321 * @param[in] hostkey_name Arbitrary identifier of the endpoint's hostkey.
322 * If an endpoint's hostkey with this identifier already exists, its contents will be changed.
323 * @param[in] keystore_reference Name of the asymmetric key pair to be referenced and used as a hostkey.
324 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
325 * Otherwise the new YANG data will be added to the previous data and may override it.
326 * @return 0 on success, non-zero otherwise.
327 */
328int nc_server_config_add_ssh_keystore_ref(const struct ly_ctx *ctx, const char *endpt_name, const char *hostkey_name,
329 const char *keystore_reference, struct lyd_node **config);
330
331/**
332 * @brief Deletes a keystore reference from the YANG data.
333 *
334 * @param[in] endpt_name Identifier of an existing endpoint.
335 * @param[in] hostkey_name Identifier of an existing hostkey on the given endpoint.
336 * @param[in,out] config Configuration YANG data tree.
337 * @return 0 on success, non-zero otherwise.
338 */
339int nc_server_config_del_ssh_keystore_ref(const char *endpt_name, const char *hostkey_name,
340 struct lyd_node **config);
341
342/**
roman8ba6efa2023-07-12 15:27:52 +0200343 * @brief Creates new YANG configuration data nodes for an SSH user's public key authentication method.
344 *
345 * @param[in] ctx libyang context.
346 * @param[in] endpt_name Arbitrary identifier of the endpoint.
347 * If an endpoint with this identifier already exists, its user might be changed.
348 * @param[in] user_name Arbitrary identifier of the user.
349 * If an user with this identifier already exists, its contents will be changed.
350 * @param[in] pubkey_name Arbitrary identifier of the user's public key.
351 * If a public key with this identifier already exists for this user, its contents will be changed.
352 * @param[in] pubkey_path Path to a file containing the user's public key.
353 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
354 * Otherwise the new YANG data will be added to the previous data and may override it.
355 * @return 0 on success, non-zero otherwise.
356 */
Roytakb2794852023-10-18 14:30:22 +0200357int nc_server_config_add_ssh_user_pubkey(const struct ly_ctx *ctx, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +0200358 const char *user_name, const char *pubkey_name, const char *pubkey_path, struct lyd_node **config);
359
360/**
361 * @brief Deletes an SSH user's public key from the YANG data.
362 *
363 * @param[in] endpt_name Identifier of an existing endpoint.
364 * @param[in] user_name Identifier of an existing user on the given endpoint.
365 * @param[in] pubkey_name Optional identifier of a public key to be deleted.
366 * If NULL, all of the users public keys will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200367 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200368 * @return 0 on success, non-zero otherwise.
369 */
Roytakb2794852023-10-18 14:30:22 +0200370int nc_server_config_del_ssh_user_pubkey(const char *endpt_name, const char *user_name,
roman8ba6efa2023-07-12 15:27:52 +0200371 const char *pubkey_name, struct lyd_node **config);
372
373/**
374 * @brief Creates new YANG configuration data nodes for an SSH user's password authentication method.
375 *
376 * @param[in] ctx libyang context.
377 * @param[in] endpt_name Arbitrary identifier of the endpoint.
378 * If an endpoint with this identifier already exists, its user might be changed.
379 * @param[in] user_name Arbitrary identifier of the user.
380 * If an user with this identifier already exists, its contents will be changed.
roman35120972023-08-08 10:39:12 +0200381 * @param[in] password Clear-text password to be set for the user. It will be hashed.
roman8ba6efa2023-07-12 15:27:52 +0200382 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
383 * Otherwise the new YANG data will be added to the previous data and may override it.
384 * @return 0 on success, non-zero otherwise.
385 */
Roytakb2794852023-10-18 14:30:22 +0200386int nc_server_config_add_ssh_user_password(const struct ly_ctx *ctx, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +0200387 const char *user_name, const char *password, struct lyd_node **config);
388
389/**
390 * @brief Deletes an SSH user's password from the YANG data.
391 *
392 * @param[in] endpt_name Identifier of an existing endpoint.
393 * @param[in] user_name Identifier of an existing user on the given endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200394 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200395 * @return 0 on success, non-zero otherwise.
396 */
Roytakb2794852023-10-18 14:30:22 +0200397int nc_server_config_del_ssh_user_password(const char *endpt_name, const char *user_name,
roman8ba6efa2023-07-12 15:27:52 +0200398 struct lyd_node **config);
399
400/**
401 * @brief Creates new YANG configuration data nodes for an SSH user's keyboard interactive authentication method.
402 *
403 * @param[in] ctx libyang context.
404 * @param[in] endpt_name Arbitrary identifier of the endpoint.
405 * If an endpoint with this identifier already exists, its user might be changed.
406 * @param[in] user_name Arbitrary identifier of the user.
407 * If an user with this identifier already exists, its contents will be changed.
408 * @param[in] pam_config_name Name of the PAM configuration file.
roman0f5fa422023-08-07 09:03:24 +0200409 * @param[in] pam_config_dir Optional. The absolute path to the directory in which the configuration file
410 * with the name pam_config_name is located. A newer version (>= 1.4) of PAM library is required to be able to specify
roman8ba6efa2023-07-12 15:27:52 +0200411 * the path. If NULL is passed, then the PAM's system directories will be searched (usually /etc/pam.d/).
412 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
413 * Otherwise the new YANG data will be added to the previous data and may override it.
414 * @return 0 on success, non-zero otherwise.
415 */
Roytakb2794852023-10-18 14:30:22 +0200416int nc_server_config_add_ssh_user_interactive(const struct ly_ctx *ctx, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +0200417 const char *user_name, const char *pam_config_name, const char *pam_config_dir, struct lyd_node **config);
418
419/**
420 * @brief Deletes an SSH user's keyboard interactive authentication from the YANG data.
421 *
422 * @param[in] endpt_name Identifier of an existing endpoint.
423 * @param[in] user_name Identifier of an existing user on the given endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200424 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200425 * @return 0 on success, non-zero otherwise.
426 */
Roytakb2794852023-10-18 14:30:22 +0200427int nc_server_config_del_ssh_user_interactive(const char *endpt_name, const char *user_name,
roman8ba6efa2023-07-12 15:27:52 +0200428 struct lyd_node **config);
429
430/**
431 * @brief Deletes an SSH user from the YANG data.
432 *
433 * @param[in] endpt_name Identifier of an existing endpoint.
434 * @param[in] user_name Optional identifier of an user to be deleted.
435 * If NULL, all of the users on this endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200436 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200437 * @return 0 on success, non-zero otherwise.
438 */
Roytakb2794852023-10-18 14:30:22 +0200439int nc_server_config_del_ssh_user(const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +0200440 const char *user_name, struct lyd_node **config);
441
442/**
romand348b942023-10-13 14:32:19 +0200443 * @brief Creates new YANG data nodes for a reference to a public key bag located in the truststore.
444 *
445 * The public key's located in the bag will be used for client authentication.
446 *
447 * @param[in] ctx libyang context.
448 * @param[in] endpt_name Arbitrary identifier of an endpoint.
449 * If an endpoint with this identifier already exists, its contents will be changed.
450 * @param[in] user_name Arbitrary identifier of the endpoint's user.
451 * If an endpoint's user with this identifier already exists, its contents will be changed.
452 * @param[in] truststore_reference Name of the public key bag to be referenced and used for authentication.
453 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
454 * Otherwise the new YANG data will be added to the previous data and may override it.
455 * @return 0 on success, non-zero otherwise.
456 */
457int nc_server_config_add_ssh_truststore_ref(const struct ly_ctx *ctx, const char *endpt_name, const char *user_name,
458 const char *truststore_reference, struct lyd_node **config);
459
460/**
461 * @brief Deletes a truststore reference from the YANG data.
462 *
463 * @param[in] endpt_name Identifier of an existing endpoint.
464 * @param[in] user_name Identifier of an user on the given endpoint whose truststore reference will be deleted.
465 * @param[in,out] config Modified configuration YANG data tree.
466 * @return 0 on success, non-zero otherwise.
467 */
468int nc_server_config_del_ssh_truststore_ref(const char *endpt_name, const char *user_name,
469 struct lyd_node **config);
470
471/**
roman8ba6efa2023-07-12 15:27:52 +0200472 * @brief Creates new YANG configuration data nodes, which will be a reference to another SSH endpoint's users.
473 *
474 * Whenever a client tries to connect to the referencing endpoint, all of its users will be tried first. If no match is
475 * found, the referenced endpoint's configured users will be tried.
476 *
477 * @param[in] ctx libyang context
478 * @param[in] endpt_name Arbitrary identifier of the endpoint.
479 * If an endpoint with this identifier already exists, its contents will be changed.
480 * @param[in] referenced_endpt Identifier of an endpoint, which has to exist whenever this data
481 * is applied. The referenced endpoint can reference another one and so on, but there mustn't be a cycle.
482 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
483 * Otherwise the new YANG data will be added to the previous data and may override it.
484 * @return 0 on success, non-zero otherwise.
485 */
Roytakb2794852023-10-18 14:30:22 +0200486int nc_server_config_add_ssh_endpoint_client_ref(const struct ly_ctx *ctx, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +0200487 const char *referenced_endpt, struct lyd_node **config);
488
489/**
490 * @brief Deletes reference to another SSH endpoint's users from the YANG data.
491 *
492 * @param[in] endpt_name Identifier of an existing endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200493 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200494 * @return 0 on success, non-zero otherwise.
495 */
Roytakb2794852023-10-18 14:30:22 +0200496int nc_server_config_del_ssh_endpoint_client_ref(const char *endpt_name, struct lyd_node **config);
roman9b1379c2023-03-31 10:11:10 +0200497
498/**
roman35120972023-08-08 10:39:12 +0200499 * @} SSH Server Configuration
roman9b1379c2023-03-31 10:11:10 +0200500 */
roman9b1379c2023-03-31 10:11:10 +0200501
502/**
roman8ba6efa2023-07-12 15:27:52 +0200503 * @defgroup server_config_tls TLS Server Configuration
504 * @ingroup server_config
roman9b1379c2023-03-31 10:11:10 +0200505 *
roman8ba6efa2023-07-12 15:27:52 +0200506 * @brief TLS server configuration creation and deletion
507 * @{
roman9b1379c2023-03-31 10:11:10 +0200508 */
roman2e797ef2023-06-19 10:47:49 +0200509
510/**
roman3f9b65c2023-06-05 14:26:58 +0200511 * @brief Creates new YANG configuration data nodes for a server's certificate.
512 *
513 * @param[in] ctx libyang context.
514 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200515 * If an endpoint with this identifier already exists, its server certificate will be changed.
roman6c4efcd2023-08-08 10:18:44 +0200516 * @param[in] privkey_path Path to the server's PEM encoded private key file.
roman3f9b65c2023-06-05 14:26:58 +0200517 * @param[in] pubkey_path Optional path to the server's public key file. If not provided,
518 * it will be generated from the private key.
romane6ec60e2023-10-19 15:21:52 +0200519 * @param[in] cert_path Path to the server's certificate file.
roman3f9b65c2023-06-05 14:26:58 +0200520 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
521 * Otherwise the new YANG data will be added to the previous data and may override it.
522 * @return 0 on success, non-zero otherwise.
523 */
romane6ec60e2023-10-19 15:21:52 +0200524int nc_server_config_add_tls_server_cert(const struct ly_ctx *ctx, const char *endpt_name, const char *privkey_path,
525 const char *pubkey_path, const char *cert_path, struct lyd_node **config);
roman3f9b65c2023-06-05 14:26:58 +0200526
527/**
roman8ba6efa2023-07-12 15:27:52 +0200528 * @brief Deletes the server's certificate from the YANG data.
529 *
530 * @param[in] endpt_name Identifier of an existing endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200531 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200532 * @return 0 on success, non-zero otherwise.
533 */
romane6ec60e2023-10-19 15:21:52 +0200534int nc_server_config_del_tls_server_cert(const char *endpt_name, struct lyd_node **config);
romand348b942023-10-13 14:32:19 +0200535
536/**
537 * @brief Creates new YANG configuration data nodes for a keystore reference to the TLS server's certificate.
538 *
539 * @param[in] ctx libyang context.
540 * @param[in] endpt_name Arbitrary identifier of the endpoint.
541 * If an endpoint with this identifier already exists, its contents will be changed.
542 * @param[in] asym_key_ref Name of the asymmetric key pair in the keystore to be referenced.
543 * @param[in] cert_ref Name of the certificate, which must belong to the given asymmetric key pair, to be referenced.
544 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
545 * Otherwise the new YANG data will be added to the previous data and may override it.
546 * @return 0 on success, non-zero otherwise.
547 */
548int nc_server_config_add_tls_keystore_ref(const struct ly_ctx *ctx, const char *endpt_name, const char *asym_key_ref,
549 const char *cert_ref, struct lyd_node **config);
550
551/**
552 * @brief Deletes a TLS server certificate keystore reference from the YANG data.
553 *
554 * @param[in] endpt_name Identifier of an existing endpoint.
555 * @param[in,out] config Modified configuration YANG data tree.
556 * @return 0 on success, non-zero otherwise.
557 */
558int nc_server_config_del_tls_keystore_ref(const char *endpt_name, struct lyd_node **config);
roman12c3d522023-07-26 13:39:30 +0200559
560/**
roman3f9b65c2023-06-05 14:26:58 +0200561 * @brief Creates new YANG configuration data nodes for a client's (end-entity) certificate.
562 *
563 * @param[in] ctx libyang context.
564 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200565 * If an endpoint with this identifier already exists, its contents will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200566 * @param[in] cert_name Arbitrary identifier of the client's certificate.
roman35120972023-08-08 10:39:12 +0200567 * If a client certificate with this identifier already exists, it will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200568 * @param[in] cert_path Path to the client's certificate file.
569 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
570 * Otherwise the new YANG data will be added to the previous data and may override it.
571 * @return 0 on success, non-zero otherwise.
572 */
romane6ec60e2023-10-19 15:21:52 +0200573int nc_server_config_add_tls_client_cert(const struct ly_ctx *ctx, const char *endpt_name, const char *cert_name,
roman3f9b65c2023-06-05 14:26:58 +0200574 const char *cert_path, struct lyd_node **config);
575
576/**
roman8ba6efa2023-07-12 15:27:52 +0200577 * @brief Deletes a client (end-entity) certificate from the YANG data.
578 *
579 * @param[in] endpt_name Identifier of an existing endpoint.
580 * @param[in] cert_name Optional name of a certificate to be deleted.
581 * If NULL, all of the end-entity certificates on the given endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200582 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200583 * @return 0 on success, non-zero otherwise.
584 */
romane6ec60e2023-10-19 15:21:52 +0200585int nc_server_config_del_tls_client_cert(const char *endpt_name, const char *cert_name, struct lyd_node **config);
romand348b942023-10-13 14:32:19 +0200586
587/**
588 * @brief Creates new YANG configuration data nodes for a truststore reference to a set of client (end-entity) certificates.
589 *
590 * @param[in] ctx libyang context.
591 * @param[in] endpt_name Arbitrary identifier of the endpoint.
592 * If an endpoint with this identifier already exists, its contents will be changed.
593 * @param[in] cert_bag_ref Identifier of the certificate bag in the truststore to be referenced.
594 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
595 * Otherwise the new YANG data will be added to the previous data and may override it.
596 * @return 0 on success, non-zero otherwise.
597 */
598int nc_server_config_add_tls_client_cert_truststore_ref(const struct ly_ctx *ctx, const char *endpt_name,
599 const char *cert_bag_ref, struct lyd_node **config);
600
601/**
602 * @brief Deletes a client (end-entity) certificates truststore reference from the YANG data.
603 *
604 * @param[in] endpt_name Identifier of an existing endpoint.
605 * @param[in,out] config Modified configuration YANG data tree.
606 * @return 0 on success, non-zero otherwise.
607 */
608int nc_server_config_del_tls_client_cert_truststore_ref(const char *endpt_name, struct lyd_node **config);
roman12c3d522023-07-26 13:39:30 +0200609
610/**
roman3f9b65c2023-06-05 14:26:58 +0200611 * @brief Creates new YANG configuration data nodes for a client certificate authority (trust-anchor) certificate.
612 *
613 * @param[in] ctx libyang context.
614 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200615 * If an endpoint with this identifier already exists, its contents will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200616 * @param[in] cert_name Arbitrary identifier of the certificate authority certificate.
roman35120972023-08-08 10:39:12 +0200617 * If a CA with this identifier already exists, it will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200618 * @param[in] cert_path Path to the CA certificate file.
619 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
620 * Otherwise the new YANG data will be added to the previous data and may override it.
621 * @return 0 on success, non-zero otherwise.
622 */
romane6ec60e2023-10-19 15:21:52 +0200623int nc_server_config_add_tls_ca_cert(const struct ly_ctx *ctx, const char *endpt_name, const char *cert_name,
roman3f9b65c2023-06-05 14:26:58 +0200624 const char *cert_path, struct lyd_node **config);
625
626/**
roman8ba6efa2023-07-12 15:27:52 +0200627 * @brief Deletes a client certificate authority (trust-anchor) certificate from the YANG data.
628 *
629 * @param[in] endpt_name Identifier of an existing endpoint.
630 * @param[in] cert_name Optional name of a certificate to be deleted.
631 * If NULL, all of the CA certificates on the given endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200632 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200633 * @return 0 on success, non-zero otherwise.
634 */
romane6ec60e2023-10-19 15:21:52 +0200635int nc_server_config_del_tls_ca_cert(const char *endpt_name, const char *cert_name, struct lyd_node **config);
romand348b942023-10-13 14:32:19 +0200636
637/**
638 * @brief Creates new YANG configuration data nodes for a truststore reference to a set of client certificate authority (trust-anchor) certificates.
639 *
640 * @param[in] ctx libyang context.
641 * @param[in] endpt_name Arbitrary identifier of the endpoint.
642 * If an endpoint with this identifier already exists, its contents will be changed.
643 * @param[in] cert_bag_ref Identifier of the certificate bag in the truststore to be referenced.
644 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
645 * Otherwise the new YANG data will be added to the previous data and may override it.
646 * @return 0 on success, non-zero otherwise.
647 */
romane6ec60e2023-10-19 15:21:52 +0200648int nc_server_config_add_tls_ca_cert_truststore_ref(const struct ly_ctx *ctx, const char *endpt_name,
romand348b942023-10-13 14:32:19 +0200649 const char *cert_bag_ref, struct lyd_node **config);
650
651/**
652 * @brief Deletes a client certificate authority (trust-anchor) certificates truststore reference from the YANG data.
653 *
654 * @param[in] endpt_name Identifier of an existing endpoint.
655 * @param[in,out] config Modified configuration YANG data tree.
656 * @return 0 on success, non-zero otherwise.
657 */
romane6ec60e2023-10-19 15:21:52 +0200658int nc_server_config_del_tls_ca_cert_truststore_ref(const char *endpt_name, struct lyd_node **config);
roman12c3d522023-07-26 13:39:30 +0200659
660/**
Roytak76958912023-09-29 15:25:14 +0200661 * @brief Creates new YANG configuration data nodes, which will be a reference to another TLS endpoint's certificates.
662 *
663 * Whenever an user tries to connect to the referencing endpoint, all of its certificates will be tried first. If no match is
664 * found, the referenced endpoint's configured certificates will be tried. The same applies to cert-to-name entries.
665 *
666 * @param[in] ctx libyang context
667 * @param[in] endpt_name Arbitrary identifier of the endpoint.
668 * If an endpoint with this identifier already exists, its contents will be changed.
669 * @param[in] referenced_endpt Identifier of an endpoint, which has to exist whenever this data
670 * is applied. The referenced endpoint can reference another one and so on, but there mustn't be a cycle.
671 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
672 * Otherwise the new YANG data will be added to the previous data and may override it.
673 * @return 0 on success, non-zero otherwise.
674 */
Roytakb2794852023-10-18 14:30:22 +0200675int nc_server_config_add_tls_endpoint_client_ref(const struct ly_ctx *ctx, const char *endpt_name,
Roytak76958912023-09-29 15:25:14 +0200676 const char *referenced_endpt, struct lyd_node **config);
677
678/**
679 * @brief Deletes reference to another TLS endpoint's users from the YANG data.
680 *
681 * @param[in] endpt_name Identifier of an existing endpoint.
682 * @param[in,out] config Modified configuration YANG data tree.
683 * @return 0 on success, non-zero otherwise.
684 */
Roytakb2794852023-10-18 14:30:22 +0200685int nc_server_config_del_tls_endpoint_client_ref(const char *endpt_name, struct lyd_node **config);
Roytak76958912023-09-29 15:25:14 +0200686
687/**
roman3f9b65c2023-06-05 14:26:58 +0200688 * @brief Creates new YANG configuration data nodes for a cert-to-name entry.
689 *
690 * @param[in] ctx libyang context.
691 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200692 * If an endpoint with this identifier already exists, its contents will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200693 * @param[in] id ID of the entry. The lower the ID, the higher the priority of the entry (it will be checked earlier).
694 * @param[in] fingerprint Optional fingerprint of the entry. The fingerprint should always be set, however if it is
695 * not set, it will match any certificate. Entry with no fingerprint should therefore be placed only as the last entry.
696 * @param[in] map_type Mapping username to the certificate option.
697 * @param[in] name Username for this cert-to-name entry.
698 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
699 * Otherwise the new YANG data will be added to the previous data and may override it.
700 * @return 0 on success, non-zero otherwise.
701 */
Roytakb2794852023-10-18 14:30:22 +0200702int nc_server_config_add_tls_ctn(const struct ly_ctx *ctx, const char *endpt_name, uint32_t id, const char *fingerprint,
roman3f9b65c2023-06-05 14:26:58 +0200703 NC_TLS_CTN_MAPTYPE map_type, const char *name, struct lyd_node **config);
704
roman12644fe2023-06-08 11:06:42 +0200705/**
roman8ba6efa2023-07-12 15:27:52 +0200706 * @brief Deletes a cert-to-name entry from the YANG data.
707 *
708 * @param[in] endpt_name Identifier of an existing endpoint.
709 * @param[in] id Optional ID of the CTN entry.
710 * If 0, all of the cert-to-name entries on the given endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200711 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200712 * @return 0 on success, non-zero otherwise.
713 */
Roytakb2794852023-10-18 14:30:22 +0200714int nc_server_config_del_tls_ctn(const char *endpt_name, uint32_t id, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200715
716/**
roman35120972023-08-08 10:39:12 +0200717 * @} TLS Server Configuration
roman8ba6efa2023-07-12 15:27:52 +0200718 */
719
720/**
roman35120972023-08-08 10:39:12 +0200721 * @defgroup server_config_ch Call Home Server Configuration
roman8ba6efa2023-07-12 15:27:52 +0200722 * @ingroup server_config
723 *
Roytak2161df62023-08-02 15:04:42 +0200724 * @brief Call Home server configuration creation and deletion
roman8ba6efa2023-07-12 15:27:52 +0200725 * @{
726 */
727
728/**
roman35120972023-08-08 10:39:12 +0200729 * @} Call Home Server Configuration
730 */
731
732/**
733 * @defgroup server_config_ch_functions Call Home Server Configuration Functions
734 * @ingroup server_config_ch
735 *
736 * @brief Call Home server configuration functions
737 * @{
738 */
739
740/**
Roytak2161df62023-08-02 15:04:42 +0200741 * @brief Creates new YANG configuration data nodes for a Call Home client's address and port.
roman142718b2023-06-29 09:15:29 +0200742 *
743 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200744 * @param[in] client_name Arbitrary identifier of the Call Home client.
745 * If a Call Home client with this identifier already exists, its contents will be changed.
roman142718b2023-06-29 09:15:29 +0200746 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
747 * If the client's endpoint with this identifier already exists, its contents will be changed.
748 * @param[in] transport Transport protocol to be used on this endpoint - either SSH or TLS.
749 * @param[in] address Address to connect to.
750 * @param[in] port Port to connect to.
751 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
752 * Otherwise the new YANG data will be added to the previous data and may override it.
753 * @return 0 on success, non-zero otherwise.
754 */
Roytakb2794852023-10-18 14:30:22 +0200755int nc_server_config_add_ch_address_port(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
roman5cbb6532023-06-22 12:53:17 +0200756 NC_TRANSPORT_IMPL transport, const char *address, const char *port, struct lyd_node **config);
757
roman8ba6efa2023-07-12 15:27:52 +0200758#endif /* NC_ENABLED_SSH_TLS */
759
760/**
Roytak2161df62023-08-02 15:04:42 +0200761 * @brief Deletes a Call Home client from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +0200762 *
763 * @param[in] client_name Optional identifier of a client to be deleted.
Roytak2161df62023-08-02 15:04:42 +0200764 * If NULL, all of the Call Home clients will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200765 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200766 * @return 0 on success, non-zero otherwise.
767 */
Roytakb2794852023-10-18 14:30:22 +0200768int nc_server_config_del_ch_client(const char *client_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200769
770/**
Roytak2161df62023-08-02 15:04:42 +0200771 * @brief Deletes a Call Home endpoint from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +0200772 *
Roytak2161df62023-08-02 15:04:42 +0200773 * @param[in] client_name Identifier of an existing Call Home client.
roman8ba6efa2023-07-12 15:27:52 +0200774 * @param[in] endpt_name Optional identifier of a CH endpoint to be deleted.
775 * If NULL, all of the CH endpoints which belong to the given client will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200776 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200777 * @return 0 on success, non-zero otherwise.
778 */
Roytakb2794852023-10-18 14:30:22 +0200779int nc_server_config_del_ch_endpt(const char *client_name, const char *endpt_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200780
781/**
Roytak2161df62023-08-02 15:04:42 +0200782 * @brief Creates new YANG configuration data nodes for the Call Home persistent connection type.
roman8ba6efa2023-07-12 15:27:52 +0200783 *
784 * This is the default connection type. If periodic connection type was set before, it will be unset.
785 *
786 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200787 * @param[in] client_name Arbitrary identifier of the Call Home client.
788 * If a Call Home client with this identifier already exists, its contents will be changed.
Roytak9b32c0f2023-08-02 15:07:29 +0200789 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +0200790 * Otherwise the new YANG data will be added to the previous data and may override it.
791 * @return 0 on success, non-zero otherwise.
792 */
Roytakb2794852023-10-18 14:30:22 +0200793int nc_server_config_add_ch_persistent(const struct ly_ctx *ctx, const char *client_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200794
795/**
Roytak2161df62023-08-02 15:04:42 +0200796 * @brief Creates new YANG configuration data nodes for the period parameter of the Call Home periodic connection type.
roman8ba6efa2023-07-12 15:27:52 +0200797 *
798 * If called, the persistent connection type will be replaced by periodic.
799 *
800 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200801 * @param[in] client_name Arbitrary identifier of the Call Home client.
802 * If a Call Home client with this identifier already exists, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +0200803 * @param[in] period Duration between periodic connections in minutes.
Roytak9b32c0f2023-08-02 15:07:29 +0200804 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +0200805 * Otherwise the new YANG data will be added to the previous data and may override it.
806 * @return 0 on success, non-zero otherwise.
807 */
Roytakb2794852023-10-18 14:30:22 +0200808int nc_server_config_add_ch_period(const struct ly_ctx *ctx, const char *client_name, uint16_t period,
roman8ba6efa2023-07-12 15:27:52 +0200809 struct lyd_node **config);
810
811/**
Roytak2161df62023-08-02 15:04:42 +0200812 * @brief Deletes the Call Home period parameter of the periodic connection type from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +0200813 *
814 * This behaves the same as setting the period to 60 minutes, which is the default value of this node.
815 *
Roytak2161df62023-08-02 15:04:42 +0200816 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +0200817 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200818 * @return 0 on success, non-zero otherwise.
819 */
Roytakb2794852023-10-18 14:30:22 +0200820int nc_server_config_del_ch_period(const char *client_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200821
822/**
Roytak2161df62023-08-02 15:04:42 +0200823 * @brief Creates new YANG configuration data nodes for the anchor time parameter of the Call Home periodic connection type.
roman8ba6efa2023-07-12 15:27:52 +0200824 *
825 * If called, the persistent connection type will be replaced by periodic.
826 *
827 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200828 * @param[in] client_name Arbitrary identifier of the Call Home client.
829 * If a Call Home client with this identifier already exists, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +0200830 * @param[in] anchor_time Timestamp before or after which a series of periodic connections are determined.
Roytak9b32c0f2023-08-02 15:07:29 +0200831 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +0200832 * Otherwise the new YANG data will be added to the previous data and may override it.
833 * @return 0 on success, non-zero otherwise.
834 */
Roytakb2794852023-10-18 14:30:22 +0200835int nc_server_config_add_ch_anchor_time(const struct ly_ctx *ctx, const char *client_name,
roman8ba6efa2023-07-12 15:27:52 +0200836 const char *anchor_time, struct lyd_node **config);
837
838/**
Roytak2161df62023-08-02 15:04:42 +0200839 * @brief Deletes the Call Home anchor time parameter of the periodic connection type from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +0200840 *
Roytak2161df62023-08-02 15:04:42 +0200841 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +0200842 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200843 * @return 0 on success, non-zero otherwise.
844 */
Roytakb2794852023-10-18 14:30:22 +0200845int nc_server_config_del_ch_anchor_time(const char *client_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200846
847/**
Roytak2161df62023-08-02 15:04:42 +0200848 * @brief Creates new YANG configuration data nodes for the idle timeout parameter of the Call Home periodic connection type.
roman8ba6efa2023-07-12 15:27:52 +0200849 *
850 * If called, the persistent connection type will be replaced by periodic.
851 *
852 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200853 * @param[in] client_name Arbitrary identifier of the Call Home client.
854 * If a Call Home client with this identifier already exists, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +0200855 * @param[in] idle_timeout Specifies the maximum number of seconds that a session may remain idle.
Roytak9b32c0f2023-08-02 15:07:29 +0200856 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +0200857 * Otherwise the new YANG data will be added to the previous data and may override it.
858 * @return 0 on success, non-zero otherwise.
859 */
Roytakb2794852023-10-18 14:30:22 +0200860int nc_server_config_add_ch_idle_timeout(const struct ly_ctx *ctx, const char *client_name,
roman8ba6efa2023-07-12 15:27:52 +0200861 uint16_t idle_timeout, struct lyd_node **config);
862
863/**
Roytak2161df62023-08-02 15:04:42 +0200864 * @brief Deletes the Call Home idle timeout parameter of the periodic connection type from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +0200865 *
866 * This behaves the same as setting the timeout to 180 seconds, which is the default value of this node.
867 *
Roytak2161df62023-08-02 15:04:42 +0200868 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +0200869 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200870 * @return 0 on success, non-zero otherwise.
871 */
Roytakb2794852023-10-18 14:30:22 +0200872int nc_server_config_del_ch_idle_timeout(const char *client_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200873
874/**
Roytak2161df62023-08-02 15:04:42 +0200875 * @brief Creates new YANG configuration data nodes for the Call Home reconnect strategy.
roman8ba6efa2023-07-12 15:27:52 +0200876 *
877 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200878 * @param[in] client_name Arbitrary identifier of the Call Home client.
879 * If a Call Home client with this identifier already exists, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +0200880 * @param[in] start_with Specifies which endpoint to try if a connection is unsuccessful. Default value is NC_CH_FIRST_LISTED.
881 * @param[in] max_wait The number of seconds after which a connection to an endpoint is deemed unsuccessful. Default value if 5.
882 * @param[in] max_attempts The number of unsuccessful connection attempts before moving to the next endpoint. Default value is 3.
Roytak9b32c0f2023-08-02 15:07:29 +0200883 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +0200884 * Otherwise the new YANG data will be added to the previous data and may override it.
885 * @return 0 on success, non-zero otherwise.
886 */
Roytakb2794852023-10-18 14:30:22 +0200887int nc_server_config_add_ch_reconnect_strategy(const struct ly_ctx *ctx, const char *client_name,
roman8ba6efa2023-07-12 15:27:52 +0200888 NC_CH_START_WITH start_with, uint16_t max_wait, uint8_t max_attempts, struct lyd_node **config);
889
890/**
Roytak2161df62023-08-02 15:04:42 +0200891 * @brief Resets the values of the Call Home reconnect strategy nodes to their defaults.
roman8ba6efa2023-07-12 15:27:52 +0200892 *
893 * The default values are: start-with = NC_CH_FIRST_LISTED, max-wait = 5 and max-attempts = 3.
894 *
Roytak2161df62023-08-02 15:04:42 +0200895 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +0200896 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200897 * @return 0 on success, non-zero otherwise.
898 */
Roytakb2794852023-10-18 14:30:22 +0200899int nc_server_config_del_ch_reconnect_strategy(const char *client_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200900
901/**
roman35120972023-08-08 10:39:12 +0200902 * @} Call Home Server Configuration Functions
roman8ba6efa2023-07-12 15:27:52 +0200903 */
904
905#ifdef NC_ENABLED_SSH_TLS
906
907/**
Roytak2161df62023-08-02 15:04:42 +0200908 * @defgroup server_config_ch_ssh SSH Call Home Server Configuration
roman8ba6efa2023-07-12 15:27:52 +0200909 * @ingroup server_config_ch
910 *
Roytak2161df62023-08-02 15:04:42 +0200911 * @brief SSH Call Home server configuration creation and deletion
roman8ba6efa2023-07-12 15:27:52 +0200912 * @{
913 */
914
roman142718b2023-06-29 09:15:29 +0200915/**
Roytak2161df62023-08-02 15:04:42 +0200916 * @brief Creates new YANG data nodes for a Call Home SSH hostkey.
roman142718b2023-06-29 09:15:29 +0200917 *
918 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200919 * @param[in] client_name Arbitrary identifier of the Call Home client.
920 * If a Call Home client with this identifier already exists, its contents will be changed.
roman142718b2023-06-29 09:15:29 +0200921 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
922 * If the client's endpoint with this identifier already exists, its contents will be changed.
923 * @param[in] hostkey_name Arbitrary identifier of the endpoint's hostkey.
924 * If the endpoint's hostkey with this identifier already exists, its contents will be changed.
925 * @param[in] privkey_path Path to a file containing a private key.
926 * The private key has to be in a PEM format. Only RSA and ECDSA keys are supported.
927 * @param[in] pubkey_path Path to a file containing a public key. If NULL, public key will be
928 * generated from the private key.
929 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
930 * Otherwise the new YANG data will be added to the previous data and may override it.
931 * @return 0 on success, non-zero otherwise.
932 */
Roytakb2794852023-10-18 14:30:22 +0200933int nc_server_config_add_ch_ssh_hostkey(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
roman5cbb6532023-06-22 12:53:17 +0200934 const char *hostkey_name, const char *privkey_path, const char *pubkey_path, struct lyd_node **config);
935
roman142718b2023-06-29 09:15:29 +0200936/**
Roytak2161df62023-08-02 15:04:42 +0200937 * @brief Deletes a Call Home hostkey from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +0200938 *
Roytak2161df62023-08-02 15:04:42 +0200939 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +0200940 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
roman8ba6efa2023-07-12 15:27:52 +0200941 * @param[in] hostkey_name Optional identifier of a hostkey to be deleted.
942 * If NULL, all of the hostkeys on the given endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200943 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200944 * @return 0 on success, non-zero otherwise.
945 */
Roytakb2794852023-10-18 14:30:22 +0200946int nc_server_config_del_ch_ssh_hostkey(const char *client_name, const char *endpt_name,
roman9d5e5a52023-07-14 12:43:44 +0200947 const char *hostkey_name, struct lyd_node **config);
948
949/**
romand348b942023-10-13 14:32:19 +0200950 * @brief Creates new YANG data nodes for a reference to an asymmetric key located in the keystore.
951 *
952 * This asymmetric key pair will be used as the Call Home SSH hostkey.
953 *
954 * @param[in] ctx libyang context.
955 * @param[in] client_name Arbitrary identifier of the Call Home client.
956 * If a Call Home client with this identifier already exists, its contents will be changed.
957 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
958 * If the client's endpoint with this identifier already exists, its contents will be changed.
959 * @param[in] hostkey_name Arbitrary identifier of the endpoint's hostkey.
960 * If the endpoint's hostkey with this identifier already exists, its contents will be changed.
961 * @param[in] keystore_reference Name of the asymmetric key pair to be referenced and used as a hostkey.
962 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
963 * Otherwise the new YANG data will be added to the previous data and may override it.
964 * @return 0 on success, non-zero otherwise.
965 */
966int nc_server_config_add_ch_ssh_keystore_ref(const struct ly_ctx *ctx, const char *client_name,
967 const char *endpt_name, const char *hostkey_name, const char *keystore_reference, struct lyd_node **config);
968
969/**
970 * @brief Deletes a Call Home keystore reference from the YANG data.
971 *
972 * @param[in] client_name Identifier of an existing Call Home client.
973 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
974 * @param[in] hostkey_name Identifier of an existing hostkey that belongs to the given CH endpoint.
975 * @param[in,out] config Modified configuration YANG data tree.
976 * @return 0 on success, non-zero otherwise.
977 */
978int nc_server_config_del_ch_ssh_keystore_ref(const char *client_name, const char *endpt_name,
979 const char *hostkey_name, struct lyd_node **config);
980
981/**
Roytak2161df62023-08-02 15:04:42 +0200982 * @brief Creates new YANG data nodes for a Call Home SSH user's public key authentication method.
roman142718b2023-06-29 09:15:29 +0200983 *
984 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200985 * @param[in] client_name Arbitrary identifier of the Call Home client.
986 * If a Call Home client with this identifier already exists, its contents will be changed.
roman142718b2023-06-29 09:15:29 +0200987 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
988 * If the client's endpoint with this identifier already exists, its contents will be changed.
989 * @param[in] user_name Arbitrary identifier of the endpoint's user.
990 * If the endpoint's user with this identifier already exists, its contents will be changed.
991 * @param[in] pubkey_name Arbitrary identifier of the user's public key.
992 * If the user's public key with this identifier already exists, its contents will be changed.
993 * @param[in] pubkey_path Path to a file containing a public key.
994 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
995 * Otherwise the new YANG data will be added to the previous data and may override it.
996 * @return 0 on success, non-zero otherwise.
997 */
Roytakb2794852023-10-18 14:30:22 +0200998int nc_server_config_add_ch_ssh_user_pubkey(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
roman5cbb6532023-06-22 12:53:17 +0200999 const char *user_name, const char *pubkey_name, const char *pubkey_path, struct lyd_node **config);
1000
roman142718b2023-06-29 09:15:29 +02001001/**
Roytak2161df62023-08-02 15:04:42 +02001002 * @brief Deletes a Call Home SSH user's public key from the YANG data.
roman142718b2023-06-29 09:15:29 +02001003 *
Roytak2161df62023-08-02 15:04:42 +02001004 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001005 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1006 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
roman8ba6efa2023-07-12 15:27:52 +02001007 * @param[in] pubkey_name Optional identifier of a public key to be deleted.
1008 * If NULL, all of the public keys which belong to the given SSH user will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001009 * @param[in,out] config Modified configuration YANG data tree.
roman142718b2023-06-29 09:15:29 +02001010 * @return 0 on success, non-zero otherwise.
1011 */
Roytakb2794852023-10-18 14:30:22 +02001012int nc_server_config_del_ch_ssh_user_pubkey(const char *client_name, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +02001013 const char *user_name, const char *pubkey_name, struct lyd_node **config);
roman5cbb6532023-06-22 12:53:17 +02001014
roman142718b2023-06-29 09:15:29 +02001015/**
Roytak2161df62023-08-02 15:04:42 +02001016 * @brief Creates new YANG data nodes for a Call Home SSH user's password authentication method.
roman9d5e5a52023-07-14 12:43:44 +02001017 *
1018 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001019 * @param[in] client_name Arbitrary identifier of the Call Home client.
1020 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001021 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1022 * If the client's endpoint with this identifier already exists, its contents will be changed.
1023 * @param[in] user_name Arbitrary identifier of the endpoint's user.
1024 * If the endpoint's user with this identifier already exists, its contents will be changed.
roman35120972023-08-08 10:39:12 +02001025 * @param[in] password Clear-text password to be set for the user. It will be hashed.
roman9d5e5a52023-07-14 12:43:44 +02001026 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1027 * Otherwise the new YANG data will be added to the previous data and may override it.
1028 * @return 0 on success, non-zero otherwise.
1029 */
Roytakb2794852023-10-18 14:30:22 +02001030int nc_server_config_add_ch_ssh_user_password(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
roman9d5e5a52023-07-14 12:43:44 +02001031 const char *user_name, const char *password, struct lyd_node **config);
1032
1033/**
Roytak2161df62023-08-02 15:04:42 +02001034 * @brief Deletes a Call Home SSH user's password from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001035 *
Roytak2161df62023-08-02 15:04:42 +02001036 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001037 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1038 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
1039 * @param[in,out] config Modified configuration YANG data tree.
1040 * @return 0 on success, non-zero otherwise.
1041 */
Roytakb2794852023-10-18 14:30:22 +02001042int nc_server_config_del_ch_ssh_user_password(const char *client_name, const char *endpt_name,
roman9d5e5a52023-07-14 12:43:44 +02001043 const char *user_name, struct lyd_node **config);
1044
1045/**
Roytak2161df62023-08-02 15:04:42 +02001046 * @brief Creates new YANG configuration data nodes for a Call Home SSH user's keyboard interactive authentication method.
roman9d5e5a52023-07-14 12:43:44 +02001047 *
1048 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001049 * @param[in] client_name Arbitrary identifier of the Call Home client.
1050 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001051 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1052 * If the client's endpoint with this identifier already exists, its contents will be changed.
1053 * @param[in] user_name Arbitrary identifier of the endpoint's user.
1054 * If the endpoint's user with this identifier already exists, its contents will be changed.
1055 * @param[in] pam_config_name Name of the PAM configuration file.
roman0f5fa422023-08-07 09:03:24 +02001056 * @param[in] pam_config_dir Optional. The absolute path to the directory in which the configuration file
1057 * with the name pam_config_name is located. A newer version (>= 1.4) of PAM library is required to be able to specify
roman9d5e5a52023-07-14 12:43:44 +02001058 * the path. If NULL is passed, then the PAM's system directories will be searched (usually /etc/pam.d/).
1059 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1060 * Otherwise the new YANG data will be added to the previous data and may override it.
1061 * @return 0 on success, non-zero otherwise.
1062 */
Roytakb2794852023-10-18 14:30:22 +02001063int nc_server_config_add_ch_ssh_user_interactive(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
roman9d5e5a52023-07-14 12:43:44 +02001064 const char *user_name, const char *pam_config_name, const char *pam_config_dir, struct lyd_node **config);
1065
1066/**
Roytak2161df62023-08-02 15:04:42 +02001067 * @brief Deletes a Call Home SSH user's keyboard interactive authentication from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001068 *
Roytak2161df62023-08-02 15:04:42 +02001069 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001070 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1071 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
1072 * @param[in,out] config Modified configuration YANG data tree.
1073 * @return 0 on success, non-zero otherwise.
1074 */
Roytakb2794852023-10-18 14:30:22 +02001075int nc_server_config_del_ch_ssh_user_interactive(const char *client_name, const char *endpt_name,
roman9d5e5a52023-07-14 12:43:44 +02001076 const char *user_name, struct lyd_node **config);
1077
1078/**
Roytak2161df62023-08-02 15:04:42 +02001079 * @brief Deletes a Call Home SSH user from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001080 *
Roytak2161df62023-08-02 15:04:42 +02001081 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001082 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1083 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
1084 * @param[in,out] config Modified configuration YANG data tree.
1085 * @return 0 on success, non-zero otherwise.
1086 */
Roytakb2794852023-10-18 14:30:22 +02001087int nc_server_config_del_ch_ssh_user(const char *client_name, const char *endpt_name,
roman9d5e5a52023-07-14 12:43:44 +02001088 const char *user_name, struct lyd_node **config);
1089
1090/**
romand348b942023-10-13 14:32:19 +02001091 * @brief Creates new YANG data nodes for a reference to a public key bag located in the truststore.
1092 *
1093 * The public key's located in the bag will be used for Call Home SSH client authentication.
1094 *
1095 * @param[in] ctx libyang context.
1096 * @param[in] client_name Arbitrary identifier of the Call Home client.
1097 * If a Call Home client with this identifier already exists, its contents will be changed.
1098 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1099 * If the client's endpoint with this identifier already exists, its contents will be changed.
1100 * @param[in] user_name Arbitrary identifier of the endpoint's user.
1101 * If the endpoint's user with this identifier already exists, its contents will be changed.
1102 * @param[in] truststore_reference Name of the public key bag to be referenced and used for authentication.
1103 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1104 * Otherwise the new YANG data will be added to the previous data and may override it.
1105 * @return 0 on success, non-zero otherwise.
1106 */
1107int nc_server_config_add_ch_ssh_truststore_ref(const struct ly_ctx *ctx, const char *client_name,
1108 const char *endpt_name, const char *user_name, const char *truststore_reference, struct lyd_node **config);
1109
1110/**
1111 * @brief Deletes a Call Home SSH truststore reference from the YANG data.
1112 *
1113 * @param[in] client_name Identifier of an existing Call Home client.
1114 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1115 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
1116 * @param[in,out] config Modified configuration YANG data tree.
1117 * @return 0 on success, non-zero otherwise.
1118 */
1119int nc_server_config_del_ch_ssh_truststore_ref(const char *client_name, const char *endpt_name,
1120 const char *user_name, struct lyd_node **config);
1121
1122/**
roman35120972023-08-08 10:39:12 +02001123 * @} SSH Call Home Server Configuration
roman142718b2023-06-29 09:15:29 +02001124 */
roman142718b2023-06-29 09:15:29 +02001125
1126/**
Roytak2161df62023-08-02 15:04:42 +02001127 * @defgroup server_config_ch_tls TLS Call Home Server Configuration
roman8ba6efa2023-07-12 15:27:52 +02001128 * @ingroup server_config_ch
roman142718b2023-06-29 09:15:29 +02001129 *
Roytak2161df62023-08-02 15:04:42 +02001130 * @brief TLS Call Home server configuration creation and deletion
roman8ba6efa2023-07-12 15:27:52 +02001131 * @{
roman142718b2023-06-29 09:15:29 +02001132 */
roman142718b2023-06-29 09:15:29 +02001133
romanb6f44032023-06-30 15:07:56 +02001134/**
Roytak2161df62023-08-02 15:04:42 +02001135 * @brief Creates new YANG configuration data nodes for a Call Home server's certificate.
romanb6f44032023-06-30 15:07:56 +02001136 *
1137 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001138 * @param[in] client_name Arbitrary identifier of the Call Home client.
1139 * If a Call Home client with this identifier already exists, its contents will be changed.
1140 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1141 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
roman6c4efcd2023-08-08 10:18:44 +02001142 * @param[in] privkey_path Path to the server's PEM encoded private key file.
romanb6f44032023-06-30 15:07:56 +02001143 * @param[in] pubkey_path Optional path to the server's public key file. If not provided,
1144 * it will be generated from the private key.
romane6ec60e2023-10-19 15:21:52 +02001145 * @param[in] cert_path Path to the server's certificate file.
Roytak934edc32023-07-27 12:04:18 +02001146 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
romanb6f44032023-06-30 15:07:56 +02001147 * Otherwise the new YANG data will be added to the previous data and may override it.
1148 * @return 0 on success, non-zero otherwise.
1149 */
romane6ec60e2023-10-19 15:21:52 +02001150int nc_server_config_add_ch_tls_server_cert(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1151 const char *privkey_path, const char *pubkey_path, const char *cert_path, struct lyd_node **config);
romanb6f44032023-06-30 15:07:56 +02001152
1153/**
Roytak2161df62023-08-02 15:04:42 +02001154 * @brief Deletes a Call Home server certificate from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001155 *
Roytak2161df62023-08-02 15:04:42 +02001156 * @param[in] client_name Identifier of an existing Call Home client.
1157 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
roman9d5e5a52023-07-14 12:43:44 +02001158 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001159 * @return 0 on success, non-zero otherwise.
1160 */
romane6ec60e2023-10-19 15:21:52 +02001161int nc_server_config_del_ch_tls_server_cert(const char *client_name, const char *endpt_name,
romand348b942023-10-13 14:32:19 +02001162 struct lyd_node **config);
1163
1164/**
1165 * @brief Creates new YANG configuration data nodes for a keystore reference to the Call Home TLS server's certificate.
1166 *
1167 * @param[in] ctx libyang context.
1168 * @param[in] client_name Arbitrary identifier of the Call Home client.
1169 * If a Call Home client with this identifier already exists, its contents will be changed.
1170 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1171 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
1172 * @param[in] asym_key_ref Name of the asymmetric key pair in the keystore to be referenced.
1173 * @param[in] cert_ref Name of the certificate, which must belong to the given asymmetric key pair, to be referenced.
1174 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1175 * Otherwise the new YANG data will be added to the previous data and may override it.
1176 * @return 0 on success, non-zero otherwise.
1177 */
1178int nc_server_config_add_ch_tls_keystore_ref(const struct ly_ctx *ctx, const char *client_name,
1179 const char *endpt_name, const char *asym_key_ref, const char *cert_ref, struct lyd_node **config);
1180
1181/**
1182 * @brief Deletes a TLS server certificate keystore reference from the YANG data.
1183 *
1184 * @param[in] client_name Identifier of an existing Call Home client.
1185 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
1186 * @param[in,out] config Modified configuration YANG data tree.
1187 * @return 0 on success, non-zero otherwise.
1188 */
1189int nc_server_config_del_ch_tls_keystore_ref(const char *client_name, const char *endpt_name,
Roytak934edc32023-07-27 12:04:18 +02001190 struct lyd_node **config);
1191
1192/**
Roytak2161df62023-08-02 15:04:42 +02001193 * @brief Creates new YANG configuration data nodes for a Call Home client's (end-entity) certificate.
romanb6f44032023-06-30 15:07:56 +02001194 *
1195 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001196 * @param[in] client_name Arbitrary identifier of the Call Home client.
1197 * If a Call Home client with this identifier already exists, its contents will be changed.
1198 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1199 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
1200 * @param[in] cert_name Arbitrary identifier of the Call Home endpoint's end-entity certificate.
1201 * If an Call Home endpoint's end-entity certificate with this identifier already exists, its contents will be changed.
romanb6f44032023-06-30 15:07:56 +02001202 * @param[in] cert_path Path to the certificate file.
Roytak934edc32023-07-27 12:04:18 +02001203 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
romanb6f44032023-06-30 15:07:56 +02001204 * Otherwise the new YANG data will be added to the previous data and may override it.
1205 * @return 0 on success, non-zero otherwise.
1206 */
romane6ec60e2023-10-19 15:21:52 +02001207int nc_server_config_add_ch_tls_client_cert(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
romanb6f44032023-06-30 15:07:56 +02001208 const char *cert_name, const char *cert_path, struct lyd_node **config);
1209
1210/**
Roytak2161df62023-08-02 15:04:42 +02001211 * @brief Deletes a Call Home client (end-entity) certificate from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001212 *
Roytak2161df62023-08-02 15:04:42 +02001213 * @param[in] client_name Identifier of an existing Call Home client.
1214 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
roman8ba6efa2023-07-12 15:27:52 +02001215 * @param[in] cert_name Optional identifier of a client certificate to be deleted.
1216 * If NULL, all of the client certificates will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001217 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001218 * @return 0 on success, non-zero otherwise.
1219 */
romane6ec60e2023-10-19 15:21:52 +02001220int nc_server_config_del_ch_tls_client_cert(const char *client_name, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +02001221 const char *cert_name, struct lyd_node **config);
1222
1223/**
romand348b942023-10-13 14:32:19 +02001224 * @brief Creates new YANG configuration data nodes for a Call Home truststore reference to a set of client (end-entity) certificates.
1225 *
1226 * @param[in] ctx libyang context.
1227 * @param[in] client_name Arbitrary identifier of the Call Home client.
1228 * If a Call Home client with this identifier already exists, its contents will be changed.
1229 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1230 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
1231 * @param[in] cert_bag_ref Identifier of the certificate bag in the truststore to be referenced.
1232 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1233 * Otherwise the new YANG data will be added to the previous data and may override it.
1234 * @return 0 on success, non-zero otherwise.
1235 */
1236int nc_server_config_add_ch_tls_client_cert_truststore_ref(const struct ly_ctx *ctx, const char *client_name,
1237 const char *endpt_name, const char *cert_bag_ref, struct lyd_node **config);
1238
1239/**
1240 * @brief Deletes a Call Home client (end-entity) certificates truststore reference from the YANG data.
1241 *
1242 * @param[in] client_name Identifier of an existing Call Home client.
1243 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
1244 * @param[in,out] config Modified configuration YANG data tree.
1245 * @return 0 on success, non-zero otherwise.
1246 */
1247int nc_server_config_del_ch_tls_client_cert_truststore_ref(const char *client_name, const char *endpt_name,
1248 struct lyd_node **config);
1249
1250/**
romanb6f44032023-06-30 15:07:56 +02001251 * @brief Creates new YANG configuration data nodes for a client certificate authority (trust-anchor) certificate.
1252 *
1253 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001254 * @param[in] client_name Arbitrary identifier of the Call Home client.
1255 * If a Call Home client with this identifier already exists, its contents will be changed.
1256 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1257 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
1258 * @param[in] cert_name Arbitrary identifier of the Call Home endpoint's certificate authority certificate.
1259 * If an Call Home endpoint's CA certificate with this identifier already exists, its contents will be changed.
romanb6f44032023-06-30 15:07:56 +02001260 * @param[in] cert_path Path to the certificate file.
Roytak9b32c0f2023-08-02 15:07:29 +02001261 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
romanb6f44032023-06-30 15:07:56 +02001262 * Otherwise the new YANG data will be added to the previous data and may override it.
1263 * @return 0 on success, non-zero otherwise.
1264 */
romane6ec60e2023-10-19 15:21:52 +02001265int nc_server_config_add_ch_tls_ca_cert(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
romanb6f44032023-06-30 15:07:56 +02001266 const char *cert_name, const char *cert_path, struct lyd_node **config);
1267
1268/**
Roytak2161df62023-08-02 15:04:42 +02001269 * @brief Deletes a Call Home client certificate authority (trust-anchor) certificate from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001270 *
Roytak2161df62023-08-02 15:04:42 +02001271 * @param[in] client_name Identifier of an existing Call Home client.
1272 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
roman8ba6efa2023-07-12 15:27:52 +02001273 * @param[in] cert_name Optional identifier of a CA certificate to be deleted.
1274 * If NULL, all of the CA certificates will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001275 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001276 * @return 0 on success, non-zero otherwise.
1277 */
romane6ec60e2023-10-19 15:21:52 +02001278int nc_server_config_del_ch_tls_ca_cert(const char *client_name, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +02001279 const char *cert_name, struct lyd_node **config);
1280
1281/**
romand348b942023-10-13 14:32:19 +02001282 * @brief Creates new YANG configuration data nodes for a Call Home truststore reference to a set of client certificate authority (trust-anchor) certificates.
1283 *
1284 * @param[in] ctx libyang context.
1285 * @param[in] client_name Arbitrary identifier of the Call Home client.
1286 * If a Call Home client with this identifier already exists, its contents will be changed.
1287 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1288 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
1289 * @param[in] cert_bag_ref Identifier of the certificate bag in the truststore to be referenced.
1290 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1291 * Otherwise the new YANG data will be added to the previous data and may override it.
1292 * @return 0 on success, non-zero otherwise.
1293 */
romane6ec60e2023-10-19 15:21:52 +02001294int nc_server_config_add_ch_tls_ca_cert_truststore_ref(const struct ly_ctx *ctx, const char *client_name,
romand348b942023-10-13 14:32:19 +02001295 const char *endpt_name, const char *cert_bag_ref, struct lyd_node **config);
1296
1297/**
1298 * @brief Deletes a Call Home client certificate authority (trust-anchor) certificates truststore reference from the YANG data.
1299 *
1300 * @param[in] client_name Identifier of an existing Call Home client.
1301 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
1302 * @param[in,out] config Modified configuration YANG data tree.
1303 * @return 0 on success, non-zero otherwise.
1304 */
romane6ec60e2023-10-19 15:21:52 +02001305int nc_server_config_del_ch_tls_ca_cert_truststore_ref(const char *client_name, const char *endpt_name,
romand348b942023-10-13 14:32:19 +02001306 struct lyd_node **config);
1307
1308/**
Roytak2161df62023-08-02 15:04:42 +02001309 * @brief Creates new YANG configuration data nodes for a Call Home cert-to-name entry.
romanb6f44032023-06-30 15:07:56 +02001310 *
1311 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001312 * @param[in] client_name Arbitrary identifier of the Call Home client.
1313 * If a Call Home client with this identifier already exists, its contents will be changed.
1314 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1315 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
romanb6f44032023-06-30 15:07:56 +02001316 * @param[in] id ID of the entry. The lower the ID, the higher the priority of the entry (it will be checked earlier).
1317 * @param[in] fingerprint Optional fingerprint of the entry. The fingerprint should always be set, however if it is
1318 * not set, it will match any certificate. Entry with no fingerprint should therefore be placed only as the last entry.
1319 * @param[in] map_type Mapping username to the certificate option.
1320 * @param[in] name Username for this cert-to-name entry.
Roytak9b32c0f2023-08-02 15:07:29 +02001321 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
romanb6f44032023-06-30 15:07:56 +02001322 * Otherwise the new YANG data will be added to the previous data and may override it.
1323 * @return 0 on success, non-zero otherwise.
1324 */
Roytakb2794852023-10-18 14:30:22 +02001325int nc_server_config_add_ch_tls_ctn(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
romanb6f44032023-06-30 15:07:56 +02001326 uint32_t id, const char *fingerprint, NC_TLS_CTN_MAPTYPE map_type, const char *name, struct lyd_node **config);
1327
roman8ba6efa2023-07-12 15:27:52 +02001328/**
Roytak2161df62023-08-02 15:04:42 +02001329 * @brief Deletes a Call Home cert-to-name entry from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001330 *
Roytak2161df62023-08-02 15:04:42 +02001331 * @param[in] client_name Identifier of an existing Call Home client.
1332 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
1333 * @param[in] id Optional identifier of the Call Home CTN entry to be deleted.
roman8ba6efa2023-07-12 15:27:52 +02001334 * If 0, all of the CTN entries will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001335 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001336 * @return 0 on success, non-zero otherwise.
1337 */
Roytakb2794852023-10-18 14:30:22 +02001338int nc_server_config_del_ch_tls_ctn(const char *client_name, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +02001339 uint32_t id, struct lyd_node **config);
1340
1341/**
roman35120972023-08-08 10:39:12 +02001342 * @} TLS Call Home Server Configuration
roman8ba6efa2023-07-12 15:27:52 +02001343 */
1344
roman2eab4742023-06-06 10:00:26 +02001345#endif /* NC_ENABLED_SSH_TLS */
roman45cec4e2023-02-17 10:21:39 +01001346
romanc1d2b092023-02-02 08:58:27 +01001347#ifdef __cplusplus
1348}
1349#endif
1350
1351#endif /* NC_SESSION_SERVER_H_ */