blob: 32f9805e059f4571ff19d1b687fe58023f2e0b43 [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 *
386 * @param[in] ctx libyang context.
387 * @param[in] endpt_name Arbitrary identifier of the endpoint.
388 * If an endpoint with this identifier already exists, its user might be changed.
389 * @param[in] user_name Arbitrary identifier of the user.
390 * If an user with this identifier already exists, its contents will be changed.
391 * @param[in] pam_config_name Name of the PAM configuration file.
roman0f5fa422023-08-07 09:03:24 +0200392 * @param[in] pam_config_dir Optional. The absolute path to the directory in which the configuration file
393 * with the name pam_config_name is located. A newer version (>= 1.4) of PAM library is required to be able to specify
roman8ba6efa2023-07-12 15:27:52 +0200394 * the path. If NULL is passed, then the PAM's system directories will be searched (usually /etc/pam.d/).
395 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
396 * Otherwise the new YANG data will be added to the previous data and may override it.
397 * @return 0 on success, non-zero otherwise.
398 */
roman808f3f62023-11-23 16:01:04 +0100399
400/**
401 * @brief Creates new YANG configuration data nodes for an SSH user's keyboard interactive authentication method.
402 *
403 * To set the PAM configuration filename, see ::nc_server_ssh_set_pam_conf_filename().
404 *
405 * @param[in] ctx libyang context.
406 * @param[in] endpt_name Arbitrary identifier of the endpoint.
407 * If an endpoint with this identifier already exists, its user might be changed.
408 * @param[in] user_name Arbitrary identifier of the user.
409 * If an user with this identifier already exists, its contents will be changed.
410 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
411 * Otherwise the new YANG data will be added to the previous data and may override it.
412 * @return 0 on success, non-zero otherwise.
413 */
Roytakb2794852023-10-18 14:30:22 +0200414int nc_server_config_add_ssh_user_interactive(const struct ly_ctx *ctx, const char *endpt_name,
roman808f3f62023-11-23 16:01:04 +0100415 const char *user_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200416
417/**
418 * @brief Deletes an SSH user's keyboard interactive authentication from the YANG data.
419 *
420 * @param[in] endpt_name Identifier of an existing endpoint.
421 * @param[in] user_name Identifier of an existing user on the given endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200422 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200423 * @return 0 on success, non-zero otherwise.
424 */
Roytakb2794852023-10-18 14:30:22 +0200425int nc_server_config_del_ssh_user_interactive(const char *endpt_name, const char *user_name,
roman8ba6efa2023-07-12 15:27:52 +0200426 struct lyd_node **config);
427
428/**
429 * @brief Deletes an SSH user from the YANG data.
430 *
431 * @param[in] endpt_name Identifier of an existing endpoint.
432 * @param[in] user_name Optional identifier of an user to be deleted.
433 * If NULL, all of the users on this endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200434 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200435 * @return 0 on success, non-zero otherwise.
436 */
Roytakb2794852023-10-18 14:30:22 +0200437int nc_server_config_del_ssh_user(const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +0200438 const char *user_name, struct lyd_node **config);
439
440/**
romand348b942023-10-13 14:32:19 +0200441 * @brief Creates new YANG data nodes for a reference to a public key bag located in the truststore.
442 *
443 * The public key's located in the bag will be used for client authentication.
444 *
445 * @param[in] ctx libyang context.
446 * @param[in] endpt_name Arbitrary identifier of an endpoint.
447 * If an endpoint with this identifier already exists, its contents will be changed.
448 * @param[in] user_name Arbitrary identifier of the endpoint's user.
449 * If an endpoint's user with this identifier already exists, its contents will be changed.
450 * @param[in] truststore_reference Name of the public key bag to be referenced and used for authentication.
451 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
452 * Otherwise the new YANG data will be added to the previous data and may override it.
453 * @return 0 on success, non-zero otherwise.
454 */
455int nc_server_config_add_ssh_truststore_ref(const struct ly_ctx *ctx, const char *endpt_name, const char *user_name,
456 const char *truststore_reference, struct lyd_node **config);
457
458/**
459 * @brief Deletes a truststore reference from the YANG data.
460 *
461 * @param[in] endpt_name Identifier of an existing endpoint.
462 * @param[in] user_name Identifier of an user on the given endpoint whose truststore reference will be deleted.
463 * @param[in,out] config Modified configuration YANG data tree.
464 * @return 0 on success, non-zero otherwise.
465 */
466int nc_server_config_del_ssh_truststore_ref(const char *endpt_name, const char *user_name,
467 struct lyd_node **config);
468
469/**
roman8ba6efa2023-07-12 15:27:52 +0200470 * @brief Creates new YANG configuration data nodes, which will be a reference to another SSH endpoint's users.
471 *
472 * Whenever a client tries to connect to the referencing endpoint, all of its users will be tried first. If no match is
473 * found, the referenced endpoint's configured users will be tried.
474 *
475 * @param[in] ctx libyang context
476 * @param[in] endpt_name Arbitrary identifier of the endpoint.
477 * If an endpoint with this identifier already exists, its contents will be changed.
478 * @param[in] referenced_endpt Identifier of an endpoint, which has to exist whenever this data
479 * is applied. The referenced endpoint can reference another one and so on, but there mustn't be a cycle.
480 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
481 * Otherwise the new YANG data will be added to the previous data and may override it.
482 * @return 0 on success, non-zero otherwise.
483 */
Roytakb2794852023-10-18 14:30:22 +0200484int nc_server_config_add_ssh_endpoint_client_ref(const struct ly_ctx *ctx, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +0200485 const char *referenced_endpt, struct lyd_node **config);
486
487/**
488 * @brief Deletes reference to another SSH endpoint's users from the YANG data.
489 *
490 * @param[in] endpt_name Identifier of an existing endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200491 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200492 * @return 0 on success, non-zero otherwise.
493 */
Roytakb2794852023-10-18 14:30:22 +0200494int nc_server_config_del_ssh_endpoint_client_ref(const char *endpt_name, struct lyd_node **config);
roman9b1379c2023-03-31 10:11:10 +0200495
496/**
roman35120972023-08-08 10:39:12 +0200497 * @} SSH Server Configuration
roman9b1379c2023-03-31 10:11:10 +0200498 */
roman9b1379c2023-03-31 10:11:10 +0200499
500/**
roman8ba6efa2023-07-12 15:27:52 +0200501 * @defgroup server_config_tls TLS Server Configuration
502 * @ingroup server_config
roman9b1379c2023-03-31 10:11:10 +0200503 *
roman8ba6efa2023-07-12 15:27:52 +0200504 * @brief TLS server configuration creation and deletion
505 * @{
roman9b1379c2023-03-31 10:11:10 +0200506 */
roman2e797ef2023-06-19 10:47:49 +0200507
508/**
roman3f9b65c2023-06-05 14:26:58 +0200509 * @brief Creates new YANG configuration data nodes for a server's certificate.
510 *
511 * @param[in] ctx libyang context.
512 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200513 * If an endpoint with this identifier already exists, its server certificate will be changed.
roman6c4efcd2023-08-08 10:18:44 +0200514 * @param[in] privkey_path Path to the server's PEM encoded private key file.
roman3f9b65c2023-06-05 14:26:58 +0200515 * @param[in] pubkey_path Optional path to the server's public key file. If not provided,
516 * it will be generated from the private key.
romane6ec60e2023-10-19 15:21:52 +0200517 * @param[in] cert_path Path to the server's certificate file.
roman3f9b65c2023-06-05 14:26:58 +0200518 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
519 * Otherwise the new YANG data will be added to the previous data and may override it.
520 * @return 0 on success, non-zero otherwise.
521 */
romane6ec60e2023-10-19 15:21:52 +0200522int nc_server_config_add_tls_server_cert(const struct ly_ctx *ctx, const char *endpt_name, const char *privkey_path,
523 const char *pubkey_path, const char *cert_path, struct lyd_node **config);
roman3f9b65c2023-06-05 14:26:58 +0200524
525/**
roman8ba6efa2023-07-12 15:27:52 +0200526 * @brief Deletes the server's certificate from the YANG data.
527 *
528 * @param[in] endpt_name Identifier of an existing endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200529 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200530 * @return 0 on success, non-zero otherwise.
531 */
romane6ec60e2023-10-19 15:21:52 +0200532int nc_server_config_del_tls_server_cert(const char *endpt_name, struct lyd_node **config);
romand348b942023-10-13 14:32:19 +0200533
534/**
535 * @brief Creates new YANG configuration data nodes for a keystore reference to the TLS server's certificate.
536 *
537 * @param[in] ctx libyang context.
538 * @param[in] endpt_name Arbitrary identifier of the endpoint.
539 * If an endpoint with this identifier already exists, its contents will be changed.
540 * @param[in] asym_key_ref Name of the asymmetric key pair in the keystore to be referenced.
541 * @param[in] cert_ref Name of the certificate, which must belong to the given asymmetric key pair, to be referenced.
542 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
543 * Otherwise the new YANG data will be added to the previous data and may override it.
544 * @return 0 on success, non-zero otherwise.
545 */
546int nc_server_config_add_tls_keystore_ref(const struct ly_ctx *ctx, const char *endpt_name, const char *asym_key_ref,
547 const char *cert_ref, struct lyd_node **config);
548
549/**
550 * @brief Deletes a TLS server certificate keystore reference from the YANG data.
551 *
552 * @param[in] endpt_name Identifier of an existing endpoint.
553 * @param[in,out] config Modified configuration YANG data tree.
554 * @return 0 on success, non-zero otherwise.
555 */
556int nc_server_config_del_tls_keystore_ref(const char *endpt_name, struct lyd_node **config);
roman12c3d522023-07-26 13:39:30 +0200557
558/**
roman3f9b65c2023-06-05 14:26:58 +0200559 * @brief Creates new YANG configuration data nodes for a client's (end-entity) certificate.
560 *
561 * @param[in] ctx libyang context.
562 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200563 * If an endpoint with this identifier already exists, its contents will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200564 * @param[in] cert_name Arbitrary identifier of the client's certificate.
roman35120972023-08-08 10:39:12 +0200565 * If a client certificate with this identifier already exists, it will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200566 * @param[in] cert_path Path to the client's certificate file.
567 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
568 * Otherwise the new YANG data will be added to the previous data and may override it.
569 * @return 0 on success, non-zero otherwise.
570 */
romane6ec60e2023-10-19 15:21:52 +0200571int 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 +0200572 const char *cert_path, struct lyd_node **config);
573
574/**
roman8ba6efa2023-07-12 15:27:52 +0200575 * @brief Deletes a client (end-entity) certificate from the YANG data.
576 *
577 * @param[in] endpt_name Identifier of an existing endpoint.
578 * @param[in] cert_name Optional name of a certificate to be deleted.
579 * If NULL, all of the end-entity certificates on the given endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200580 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200581 * @return 0 on success, non-zero otherwise.
582 */
romane6ec60e2023-10-19 15:21:52 +0200583int 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 +0200584
585/**
586 * @brief Creates new YANG configuration data nodes for a truststore reference to a set of client (end-entity) certificates.
587 *
588 * @param[in] ctx libyang context.
589 * @param[in] endpt_name Arbitrary identifier of the endpoint.
590 * If an endpoint with this identifier already exists, its contents will be changed.
591 * @param[in] cert_bag_ref Identifier of the certificate bag in the truststore to be referenced.
592 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
593 * Otherwise the new YANG data will be added to the previous data and may override it.
594 * @return 0 on success, non-zero otherwise.
595 */
596int nc_server_config_add_tls_client_cert_truststore_ref(const struct ly_ctx *ctx, const char *endpt_name,
597 const char *cert_bag_ref, struct lyd_node **config);
598
599/**
600 * @brief Deletes a client (end-entity) certificates truststore reference from the YANG data.
601 *
602 * @param[in] endpt_name Identifier of an existing endpoint.
603 * @param[in,out] config Modified configuration YANG data tree.
604 * @return 0 on success, non-zero otherwise.
605 */
606int nc_server_config_del_tls_client_cert_truststore_ref(const char *endpt_name, struct lyd_node **config);
roman12c3d522023-07-26 13:39:30 +0200607
608/**
roman3f9b65c2023-06-05 14:26:58 +0200609 * @brief Creates new YANG configuration data nodes for a client certificate authority (trust-anchor) certificate.
610 *
611 * @param[in] ctx libyang context.
612 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200613 * If an endpoint with this identifier already exists, its contents will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200614 * @param[in] cert_name Arbitrary identifier of the certificate authority certificate.
roman35120972023-08-08 10:39:12 +0200615 * If a CA with this identifier already exists, it will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200616 * @param[in] cert_path Path to the CA certificate file.
617 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
618 * Otherwise the new YANG data will be added to the previous data and may override it.
619 * @return 0 on success, non-zero otherwise.
620 */
romane6ec60e2023-10-19 15:21:52 +0200621int 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 +0200622 const char *cert_path, struct lyd_node **config);
623
624/**
roman8ba6efa2023-07-12 15:27:52 +0200625 * @brief Deletes a client certificate authority (trust-anchor) certificate from the YANG data.
626 *
627 * @param[in] endpt_name Identifier of an existing endpoint.
628 * @param[in] cert_name Optional name of a certificate to be deleted.
629 * If NULL, all of the CA certificates on the given endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200630 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200631 * @return 0 on success, non-zero otherwise.
632 */
romane6ec60e2023-10-19 15:21:52 +0200633int 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 +0200634
635/**
636 * @brief Creates new YANG configuration data nodes for a truststore reference to a set of client certificate authority (trust-anchor) certificates.
637 *
638 * @param[in] ctx libyang context.
639 * @param[in] endpt_name Arbitrary identifier of the endpoint.
640 * If an endpoint with this identifier already exists, its contents will be changed.
641 * @param[in] cert_bag_ref Identifier of the certificate bag in the truststore to be referenced.
642 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
643 * Otherwise the new YANG data will be added to the previous data and may override it.
644 * @return 0 on success, non-zero otherwise.
645 */
romane6ec60e2023-10-19 15:21:52 +0200646int nc_server_config_add_tls_ca_cert_truststore_ref(const struct ly_ctx *ctx, const char *endpt_name,
romand348b942023-10-13 14:32:19 +0200647 const char *cert_bag_ref, struct lyd_node **config);
648
649/**
650 * @brief Deletes a client certificate authority (trust-anchor) certificates truststore reference from the YANG data.
651 *
652 * @param[in] endpt_name Identifier of an existing endpoint.
653 * @param[in,out] config Modified configuration YANG data tree.
654 * @return 0 on success, non-zero otherwise.
655 */
romane6ec60e2023-10-19 15:21:52 +0200656int nc_server_config_del_tls_ca_cert_truststore_ref(const char *endpt_name, struct lyd_node **config);
roman12c3d522023-07-26 13:39:30 +0200657
658/**
Roytak76958912023-09-29 15:25:14 +0200659 * @brief Creates new YANG configuration data nodes, which will be a reference to another TLS endpoint's certificates.
660 *
661 * Whenever an user tries to connect to the referencing endpoint, all of its certificates will be tried first. If no match is
662 * found, the referenced endpoint's configured certificates will be tried. The same applies to cert-to-name entries.
663 *
664 * @param[in] ctx libyang context
665 * @param[in] endpt_name Arbitrary identifier of the endpoint.
666 * If an endpoint with this identifier already exists, its contents will be changed.
667 * @param[in] referenced_endpt Identifier of an endpoint, which has to exist whenever this data
668 * is applied. The referenced endpoint can reference another one and so on, but there mustn't be a cycle.
669 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
670 * Otherwise the new YANG data will be added to the previous data and may override it.
671 * @return 0 on success, non-zero otherwise.
672 */
Roytakb2794852023-10-18 14:30:22 +0200673int nc_server_config_add_tls_endpoint_client_ref(const struct ly_ctx *ctx, const char *endpt_name,
Roytak76958912023-09-29 15:25:14 +0200674 const char *referenced_endpt, struct lyd_node **config);
675
676/**
677 * @brief Deletes reference to another TLS endpoint's users from the YANG data.
678 *
679 * @param[in] endpt_name Identifier of an existing endpoint.
680 * @param[in,out] config Modified configuration YANG data tree.
681 * @return 0 on success, non-zero otherwise.
682 */
Roytakb2794852023-10-18 14:30:22 +0200683int nc_server_config_del_tls_endpoint_client_ref(const char *endpt_name, struct lyd_node **config);
Roytak76958912023-09-29 15:25:14 +0200684
685/**
roman3f9b65c2023-06-05 14:26:58 +0200686 * @brief Creates new YANG configuration data nodes for a cert-to-name entry.
687 *
688 * @param[in] ctx libyang context.
689 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200690 * If an endpoint with this identifier already exists, its contents will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200691 * @param[in] id ID of the entry. The lower the ID, the higher the priority of the entry (it will be checked earlier).
692 * @param[in] fingerprint Optional fingerprint of the entry. The fingerprint should always be set, however if it is
693 * not set, it will match any certificate. Entry with no fingerprint should therefore be placed only as the last entry.
694 * @param[in] map_type Mapping username to the certificate option.
695 * @param[in] name Username for this cert-to-name entry.
696 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
697 * Otherwise the new YANG data will be added to the previous data and may override it.
698 * @return 0 on success, non-zero otherwise.
699 */
Roytakb2794852023-10-18 14:30:22 +0200700int 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 +0200701 NC_TLS_CTN_MAPTYPE map_type, const char *name, struct lyd_node **config);
702
roman12644fe2023-06-08 11:06:42 +0200703/**
roman8ba6efa2023-07-12 15:27:52 +0200704 * @brief Deletes a cert-to-name entry from the YANG data.
705 *
706 * @param[in] endpt_name Identifier of an existing endpoint.
707 * @param[in] id Optional ID of the CTN entry.
708 * If 0, all of the cert-to-name entries on the given endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200709 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200710 * @return 0 on success, non-zero otherwise.
711 */
Roytakb2794852023-10-18 14:30:22 +0200712int nc_server_config_del_tls_ctn(const char *endpt_name, uint32_t id, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200713
714/**
roman35120972023-08-08 10:39:12 +0200715 * @} TLS Server Configuration
roman8ba6efa2023-07-12 15:27:52 +0200716 */
717
718/**
roman35120972023-08-08 10:39:12 +0200719 * @defgroup server_config_ch Call Home Server Configuration
roman8ba6efa2023-07-12 15:27:52 +0200720 * @ingroup server_config
721 *
Roytak2161df62023-08-02 15:04:42 +0200722 * @brief Call Home server configuration creation and deletion
roman8ba6efa2023-07-12 15:27:52 +0200723 * @{
724 */
725
726/**
roman35120972023-08-08 10:39:12 +0200727 * @} Call Home Server Configuration
728 */
729
730/**
731 * @defgroup server_config_ch_functions Call Home Server Configuration Functions
732 * @ingroup server_config_ch
733 *
734 * @brief Call Home server configuration functions
735 * @{
736 */
737
738/**
Roytak2161df62023-08-02 15:04:42 +0200739 * @brief Creates new YANG configuration data nodes for a Call Home client's address and port.
roman142718b2023-06-29 09:15:29 +0200740 *
741 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200742 * @param[in] client_name Arbitrary identifier of the Call Home client.
743 * If a Call Home client with this identifier already exists, its contents will be changed.
roman142718b2023-06-29 09:15:29 +0200744 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
745 * If the client's endpoint with this identifier already exists, its contents will be changed.
746 * @param[in] transport Transport protocol to be used on this endpoint - either SSH or TLS.
747 * @param[in] address Address to connect to.
748 * @param[in] port Port to connect to.
749 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
750 * Otherwise the new YANG data will be added to the previous data and may override it.
751 * @return 0 on success, non-zero otherwise.
752 */
Roytakb2794852023-10-18 14:30:22 +0200753int 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 +0200754 NC_TRANSPORT_IMPL transport, const char *address, const char *port, struct lyd_node **config);
755
roman8ba6efa2023-07-12 15:27:52 +0200756#endif /* NC_ENABLED_SSH_TLS */
757
758/**
Roytak2161df62023-08-02 15:04:42 +0200759 * @brief Deletes a Call Home client from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +0200760 *
761 * @param[in] client_name Optional identifier of a client to be deleted.
Roytak2161df62023-08-02 15:04:42 +0200762 * If NULL, all of the Call Home clients will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200763 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200764 * @return 0 on success, non-zero otherwise.
765 */
Roytakb2794852023-10-18 14:30:22 +0200766int nc_server_config_del_ch_client(const char *client_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200767
768/**
Roytak2161df62023-08-02 15:04:42 +0200769 * @brief Deletes a Call Home endpoint from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +0200770 *
Roytak2161df62023-08-02 15:04:42 +0200771 * @param[in] client_name Identifier of an existing Call Home client.
roman8ba6efa2023-07-12 15:27:52 +0200772 * @param[in] endpt_name Optional identifier of a CH endpoint to be deleted.
773 * If NULL, all of the CH endpoints which belong to the given client will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200774 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200775 * @return 0 on success, non-zero otherwise.
776 */
Roytakb2794852023-10-18 14:30:22 +0200777int nc_server_config_del_ch_endpt(const char *client_name, const char *endpt_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200778
779/**
Roytak2161df62023-08-02 15:04:42 +0200780 * @brief Creates new YANG configuration data nodes for the Call Home persistent connection type.
roman8ba6efa2023-07-12 15:27:52 +0200781 *
782 * This is the default connection type. If periodic connection type was set before, it will be unset.
783 *
784 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200785 * @param[in] client_name Arbitrary identifier of the Call Home client.
786 * If a Call Home client with this identifier already exists, its contents will be changed.
Roytak9b32c0f2023-08-02 15:07:29 +0200787 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +0200788 * Otherwise the new YANG data will be added to the previous data and may override it.
789 * @return 0 on success, non-zero otherwise.
790 */
Roytakb2794852023-10-18 14:30:22 +0200791int 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 +0200792
793/**
Roytak2161df62023-08-02 15:04:42 +0200794 * @brief Creates new YANG configuration data nodes for the period parameter of the Call Home periodic connection type.
roman8ba6efa2023-07-12 15:27:52 +0200795 *
796 * If called, the persistent connection type will be replaced by periodic.
797 *
798 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200799 * @param[in] client_name Arbitrary identifier of the Call Home client.
800 * If a Call Home client with this identifier already exists, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +0200801 * @param[in] period Duration between periodic connections in minutes.
Roytak9b32c0f2023-08-02 15:07:29 +0200802 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +0200803 * Otherwise the new YANG data will be added to the previous data and may override it.
804 * @return 0 on success, non-zero otherwise.
805 */
Roytakb2794852023-10-18 14:30:22 +0200806int nc_server_config_add_ch_period(const struct ly_ctx *ctx, const char *client_name, uint16_t period,
roman8ba6efa2023-07-12 15:27:52 +0200807 struct lyd_node **config);
808
809/**
Roytak2161df62023-08-02 15:04:42 +0200810 * @brief Deletes the Call Home period parameter of the periodic connection type from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +0200811 *
812 * This behaves the same as setting the period to 60 minutes, which is the default value of this node.
813 *
Roytak2161df62023-08-02 15:04:42 +0200814 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +0200815 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200816 * @return 0 on success, non-zero otherwise.
817 */
Roytakb2794852023-10-18 14:30:22 +0200818int nc_server_config_del_ch_period(const char *client_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200819
820/**
Roytak2161df62023-08-02 15:04:42 +0200821 * @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 +0200822 *
823 * If called, the persistent connection type will be replaced by periodic.
824 *
825 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200826 * @param[in] client_name Arbitrary identifier of the Call Home client.
827 * If a Call Home client with this identifier already exists, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +0200828 * @param[in] anchor_time Timestamp before or after which a series of periodic connections are determined.
Roytak9b32c0f2023-08-02 15:07:29 +0200829 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +0200830 * Otherwise the new YANG data will be added to the previous data and may override it.
831 * @return 0 on success, non-zero otherwise.
832 */
Roytakb2794852023-10-18 14:30:22 +0200833int nc_server_config_add_ch_anchor_time(const struct ly_ctx *ctx, const char *client_name,
roman8ba6efa2023-07-12 15:27:52 +0200834 const char *anchor_time, struct lyd_node **config);
835
836/**
Roytak2161df62023-08-02 15:04:42 +0200837 * @brief Deletes the Call Home anchor time parameter of the periodic connection type from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +0200838 *
Roytak2161df62023-08-02 15:04:42 +0200839 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +0200840 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200841 * @return 0 on success, non-zero otherwise.
842 */
Roytakb2794852023-10-18 14:30:22 +0200843int nc_server_config_del_ch_anchor_time(const char *client_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200844
845/**
Roytak2161df62023-08-02 15:04:42 +0200846 * @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 +0200847 *
848 * If called, the persistent connection type will be replaced by periodic.
849 *
850 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200851 * @param[in] client_name Arbitrary identifier of the Call Home client.
852 * If a Call Home client with this identifier already exists, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +0200853 * @param[in] idle_timeout Specifies the maximum number of seconds that a session may remain idle.
Roytak9b32c0f2023-08-02 15:07:29 +0200854 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +0200855 * Otherwise the new YANG data will be added to the previous data and may override it.
856 * @return 0 on success, non-zero otherwise.
857 */
Roytakb2794852023-10-18 14:30:22 +0200858int nc_server_config_add_ch_idle_timeout(const struct ly_ctx *ctx, const char *client_name,
roman8ba6efa2023-07-12 15:27:52 +0200859 uint16_t idle_timeout, struct lyd_node **config);
860
861/**
Roytak2161df62023-08-02 15:04:42 +0200862 * @brief Deletes the Call Home idle timeout parameter of the periodic connection type from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +0200863 *
864 * This behaves the same as setting the timeout to 180 seconds, which is the default value of this node.
865 *
Roytak2161df62023-08-02 15:04:42 +0200866 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +0200867 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200868 * @return 0 on success, non-zero otherwise.
869 */
Roytakb2794852023-10-18 14:30:22 +0200870int nc_server_config_del_ch_idle_timeout(const char *client_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200871
872/**
Roytak2161df62023-08-02 15:04:42 +0200873 * @brief Creates new YANG configuration data nodes for the Call Home reconnect strategy.
roman8ba6efa2023-07-12 15:27:52 +0200874 *
875 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200876 * @param[in] client_name Arbitrary identifier of the Call Home client.
877 * If a Call Home client with this identifier already exists, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +0200878 * @param[in] start_with Specifies which endpoint to try if a connection is unsuccessful. Default value is NC_CH_FIRST_LISTED.
879 * @param[in] max_wait The number of seconds after which a connection to an endpoint is deemed unsuccessful. Default value if 5.
880 * @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 +0200881 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +0200882 * Otherwise the new YANG data will be added to the previous data and may override it.
883 * @return 0 on success, non-zero otherwise.
884 */
Roytakb2794852023-10-18 14:30:22 +0200885int nc_server_config_add_ch_reconnect_strategy(const struct ly_ctx *ctx, const char *client_name,
roman8ba6efa2023-07-12 15:27:52 +0200886 NC_CH_START_WITH start_with, uint16_t max_wait, uint8_t max_attempts, struct lyd_node **config);
887
888/**
Roytak2161df62023-08-02 15:04:42 +0200889 * @brief Resets the values of the Call Home reconnect strategy nodes to their defaults.
roman8ba6efa2023-07-12 15:27:52 +0200890 *
891 * The default values are: start-with = NC_CH_FIRST_LISTED, max-wait = 5 and max-attempts = 3.
892 *
Roytak2161df62023-08-02 15:04:42 +0200893 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +0200894 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200895 * @return 0 on success, non-zero otherwise.
896 */
Roytakb2794852023-10-18 14:30:22 +0200897int nc_server_config_del_ch_reconnect_strategy(const char *client_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200898
899/**
roman35120972023-08-08 10:39:12 +0200900 * @} Call Home Server Configuration Functions
roman8ba6efa2023-07-12 15:27:52 +0200901 */
902
903#ifdef NC_ENABLED_SSH_TLS
904
905/**
Roytak2161df62023-08-02 15:04:42 +0200906 * @defgroup server_config_ch_ssh SSH Call Home Server Configuration
roman8ba6efa2023-07-12 15:27:52 +0200907 * @ingroup server_config_ch
908 *
Roytak2161df62023-08-02 15:04:42 +0200909 * @brief SSH Call Home server configuration creation and deletion
roman8ba6efa2023-07-12 15:27:52 +0200910 * @{
911 */
912
roman142718b2023-06-29 09:15:29 +0200913/**
Roytak2161df62023-08-02 15:04:42 +0200914 * @brief Creates new YANG data nodes for a Call Home SSH hostkey.
roman142718b2023-06-29 09:15:29 +0200915 *
916 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200917 * @param[in] client_name Arbitrary identifier of the Call Home client.
918 * If a Call Home client with this identifier already exists, its contents will be changed.
roman142718b2023-06-29 09:15:29 +0200919 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
920 * If the client's endpoint with this identifier already exists, its contents will be changed.
921 * @param[in] hostkey_name Arbitrary identifier of the endpoint's hostkey.
922 * If the endpoint's hostkey with this identifier already exists, its contents will be changed.
923 * @param[in] privkey_path Path to a file containing a private key.
924 * The private key has to be in a PEM format. Only RSA and ECDSA keys are supported.
925 * @param[in] pubkey_path Path to a file containing a public key. If NULL, public key will be
926 * generated from the private key.
927 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
928 * Otherwise the new YANG data will be added to the previous data and may override it.
929 * @return 0 on success, non-zero otherwise.
930 */
Roytakb2794852023-10-18 14:30:22 +0200931int 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 +0200932 const char *hostkey_name, const char *privkey_path, const char *pubkey_path, struct lyd_node **config);
933
roman142718b2023-06-29 09:15:29 +0200934/**
Roytak2161df62023-08-02 15:04:42 +0200935 * @brief Deletes a Call Home hostkey from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +0200936 *
Roytak2161df62023-08-02 15:04:42 +0200937 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +0200938 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
roman8ba6efa2023-07-12 15:27:52 +0200939 * @param[in] hostkey_name Optional identifier of a hostkey to be deleted.
940 * If NULL, all of the hostkeys on the given endpoint will be deleted.
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_ssh_hostkey(const char *client_name, const char *endpt_name,
roman9d5e5a52023-07-14 12:43:44 +0200945 const char *hostkey_name, struct lyd_node **config);
946
947/**
romand348b942023-10-13 14:32:19 +0200948 * @brief Creates new YANG data nodes for a reference to an asymmetric key located in the keystore.
949 *
950 * This asymmetric key pair will be used as the Call Home SSH hostkey.
951 *
952 * @param[in] ctx libyang context.
953 * @param[in] client_name Arbitrary identifier of the Call Home client.
954 * If a Call Home client with this identifier already exists, its contents will be changed.
955 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
956 * If the client's endpoint with this identifier already exists, its contents will be changed.
957 * @param[in] hostkey_name Arbitrary identifier of the endpoint's hostkey.
958 * If the endpoint's hostkey with this identifier already exists, its contents will be changed.
959 * @param[in] keystore_reference Name of the asymmetric key pair to be referenced and used as a hostkey.
960 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
961 * Otherwise the new YANG data will be added to the previous data and may override it.
962 * @return 0 on success, non-zero otherwise.
963 */
964int nc_server_config_add_ch_ssh_keystore_ref(const struct ly_ctx *ctx, const char *client_name,
965 const char *endpt_name, const char *hostkey_name, const char *keystore_reference, struct lyd_node **config);
966
967/**
968 * @brief Deletes a Call Home keystore reference from the YANG data.
969 *
970 * @param[in] client_name Identifier of an existing Call Home client.
971 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
972 * @param[in] hostkey_name Identifier of an existing hostkey that belongs to the given CH endpoint.
973 * @param[in,out] config Modified configuration YANG data tree.
974 * @return 0 on success, non-zero otherwise.
975 */
976int nc_server_config_del_ch_ssh_keystore_ref(const char *client_name, const char *endpt_name,
977 const char *hostkey_name, struct lyd_node **config);
978
979/**
Roytak2161df62023-08-02 15:04:42 +0200980 * @brief Creates new YANG data nodes for a Call Home SSH user's public key authentication method.
roman142718b2023-06-29 09:15:29 +0200981 *
982 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200983 * @param[in] client_name Arbitrary identifier of the Call Home client.
984 * If a Call Home client with this identifier already exists, its contents will be changed.
roman142718b2023-06-29 09:15:29 +0200985 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
986 * If the client's endpoint with this identifier already exists, its contents will be changed.
987 * @param[in] user_name Arbitrary identifier of the endpoint's user.
988 * If the endpoint's user with this identifier already exists, its contents will be changed.
989 * @param[in] pubkey_name Arbitrary identifier of the user's public key.
990 * If the user's public key with this identifier already exists, its contents will be changed.
991 * @param[in] pubkey_path Path to a file containing a public key.
992 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
993 * Otherwise the new YANG data will be added to the previous data and may override it.
994 * @return 0 on success, non-zero otherwise.
995 */
Roytakb2794852023-10-18 14:30:22 +0200996int 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 +0200997 const char *user_name, const char *pubkey_name, const char *pubkey_path, struct lyd_node **config);
998
roman142718b2023-06-29 09:15:29 +0200999/**
Roytak2161df62023-08-02 15:04:42 +02001000 * @brief Deletes a Call Home SSH user's public key from the YANG data.
roman142718b2023-06-29 09:15:29 +02001001 *
Roytak2161df62023-08-02 15:04:42 +02001002 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001003 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1004 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
roman8ba6efa2023-07-12 15:27:52 +02001005 * @param[in] pubkey_name Optional identifier of a public key to be deleted.
1006 * If NULL, all of the public keys which belong to the given SSH user will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001007 * @param[in,out] config Modified configuration YANG data tree.
roman142718b2023-06-29 09:15:29 +02001008 * @return 0 on success, non-zero otherwise.
1009 */
Roytakb2794852023-10-18 14:30:22 +02001010int nc_server_config_del_ch_ssh_user_pubkey(const char *client_name, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +02001011 const char *user_name, const char *pubkey_name, struct lyd_node **config);
roman5cbb6532023-06-22 12:53:17 +02001012
roman142718b2023-06-29 09:15:29 +02001013/**
Roytak2161df62023-08-02 15:04:42 +02001014 * @brief Creates new YANG data nodes for a Call Home SSH user's password authentication method.
roman9d5e5a52023-07-14 12:43:44 +02001015 *
1016 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001017 * @param[in] client_name Arbitrary identifier of the Call Home client.
1018 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001019 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1020 * If the client's endpoint with this identifier already exists, its contents will be changed.
1021 * @param[in] user_name Arbitrary identifier of the endpoint's user.
1022 * If the endpoint's user with this identifier already exists, its contents will be changed.
roman35120972023-08-08 10:39:12 +02001023 * @param[in] password Clear-text password to be set for the user. It will be hashed.
roman9d5e5a52023-07-14 12:43:44 +02001024 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1025 * Otherwise the new YANG data will be added to the previous data and may override it.
1026 * @return 0 on success, non-zero otherwise.
1027 */
Roytakb2794852023-10-18 14:30:22 +02001028int 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 +02001029 const char *user_name, const char *password, struct lyd_node **config);
1030
1031/**
Roytak2161df62023-08-02 15:04:42 +02001032 * @brief Deletes a Call Home SSH user's password from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001033 *
Roytak2161df62023-08-02 15:04:42 +02001034 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001035 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1036 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
1037 * @param[in,out] config Modified configuration YANG data tree.
1038 * @return 0 on success, non-zero otherwise.
1039 */
Roytakb2794852023-10-18 14:30:22 +02001040int nc_server_config_del_ch_ssh_user_password(const char *client_name, const char *endpt_name,
roman9d5e5a52023-07-14 12:43:44 +02001041 const char *user_name, struct lyd_node **config);
1042
1043/**
Roytak2161df62023-08-02 15:04:42 +02001044 * @brief Creates new YANG configuration data nodes for a Call Home SSH user's keyboard interactive authentication method.
roman9d5e5a52023-07-14 12:43:44 +02001045 *
roman808f3f62023-11-23 16:01:04 +01001046 * To set the PAM configuration filename, see ::nc_server_ssh_set_pam_conf_filename().
1047 *
roman9d5e5a52023-07-14 12:43:44 +02001048 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001049 * @param[in] client_name Arbitrary identifier of the Call Home client.
1050 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001051 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1052 * If the client's endpoint with this identifier already exists, its contents will be changed.
1053 * @param[in] user_name Arbitrary identifier of the endpoint's user.
1054 * If the endpoint's user with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001055 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1056 * Otherwise the new YANG data will be added to the previous data and may override it.
1057 * @return 0 on success, non-zero otherwise.
1058 */
Roytakb2794852023-10-18 14:30:22 +02001059int 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 +01001060 const char *user_name, struct lyd_node **config);
roman9d5e5a52023-07-14 12:43:44 +02001061
1062/**
Roytak2161df62023-08-02 15:04:42 +02001063 * @brief Deletes a Call Home SSH user's keyboard interactive authentication from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001064 *
Roytak2161df62023-08-02 15:04:42 +02001065 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001066 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1067 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
1068 * @param[in,out] config Modified configuration YANG data tree.
1069 * @return 0 on success, non-zero otherwise.
1070 */
Roytakb2794852023-10-18 14:30:22 +02001071int nc_server_config_del_ch_ssh_user_interactive(const char *client_name, const char *endpt_name,
roman9d5e5a52023-07-14 12:43:44 +02001072 const char *user_name, struct lyd_node **config);
1073
1074/**
Roytak2161df62023-08-02 15:04:42 +02001075 * @brief Deletes a Call Home SSH user from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001076 *
Roytak2161df62023-08-02 15:04:42 +02001077 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001078 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1079 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
1080 * @param[in,out] config Modified configuration YANG data tree.
1081 * @return 0 on success, non-zero otherwise.
1082 */
Roytakb2794852023-10-18 14:30:22 +02001083int nc_server_config_del_ch_ssh_user(const char *client_name, const char *endpt_name,
roman9d5e5a52023-07-14 12:43:44 +02001084 const char *user_name, struct lyd_node **config);
1085
1086/**
romand348b942023-10-13 14:32:19 +02001087 * @brief Creates new YANG data nodes for a reference to a public key bag located in the truststore.
1088 *
1089 * The public key's located in the bag will be used for Call Home SSH client authentication.
1090 *
1091 * @param[in] ctx libyang context.
1092 * @param[in] client_name Arbitrary identifier of the Call Home client.
1093 * If a Call Home client with this identifier already exists, its contents will be changed.
1094 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1095 * If the client's endpoint with this identifier already exists, its contents will be changed.
1096 * @param[in] user_name Arbitrary identifier of the endpoint's user.
1097 * If the endpoint's user with this identifier already exists, its contents will be changed.
1098 * @param[in] truststore_reference Name of the public key bag to be referenced and used for authentication.
1099 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1100 * Otherwise the new YANG data will be added to the previous data and may override it.
1101 * @return 0 on success, non-zero otherwise.
1102 */
1103int nc_server_config_add_ch_ssh_truststore_ref(const struct ly_ctx *ctx, const char *client_name,
1104 const char *endpt_name, const char *user_name, const char *truststore_reference, struct lyd_node **config);
1105
1106/**
1107 * @brief Deletes a Call Home SSH truststore reference from the YANG data.
1108 *
1109 * @param[in] client_name Identifier of an existing Call Home client.
1110 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1111 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
1112 * @param[in,out] config Modified configuration YANG data tree.
1113 * @return 0 on success, non-zero otherwise.
1114 */
1115int nc_server_config_del_ch_ssh_truststore_ref(const char *client_name, const char *endpt_name,
1116 const char *user_name, struct lyd_node **config);
1117
1118/**
roman35120972023-08-08 10:39:12 +02001119 * @} SSH Call Home Server Configuration
roman142718b2023-06-29 09:15:29 +02001120 */
roman142718b2023-06-29 09:15:29 +02001121
1122/**
Roytak2161df62023-08-02 15:04:42 +02001123 * @defgroup server_config_ch_tls TLS Call Home Server Configuration
roman8ba6efa2023-07-12 15:27:52 +02001124 * @ingroup server_config_ch
roman142718b2023-06-29 09:15:29 +02001125 *
Roytak2161df62023-08-02 15:04:42 +02001126 * @brief TLS Call Home server configuration creation and deletion
roman8ba6efa2023-07-12 15:27:52 +02001127 * @{
roman142718b2023-06-29 09:15:29 +02001128 */
roman142718b2023-06-29 09:15:29 +02001129
romanb6f44032023-06-30 15:07:56 +02001130/**
Roytak2161df62023-08-02 15:04:42 +02001131 * @brief Creates new YANG configuration data nodes for a Call Home server's certificate.
romanb6f44032023-06-30 15:07:56 +02001132 *
1133 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001134 * @param[in] client_name Arbitrary identifier of the Call Home client.
1135 * If a Call Home client with this identifier already exists, its contents will be changed.
1136 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1137 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
roman6c4efcd2023-08-08 10:18:44 +02001138 * @param[in] privkey_path Path to the server's PEM encoded private key file.
romanb6f44032023-06-30 15:07:56 +02001139 * @param[in] pubkey_path Optional path to the server's public key file. If not provided,
1140 * it will be generated from the private key.
romane6ec60e2023-10-19 15:21:52 +02001141 * @param[in] cert_path Path to the server's certificate file.
Roytak934edc32023-07-27 12:04:18 +02001142 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
romanb6f44032023-06-30 15:07:56 +02001143 * Otherwise the new YANG data will be added to the previous data and may override it.
1144 * @return 0 on success, non-zero otherwise.
1145 */
romane6ec60e2023-10-19 15:21:52 +02001146int nc_server_config_add_ch_tls_server_cert(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1147 const char *privkey_path, const char *pubkey_path, const char *cert_path, struct lyd_node **config);
romanb6f44032023-06-30 15:07:56 +02001148
1149/**
Roytak2161df62023-08-02 15:04:42 +02001150 * @brief Deletes a Call Home server certificate from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001151 *
Roytak2161df62023-08-02 15:04:42 +02001152 * @param[in] client_name Identifier of an existing Call Home client.
1153 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
roman9d5e5a52023-07-14 12:43:44 +02001154 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001155 * @return 0 on success, non-zero otherwise.
1156 */
romane6ec60e2023-10-19 15:21:52 +02001157int nc_server_config_del_ch_tls_server_cert(const char *client_name, const char *endpt_name,
romand348b942023-10-13 14:32:19 +02001158 struct lyd_node **config);
1159
1160/**
1161 * @brief Creates new YANG configuration data nodes for a keystore reference to the Call Home TLS server's certificate.
1162 *
1163 * @param[in] ctx libyang context.
1164 * @param[in] client_name Arbitrary identifier of the Call Home client.
1165 * If a Call Home client with this identifier already exists, its contents will be changed.
1166 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1167 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
1168 * @param[in] asym_key_ref Name of the asymmetric key pair in the keystore to be referenced.
1169 * @param[in] cert_ref Name of the certificate, which must belong to the given asymmetric key pair, to be referenced.
1170 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1171 * Otherwise the new YANG data will be added to the previous data and may override it.
1172 * @return 0 on success, non-zero otherwise.
1173 */
1174int nc_server_config_add_ch_tls_keystore_ref(const struct ly_ctx *ctx, const char *client_name,
1175 const char *endpt_name, const char *asym_key_ref, const char *cert_ref, struct lyd_node **config);
1176
1177/**
1178 * @brief Deletes a TLS server certificate keystore reference from the YANG data.
1179 *
1180 * @param[in] client_name Identifier of an existing Call Home client.
1181 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
1182 * @param[in,out] config Modified configuration YANG data tree.
1183 * @return 0 on success, non-zero otherwise.
1184 */
1185int nc_server_config_del_ch_tls_keystore_ref(const char *client_name, const char *endpt_name,
Roytak934edc32023-07-27 12:04:18 +02001186 struct lyd_node **config);
1187
1188/**
Roytak2161df62023-08-02 15:04:42 +02001189 * @brief Creates new YANG configuration data nodes for a Call Home client's (end-entity) certificate.
romanb6f44032023-06-30 15:07:56 +02001190 *
1191 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001192 * @param[in] client_name Arbitrary identifier of the Call Home client.
1193 * If a Call Home client with this identifier already exists, its contents will be changed.
1194 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1195 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
1196 * @param[in] cert_name Arbitrary identifier of the Call Home endpoint's end-entity certificate.
1197 * 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 +02001198 * @param[in] cert_path Path to the certificate file.
Roytak934edc32023-07-27 12:04:18 +02001199 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
romanb6f44032023-06-30 15:07:56 +02001200 * Otherwise the new YANG data will be added to the previous data and may override it.
1201 * @return 0 on success, non-zero otherwise.
1202 */
romane6ec60e2023-10-19 15:21:52 +02001203int 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 +02001204 const char *cert_name, const char *cert_path, struct lyd_node **config);
1205
1206/**
Roytak2161df62023-08-02 15:04:42 +02001207 * @brief Deletes a Call Home client (end-entity) certificate from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001208 *
Roytak2161df62023-08-02 15:04:42 +02001209 * @param[in] client_name Identifier of an existing Call Home client.
1210 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
roman8ba6efa2023-07-12 15:27:52 +02001211 * @param[in] cert_name Optional identifier of a client certificate to be deleted.
1212 * If NULL, all of the client certificates will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001213 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001214 * @return 0 on success, non-zero otherwise.
1215 */
romane6ec60e2023-10-19 15:21:52 +02001216int nc_server_config_del_ch_tls_client_cert(const char *client_name, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +02001217 const char *cert_name, struct lyd_node **config);
1218
1219/**
romand348b942023-10-13 14:32:19 +02001220 * @brief Creates new YANG configuration data nodes for a Call Home truststore reference to a set of client (end-entity) certificates.
1221 *
1222 * @param[in] ctx libyang context.
1223 * @param[in] client_name Arbitrary identifier of the Call Home client.
1224 * If a Call Home client with this identifier already exists, its contents will be changed.
1225 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1226 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
1227 * @param[in] cert_bag_ref Identifier of the certificate bag in the truststore to be referenced.
1228 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1229 * Otherwise the new YANG data will be added to the previous data and may override it.
1230 * @return 0 on success, non-zero otherwise.
1231 */
1232int nc_server_config_add_ch_tls_client_cert_truststore_ref(const struct ly_ctx *ctx, const char *client_name,
1233 const char *endpt_name, const char *cert_bag_ref, struct lyd_node **config);
1234
1235/**
1236 * @brief Deletes a Call Home client (end-entity) certificates truststore reference from the YANG data.
1237 *
1238 * @param[in] client_name Identifier of an existing Call Home client.
1239 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
1240 * @param[in,out] config Modified configuration YANG data tree.
1241 * @return 0 on success, non-zero otherwise.
1242 */
1243int nc_server_config_del_ch_tls_client_cert_truststore_ref(const char *client_name, const char *endpt_name,
1244 struct lyd_node **config);
1245
1246/**
romanb6f44032023-06-30 15:07:56 +02001247 * @brief Creates new YANG configuration data nodes for a client certificate authority (trust-anchor) certificate.
1248 *
1249 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001250 * @param[in] client_name Arbitrary identifier of the Call Home client.
1251 * If a Call Home client with this identifier already exists, its contents will be changed.
1252 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1253 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
1254 * @param[in] cert_name Arbitrary identifier of the Call Home endpoint's certificate authority certificate.
1255 * If an Call Home endpoint's CA certificate with this identifier already exists, its contents will be changed.
romanb6f44032023-06-30 15:07:56 +02001256 * @param[in] cert_path Path to the certificate file.
Roytak9b32c0f2023-08-02 15:07:29 +02001257 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
romanb6f44032023-06-30 15:07:56 +02001258 * Otherwise the new YANG data will be added to the previous data and may override it.
1259 * @return 0 on success, non-zero otherwise.
1260 */
romane6ec60e2023-10-19 15:21:52 +02001261int 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 +02001262 const char *cert_name, const char *cert_path, struct lyd_node **config);
1263
1264/**
Roytak2161df62023-08-02 15:04:42 +02001265 * @brief Deletes a Call Home client certificate authority (trust-anchor) certificate from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001266 *
Roytak2161df62023-08-02 15:04:42 +02001267 * @param[in] client_name Identifier of an existing Call Home client.
1268 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
roman8ba6efa2023-07-12 15:27:52 +02001269 * @param[in] cert_name Optional identifier of a CA certificate to be deleted.
1270 * If NULL, all of the CA certificates will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001271 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001272 * @return 0 on success, non-zero otherwise.
1273 */
romane6ec60e2023-10-19 15:21:52 +02001274int nc_server_config_del_ch_tls_ca_cert(const char *client_name, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +02001275 const char *cert_name, struct lyd_node **config);
1276
1277/**
romand348b942023-10-13 14:32:19 +02001278 * @brief Creates new YANG configuration data nodes for a Call Home truststore reference to a set of client certificate authority (trust-anchor) certificates.
1279 *
1280 * @param[in] ctx libyang context.
1281 * @param[in] client_name Arbitrary identifier of the Call Home client.
1282 * If a Call Home client with this identifier already exists, its contents will be changed.
1283 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1284 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
1285 * @param[in] cert_bag_ref Identifier of the certificate bag in the truststore to be referenced.
1286 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1287 * Otherwise the new YANG data will be added to the previous data and may override it.
1288 * @return 0 on success, non-zero otherwise.
1289 */
romane6ec60e2023-10-19 15:21:52 +02001290int 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 +02001291 const char *endpt_name, const char *cert_bag_ref, struct lyd_node **config);
1292
1293/**
1294 * @brief Deletes a Call Home client certificate authority (trust-anchor) certificates truststore reference from the YANG data.
1295 *
1296 * @param[in] client_name Identifier of an existing Call Home client.
1297 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
1298 * @param[in,out] config Modified configuration YANG data tree.
1299 * @return 0 on success, non-zero otherwise.
1300 */
romane6ec60e2023-10-19 15:21:52 +02001301int nc_server_config_del_ch_tls_ca_cert_truststore_ref(const char *client_name, const char *endpt_name,
romand348b942023-10-13 14:32:19 +02001302 struct lyd_node **config);
1303
1304/**
Roytak2161df62023-08-02 15:04:42 +02001305 * @brief Creates new YANG configuration data nodes for a Call Home cert-to-name entry.
romanb6f44032023-06-30 15:07:56 +02001306 *
1307 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001308 * @param[in] client_name Arbitrary identifier of the Call Home client.
1309 * If a Call Home client with this identifier already exists, its contents will be changed.
1310 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1311 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
romanb6f44032023-06-30 15:07:56 +02001312 * @param[in] id ID of the entry. The lower the ID, the higher the priority of the entry (it will be checked earlier).
1313 * @param[in] fingerprint Optional fingerprint of the entry. The fingerprint should always be set, however if it is
1314 * not set, it will match any certificate. Entry with no fingerprint should therefore be placed only as the last entry.
1315 * @param[in] map_type Mapping username to the certificate option.
1316 * @param[in] name Username for this cert-to-name entry.
Roytak9b32c0f2023-08-02 15:07:29 +02001317 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
romanb6f44032023-06-30 15:07:56 +02001318 * Otherwise the new YANG data will be added to the previous data and may override it.
1319 * @return 0 on success, non-zero otherwise.
1320 */
Roytakb2794852023-10-18 14:30:22 +02001321int 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 +02001322 uint32_t id, const char *fingerprint, NC_TLS_CTN_MAPTYPE map_type, const char *name, struct lyd_node **config);
1323
roman8ba6efa2023-07-12 15:27:52 +02001324/**
Roytak2161df62023-08-02 15:04:42 +02001325 * @brief Deletes a Call Home cert-to-name entry from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001326 *
Roytak2161df62023-08-02 15:04:42 +02001327 * @param[in] client_name Identifier of an existing Call Home client.
1328 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
1329 * @param[in] id Optional identifier of the Call Home CTN entry to be deleted.
roman8ba6efa2023-07-12 15:27:52 +02001330 * If 0, all of the CTN entries will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001331 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001332 * @return 0 on success, non-zero otherwise.
1333 */
Roytakb2794852023-10-18 14:30:22 +02001334int nc_server_config_del_ch_tls_ctn(const char *client_name, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +02001335 uint32_t id, struct lyd_node **config);
1336
1337/**
roman35120972023-08-08 10:39:12 +02001338 * @} TLS Call Home Server Configuration
roman8ba6efa2023-07-12 15:27:52 +02001339 */
1340
roman2eab4742023-06-06 10:00:26 +02001341#endif /* NC_ENABLED_SSH_TLS */
roman45cec4e2023-02-17 10:21:39 +01001342
romanc1d2b092023-02-02 08:58:27 +01001343#ifdef __cplusplus
1344}
1345#endif
1346
1347#endif /* NC_SESSION_SERVER_H_ */