blob: e38c086c762e07099e36c1d9731d745e1e9c8d53 [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
romanc1d2b092023-02-02 08:58:27 +010023#include <stdint.h>
24
roman3f9b65c2023-06-05 14:26:58 +020025#include <libyang/libyang.h>
26
romanc1d2b092023-02-02 08:58:27 +010027#include "session.h"
romanc1d2b092023-02-02 08:58:27 +010028
29/**
roman8ba6efa2023-07-12 15:27:52 +020030 * @defgroup server_config Server Configuration
31 * @ingroup server
32 *
33 * @brief Server-side configuration creation and application
34 * @{
35 */
36
37/**
roman35120972023-08-08 10:39:12 +020038 * @} Server Configuration
39 */
40
41/**
42 * @defgroup server_config_functions Server Configuration Functions
43 * @ingroup server_config
44 *
45 * @brief Server-side configuration functions
46 * @{
47 */
48
49/**
50 * @brief Implements all the required modules and their features in the context.
51 * Needs to be called before any other configuration functions.
52 *
53 * If ctx is :
54 * - NULL: a new context will be created and if the call is successful you have to free it,
55 * - non NULL: modules will simply be implemented.
56 *
57 * Implemented modules: ietf-netconf-server, ietf-x509-cert-to-name, ietf-crypto-types,
58 * ietf-tcp-common, ietf-ssh-common, iana-ssh-encryption-algs, iana-ssh-key-exchange-algs,
59 * iana-ssh-mac-algs, iana-ssh-public-key-algs, ietf-keystore, ietf-ssh-server, ietf-truststore,
60 * ietf-tls-server and libnetconf2-netconf-server.
61 *
roman6430c152023-10-12 11:28:47 +020062 * @param[in, out] ctx Optional context in which the modules will be implemented. Created if *ctx is null.
roman35120972023-08-08 10:39:12 +020063 * @return 0 on success, 1 on error.
64 */
65int nc_server_config_load_modules(struct ly_ctx **ctx);
66
67/**
roman6430c152023-10-12 11:28:47 +020068 * @brief Configure server based on the given diff.
romanc1d2b092023-02-02 08:58:27 +010069 *
roman6430c152023-10-12 11:28:47 +020070 * Context must already have implemented the required modules, see ::nc_server_config_load_modules().
romanc1d2b092023-02-02 08:58:27 +010071 *
roman6430c152023-10-12 11:28:47 +020072 * @param[in] diff YANG diff belonging to either ietf-netconf-server, ietf-keystore or ietf-truststore modules.
Roytakb2794852023-10-18 14:30:22 +020073 * The top level node HAS to have an operation (create, replace, delete or none).
romanc1d2b092023-02-02 08:58:27 +010074 * @return 0 on success, 1 on error.
75 */
romanf6f37a52023-05-25 14:27:51 +020076int nc_server_config_setup_diff(const struct lyd_node *diff);
romanc1d2b092023-02-02 08:58:27 +010077
78/**
romanf02273a2023-05-25 09:44:11 +020079 * @brief Configure server based on the given data.
80 *
romanf02273a2023-05-25 09:44:11 +020081 * 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 +020082 * and just the given data will be applied.
roman0f5fa422023-08-07 09:03:24 +020083 * Context must already have implemented the required modules, see ::nc_server_config_load_modules().
romanf02273a2023-05-25 09:44:11 +020084 *
roman6430c152023-10-12 11:28:47 +020085 * @param[in] data YANG data belonging to either ietf-netconf-server, ietf-keystore or ietf-truststore modules.
Roytakb2794852023-10-18 14:30:22 +020086 * This data __must be valid__. No node can have an operation attribute.
romanf02273a2023-05-25 09:44:11 +020087 * @return 0 on success, 1 on error.
88 */
romanf6f37a52023-05-25 14:27:51 +020089int nc_server_config_setup_data(const struct lyd_node *data);
romanf02273a2023-05-25 09:44:11 +020090
91/**
roman6430c152023-10-12 11:28:47 +020092 * @brief Configure server based on the given data stored in a file.
93 *
roman0f5fa422023-08-07 09:03:24 +020094 * Wrapper around ::nc_server_config_setup_data() hiding work with parsing the data.
roman6430c152023-10-12 11:28:47 +020095 * Context must already have implemented the required modules, see ::nc_server_config_load_modules().
romanc1d2b092023-02-02 08:58:27 +010096 *
97 * @param[in] ctx libyang context.
roman6430c152023-10-12 11:28:47 +020098 * @param[in] path Path to a file with ietf-netconf-server, ietf-keystore or ietf-truststore YANG data.
Roytakb2794852023-10-18 14:30:22 +020099 * This data __must be valid__. No node can have an operation attribute.
romanc1d2b092023-02-02 08:58:27 +0100100 * @return 0 on success, 1 on error.
101 */
102int nc_server_config_setup_path(const struct ly_ctx *ctx, const char *path);
103
roman2eab4742023-06-06 10:00:26 +0200104#ifdef NC_ENABLED_SSH_TLS
105
romanc1d2b092023-02-02 08:58:27 +0100106/**
roman6430c152023-10-12 11:28:47 +0200107 * @brief Creates new YANG configuration data nodes for address and port.
roman9b1379c2023-03-31 10:11:10 +0200108 *
roman9b1379c2023-03-31 10:11:10 +0200109 * @param[in] ctx libyang context.
110 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman35120972023-08-08 10:39:12 +0200111 * If an endpoint with this identifier already exists, its contents might be changed.
roman3f9b65c2023-06-05 14:26:58 +0200112 * @param[in] transport Either SSH or TLS transport for the given endpoint.
113 * @param[in] address New listening address.
114 * @param[in] port New listening port.
roman9b1379c2023-03-31 10:11:10 +0200115 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
116 * Otherwise the new YANG data will be added to the previous data and may override it.
117 * @return 0 on success, non-zero otherwise.
roman45cec4e2023-02-17 10:21:39 +0100118 */
Roytakb2794852023-10-18 14:30:22 +0200119int 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 +0200120 const char *address, uint16_t port, struct lyd_node **config);
roman3f9b65c2023-06-05 14:26:58 +0200121
roman8ba6efa2023-07-12 15:27:52 +0200122#endif /* NC_ENABLED_SSH_TLS */
123
124/**
romand0b78372023-09-14 10:06:03 +0200125 * @brief Creates new YANG data nodes for a UNIX socket.
126 *
127 * @param[in] ctx libyang context.
128 * @param[in] endpt_name Arbitrary identifier of the endpoint.
129 * If an endpoint with this identifier already exists, its contents might be changed.
130 * @param[in] path Path to the socket.
131 * @param[in] mode New mode, use -1 for default.
132 * @param[in] uid New uid, use -1 for default
133 * @param[in] gid New gid, use -1 for default
134 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
135 * Otherwise the new YANG data will be added to the previous data and may override it.
136 * @return 0 on success, non-zero otherwise.
137 */
Roytakb2794852023-10-18 14:30:22 +0200138int nc_server_config_add_unix_socket(const struct ly_ctx *ctx, const char *endpt_name, const char *path,
romand0b78372023-09-14 10:06:03 +0200139 mode_t mode, uid_t uid, gid_t gid, struct lyd_node **config);
140
141/**
roman8ba6efa2023-07-12 15:27:52 +0200142 * @brief Deletes an endpoint from the YANG data.
143 *
144 * @param[in] endpt_name Optional identifier of an endpoint to be deleted.
145 * If NULL, all of the endpoints will be deleted.
roman35120972023-08-08 10:39:12 +0200146 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200147 * @return 0 on success, non-zero otherwise.
148 */
Roytakb2794852023-10-18 14:30:22 +0200149int nc_server_config_del_endpt(const char *endpt_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200150
151#ifdef NC_ENABLED_SSH_TLS
152
153/**
154 * @brief Creates new YANG data nodes for an asymmetric key in the keystore.
155 *
156 * @param[in] ctx libyang context.
roman13145912023-08-17 15:36:54 +0200157 * @param[in] ti Transport in which the key pair will be used. Either SSH or TLS.
roman12c3d522023-07-26 13:39:30 +0200158 * @param[in] asym_key_name Identifier of the asymmetric key pair.
159 * This identifier is used to reference the key pair.
roman8ba6efa2023-07-12 15:27:52 +0200160 * @param[in] privkey_path Path to a private key file.
161 * @param[in] pubkey_path Optional path a public key file.
162 * If not supplied, it will be generated from the private key.
163 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
164 * Otherwise the new YANG data will be added to the previous data and may override it.
165 * @return 0 on success, non-zero otherwise.
166 */
Roytakb2794852023-10-18 14:30:22 +0200167int 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 +0200168 const char *privkey_path, const char *pubkey_path, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200169
170/**
171 * @brief Deletes a keystore's asymmetric key from the YANG data.
172 *
roman12c3d522023-07-26 13:39:30 +0200173 * @param[in] asym_key_name Optional identifier of the asymmetric key to be deleted.
roman8ba6efa2023-07-12 15:27:52 +0200174 * If NULL, all of the asymmetric keys in the keystore will be deleted.
175 * @param[in,out] config Configuration YANG data tree.
176 * @return 0 on success, non-zero otherwise.
177 */
Roytakb2794852023-10-18 14:30:22 +0200178int nc_server_config_del_keystore_asym_key(const char *asym_key_name, struct lyd_node **config);
roman12c3d522023-07-26 13:39:30 +0200179
180/**
181 * @brief Creates new YANG data nodes for a certificate in the keystore.
182 *
roman6430c152023-10-12 11:28:47 +0200183 * A certificate can not exist without its asymmetric key, so you must create an asymmetric key
184 * with the same identifier you pass to this function.
roman12c3d522023-07-26 13:39:30 +0200185 *
186 * @param[in] ctx libyang context.
187 * @param[in] asym_key_name Arbitrary identifier of the asymmetric key.
188 * If an asymmetric key pair with this name already exists, its contents will be changed.
189 * @param[in] cert_name Arbitrary identifier of the key pair's certificate.
190 * If a certificate with this name already exists, its contents will be changed.
191 * @param[in] cert_path Path to the PEM encoded certificate file.
192 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
193 * Otherwise the new YANG data will be added to the previous data and may override it.
194 * @return 0 on success, non-zero otherwise.
195 */
Roytakb2794852023-10-18 14:30:22 +0200196int 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 +0200197 const char *cert_path, struct lyd_node **config);
198
199/**
200 * @brief Deletes a keystore's certificate from the YANG data.
201 *
202 * @param[in] asym_key_name Identifier of an existing asymmetric key pair.
203 * @param[in] cert_name Optional identifier of a certificate to be deleted.
204 * If NULL, all of the certificates belonging to the asymmetric key pair will be deleted.
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 */
Roytakb2794852023-10-18 14:30:22 +0200209int 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 +0200210
211/**
212 * @brief Creates new YANG data nodes for a public key in the truststore.
213 *
214 * @param[in] ctx libyang context.
Roytakb2794852023-10-18 14:30:22 +0200215 * @param[in] ti Transport for which this key will be used, to be generated correctly.
roman12c3d522023-07-26 13:39:30 +0200216 * @param[in] pub_bag_name Arbitrary identifier of the public key bag.
roman8ba6efa2023-07-12 15:27:52 +0200217 * This name is used to reference the public keys in the bag.
218 * If a public key bag with this name already exists, its contents will be changed.
219 * @param[in] pubkey_name Arbitrary identifier of the public key.
roman12c3d522023-07-26 13:39:30 +0200220 * If a public key with this name already exists in the given bag, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +0200221 * @param[in] pubkey_path Path to a file containing a public key.
222 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
223 * Otherwise the new YANG data will be added to the previous data and may override it.
224 * @return 0 on success, non-zero otherwise.
225 */
Roytakb2794852023-10-18 14:30:22 +0200226int nc_server_config_add_truststore_pubkey(const struct ly_ctx *ctx, NC_TRANSPORT_IMPL ti,
227 const char *pub_bag_name, const char *pubkey_name, const char *pubkey_path, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200228
229/**
230 * @brief Deletes a truststore's public key from the YANG data.
231 *
roman12c3d522023-07-26 13:39:30 +0200232 * @param[in] pub_bag_name Identifier of an existing public key bag.
roman8ba6efa2023-07-12 15:27:52 +0200233 * @param[in] pubkey_name Optional identifier of a public key to be deleted.
234 * If NULL, all of the public keys in the given bag will be deleted.
235 * @param[in,out] config Configuration YANG data tree.
236 * @return 0 on success, non-zero otherwise.
237 */
Roytakb2794852023-10-18 14:30:22 +0200238int nc_server_config_del_truststore_pubkey(const char *pub_bag_name, const char *pubkey_name, struct lyd_node **config);
roman12c3d522023-07-26 13:39:30 +0200239
240/**
241 * @brief Creates new YANG data nodes for a certificate in the truststore.
242 *
243 * @param[in] ctx libyang context.
244 * @param[in] cert_bag_name Arbitrary identifier of the certificate bag.
245 * This name is used to reference the certificates in the bag.
246 * If a certificate bag with this name already exists, its contents will be changed.
247 * @param[in] cert_name Arbitrary identifier of the certificate.
248 * If a certificate with this name already exists in the given bag, its contents will be changed.
249 * @param[in] cert_path Path to a file containing a PEM encoded certificate.
250 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
251 * Otherwise the new YANG data will be added to the previous data and may override it.
252 * @return 0 on success, non-zero otherwise.
253 */
Roytakb2794852023-10-18 14:30:22 +0200254int nc_server_config_add_truststore_cert(const struct ly_ctx *ctx, const char *cert_bag_name, const char *cert_name,
roman12c3d522023-07-26 13:39:30 +0200255 const char *cert_path, struct lyd_node **config);
256
257/**
258 * @brief Deletes a truststore's certificate from the YANG data.
259 *
260 * @param[in] cert_bag_name Identifier of an existing certificate bag.
261 * @param[in] cert_name Optional identifier of a certificate to be deleted.
262 * If NULL, all of the certificates in the given bag will be deleted.
263 * @param[in,out] config Configuration YANG data tree.
264 * @return 0 on success, non-zero otherwise.
265 */
Roytakb2794852023-10-18 14:30:22 +0200266int nc_server_config_del_truststore_cert(const char *cert_bag_name,
roman12c3d522023-07-26 13:39:30 +0200267 const char *cert_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200268
269/**
roman35120972023-08-08 10:39:12 +0200270 * @} Server Configuration Functions
roman8ba6efa2023-07-12 15:27:52 +0200271 */
272
273/**
274 * @defgroup server_config_ssh SSH Server Configuration
275 * @ingroup server_config
276 *
277 * @brief SSH server configuration creation and deletion
278 * @{
279 */
280
roman3f9b65c2023-06-05 14:26:58 +0200281/**
282 * @brief Creates new YANG configuration data nodes for a hostkey.
283 *
284 * @param[in] ctx libyang context.
285 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200286 * If an endpoint with this identifier already exists, its hostkey might be changed.
roman3f9b65c2023-06-05 14:26:58 +0200287 * @param[in] hostkey_name Arbitrary identifier of the hostkey.
roman142718b2023-06-29 09:15:29 +0200288 * If a hostkey with this identifier already exists, its contents will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200289 * @param[in] privkey_path Path to a file containing a private key.
290 * The private key has to be in a PEM format. Only RSA and ECDSA keys are supported.
roman35120972023-08-08 10:39:12 +0200291 * @param[in] pubkey_path Optional path to a file containing a public key. If NULL, public key will be
roman3f9b65c2023-06-05 14:26:58 +0200292 * generated from the private key.
293 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
294 * Otherwise the new YANG data will be added to the previous data and may override it.
295 * @return 0 on success, non-zero otherwise.
296 */
Roytakb2794852023-10-18 14:30:22 +0200297int nc_server_config_add_ssh_hostkey(const struct ly_ctx *ctx, const char *endpt_name, const char *hostkey_name,
roman8ba6efa2023-07-12 15:27:52 +0200298 const char *privkey_path, const char *pubkey_path, struct lyd_node **config);
299
300/**
301 * @brief Deletes a hostkey from the YANG data.
302 *
303 * @param[in] ctx libyang context.
304 * @param[in] endpt_name Identifier of an existing endpoint.
305 * @param[in] hostkey_name Optional identifier of the hostkey to be deleted.
306 * If NULL, all of the hostkeys on this endpoint will be deleted.
307 * @param[in,out] config Configuration YANG data tree.
308 * @return 0 on success, non-zero otherwise.
309 */
Roytakb2794852023-10-18 14:30:22 +0200310int nc_server_config_del_ssh_hostkey(const struct ly_ctx *ctx, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +0200311 const char *hostkey_name, struct lyd_node **config);
312
313/**
roman68404fd2023-07-24 10:40:59 +0200314 * @brief Creates new YANG configuration data nodes for the maximum amount of failed SSH authentication attempts.
315 *
316 * @param[in] ctx libyang context.
317 * @param[in] endpt_name Arbitrary identifier of the endpoint.
318 * If an endpoint with this identifier already exists, its contents might be changed.
319 * @param[in] auth_attempts Maximum amount of failed SSH authentication attempts after which a
320 * client is disconnected. The default value is 3.
321 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
322 * Otherwise the new YANG data will be added to the previous data and may override it.
323 * @return 0 on success, non-zero otherwise.
324 */
Roytakb2794852023-10-18 14:30:22 +0200325int nc_server_config_add_ssh_auth_attempts(const struct ly_ctx *ctx, const char *endpt_name, uint16_t auth_attempts,
roman68404fd2023-07-24 10:40:59 +0200326 struct lyd_node **config);
327
328/**
329 * @brief Creates new YANG configuration data nodes for an SSH authentication timeout.
330 *
331 * @param[in] ctx libyang context.
332 * @param[in] endpt_name Arbitrary identifier of the endpoint.
333 * If an endpoint with this identifier already exists, its contents might be changed.
334 * @param[in] auth_timeout Maximum amount of time in seconds after which the authentication is deemed
335 * unsuccessful. The default value is 10.
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_auth_timeout(const struct ly_ctx *ctx, const char *endpt_name, uint16_t auth_timeout,
roman68404fd2023-07-24 10:40:59 +0200341 struct lyd_node **config);
342
343/**
roman8ba6efa2023-07-12 15:27:52 +0200344 * @brief Creates new YANG configuration data nodes for an SSH user's public key authentication method.
345 *
346 * @param[in] ctx libyang context.
347 * @param[in] endpt_name Arbitrary identifier of the endpoint.
348 * If an endpoint with this identifier already exists, its user might be changed.
349 * @param[in] user_name Arbitrary identifier of the user.
350 * If an user with this identifier already exists, its contents will be changed.
351 * @param[in] pubkey_name Arbitrary identifier of the user's public key.
352 * If a public key with this identifier already exists for this user, its contents will be changed.
353 * @param[in] pubkey_path Path to a file containing the user's public key.
354 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
355 * Otherwise the new YANG data will be added to the previous data and may override it.
356 * @return 0 on success, non-zero otherwise.
357 */
Roytakb2794852023-10-18 14:30:22 +0200358int nc_server_config_add_ssh_user_pubkey(const struct ly_ctx *ctx, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +0200359 const char *user_name, const char *pubkey_name, const char *pubkey_path, struct lyd_node **config);
360
361/**
362 * @brief Deletes an SSH user's public key from the YANG data.
363 *
364 * @param[in] endpt_name Identifier of an existing endpoint.
365 * @param[in] user_name Identifier of an existing user on the given endpoint.
366 * @param[in] pubkey_name Optional identifier of a public key to be deleted.
367 * If NULL, all of the users public keys will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200368 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200369 * @return 0 on success, non-zero otherwise.
370 */
Roytakb2794852023-10-18 14:30:22 +0200371int nc_server_config_del_ssh_user_pubkey(const char *endpt_name, const char *user_name,
roman8ba6efa2023-07-12 15:27:52 +0200372 const char *pubkey_name, struct lyd_node **config);
373
374/**
375 * @brief Creates new YANG configuration data nodes for an SSH user's password authentication method.
376 *
377 * @param[in] ctx libyang context.
378 * @param[in] endpt_name Arbitrary identifier of the endpoint.
379 * If an endpoint with this identifier already exists, its user might be changed.
380 * @param[in] user_name Arbitrary identifier of the user.
381 * If an user with this identifier already exists, its contents will be changed.
roman35120972023-08-08 10:39:12 +0200382 * @param[in] password Clear-text password to be set for the user. It will be hashed.
roman8ba6efa2023-07-12 15:27:52 +0200383 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
384 * Otherwise the new YANG data will be added to the previous data and may override it.
385 * @return 0 on success, non-zero otherwise.
386 */
Roytakb2794852023-10-18 14:30:22 +0200387int nc_server_config_add_ssh_user_password(const struct ly_ctx *ctx, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +0200388 const char *user_name, const char *password, struct lyd_node **config);
389
390/**
391 * @brief Deletes an SSH user's password from the YANG data.
392 *
393 * @param[in] endpt_name Identifier of an existing endpoint.
394 * @param[in] user_name Identifier of an existing user on the given endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200395 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200396 * @return 0 on success, non-zero otherwise.
397 */
Roytakb2794852023-10-18 14:30:22 +0200398int nc_server_config_del_ssh_user_password(const char *endpt_name, const char *user_name,
roman8ba6efa2023-07-12 15:27:52 +0200399 struct lyd_node **config);
400
401/**
402 * @brief Creates new YANG configuration data nodes for an SSH user's keyboard interactive authentication method.
403 *
404 * @param[in] ctx libyang context.
405 * @param[in] endpt_name Arbitrary identifier of the endpoint.
406 * If an endpoint with this identifier already exists, its user might be changed.
407 * @param[in] user_name Arbitrary identifier of the user.
408 * If an user with this identifier already exists, its contents will be changed.
409 * @param[in] pam_config_name Name of the PAM configuration file.
roman0f5fa422023-08-07 09:03:24 +0200410 * @param[in] pam_config_dir Optional. The absolute path to the directory in which the configuration file
411 * 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 +0200412 * the path. If NULL is passed, then the PAM's system directories will be searched (usually /etc/pam.d/).
413 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
414 * Otherwise the new YANG data will be added to the previous data and may override it.
415 * @return 0 on success, non-zero otherwise.
416 */
Roytakb2794852023-10-18 14:30:22 +0200417int nc_server_config_add_ssh_user_interactive(const struct ly_ctx *ctx, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +0200418 const char *user_name, const char *pam_config_name, const char *pam_config_dir, struct lyd_node **config);
419
420/**
421 * @brief Deletes an SSH user's keyboard interactive authentication from the YANG data.
422 *
423 * @param[in] endpt_name Identifier of an existing endpoint.
424 * @param[in] user_name Identifier of an existing user on the given endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200425 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200426 * @return 0 on success, non-zero otherwise.
427 */
Roytakb2794852023-10-18 14:30:22 +0200428int nc_server_config_del_ssh_user_interactive(const char *endpt_name, const char *user_name,
roman8ba6efa2023-07-12 15:27:52 +0200429 struct lyd_node **config);
430
431/**
432 * @brief Deletes an SSH user from the YANG data.
433 *
434 * @param[in] endpt_name Identifier of an existing endpoint.
435 * @param[in] user_name Optional identifier of an user to be deleted.
436 * If NULL, all of the users on this endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200437 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200438 * @return 0 on success, non-zero otherwise.
439 */
Roytakb2794852023-10-18 14:30:22 +0200440int nc_server_config_del_ssh_user(const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +0200441 const char *user_name, struct lyd_node **config);
442
443/**
roman8ba6efa2023-07-12 15:27:52 +0200444 * @brief Creates new YANG configuration data nodes, which will be a reference to another SSH endpoint's users.
445 *
446 * Whenever a client tries to connect to the referencing endpoint, all of its users will be tried first. If no match is
447 * found, the referenced endpoint's configured users will be tried.
448 *
449 * @param[in] ctx libyang context
450 * @param[in] endpt_name Arbitrary identifier of the endpoint.
451 * If an endpoint with this identifier already exists, its contents will be changed.
452 * @param[in] referenced_endpt Identifier of an endpoint, which has to exist whenever this data
453 * is applied. The referenced endpoint can reference another one and so on, but there mustn't be a cycle.
454 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
455 * Otherwise the new YANG data will be added to the previous data and may override it.
456 * @return 0 on success, non-zero otherwise.
457 */
Roytakb2794852023-10-18 14:30:22 +0200458int nc_server_config_add_ssh_endpoint_client_ref(const struct ly_ctx *ctx, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +0200459 const char *referenced_endpt, struct lyd_node **config);
460
461/**
462 * @brief Deletes reference to another SSH endpoint's users from the YANG data.
463 *
464 * @param[in] endpt_name Identifier of an existing endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200465 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200466 * @return 0 on success, non-zero otherwise.
467 */
Roytakb2794852023-10-18 14:30:22 +0200468int nc_server_config_del_ssh_endpoint_client_ref(const char *endpt_name, struct lyd_node **config);
roman9b1379c2023-03-31 10:11:10 +0200469
470/**
roman35120972023-08-08 10:39:12 +0200471 * @} SSH Server Configuration
roman9b1379c2023-03-31 10:11:10 +0200472 */
roman9b1379c2023-03-31 10:11:10 +0200473
474/**
roman8ba6efa2023-07-12 15:27:52 +0200475 * @defgroup server_config_tls TLS Server Configuration
476 * @ingroup server_config
roman9b1379c2023-03-31 10:11:10 +0200477 *
roman8ba6efa2023-07-12 15:27:52 +0200478 * @brief TLS server configuration creation and deletion
479 * @{
roman9b1379c2023-03-31 10:11:10 +0200480 */
roman2e797ef2023-06-19 10:47:49 +0200481
482/**
roman3f9b65c2023-06-05 14:26:58 +0200483 * @brief Creates new YANG configuration data nodes for a server's certificate.
484 *
485 * @param[in] ctx libyang context.
486 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200487 * If an endpoint with this identifier already exists, its server certificate will be changed.
roman6c4efcd2023-08-08 10:18:44 +0200488 * @param[in] privkey_path Path to the server's PEM encoded private key file.
roman3f9b65c2023-06-05 14:26:58 +0200489 * @param[in] pubkey_path Optional path to the server's public key file. If not provided,
490 * it will be generated from the private key.
roman3f9b65c2023-06-05 14:26:58 +0200491 * @param[in] certificate_path Path to the server's certificate file.
492 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
493 * Otherwise the new YANG data will be added to the previous data and may override it.
494 * @return 0 on success, non-zero otherwise.
495 */
Roytakb2794852023-10-18 14:30:22 +0200496int nc_server_config_add_tls_server_cert(const struct ly_ctx *ctx, const char *endpt_name, const char *privkey_path,
roman6c4efcd2023-08-08 10:18:44 +0200497 const char *pubkey_path, const char *certificate_path, struct lyd_node **config);
roman3f9b65c2023-06-05 14:26:58 +0200498
499/**
roman8ba6efa2023-07-12 15:27:52 +0200500 * @brief Deletes the server's certificate from the YANG data.
501 *
502 * @param[in] endpt_name Identifier of an existing endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200503 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200504 * @return 0 on success, non-zero otherwise.
505 */
Roytakb2794852023-10-18 14:30:22 +0200506int nc_server_config_del_tls_server_cert(const char *endpt_name, struct lyd_node **config);
roman12c3d522023-07-26 13:39:30 +0200507
508/**
roman3f9b65c2023-06-05 14:26:58 +0200509 * @brief Creates new YANG configuration data nodes for a client's (end-entity) 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 contents will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200514 * @param[in] cert_name Arbitrary identifier of the client's certificate.
roman35120972023-08-08 10:39:12 +0200515 * If a client certificate with this identifier already exists, it will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200516 * @param[in] cert_path Path to the client's certificate file.
517 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
518 * Otherwise the new YANG data will be added to the previous data and may override it.
519 * @return 0 on success, non-zero otherwise.
520 */
Roytakb2794852023-10-18 14:30:22 +0200521int 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 +0200522 const char *cert_path, struct lyd_node **config);
523
524/**
roman8ba6efa2023-07-12 15:27:52 +0200525 * @brief Deletes a client (end-entity) certificate from the YANG data.
526 *
527 * @param[in] endpt_name Identifier of an existing endpoint.
528 * @param[in] cert_name Optional name of a certificate to be deleted.
529 * If NULL, all of the end-entity certificates on the given endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200530 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200531 * @return 0 on success, non-zero otherwise.
532 */
Roytakb2794852023-10-18 14:30:22 +0200533int nc_server_config_del_tls_client_cert(const char *endpt_name, const char *cert_name, struct lyd_node **config);
roman12c3d522023-07-26 13:39:30 +0200534
535/**
roman3f9b65c2023-06-05 14:26:58 +0200536 * @brief Creates new YANG configuration data nodes for a client certificate authority (trust-anchor) certificate.
537 *
538 * @param[in] ctx libyang context.
539 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200540 * If an endpoint with this identifier already exists, its contents will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200541 * @param[in] cert_name Arbitrary identifier of the certificate authority certificate.
roman35120972023-08-08 10:39:12 +0200542 * If a CA with this identifier already exists, it will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200543 * @param[in] cert_path Path to the CA certificate file.
544 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
545 * Otherwise the new YANG data will be added to the previous data and may override it.
546 * @return 0 on success, non-zero otherwise.
547 */
Roytakb2794852023-10-18 14:30:22 +0200548int 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 +0200549 const char *cert_path, struct lyd_node **config);
550
551/**
roman8ba6efa2023-07-12 15:27:52 +0200552 * @brief Deletes a client certificate authority (trust-anchor) certificate from the YANG data.
553 *
554 * @param[in] endpt_name Identifier of an existing endpoint.
555 * @param[in] cert_name Optional name of a certificate to be deleted.
556 * If NULL, all of the CA certificates on the given endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200557 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200558 * @return 0 on success, non-zero otherwise.
559 */
Roytakb2794852023-10-18 14:30:22 +0200560int nc_server_config_del_tls_ca_cert(const char *endpt_name, const char *cert_name, struct lyd_node **config);
roman12c3d522023-07-26 13:39:30 +0200561
562/**
Roytak76958912023-09-29 15:25:14 +0200563 * @brief Creates new YANG configuration data nodes, which will be a reference to another TLS endpoint's certificates.
564 *
565 * Whenever an user tries to connect to the referencing endpoint, all of its certificates will be tried first. If no match is
566 * found, the referenced endpoint's configured certificates will be tried. The same applies to cert-to-name entries.
567 *
568 * @param[in] ctx libyang context
569 * @param[in] endpt_name Arbitrary identifier of the endpoint.
570 * If an endpoint with this identifier already exists, its contents will be changed.
571 * @param[in] referenced_endpt Identifier of an endpoint, which has to exist whenever this data
572 * is applied. The referenced endpoint can reference another one and so on, but there mustn't be a cycle.
573 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
574 * Otherwise the new YANG data will be added to the previous data and may override it.
575 * @return 0 on success, non-zero otherwise.
576 */
Roytakb2794852023-10-18 14:30:22 +0200577int nc_server_config_add_tls_endpoint_client_ref(const struct ly_ctx *ctx, const char *endpt_name,
Roytak76958912023-09-29 15:25:14 +0200578 const char *referenced_endpt, struct lyd_node **config);
579
580/**
581 * @brief Deletes reference to another TLS endpoint's users from the YANG data.
582 *
583 * @param[in] endpt_name Identifier of an existing endpoint.
584 * @param[in,out] config Modified configuration YANG data tree.
585 * @return 0 on success, non-zero otherwise.
586 */
Roytakb2794852023-10-18 14:30:22 +0200587int nc_server_config_del_tls_endpoint_client_ref(const char *endpt_name, struct lyd_node **config);
Roytak76958912023-09-29 15:25:14 +0200588
589/**
roman3f9b65c2023-06-05 14:26:58 +0200590 * @brief Creates new YANG configuration data nodes for a cert-to-name entry.
591 *
592 * @param[in] ctx libyang context.
593 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200594 * If an endpoint with this identifier already exists, its contents will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200595 * @param[in] id ID of the entry. The lower the ID, the higher the priority of the entry (it will be checked earlier).
596 * @param[in] fingerprint Optional fingerprint of the entry. The fingerprint should always be set, however if it is
597 * not set, it will match any certificate. Entry with no fingerprint should therefore be placed only as the last entry.
598 * @param[in] map_type Mapping username to the certificate option.
599 * @param[in] name Username for this cert-to-name entry.
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 */
Roytakb2794852023-10-18 14:30:22 +0200604int 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 +0200605 NC_TLS_CTN_MAPTYPE map_type, const char *name, struct lyd_node **config);
606
roman12644fe2023-06-08 11:06:42 +0200607/**
roman8ba6efa2023-07-12 15:27:52 +0200608 * @brief Deletes a cert-to-name entry from the YANG data.
609 *
610 * @param[in] endpt_name Identifier of an existing endpoint.
611 * @param[in] id Optional ID of the CTN entry.
612 * If 0, all of the cert-to-name entries 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 */
Roytakb2794852023-10-18 14:30:22 +0200616int nc_server_config_del_tls_ctn(const char *endpt_name, uint32_t id, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200617
618/**
roman35120972023-08-08 10:39:12 +0200619 * @} TLS Server Configuration
roman8ba6efa2023-07-12 15:27:52 +0200620 */
621
622/**
roman35120972023-08-08 10:39:12 +0200623 * @defgroup server_config_ch Call Home Server Configuration
roman8ba6efa2023-07-12 15:27:52 +0200624 * @ingroup server_config
625 *
Roytak2161df62023-08-02 15:04:42 +0200626 * @brief Call Home server configuration creation and deletion
roman8ba6efa2023-07-12 15:27:52 +0200627 * @{
628 */
629
630/**
roman35120972023-08-08 10:39:12 +0200631 * @} Call Home Server Configuration
632 */
633
634/**
635 * @defgroup server_config_ch_functions Call Home Server Configuration Functions
636 * @ingroup server_config_ch
637 *
638 * @brief Call Home server configuration functions
639 * @{
640 */
641
642/**
Roytak2161df62023-08-02 15:04:42 +0200643 * @brief Creates new YANG configuration data nodes for a Call Home client's address and port.
roman142718b2023-06-29 09:15:29 +0200644 *
645 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200646 * @param[in] client_name Arbitrary identifier of the Call Home client.
647 * If a Call Home client with this identifier already exists, its contents will be changed.
roman142718b2023-06-29 09:15:29 +0200648 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
649 * If the client's endpoint with this identifier already exists, its contents will be changed.
650 * @param[in] transport Transport protocol to be used on this endpoint - either SSH or TLS.
651 * @param[in] address Address to connect to.
652 * @param[in] port Port to connect to.
653 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
654 * Otherwise the new YANG data will be added to the previous data and may override it.
655 * @return 0 on success, non-zero otherwise.
656 */
Roytakb2794852023-10-18 14:30:22 +0200657int 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 +0200658 NC_TRANSPORT_IMPL transport, const char *address, const char *port, struct lyd_node **config);
659
roman8ba6efa2023-07-12 15:27:52 +0200660#endif /* NC_ENABLED_SSH_TLS */
661
662/**
Roytak2161df62023-08-02 15:04:42 +0200663 * @brief Deletes a Call Home client from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +0200664 *
665 * @param[in] client_name Optional identifier of a client to be deleted.
Roytak2161df62023-08-02 15:04:42 +0200666 * If NULL, all of the Call Home clients will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200667 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200668 * @return 0 on success, non-zero otherwise.
669 */
Roytakb2794852023-10-18 14:30:22 +0200670int nc_server_config_del_ch_client(const char *client_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200671
672/**
Roytak2161df62023-08-02 15:04:42 +0200673 * @brief Deletes a Call Home endpoint from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +0200674 *
Roytak2161df62023-08-02 15:04:42 +0200675 * @param[in] client_name Identifier of an existing Call Home client.
roman8ba6efa2023-07-12 15:27:52 +0200676 * @param[in] endpt_name Optional identifier of a CH endpoint to be deleted.
677 * If NULL, all of the CH endpoints which belong to the given client will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200678 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200679 * @return 0 on success, non-zero otherwise.
680 */
Roytakb2794852023-10-18 14:30:22 +0200681int nc_server_config_del_ch_endpt(const char *client_name, const char *endpt_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200682
683/**
Roytak2161df62023-08-02 15:04:42 +0200684 * @brief Creates new YANG configuration data nodes for the Call Home persistent connection type.
roman8ba6efa2023-07-12 15:27:52 +0200685 *
686 * This is the default connection type. If periodic connection type was set before, it will be unset.
687 *
688 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200689 * @param[in] client_name Arbitrary identifier of the Call Home client.
690 * If a Call Home client with this identifier already exists, its contents will be changed.
Roytak9b32c0f2023-08-02 15:07:29 +0200691 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +0200692 * Otherwise the new YANG data will be added to the previous data and may override it.
693 * @return 0 on success, non-zero otherwise.
694 */
Roytakb2794852023-10-18 14:30:22 +0200695int 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 +0200696
697/**
Roytak2161df62023-08-02 15:04:42 +0200698 * @brief Creates new YANG configuration data nodes for the period parameter of the Call Home periodic connection type.
roman8ba6efa2023-07-12 15:27:52 +0200699 *
700 * If called, the persistent connection type will be replaced by periodic.
701 *
702 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200703 * @param[in] client_name Arbitrary identifier of the Call Home client.
704 * If a Call Home client with this identifier already exists, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +0200705 * @param[in] period Duration between periodic connections in minutes.
Roytak9b32c0f2023-08-02 15:07:29 +0200706 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +0200707 * Otherwise the new YANG data will be added to the previous data and may override it.
708 * @return 0 on success, non-zero otherwise.
709 */
Roytakb2794852023-10-18 14:30:22 +0200710int nc_server_config_add_ch_period(const struct ly_ctx *ctx, const char *client_name, uint16_t period,
roman8ba6efa2023-07-12 15:27:52 +0200711 struct lyd_node **config);
712
713/**
Roytak2161df62023-08-02 15:04:42 +0200714 * @brief Deletes the Call Home period parameter of the periodic connection type from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +0200715 *
716 * This behaves the same as setting the period to 60 minutes, which is the default value of this node.
717 *
Roytak2161df62023-08-02 15:04:42 +0200718 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +0200719 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200720 * @return 0 on success, non-zero otherwise.
721 */
Roytakb2794852023-10-18 14:30:22 +0200722int nc_server_config_del_ch_period(const char *client_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200723
724/**
Roytak2161df62023-08-02 15:04:42 +0200725 * @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 +0200726 *
727 * If called, the persistent connection type will be replaced by periodic.
728 *
729 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200730 * @param[in] client_name Arbitrary identifier of the Call Home client.
731 * If a Call Home client with this identifier already exists, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +0200732 * @param[in] anchor_time Timestamp before or after which a series of periodic connections are determined.
Roytak9b32c0f2023-08-02 15:07:29 +0200733 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +0200734 * Otherwise the new YANG data will be added to the previous data and may override it.
735 * @return 0 on success, non-zero otherwise.
736 */
Roytakb2794852023-10-18 14:30:22 +0200737int nc_server_config_add_ch_anchor_time(const struct ly_ctx *ctx, const char *client_name,
roman8ba6efa2023-07-12 15:27:52 +0200738 const char *anchor_time, struct lyd_node **config);
739
740/**
Roytak2161df62023-08-02 15:04:42 +0200741 * @brief Deletes the Call Home anchor time parameter of the periodic connection type from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +0200742 *
Roytak2161df62023-08-02 15:04:42 +0200743 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +0200744 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200745 * @return 0 on success, non-zero otherwise.
746 */
Roytakb2794852023-10-18 14:30:22 +0200747int nc_server_config_del_ch_anchor_time(const char *client_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200748
749/**
Roytak2161df62023-08-02 15:04:42 +0200750 * @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 +0200751 *
752 * If called, the persistent connection type will be replaced by periodic.
753 *
754 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200755 * @param[in] client_name Arbitrary identifier of the Call Home client.
756 * If a Call Home client with this identifier already exists, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +0200757 * @param[in] idle_timeout Specifies the maximum number of seconds that a session may remain idle.
Roytak9b32c0f2023-08-02 15:07:29 +0200758 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +0200759 * Otherwise the new YANG data will be added to the previous data and may override it.
760 * @return 0 on success, non-zero otherwise.
761 */
Roytakb2794852023-10-18 14:30:22 +0200762int nc_server_config_add_ch_idle_timeout(const struct ly_ctx *ctx, const char *client_name,
roman8ba6efa2023-07-12 15:27:52 +0200763 uint16_t idle_timeout, struct lyd_node **config);
764
765/**
Roytak2161df62023-08-02 15:04:42 +0200766 * @brief Deletes the Call Home idle timeout parameter of the periodic connection type from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +0200767 *
768 * This behaves the same as setting the timeout to 180 seconds, which is the default value of this node.
769 *
Roytak2161df62023-08-02 15:04:42 +0200770 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +0200771 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200772 * @return 0 on success, non-zero otherwise.
773 */
Roytakb2794852023-10-18 14:30:22 +0200774int nc_server_config_del_ch_idle_timeout(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 Call Home reconnect strategy.
roman8ba6efa2023-07-12 15:27:52 +0200778 *
779 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200780 * @param[in] client_name Arbitrary identifier of the Call Home client.
781 * If a Call Home client with this identifier already exists, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +0200782 * @param[in] start_with Specifies which endpoint to try if a connection is unsuccessful. Default value is NC_CH_FIRST_LISTED.
783 * @param[in] max_wait The number of seconds after which a connection to an endpoint is deemed unsuccessful. Default value if 5.
784 * @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 +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_reconnect_strategy(const struct ly_ctx *ctx, const char *client_name,
roman8ba6efa2023-07-12 15:27:52 +0200790 NC_CH_START_WITH start_with, uint16_t max_wait, uint8_t max_attempts, struct lyd_node **config);
791
792/**
Roytak2161df62023-08-02 15:04:42 +0200793 * @brief Resets the values of the Call Home reconnect strategy nodes to their defaults.
roman8ba6efa2023-07-12 15:27:52 +0200794 *
795 * The default values are: start-with = NC_CH_FIRST_LISTED, max-wait = 5 and max-attempts = 3.
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_reconnect_strategy(const char *client_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200802
803/**
roman35120972023-08-08 10:39:12 +0200804 * @} Call Home Server Configuration Functions
roman8ba6efa2023-07-12 15:27:52 +0200805 */
806
807#ifdef NC_ENABLED_SSH_TLS
808
809/**
Roytak2161df62023-08-02 15:04:42 +0200810 * @defgroup server_config_ch_ssh SSH Call Home Server Configuration
roman8ba6efa2023-07-12 15:27:52 +0200811 * @ingroup server_config_ch
812 *
Roytak2161df62023-08-02 15:04:42 +0200813 * @brief SSH Call Home server configuration creation and deletion
roman8ba6efa2023-07-12 15:27:52 +0200814 * @{
815 */
816
roman142718b2023-06-29 09:15:29 +0200817/**
Roytak2161df62023-08-02 15:04:42 +0200818 * @brief Creates new YANG data nodes for a Call Home SSH hostkey.
roman142718b2023-06-29 09:15:29 +0200819 *
820 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200821 * @param[in] client_name Arbitrary identifier of the Call Home client.
822 * If a Call Home client with this identifier already exists, its contents will be changed.
roman142718b2023-06-29 09:15:29 +0200823 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
824 * If the client's endpoint with this identifier already exists, its contents will be changed.
825 * @param[in] hostkey_name Arbitrary identifier of the endpoint's hostkey.
826 * If the endpoint's hostkey with this identifier already exists, its contents will be changed.
827 * @param[in] privkey_path Path to a file containing a private key.
828 * The private key has to be in a PEM format. Only RSA and ECDSA keys are supported.
829 * @param[in] pubkey_path Path to a file containing a public key. If NULL, public key will be
830 * generated from the private key.
831 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
832 * Otherwise the new YANG data will be added to the previous data and may override it.
833 * @return 0 on success, non-zero otherwise.
834 */
Roytakb2794852023-10-18 14:30:22 +0200835int nc_server_config_add_ch_ssh_hostkey(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
roman5cbb6532023-06-22 12:53:17 +0200836 const char *hostkey_name, const char *privkey_path, const char *pubkey_path, struct lyd_node **config);
837
roman142718b2023-06-29 09:15:29 +0200838/**
Roytak2161df62023-08-02 15:04:42 +0200839 * @brief Deletes a Call Home hostkey from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +0200840 *
Roytak2161df62023-08-02 15:04:42 +0200841 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +0200842 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
roman8ba6efa2023-07-12 15:27:52 +0200843 * @param[in] hostkey_name Optional identifier of a hostkey to be deleted.
844 * If NULL, all of the hostkeys on the given endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200845 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200846 * @return 0 on success, non-zero otherwise.
847 */
Roytakb2794852023-10-18 14:30:22 +0200848int nc_server_config_del_ch_ssh_hostkey(const char *client_name, const char *endpt_name,
roman9d5e5a52023-07-14 12:43:44 +0200849 const char *hostkey_name, struct lyd_node **config);
850
851/**
Roytak2161df62023-08-02 15:04:42 +0200852 * @brief Creates new YANG configuration data nodes for the maximum amount of failed Call Home SSH authentication attempts.
roman68404fd2023-07-24 10:40:59 +0200853 *
854 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200855 * @param[in] client_name Arbitrary identifier of the Call Home client.
856 * If a Call Home client with this identifier already exists, its contents will be changed.
roman68404fd2023-07-24 10:40:59 +0200857 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
858 * If the client's endpoint with this identifier already exists, its contents will be changed.
859 * @param[in] auth_attempts Maximum amount of failed SSH authentication attempts after which a
860 * client is disconnected. The default value is 3.
861 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
862 * Otherwise the new YANG data will be added to the previous data and may override it.
863 * @return 0 on success, non-zero otherwise.
864 */
Roytakb2794852023-10-18 14:30:22 +0200865int nc_server_config_add_ch_ssh_auth_attempts(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
roman68404fd2023-07-24 10:40:59 +0200866 uint16_t auth_attempts, struct lyd_node **config);
867
868/**
Roytak2161df62023-08-02 15:04:42 +0200869 * @brief Creates new YANG configuration data nodes for a Call Home SSH authentication timeout.
roman68404fd2023-07-24 10:40:59 +0200870 *
871 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200872 * @param[in] client_name Arbitrary identifier of the Call Home client.
873 * If a Call Home client with this identifier already exists, its contents will be changed.
roman68404fd2023-07-24 10:40:59 +0200874 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
875 * If the client's endpoint with this identifier already exists, its contents will be changed.
876 * @param[in] auth_timeout Maximum amount of time in seconds after which the authentication is deemed
877 * unsuccessful. The default value is 10.
878 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
879 * Otherwise the new YANG data will be added to the previous data and may override it.
880 * @return 0 on success, non-zero otherwise.
881 */
Roytakb2794852023-10-18 14:30:22 +0200882int nc_server_config_add_ch_ssh_auth_timeout(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
roman68404fd2023-07-24 10:40:59 +0200883 uint16_t auth_timeout, struct lyd_node **config);
884
885/**
Roytak2161df62023-08-02 15:04:42 +0200886 * @brief Creates new YANG data nodes for a Call Home SSH user's public key authentication method.
roman142718b2023-06-29 09:15:29 +0200887 *
888 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200889 * @param[in] client_name Arbitrary identifier of the Call Home client.
890 * If a Call Home client with this identifier already exists, its contents will be changed.
roman142718b2023-06-29 09:15:29 +0200891 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
892 * If the client's endpoint with this identifier already exists, its contents will be changed.
893 * @param[in] user_name Arbitrary identifier of the endpoint's user.
894 * If the endpoint's user with this identifier already exists, its contents will be changed.
895 * @param[in] pubkey_name Arbitrary identifier of the user's public key.
896 * If the user's public key with this identifier already exists, its contents will be changed.
897 * @param[in] pubkey_path Path to a file containing a public key.
898 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
899 * Otherwise the new YANG data will be added to the previous data and may override it.
900 * @return 0 on success, non-zero otherwise.
901 */
Roytakb2794852023-10-18 14:30:22 +0200902int 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 +0200903 const char *user_name, const char *pubkey_name, const char *pubkey_path, struct lyd_node **config);
904
roman142718b2023-06-29 09:15:29 +0200905/**
Roytak2161df62023-08-02 15:04:42 +0200906 * @brief Deletes a Call Home SSH user's public key from the YANG data.
roman142718b2023-06-29 09:15:29 +0200907 *
Roytak2161df62023-08-02 15:04:42 +0200908 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +0200909 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
910 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
roman8ba6efa2023-07-12 15:27:52 +0200911 * @param[in] pubkey_name Optional identifier of a public key to be deleted.
912 * If NULL, all of the public keys which belong to the given SSH user will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200913 * @param[in,out] config Modified configuration YANG data tree.
roman142718b2023-06-29 09:15:29 +0200914 * @return 0 on success, non-zero otherwise.
915 */
Roytakb2794852023-10-18 14:30:22 +0200916int nc_server_config_del_ch_ssh_user_pubkey(const char *client_name, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +0200917 const char *user_name, const char *pubkey_name, struct lyd_node **config);
roman5cbb6532023-06-22 12:53:17 +0200918
roman142718b2023-06-29 09:15:29 +0200919/**
Roytak2161df62023-08-02 15:04:42 +0200920 * @brief Creates new YANG data nodes for a Call Home SSH user's password authentication method.
roman9d5e5a52023-07-14 12:43:44 +0200921 *
922 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200923 * @param[in] client_name Arbitrary identifier of the Call Home client.
924 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +0200925 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
926 * If the client's endpoint with this identifier already exists, its contents will be changed.
927 * @param[in] user_name Arbitrary identifier of the endpoint's user.
928 * If the endpoint's user with this identifier already exists, its contents will be changed.
roman35120972023-08-08 10:39:12 +0200929 * @param[in] password Clear-text password to be set for the user. It will be hashed.
roman9d5e5a52023-07-14 12:43:44 +0200930 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
931 * Otherwise the new YANG data will be added to the previous data and may override it.
932 * @return 0 on success, non-zero otherwise.
933 */
Roytakb2794852023-10-18 14:30:22 +0200934int 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 +0200935 const char *user_name, const char *password, struct lyd_node **config);
936
937/**
Roytak2161df62023-08-02 15:04:42 +0200938 * @brief Deletes a Call Home SSH user's password from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +0200939 *
Roytak2161df62023-08-02 15:04:42 +0200940 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +0200941 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
942 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
943 * @param[in,out] config Modified configuration YANG data tree.
944 * @return 0 on success, non-zero otherwise.
945 */
Roytakb2794852023-10-18 14:30:22 +0200946int nc_server_config_del_ch_ssh_user_password(const char *client_name, const char *endpt_name,
roman9d5e5a52023-07-14 12:43:44 +0200947 const char *user_name, struct lyd_node **config);
948
949/**
Roytak2161df62023-08-02 15:04:42 +0200950 * @brief Creates new YANG configuration data nodes for a Call Home SSH user's keyboard interactive authentication method.
roman9d5e5a52023-07-14 12:43:44 +0200951 *
952 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +0200953 * @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.
roman9d5e5a52023-07-14 12:43:44 +0200955 * @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] user_name Arbitrary identifier of the endpoint's user.
958 * If the endpoint's user with this identifier already exists, its contents will be changed.
959 * @param[in] pam_config_name Name of the PAM configuration file.
roman0f5fa422023-08-07 09:03:24 +0200960 * @param[in] pam_config_dir Optional. The absolute path to the directory in which the configuration file
961 * with the name pam_config_name is located. A newer version (>= 1.4) of PAM library is required to be able to specify
roman9d5e5a52023-07-14 12:43:44 +0200962 * the path. If NULL is passed, then the PAM's system directories will be searched (usually /etc/pam.d/).
963 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
964 * Otherwise the new YANG data will be added to the previous data and may override it.
965 * @return 0 on success, non-zero otherwise.
966 */
Roytakb2794852023-10-18 14:30:22 +0200967int nc_server_config_add_ch_ssh_user_interactive(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
roman9d5e5a52023-07-14 12:43:44 +0200968 const char *user_name, const char *pam_config_name, const char *pam_config_dir, struct lyd_node **config);
969
970/**
Roytak2161df62023-08-02 15:04:42 +0200971 * @brief Deletes a Call Home SSH user's keyboard interactive authentication from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +0200972 *
Roytak2161df62023-08-02 15:04:42 +0200973 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +0200974 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
975 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
976 * @param[in,out] config Modified configuration YANG data tree.
977 * @return 0 on success, non-zero otherwise.
978 */
Roytakb2794852023-10-18 14:30:22 +0200979int nc_server_config_del_ch_ssh_user_interactive(const char *client_name, const char *endpt_name,
roman9d5e5a52023-07-14 12:43:44 +0200980 const char *user_name, struct lyd_node **config);
981
982/**
Roytak2161df62023-08-02 15:04:42 +0200983 * @brief Deletes a Call Home SSH user from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +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.
988 * @param[in,out] config Modified configuration YANG data tree.
989 * @return 0 on success, non-zero otherwise.
990 */
Roytakb2794852023-10-18 14:30:22 +0200991int nc_server_config_del_ch_ssh_user(const char *client_name, const char *endpt_name,
roman9d5e5a52023-07-14 12:43:44 +0200992 const char *user_name, struct lyd_node **config);
993
994/**
roman35120972023-08-08 10:39:12 +0200995 * @} SSH Call Home Server Configuration
roman142718b2023-06-29 09:15:29 +0200996 */
roman142718b2023-06-29 09:15:29 +0200997
998/**
Roytak2161df62023-08-02 15:04:42 +0200999 * @defgroup server_config_ch_tls TLS Call Home Server Configuration
roman8ba6efa2023-07-12 15:27:52 +02001000 * @ingroup server_config_ch
roman142718b2023-06-29 09:15:29 +02001001 *
Roytak2161df62023-08-02 15:04:42 +02001002 * @brief TLS Call Home server configuration creation and deletion
roman8ba6efa2023-07-12 15:27:52 +02001003 * @{
roman142718b2023-06-29 09:15:29 +02001004 */
roman142718b2023-06-29 09:15:29 +02001005
romanb6f44032023-06-30 15:07:56 +02001006/**
Roytak2161df62023-08-02 15:04:42 +02001007 * @brief Creates new YANG configuration data nodes for a Call Home server's certificate.
romanb6f44032023-06-30 15:07:56 +02001008 *
1009 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001010 * @param[in] client_name Arbitrary identifier of the Call Home client.
1011 * If a Call Home client with this identifier already exists, its contents will be changed.
1012 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1013 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
roman6c4efcd2023-08-08 10:18:44 +02001014 * @param[in] privkey_path Path to the server's PEM encoded private key file.
romanb6f44032023-06-30 15:07:56 +02001015 * @param[in] pubkey_path Optional path to the server's public key file. If not provided,
1016 * it will be generated from the private key.
romanb6f44032023-06-30 15:07:56 +02001017 * @param[in] certificate_path Path to the server's certificate file.
Roytak934edc32023-07-27 12:04:18 +02001018 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
romanb6f44032023-06-30 15:07:56 +02001019 * Otherwise the new YANG data will be added to the previous data and may override it.
1020 * @return 0 on success, non-zero otherwise.
1021 */
Roytakb2794852023-10-18 14:30:22 +02001022int nc_server_config_add_ch_tls_server_cert(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
roman6c4efcd2023-08-08 10:18:44 +02001023 const char *privkey_path, const char *pubkey_path, const char *certificate_path, struct lyd_node **config);
romanb6f44032023-06-30 15:07:56 +02001024
1025/**
Roytak2161df62023-08-02 15:04:42 +02001026 * @brief Deletes a Call Home server certificate from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001027 *
Roytak2161df62023-08-02 15:04:42 +02001028 * @param[in] client_name Identifier of an existing Call Home client.
1029 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
roman9d5e5a52023-07-14 12:43:44 +02001030 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001031 * @return 0 on success, non-zero otherwise.
1032 */
Roytakb2794852023-10-18 14:30:22 +02001033int nc_server_config_del_ch_tls_server_cert(const char *client_name, const char *endpt_name,
Roytak934edc32023-07-27 12:04:18 +02001034 struct lyd_node **config);
1035
1036/**
Roytak2161df62023-08-02 15:04:42 +02001037 * @brief Creates new YANG configuration data nodes for a Call Home client's (end-entity) certificate.
romanb6f44032023-06-30 15:07:56 +02001038 *
1039 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001040 * @param[in] client_name Arbitrary identifier of the Call Home client.
1041 * If a Call Home client with this identifier already exists, its contents will be changed.
1042 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1043 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
1044 * @param[in] cert_name Arbitrary identifier of the Call Home endpoint's end-entity certificate.
1045 * 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 +02001046 * @param[in] cert_path Path to the certificate file.
Roytak934edc32023-07-27 12:04:18 +02001047 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
romanb6f44032023-06-30 15:07:56 +02001048 * Otherwise the new YANG data will be added to the previous data and may override it.
1049 * @return 0 on success, non-zero otherwise.
1050 */
Roytakb2794852023-10-18 14:30:22 +02001051int 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 +02001052 const char *cert_name, const char *cert_path, struct lyd_node **config);
1053
1054/**
Roytak2161df62023-08-02 15:04:42 +02001055 * @brief Deletes a Call Home client (end-entity) certificate from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001056 *
Roytak2161df62023-08-02 15:04:42 +02001057 * @param[in] client_name Identifier of an existing Call Home client.
1058 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
roman8ba6efa2023-07-12 15:27:52 +02001059 * @param[in] cert_name Optional identifier of a client certificate to be deleted.
1060 * If NULL, all of the client certificates will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001061 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001062 * @return 0 on success, non-zero otherwise.
1063 */
Roytakb2794852023-10-18 14:30:22 +02001064int nc_server_config_del_ch_tls_client_cert(const char *client_name, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +02001065 const char *cert_name, struct lyd_node **config);
1066
1067/**
romanb6f44032023-06-30 15:07:56 +02001068 * @brief Creates new YANG configuration data nodes for a client certificate authority (trust-anchor) certificate.
1069 *
1070 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001071 * @param[in] client_name Arbitrary identifier of the Call Home client.
1072 * If a Call Home client with this identifier already exists, its contents will be changed.
1073 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1074 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
1075 * @param[in] cert_name Arbitrary identifier of the Call Home endpoint's certificate authority certificate.
1076 * If an Call Home endpoint's CA certificate with this identifier already exists, its contents will be changed.
romanb6f44032023-06-30 15:07:56 +02001077 * @param[in] cert_path Path to the certificate file.
Roytak9b32c0f2023-08-02 15:07:29 +02001078 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
romanb6f44032023-06-30 15:07:56 +02001079 * Otherwise the new YANG data will be added to the previous data and may override it.
1080 * @return 0 on success, non-zero otherwise.
1081 */
Roytakb2794852023-10-18 14:30:22 +02001082int 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 +02001083 const char *cert_name, const char *cert_path, struct lyd_node **config);
1084
1085/**
Roytak2161df62023-08-02 15:04:42 +02001086 * @brief Deletes a Call Home client certificate authority (trust-anchor) certificate from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001087 *
Roytak2161df62023-08-02 15:04:42 +02001088 * @param[in] client_name Identifier of an existing Call Home client.
1089 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
roman8ba6efa2023-07-12 15:27:52 +02001090 * @param[in] cert_name Optional identifier of a CA certificate to be deleted.
1091 * If NULL, all of the CA certificates will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001092 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001093 * @return 0 on success, non-zero otherwise.
1094 */
Roytakb2794852023-10-18 14:30:22 +02001095int nc_server_config_del_ch_tls_ca_cert(const char *client_name, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +02001096 const char *cert_name, struct lyd_node **config);
1097
1098/**
Roytak2161df62023-08-02 15:04:42 +02001099 * @brief Creates new YANG configuration data nodes for a Call Home cert-to-name entry.
romanb6f44032023-06-30 15:07:56 +02001100 *
1101 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001102 * @param[in] client_name Arbitrary identifier of the Call Home client.
1103 * If a Call Home client with this identifier already exists, its contents will be changed.
1104 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1105 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
romanb6f44032023-06-30 15:07:56 +02001106 * @param[in] id ID of the entry. The lower the ID, the higher the priority of the entry (it will be checked earlier).
1107 * @param[in] fingerprint Optional fingerprint of the entry. The fingerprint should always be set, however if it is
1108 * not set, it will match any certificate. Entry with no fingerprint should therefore be placed only as the last entry.
1109 * @param[in] map_type Mapping username to the certificate option.
1110 * @param[in] name Username for this cert-to-name entry.
Roytak9b32c0f2023-08-02 15:07:29 +02001111 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
romanb6f44032023-06-30 15:07:56 +02001112 * Otherwise the new YANG data will be added to the previous data and may override it.
1113 * @return 0 on success, non-zero otherwise.
1114 */
Roytakb2794852023-10-18 14:30:22 +02001115int 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 +02001116 uint32_t id, const char *fingerprint, NC_TLS_CTN_MAPTYPE map_type, const char *name, struct lyd_node **config);
1117
roman8ba6efa2023-07-12 15:27:52 +02001118/**
Roytak2161df62023-08-02 15:04:42 +02001119 * @brief Deletes a Call Home cert-to-name entry from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001120 *
Roytak2161df62023-08-02 15:04:42 +02001121 * @param[in] client_name Identifier of an existing Call Home client.
1122 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
1123 * @param[in] id Optional identifier of the Call Home CTN entry to be deleted.
roman8ba6efa2023-07-12 15:27:52 +02001124 * If 0, all of the CTN entries will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001125 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001126 * @return 0 on success, non-zero otherwise.
1127 */
Roytakb2794852023-10-18 14:30:22 +02001128int nc_server_config_del_ch_tls_ctn(const char *client_name, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +02001129 uint32_t id, struct lyd_node **config);
1130
1131/**
roman35120972023-08-08 10:39:12 +02001132 * @} TLS Call Home Server Configuration
roman8ba6efa2023-07-12 15:27:52 +02001133 */
1134
roman2eab4742023-06-06 10:00:26 +02001135#endif /* NC_ENABLED_SSH_TLS */
roman45cec4e2023-02-17 10:21:39 +01001136
romanc1d2b092023-02-02 08:58:27 +01001137#ifdef __cplusplus
1138}
1139#endif
1140
1141#endif /* NC_SESSION_SERVER_H_ */