Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 1 | /** |
| 2 | * \file session_server_ch.h |
| 3 | * \author Michal Vasko <mvasko@cesnet.cz> |
| 4 | * \brief libnetconf2 Call Home session server manipulation |
| 5 | * |
| 6 | * Copyright (c) 2015 CESNET, z.s.p.o. |
| 7 | * |
Radek Krejci | 9b81f5b | 2016-02-24 13:14:49 +0100 | [diff] [blame] | 8 | * This source code is licensed under BSD 3-Clause License (the "License"). |
| 9 | * You may not use this file except in compliance with the License. |
| 10 | * You may obtain a copy of the License at |
Michal Vasko | afd416b | 2016-02-25 14:51:46 +0100 | [diff] [blame] | 11 | * |
Radek Krejci | 9b81f5b | 2016-02-24 13:14:49 +0100 | [diff] [blame] | 12 | * https://opensource.org/licenses/BSD-3-Clause |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 13 | */ |
| 14 | |
| 15 | #ifndef NC_SESSION_SERVER_CH_H_ |
| 16 | #define NC_SESSION_SERVER_CH_H_ |
| 17 | |
Michal Vasko | c09730e | 2019-01-17 10:07:26 +0100 | [diff] [blame] | 18 | #ifdef __cplusplus |
| 19 | extern "C" { |
| 20 | #endif |
| 21 | |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 22 | #include <stdint.h> |
| 23 | #include <libyang/libyang.h> |
| 24 | |
| 25 | #include "session.h" |
| 26 | #include "netconf.h" |
| 27 | |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 28 | #if defined(NC_ENABLED_SSH) || defined(NC_ENABLED_TLS) |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 29 | |
| 30 | /** |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 31 | * @defgroup server_ch Server-side Call Home |
| 32 | * @ingroup server |
| 33 | * |
| 34 | * @brief Call Home functionality for server-side applications. |
| 35 | * @{ |
| 36 | */ |
| 37 | |
| 38 | /** |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 39 | * @brief Add a new Call Home client. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 40 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 41 | * @param[in] name Arbitrary unique client name. |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 42 | * @return 0 on success, -1 on error. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 43 | */ |
Michal Vasko | adf30f0 | 2019-06-24 09:34:47 +0200 | [diff] [blame] | 44 | int nc_server_ch_add_client(const char *name); |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 45 | |
| 46 | /** |
| 47 | * @brief Drop any connections, stop connecting and remove a client. |
| 48 | * |
| 49 | * @param[in] name Client name. NULL matches all the clients. |
| 50 | * @return 0 on success, -1 on not finding any match. |
| 51 | */ |
Michal Vasko | adf30f0 | 2019-06-24 09:34:47 +0200 | [diff] [blame] | 52 | int nc_server_ch_del_client(const char *name); |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 53 | |
| 54 | /** |
Michal Vasko | fb1724b | 2020-01-31 11:02:00 +0100 | [diff] [blame] | 55 | * @brief Check if a Call Home client exists. |
| 56 | * |
| 57 | * @param[in] name Client name. |
| 58 | * @return 0 if does not exists, non-zero otherwise. |
| 59 | */ |
| 60 | int nc_server_ch_is_client(const char *name); |
| 61 | |
| 62 | /** |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 63 | * @brief Add a new Call Home client endpoint. |
| 64 | * |
| 65 | * @param[in] client_name Existing client name. |
| 66 | * @param[in] endpt_name Arbitrary unique (within the client) endpoint name. |
Michal Vasko | adf30f0 | 2019-06-24 09:34:47 +0200 | [diff] [blame] | 67 | * @param[in] ti Transport protocol to use. |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 68 | * @return 0 on success, -1 on error. |
| 69 | */ |
Michal Vasko | adf30f0 | 2019-06-24 09:34:47 +0200 | [diff] [blame] | 70 | int nc_server_ch_client_add_endpt(const char *client_name, const char *endpt_name, NC_TRANSPORT_IMPL ti); |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 71 | |
| 72 | /** |
| 73 | * @brief Remove a Call Home client endpoint. |
| 74 | * |
| 75 | * @param[in] client_name Existing client name. |
| 76 | * @param[in] endpt_name Existing endpoint of \p client_name. NULL matches all endpoints. |
Michal Vasko | adf30f0 | 2019-06-24 09:34:47 +0200 | [diff] [blame] | 77 | * @param[in] ti Client transport protocol. NULL matches any protocol. |
| 78 | * Redundant to set if \p endpt_name is set, client names are |
| 79 | * unique disregarding their protocol. |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 80 | * @return 0 on success, -1 on error. |
| 81 | */ |
Michal Vasko | adf30f0 | 2019-06-24 09:34:47 +0200 | [diff] [blame] | 82 | int nc_server_ch_client_del_endpt(const char *client_name, const char *endpt_name, NC_TRANSPORT_IMPL ti); |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 83 | |
| 84 | /** |
Michal Vasko | fb1724b | 2020-01-31 11:02:00 +0100 | [diff] [blame] | 85 | * @brief Check if an endpoint of a Call Home client exists. |
| 86 | * |
| 87 | * @param[in] client_name Client name. |
| 88 | * @param[in] endpt_name Endpoint name. |
| 89 | * @return 0 if does not exists, non-zero otherwise. |
| 90 | */ |
| 91 | int nc_server_ch_client_is_endpt(const char *client_name, const char *endpt_name); |
| 92 | |
| 93 | /** |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 94 | * @brief Change Call Home client endpoint listening address. |
| 95 | * |
| 96 | * On error the previous listening socket (if any) is left untouched. |
| 97 | * |
| 98 | * @param[in] client_name Existing Call Home client name. |
| 99 | * @param[in] endpt_name Existing endpoint name of \p client_name. |
| 100 | * @param[in] address New listening address. |
| 101 | * @return 0 on success, -1 on error. |
| 102 | */ |
| 103 | int nc_server_ch_client_endpt_set_address(const char *client_name, const char *endpt_name, const char *address); |
| 104 | |
| 105 | /** |
| 106 | * @brief Change Call Home client endpoint listening port. |
| 107 | * |
| 108 | * On error the previous listening socket (if any) is left untouched. |
| 109 | * |
| 110 | * @param[in] client_name Existing Call Home client name. |
| 111 | * @param[in] endpt_name Existing endpoint name of \p client_name. |
| 112 | * @param[in] port New listening port. |
| 113 | * @return 0 on success, -1 on error. |
| 114 | */ |
| 115 | int nc_server_ch_client_endpt_set_port(const char *client_name, const char *endpt_name, uint16_t port); |
| 116 | |
| 117 | /** |
Michal Vasko | e49a15f | 2019-05-27 14:18:36 +0200 | [diff] [blame] | 118 | * @brief Change Call Home client endpoint keepalives state. Affects only new connections. |
| 119 | * |
| 120 | * @param[in] client_name Existing Call Home client name. |
| 121 | * @param[in] endpt_name Existing endpoint name of \p client_name. |
| 122 | * @param[in] enable Whether to enable or disable keepalives. |
| 123 | * @return 0 on success, -1 on error. |
| 124 | */ |
| 125 | int nc_server_ch_client_endpt_enable_keepalives(const char *client_name, const char *endpt_name, int enable); |
| 126 | |
| 127 | /** |
| 128 | * @brief Change Call Home client endpoint keepalives parameters. Affects only new connections. |
| 129 | * |
| 130 | * @param[in] client_name Existing Call Home client name. |
| 131 | * @param[in] endpt_name Existing endpoint name of \p client_name. |
| 132 | * @param[in] idle_time Keepalive idle time in seconds, 1 by default, -1 to keep previous value. |
| 133 | * @param[in] max_probes Keepalive max probes sent, 10 by default, -1 to keep previous value. |
| 134 | * @param[in] probe_interval Keepalive probe interval in seconds, 5 by default, -1 to keep previous value. |
| 135 | * @return 0 on success, -1 on error. |
| 136 | */ |
| 137 | int nc_server_ch_client_endpt_set_keepalives(const char *client_name, const char *endpt_name, int idle_time, |
| 138 | int max_probes, int probe_interval); |
| 139 | |
| 140 | /** |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 141 | * @brief Set Call Home client connection type. |
| 142 | * |
| 143 | * @param[in] client_name Existing Call Home client name. |
| 144 | * @param[in] conn_type Call Home connection type. |
| 145 | * @return 0 on success, -1 on error. |
| 146 | */ |
| 147 | int nc_server_ch_client_set_conn_type(const char *client_name, NC_CH_CONN_TYPE conn_type); |
| 148 | |
| 149 | /** |
Michal Vasko | e49a15f | 2019-05-27 14:18:36 +0200 | [diff] [blame] | 150 | * @brief Set Call Home client periodic connection period for reconnecting. |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 151 | * |
| 152 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | e49a15f | 2019-05-27 14:18:36 +0200 | [diff] [blame] | 153 | * @param[in] period Call Home periodic connection period in minutes. |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 154 | * @return 0 on success, -1 on error. |
| 155 | */ |
Michal Vasko | e49a15f | 2019-05-27 14:18:36 +0200 | [diff] [blame] | 156 | int nc_server_ch_client_periodic_set_period(const char *client_name, uint16_t period); |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 157 | |
| 158 | /** |
Michal Vasko | e49a15f | 2019-05-27 14:18:36 +0200 | [diff] [blame] | 159 | * @brief Set Call Home client periodic connection period anchor time. |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 160 | * |
| 161 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | e49a15f | 2019-05-27 14:18:36 +0200 | [diff] [blame] | 162 | * @param[in] anchor_time Call Home periodic connection anchor time for the period. |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 163 | * @return 0 on success, -1 on error. |
| 164 | */ |
Michal Vasko | e49a15f | 2019-05-27 14:18:36 +0200 | [diff] [blame] | 165 | int nc_server_ch_client_periodic_set_anchor_time(const char *client_name, time_t anchor_time); |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 166 | |
| 167 | /** |
| 168 | * @brief Set Call Home client periodic connection idle timeout. |
| 169 | * |
| 170 | * @param[in] client_name Existing Call Home client name. |
| 171 | * @param[in] idle_timeout Call Home periodic idle timeout. |
| 172 | * @return 0 on success, -1 on error. |
| 173 | */ |
Michal Vasko | e49a15f | 2019-05-27 14:18:36 +0200 | [diff] [blame] | 174 | int nc_server_ch_client_periodic_set_idle_timeout(const char *client_name, uint16_t idle_timeout); |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 175 | |
| 176 | /** |
| 177 | * @brief Set Call Home client start-with policy. |
| 178 | * |
| 179 | * @param[in] client_name Existing Call Home client name. |
| 180 | * @param[in] start_with Call Home client start-with. |
| 181 | * @return 0 on success, -1 on error. |
| 182 | */ |
| 183 | int nc_server_ch_client_set_start_with(const char *client_name, NC_CH_START_WITH start_with); |
| 184 | |
| 185 | /** |
| 186 | * @brief Set Call Home client overall max attempts. |
| 187 | * |
| 188 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | 50d2a5c | 2017-02-14 10:29:49 +0100 | [diff] [blame] | 189 | * @param[in] max_attempts Call Home overall max reconnect attempts. |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 190 | * @return 0 on success, -1 on error. |
| 191 | */ |
| 192 | int nc_server_ch_client_set_max_attempts(const char *client_name, uint8_t max_attempts); |
| 193 | |
| 194 | /** |
| 195 | * @brief Establish a Call Home connection with a listening NETCONF client. |
| 196 | * |
| 197 | * @param[in] client_name Existing client name. |
| 198 | * @param[out] session_clb Function that is called for every established session on the client. \p new_session |
| 199 | * pointer is internally discarded afterwards. |
| 200 | * @return 0 if the thread was successfully created, -1 on error. |
| 201 | */ |
| 202 | int nc_connect_ch_client_dispatch(const char *client_name, |
Michal Vasko | adf30f0 | 2019-06-24 09:34:47 +0200 | [diff] [blame] | 203 | void (*session_clb)(const char *client_name, struct nc_session *new_session)); |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 204 | |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 205 | /** @} Server-side Call Home */ |
| 206 | |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 207 | #endif /* NC_ENABLED_SSH || NC_ENABLED_TLS */ |
| 208 | |
| 209 | #ifdef NC_ENABLED_SSH |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 210 | |
| 211 | /** |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 212 | * @defgroup server_ch_ssh Server-side Call Home on SSH |
| 213 | * @ingroup server_ch |
| 214 | * |
| 215 | * @brief SSH settings for the Call Home functionality |
| 216 | * @{ |
| 217 | */ |
| 218 | |
| 219 | /** |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 220 | * @brief Add Call Home SSH host keys the server will identify itself with. Only the name is set, the key itself |
| 221 | * wil be retrieved using a callback. |
Michal Vasko | e2713da | 2016-08-22 16:06:40 +0200 | [diff] [blame] | 222 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 223 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | adf30f0 | 2019-06-24 09:34:47 +0200 | [diff] [blame] | 224 | * @param[in] endpt_name Existing endpoint name of the client. |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 225 | * @param[in] name Arbitrary name of the host key. |
Michal Vasko | 7d25588 | 2017-02-09 13:35:08 +0100 | [diff] [blame] | 226 | * @param[in] idx Optional index where to add the key. -1 adds at the end. |
Michal Vasko | e2713da | 2016-08-22 16:06:40 +0200 | [diff] [blame] | 227 | * @return 0 on success, -1 on error. |
| 228 | */ |
Michal Vasko | adf30f0 | 2019-06-24 09:34:47 +0200 | [diff] [blame] | 229 | int nc_server_ssh_ch_client_endpt_add_hostkey(const char *client_name, const char *endpt_name, const char *name, int16_t idx); |
Michal Vasko | e2713da | 2016-08-22 16:06:40 +0200 | [diff] [blame] | 230 | |
| 231 | /** |
| 232 | * @brief Delete Call Home SSH host keys. Their order is preserved. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 233 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 234 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | adf30f0 | 2019-06-24 09:34:47 +0200 | [diff] [blame] | 235 | * @param[in] endpt_name Existing endpoint name of the client. |
Michal Vasko | 7d25588 | 2017-02-09 13:35:08 +0100 | [diff] [blame] | 236 | * @param[in] name Name of the host key. NULL matches all the keys, but if \p idx != -1 then this must be NULL. |
| 237 | * @param[in] idx Index of the hostkey. -1 matches all indices, but if \p name != NULL then this must be -1. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 238 | * @return 0 on success, -1 on error. |
| 239 | */ |
Michal Vasko | adf30f0 | 2019-06-24 09:34:47 +0200 | [diff] [blame] | 240 | int nc_server_ssh_ch_client_endpt_del_hostkey(const char *client_name, const char *endpt_name, const char *name, int16_t idx); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 241 | |
| 242 | /** |
Michal Vasko | fbfe8b6 | 2017-02-14 10:22:30 +0100 | [diff] [blame] | 243 | * @brief Move Call Home SSH host key. |
| 244 | * |
Michal Vasko | 50d2a5c | 2017-02-14 10:29:49 +0100 | [diff] [blame] | 245 | * @param[in] client_name Exisitng Call Home client name. |
Michal Vasko | adf30f0 | 2019-06-24 09:34:47 +0200 | [diff] [blame] | 246 | * @param[in] endpt_name Existing endpoint name of the client. |
Michal Vasko | fbfe8b6 | 2017-02-14 10:22:30 +0100 | [diff] [blame] | 247 | * @param[in] key_mov Name of the host key that will be moved. |
| 248 | * @param[in] key_after Name of the key that will preceed \p key_mov. NULL if \p key_mov is to be moved at the beginning. |
| 249 | * @return 0 in success, -1 on error. |
| 250 | */ |
Michal Vasko | adf30f0 | 2019-06-24 09:34:47 +0200 | [diff] [blame] | 251 | int nc_server_ssh_ch_client_endpt_mov_hostkey(const char *client_name, const char *endpt_name, const char *key_mov, |
| 252 | const char *key_after); |
Michal Vasko | fbfe8b6 | 2017-02-14 10:22:30 +0100 | [diff] [blame] | 253 | |
| 254 | /** |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 255 | * @brief Set accepted Call Home SSH authentication methods. All (publickey, password, interactive) |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 256 | * are supported by default. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 257 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 258 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | adf30f0 | 2019-06-24 09:34:47 +0200 | [diff] [blame] | 259 | * @param[in] endpt_name Existing endpoint name of the client. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 260 | * @param[in] auth_methods Accepted authentication methods bit field of NC_SSH_AUTH_TYPE. |
| 261 | * @return 0 on success, -1 on error. |
| 262 | */ |
Michal Vasko | adf30f0 | 2019-06-24 09:34:47 +0200 | [diff] [blame] | 263 | int nc_server_ssh_ch_client_endpt_set_auth_methods(const char *client_name, const char *endpt_name, int auth_methods); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 264 | |
| 265 | /** |
Michal Vasko | ddce121 | 2019-05-24 09:58:49 +0200 | [diff] [blame] | 266 | * @brief Get accepted Call Home SSH authentication methods. |
| 267 | * |
| 268 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | adf30f0 | 2019-06-24 09:34:47 +0200 | [diff] [blame] | 269 | * @param[in] endpt_name Existing endpoint name of the client. |
Michal Vasko | ddce121 | 2019-05-24 09:58:49 +0200 | [diff] [blame] | 270 | * @return Accepted authentication methods bit field of NC_SSH_AUTH_TYPE. |
| 271 | */ |
Michal Vasko | adf30f0 | 2019-06-24 09:34:47 +0200 | [diff] [blame] | 272 | int nc_server_ssh_ch_client_endpt_get_auth_methods(const char *client_name, const char *endpt_name); |
Michal Vasko | ddce121 | 2019-05-24 09:58:49 +0200 | [diff] [blame] | 273 | |
| 274 | /** |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 275 | * @brief Set Call Home SSH authentication attempts of every client. 3 by default. |
| 276 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 277 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | adf30f0 | 2019-06-24 09:34:47 +0200 | [diff] [blame] | 278 | * @param[in] endpt_name Existing endpoint name of the client. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 279 | * @param[in] auth_attempts Failed authentication attempts before a client is dropped. |
| 280 | * @return 0 on success, -1 on error. |
| 281 | */ |
Michal Vasko | adf30f0 | 2019-06-24 09:34:47 +0200 | [diff] [blame] | 282 | int nc_server_ssh_ch_client_endpt_set_auth_attempts(const char *client_name, const char *endpt_name, uint16_t auth_attempts); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 283 | |
| 284 | /** |
Michal Vasko | cbad4c5 | 2019-06-27 16:30:35 +0200 | [diff] [blame] | 285 | * @brief Set Call Home SSH authentication timeout. 30 seconds by default. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 286 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 287 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | adf30f0 | 2019-06-24 09:34:47 +0200 | [diff] [blame] | 288 | * @param[in] endpt_name Existing endpoint name of the client. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 289 | * @param[in] auth_timeout Number of seconds before an unauthenticated client is dropped. |
| 290 | * @return 0 on success, -1 on error. |
| 291 | */ |
Michal Vasko | adf30f0 | 2019-06-24 09:34:47 +0200 | [diff] [blame] | 292 | int nc_server_ssh_ch_client_endpt_set_auth_timeout(const char *client_name, const char *endpt_name, uint16_t auth_timeout); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 293 | |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 294 | /** @} Server-side Call Home on SSH */ |
| 295 | |
Radek Krejci | 53691be | 2016-02-22 13:58:37 +0100 | [diff] [blame] | 296 | #endif /* NC_ENABLED_SSH */ |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 297 | |
Radek Krejci | 53691be | 2016-02-22 13:58:37 +0100 | [diff] [blame] | 298 | #ifdef NC_ENABLED_TLS |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 299 | |
| 300 | /** |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 301 | * @defgroup server_ch_tls Server-side Call Home on TLS |
| 302 | * @ingroup server_ch |
| 303 | * |
| 304 | * @brief TLS settings for the Call Home functionality |
| 305 | * @{ |
| 306 | */ |
| 307 | |
| 308 | /** |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 309 | * @brief Set the server Call Home TLS certificate. Only the name is set, the certificate itself |
| 310 | * wil be retrieved using a callback. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 311 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 312 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | adf30f0 | 2019-06-24 09:34:47 +0200 | [diff] [blame] | 313 | * @param[in] endpt_name Existing endpoint name of the client. |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 314 | * @param[in] name Arbitrary certificate name. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 315 | * @return 0 on success, -1 on error. |
| 316 | */ |
Michal Vasko | adf30f0 | 2019-06-24 09:34:47 +0200 | [diff] [blame] | 317 | int nc_server_tls_ch_client_endpt_set_server_cert(const char *client_name, const char *endpt_name, const char *name); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 318 | |
| 319 | /** |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 320 | * @brief Add a Call Home trusted certificate list. Can be both a CA or a client one. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 321 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 322 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | adf30f0 | 2019-06-24 09:34:47 +0200 | [diff] [blame] | 323 | * @param[in] endpt_name Existing endpoint name of the client. |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 324 | * @param[in] name Arbitary name identifying this certificate list. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 325 | * @return 0 on success, -1 on error. |
| 326 | */ |
Michal Vasko | adf30f0 | 2019-06-24 09:34:47 +0200 | [diff] [blame] | 327 | int nc_server_tls_ch_client_endpt_add_trusted_cert_list(const char *client_name, const char *endpt_name, const char *name); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 328 | |
| 329 | /** |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 330 | * @brief Remove a set Call Home trusted certificate list. CRLs and CTN entries are not affected. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 331 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 332 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | adf30f0 | 2019-06-24 09:34:47 +0200 | [diff] [blame] | 333 | * @param[in] endpt_name Existing endpoint name of the client. |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 334 | * @param[in] name Name of the certificate list to delete. NULL deletes all the lists. |
| 335 | * @return 0 on success, -1 on not found. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 336 | */ |
Michal Vasko | adf30f0 | 2019-06-24 09:34:47 +0200 | [diff] [blame] | 337 | int nc_server_tls_ch_client_endpt_del_trusted_cert_list(const char *client_name, const char *endpt_name, const char *name); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 338 | |
| 339 | /** |
| 340 | * @brief Set trusted Call Home Certificate Authority certificate locations. There |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 341 | * can only be one file and one directory, they are replaced if already set. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 342 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 343 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | adf30f0 | 2019-06-24 09:34:47 +0200 | [diff] [blame] | 344 | * @param[in] endpt_name Existing endpoint name of the client. |
Michal Vasko | b34b3e8 | 2016-02-26 15:04:58 +0100 | [diff] [blame] | 345 | * @param[in] ca_file Path to a trusted CA cert store file in PEM format. |
| 346 | * Can be NULL. |
| 347 | * @param[in] ca_dir Path to a trusted CA cert store hashed directory |
| 348 | * (c_rehash utility can be used to create hashes) |
| 349 | * with PEM files. Can be NULL. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 350 | * @return 0 on success, -1 on error. |
| 351 | */ |
Michal Vasko | adf30f0 | 2019-06-24 09:34:47 +0200 | [diff] [blame] | 352 | int nc_server_tls_ch_client_endpt_set_trusted_ca_paths(const char *client_name, const char *endpt_name, const char *ca_file, |
| 353 | const char *ca_dir); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 354 | |
| 355 | /** |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 356 | * @brief Set Call Home Certificate Revocation List locations. There can only be |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 357 | * one file and one directory, they are replaced if already set. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 358 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 359 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | adf30f0 | 2019-06-24 09:34:47 +0200 | [diff] [blame] | 360 | * @param[in] endpt_name Existing endpoint name of the client. |
Michal Vasko | b34b3e8 | 2016-02-26 15:04:58 +0100 | [diff] [blame] | 361 | * @param[in] crl_file Path to a CRL store file in PEM format. Can be NULL. |
| 362 | * @param[in] crl_dir Path to a CRL store hashed directory (c_rehash utility |
| 363 | * can be used to create hashes) with PEM files. Can be NULL. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 364 | * @return 0 on success, -1 on error. |
| 365 | */ |
Michal Vasko | adf30f0 | 2019-06-24 09:34:47 +0200 | [diff] [blame] | 366 | int nc_server_tls_ch_client_endpt_set_crl_paths(const char *client_name, const char *endpt_name, const char *crl_file, |
| 367 | const char *crl_dir); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 368 | |
| 369 | /** |
| 370 | * @brief Destroy and clean Call Home CRLs. Call Home certificates, private keys, |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 371 | * and CTN entries are not affected. |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 372 | * |
| 373 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | adf30f0 | 2019-06-24 09:34:47 +0200 | [diff] [blame] | 374 | * @param[in] endpt_name Existing endpoint name of the client. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 375 | */ |
Michal Vasko | adf30f0 | 2019-06-24 09:34:47 +0200 | [diff] [blame] | 376 | void nc_server_tls_ch_client_endpt_clear_crls(const char *client_name, const char *endpt_name); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 377 | |
| 378 | /** |
Michal Vasko | 3cf4aaa | 2017-02-01 15:03:36 +0100 | [diff] [blame] | 379 | * @brief Add a cert-to-name entry. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 380 | * |
Michal Vasko | 3cf4aaa | 2017-02-01 15:03:36 +0100 | [diff] [blame] | 381 | * It is possible to add an entry step-by-step, specifying first only \p ip and in later calls |
| 382 | * \p fingerprint, \p map_type, and optionally \p name spearately. |
| 383 | * |
Michal Vasko | 50d2a5c | 2017-02-14 10:29:49 +0100 | [diff] [blame] | 384 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | adf30f0 | 2019-06-24 09:34:47 +0200 | [diff] [blame] | 385 | * @param[in] endpt_name Existing endpoint name of the client. |
Michal Vasko | 3cf4aaa | 2017-02-01 15:03:36 +0100 | [diff] [blame] | 386 | * @param[in] id Priority of the entry. It must be unique. If already exists, the entry with this id |
| 387 | * is modified. |
| 388 | * @param[in] fingerprint Matching certificate fingerprint. If NULL, kept temporarily unset. |
| 389 | * @param[in] map_type Type of username-certificate mapping. If 0, kept temporarily unset. |
| 390 | * @param[in] name Specific username used only if \p map_type == NC_TLS_CTN_SPECIFED. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 391 | * @return 0 on success, -1 on error. |
| 392 | */ |
Michal Vasko | adf30f0 | 2019-06-24 09:34:47 +0200 | [diff] [blame] | 393 | int nc_server_tls_ch_client_endpt_add_ctn(const char *client_name, const char *endpt_name, uint32_t id, |
| 394 | const char *fingerprint, NC_TLS_CTN_MAPTYPE map_type, const char *name); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 395 | |
| 396 | /** |
Michal Vasko | 58c22a2 | 2016-11-23 13:49:53 +0100 | [diff] [blame] | 397 | * @brief Remove a Call Home cert-to-name entry. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 398 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 399 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | adf30f0 | 2019-06-24 09:34:47 +0200 | [diff] [blame] | 400 | * @param[in] endpt_name Existing endpoint name of the client. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 401 | * @param[in] id Priority of the entry. -1 matches all the priorities. |
| 402 | * @param[in] fingerprint Fingerprint fo the entry. NULL matches all the fingerprints. |
| 403 | * @param[in] map_type Mapping type of the entry. 0 matches all the mapping types. |
| 404 | * @param[in] name Specific username for the entry. NULL matches all the usernames. |
| 405 | * @return 0 on success, -1 on not finding any match. |
| 406 | */ |
Michal Vasko | adf30f0 | 2019-06-24 09:34:47 +0200 | [diff] [blame] | 407 | int nc_server_tls_ch_client_endpt_del_ctn(const char *client_name, const char *endpt_name, int64_t id, |
| 408 | const char *fingerprint, NC_TLS_CTN_MAPTYPE map_type, const char *name); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 409 | |
Michal Vasko | df5e6af | 2016-11-23 13:50:56 +0100 | [diff] [blame] | 410 | /** |
| 411 | * @brief Get a Call Home cert-to-name entry. |
| 412 | * |
| 413 | * If a parameter is NULL, it is ignored. If its dereferenced value is NULL, |
| 414 | * it is filled and returned. If the value is set, it is used as a filter. |
| 415 | * Returns first matching entry. |
| 416 | * |
| 417 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | adf30f0 | 2019-06-24 09:34:47 +0200 | [diff] [blame] | 418 | * @param[in] endpt_name Existing endpoint name of the client. |
Michal Vasko | df5e6af | 2016-11-23 13:50:56 +0100 | [diff] [blame] | 419 | * @param[in,out] id Priority of the entry. |
| 420 | * @param[in,out] fingerprint Fingerprint fo the entry. |
| 421 | * @param[in,out] map_type Mapping type of the entry. |
| 422 | * @param[in,out] name Specific username for the entry. |
| 423 | * @return 0 on success, -1 on not finding any match. |
| 424 | */ |
Michal Vasko | adf30f0 | 2019-06-24 09:34:47 +0200 | [diff] [blame] | 425 | int nc_server_tls_ch_client_endpt_get_ctn(const char *client_name, const char *endpt_name, uint32_t *id, char **fingerprint, |
| 426 | NC_TLS_CTN_MAPTYPE *map_type, char **name); |
Michal Vasko | df5e6af | 2016-11-23 13:50:56 +0100 | [diff] [blame] | 427 | |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 428 | /** @} Server-side Call Home on TLS */ |
| 429 | |
Radek Krejci | 53691be | 2016-02-22 13:58:37 +0100 | [diff] [blame] | 430 | #endif /* NC_ENABLED_TLS */ |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 431 | |
Michal Vasko | c09730e | 2019-01-17 10:07:26 +0100 | [diff] [blame] | 432 | #ifdef __cplusplus |
| 433 | } |
| 434 | #endif |
| 435 | |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 436 | #endif /* NC_SESSION_SERVER_CH_H_ */ |