blob: 07584d2c3135ad7141944b78ccac803b4176d523 [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/**
roman35120972023-08-08 10:39:12 +0200253 * @} Server Configuration Functions
roman8ba6efa2023-07-12 15:27:52 +0200254 */
255
256/**
257 * @defgroup server_config_ssh SSH Server Configuration
258 * @ingroup server_config
259 *
260 * @brief SSH server configuration creation and deletion
261 * @{
262 */
263
roman3f9b65c2023-06-05 14:26:58 +0200264/**
265 * @brief Creates new YANG configuration data nodes for a hostkey.
266 *
267 * @param[in] ctx libyang context.
268 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200269 * If an endpoint with this identifier already exists, its hostkey might be changed.
roman3f9b65c2023-06-05 14:26:58 +0200270 * @param[in] hostkey_name Arbitrary identifier of the hostkey.
roman142718b2023-06-29 09:15:29 +0200271 * If a hostkey with this identifier already exists, its contents will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200272 * @param[in] privkey_path Path to a file containing a private key.
273 * The private key has to be in a PEM format. Only RSA and ECDSA keys are supported.
roman35120972023-08-08 10:39:12 +0200274 * @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 +0200275 * generated from the private key.
276 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
277 * Otherwise the new YANG data will be added to the previous data and may override it.
278 * @return 0 on success, non-zero otherwise.
279 */
Roytakb2794852023-10-18 14:30:22 +0200280int 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 +0200281 const char *privkey_path, const char *pubkey_path, struct lyd_node **config);
282
283/**
284 * @brief Deletes a hostkey from the YANG data.
285 *
286 * @param[in] ctx libyang context.
287 * @param[in] endpt_name Identifier of an existing endpoint.
288 * @param[in] hostkey_name Optional identifier of the hostkey to be deleted.
289 * If NULL, all of the hostkeys on this endpoint will be deleted.
290 * @param[in,out] config Configuration YANG data tree.
291 * @return 0 on success, non-zero otherwise.
292 */
Roytakb2794852023-10-18 14:30:22 +0200293int nc_server_config_del_ssh_hostkey(const struct ly_ctx *ctx, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +0200294 const char *hostkey_name, struct lyd_node **config);
295
296/**
romand348b942023-10-13 14:32:19 +0200297 * @brief Creates new YANG data nodes for a reference to an asymmetric key located in the keystore.
298 *
299 * This asymmetric key pair will be used as the SSH hostkey.
300 *
301 * @param[in] ctx libyang context.
302 * @param[in] endpt_name Arbitrary identifier of an endpoint.
303 * If an endpoint with this identifier already exists, its contents will be changed.
304 * @param[in] hostkey_name Arbitrary identifier of the endpoint's hostkey.
305 * If an endpoint's hostkey with this identifier already exists, its contents will be changed.
306 * @param[in] keystore_reference Name of the asymmetric key pair to be referenced and used as a hostkey.
307 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
308 * Otherwise the new YANG data will be added to the previous data and may override it.
309 * @return 0 on success, non-zero otherwise.
310 */
311int nc_server_config_add_ssh_keystore_ref(const struct ly_ctx *ctx, const char *endpt_name, const char *hostkey_name,
312 const char *keystore_reference, struct lyd_node **config);
313
314/**
315 * @brief Deletes a keystore reference from the YANG data.
316 *
317 * @param[in] endpt_name Identifier of an existing endpoint.
318 * @param[in] hostkey_name Identifier of an existing hostkey on the given endpoint.
319 * @param[in,out] config Configuration YANG data tree.
320 * @return 0 on success, non-zero otherwise.
321 */
322int nc_server_config_del_ssh_keystore_ref(const char *endpt_name, const char *hostkey_name,
323 struct lyd_node **config);
324
325/**
roman8ba6efa2023-07-12 15:27:52 +0200326 * @brief Creates new YANG configuration data nodes for an SSH user's public key authentication method.
327 *
328 * @param[in] ctx libyang context.
329 * @param[in] endpt_name Arbitrary identifier of the endpoint.
330 * If an endpoint with this identifier already exists, its user might be changed.
331 * @param[in] user_name Arbitrary identifier of the user.
332 * If an user with this identifier already exists, its contents will be changed.
333 * @param[in] pubkey_name Arbitrary identifier of the user's public key.
334 * If a public key with this identifier already exists for this user, its contents will be changed.
335 * @param[in] pubkey_path Path to a file containing the user's public key.
336 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
337 * Otherwise the new YANG data will be added to the previous data and may override it.
338 * @return 0 on success, non-zero otherwise.
339 */
Roytakb2794852023-10-18 14:30:22 +0200340int nc_server_config_add_ssh_user_pubkey(const struct ly_ctx *ctx, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +0200341 const char *user_name, const char *pubkey_name, const char *pubkey_path, struct lyd_node **config);
342
343/**
344 * @brief Deletes an SSH user's public key from the YANG data.
345 *
346 * @param[in] endpt_name Identifier of an existing endpoint.
347 * @param[in] user_name Identifier of an existing user on the given endpoint.
348 * @param[in] pubkey_name Optional identifier of a public key to be deleted.
349 * If NULL, all of the users public keys will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200350 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200351 * @return 0 on success, non-zero otherwise.
352 */
Roytakb2794852023-10-18 14:30:22 +0200353int nc_server_config_del_ssh_user_pubkey(const char *endpt_name, const char *user_name,
roman8ba6efa2023-07-12 15:27:52 +0200354 const char *pubkey_name, struct lyd_node **config);
355
356/**
357 * @brief Creates new YANG configuration data nodes for an SSH user's password authentication method.
358 *
359 * @param[in] ctx libyang context.
360 * @param[in] endpt_name Arbitrary identifier of the endpoint.
361 * If an endpoint with this identifier already exists, its user might be changed.
362 * @param[in] user_name Arbitrary identifier of the user.
363 * If an user with this identifier already exists, its contents will be changed.
roman35120972023-08-08 10:39:12 +0200364 * @param[in] password Clear-text password to be set for the user. It will be hashed.
roman8ba6efa2023-07-12 15:27:52 +0200365 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
366 * Otherwise the new YANG data will be added to the previous data and may override it.
367 * @return 0 on success, non-zero otherwise.
368 */
Roytakb2794852023-10-18 14:30:22 +0200369int nc_server_config_add_ssh_user_password(const struct ly_ctx *ctx, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +0200370 const char *user_name, const char *password, struct lyd_node **config);
371
372/**
373 * @brief Deletes an SSH user's password from the YANG data.
374 *
375 * @param[in] endpt_name Identifier of an existing endpoint.
376 * @param[in] user_name Identifier of an existing user on the given endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200377 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200378 * @return 0 on success, non-zero otherwise.
379 */
Roytakb2794852023-10-18 14:30:22 +0200380int nc_server_config_del_ssh_user_password(const char *endpt_name, const char *user_name,
roman8ba6efa2023-07-12 15:27:52 +0200381 struct lyd_node **config);
382
383/**
384 * @brief Creates new YANG configuration data nodes for an SSH user's keyboard interactive authentication method.
385 *
romanc6518422023-11-30 16:39:00 +0100386 * 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 +0100387 *
388 * @param[in] ctx libyang context.
389 * @param[in] endpt_name Arbitrary identifier of the endpoint.
390 * If an endpoint with this identifier already exists, its user might be changed.
391 * @param[in] user_name Arbitrary identifier of the user.
392 * If an user with this identifier already exists, its contents will be changed.
393 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
394 * Otherwise the new YANG data will be added to the previous data and may override it.
395 * @return 0 on success, non-zero otherwise.
396 */
Roytakb2794852023-10-18 14:30:22 +0200397int nc_server_config_add_ssh_user_interactive(const struct ly_ctx *ctx, const char *endpt_name,
roman808f3f62023-11-23 16:01:04 +0100398 const char *user_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200399
400/**
401 * @brief Deletes an SSH user's keyboard interactive authentication from the YANG data.
402 *
403 * @param[in] endpt_name Identifier of an existing endpoint.
404 * @param[in] user_name Identifier of an existing user on the given endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200405 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200406 * @return 0 on success, non-zero otherwise.
407 */
Roytakb2794852023-10-18 14:30:22 +0200408int nc_server_config_del_ssh_user_interactive(const char *endpt_name, const char *user_name,
roman8ba6efa2023-07-12 15:27:52 +0200409 struct lyd_node **config);
410
411/**
412 * @brief Deletes an SSH user from the YANG data.
413 *
414 * @param[in] endpt_name Identifier of an existing endpoint.
415 * @param[in] user_name Optional identifier of an user to be deleted.
416 * If NULL, all of the users on this endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200417 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200418 * @return 0 on success, non-zero otherwise.
419 */
Roytakb2794852023-10-18 14:30:22 +0200420int nc_server_config_del_ssh_user(const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +0200421 const char *user_name, struct lyd_node **config);
422
423/**
romand348b942023-10-13 14:32:19 +0200424 * @brief Creates new YANG data nodes for a reference to a public key bag located in the truststore.
425 *
426 * The public key's located in the bag will be used for client authentication.
427 *
428 * @param[in] ctx libyang context.
429 * @param[in] endpt_name Arbitrary identifier of an endpoint.
430 * If an endpoint with this identifier already exists, its contents will be changed.
431 * @param[in] user_name Arbitrary identifier of the endpoint's user.
432 * If an endpoint's user with this identifier already exists, its contents will be changed.
433 * @param[in] truststore_reference Name of the public key bag to be referenced and used for authentication.
434 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
435 * Otherwise the new YANG data will be added to the previous data and may override it.
436 * @return 0 on success, non-zero otherwise.
437 */
438int nc_server_config_add_ssh_truststore_ref(const struct ly_ctx *ctx, const char *endpt_name, const char *user_name,
439 const char *truststore_reference, struct lyd_node **config);
440
441/**
442 * @brief Deletes a truststore reference from the YANG data.
443 *
444 * @param[in] endpt_name Identifier of an existing endpoint.
445 * @param[in] user_name Identifier of an user on the given endpoint whose truststore reference will be deleted.
446 * @param[in,out] config Modified configuration YANG data tree.
447 * @return 0 on success, non-zero otherwise.
448 */
449int nc_server_config_del_ssh_truststore_ref(const char *endpt_name, const char *user_name,
450 struct lyd_node **config);
451
452/**
roman8ba6efa2023-07-12 15:27:52 +0200453 * @brief Creates new YANG configuration data nodes, which will be a reference to another SSH endpoint's users.
454 *
455 * Whenever a client tries to connect to the referencing endpoint, all of its users will be tried first. If no match is
456 * found, the referenced endpoint's configured users will be tried.
457 *
458 * @param[in] ctx libyang context
459 * @param[in] endpt_name Arbitrary identifier of the endpoint.
460 * If an endpoint with this identifier already exists, its contents will be changed.
461 * @param[in] referenced_endpt Identifier of an endpoint, which has to exist whenever this data
462 * is applied. The referenced endpoint can reference another one and so on, but there mustn't be a cycle.
463 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
464 * Otherwise the new YANG data will be added to the previous data and may override it.
465 * @return 0 on success, non-zero otherwise.
466 */
Roytakb2794852023-10-18 14:30:22 +0200467int nc_server_config_add_ssh_endpoint_client_ref(const struct ly_ctx *ctx, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +0200468 const char *referenced_endpt, struct lyd_node **config);
469
470/**
471 * @brief Deletes reference to another SSH endpoint's users from the YANG data.
472 *
473 * @param[in] endpt_name Identifier of an existing endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200474 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200475 * @return 0 on success, non-zero otherwise.
476 */
Roytakb2794852023-10-18 14:30:22 +0200477int nc_server_config_del_ssh_endpoint_client_ref(const char *endpt_name, struct lyd_node **config);
roman9b1379c2023-03-31 10:11:10 +0200478
479/**
roman35120972023-08-08 10:39:12 +0200480 * @} SSH Server Configuration
roman9b1379c2023-03-31 10:11:10 +0200481 */
roman9b1379c2023-03-31 10:11:10 +0200482
483/**
roman8ba6efa2023-07-12 15:27:52 +0200484 * @defgroup server_config_tls TLS Server Configuration
485 * @ingroup server_config
roman9b1379c2023-03-31 10:11:10 +0200486 *
roman8ba6efa2023-07-12 15:27:52 +0200487 * @brief TLS server configuration creation and deletion
488 * @{
roman9b1379c2023-03-31 10:11:10 +0200489 */
roman2e797ef2023-06-19 10:47:49 +0200490
491/**
roman3f9b65c2023-06-05 14:26:58 +0200492 * @brief Creates new YANG configuration data nodes for a server's certificate.
493 *
494 * @param[in] ctx libyang context.
495 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200496 * If an endpoint with this identifier already exists, its server certificate will be changed.
roman6c4efcd2023-08-08 10:18:44 +0200497 * @param[in] privkey_path Path to the server's PEM encoded private key file.
roman3f9b65c2023-06-05 14:26:58 +0200498 * @param[in] pubkey_path Optional path to the server's public key file. If not provided,
499 * it will be generated from the private key.
romane6ec60e2023-10-19 15:21:52 +0200500 * @param[in] cert_path Path to the server's certificate file.
roman3f9b65c2023-06-05 14:26:58 +0200501 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
502 * Otherwise the new YANG data will be added to the previous data and may override it.
503 * @return 0 on success, non-zero otherwise.
504 */
romane6ec60e2023-10-19 15:21:52 +0200505int nc_server_config_add_tls_server_cert(const struct ly_ctx *ctx, const char *endpt_name, const char *privkey_path,
506 const char *pubkey_path, const char *cert_path, struct lyd_node **config);
roman3f9b65c2023-06-05 14:26:58 +0200507
508/**
roman8ba6efa2023-07-12 15:27:52 +0200509 * @brief Deletes the server's certificate from the YANG data.
510 *
511 * @param[in] endpt_name Identifier of an existing endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200512 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200513 * @return 0 on success, non-zero otherwise.
514 */
romane6ec60e2023-10-19 15:21:52 +0200515int nc_server_config_del_tls_server_cert(const char *endpt_name, struct lyd_node **config);
romand348b942023-10-13 14:32:19 +0200516
517/**
518 * @brief Creates new YANG configuration data nodes for a keystore reference to the TLS server's certificate.
519 *
520 * @param[in] ctx libyang context.
521 * @param[in] endpt_name Arbitrary identifier of the endpoint.
522 * If an endpoint with this identifier already exists, its contents will be changed.
523 * @param[in] asym_key_ref Name of the asymmetric key pair in the keystore to be referenced.
524 * @param[in] cert_ref Name of the certificate, which must belong to the given asymmetric key pair, to be referenced.
525 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
526 * Otherwise the new YANG data will be added to the previous data and may override it.
527 * @return 0 on success, non-zero otherwise.
528 */
529int nc_server_config_add_tls_keystore_ref(const struct ly_ctx *ctx, const char *endpt_name, const char *asym_key_ref,
530 const char *cert_ref, struct lyd_node **config);
531
532/**
533 * @brief Deletes a TLS server certificate keystore reference from the YANG data.
534 *
535 * @param[in] endpt_name Identifier of an existing endpoint.
536 * @param[in,out] config Modified configuration YANG data tree.
537 * @return 0 on success, non-zero otherwise.
538 */
539int nc_server_config_del_tls_keystore_ref(const char *endpt_name, struct lyd_node **config);
roman12c3d522023-07-26 13:39:30 +0200540
541/**
roman3f9b65c2023-06-05 14:26:58 +0200542 * @brief Creates new YANG configuration data nodes for a client's (end-entity) certificate.
543 *
544 * @param[in] ctx libyang context.
545 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200546 * If an endpoint with this identifier already exists, its contents will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200547 * @param[in] cert_name Arbitrary identifier of the client's certificate.
roman35120972023-08-08 10:39:12 +0200548 * If a client certificate with this identifier already exists, it will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200549 * @param[in] cert_path Path to the client's certificate file.
550 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
551 * Otherwise the new YANG data will be added to the previous data and may override it.
552 * @return 0 on success, non-zero otherwise.
553 */
romane6ec60e2023-10-19 15:21:52 +0200554int 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 +0200555 const char *cert_path, struct lyd_node **config);
556
557/**
roman8ba6efa2023-07-12 15:27:52 +0200558 * @brief Deletes a client (end-entity) certificate from the YANG data.
559 *
560 * @param[in] endpt_name Identifier of an existing endpoint.
561 * @param[in] cert_name Optional name of a certificate to be deleted.
562 * If NULL, all of the end-entity certificates on the given endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200563 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200564 * @return 0 on success, non-zero otherwise.
565 */
romane6ec60e2023-10-19 15:21:52 +0200566int 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 +0200567
568/**
569 * @brief Creates new YANG configuration data nodes for a truststore reference to a set of client (end-entity) certificates.
570 *
571 * @param[in] ctx libyang context.
572 * @param[in] endpt_name Arbitrary identifier of the endpoint.
573 * If an endpoint with this identifier already exists, its contents will be changed.
574 * @param[in] cert_bag_ref Identifier of the certificate bag in the truststore to be referenced.
575 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
576 * Otherwise the new YANG data will be added to the previous data and may override it.
577 * @return 0 on success, non-zero otherwise.
578 */
579int nc_server_config_add_tls_client_cert_truststore_ref(const struct ly_ctx *ctx, const char *endpt_name,
580 const char *cert_bag_ref, struct lyd_node **config);
581
582/**
583 * @brief Deletes a client (end-entity) certificates truststore reference from the YANG data.
584 *
585 * @param[in] endpt_name Identifier of an existing endpoint.
586 * @param[in,out] config Modified configuration YANG data tree.
587 * @return 0 on success, non-zero otherwise.
588 */
589int nc_server_config_del_tls_client_cert_truststore_ref(const char *endpt_name, struct lyd_node **config);
roman12c3d522023-07-26 13:39:30 +0200590
591/**
roman3f9b65c2023-06-05 14:26:58 +0200592 * @brief Creates new YANG configuration data nodes for a client certificate authority (trust-anchor) certificate.
593 *
594 * @param[in] ctx libyang context.
595 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200596 * If an endpoint with this identifier already exists, its contents will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200597 * @param[in] cert_name Arbitrary identifier of the certificate authority certificate.
roman35120972023-08-08 10:39:12 +0200598 * If a CA with this identifier already exists, it will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200599 * @param[in] cert_path Path to the CA certificate file.
600 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
601 * Otherwise the new YANG data will be added to the previous data and may override it.
602 * @return 0 on success, non-zero otherwise.
603 */
romane6ec60e2023-10-19 15:21:52 +0200604int 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 +0200605 const char *cert_path, struct lyd_node **config);
606
607/**
roman8ba6efa2023-07-12 15:27:52 +0200608 * @brief Deletes a client certificate authority (trust-anchor) certificate from the YANG data.
609 *
610 * @param[in] endpt_name Identifier of an existing endpoint.
611 * @param[in] cert_name Optional name of a certificate to be deleted.
612 * If NULL, all of the CA certificates on the given endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200613 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200614 * @return 0 on success, non-zero otherwise.
615 */
romane6ec60e2023-10-19 15:21:52 +0200616int 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 +0200617
618/**
619 * @brief Creates new YANG configuration data nodes for a truststore reference to a set of client certificate authority (trust-anchor) certificates.
620 *
621 * @param[in] ctx libyang context.
622 * @param[in] endpt_name Arbitrary identifier of the endpoint.
623 * If an endpoint with this identifier already exists, its contents will be changed.
624 * @param[in] cert_bag_ref Identifier of the certificate bag in the truststore to be referenced.
625 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
626 * Otherwise the new YANG data will be added to the previous data and may override it.
627 * @return 0 on success, non-zero otherwise.
628 */
romane6ec60e2023-10-19 15:21:52 +0200629int nc_server_config_add_tls_ca_cert_truststore_ref(const struct ly_ctx *ctx, const char *endpt_name,
romand348b942023-10-13 14:32:19 +0200630 const char *cert_bag_ref, struct lyd_node **config);
631
632/**
633 * @brief Deletes a client certificate authority (trust-anchor) certificates truststore reference from the YANG data.
634 *
635 * @param[in] endpt_name Identifier of an existing endpoint.
636 * @param[in,out] config Modified configuration YANG data tree.
637 * @return 0 on success, non-zero otherwise.
638 */
romane6ec60e2023-10-19 15:21:52 +0200639int nc_server_config_del_tls_ca_cert_truststore_ref(const char *endpt_name, struct lyd_node **config);
roman12c3d522023-07-26 13:39:30 +0200640
641/**
Roytak76958912023-09-29 15:25:14 +0200642 * @brief Creates new YANG configuration data nodes, which will be a reference to another TLS endpoint's certificates.
643 *
644 * Whenever an user tries to connect to the referencing endpoint, all of its certificates will be tried first. If no match is
645 * found, the referenced endpoint's configured certificates will be tried. The same applies to cert-to-name entries.
646 *
647 * @param[in] ctx libyang context
648 * @param[in] endpt_name Arbitrary identifier of the endpoint.
649 * If an endpoint with this identifier already exists, its contents will be changed.
650 * @param[in] referenced_endpt Identifier of an endpoint, which has to exist whenever this data
651 * is applied. The referenced endpoint can reference another one and so on, but there mustn't be a cycle.
652 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
653 * Otherwise the new YANG data will be added to the previous data and may override it.
654 * @return 0 on success, non-zero otherwise.
655 */
Roytakb2794852023-10-18 14:30:22 +0200656int nc_server_config_add_tls_endpoint_client_ref(const struct ly_ctx *ctx, const char *endpt_name,
Roytak76958912023-09-29 15:25:14 +0200657 const char *referenced_endpt, struct lyd_node **config);
658
659/**
660 * @brief Deletes reference to another TLS endpoint's users from the YANG data.
661 *
662 * @param[in] endpt_name Identifier of an existing endpoint.
663 * @param[in,out] config Modified configuration YANG data tree.
664 * @return 0 on success, non-zero otherwise.
665 */
Roytakb2794852023-10-18 14:30:22 +0200666int nc_server_config_del_tls_endpoint_client_ref(const char *endpt_name, struct lyd_node **config);
Roytak76958912023-09-29 15:25:14 +0200667
668/**
roman3f9b65c2023-06-05 14:26:58 +0200669 * @brief Creates new YANG configuration data nodes for a cert-to-name entry.
670 *
671 * @param[in] ctx libyang context.
672 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200673 * If an endpoint with this identifier already exists, its contents will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200674 * @param[in] id ID of the entry. The lower the ID, the higher the priority of the entry (it will be checked earlier).
675 * @param[in] fingerprint Optional fingerprint of the entry. The fingerprint should always be set, however if it is
676 * not set, it will match any certificate. Entry with no fingerprint should therefore be placed only as the last entry.
677 * @param[in] map_type Mapping username to the certificate option.
678 * @param[in] name Username for this cert-to-name entry.
679 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
680 * Otherwise the new YANG data will be added to the previous data and may override it.
681 * @return 0 on success, non-zero otherwise.
682 */
Roytakb2794852023-10-18 14:30:22 +0200683int 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 +0200684 NC_TLS_CTN_MAPTYPE map_type, const char *name, struct lyd_node **config);
685
roman12644fe2023-06-08 11:06:42 +0200686/**
roman8ba6efa2023-07-12 15:27:52 +0200687 * @brief Deletes a cert-to-name entry from the YANG data.
688 *
689 * @param[in] endpt_name Identifier of an existing endpoint.
690 * @param[in] id Optional ID of the CTN entry.
691 * If 0, all of the cert-to-name entries on the given endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200692 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200693 * @return 0 on success, non-zero otherwise.
694 */
Roytakb2794852023-10-18 14:30:22 +0200695int nc_server_config_del_tls_ctn(const char *endpt_name, uint32_t id, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200696
697/**
roman35120972023-08-08 10:39:12 +0200698 * @} TLS Server Configuration
roman8ba6efa2023-07-12 15:27:52 +0200699 */
700
701/**
roman35120972023-08-08 10:39:12 +0200702 * @defgroup server_config_ch Call Home Server Configuration
roman8ba6efa2023-07-12 15:27:52 +0200703 * @ingroup server_config
704 *
Roytak2161df62023-08-02 15:04:42 +0200705 * @brief Call Home server configuration creation and deletion
roman8ba6efa2023-07-12 15:27:52 +0200706 * @{
707 */
708
709/**
roman35120972023-08-08 10:39:12 +0200710 * @} Call Home Server Configuration
711 */
712
713/**
714 * @defgroup server_config_ch_functions Call Home Server Configuration Functions
715 * @ingroup server_config_ch
716 *
717 * @brief Call Home server configuration functions
718 * @{
719 */
720
721/**
Roytak2161df62023-08-02 15:04:42 +0200722 * @brief Creates new YANG configuration data nodes for a Call Home client's address and port.
roman142718b2023-06-29 09:15:29 +0200723 *
724 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200725 * @param[in] client_name Arbitrary identifier of the Call Home client.
726 * If a Call Home client with this identifier already exists, its contents will be changed.
roman142718b2023-06-29 09:15:29 +0200727 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
728 * If the client's endpoint with this identifier already exists, its contents will be changed.
729 * @param[in] transport Transport protocol to be used on this endpoint - either SSH or TLS.
730 * @param[in] address Address to connect to.
731 * @param[in] port Port to connect to.
732 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
733 * Otherwise the new YANG data will be added to the previous data and may override it.
734 * @return 0 on success, non-zero otherwise.
735 */
Roytakb2794852023-10-18 14:30:22 +0200736int 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 +0200737 NC_TRANSPORT_IMPL transport, const char *address, const char *port, struct lyd_node **config);
738
roman8ba6efa2023-07-12 15:27:52 +0200739#endif /* NC_ENABLED_SSH_TLS */
740
741/**
Roytak2161df62023-08-02 15:04:42 +0200742 * @brief Deletes a Call Home client from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +0200743 *
744 * @param[in] client_name Optional identifier of a client to be deleted.
Roytak2161df62023-08-02 15:04:42 +0200745 * If NULL, all of the Call Home clients will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200746 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200747 * @return 0 on success, non-zero otherwise.
748 */
Roytakb2794852023-10-18 14:30:22 +0200749int nc_server_config_del_ch_client(const char *client_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200750
751/**
Roytak2161df62023-08-02 15:04:42 +0200752 * @brief Deletes a Call Home endpoint from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +0200753 *
Roytak2161df62023-08-02 15:04:42 +0200754 * @param[in] client_name Identifier of an existing Call Home client.
roman8ba6efa2023-07-12 15:27:52 +0200755 * @param[in] endpt_name Optional identifier of a CH endpoint to be deleted.
756 * If NULL, all of the CH endpoints which belong to the given client will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200757 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200758 * @return 0 on success, non-zero otherwise.
759 */
Roytakb2794852023-10-18 14:30:22 +0200760int nc_server_config_del_ch_endpt(const char *client_name, const char *endpt_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200761
762/**
Roytak2161df62023-08-02 15:04:42 +0200763 * @brief Creates new YANG configuration data nodes for the Call Home persistent connection type.
roman8ba6efa2023-07-12 15:27:52 +0200764 *
765 * This is the default connection type. If periodic connection type was set before, it will be unset.
766 *
767 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200768 * @param[in] client_name Arbitrary identifier of the Call Home client.
769 * If a Call Home client with this identifier already exists, its contents will be changed.
Roytak9b32c0f2023-08-02 15:07:29 +0200770 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +0200771 * Otherwise the new YANG data will be added to the previous data and may override it.
772 * @return 0 on success, non-zero otherwise.
773 */
Roytakb2794852023-10-18 14:30:22 +0200774int 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 +0200775
776/**
Roytak2161df62023-08-02 15:04:42 +0200777 * @brief Creates new YANG configuration data nodes for the period parameter of the Call Home periodic connection type.
roman8ba6efa2023-07-12 15:27:52 +0200778 *
779 * If called, the persistent connection type will be replaced by periodic.
780 *
781 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200782 * @param[in] client_name Arbitrary identifier of the Call Home client.
783 * If a Call Home client with this identifier already exists, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +0200784 * @param[in] period Duration between periodic connections in minutes.
Roytak9b32c0f2023-08-02 15:07:29 +0200785 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +0200786 * Otherwise the new YANG data will be added to the previous data and may override it.
787 * @return 0 on success, non-zero otherwise.
788 */
Roytakb2794852023-10-18 14:30:22 +0200789int nc_server_config_add_ch_period(const struct ly_ctx *ctx, const char *client_name, uint16_t period,
roman8ba6efa2023-07-12 15:27:52 +0200790 struct lyd_node **config);
791
792/**
Roytak2161df62023-08-02 15:04:42 +0200793 * @brief Deletes the Call Home period parameter of the periodic connection type from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +0200794 *
795 * This behaves the same as setting the period to 60 minutes, which is the default value of this node.
796 *
Roytak2161df62023-08-02 15:04:42 +0200797 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +0200798 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200799 * @return 0 on success, non-zero otherwise.
800 */
Roytakb2794852023-10-18 14:30:22 +0200801int nc_server_config_del_ch_period(const char *client_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200802
803/**
Roytak2161df62023-08-02 15:04:42 +0200804 * @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 +0200805 *
806 * If called, the persistent connection type will be replaced by periodic.
807 *
808 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200809 * @param[in] client_name Arbitrary identifier of the Call Home client.
810 * If a Call Home client with this identifier already exists, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +0200811 * @param[in] anchor_time Timestamp before or after which a series of periodic connections are determined.
Roytak9b32c0f2023-08-02 15:07:29 +0200812 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +0200813 * Otherwise the new YANG data will be added to the previous data and may override it.
814 * @return 0 on success, non-zero otherwise.
815 */
Roytakb2794852023-10-18 14:30:22 +0200816int nc_server_config_add_ch_anchor_time(const struct ly_ctx *ctx, const char *client_name,
roman8ba6efa2023-07-12 15:27:52 +0200817 const char *anchor_time, struct lyd_node **config);
818
819/**
Roytak2161df62023-08-02 15:04:42 +0200820 * @brief Deletes the Call Home anchor time parameter of the periodic connection type from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +0200821 *
Roytak2161df62023-08-02 15:04:42 +0200822 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +0200823 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200824 * @return 0 on success, non-zero otherwise.
825 */
Roytakb2794852023-10-18 14:30:22 +0200826int nc_server_config_del_ch_anchor_time(const char *client_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200827
828/**
Roytak2161df62023-08-02 15:04:42 +0200829 * @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 +0200830 *
831 * If called, the persistent connection type will be replaced by periodic.
832 *
833 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200834 * @param[in] client_name Arbitrary identifier of the Call Home client.
835 * If a Call Home client with this identifier already exists, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +0200836 * @param[in] idle_timeout Specifies the maximum number of seconds that a session may remain idle.
Roytak9b32c0f2023-08-02 15:07:29 +0200837 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +0200838 * Otherwise the new YANG data will be added to the previous data and may override it.
839 * @return 0 on success, non-zero otherwise.
840 */
Roytakb2794852023-10-18 14:30:22 +0200841int nc_server_config_add_ch_idle_timeout(const struct ly_ctx *ctx, const char *client_name,
roman8ba6efa2023-07-12 15:27:52 +0200842 uint16_t idle_timeout, struct lyd_node **config);
843
844/**
Roytak2161df62023-08-02 15:04:42 +0200845 * @brief Deletes the Call Home idle timeout parameter of the periodic connection type from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +0200846 *
847 * This behaves the same as setting the timeout to 180 seconds, which is the default value of this node.
848 *
Roytak2161df62023-08-02 15:04:42 +0200849 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +0200850 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200851 * @return 0 on success, non-zero otherwise.
852 */
Roytakb2794852023-10-18 14:30:22 +0200853int nc_server_config_del_ch_idle_timeout(const char *client_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200854
855/**
Roytak2161df62023-08-02 15:04:42 +0200856 * @brief Creates new YANG configuration data nodes for the Call Home reconnect strategy.
roman8ba6efa2023-07-12 15:27:52 +0200857 *
858 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200859 * @param[in] client_name Arbitrary identifier of the Call Home client.
860 * If a Call Home client with this identifier already exists, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +0200861 * @param[in] start_with Specifies which endpoint to try if a connection is unsuccessful. Default value is NC_CH_FIRST_LISTED.
862 * @param[in] max_wait The number of seconds after which a connection to an endpoint is deemed unsuccessful. Default value if 5.
863 * @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 +0200864 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +0200865 * Otherwise the new YANG data will be added to the previous data and may override it.
866 * @return 0 on success, non-zero otherwise.
867 */
Roytakb2794852023-10-18 14:30:22 +0200868int nc_server_config_add_ch_reconnect_strategy(const struct ly_ctx *ctx, const char *client_name,
roman8ba6efa2023-07-12 15:27:52 +0200869 NC_CH_START_WITH start_with, uint16_t max_wait, uint8_t max_attempts, struct lyd_node **config);
870
871/**
Roytak2161df62023-08-02 15:04:42 +0200872 * @brief Resets the values of the Call Home reconnect strategy nodes to their defaults.
roman8ba6efa2023-07-12 15:27:52 +0200873 *
874 * The default values are: start-with = NC_CH_FIRST_LISTED, max-wait = 5 and max-attempts = 3.
875 *
Roytak2161df62023-08-02 15:04:42 +0200876 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +0200877 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200878 * @return 0 on success, non-zero otherwise.
879 */
Roytakb2794852023-10-18 14:30:22 +0200880int nc_server_config_del_ch_reconnect_strategy(const char *client_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200881
882/**
roman35120972023-08-08 10:39:12 +0200883 * @} Call Home Server Configuration Functions
roman8ba6efa2023-07-12 15:27:52 +0200884 */
885
886#ifdef NC_ENABLED_SSH_TLS
887
888/**
Roytak2161df62023-08-02 15:04:42 +0200889 * @defgroup server_config_ch_ssh SSH Call Home Server Configuration
roman8ba6efa2023-07-12 15:27:52 +0200890 * @ingroup server_config_ch
891 *
Roytak2161df62023-08-02 15:04:42 +0200892 * @brief SSH Call Home server configuration creation and deletion
roman8ba6efa2023-07-12 15:27:52 +0200893 * @{
894 */
895
roman142718b2023-06-29 09:15:29 +0200896/**
Roytak2161df62023-08-02 15:04:42 +0200897 * @brief Creates new YANG data nodes for a Call Home SSH hostkey.
roman142718b2023-06-29 09:15:29 +0200898 *
899 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200900 * @param[in] client_name Arbitrary identifier of the Call Home client.
901 * If a Call Home client with this identifier already exists, its contents will be changed.
roman142718b2023-06-29 09:15:29 +0200902 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
903 * If the client's endpoint with this identifier already exists, its contents will be changed.
904 * @param[in] hostkey_name Arbitrary identifier of the endpoint's hostkey.
905 * If the endpoint's hostkey with this identifier already exists, its contents will be changed.
906 * @param[in] privkey_path Path to a file containing a private key.
907 * The private key has to be in a PEM format. Only RSA and ECDSA keys are supported.
908 * @param[in] pubkey_path Path to a file containing a public key. If NULL, public key will be
909 * generated from the private key.
910 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
911 * Otherwise the new YANG data will be added to the previous data and may override it.
912 * @return 0 on success, non-zero otherwise.
913 */
Roytakb2794852023-10-18 14:30:22 +0200914int 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 +0200915 const char *hostkey_name, const char *privkey_path, const char *pubkey_path, struct lyd_node **config);
916
roman142718b2023-06-29 09:15:29 +0200917/**
Roytak2161df62023-08-02 15:04:42 +0200918 * @brief Deletes a Call Home hostkey from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +0200919 *
Roytak2161df62023-08-02 15:04:42 +0200920 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +0200921 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
roman8ba6efa2023-07-12 15:27:52 +0200922 * @param[in] hostkey_name Optional identifier of a hostkey to be deleted.
923 * If NULL, all of the hostkeys on the given endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200924 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200925 * @return 0 on success, non-zero otherwise.
926 */
Roytakb2794852023-10-18 14:30:22 +0200927int nc_server_config_del_ch_ssh_hostkey(const char *client_name, const char *endpt_name,
roman9d5e5a52023-07-14 12:43:44 +0200928 const char *hostkey_name, struct lyd_node **config);
929
930/**
romand348b942023-10-13 14:32:19 +0200931 * @brief Creates new YANG data nodes for a reference to an asymmetric key located in the keystore.
932 *
933 * This asymmetric key pair will be used as the Call Home SSH hostkey.
934 *
935 * @param[in] ctx libyang context.
936 * @param[in] client_name Arbitrary identifier of the Call Home client.
937 * If a Call Home client with this identifier already exists, its contents will be changed.
938 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
939 * If the client's endpoint with this identifier already exists, its contents will be changed.
940 * @param[in] hostkey_name Arbitrary identifier of the endpoint's hostkey.
941 * If the endpoint's hostkey with this identifier already exists, its contents will be changed.
942 * @param[in] keystore_reference Name of the asymmetric key pair to be referenced and used as a hostkey.
943 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
944 * Otherwise the new YANG data will be added to the previous data and may override it.
945 * @return 0 on success, non-zero otherwise.
946 */
947int nc_server_config_add_ch_ssh_keystore_ref(const struct ly_ctx *ctx, const char *client_name,
948 const char *endpt_name, const char *hostkey_name, const char *keystore_reference, struct lyd_node **config);
949
950/**
951 * @brief Deletes a Call Home keystore reference from the YANG data.
952 *
953 * @param[in] client_name Identifier of an existing Call Home client.
954 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
955 * @param[in] hostkey_name Identifier of an existing hostkey that belongs to the given CH endpoint.
956 * @param[in,out] config Modified configuration YANG data tree.
957 * @return 0 on success, non-zero otherwise.
958 */
959int nc_server_config_del_ch_ssh_keystore_ref(const char *client_name, const char *endpt_name,
960 const char *hostkey_name, struct lyd_node **config);
961
962/**
Roytak2161df62023-08-02 15:04:42 +0200963 * @brief Creates new YANG data nodes for a Call Home SSH user's public key authentication method.
roman142718b2023-06-29 09:15:29 +0200964 *
965 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200966 * @param[in] client_name Arbitrary identifier of the Call Home client.
967 * If a Call Home client with this identifier already exists, its contents will be changed.
roman142718b2023-06-29 09:15:29 +0200968 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
969 * If the client's endpoint with this identifier already exists, its contents will be changed.
970 * @param[in] user_name Arbitrary identifier of the endpoint's user.
971 * If the endpoint's user with this identifier already exists, its contents will be changed.
972 * @param[in] pubkey_name Arbitrary identifier of the user's public key.
973 * If the user's public key with this identifier already exists, its contents will be changed.
974 * @param[in] pubkey_path Path to a file containing a public key.
975 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
976 * Otherwise the new YANG data will be added to the previous data and may override it.
977 * @return 0 on success, non-zero otherwise.
978 */
Roytakb2794852023-10-18 14:30:22 +0200979int 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 +0200980 const char *user_name, const char *pubkey_name, const char *pubkey_path, struct lyd_node **config);
981
roman142718b2023-06-29 09:15:29 +0200982/**
Roytak2161df62023-08-02 15:04:42 +0200983 * @brief Deletes a Call Home SSH user's public key from the YANG data.
roman142718b2023-06-29 09:15:29 +0200984 *
Roytak2161df62023-08-02 15:04:42 +0200985 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +0200986 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
987 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
roman8ba6efa2023-07-12 15:27:52 +0200988 * @param[in] pubkey_name Optional identifier of a public key to be deleted.
989 * If NULL, all of the public keys which belong to the given SSH user will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200990 * @param[in,out] config Modified configuration YANG data tree.
roman142718b2023-06-29 09:15:29 +0200991 * @return 0 on success, non-zero otherwise.
992 */
Roytakb2794852023-10-18 14:30:22 +0200993int nc_server_config_del_ch_ssh_user_pubkey(const char *client_name, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +0200994 const char *user_name, const char *pubkey_name, struct lyd_node **config);
roman5cbb6532023-06-22 12:53:17 +0200995
roman142718b2023-06-29 09:15:29 +0200996/**
Roytak2161df62023-08-02 15:04:42 +0200997 * @brief Creates new YANG data nodes for a Call Home SSH user's password authentication method.
roman9d5e5a52023-07-14 12:43:44 +0200998 *
999 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001000 * @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.
roman9d5e5a52023-07-14 12:43:44 +02001002 * @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] user_name Arbitrary identifier of the endpoint's user.
1005 * If the endpoint's user with this identifier already exists, its contents will be changed.
roman35120972023-08-08 10:39:12 +02001006 * @param[in] password Clear-text password to be set for the user. It will be hashed.
roman9d5e5a52023-07-14 12:43:44 +02001007 * @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 */
Roytakb2794852023-10-18 14:30:22 +02001011int 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 +02001012 const char *user_name, const char *password, struct lyd_node **config);
1013
1014/**
Roytak2161df62023-08-02 15:04:42 +02001015 * @brief Deletes a Call Home SSH user's password from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001016 *
Roytak2161df62023-08-02 15:04:42 +02001017 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001018 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1019 * @param[in] user_name Identifier of an existing SSH user 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 */
Roytakb2794852023-10-18 14:30:22 +02001023int nc_server_config_del_ch_ssh_user_password(const char *client_name, const char *endpt_name,
roman9d5e5a52023-07-14 12:43:44 +02001024 const char *user_name, struct lyd_node **config);
1025
1026/**
Roytak2161df62023-08-02 15:04:42 +02001027 * @brief Creates new YANG configuration data nodes for a Call Home SSH user's keyboard interactive authentication method.
roman9d5e5a52023-07-14 12:43:44 +02001028 *
romanc6518422023-11-30 16:39:00 +01001029 * 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 +01001030 *
roman9d5e5a52023-07-14 12:43:44 +02001031 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001032 * @param[in] client_name Arbitrary identifier of the Call Home client.
1033 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001034 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1035 * If the client's endpoint with this identifier already exists, its contents will be changed.
1036 * @param[in] user_name Arbitrary identifier of the endpoint's user.
1037 * If the endpoint's user with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001038 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1039 * Otherwise the new YANG data will be added to the previous data and may override it.
1040 * @return 0 on success, non-zero otherwise.
1041 */
Roytakb2794852023-10-18 14:30:22 +02001042int 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 +01001043 const char *user_name, struct lyd_node **config);
roman9d5e5a52023-07-14 12:43:44 +02001044
1045/**
Roytak2161df62023-08-02 15:04:42 +02001046 * @brief Deletes a Call Home SSH user's keyboard interactive authentication from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001047 *
Roytak2161df62023-08-02 15:04:42 +02001048 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001049 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1050 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
1051 * @param[in,out] config Modified configuration YANG data tree.
1052 * @return 0 on success, non-zero otherwise.
1053 */
Roytakb2794852023-10-18 14:30:22 +02001054int nc_server_config_del_ch_ssh_user_interactive(const char *client_name, const char *endpt_name,
roman9d5e5a52023-07-14 12:43:44 +02001055 const char *user_name, struct lyd_node **config);
1056
1057/**
Roytak2161df62023-08-02 15:04:42 +02001058 * @brief Deletes a Call Home SSH user from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001059 *
Roytak2161df62023-08-02 15:04:42 +02001060 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001061 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1062 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
1063 * @param[in,out] config Modified configuration YANG data tree.
1064 * @return 0 on success, non-zero otherwise.
1065 */
Roytakb2794852023-10-18 14:30:22 +02001066int nc_server_config_del_ch_ssh_user(const char *client_name, const char *endpt_name,
roman9d5e5a52023-07-14 12:43:44 +02001067 const char *user_name, struct lyd_node **config);
1068
1069/**
romand348b942023-10-13 14:32:19 +02001070 * @brief Creates new YANG data nodes for a reference to a public key bag located in the truststore.
1071 *
1072 * The public key's located in the bag will be used for Call Home SSH client authentication.
1073 *
1074 * @param[in] ctx libyang context.
1075 * @param[in] client_name Arbitrary identifier of the Call Home client.
1076 * If a Call Home client with this identifier already exists, its contents will be changed.
1077 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1078 * If the client's endpoint with this identifier already exists, its contents will be changed.
1079 * @param[in] user_name Arbitrary identifier of the endpoint's user.
1080 * If the endpoint's user with this identifier already exists, its contents will be changed.
1081 * @param[in] truststore_reference Name of the public key bag to be referenced and used for authentication.
1082 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1083 * Otherwise the new YANG data will be added to the previous data and may override it.
1084 * @return 0 on success, non-zero otherwise.
1085 */
1086int nc_server_config_add_ch_ssh_truststore_ref(const struct ly_ctx *ctx, const char *client_name,
1087 const char *endpt_name, const char *user_name, const char *truststore_reference, struct lyd_node **config);
1088
1089/**
1090 * @brief Deletes a Call Home SSH truststore reference from the YANG data.
1091 *
1092 * @param[in] client_name Identifier of an existing Call Home client.
1093 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1094 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
1095 * @param[in,out] config Modified configuration YANG data tree.
1096 * @return 0 on success, non-zero otherwise.
1097 */
1098int nc_server_config_del_ch_ssh_truststore_ref(const char *client_name, const char *endpt_name,
1099 const char *user_name, struct lyd_node **config);
1100
1101/**
roman35120972023-08-08 10:39:12 +02001102 * @} SSH Call Home Server Configuration
roman142718b2023-06-29 09:15:29 +02001103 */
roman142718b2023-06-29 09:15:29 +02001104
1105/**
Roytak2161df62023-08-02 15:04:42 +02001106 * @defgroup server_config_ch_tls TLS Call Home Server Configuration
roman8ba6efa2023-07-12 15:27:52 +02001107 * @ingroup server_config_ch
roman142718b2023-06-29 09:15:29 +02001108 *
Roytak2161df62023-08-02 15:04:42 +02001109 * @brief TLS Call Home server configuration creation and deletion
roman8ba6efa2023-07-12 15:27:52 +02001110 * @{
roman142718b2023-06-29 09:15:29 +02001111 */
roman142718b2023-06-29 09:15:29 +02001112
romanb6f44032023-06-30 15:07:56 +02001113/**
Roytak2161df62023-08-02 15:04:42 +02001114 * @brief Creates new YANG configuration data nodes for a Call Home server's certificate.
romanb6f44032023-06-30 15:07:56 +02001115 *
1116 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001117 * @param[in] client_name Arbitrary identifier of the Call Home client.
1118 * If a Call Home client with this identifier already exists, its contents will be changed.
1119 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1120 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
roman6c4efcd2023-08-08 10:18:44 +02001121 * @param[in] privkey_path Path to the server's PEM encoded private key file.
romanb6f44032023-06-30 15:07:56 +02001122 * @param[in] pubkey_path Optional path to the server's public key file. If not provided,
1123 * it will be generated from the private key.
romane6ec60e2023-10-19 15:21:52 +02001124 * @param[in] cert_path Path to the server's certificate file.
Roytak934edc32023-07-27 12:04:18 +02001125 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
romanb6f44032023-06-30 15:07:56 +02001126 * Otherwise the new YANG data will be added to the previous data and may override it.
1127 * @return 0 on success, non-zero otherwise.
1128 */
romane6ec60e2023-10-19 15:21:52 +02001129int nc_server_config_add_ch_tls_server_cert(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1130 const char *privkey_path, const char *pubkey_path, const char *cert_path, struct lyd_node **config);
romanb6f44032023-06-30 15:07:56 +02001131
1132/**
Roytak2161df62023-08-02 15:04:42 +02001133 * @brief Deletes a Call Home server certificate from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001134 *
Roytak2161df62023-08-02 15:04:42 +02001135 * @param[in] client_name Identifier of an existing Call Home client.
1136 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
roman9d5e5a52023-07-14 12:43:44 +02001137 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001138 * @return 0 on success, non-zero otherwise.
1139 */
romane6ec60e2023-10-19 15:21:52 +02001140int nc_server_config_del_ch_tls_server_cert(const char *client_name, const char *endpt_name,
romand348b942023-10-13 14:32:19 +02001141 struct lyd_node **config);
1142
1143/**
1144 * @brief Creates new YANG configuration data nodes for a keystore reference to the Call Home TLS server's certificate.
1145 *
1146 * @param[in] ctx libyang context.
1147 * @param[in] client_name Arbitrary identifier of the Call Home client.
1148 * If a Call Home client with this identifier already exists, its contents will be changed.
1149 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1150 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
1151 * @param[in] asym_key_ref Name of the asymmetric key pair in the keystore to be referenced.
1152 * @param[in] cert_ref Name of the certificate, which must belong to the given asymmetric key pair, to be referenced.
1153 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1154 * Otherwise the new YANG data will be added to the previous data and may override it.
1155 * @return 0 on success, non-zero otherwise.
1156 */
1157int nc_server_config_add_ch_tls_keystore_ref(const struct ly_ctx *ctx, const char *client_name,
1158 const char *endpt_name, const char *asym_key_ref, const char *cert_ref, struct lyd_node **config);
1159
1160/**
1161 * @brief Deletes a TLS server certificate keystore reference from the YANG data.
1162 *
1163 * @param[in] client_name Identifier of an existing Call Home client.
1164 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
1165 * @param[in,out] config Modified configuration YANG data tree.
1166 * @return 0 on success, non-zero otherwise.
1167 */
1168int nc_server_config_del_ch_tls_keystore_ref(const char *client_name, const char *endpt_name,
Roytak934edc32023-07-27 12:04:18 +02001169 struct lyd_node **config);
1170
1171/**
Roytak2161df62023-08-02 15:04:42 +02001172 * @brief Creates new YANG configuration data nodes for a Call Home client's (end-entity) certificate.
romanb6f44032023-06-30 15:07:56 +02001173 *
1174 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001175 * @param[in] client_name Arbitrary identifier of the Call Home client.
1176 * If a Call Home client with this identifier already exists, its contents will be changed.
1177 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1178 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
1179 * @param[in] cert_name Arbitrary identifier of the Call Home endpoint's end-entity certificate.
1180 * 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 +02001181 * @param[in] cert_path Path to the certificate file.
Roytak934edc32023-07-27 12:04:18 +02001182 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
romanb6f44032023-06-30 15:07:56 +02001183 * Otherwise the new YANG data will be added to the previous data and may override it.
1184 * @return 0 on success, non-zero otherwise.
1185 */
romane6ec60e2023-10-19 15:21:52 +02001186int 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 +02001187 const char *cert_name, const char *cert_path, struct lyd_node **config);
1188
1189/**
Roytak2161df62023-08-02 15:04:42 +02001190 * @brief Deletes a Call Home client (end-entity) certificate from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001191 *
Roytak2161df62023-08-02 15:04:42 +02001192 * @param[in] client_name Identifier of an existing Call Home client.
1193 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
roman8ba6efa2023-07-12 15:27:52 +02001194 * @param[in] cert_name Optional identifier of a client certificate to be deleted.
1195 * If NULL, all of the client certificates will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001196 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001197 * @return 0 on success, non-zero otherwise.
1198 */
romane6ec60e2023-10-19 15:21:52 +02001199int nc_server_config_del_ch_tls_client_cert(const char *client_name, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +02001200 const char *cert_name, struct lyd_node **config);
1201
1202/**
romand348b942023-10-13 14:32:19 +02001203 * @brief Creates new YANG configuration data nodes for a Call Home truststore reference to a set of client (end-entity) certificates.
1204 *
1205 * @param[in] ctx libyang context.
1206 * @param[in] client_name Arbitrary identifier of the Call Home client.
1207 * If a Call Home client with this identifier already exists, its contents will be changed.
1208 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1209 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
1210 * @param[in] cert_bag_ref Identifier of the certificate bag in the truststore to be referenced.
1211 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1212 * Otherwise the new YANG data will be added to the previous data and may override it.
1213 * @return 0 on success, non-zero otherwise.
1214 */
1215int nc_server_config_add_ch_tls_client_cert_truststore_ref(const struct ly_ctx *ctx, const char *client_name,
1216 const char *endpt_name, const char *cert_bag_ref, struct lyd_node **config);
1217
1218/**
1219 * @brief Deletes a Call Home client (end-entity) certificates truststore reference from the YANG data.
1220 *
1221 * @param[in] client_name Identifier of an existing Call Home client.
1222 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
1223 * @param[in,out] config Modified configuration YANG data tree.
1224 * @return 0 on success, non-zero otherwise.
1225 */
1226int nc_server_config_del_ch_tls_client_cert_truststore_ref(const char *client_name, const char *endpt_name,
1227 struct lyd_node **config);
1228
1229/**
romanb6f44032023-06-30 15:07:56 +02001230 * @brief Creates new YANG configuration data nodes for a client certificate authority (trust-anchor) certificate.
1231 *
1232 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001233 * @param[in] client_name Arbitrary identifier of the Call Home client.
1234 * If a Call Home client with this identifier already exists, its contents will be changed.
1235 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1236 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
1237 * @param[in] cert_name Arbitrary identifier of the Call Home endpoint's certificate authority certificate.
1238 * If an Call Home endpoint's CA certificate with this identifier already exists, its contents will be changed.
romanb6f44032023-06-30 15:07:56 +02001239 * @param[in] cert_path Path to the certificate file.
Roytak9b32c0f2023-08-02 15:07:29 +02001240 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
romanb6f44032023-06-30 15:07:56 +02001241 * Otherwise the new YANG data will be added to the previous data and may override it.
1242 * @return 0 on success, non-zero otherwise.
1243 */
romane6ec60e2023-10-19 15:21:52 +02001244int 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 +02001245 const char *cert_name, const char *cert_path, struct lyd_node **config);
1246
1247/**
Roytak2161df62023-08-02 15:04:42 +02001248 * @brief Deletes a Call Home client certificate authority (trust-anchor) certificate from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001249 *
Roytak2161df62023-08-02 15:04:42 +02001250 * @param[in] client_name Identifier of an existing Call Home client.
1251 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
roman8ba6efa2023-07-12 15:27:52 +02001252 * @param[in] cert_name Optional identifier of a CA certificate to be deleted.
1253 * If NULL, all of the CA certificates will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001254 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001255 * @return 0 on success, non-zero otherwise.
1256 */
romane6ec60e2023-10-19 15:21:52 +02001257int nc_server_config_del_ch_tls_ca_cert(const char *client_name, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +02001258 const char *cert_name, struct lyd_node **config);
1259
1260/**
romand348b942023-10-13 14:32:19 +02001261 * @brief Creates new YANG configuration data nodes for a Call Home truststore reference to a set of client certificate authority (trust-anchor) certificates.
1262 *
1263 * @param[in] ctx libyang context.
1264 * @param[in] client_name Arbitrary identifier of the Call Home client.
1265 * If a Call Home client with this identifier already exists, its contents will be changed.
1266 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1267 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
1268 * @param[in] cert_bag_ref Identifier of the certificate bag in the truststore to be referenced.
1269 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1270 * Otherwise the new YANG data will be added to the previous data and may override it.
1271 * @return 0 on success, non-zero otherwise.
1272 */
romane6ec60e2023-10-19 15:21:52 +02001273int 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 +02001274 const char *endpt_name, const char *cert_bag_ref, struct lyd_node **config);
1275
1276/**
1277 * @brief Deletes a Call Home client certificate authority (trust-anchor) certificates truststore reference from the YANG data.
1278 *
1279 * @param[in] client_name Identifier of an existing Call Home client.
1280 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
1281 * @param[in,out] config Modified configuration YANG data tree.
1282 * @return 0 on success, non-zero otherwise.
1283 */
romane6ec60e2023-10-19 15:21:52 +02001284int nc_server_config_del_ch_tls_ca_cert_truststore_ref(const char *client_name, const char *endpt_name,
romand348b942023-10-13 14:32:19 +02001285 struct lyd_node **config);
1286
1287/**
Roytak2161df62023-08-02 15:04:42 +02001288 * @brief Creates new YANG configuration data nodes for a Call Home cert-to-name entry.
romanb6f44032023-06-30 15:07:56 +02001289 *
1290 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001291 * @param[in] client_name Arbitrary identifier of the Call Home client.
1292 * If a Call Home client with this identifier already exists, its contents will be changed.
1293 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1294 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
romanb6f44032023-06-30 15:07:56 +02001295 * @param[in] id ID of the entry. The lower the ID, the higher the priority of the entry (it will be checked earlier).
1296 * @param[in] fingerprint Optional fingerprint of the entry. The fingerprint should always be set, however if it is
1297 * not set, it will match any certificate. Entry with no fingerprint should therefore be placed only as the last entry.
1298 * @param[in] map_type Mapping username to the certificate option.
1299 * @param[in] name Username for this cert-to-name entry.
Roytak9b32c0f2023-08-02 15:07:29 +02001300 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
romanb6f44032023-06-30 15:07:56 +02001301 * Otherwise the new YANG data will be added to the previous data and may override it.
1302 * @return 0 on success, non-zero otherwise.
1303 */
Roytakb2794852023-10-18 14:30:22 +02001304int 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 +02001305 uint32_t id, const char *fingerprint, NC_TLS_CTN_MAPTYPE map_type, const char *name, struct lyd_node **config);
1306
roman8ba6efa2023-07-12 15:27:52 +02001307/**
Roytak2161df62023-08-02 15:04:42 +02001308 * @brief Deletes a Call Home cert-to-name entry from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001309 *
Roytak2161df62023-08-02 15:04:42 +02001310 * @param[in] client_name Identifier of an existing Call Home client.
1311 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
1312 * @param[in] id Optional identifier of the Call Home CTN entry to be deleted.
roman8ba6efa2023-07-12 15:27:52 +02001313 * If 0, all of the CTN entries will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001314 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001315 * @return 0 on success, non-zero otherwise.
1316 */
Roytakb2794852023-10-18 14:30:22 +02001317int nc_server_config_del_ch_tls_ctn(const char *client_name, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +02001318 uint32_t id, struct lyd_node **config);
1319
1320/**
roman35120972023-08-08 10:39:12 +02001321 * @} TLS Call Home Server Configuration
roman8ba6efa2023-07-12 15:27:52 +02001322 */
1323
roman2eab4742023-06-06 10:00:26 +02001324#endif /* NC_ENABLED_SSH_TLS */
roman45cec4e2023-02-17 10:21:39 +01001325
romanc1d2b092023-02-02 08:58:27 +01001326#ifdef __cplusplus
1327}
1328#endif
1329
1330#endif /* NC_SESSION_SERVER_H_ */