roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 1 | /** |
roman | e028ef9 | 2023-02-24 16:33:08 +0100 | [diff] [blame] | 2 | * @file server_config.h |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 3 | * @author Roman Janota <janota@cesnet.cz> |
| 4 | * @brief libnetconf2 server configuration |
| 5 | * |
| 6 | * @copyright |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 7 | * Copyright (c) 2023 CESNET, z.s.p.o. |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 8 | * |
| 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 |
| 20 | extern "C" { |
| 21 | #endif |
| 22 | |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 23 | #include <stdint.h> |
| 24 | |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 25 | #include <libyang/libyang.h> |
| 26 | |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 27 | #include "session.h" |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 28 | |
| 29 | /** |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 30 | * @defgroup server_config Server Configuration |
| 31 | * @ingroup server |
| 32 | * |
| 33 | * @brief Server-side configuration creation and application |
| 34 | * @{ |
| 35 | */ |
| 36 | |
| 37 | /** |
roman | 3512097 | 2023-08-08 10:39:12 +0200 | [diff] [blame] | 38 | * @} 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 | * |
roman | 6430c15 | 2023-10-12 11:28:47 +0200 | [diff] [blame] | 62 | * @param[in, out] ctx Optional context in which the modules will be implemented. Created if *ctx is null. |
roman | 3512097 | 2023-08-08 10:39:12 +0200 | [diff] [blame] | 63 | * @return 0 on success, 1 on error. |
| 64 | */ |
| 65 | int nc_server_config_load_modules(struct ly_ctx **ctx); |
| 66 | |
| 67 | /** |
roman | 6430c15 | 2023-10-12 11:28:47 +0200 | [diff] [blame] | 68 | * @brief Configure server based on the given diff. |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 69 | * |
roman | 6430c15 | 2023-10-12 11:28:47 +0200 | [diff] [blame] | 70 | * Context must already have implemented the required modules, see ::nc_server_config_load_modules(). |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 71 | * |
roman | 6430c15 | 2023-10-12 11:28:47 +0200 | [diff] [blame] | 72 | * @param[in] diff YANG diff belonging to either ietf-netconf-server, ietf-keystore or ietf-truststore modules. |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 73 | * The top level node HAS to have an operation (create, replace, delete or none). |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 74 | * @return 0 on success, 1 on error. |
| 75 | */ |
roman | f6f37a5 | 2023-05-25 14:27:51 +0200 | [diff] [blame] | 76 | int nc_server_config_setup_diff(const struct lyd_node *diff); |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 77 | |
| 78 | /** |
roman | f02273a | 2023-05-25 09:44:11 +0200 | [diff] [blame] | 79 | * @brief Configure server based on the given data. |
| 80 | * |
roman | f02273a | 2023-05-25 09:44:11 +0200 | [diff] [blame] | 81 | * Behaves as if all the nodes in data had the replace operation. That means that the current configuration will be deleted |
roman | 6430c15 | 2023-10-12 11:28:47 +0200 | [diff] [blame] | 82 | * and just the given data will be applied. |
roman | 0f5fa42 | 2023-08-07 09:03:24 +0200 | [diff] [blame] | 83 | * Context must already have implemented the required modules, see ::nc_server_config_load_modules(). |
roman | f02273a | 2023-05-25 09:44:11 +0200 | [diff] [blame] | 84 | * |
roman | 6430c15 | 2023-10-12 11:28:47 +0200 | [diff] [blame] | 85 | * @param[in] data YANG data belonging to either ietf-netconf-server, ietf-keystore or ietf-truststore modules. |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 86 | * This data __must be valid__. No node can have an operation attribute. |
roman | f02273a | 2023-05-25 09:44:11 +0200 | [diff] [blame] | 87 | * @return 0 on success, 1 on error. |
| 88 | */ |
roman | f6f37a5 | 2023-05-25 14:27:51 +0200 | [diff] [blame] | 89 | int nc_server_config_setup_data(const struct lyd_node *data); |
roman | f02273a | 2023-05-25 09:44:11 +0200 | [diff] [blame] | 90 | |
| 91 | /** |
roman | 6430c15 | 2023-10-12 11:28:47 +0200 | [diff] [blame] | 92 | * @brief Configure server based on the given data stored in a file. |
| 93 | * |
roman | 0f5fa42 | 2023-08-07 09:03:24 +0200 | [diff] [blame] | 94 | * Wrapper around ::nc_server_config_setup_data() hiding work with parsing the data. |
roman | 6430c15 | 2023-10-12 11:28:47 +0200 | [diff] [blame] | 95 | * Context must already have implemented the required modules, see ::nc_server_config_load_modules(). |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 96 | * |
| 97 | * @param[in] ctx libyang context. |
roman | 6430c15 | 2023-10-12 11:28:47 +0200 | [diff] [blame] | 98 | * @param[in] path Path to a file with ietf-netconf-server, ietf-keystore or ietf-truststore YANG data. |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 99 | * This data __must be valid__. No node can have an operation attribute. |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 100 | * @return 0 on success, 1 on error. |
| 101 | */ |
| 102 | int nc_server_config_setup_path(const struct ly_ctx *ctx, const char *path); |
| 103 | |
roman | 2eab474 | 2023-06-06 10:00:26 +0200 | [diff] [blame] | 104 | #ifdef NC_ENABLED_SSH_TLS |
| 105 | |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 106 | /** |
roman | 6430c15 | 2023-10-12 11:28:47 +0200 | [diff] [blame] | 107 | * @brief Creates new YANG configuration data nodes for address and port. |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 108 | * |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 109 | * @param[in] ctx libyang context. |
| 110 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
roman | 3512097 | 2023-08-08 10:39:12 +0200 | [diff] [blame] | 111 | * If an endpoint with this identifier already exists, its contents might be changed. |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 112 | * @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. |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 115 | * @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. |
roman | 45cec4e | 2023-02-17 10:21:39 +0100 | [diff] [blame] | 118 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 119 | int nc_server_config_add_address_port(const struct ly_ctx *ctx, const char *endpt_name, NC_TRANSPORT_IMPL transport, |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 120 | const char *address, uint16_t port, struct lyd_node **config); |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 121 | |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 122 | #endif /* NC_ENABLED_SSH_TLS */ |
| 123 | |
| 124 | /** |
roman | d0b7837 | 2023-09-14 10:06:03 +0200 | [diff] [blame] | 125 | * @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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 138 | int nc_server_config_add_unix_socket(const struct ly_ctx *ctx, const char *endpt_name, const char *path, |
roman | d0b7837 | 2023-09-14 10:06:03 +0200 | [diff] [blame] | 139 | mode_t mode, uid_t uid, gid_t gid, struct lyd_node **config); |
| 140 | |
| 141 | /** |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 142 | * @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. |
roman | 3512097 | 2023-08-08 10:39:12 +0200 | [diff] [blame] | 146 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 147 | * @return 0 on success, non-zero otherwise. |
| 148 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 149 | int nc_server_config_del_endpt(const char *endpt_name, struct lyd_node **config); |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 150 | |
| 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. |
roman | 1314591 | 2023-08-17 15:36:54 +0200 | [diff] [blame] | 157 | * @param[in] ti Transport in which the key pair will be used. Either SSH or TLS. |
roman | 12c3d52 | 2023-07-26 13:39:30 +0200 | [diff] [blame] | 158 | * @param[in] asym_key_name Identifier of the asymmetric key pair. |
| 159 | * This identifier is used to reference the key pair. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 160 | * @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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 167 | int nc_server_config_add_keystore_asym_key(const struct ly_ctx *ctx, NC_TRANSPORT_IMPL ti, const char *asym_key_name, |
roman | 1314591 | 2023-08-17 15:36:54 +0200 | [diff] [blame] | 168 | const char *privkey_path, const char *pubkey_path, struct lyd_node **config); |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 169 | |
| 170 | /** |
| 171 | * @brief Deletes a keystore's asymmetric key from the YANG data. |
| 172 | * |
roman | 12c3d52 | 2023-07-26 13:39:30 +0200 | [diff] [blame] | 173 | * @param[in] asym_key_name Optional identifier of the asymmetric key to be deleted. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 174 | * 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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 178 | int nc_server_config_del_keystore_asym_key(const char *asym_key_name, struct lyd_node **config); |
roman | 12c3d52 | 2023-07-26 13:39:30 +0200 | [diff] [blame] | 179 | |
| 180 | /** |
| 181 | * @brief Creates new YANG data nodes for a certificate in the keystore. |
| 182 | * |
roman | 6430c15 | 2023-10-12 11:28:47 +0200 | [diff] [blame] | 183 | * 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. |
roman | 12c3d52 | 2023-07-26 13:39:30 +0200 | [diff] [blame] | 185 | * |
| 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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 196 | int nc_server_config_add_keystore_cert(const struct ly_ctx *ctx, const char *asym_key_name, const char *cert_name, |
roman | 12c3d52 | 2023-07-26 13:39:30 +0200 | [diff] [blame] | 197 | 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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 209 | int nc_server_config_del_keystore_cert(const char *asym_key_name, const char *cert_name, struct lyd_node **config); |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 210 | |
| 211 | /** |
| 212 | * @brief Creates new YANG data nodes for a public key in the truststore. |
| 213 | * |
| 214 | * @param[in] ctx libyang context. |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 215 | * @param[in] ti Transport for which this key will be used, to be generated correctly. |
roman | 12c3d52 | 2023-07-26 13:39:30 +0200 | [diff] [blame] | 216 | * @param[in] pub_bag_name Arbitrary identifier of the public key bag. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 217 | * 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. |
roman | 12c3d52 | 2023-07-26 13:39:30 +0200 | [diff] [blame] | 220 | * If a public key with this name already exists in the given bag, its contents will be changed. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 221 | * @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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 226 | int 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); |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 228 | |
| 229 | /** |
| 230 | * @brief Deletes a truststore's public key from the YANG data. |
| 231 | * |
roman | 12c3d52 | 2023-07-26 13:39:30 +0200 | [diff] [blame] | 232 | * @param[in] pub_bag_name Identifier of an existing public key bag. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 233 | * @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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 238 | int nc_server_config_del_truststore_pubkey(const char *pub_bag_name, const char *pubkey_name, struct lyd_node **config); |
roman | 12c3d52 | 2023-07-26 13:39:30 +0200 | [diff] [blame] | 239 | |
| 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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 254 | int nc_server_config_add_truststore_cert(const struct ly_ctx *ctx, const char *cert_bag_name, const char *cert_name, |
roman | 12c3d52 | 2023-07-26 13:39:30 +0200 | [diff] [blame] | 255 | 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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 266 | int nc_server_config_del_truststore_cert(const char *cert_bag_name, |
roman | 12c3d52 | 2023-07-26 13:39:30 +0200 | [diff] [blame] | 267 | const char *cert_name, struct lyd_node **config); |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 268 | |
| 269 | /** |
roman | 3512097 | 2023-08-08 10:39:12 +0200 | [diff] [blame] | 270 | * @} Server Configuration Functions |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 271 | */ |
| 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 | |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 281 | /** |
| 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. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 286 | * If an endpoint with this identifier already exists, its hostkey might be changed. |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 287 | * @param[in] hostkey_name Arbitrary identifier of the hostkey. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 288 | * If a hostkey with this identifier already exists, its contents will be changed. |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 289 | * @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. |
roman | 3512097 | 2023-08-08 10:39:12 +0200 | [diff] [blame] | 291 | * @param[in] pubkey_path Optional path to a file containing a public key. If NULL, public key will be |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 292 | * 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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 297 | int nc_server_config_add_ssh_hostkey(const struct ly_ctx *ctx, const char *endpt_name, const char *hostkey_name, |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 298 | 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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 310 | int nc_server_config_del_ssh_hostkey(const struct ly_ctx *ctx, const char *endpt_name, |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 311 | const char *hostkey_name, struct lyd_node **config); |
| 312 | |
| 313 | /** |
roman | 68404fd | 2023-07-24 10:40:59 +0200 | [diff] [blame] | 314 | * @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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 325 | int nc_server_config_add_ssh_auth_attempts(const struct ly_ctx *ctx, const char *endpt_name, uint16_t auth_attempts, |
roman | 68404fd | 2023-07-24 10:40:59 +0200 | [diff] [blame] | 326 | 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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 340 | int nc_server_config_add_ssh_auth_timeout(const struct ly_ctx *ctx, const char *endpt_name, uint16_t auth_timeout, |
roman | 68404fd | 2023-07-24 10:40:59 +0200 | [diff] [blame] | 341 | struct lyd_node **config); |
| 342 | |
| 343 | /** |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 344 | * @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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 358 | int nc_server_config_add_ssh_user_pubkey(const struct ly_ctx *ctx, const char *endpt_name, |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 359 | 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. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 368 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 369 | * @return 0 on success, non-zero otherwise. |
| 370 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 371 | int nc_server_config_del_ssh_user_pubkey(const char *endpt_name, const char *user_name, |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 372 | 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. |
roman | 3512097 | 2023-08-08 10:39:12 +0200 | [diff] [blame] | 382 | * @param[in] password Clear-text password to be set for the user. It will be hashed. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 383 | * @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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 387 | int nc_server_config_add_ssh_user_password(const struct ly_ctx *ctx, const char *endpt_name, |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 388 | 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. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 395 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 396 | * @return 0 on success, non-zero otherwise. |
| 397 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 398 | int nc_server_config_del_ssh_user_password(const char *endpt_name, const char *user_name, |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 399 | 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. |
roman | 0f5fa42 | 2023-08-07 09:03:24 +0200 | [diff] [blame] | 410 | * @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 |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 412 | * 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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 417 | int nc_server_config_add_ssh_user_interactive(const struct ly_ctx *ctx, const char *endpt_name, |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 418 | 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. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 425 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 426 | * @return 0 on success, non-zero otherwise. |
| 427 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 428 | int nc_server_config_del_ssh_user_interactive(const char *endpt_name, const char *user_name, |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 429 | 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. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 437 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 438 | * @return 0 on success, non-zero otherwise. |
| 439 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 440 | int nc_server_config_del_ssh_user(const char *endpt_name, |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 441 | const char *user_name, struct lyd_node **config); |
| 442 | |
| 443 | /** |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 444 | * @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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 458 | int nc_server_config_add_ssh_endpoint_client_ref(const struct ly_ctx *ctx, const char *endpt_name, |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 459 | 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. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 465 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 466 | * @return 0 on success, non-zero otherwise. |
| 467 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 468 | int nc_server_config_del_ssh_endpoint_client_ref(const char *endpt_name, struct lyd_node **config); |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 469 | |
| 470 | /** |
roman | 3512097 | 2023-08-08 10:39:12 +0200 | [diff] [blame] | 471 | * @} SSH Server Configuration |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 472 | */ |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 473 | |
| 474 | /** |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 475 | * @defgroup server_config_tls TLS Server Configuration |
| 476 | * @ingroup server_config |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 477 | * |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 478 | * @brief TLS server configuration creation and deletion |
| 479 | * @{ |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 480 | */ |
roman | 2e797ef | 2023-06-19 10:47:49 +0200 | [diff] [blame] | 481 | |
| 482 | /** |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 483 | * @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. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 487 | * If an endpoint with this identifier already exists, its server certificate will be changed. |
roman | 6c4efcd | 2023-08-08 10:18:44 +0200 | [diff] [blame] | 488 | * @param[in] privkey_path Path to the server's PEM encoded private key file. |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 489 | * @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. |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 491 | * @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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 496 | int nc_server_config_add_tls_server_cert(const struct ly_ctx *ctx, const char *endpt_name, const char *privkey_path, |
roman | 6c4efcd | 2023-08-08 10:18:44 +0200 | [diff] [blame] | 497 | const char *pubkey_path, const char *certificate_path, struct lyd_node **config); |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 498 | |
| 499 | /** |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 500 | * @brief Deletes the server's certificate from the YANG data. |
| 501 | * |
| 502 | * @param[in] endpt_name Identifier of an existing endpoint. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 503 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 504 | * @return 0 on success, non-zero otherwise. |
| 505 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 506 | int nc_server_config_del_tls_server_cert(const char *endpt_name, struct lyd_node **config); |
roman | 12c3d52 | 2023-07-26 13:39:30 +0200 | [diff] [blame] | 507 | |
| 508 | /** |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 509 | * @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. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 513 | * If an endpoint with this identifier already exists, its contents will be changed. |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 514 | * @param[in] cert_name Arbitrary identifier of the client's certificate. |
roman | 3512097 | 2023-08-08 10:39:12 +0200 | [diff] [blame] | 515 | * If a client certificate with this identifier already exists, it will be changed. |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 516 | * @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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 521 | int nc_server_config_add_tls_client_cert(const struct ly_ctx *ctx, const char *endpt_name, const char *cert_name, |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 522 | const char *cert_path, struct lyd_node **config); |
| 523 | |
| 524 | /** |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 525 | * @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. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 530 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 531 | * @return 0 on success, non-zero otherwise. |
| 532 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 533 | int nc_server_config_del_tls_client_cert(const char *endpt_name, const char *cert_name, struct lyd_node **config); |
roman | 12c3d52 | 2023-07-26 13:39:30 +0200 | [diff] [blame] | 534 | |
| 535 | /** |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 536 | * @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. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 540 | * If an endpoint with this identifier already exists, its contents will be changed. |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 541 | * @param[in] cert_name Arbitrary identifier of the certificate authority certificate. |
roman | 3512097 | 2023-08-08 10:39:12 +0200 | [diff] [blame] | 542 | * If a CA with this identifier already exists, it will be changed. |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 543 | * @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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 548 | int nc_server_config_add_tls_ca_cert(const struct ly_ctx *ctx, const char *endpt_name, const char *cert_name, |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 549 | const char *cert_path, struct lyd_node **config); |
| 550 | |
| 551 | /** |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 552 | * @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. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 557 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 558 | * @return 0 on success, non-zero otherwise. |
| 559 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 560 | int nc_server_config_del_tls_ca_cert(const char *endpt_name, const char *cert_name, struct lyd_node **config); |
roman | 12c3d52 | 2023-07-26 13:39:30 +0200 | [diff] [blame] | 561 | |
| 562 | /** |
Roytak | 7695891 | 2023-09-29 15:25:14 +0200 | [diff] [blame] | 563 | * @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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 577 | int nc_server_config_add_tls_endpoint_client_ref(const struct ly_ctx *ctx, const char *endpt_name, |
Roytak | 7695891 | 2023-09-29 15:25:14 +0200 | [diff] [blame] | 578 | 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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 587 | int nc_server_config_del_tls_endpoint_client_ref(const char *endpt_name, struct lyd_node **config); |
Roytak | 7695891 | 2023-09-29 15:25:14 +0200 | [diff] [blame] | 588 | |
| 589 | /** |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 590 | * @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. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 594 | * If an endpoint with this identifier already exists, its contents will be changed. |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 595 | * @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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 604 | int nc_server_config_add_tls_ctn(const struct ly_ctx *ctx, const char *endpt_name, uint32_t id, const char *fingerprint, |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 605 | NC_TLS_CTN_MAPTYPE map_type, const char *name, struct lyd_node **config); |
| 606 | |
roman | 12644fe | 2023-06-08 11:06:42 +0200 | [diff] [blame] | 607 | /** |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 608 | * @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. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 613 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 614 | * @return 0 on success, non-zero otherwise. |
| 615 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 616 | int nc_server_config_del_tls_ctn(const char *endpt_name, uint32_t id, struct lyd_node **config); |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 617 | |
| 618 | /** |
roman | 3512097 | 2023-08-08 10:39:12 +0200 | [diff] [blame] | 619 | * @} TLS Server Configuration |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 620 | */ |
| 621 | |
| 622 | /** |
roman | 3512097 | 2023-08-08 10:39:12 +0200 | [diff] [blame] | 623 | * @defgroup server_config_ch Call Home Server Configuration |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 624 | * @ingroup server_config |
| 625 | * |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 626 | * @brief Call Home server configuration creation and deletion |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 627 | * @{ |
| 628 | */ |
| 629 | |
| 630 | /** |
roman | 3512097 | 2023-08-08 10:39:12 +0200 | [diff] [blame] | 631 | * @} 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 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 643 | * @brief Creates new YANG configuration data nodes for a Call Home client's address and port. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 644 | * |
| 645 | * @param[in] ctx libyang context. |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 646 | * @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. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 648 | * @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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 657 | int nc_server_config_add_ch_address_port(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name, |
roman | 5cbb653 | 2023-06-22 12:53:17 +0200 | [diff] [blame] | 658 | NC_TRANSPORT_IMPL transport, const char *address, const char *port, struct lyd_node **config); |
| 659 | |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 660 | #endif /* NC_ENABLED_SSH_TLS */ |
| 661 | |
| 662 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 663 | * @brief Deletes a Call Home client from the YANG data. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 664 | * |
| 665 | * @param[in] client_name Optional identifier of a client to be deleted. |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 666 | * If NULL, all of the Call Home clients will be deleted. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 667 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 668 | * @return 0 on success, non-zero otherwise. |
| 669 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 670 | int nc_server_config_del_ch_client(const char *client_name, struct lyd_node **config); |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 671 | |
| 672 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 673 | * @brief Deletes a Call Home endpoint from the YANG data. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 674 | * |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 675 | * @param[in] client_name Identifier of an existing Call Home client. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 676 | * @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. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 678 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 679 | * @return 0 on success, non-zero otherwise. |
| 680 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 681 | int nc_server_config_del_ch_endpt(const char *client_name, const char *endpt_name, struct lyd_node **config); |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 682 | |
| 683 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 684 | * @brief Creates new YANG configuration data nodes for the Call Home persistent connection type. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 685 | * |
| 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. |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 689 | * @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. |
Roytak | 9b32c0f | 2023-08-02 15:07:29 +0200 | [diff] [blame] | 691 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 692 | * 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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 695 | int nc_server_config_add_ch_persistent(const struct ly_ctx *ctx, const char *client_name, struct lyd_node **config); |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 696 | |
| 697 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 698 | * @brief Creates new YANG configuration data nodes for the period parameter of the Call Home periodic connection type. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 699 | * |
| 700 | * If called, the persistent connection type will be replaced by periodic. |
| 701 | * |
| 702 | * @param[in] ctx libyang context. |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 703 | * @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. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 705 | * @param[in] period Duration between periodic connections in minutes. |
Roytak | 9b32c0f | 2023-08-02 15:07:29 +0200 | [diff] [blame] | 706 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 707 | * 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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 710 | int nc_server_config_add_ch_period(const struct ly_ctx *ctx, const char *client_name, uint16_t period, |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 711 | struct lyd_node **config); |
| 712 | |
| 713 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 714 | * @brief Deletes the Call Home period parameter of the periodic connection type from the YANG data. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 715 | * |
| 716 | * This behaves the same as setting the period to 60 minutes, which is the default value of this node. |
| 717 | * |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 718 | * @param[in] client_name Identifier of an existing Call Home client. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 719 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 720 | * @return 0 on success, non-zero otherwise. |
| 721 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 722 | int nc_server_config_del_ch_period(const char *client_name, struct lyd_node **config); |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 723 | |
| 724 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 725 | * @brief Creates new YANG configuration data nodes for the anchor time parameter of the Call Home periodic connection type. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 726 | * |
| 727 | * If called, the persistent connection type will be replaced by periodic. |
| 728 | * |
| 729 | * @param[in] ctx libyang context. |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 730 | * @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. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 732 | * @param[in] anchor_time Timestamp before or after which a series of periodic connections are determined. |
Roytak | 9b32c0f | 2023-08-02 15:07:29 +0200 | [diff] [blame] | 733 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 734 | * 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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 737 | int nc_server_config_add_ch_anchor_time(const struct ly_ctx *ctx, const char *client_name, |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 738 | const char *anchor_time, struct lyd_node **config); |
| 739 | |
| 740 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 741 | * @brief Deletes the Call Home anchor time parameter of the periodic connection type from the YANG data. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 742 | * |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 743 | * @param[in] client_name Identifier of an existing Call Home client. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 744 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 745 | * @return 0 on success, non-zero otherwise. |
| 746 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 747 | int nc_server_config_del_ch_anchor_time(const char *client_name, struct lyd_node **config); |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 748 | |
| 749 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 750 | * @brief Creates new YANG configuration data nodes for the idle timeout parameter of the Call Home periodic connection type. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 751 | * |
| 752 | * If called, the persistent connection type will be replaced by periodic. |
| 753 | * |
| 754 | * @param[in] ctx libyang context. |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 755 | * @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. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 757 | * @param[in] idle_timeout Specifies the maximum number of seconds that a session may remain idle. |
Roytak | 9b32c0f | 2023-08-02 15:07:29 +0200 | [diff] [blame] | 758 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 759 | * 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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 762 | int nc_server_config_add_ch_idle_timeout(const struct ly_ctx *ctx, const char *client_name, |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 763 | uint16_t idle_timeout, struct lyd_node **config); |
| 764 | |
| 765 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 766 | * @brief Deletes the Call Home idle timeout parameter of the periodic connection type from the YANG data. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 767 | * |
| 768 | * This behaves the same as setting the timeout to 180 seconds, which is the default value of this node. |
| 769 | * |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 770 | * @param[in] client_name Identifier of an existing Call Home client. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 771 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 772 | * @return 0 on success, non-zero otherwise. |
| 773 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 774 | int nc_server_config_del_ch_idle_timeout(const char *client_name, struct lyd_node **config); |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 775 | |
| 776 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 777 | * @brief Creates new YANG configuration data nodes for the Call Home reconnect strategy. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 778 | * |
| 779 | * @param[in] ctx libyang context. |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 780 | * @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. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 782 | * @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. |
Roytak | 9b32c0f | 2023-08-02 15:07:29 +0200 | [diff] [blame] | 785 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 786 | * 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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 789 | int nc_server_config_add_ch_reconnect_strategy(const struct ly_ctx *ctx, const char *client_name, |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 790 | NC_CH_START_WITH start_with, uint16_t max_wait, uint8_t max_attempts, struct lyd_node **config); |
| 791 | |
| 792 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 793 | * @brief Resets the values of the Call Home reconnect strategy nodes to their defaults. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 794 | * |
| 795 | * The default values are: start-with = NC_CH_FIRST_LISTED, max-wait = 5 and max-attempts = 3. |
| 796 | * |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 797 | * @param[in] client_name Identifier of an existing Call Home client. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 798 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 799 | * @return 0 on success, non-zero otherwise. |
| 800 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 801 | int nc_server_config_del_ch_reconnect_strategy(const char *client_name, struct lyd_node **config); |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 802 | |
| 803 | /** |
roman | 3512097 | 2023-08-08 10:39:12 +0200 | [diff] [blame] | 804 | * @} Call Home Server Configuration Functions |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 805 | */ |
| 806 | |
| 807 | #ifdef NC_ENABLED_SSH_TLS |
| 808 | |
| 809 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 810 | * @defgroup server_config_ch_ssh SSH Call Home Server Configuration |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 811 | * @ingroup server_config_ch |
| 812 | * |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 813 | * @brief SSH Call Home server configuration creation and deletion |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 814 | * @{ |
| 815 | */ |
| 816 | |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 817 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 818 | * @brief Creates new YANG data nodes for a Call Home SSH hostkey. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 819 | * |
| 820 | * @param[in] ctx libyang context. |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 821 | * @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. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 823 | * @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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 835 | int nc_server_config_add_ch_ssh_hostkey(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name, |
roman | 5cbb653 | 2023-06-22 12:53:17 +0200 | [diff] [blame] | 836 | const char *hostkey_name, const char *privkey_path, const char *pubkey_path, struct lyd_node **config); |
| 837 | |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 838 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 839 | * @brief Deletes a Call Home hostkey from the YANG data. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 840 | * |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 841 | * @param[in] client_name Identifier of an existing Call Home client. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 842 | * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 843 | * @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. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 845 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 846 | * @return 0 on success, non-zero otherwise. |
| 847 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 848 | int nc_server_config_del_ch_ssh_hostkey(const char *client_name, const char *endpt_name, |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 849 | const char *hostkey_name, struct lyd_node **config); |
| 850 | |
| 851 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 852 | * @brief Creates new YANG configuration data nodes for the maximum amount of failed Call Home SSH authentication attempts. |
roman | 68404fd | 2023-07-24 10:40:59 +0200 | [diff] [blame] | 853 | * |
| 854 | * @param[in] ctx libyang context. |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 855 | * @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. |
roman | 68404fd | 2023-07-24 10:40:59 +0200 | [diff] [blame] | 857 | * @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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 865 | int nc_server_config_add_ch_ssh_auth_attempts(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name, |
roman | 68404fd | 2023-07-24 10:40:59 +0200 | [diff] [blame] | 866 | uint16_t auth_attempts, struct lyd_node **config); |
| 867 | |
| 868 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 869 | * @brief Creates new YANG configuration data nodes for a Call Home SSH authentication timeout. |
roman | 68404fd | 2023-07-24 10:40:59 +0200 | [diff] [blame] | 870 | * |
| 871 | * @param[in] ctx libyang context. |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 872 | * @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. |
roman | 68404fd | 2023-07-24 10:40:59 +0200 | [diff] [blame] | 874 | * @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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 882 | int nc_server_config_add_ch_ssh_auth_timeout(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name, |
roman | 68404fd | 2023-07-24 10:40:59 +0200 | [diff] [blame] | 883 | uint16_t auth_timeout, struct lyd_node **config); |
| 884 | |
| 885 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 886 | * @brief Creates new YANG data nodes for a Call Home SSH user's public key authentication method. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 887 | * |
| 888 | * @param[in] ctx libyang context. |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 889 | * @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. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 891 | * @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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 902 | int nc_server_config_add_ch_ssh_user_pubkey(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name, |
roman | 5cbb653 | 2023-06-22 12:53:17 +0200 | [diff] [blame] | 903 | const char *user_name, const char *pubkey_name, const char *pubkey_path, struct lyd_node **config); |
| 904 | |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 905 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 906 | * @brief Deletes a Call Home SSH user's public key from the YANG data. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 907 | * |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 908 | * @param[in] client_name Identifier of an existing Call Home client. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 909 | * @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. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 911 | * @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. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 913 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 914 | * @return 0 on success, non-zero otherwise. |
| 915 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 916 | int nc_server_config_del_ch_ssh_user_pubkey(const char *client_name, const char *endpt_name, |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 917 | const char *user_name, const char *pubkey_name, struct lyd_node **config); |
roman | 5cbb653 | 2023-06-22 12:53:17 +0200 | [diff] [blame] | 918 | |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 919 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 920 | * @brief Creates new YANG data nodes for a Call Home SSH user's password authentication method. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 921 | * |
| 922 | * @param[in] ctx libyang context. |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 923 | * @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. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 925 | * @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. |
roman | 3512097 | 2023-08-08 10:39:12 +0200 | [diff] [blame] | 929 | * @param[in] password Clear-text password to be set for the user. It will be hashed. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 930 | * @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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 934 | int nc_server_config_add_ch_ssh_user_password(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name, |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 935 | const char *user_name, const char *password, struct lyd_node **config); |
| 936 | |
| 937 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 938 | * @brief Deletes a Call Home SSH user's password from the YANG data. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 939 | * |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 940 | * @param[in] client_name Identifier of an existing Call Home client. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 941 | * @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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 946 | int nc_server_config_del_ch_ssh_user_password(const char *client_name, const char *endpt_name, |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 947 | const char *user_name, struct lyd_node **config); |
| 948 | |
| 949 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 950 | * @brief Creates new YANG configuration data nodes for a Call Home SSH user's keyboard interactive authentication method. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 951 | * |
| 952 | * @param[in] ctx libyang context. |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 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. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 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] 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. |
roman | 0f5fa42 | 2023-08-07 09:03:24 +0200 | [diff] [blame] | 960 | * @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 |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 962 | * 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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 967 | int nc_server_config_add_ch_ssh_user_interactive(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name, |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 968 | const char *user_name, const char *pam_config_name, const char *pam_config_dir, struct lyd_node **config); |
| 969 | |
| 970 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 971 | * @brief Deletes a Call Home SSH user's keyboard interactive authentication from the YANG data. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 972 | * |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 973 | * @param[in] client_name Identifier of an existing Call Home client. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 974 | * @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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 979 | int nc_server_config_del_ch_ssh_user_interactive(const char *client_name, const char *endpt_name, |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 980 | const char *user_name, struct lyd_node **config); |
| 981 | |
| 982 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 983 | * @brief Deletes a Call Home SSH user from the YANG data. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 984 | * |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 985 | * @param[in] client_name Identifier of an existing Call Home client. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 986 | * @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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 991 | int nc_server_config_del_ch_ssh_user(const char *client_name, const char *endpt_name, |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 992 | const char *user_name, struct lyd_node **config); |
| 993 | |
| 994 | /** |
roman | 3512097 | 2023-08-08 10:39:12 +0200 | [diff] [blame] | 995 | * @} SSH Call Home Server Configuration |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 996 | */ |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 997 | |
| 998 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 999 | * @defgroup server_config_ch_tls TLS Call Home Server Configuration |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 1000 | * @ingroup server_config_ch |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 1001 | * |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1002 | * @brief TLS Call Home server configuration creation and deletion |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 1003 | * @{ |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 1004 | */ |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 1005 | |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1006 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1007 | * @brief Creates new YANG configuration data nodes for a Call Home server's certificate. |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1008 | * |
| 1009 | * @param[in] ctx libyang context. |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1010 | * @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. |
roman | 6c4efcd | 2023-08-08 10:18:44 +0200 | [diff] [blame] | 1014 | * @param[in] privkey_path Path to the server's PEM encoded private key file. |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1015 | * @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. |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1017 | * @param[in] certificate_path Path to the server's certificate file. |
Roytak | 934edc3 | 2023-07-27 12:04:18 +0200 | [diff] [blame] | 1018 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1019 | * 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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 1022 | int nc_server_config_add_ch_tls_server_cert(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name, |
roman | 6c4efcd | 2023-08-08 10:18:44 +0200 | [diff] [blame] | 1023 | const char *privkey_path, const char *pubkey_path, const char *certificate_path, struct lyd_node **config); |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1024 | |
| 1025 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1026 | * @brief Deletes a Call Home server certificate from the YANG data. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 1027 | * |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1028 | * @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. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 1030 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 1031 | * @return 0 on success, non-zero otherwise. |
| 1032 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 1033 | int nc_server_config_del_ch_tls_server_cert(const char *client_name, const char *endpt_name, |
Roytak | 934edc3 | 2023-07-27 12:04:18 +0200 | [diff] [blame] | 1034 | struct lyd_node **config); |
| 1035 | |
| 1036 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1037 | * @brief Creates new YANG configuration data nodes for a Call Home client's (end-entity) certificate. |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1038 | * |
| 1039 | * @param[in] ctx libyang context. |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1040 | * @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. |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1046 | * @param[in] cert_path Path to the certificate file. |
Roytak | 934edc3 | 2023-07-27 12:04:18 +0200 | [diff] [blame] | 1047 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1048 | * 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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 1051 | int nc_server_config_add_ch_tls_client_cert(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name, |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1052 | const char *cert_name, const char *cert_path, struct lyd_node **config); |
| 1053 | |
| 1054 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1055 | * @brief Deletes a Call Home client (end-entity) certificate from the YANG data. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 1056 | * |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1057 | * @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. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 1059 | * @param[in] cert_name Optional identifier of a client certificate to be deleted. |
| 1060 | * If NULL, all of the client certificates will be deleted. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 1061 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 1062 | * @return 0 on success, non-zero otherwise. |
| 1063 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 1064 | int nc_server_config_del_ch_tls_client_cert(const char *client_name, const char *endpt_name, |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 1065 | const char *cert_name, struct lyd_node **config); |
| 1066 | |
| 1067 | /** |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1068 | * @brief Creates new YANG configuration data nodes for a client certificate authority (trust-anchor) certificate. |
| 1069 | * |
| 1070 | * @param[in] ctx libyang context. |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1071 | * @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. |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1077 | * @param[in] cert_path Path to the certificate file. |
Roytak | 9b32c0f | 2023-08-02 15:07:29 +0200 | [diff] [blame] | 1078 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1079 | * 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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 1082 | int nc_server_config_add_ch_tls_ca_cert(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name, |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1083 | const char *cert_name, const char *cert_path, struct lyd_node **config); |
| 1084 | |
| 1085 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1086 | * @brief Deletes a Call Home client certificate authority (trust-anchor) certificate from the YANG data. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 1087 | * |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1088 | * @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. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 1090 | * @param[in] cert_name Optional identifier of a CA certificate to be deleted. |
| 1091 | * If NULL, all of the CA certificates will be deleted. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 1092 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 1093 | * @return 0 on success, non-zero otherwise. |
| 1094 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 1095 | int nc_server_config_del_ch_tls_ca_cert(const char *client_name, const char *endpt_name, |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 1096 | const char *cert_name, struct lyd_node **config); |
| 1097 | |
| 1098 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1099 | * @brief Creates new YANG configuration data nodes for a Call Home cert-to-name entry. |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1100 | * |
| 1101 | * @param[in] ctx libyang context. |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1102 | * @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. |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1106 | * @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. |
Roytak | 9b32c0f | 2023-08-02 15:07:29 +0200 | [diff] [blame] | 1111 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1112 | * 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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 1115 | int nc_server_config_add_ch_tls_ctn(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name, |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1116 | uint32_t id, const char *fingerprint, NC_TLS_CTN_MAPTYPE map_type, const char *name, struct lyd_node **config); |
| 1117 | |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 1118 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1119 | * @brief Deletes a Call Home cert-to-name entry from the YANG data. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 1120 | * |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1121 | * @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. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 1124 | * If 0, all of the CTN entries will be deleted. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 1125 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 1126 | * @return 0 on success, non-zero otherwise. |
| 1127 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame^] | 1128 | int nc_server_config_del_ch_tls_ctn(const char *client_name, const char *endpt_name, |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 1129 | uint32_t id, struct lyd_node **config); |
| 1130 | |
| 1131 | /** |
roman | 3512097 | 2023-08-08 10:39:12 +0200 | [diff] [blame] | 1132 | * @} TLS Call Home Server Configuration |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 1133 | */ |
| 1134 | |
roman | 2eab474 | 2023-06-06 10:00:26 +0200 | [diff] [blame] | 1135 | #endif /* NC_ENABLED_SSH_TLS */ |
roman | 45cec4e | 2023-02-17 10:21:39 +0100 | [diff] [blame] | 1136 | |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 1137 | #ifdef __cplusplus |
| 1138 | } |
| 1139 | #endif |
| 1140 | |
| 1141 | #endif /* NC_SESSION_SERVER_H_ */ |