blob: 366ec71fae824ad77bbd78a2b4568d62e26b2bc9 [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/**
126 * @brief Deletes an endpoint from the YANG data.
127 *
128 * @param[in] endpt_name Optional identifier of an endpoint to be deleted.
129 * If NULL, all of the endpoints will be deleted.
roman35120972023-08-08 10:39:12 +0200130 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200131 * @return 0 on success, non-zero otherwise.
132 */
Roytakb2794852023-10-18 14:30:22 +0200133int nc_server_config_del_endpt(const char *endpt_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200134
135#ifdef NC_ENABLED_SSH_TLS
136
137/**
138 * @brief Creates new YANG data nodes for an asymmetric key in the keystore.
139 *
140 * @param[in] ctx libyang context.
roman13145912023-08-17 15:36:54 +0200141 * @param[in] ti Transport in which the key pair will be used. Either SSH or TLS.
roman12c3d522023-07-26 13:39:30 +0200142 * @param[in] asym_key_name Identifier of the asymmetric key pair.
143 * This identifier is used to reference the key pair.
roman8ba6efa2023-07-12 15:27:52 +0200144 * @param[in] privkey_path Path to a private key file.
145 * @param[in] pubkey_path Optional path a public key file.
146 * If not supplied, it will be generated from the private key.
147 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
148 * Otherwise the new YANG data will be added to the previous data and may override it.
149 * @return 0 on success, non-zero otherwise.
150 */
Roytakb2794852023-10-18 14:30:22 +0200151int 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 +0200152 const char *privkey_path, const char *pubkey_path, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200153
154/**
155 * @brief Deletes a keystore's asymmetric key from the YANG data.
156 *
roman12c3d522023-07-26 13:39:30 +0200157 * @param[in] asym_key_name Optional identifier of the asymmetric key to be deleted.
roman8ba6efa2023-07-12 15:27:52 +0200158 * If NULL, all of the asymmetric keys in the keystore will be deleted.
159 * @param[in,out] config Configuration YANG data tree.
160 * @return 0 on success, non-zero otherwise.
161 */
Roytakb2794852023-10-18 14:30:22 +0200162int nc_server_config_del_keystore_asym_key(const char *asym_key_name, struct lyd_node **config);
roman12c3d522023-07-26 13:39:30 +0200163
164/**
165 * @brief Creates new YANG data nodes for a certificate in the keystore.
166 *
roman6430c152023-10-12 11:28:47 +0200167 * A certificate can not exist without its asymmetric key, so you must create an asymmetric key
168 * with the same identifier you pass to this function.
roman12c3d522023-07-26 13:39:30 +0200169 *
170 * @param[in] ctx libyang context.
171 * @param[in] asym_key_name Arbitrary identifier of the asymmetric key.
172 * If an asymmetric key pair with this name already exists, its contents will be changed.
173 * @param[in] cert_name Arbitrary identifier of the key pair's certificate.
174 * If a certificate with this name already exists, its contents will be changed.
175 * @param[in] cert_path Path to the PEM encoded certificate file.
176 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
177 * Otherwise the new YANG data will be added to the previous data and may override it.
178 * @return 0 on success, non-zero otherwise.
179 */
Roytakb2794852023-10-18 14:30:22 +0200180int 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 +0200181 const char *cert_path, struct lyd_node **config);
182
183/**
184 * @brief Deletes a keystore's certificate from the YANG data.
185 *
186 * @param[in] asym_key_name Identifier of an existing asymmetric key pair.
187 * @param[in] cert_name Optional identifier of a certificate to be deleted.
188 * If NULL, all of the certificates belonging to the asymmetric key pair will be deleted.
189 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
190 * Otherwise the new YANG data will be added to the previous data and may override it.
191 * @return 0 on success, non-zero otherwise.
192 */
Roytakb2794852023-10-18 14:30:22 +0200193int 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 +0200194
195/**
196 * @brief Creates new YANG data nodes for a public key in the truststore.
197 *
198 * @param[in] ctx libyang context.
roman12c3d522023-07-26 13:39:30 +0200199 * @param[in] pub_bag_name Arbitrary identifier of the public key bag.
roman8ba6efa2023-07-12 15:27:52 +0200200 * This name is used to reference the public keys in the bag.
201 * If a public key bag with this name already exists, its contents will be changed.
202 * @param[in] pubkey_name Arbitrary identifier of the public key.
roman12c3d522023-07-26 13:39:30 +0200203 * If a public key with this name already exists in the given bag, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +0200204 * @param[in] pubkey_path Path to a file containing a public key.
205 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
206 * Otherwise the new YANG data will be added to the previous data and may override it.
207 * @return 0 on success, non-zero otherwise.
208 */
romand348b942023-10-13 14:32:19 +0200209int nc_server_config_add_truststore_pubkey(const struct ly_ctx *ctx, const char *pub_bag_name, const char *pubkey_name,
210 const char *pubkey_path, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200211
212/**
213 * @brief Deletes a truststore's public key from the YANG data.
214 *
roman12c3d522023-07-26 13:39:30 +0200215 * @param[in] pub_bag_name Identifier of an existing public key bag.
roman8ba6efa2023-07-12 15:27:52 +0200216 * @param[in] pubkey_name Optional identifier of a public key to be deleted.
217 * If NULL, all of the public keys in the given bag will be deleted.
218 * @param[in,out] config Configuration YANG data tree.
219 * @return 0 on success, non-zero otherwise.
220 */
Roytakb2794852023-10-18 14:30:22 +0200221int 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 +0200222
223/**
224 * @brief Creates new YANG data nodes for a certificate in the truststore.
225 *
226 * @param[in] ctx libyang context.
227 * @param[in] cert_bag_name Arbitrary identifier of the certificate bag.
228 * This name is used to reference the certificates in the bag.
229 * If a certificate bag with this name already exists, its contents will be changed.
230 * @param[in] cert_name Arbitrary identifier of the certificate.
231 * If a certificate with this name already exists in the given bag, its contents will be changed.
232 * @param[in] cert_path Path to a file containing a PEM encoded certificate.
233 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
234 * Otherwise the new YANG data will be added to the previous data and may override it.
235 * @return 0 on success, non-zero otherwise.
236 */
Roytakb2794852023-10-18 14:30:22 +0200237int 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 +0200238 const char *cert_path, struct lyd_node **config);
239
240/**
241 * @brief Deletes a truststore's certificate from the YANG data.
242 *
243 * @param[in] cert_bag_name Identifier of an existing certificate bag.
244 * @param[in] cert_name Optional identifier of a certificate to be deleted.
245 * If NULL, all of the certificates in the given bag will be deleted.
246 * @param[in,out] config Configuration YANG data tree.
247 * @return 0 on success, non-zero otherwise.
248 */
Roytakb2794852023-10-18 14:30:22 +0200249int nc_server_config_del_truststore_cert(const char *cert_bag_name,
roman12c3d522023-07-26 13:39:30 +0200250 const char *cert_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200251
252/**
romand05b2ad2024-01-23 12:02:40 +0100253 * @brief Gets the hostkey algorithms supported by the server from the 'iana-ssh-public-key-algs' YANG module.
254 *
255 * @param[in] ctx libyang context.
256 * @param[out] hostkey_algs Container with leaf-lists containing the supported algorithms.
257 * @return 0 on success, non-zero otherwise.
258 */
259int nc_server_config_oper_get_hostkey_algs(const struct ly_ctx *ctx, struct lyd_node **hostkey_algs);
260
261/**
262 * @brief Gets the key exchange algorithms supported by the server from the 'iana-ssh-key-exchange-algs' YANG module.
263 *
264 * @param[in] ctx libyang context.
265 * @param[out] kex_algs Container with leaf-lists containing the supported algorithms.
266 * @return 0 on success, non-zero otherwise.
267 */
268int nc_server_config_oper_get_kex_algs(const struct ly_ctx *ctx, struct lyd_node **kex_algs);
269
270/**
271 * @brief Gets the encryption algorithms supported by the server from the 'iana-ssh-encryption-algs' YANG module.
272 *
273 * @param[in] ctx libyang context.
274 * @param[out] encryption_algs Container with leaf-lists containing the supported algorithms.
275 * @return 0 on success, non-zero otherwise.
276 */
277int nc_server_config_oper_get_encryption_algs(const struct ly_ctx *ctx, struct lyd_node **encryption_algs);
278
279/**
280 * @brief Gets the MAC algorithms supported by the server from the 'iana-ssh-mac-algs' YANG module.
281 *
282 * @param[in] ctx libyang context.
283 * @param[out] mac_algs Container with leaf-lists containing the supported algorithms.
284 * @return 0 on success, non-zero otherwise.
285 */
286int nc_server_config_oper_get_mac_algs(const struct ly_ctx *ctx, struct lyd_node **mac_algs);
287
288/**
roman35120972023-08-08 10:39:12 +0200289 * @} Server Configuration Functions
roman8ba6efa2023-07-12 15:27:52 +0200290 */
291
292/**
293 * @defgroup server_config_ssh SSH Server Configuration
294 * @ingroup server_config
295 *
296 * @brief SSH server configuration creation and deletion
297 * @{
298 */
299
roman3f9b65c2023-06-05 14:26:58 +0200300/**
301 * @brief Creates new YANG configuration data nodes for a hostkey.
302 *
303 * @param[in] ctx libyang context.
304 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200305 * If an endpoint with this identifier already exists, its hostkey might be changed.
roman3f9b65c2023-06-05 14:26:58 +0200306 * @param[in] hostkey_name Arbitrary identifier of the hostkey.
roman142718b2023-06-29 09:15:29 +0200307 * If a hostkey with this identifier already exists, its contents will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200308 * @param[in] privkey_path Path to a file containing a private key.
309 * The private key has to be in a PEM format. Only RSA and ECDSA keys are supported.
roman35120972023-08-08 10:39:12 +0200310 * @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 +0200311 * generated from the private key.
312 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
313 * Otherwise the new YANG data will be added to the previous data and may override it.
314 * @return 0 on success, non-zero otherwise.
315 */
Roytakb2794852023-10-18 14:30:22 +0200316int 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 +0200317 const char *privkey_path, const char *pubkey_path, struct lyd_node **config);
318
319/**
320 * @brief Deletes a hostkey from the YANG data.
321 *
322 * @param[in] ctx libyang context.
323 * @param[in] endpt_name Identifier of an existing endpoint.
324 * @param[in] hostkey_name Optional identifier of the hostkey to be deleted.
325 * If NULL, all of the hostkeys on this endpoint will be deleted.
326 * @param[in,out] config Configuration YANG data tree.
327 * @return 0 on success, non-zero otherwise.
328 */
Roytakb2794852023-10-18 14:30:22 +0200329int nc_server_config_del_ssh_hostkey(const struct ly_ctx *ctx, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +0200330 const char *hostkey_name, struct lyd_node **config);
331
332/**
romand348b942023-10-13 14:32:19 +0200333 * @brief Creates new YANG data nodes for a reference to an asymmetric key located in the keystore.
334 *
335 * This asymmetric key pair will be used as the SSH hostkey.
336 *
337 * @param[in] ctx libyang context.
338 * @param[in] endpt_name Arbitrary identifier of an endpoint.
339 * If an endpoint with this identifier already exists, its contents will be changed.
340 * @param[in] hostkey_name Arbitrary identifier of the endpoint's hostkey.
341 * If an endpoint's hostkey with this identifier already exists, its contents will be changed.
342 * @param[in] keystore_reference Name of the asymmetric key pair to be referenced and used as a hostkey.
343 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
344 * Otherwise the new YANG data will be added to the previous data and may override it.
345 * @return 0 on success, non-zero otherwise.
346 */
347int nc_server_config_add_ssh_keystore_ref(const struct ly_ctx *ctx, const char *endpt_name, const char *hostkey_name,
348 const char *keystore_reference, struct lyd_node **config);
349
350/**
351 * @brief Deletes a keystore reference from the YANG data.
352 *
353 * @param[in] endpt_name Identifier of an existing endpoint.
354 * @param[in] hostkey_name Identifier of an existing hostkey on the given endpoint.
355 * @param[in,out] config Configuration YANG data tree.
356 * @return 0 on success, non-zero otherwise.
357 */
358int nc_server_config_del_ssh_keystore_ref(const char *endpt_name, const char *hostkey_name,
359 struct lyd_node **config);
360
361/**
roman8ba6efa2023-07-12 15:27:52 +0200362 * @brief Creates new YANG configuration data nodes for an SSH user's public key authentication method.
363 *
364 * @param[in] ctx libyang context.
365 * @param[in] endpt_name Arbitrary identifier of the endpoint.
366 * If an endpoint with this identifier already exists, its user might be changed.
367 * @param[in] user_name Arbitrary identifier of the user.
368 * If an user with this identifier already exists, its contents will be changed.
369 * @param[in] pubkey_name Arbitrary identifier of the user's public key.
370 * If a public key with this identifier already exists for this user, its contents will be changed.
371 * @param[in] pubkey_path Path to a file containing the user's public key.
372 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
373 * Otherwise the new YANG data will be added to the previous data and may override it.
374 * @return 0 on success, non-zero otherwise.
375 */
Roytakb2794852023-10-18 14:30:22 +0200376int nc_server_config_add_ssh_user_pubkey(const struct ly_ctx *ctx, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +0200377 const char *user_name, const char *pubkey_name, const char *pubkey_path, struct lyd_node **config);
378
379/**
380 * @brief Deletes an SSH user's public key from the YANG data.
381 *
382 * @param[in] endpt_name Identifier of an existing endpoint.
383 * @param[in] user_name Identifier of an existing user on the given endpoint.
384 * @param[in] pubkey_name Optional identifier of a public key to be deleted.
385 * If NULL, all of the users public keys will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200386 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200387 * @return 0 on success, non-zero otherwise.
388 */
Roytakb2794852023-10-18 14:30:22 +0200389int nc_server_config_del_ssh_user_pubkey(const char *endpt_name, const char *user_name,
roman8ba6efa2023-07-12 15:27:52 +0200390 const char *pubkey_name, struct lyd_node **config);
391
392/**
romana9ec3362023-12-21 10:59:57 +0100393 * @brief Creates new YANG configuration data nodes for an SSH user that will use system's authorized_keys to authenticate.
394 *
395 * The path to the authorized_keys file must be configured to successfully
396 * authenticate, see ::nc_server_ssh_set_authkey_path_format().
397 *
398 * @param[in] ctx libyang context.
399 * @param[in] endpt_name Arbitrary identifier of the endpoint.
400 * If an endpoint with this identifier already exists, its user might be changed.
401 * @param[in] user_name Arbitrary identifier of the user.
402 * If an user with this identifier already exists, its contents will be changed.
403 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
404 * Otherwise the new YANG data will be added to the previous data and may override it.
405 * @return 0 on success, non-zero otherwise.
406 */
407int nc_server_config_add_ssh_user_authkey(const struct ly_ctx *ctx, const char *endpt_name,
408 const char *user_name, struct lyd_node **config);
409
410/**
411 * @brief Deletes an SSH user's authorized_keys method from the YANG data.
412 *
413 * @param[in] endpt_name Identifier of an existing endpoint.
414 * @param[in] user_name Identifier of an existing user on the given endpoint.
415 * @param[in,out] config Modified configuration YANG data tree.
416 * @return 0 on success, non-zero otherwise.
417 */
418int nc_server_config_del_ssh_user_authkey(const char *endpt_name, const char *user_name, struct lyd_node **config);
419
420/**
roman8ba6efa2023-07-12 15:27:52 +0200421 * @brief Creates new YANG configuration data nodes for an SSH user's password authentication method.
422 *
423 * @param[in] ctx libyang context.
424 * @param[in] endpt_name Arbitrary identifier of the endpoint.
425 * If an endpoint with this identifier already exists, its user might be changed.
426 * @param[in] user_name Arbitrary identifier of the user.
427 * If an user with this identifier already exists, its contents will be changed.
roman35120972023-08-08 10:39:12 +0200428 * @param[in] password Clear-text password to be set for the user. It will be hashed.
roman8ba6efa2023-07-12 15:27:52 +0200429 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
430 * Otherwise the new YANG data will be added to the previous data and may override it.
431 * @return 0 on success, non-zero otherwise.
432 */
Roytakb2794852023-10-18 14:30:22 +0200433int nc_server_config_add_ssh_user_password(const struct ly_ctx *ctx, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +0200434 const char *user_name, const char *password, struct lyd_node **config);
435
436/**
437 * @brief Deletes an SSH user's password from the YANG data.
438 *
439 * @param[in] endpt_name Identifier of an existing endpoint.
440 * @param[in] user_name Identifier of an existing user on the given endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200441 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200442 * @return 0 on success, non-zero otherwise.
443 */
Roytakb2794852023-10-18 14:30:22 +0200444int nc_server_config_del_ssh_user_password(const char *endpt_name, const char *user_name,
roman8ba6efa2023-07-12 15:27:52 +0200445 struct lyd_node **config);
446
447/**
448 * @brief Creates new YANG configuration data nodes for an SSH user's keyboard interactive authentication method.
449 *
romanc6518422023-11-30 16:39:00 +0100450 * One of Linux PAM, local users, or user callback is used to authenticate users with this SSH method (see \ref ln2doc_kbdint "the documentation").
roman808f3f62023-11-23 16:01:04 +0100451 *
452 * @param[in] ctx libyang context.
453 * @param[in] endpt_name Arbitrary identifier of the endpoint.
454 * If an endpoint with this identifier already exists, its user might be changed.
455 * @param[in] user_name Arbitrary identifier of the user.
456 * If an user with this identifier already exists, its contents will be changed.
457 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
458 * Otherwise the new YANG data will be added to the previous data and may override it.
459 * @return 0 on success, non-zero otherwise.
460 */
Roytakb2794852023-10-18 14:30:22 +0200461int nc_server_config_add_ssh_user_interactive(const struct ly_ctx *ctx, const char *endpt_name,
roman808f3f62023-11-23 16:01:04 +0100462 const char *user_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200463
464/**
465 * @brief Deletes an SSH user's keyboard interactive authentication from the YANG data.
466 *
467 * @param[in] endpt_name Identifier of an existing endpoint.
468 * @param[in] user_name Identifier of an existing user on the given endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200469 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200470 * @return 0 on success, non-zero otherwise.
471 */
Roytakb2794852023-10-18 14:30:22 +0200472int nc_server_config_del_ssh_user_interactive(const char *endpt_name, const char *user_name,
roman8ba6efa2023-07-12 15:27:52 +0200473 struct lyd_node **config);
474
475/**
476 * @brief Deletes an SSH user from the YANG data.
477 *
478 * @param[in] endpt_name Identifier of an existing endpoint.
479 * @param[in] user_name Optional identifier of an user to be deleted.
480 * If NULL, all of the users on this endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200481 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200482 * @return 0 on success, non-zero otherwise.
483 */
Roytakb2794852023-10-18 14:30:22 +0200484int nc_server_config_del_ssh_user(const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +0200485 const char *user_name, struct lyd_node **config);
486
487/**
romand348b942023-10-13 14:32:19 +0200488 * @brief Creates new YANG data nodes for a reference to a public key bag located in the truststore.
489 *
490 * The public key's located in the bag will be used for client authentication.
491 *
492 * @param[in] ctx libyang context.
493 * @param[in] endpt_name Arbitrary identifier of an endpoint.
494 * If an endpoint with this identifier already exists, its contents will be changed.
495 * @param[in] user_name Arbitrary identifier of the endpoint's user.
496 * If an endpoint's user with this identifier already exists, its contents will be changed.
497 * @param[in] truststore_reference Name of the public key bag to be referenced and used for authentication.
498 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
499 * Otherwise the new YANG data will be added to the previous data and may override it.
500 * @return 0 on success, non-zero otherwise.
501 */
502int nc_server_config_add_ssh_truststore_ref(const struct ly_ctx *ctx, const char *endpt_name, const char *user_name,
503 const char *truststore_reference, struct lyd_node **config);
504
505/**
506 * @brief Deletes a truststore reference from the YANG data.
507 *
508 * @param[in] endpt_name Identifier of an existing endpoint.
509 * @param[in] user_name Identifier of an user on the given endpoint whose truststore reference will be deleted.
510 * @param[in,out] config Modified configuration YANG data tree.
511 * @return 0 on success, non-zero otherwise.
512 */
513int nc_server_config_del_ssh_truststore_ref(const char *endpt_name, const char *user_name,
514 struct lyd_node **config);
515
516/**
roman8ba6efa2023-07-12 15:27:52 +0200517 * @brief Creates new YANG configuration data nodes, which will be a reference to another SSH endpoint's users.
518 *
519 * Whenever a client tries to connect to the referencing endpoint, all of its users will be tried first. If no match is
520 * found, the referenced endpoint's configured users will be tried.
521 *
522 * @param[in] ctx libyang context
523 * @param[in] endpt_name Arbitrary identifier of the endpoint.
524 * If an endpoint with this identifier already exists, its contents will be changed.
525 * @param[in] referenced_endpt Identifier of an endpoint, which has to exist whenever this data
526 * is applied. The referenced endpoint can reference another one and so on, but there mustn't be a cycle.
527 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
528 * Otherwise the new YANG data will be added to the previous data and may override it.
529 * @return 0 on success, non-zero otherwise.
530 */
Roytakb2794852023-10-18 14:30:22 +0200531int nc_server_config_add_ssh_endpoint_client_ref(const struct ly_ctx *ctx, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +0200532 const char *referenced_endpt, struct lyd_node **config);
533
534/**
535 * @brief Deletes reference to another SSH endpoint's users from the YANG data.
536 *
537 * @param[in] endpt_name Identifier of an existing endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200538 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200539 * @return 0 on success, non-zero otherwise.
540 */
Roytakb2794852023-10-18 14:30:22 +0200541int nc_server_config_del_ssh_endpoint_client_ref(const char *endpt_name, struct lyd_node **config);
roman9b1379c2023-03-31 10:11:10 +0200542
543/**
roman35120972023-08-08 10:39:12 +0200544 * @} SSH Server Configuration
roman9b1379c2023-03-31 10:11:10 +0200545 */
roman9b1379c2023-03-31 10:11:10 +0200546
547/**
roman8ba6efa2023-07-12 15:27:52 +0200548 * @defgroup server_config_tls TLS Server Configuration
549 * @ingroup server_config
roman9b1379c2023-03-31 10:11:10 +0200550 *
roman8ba6efa2023-07-12 15:27:52 +0200551 * @brief TLS server configuration creation and deletion
552 * @{
roman9b1379c2023-03-31 10:11:10 +0200553 */
roman2e797ef2023-06-19 10:47:49 +0200554
555/**
roman3f9b65c2023-06-05 14:26:58 +0200556 * @brief Creates new YANG configuration data nodes for a server's certificate.
557 *
558 * @param[in] ctx libyang context.
559 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200560 * If an endpoint with this identifier already exists, its server certificate will be changed.
roman6c4efcd2023-08-08 10:18:44 +0200561 * @param[in] privkey_path Path to the server's PEM encoded private key file.
roman3f9b65c2023-06-05 14:26:58 +0200562 * @param[in] pubkey_path Optional path to the server's public key file. If not provided,
563 * it will be generated from the private key.
romane6ec60e2023-10-19 15:21:52 +0200564 * @param[in] cert_path Path to the server's certificate file.
roman3f9b65c2023-06-05 14:26:58 +0200565 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
566 * Otherwise the new YANG data will be added to the previous data and may override it.
567 * @return 0 on success, non-zero otherwise.
568 */
romane6ec60e2023-10-19 15:21:52 +0200569int nc_server_config_add_tls_server_cert(const struct ly_ctx *ctx, const char *endpt_name, const char *privkey_path,
570 const char *pubkey_path, const char *cert_path, struct lyd_node **config);
roman3f9b65c2023-06-05 14:26:58 +0200571
572/**
roman8ba6efa2023-07-12 15:27:52 +0200573 * @brief Deletes the server's certificate from the YANG data.
574 *
575 * @param[in] endpt_name Identifier of an existing endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200576 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200577 * @return 0 on success, non-zero otherwise.
578 */
romane6ec60e2023-10-19 15:21:52 +0200579int nc_server_config_del_tls_server_cert(const char *endpt_name, struct lyd_node **config);
romand348b942023-10-13 14:32:19 +0200580
581/**
582 * @brief Creates new YANG configuration data nodes for a keystore reference to the TLS server's certificate.
583 *
584 * @param[in] ctx libyang context.
585 * @param[in] endpt_name Arbitrary identifier of the endpoint.
586 * If an endpoint with this identifier already exists, its contents will be changed.
587 * @param[in] asym_key_ref Name of the asymmetric key pair in the keystore to be referenced.
588 * @param[in] cert_ref Name of the certificate, which must belong to the given asymmetric key pair, to be referenced.
589 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
590 * Otherwise the new YANG data will be added to the previous data and may override it.
591 * @return 0 on success, non-zero otherwise.
592 */
593int nc_server_config_add_tls_keystore_ref(const struct ly_ctx *ctx, const char *endpt_name, const char *asym_key_ref,
594 const char *cert_ref, struct lyd_node **config);
595
596/**
597 * @brief Deletes a TLS server certificate keystore reference from the YANG data.
598 *
599 * @param[in] endpt_name Identifier of an existing endpoint.
600 * @param[in,out] config Modified configuration YANG data tree.
601 * @return 0 on success, non-zero otherwise.
602 */
603int nc_server_config_del_tls_keystore_ref(const char *endpt_name, struct lyd_node **config);
roman12c3d522023-07-26 13:39:30 +0200604
605/**
roman3f9b65c2023-06-05 14:26:58 +0200606 * @brief Creates new YANG configuration data nodes for a client's (end-entity) certificate.
607 *
608 * @param[in] ctx libyang context.
609 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200610 * If an endpoint with this identifier already exists, its contents will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200611 * @param[in] cert_name Arbitrary identifier of the client's certificate.
roman35120972023-08-08 10:39:12 +0200612 * If a client certificate with this identifier already exists, it will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200613 * @param[in] cert_path Path to the client's certificate file.
614 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
615 * Otherwise the new YANG data will be added to the previous data and may override it.
616 * @return 0 on success, non-zero otherwise.
617 */
romane6ec60e2023-10-19 15:21:52 +0200618int 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 +0200619 const char *cert_path, struct lyd_node **config);
620
621/**
roman8ba6efa2023-07-12 15:27:52 +0200622 * @brief Deletes a client (end-entity) certificate from the YANG data.
623 *
624 * @param[in] endpt_name Identifier of an existing endpoint.
625 * @param[in] cert_name Optional name of a certificate to be deleted.
626 * If NULL, all of the end-entity certificates on the given endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200627 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200628 * @return 0 on success, non-zero otherwise.
629 */
romane6ec60e2023-10-19 15:21:52 +0200630int 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 +0200631
632/**
633 * @brief Creates new YANG configuration data nodes for a truststore reference to a set of client (end-entity) certificates.
634 *
635 * @param[in] ctx libyang context.
636 * @param[in] endpt_name Arbitrary identifier of the endpoint.
637 * If an endpoint with this identifier already exists, its contents will be changed.
638 * @param[in] cert_bag_ref Identifier of the certificate bag in the truststore to be referenced.
639 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
640 * Otherwise the new YANG data will be added to the previous data and may override it.
641 * @return 0 on success, non-zero otherwise.
642 */
643int nc_server_config_add_tls_client_cert_truststore_ref(const struct ly_ctx *ctx, const char *endpt_name,
644 const char *cert_bag_ref, struct lyd_node **config);
645
646/**
647 * @brief Deletes a client (end-entity) certificates truststore reference from the YANG data.
648 *
649 * @param[in] endpt_name Identifier of an existing endpoint.
650 * @param[in,out] config Modified configuration YANG data tree.
651 * @return 0 on success, non-zero otherwise.
652 */
653int nc_server_config_del_tls_client_cert_truststore_ref(const char *endpt_name, struct lyd_node **config);
roman12c3d522023-07-26 13:39:30 +0200654
655/**
roman3f9b65c2023-06-05 14:26:58 +0200656 * @brief Creates new YANG configuration data nodes for a client certificate authority (trust-anchor) certificate.
657 *
658 * @param[in] ctx libyang context.
659 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200660 * If an endpoint with this identifier already exists, its contents will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200661 * @param[in] cert_name Arbitrary identifier of the certificate authority certificate.
roman35120972023-08-08 10:39:12 +0200662 * If a CA with this identifier already exists, it will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200663 * @param[in] cert_path Path to the CA certificate file.
664 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
665 * Otherwise the new YANG data will be added to the previous data and may override it.
666 * @return 0 on success, non-zero otherwise.
667 */
romane6ec60e2023-10-19 15:21:52 +0200668int 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 +0200669 const char *cert_path, struct lyd_node **config);
670
671/**
roman8ba6efa2023-07-12 15:27:52 +0200672 * @brief Deletes a client certificate authority (trust-anchor) certificate from the YANG data.
673 *
674 * @param[in] endpt_name Identifier of an existing endpoint.
675 * @param[in] cert_name Optional name of a certificate to be deleted.
676 * If NULL, all of the CA certificates on the given endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200677 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200678 * @return 0 on success, non-zero otherwise.
679 */
romane6ec60e2023-10-19 15:21:52 +0200680int 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 +0200681
682/**
683 * @brief Creates new YANG configuration data nodes for a truststore reference to a set of client certificate authority (trust-anchor) certificates.
684 *
685 * @param[in] ctx libyang context.
686 * @param[in] endpt_name Arbitrary identifier of the endpoint.
687 * If an endpoint with this identifier already exists, its contents will be changed.
688 * @param[in] cert_bag_ref Identifier of the certificate bag in the truststore to be referenced.
689 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
690 * Otherwise the new YANG data will be added to the previous data and may override it.
691 * @return 0 on success, non-zero otherwise.
692 */
romane6ec60e2023-10-19 15:21:52 +0200693int nc_server_config_add_tls_ca_cert_truststore_ref(const struct ly_ctx *ctx, const char *endpt_name,
romand348b942023-10-13 14:32:19 +0200694 const char *cert_bag_ref, struct lyd_node **config);
695
696/**
697 * @brief Deletes a client certificate authority (trust-anchor) certificates truststore reference from the YANG data.
698 *
699 * @param[in] endpt_name Identifier of an existing endpoint.
700 * @param[in,out] config Modified configuration YANG data tree.
701 * @return 0 on success, non-zero otherwise.
702 */
romane6ec60e2023-10-19 15:21:52 +0200703int nc_server_config_del_tls_ca_cert_truststore_ref(const char *endpt_name, struct lyd_node **config);
roman12c3d522023-07-26 13:39:30 +0200704
705/**
Roytak76958912023-09-29 15:25:14 +0200706 * @brief Creates new YANG configuration data nodes, which will be a reference to another TLS endpoint's certificates.
707 *
708 * Whenever an user tries to connect to the referencing endpoint, all of its certificates will be tried first. If no match is
709 * found, the referenced endpoint's configured certificates will be tried. The same applies to cert-to-name entries.
710 *
711 * @param[in] ctx libyang context
712 * @param[in] endpt_name Arbitrary identifier of the endpoint.
713 * If an endpoint with this identifier already exists, its contents will be changed.
714 * @param[in] referenced_endpt Identifier of an endpoint, which has to exist whenever this data
715 * is applied. The referenced endpoint can reference another one and so on, but there mustn't be a cycle.
716 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
717 * Otherwise the new YANG data will be added to the previous data and may override it.
718 * @return 0 on success, non-zero otherwise.
719 */
Roytakb2794852023-10-18 14:30:22 +0200720int nc_server_config_add_tls_endpoint_client_ref(const struct ly_ctx *ctx, const char *endpt_name,
Roytak76958912023-09-29 15:25:14 +0200721 const char *referenced_endpt, struct lyd_node **config);
722
723/**
724 * @brief Deletes reference to another TLS endpoint's users from the YANG data.
725 *
726 * @param[in] endpt_name Identifier of an existing endpoint.
727 * @param[in,out] config Modified configuration YANG data tree.
728 * @return 0 on success, non-zero otherwise.
729 */
Roytakb2794852023-10-18 14:30:22 +0200730int nc_server_config_del_tls_endpoint_client_ref(const char *endpt_name, struct lyd_node **config);
Roytak76958912023-09-29 15:25:14 +0200731
732/**
roman3f9b65c2023-06-05 14:26:58 +0200733 * @brief Creates new YANG configuration data nodes for a cert-to-name entry.
734 *
735 * @param[in] ctx libyang context.
736 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200737 * If an endpoint with this identifier already exists, its contents will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200738 * @param[in] id ID of the entry. The lower the ID, the higher the priority of the entry (it will be checked earlier).
739 * @param[in] fingerprint Optional fingerprint of the entry. The fingerprint should always be set, however if it is
740 * not set, it will match any certificate. Entry with no fingerprint should therefore be placed only as the last entry.
741 * @param[in] map_type Mapping username to the certificate option.
742 * @param[in] name Username for this cert-to-name entry.
743 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
744 * Otherwise the new YANG data will be added to the previous data and may override it.
745 * @return 0 on success, non-zero otherwise.
746 */
Roytakb2794852023-10-18 14:30:22 +0200747int 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 +0200748 NC_TLS_CTN_MAPTYPE map_type, const char *name, struct lyd_node **config);
749
roman12644fe2023-06-08 11:06:42 +0200750/**
roman8ba6efa2023-07-12 15:27:52 +0200751 * @brief Deletes a cert-to-name entry from the YANG data.
752 *
753 * @param[in] endpt_name Identifier of an existing endpoint.
754 * @param[in] id Optional ID of the CTN entry.
755 * If 0, all of the cert-to-name entries on the given endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200756 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200757 * @return 0 on success, non-zero otherwise.
758 */
Roytakb2794852023-10-18 14:30:22 +0200759int nc_server_config_del_tls_ctn(const char *endpt_name, uint32_t id, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200760
761/**
roman35120972023-08-08 10:39:12 +0200762 * @} TLS Server Configuration
roman8ba6efa2023-07-12 15:27:52 +0200763 */
764
765/**
roman35120972023-08-08 10:39:12 +0200766 * @defgroup server_config_ch Call Home Server Configuration
roman8ba6efa2023-07-12 15:27:52 +0200767 * @ingroup server_config
768 *
Roytak2161df62023-08-02 15:04:42 +0200769 * @brief Call Home server configuration creation and deletion
roman8ba6efa2023-07-12 15:27:52 +0200770 * @{
771 */
772
773/**
roman35120972023-08-08 10:39:12 +0200774 * @} Call Home Server Configuration
775 */
776
777/**
778 * @defgroup server_config_ch_functions Call Home Server Configuration Functions
779 * @ingroup server_config_ch
780 *
781 * @brief Call Home server configuration functions
782 * @{
783 */
784
785/**
Roytak2161df62023-08-02 15:04:42 +0200786 * @brief Creates new YANG configuration data nodes for a Call Home client's address and port.
roman142718b2023-06-29 09:15:29 +0200787 *
788 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200789 * @param[in] client_name Arbitrary identifier of the Call Home client.
790 * If a Call Home client with this identifier already exists, its contents will be changed.
roman142718b2023-06-29 09:15:29 +0200791 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
792 * If the client's endpoint with this identifier already exists, its contents will be changed.
793 * @param[in] transport Transport protocol to be used on this endpoint - either SSH or TLS.
794 * @param[in] address Address to connect to.
795 * @param[in] port Port to connect to.
796 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
797 * Otherwise the new YANG data will be added to the previous data and may override it.
798 * @return 0 on success, non-zero otherwise.
799 */
Roytakb2794852023-10-18 14:30:22 +0200800int 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 +0200801 NC_TRANSPORT_IMPL transport, const char *address, const char *port, struct lyd_node **config);
802
roman8ba6efa2023-07-12 15:27:52 +0200803#endif /* NC_ENABLED_SSH_TLS */
804
805/**
Roytak2161df62023-08-02 15:04:42 +0200806 * @brief Deletes a Call Home client from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +0200807 *
808 * @param[in] client_name Optional identifier of a client to be deleted.
Roytak2161df62023-08-02 15:04:42 +0200809 * If NULL, all of the Call Home clients will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200810 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200811 * @return 0 on success, non-zero otherwise.
812 */
Roytakb2794852023-10-18 14:30:22 +0200813int nc_server_config_del_ch_client(const char *client_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200814
815/**
Roytak2161df62023-08-02 15:04:42 +0200816 * @brief Deletes a Call Home endpoint from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +0200817 *
Roytak2161df62023-08-02 15:04:42 +0200818 * @param[in] client_name Identifier of an existing Call Home client.
roman8ba6efa2023-07-12 15:27:52 +0200819 * @param[in] endpt_name Optional identifier of a CH endpoint to be deleted.
820 * If NULL, all of the CH endpoints which belong to the given client will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200821 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200822 * @return 0 on success, non-zero otherwise.
823 */
Roytakb2794852023-10-18 14:30:22 +0200824int nc_server_config_del_ch_endpt(const char *client_name, const char *endpt_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200825
826/**
Roytak2161df62023-08-02 15:04:42 +0200827 * @brief Creates new YANG configuration data nodes for the Call Home persistent connection type.
roman8ba6efa2023-07-12 15:27:52 +0200828 *
829 * This is the default connection type. If periodic connection type was set before, it will be unset.
830 *
831 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200832 * @param[in] client_name Arbitrary identifier of the Call Home client.
833 * If a Call Home client with this identifier already exists, its contents will be changed.
Roytak9b32c0f2023-08-02 15:07:29 +0200834 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +0200835 * Otherwise the new YANG data will be added to the previous data and may override it.
836 * @return 0 on success, non-zero otherwise.
837 */
Roytakb2794852023-10-18 14:30:22 +0200838int 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 +0200839
840/**
Roytak2161df62023-08-02 15:04:42 +0200841 * @brief Creates new YANG configuration data nodes for the period parameter of the Call Home periodic connection type.
roman8ba6efa2023-07-12 15:27:52 +0200842 *
843 * If called, the persistent connection type will be replaced by periodic.
844 *
845 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200846 * @param[in] client_name Arbitrary identifier of the Call Home client.
847 * If a Call Home client with this identifier already exists, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +0200848 * @param[in] period Duration between periodic connections in minutes.
Roytak9b32c0f2023-08-02 15:07:29 +0200849 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +0200850 * Otherwise the new YANG data will be added to the previous data and may override it.
851 * @return 0 on success, non-zero otherwise.
852 */
Roytakb2794852023-10-18 14:30:22 +0200853int nc_server_config_add_ch_period(const struct ly_ctx *ctx, const char *client_name, uint16_t period,
roman8ba6efa2023-07-12 15:27:52 +0200854 struct lyd_node **config);
855
856/**
Roytak2161df62023-08-02 15:04:42 +0200857 * @brief Deletes the Call Home period parameter of the periodic connection type from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +0200858 *
859 * This behaves the same as setting the period to 60 minutes, which is the default value of this node.
860 *
Roytak2161df62023-08-02 15:04:42 +0200861 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +0200862 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200863 * @return 0 on success, non-zero otherwise.
864 */
Roytakb2794852023-10-18 14:30:22 +0200865int nc_server_config_del_ch_period(const char *client_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200866
867/**
Roytak2161df62023-08-02 15:04:42 +0200868 * @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 +0200869 *
870 * If called, the persistent connection type will be replaced by periodic.
871 *
872 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200873 * @param[in] client_name Arbitrary identifier of the Call Home client.
874 * If a Call Home client with this identifier already exists, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +0200875 * @param[in] anchor_time Timestamp before or after which a series of periodic connections are determined.
Roytak9b32c0f2023-08-02 15:07:29 +0200876 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +0200877 * Otherwise the new YANG data will be added to the previous data and may override it.
878 * @return 0 on success, non-zero otherwise.
879 */
Roytakb2794852023-10-18 14:30:22 +0200880int nc_server_config_add_ch_anchor_time(const struct ly_ctx *ctx, const char *client_name,
roman8ba6efa2023-07-12 15:27:52 +0200881 const char *anchor_time, struct lyd_node **config);
882
883/**
Roytak2161df62023-08-02 15:04:42 +0200884 * @brief Deletes the Call Home anchor time parameter of the periodic connection type from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +0200885 *
Roytak2161df62023-08-02 15:04:42 +0200886 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +0200887 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200888 * @return 0 on success, non-zero otherwise.
889 */
Roytakb2794852023-10-18 14:30:22 +0200890int nc_server_config_del_ch_anchor_time(const char *client_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200891
892/**
Roytak2161df62023-08-02 15:04:42 +0200893 * @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 +0200894 *
895 * If called, the persistent connection type will be replaced by periodic.
896 *
897 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200898 * @param[in] client_name Arbitrary identifier of the Call Home client.
899 * If a Call Home client with this identifier already exists, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +0200900 * @param[in] idle_timeout Specifies the maximum number of seconds that a session may remain idle.
Roytak9b32c0f2023-08-02 15:07:29 +0200901 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +0200902 * Otherwise the new YANG data will be added to the previous data and may override it.
903 * @return 0 on success, non-zero otherwise.
904 */
Roytakb2794852023-10-18 14:30:22 +0200905int nc_server_config_add_ch_idle_timeout(const struct ly_ctx *ctx, const char *client_name,
roman8ba6efa2023-07-12 15:27:52 +0200906 uint16_t idle_timeout, struct lyd_node **config);
907
908/**
Roytak2161df62023-08-02 15:04:42 +0200909 * @brief Deletes the Call Home idle timeout parameter of the periodic connection type from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +0200910 *
911 * This behaves the same as setting the timeout to 180 seconds, which is the default value of this node.
912 *
Roytak2161df62023-08-02 15:04:42 +0200913 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +0200914 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200915 * @return 0 on success, non-zero otherwise.
916 */
Roytakb2794852023-10-18 14:30:22 +0200917int nc_server_config_del_ch_idle_timeout(const char *client_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200918
919/**
Roytak2161df62023-08-02 15:04:42 +0200920 * @brief Creates new YANG configuration data nodes for the Call Home reconnect strategy.
roman8ba6efa2023-07-12 15:27:52 +0200921 *
922 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200923 * @param[in] client_name Arbitrary identifier of the Call Home client.
924 * If a Call Home client with this identifier already exists, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +0200925 * @param[in] start_with Specifies which endpoint to try if a connection is unsuccessful. Default value is NC_CH_FIRST_LISTED.
926 * @param[in] max_wait The number of seconds after which a connection to an endpoint is deemed unsuccessful. Default value if 5.
927 * @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 +0200928 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +0200929 * Otherwise the new YANG data will be added to the previous data and may override it.
930 * @return 0 on success, non-zero otherwise.
931 */
Roytakb2794852023-10-18 14:30:22 +0200932int nc_server_config_add_ch_reconnect_strategy(const struct ly_ctx *ctx, const char *client_name,
roman8ba6efa2023-07-12 15:27:52 +0200933 NC_CH_START_WITH start_with, uint16_t max_wait, uint8_t max_attempts, struct lyd_node **config);
934
935/**
Roytak2161df62023-08-02 15:04:42 +0200936 * @brief Resets the values of the Call Home reconnect strategy nodes to their defaults.
roman8ba6efa2023-07-12 15:27:52 +0200937 *
938 * The default values are: start-with = NC_CH_FIRST_LISTED, max-wait = 5 and max-attempts = 3.
939 *
Roytak2161df62023-08-02 15:04:42 +0200940 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +0200941 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200942 * @return 0 on success, non-zero otherwise.
943 */
Roytakb2794852023-10-18 14:30:22 +0200944int nc_server_config_del_ch_reconnect_strategy(const char *client_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200945
946/**
roman35120972023-08-08 10:39:12 +0200947 * @} Call Home Server Configuration Functions
roman8ba6efa2023-07-12 15:27:52 +0200948 */
949
950#ifdef NC_ENABLED_SSH_TLS
951
952/**
Roytak2161df62023-08-02 15:04:42 +0200953 * @defgroup server_config_ch_ssh SSH Call Home Server Configuration
roman8ba6efa2023-07-12 15:27:52 +0200954 * @ingroup server_config_ch
955 *
Roytak2161df62023-08-02 15:04:42 +0200956 * @brief SSH Call Home server configuration creation and deletion
roman8ba6efa2023-07-12 15:27:52 +0200957 * @{
958 */
959
roman142718b2023-06-29 09:15:29 +0200960/**
Roytak2161df62023-08-02 15:04:42 +0200961 * @brief Creates new YANG data nodes for a Call Home SSH hostkey.
roman142718b2023-06-29 09:15:29 +0200962 *
963 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200964 * @param[in] client_name Arbitrary identifier of the Call Home client.
965 * If a Call Home client with this identifier already exists, its contents will be changed.
roman142718b2023-06-29 09:15:29 +0200966 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
967 * If the client's endpoint with this identifier already exists, its contents will be changed.
968 * @param[in] hostkey_name Arbitrary identifier of the endpoint's hostkey.
969 * If the endpoint's hostkey with this identifier already exists, its contents will be changed.
970 * @param[in] privkey_path Path to a file containing a private key.
971 * The private key has to be in a PEM format. Only RSA and ECDSA keys are supported.
972 * @param[in] pubkey_path Path to a file containing a public key. If NULL, public key will be
973 * generated from the private key.
974 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
975 * Otherwise the new YANG data will be added to the previous data and may override it.
976 * @return 0 on success, non-zero otherwise.
977 */
Roytakb2794852023-10-18 14:30:22 +0200978int 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 +0200979 const char *hostkey_name, const char *privkey_path, const char *pubkey_path, struct lyd_node **config);
980
roman142718b2023-06-29 09:15:29 +0200981/**
Roytak2161df62023-08-02 15:04:42 +0200982 * @brief Deletes a Call Home hostkey from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +0200983 *
Roytak2161df62023-08-02 15:04:42 +0200984 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +0200985 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
roman8ba6efa2023-07-12 15:27:52 +0200986 * @param[in] hostkey_name Optional identifier of a hostkey to be deleted.
987 * If NULL, all of the hostkeys on the given endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200988 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200989 * @return 0 on success, non-zero otherwise.
990 */
Roytakb2794852023-10-18 14:30:22 +0200991int nc_server_config_del_ch_ssh_hostkey(const char *client_name, const char *endpt_name,
roman9d5e5a52023-07-14 12:43:44 +0200992 const char *hostkey_name, struct lyd_node **config);
993
994/**
romand348b942023-10-13 14:32:19 +0200995 * @brief Creates new YANG data nodes for a reference to an asymmetric key located in the keystore.
996 *
997 * This asymmetric key pair will be used as the Call Home SSH hostkey.
998 *
999 * @param[in] ctx libyang context.
1000 * @param[in] client_name Arbitrary identifier of the Call Home client.
1001 * If a Call Home client with this identifier already exists, its contents will be changed.
1002 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1003 * If the client's endpoint with this identifier already exists, its contents will be changed.
1004 * @param[in] hostkey_name Arbitrary identifier of the endpoint's hostkey.
1005 * If the endpoint's hostkey with this identifier already exists, its contents will be changed.
1006 * @param[in] keystore_reference Name of the asymmetric key pair to be referenced and used as a hostkey.
1007 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1008 * Otherwise the new YANG data will be added to the previous data and may override it.
1009 * @return 0 on success, non-zero otherwise.
1010 */
1011int nc_server_config_add_ch_ssh_keystore_ref(const struct ly_ctx *ctx, const char *client_name,
1012 const char *endpt_name, const char *hostkey_name, const char *keystore_reference, struct lyd_node **config);
1013
1014/**
1015 * @brief Deletes a Call Home keystore reference from the YANG data.
1016 *
1017 * @param[in] client_name Identifier of an existing Call Home client.
1018 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1019 * @param[in] hostkey_name Identifier of an existing hostkey that belongs to the given CH endpoint.
1020 * @param[in,out] config Modified configuration YANG data tree.
1021 * @return 0 on success, non-zero otherwise.
1022 */
1023int nc_server_config_del_ch_ssh_keystore_ref(const char *client_name, const char *endpt_name,
1024 const char *hostkey_name, struct lyd_node **config);
1025
1026/**
Roytak2161df62023-08-02 15:04:42 +02001027 * @brief Creates new YANG data nodes for a Call Home SSH user's public key authentication method.
roman142718b2023-06-29 09:15:29 +02001028 *
1029 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001030 * @param[in] client_name Arbitrary identifier of the Call Home client.
1031 * If a Call Home client with this identifier already exists, its contents will be changed.
roman142718b2023-06-29 09:15:29 +02001032 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1033 * If the client's endpoint with this identifier already exists, its contents will be changed.
1034 * @param[in] user_name Arbitrary identifier of the endpoint's user.
1035 * If the endpoint's user with this identifier already exists, its contents will be changed.
1036 * @param[in] pubkey_name Arbitrary identifier of the user's public key.
1037 * If the user's public key with this identifier already exists, its contents will be changed.
1038 * @param[in] pubkey_path Path to a file containing a public key.
1039 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1040 * Otherwise the new YANG data will be added to the previous data and may override it.
1041 * @return 0 on success, non-zero otherwise.
1042 */
Roytakb2794852023-10-18 14:30:22 +02001043int 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 +02001044 const char *user_name, const char *pubkey_name, const char *pubkey_path, struct lyd_node **config);
1045
roman142718b2023-06-29 09:15:29 +02001046/**
Roytak2161df62023-08-02 15:04:42 +02001047 * @brief Deletes a Call Home SSH user's public key from the YANG data.
roman142718b2023-06-29 09:15:29 +02001048 *
Roytak2161df62023-08-02 15:04:42 +02001049 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001050 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1051 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
roman8ba6efa2023-07-12 15:27:52 +02001052 * @param[in] pubkey_name Optional identifier of a public key to be deleted.
1053 * If NULL, all of the public keys which belong to the given SSH user will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001054 * @param[in,out] config Modified configuration YANG data tree.
roman142718b2023-06-29 09:15:29 +02001055 * @return 0 on success, non-zero otherwise.
1056 */
Roytakb2794852023-10-18 14:30:22 +02001057int nc_server_config_del_ch_ssh_user_pubkey(const char *client_name, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +02001058 const char *user_name, const char *pubkey_name, struct lyd_node **config);
roman5cbb6532023-06-22 12:53:17 +02001059
roman142718b2023-06-29 09:15:29 +02001060/**
romana9ec3362023-12-21 10:59:57 +01001061 * @brief Creates new YANG configuration data nodes for a Call Home SSH user that will use system's authorized_keys to authenticate.
1062 *
1063 * The path to the authorized_keys file must be configured to successfully
1064 * authenticate, see ::nc_server_ssh_set_authkey_path_format().
1065 *
1066 * @param[in] ctx libyang context.
1067 * @param[in] client_name Arbitrary identifier of the Call Home client.
1068 * If a Call Home client with this identifier already exists, its contents will be changed.
1069 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1070 * If the client's endpoint with this identifier already exists, its contents will be changed.
1071 * @param[in] user_name Arbitrary identifier of the endpoint's user.
1072 * If the endpoint's user with this identifier already exists, its contents will be changed.
1073 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1074 * Otherwise the new YANG data will be added to the previous data and may override it.
1075 * @return 0 on success, non-zero otherwise.
1076 */
1077int nc_server_config_add_ch_ssh_user_authkey(const struct ly_ctx *ctx, const char *client_name,
1078 const char *endpt_name, const char *user_name, struct lyd_node **config);
1079
1080/**
1081 * @brief Deletes a Call Home SSH user's authorized_keys method from the YANG data.
1082 *
1083 * @param[in] client_name Identifier of an existing Call Home client.
1084 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1085 * @param[in] user_name Identifier of an existing user on the given endpoint.
1086 * @param[in,out] config Modified configuration YANG data tree.
1087 * @return 0 on success, non-zero otherwise.
1088 */
1089int nc_server_config_ch_del_ssh_user_authkey(const char *client_name, const char *endpt_name,
1090 const char *user_name, struct lyd_node **config);
1091
1092/**
Roytak2161df62023-08-02 15:04:42 +02001093 * @brief Creates new YANG data nodes for a Call Home SSH user's password authentication method.
roman9d5e5a52023-07-14 12:43:44 +02001094 *
1095 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001096 * @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.
roman9d5e5a52023-07-14 12:43:44 +02001098 * @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.
roman35120972023-08-08 10:39:12 +02001102 * @param[in] password Clear-text password to be set for the user. It will be hashed.
roman9d5e5a52023-07-14 12:43:44 +02001103 * @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 */
Roytakb2794852023-10-18 14:30:22 +02001107int 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 +02001108 const char *user_name, const char *password, struct lyd_node **config);
1109
1110/**
Roytak2161df62023-08-02 15:04:42 +02001111 * @brief Deletes a Call Home SSH user's password from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001112 *
Roytak2161df62023-08-02 15:04:42 +02001113 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001114 * @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 */
Roytakb2794852023-10-18 14:30:22 +02001119int nc_server_config_del_ch_ssh_user_password(const char *client_name, const char *endpt_name,
roman9d5e5a52023-07-14 12:43:44 +02001120 const char *user_name, struct lyd_node **config);
1121
1122/**
Roytak2161df62023-08-02 15:04:42 +02001123 * @brief Creates new YANG configuration data nodes for a Call Home SSH user's keyboard interactive authentication method.
roman9d5e5a52023-07-14 12:43:44 +02001124 *
romanc6518422023-11-30 16:39:00 +01001125 * One of Linux PAM, local users, or user callback is used to authenticate users with this SSH method (see \ref ln2doc_kbdint "the documentation").
roman808f3f62023-11-23 16:01:04 +01001126 *
roman9d5e5a52023-07-14 12:43:44 +02001127 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001128 * @param[in] client_name Arbitrary identifier of the Call Home client.
1129 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001130 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1131 * If the client's endpoint with this identifier already exists, its contents will be changed.
1132 * @param[in] user_name Arbitrary identifier of the endpoint's user.
1133 * If the endpoint's user with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001134 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1135 * Otherwise the new YANG data will be added to the previous data and may override it.
1136 * @return 0 on success, non-zero otherwise.
1137 */
Roytakb2794852023-10-18 14:30:22 +02001138int nc_server_config_add_ch_ssh_user_interactive(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
roman808f3f62023-11-23 16:01:04 +01001139 const char *user_name, struct lyd_node **config);
roman9d5e5a52023-07-14 12:43:44 +02001140
1141/**
Roytak2161df62023-08-02 15:04:42 +02001142 * @brief Deletes a Call Home SSH user's keyboard interactive authentication from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001143 *
Roytak2161df62023-08-02 15:04:42 +02001144 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001145 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1146 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
1147 * @param[in,out] config Modified configuration YANG data tree.
1148 * @return 0 on success, non-zero otherwise.
1149 */
Roytakb2794852023-10-18 14:30:22 +02001150int nc_server_config_del_ch_ssh_user_interactive(const char *client_name, const char *endpt_name,
roman9d5e5a52023-07-14 12:43:44 +02001151 const char *user_name, struct lyd_node **config);
1152
1153/**
Roytak2161df62023-08-02 15:04:42 +02001154 * @brief Deletes a Call Home SSH user from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001155 *
Roytak2161df62023-08-02 15:04:42 +02001156 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001157 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1158 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
1159 * @param[in,out] config Modified configuration YANG data tree.
1160 * @return 0 on success, non-zero otherwise.
1161 */
Roytakb2794852023-10-18 14:30:22 +02001162int nc_server_config_del_ch_ssh_user(const char *client_name, const char *endpt_name,
roman9d5e5a52023-07-14 12:43:44 +02001163 const char *user_name, struct lyd_node **config);
1164
1165/**
romand348b942023-10-13 14:32:19 +02001166 * @brief Creates new YANG data nodes for a reference to a public key bag located in the truststore.
1167 *
1168 * The public key's located in the bag will be used for Call Home SSH client authentication.
1169 *
1170 * @param[in] ctx libyang context.
1171 * @param[in] client_name Arbitrary identifier of the Call Home client.
1172 * If a Call Home client with this identifier already exists, its contents will be changed.
1173 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1174 * If the client's endpoint with this identifier already exists, its contents will be changed.
1175 * @param[in] user_name Arbitrary identifier of the endpoint's user.
1176 * If the endpoint's user with this identifier already exists, its contents will be changed.
1177 * @param[in] truststore_reference Name of the public key bag to be referenced and used for authentication.
1178 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1179 * Otherwise the new YANG data will be added to the previous data and may override it.
1180 * @return 0 on success, non-zero otherwise.
1181 */
1182int nc_server_config_add_ch_ssh_truststore_ref(const struct ly_ctx *ctx, const char *client_name,
1183 const char *endpt_name, const char *user_name, const char *truststore_reference, struct lyd_node **config);
1184
1185/**
1186 * @brief Deletes a Call Home SSH truststore reference from the YANG data.
1187 *
1188 * @param[in] client_name Identifier of an existing Call Home client.
1189 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1190 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
1191 * @param[in,out] config Modified configuration YANG data tree.
1192 * @return 0 on success, non-zero otherwise.
1193 */
1194int nc_server_config_del_ch_ssh_truststore_ref(const char *client_name, const char *endpt_name,
1195 const char *user_name, struct lyd_node **config);
1196
1197/**
roman35120972023-08-08 10:39:12 +02001198 * @} SSH Call Home Server Configuration
roman142718b2023-06-29 09:15:29 +02001199 */
roman142718b2023-06-29 09:15:29 +02001200
1201/**
Roytak2161df62023-08-02 15:04:42 +02001202 * @defgroup server_config_ch_tls TLS Call Home Server Configuration
roman8ba6efa2023-07-12 15:27:52 +02001203 * @ingroup server_config_ch
roman142718b2023-06-29 09:15:29 +02001204 *
Roytak2161df62023-08-02 15:04:42 +02001205 * @brief TLS Call Home server configuration creation and deletion
roman8ba6efa2023-07-12 15:27:52 +02001206 * @{
roman142718b2023-06-29 09:15:29 +02001207 */
roman142718b2023-06-29 09:15:29 +02001208
romanb6f44032023-06-30 15:07:56 +02001209/**
Roytak2161df62023-08-02 15:04:42 +02001210 * @brief Creates new YANG configuration data nodes for a Call Home server's certificate.
romanb6f44032023-06-30 15:07:56 +02001211 *
1212 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001213 * @param[in] client_name Arbitrary identifier of the Call Home client.
1214 * If a Call Home client with this identifier already exists, its contents will be changed.
1215 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1216 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
roman6c4efcd2023-08-08 10:18:44 +02001217 * @param[in] privkey_path Path to the server's PEM encoded private key file.
romanb6f44032023-06-30 15:07:56 +02001218 * @param[in] pubkey_path Optional path to the server's public key file. If not provided,
1219 * it will be generated from the private key.
romane6ec60e2023-10-19 15:21:52 +02001220 * @param[in] cert_path Path to the server's certificate file.
Roytak934edc32023-07-27 12:04:18 +02001221 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
romanb6f44032023-06-30 15:07:56 +02001222 * Otherwise the new YANG data will be added to the previous data and may override it.
1223 * @return 0 on success, non-zero otherwise.
1224 */
romane6ec60e2023-10-19 15:21:52 +02001225int nc_server_config_add_ch_tls_server_cert(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1226 const char *privkey_path, const char *pubkey_path, const char *cert_path, struct lyd_node **config);
romanb6f44032023-06-30 15:07:56 +02001227
1228/**
Roytak2161df62023-08-02 15:04:42 +02001229 * @brief Deletes a Call Home server certificate from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001230 *
Roytak2161df62023-08-02 15:04:42 +02001231 * @param[in] client_name Identifier of an existing Call Home client.
1232 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
roman9d5e5a52023-07-14 12:43:44 +02001233 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001234 * @return 0 on success, non-zero otherwise.
1235 */
romane6ec60e2023-10-19 15:21:52 +02001236int nc_server_config_del_ch_tls_server_cert(const char *client_name, const char *endpt_name,
romand348b942023-10-13 14:32:19 +02001237 struct lyd_node **config);
1238
1239/**
1240 * @brief Creates new YANG configuration data nodes for a keystore reference to the Call Home TLS server's certificate.
1241 *
1242 * @param[in] ctx libyang context.
1243 * @param[in] client_name Arbitrary identifier of the Call Home client.
1244 * If a Call Home client with this identifier already exists, its contents will be changed.
1245 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1246 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
1247 * @param[in] asym_key_ref Name of the asymmetric key pair in the keystore to be referenced.
1248 * @param[in] cert_ref Name of the certificate, which must belong to the given asymmetric key pair, to be referenced.
1249 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1250 * Otherwise the new YANG data will be added to the previous data and may override it.
1251 * @return 0 on success, non-zero otherwise.
1252 */
1253int nc_server_config_add_ch_tls_keystore_ref(const struct ly_ctx *ctx, const char *client_name,
1254 const char *endpt_name, const char *asym_key_ref, const char *cert_ref, struct lyd_node **config);
1255
1256/**
1257 * @brief Deletes a TLS server certificate keystore reference from the YANG data.
1258 *
1259 * @param[in] client_name Identifier of an existing Call Home client.
1260 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
1261 * @param[in,out] config Modified configuration YANG data tree.
1262 * @return 0 on success, non-zero otherwise.
1263 */
1264int nc_server_config_del_ch_tls_keystore_ref(const char *client_name, const char *endpt_name,
Roytak934edc32023-07-27 12:04:18 +02001265 struct lyd_node **config);
1266
1267/**
Roytak2161df62023-08-02 15:04:42 +02001268 * @brief Creates new YANG configuration data nodes for a Call Home client's (end-entity) certificate.
romanb6f44032023-06-30 15:07:56 +02001269 *
1270 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001271 * @param[in] client_name Arbitrary identifier of the Call Home client.
1272 * If a Call Home client with this identifier already exists, its contents will be changed.
1273 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1274 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
1275 * @param[in] cert_name Arbitrary identifier of the Call Home endpoint's end-entity certificate.
1276 * 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 +02001277 * @param[in] cert_path Path to the certificate file.
Roytak934edc32023-07-27 12:04:18 +02001278 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
romanb6f44032023-06-30 15:07:56 +02001279 * Otherwise the new YANG data will be added to the previous data and may override it.
1280 * @return 0 on success, non-zero otherwise.
1281 */
romane6ec60e2023-10-19 15:21:52 +02001282int 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 +02001283 const char *cert_name, const char *cert_path, struct lyd_node **config);
1284
1285/**
Roytak2161df62023-08-02 15:04:42 +02001286 * @brief Deletes a Call Home client (end-entity) certificate from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001287 *
Roytak2161df62023-08-02 15:04:42 +02001288 * @param[in] client_name Identifier of an existing Call Home client.
1289 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
roman8ba6efa2023-07-12 15:27:52 +02001290 * @param[in] cert_name Optional identifier of a client certificate to be deleted.
1291 * If NULL, all of the client certificates will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001292 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001293 * @return 0 on success, non-zero otherwise.
1294 */
romane6ec60e2023-10-19 15:21:52 +02001295int nc_server_config_del_ch_tls_client_cert(const char *client_name, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +02001296 const char *cert_name, struct lyd_node **config);
1297
1298/**
romand348b942023-10-13 14:32:19 +02001299 * @brief Creates new YANG configuration data nodes for a Call Home truststore reference to a set of client (end-entity) certificates.
1300 *
1301 * @param[in] ctx libyang context.
1302 * @param[in] client_name Arbitrary identifier of the Call Home client.
1303 * If a Call Home client with this identifier already exists, its contents will be changed.
1304 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1305 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
1306 * @param[in] cert_bag_ref Identifier of the certificate bag in the truststore to be referenced.
1307 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1308 * Otherwise the new YANG data will be added to the previous data and may override it.
1309 * @return 0 on success, non-zero otherwise.
1310 */
1311int nc_server_config_add_ch_tls_client_cert_truststore_ref(const struct ly_ctx *ctx, const char *client_name,
1312 const char *endpt_name, const char *cert_bag_ref, struct lyd_node **config);
1313
1314/**
1315 * @brief Deletes a Call Home client (end-entity) certificates truststore reference from the YANG data.
1316 *
1317 * @param[in] client_name Identifier of an existing Call Home client.
1318 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
1319 * @param[in,out] config Modified configuration YANG data tree.
1320 * @return 0 on success, non-zero otherwise.
1321 */
1322int nc_server_config_del_ch_tls_client_cert_truststore_ref(const char *client_name, const char *endpt_name,
1323 struct lyd_node **config);
1324
1325/**
romanb6f44032023-06-30 15:07:56 +02001326 * @brief Creates new YANG configuration data nodes for a client certificate authority (trust-anchor) certificate.
1327 *
1328 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001329 * @param[in] client_name Arbitrary identifier of the Call Home client.
1330 * If a Call Home client with this identifier already exists, its contents will be changed.
1331 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1332 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
1333 * @param[in] cert_name Arbitrary identifier of the Call Home endpoint's certificate authority certificate.
1334 * If an Call Home endpoint's CA certificate with this identifier already exists, its contents will be changed.
romanb6f44032023-06-30 15:07:56 +02001335 * @param[in] cert_path Path to the certificate file.
Roytak9b32c0f2023-08-02 15:07:29 +02001336 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
romanb6f44032023-06-30 15:07:56 +02001337 * Otherwise the new YANG data will be added to the previous data and may override it.
1338 * @return 0 on success, non-zero otherwise.
1339 */
romane6ec60e2023-10-19 15:21:52 +02001340int 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 +02001341 const char *cert_name, const char *cert_path, struct lyd_node **config);
1342
1343/**
Roytak2161df62023-08-02 15:04:42 +02001344 * @brief Deletes a Call Home client certificate authority (trust-anchor) certificate from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001345 *
Roytak2161df62023-08-02 15:04:42 +02001346 * @param[in] client_name Identifier of an existing Call Home client.
1347 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
roman8ba6efa2023-07-12 15:27:52 +02001348 * @param[in] cert_name Optional identifier of a CA certificate to be deleted.
1349 * If NULL, all of the CA certificates will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001350 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001351 * @return 0 on success, non-zero otherwise.
1352 */
romane6ec60e2023-10-19 15:21:52 +02001353int nc_server_config_del_ch_tls_ca_cert(const char *client_name, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +02001354 const char *cert_name, struct lyd_node **config);
1355
1356/**
romand348b942023-10-13 14:32:19 +02001357 * @brief Creates new YANG configuration data nodes for a Call Home truststore reference to a set of client certificate authority (trust-anchor) certificates.
1358 *
1359 * @param[in] ctx libyang context.
1360 * @param[in] client_name Arbitrary identifier of the Call Home client.
1361 * If a Call Home client with this identifier already exists, its contents will be changed.
1362 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1363 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
1364 * @param[in] cert_bag_ref Identifier of the certificate bag in the truststore to be referenced.
1365 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1366 * Otherwise the new YANG data will be added to the previous data and may override it.
1367 * @return 0 on success, non-zero otherwise.
1368 */
romane6ec60e2023-10-19 15:21:52 +02001369int 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 +02001370 const char *endpt_name, const char *cert_bag_ref, struct lyd_node **config);
1371
1372/**
1373 * @brief Deletes a Call Home client certificate authority (trust-anchor) certificates truststore reference from the YANG data.
1374 *
1375 * @param[in] client_name Identifier of an existing Call Home client.
1376 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
1377 * @param[in,out] config Modified configuration YANG data tree.
1378 * @return 0 on success, non-zero otherwise.
1379 */
romane6ec60e2023-10-19 15:21:52 +02001380int nc_server_config_del_ch_tls_ca_cert_truststore_ref(const char *client_name, const char *endpt_name,
romand348b942023-10-13 14:32:19 +02001381 struct lyd_node **config);
1382
1383/**
Roytak2161df62023-08-02 15:04:42 +02001384 * @brief Creates new YANG configuration data nodes for a Call Home cert-to-name entry.
romanb6f44032023-06-30 15:07:56 +02001385 *
1386 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001387 * @param[in] client_name Arbitrary identifier of the Call Home client.
1388 * If a Call Home client with this identifier already exists, its contents will be changed.
1389 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1390 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
romanb6f44032023-06-30 15:07:56 +02001391 * @param[in] id ID of the entry. The lower the ID, the higher the priority of the entry (it will be checked earlier).
1392 * @param[in] fingerprint Optional fingerprint of the entry. The fingerprint should always be set, however if it is
1393 * not set, it will match any certificate. Entry with no fingerprint should therefore be placed only as the last entry.
1394 * @param[in] map_type Mapping username to the certificate option.
1395 * @param[in] name Username for this cert-to-name entry.
Roytak9b32c0f2023-08-02 15:07:29 +02001396 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
romanb6f44032023-06-30 15:07:56 +02001397 * Otherwise the new YANG data will be added to the previous data and may override it.
1398 * @return 0 on success, non-zero otherwise.
1399 */
Roytakb2794852023-10-18 14:30:22 +02001400int 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 +02001401 uint32_t id, const char *fingerprint, NC_TLS_CTN_MAPTYPE map_type, const char *name, struct lyd_node **config);
1402
roman8ba6efa2023-07-12 15:27:52 +02001403/**
Roytak2161df62023-08-02 15:04:42 +02001404 * @brief Deletes a Call Home cert-to-name entry from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001405 *
Roytak2161df62023-08-02 15:04:42 +02001406 * @param[in] client_name Identifier of an existing Call Home client.
1407 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
1408 * @param[in] id Optional identifier of the Call Home CTN entry to be deleted.
roman8ba6efa2023-07-12 15:27:52 +02001409 * If 0, all of the CTN entries will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001410 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001411 * @return 0 on success, non-zero otherwise.
1412 */
Roytakb2794852023-10-18 14:30:22 +02001413int nc_server_config_del_ch_tls_ctn(const char *client_name, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +02001414 uint32_t id, struct lyd_node **config);
1415
1416/**
roman35120972023-08-08 10:39:12 +02001417 * @} TLS Call Home Server Configuration
roman8ba6efa2023-07-12 15:27:52 +02001418 */
1419
roman2eab4742023-06-06 10:00:26 +02001420#endif /* NC_ENABLED_SSH_TLS */
roman45cec4e2023-02-17 10:21:39 +01001421
romanc1d2b092023-02-02 08:58:27 +01001422#ifdef __cplusplus
1423}
1424#endif
1425
1426#endif /* NC_SESSION_SERVER_H_ */