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 | |
| 18 | #include <stdint.h> |
| 19 | #include <libyang/libyang.h> |
| 20 | |
| 21 | #include "session.h" |
| 22 | #include "netconf.h" |
| 23 | |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 24 | #if defined(NC_ENABLED_SSH) || defined(NC_ENABLED_TLS) |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 25 | |
| 26 | /** |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 27 | * @brief Add a new Call Home client. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 28 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 29 | * @param[in] name Arbitrary unique client name. |
| 30 | * @param[in] ti Transport protocol to use. |
| 31 | * @return 0 on success, -1 on error. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 32 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 33 | int nc_server_ch_add_client(const char *name, NC_TRANSPORT_IMPL ti); |
| 34 | |
| 35 | /** |
| 36 | * @brief Drop any connections, stop connecting and remove a client. |
| 37 | * |
| 38 | * @param[in] name Client name. NULL matches all the clients. |
Michal Vasko | 5905037 | 2016-11-22 14:33:55 +0100 | [diff] [blame] | 39 | * @param[in] ti Client transport protocol. NULL matches any protocol. |
| 40 | * Redundant to set if \p name is set, client names are |
| 41 | * unique disregarding their protocol. |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 42 | * @return 0 on success, -1 on not finding any match. |
| 43 | */ |
Michal Vasko | 5905037 | 2016-11-22 14:33:55 +0100 | [diff] [blame] | 44 | int nc_server_ch_del_client(const char *name, NC_TRANSPORT_IMPL ti); |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 45 | |
| 46 | /** |
| 47 | * @brief Add a new Call Home client endpoint. |
| 48 | * |
| 49 | * @param[in] client_name Existing client name. |
| 50 | * @param[in] endpt_name Arbitrary unique (within the client) endpoint name. |
| 51 | * @return 0 on success, -1 on error. |
| 52 | */ |
| 53 | int nc_server_ch_client_add_endpt(const char *client_name, const char *endpt_name); |
| 54 | |
| 55 | /** |
| 56 | * @brief Remove a Call Home client endpoint. |
| 57 | * |
| 58 | * @param[in] client_name Existing client name. |
| 59 | * @param[in] endpt_name Existing endpoint of \p client_name. NULL matches all endpoints. |
| 60 | * @return 0 on success, -1 on error. |
| 61 | */ |
| 62 | int nc_server_ch_client_del_endpt(const char *client_name, const char *endpt_name); |
| 63 | |
| 64 | /** |
| 65 | * @brief Change Call Home client endpoint listening address. |
| 66 | * |
| 67 | * On error the previous listening socket (if any) is left untouched. |
| 68 | * |
| 69 | * @param[in] client_name Existing Call Home client name. |
| 70 | * @param[in] endpt_name Existing endpoint name of \p client_name. |
| 71 | * @param[in] address New listening address. |
| 72 | * @return 0 on success, -1 on error. |
| 73 | */ |
| 74 | int nc_server_ch_client_endpt_set_address(const char *client_name, const char *endpt_name, const char *address); |
| 75 | |
| 76 | /** |
| 77 | * @brief Change Call Home client endpoint listening port. |
| 78 | * |
| 79 | * On error the previous listening socket (if any) is left untouched. |
| 80 | * |
| 81 | * @param[in] client_name Existing Call Home client name. |
| 82 | * @param[in] endpt_name Existing endpoint name of \p client_name. |
| 83 | * @param[in] port New listening port. |
| 84 | * @return 0 on success, -1 on error. |
| 85 | */ |
| 86 | int nc_server_ch_client_endpt_set_port(const char *client_name, const char *endpt_name, uint16_t port); |
| 87 | |
| 88 | /** |
| 89 | * @brief Set Call Home client connection type. |
| 90 | * |
| 91 | * @param[in] client_name Existing Call Home client name. |
| 92 | * @param[in] conn_type Call Home connection type. |
| 93 | * @return 0 on success, -1 on error. |
| 94 | */ |
| 95 | int nc_server_ch_client_set_conn_type(const char *client_name, NC_CH_CONN_TYPE conn_type); |
| 96 | |
| 97 | /** |
| 98 | * @brief Set Call Home client persistent connection idle timeout. |
| 99 | * |
| 100 | * @param[in] client_name Existing Call Home client name. |
| 101 | * @param[in] idle_timeout Call Home persistent idle timeout. |
| 102 | * @return 0 on success, -1 on error. |
| 103 | */ |
| 104 | int nc_server_ch_client_persist_set_idle_timeout(const char *client_name, uint32_t idle_timeout); |
| 105 | |
| 106 | /** |
| 107 | * @brief Set Call Home client persistent connection keep-alive max wait time. |
| 108 | * |
| 109 | * @param[in] client_name Existing Call Home client name. |
| 110 | * @param[in] max_wait Call Home persistent max wait time for keep-alive reply. |
| 111 | * @return 0 on success, -1 on error. |
| 112 | */ |
| 113 | int nc_server_ch_client_persist_set_keep_alive_max_wait(const char *client_name, uint16_t max_wait); |
| 114 | |
| 115 | /** |
| 116 | * @brief Set Call Home client persistent connection keep-alive max attempts. |
| 117 | * |
| 118 | * @param[in] client_name Existing Call Home client name. |
| 119 | * @param[in] max_attempts Call Home persistent keep-alive maximum contact attempts. |
| 120 | * @return 0 on success, -1 on error. |
| 121 | */ |
| 122 | int nc_server_ch_client_persist_set_keep_alive_max_attempts(const char *client_name, uint8_t max_attempts); |
| 123 | |
| 124 | /** |
| 125 | * @brief Set Call Home client periodic connection idle timeout. |
| 126 | * |
| 127 | * @param[in] client_name Existing Call Home client name. |
| 128 | * @param[in] idle_timeout Call Home periodic idle timeout. |
| 129 | * @return 0 on success, -1 on error. |
| 130 | */ |
| 131 | int nc_server_ch_client_period_set_idle_timeout(const char *client_name, uint16_t idle_timeout); |
| 132 | |
| 133 | /** |
| 134 | * @brief Set Call Home client periodic reconnect timeout. |
| 135 | * |
| 136 | * @param[in] client_name Existing Call Home client name. |
| 137 | * @param[in] reconnect_timeout Call Home periodic reconnect timeout. |
| 138 | * @return 0 on success, -1 on error. |
| 139 | */ |
| 140 | int nc_server_ch_client_period_set_reconnect_timeout(const char *client_name, uint16_t reconnect_timeout); |
| 141 | |
| 142 | /** |
| 143 | * @brief Set Call Home client start-with policy. |
| 144 | * |
| 145 | * @param[in] client_name Existing Call Home client name. |
| 146 | * @param[in] start_with Call Home client start-with. |
| 147 | * @return 0 on success, -1 on error. |
| 148 | */ |
| 149 | int nc_server_ch_client_set_start_with(const char *client_name, NC_CH_START_WITH start_with); |
| 150 | |
| 151 | /** |
| 152 | * @brief Set Call Home client overall max attempts. |
| 153 | * |
| 154 | * @param[in] client_name Existing Call Home client name. |
| 155 | * @param[in] conn_type Call Home overall max reconnect attempts. |
| 156 | * @return 0 on success, -1 on error. |
| 157 | */ |
| 158 | int nc_server_ch_client_set_max_attempts(const char *client_name, uint8_t max_attempts); |
| 159 | |
| 160 | /** |
| 161 | * @brief Establish a Call Home connection with a listening NETCONF client. |
| 162 | * |
| 163 | * @param[in] client_name Existing client name. |
| 164 | * @param[out] session_clb Function that is called for every established session on the client. \p new_session |
| 165 | * pointer is internally discarded afterwards. |
| 166 | * @return 0 if the thread was successfully created, -1 on error. |
| 167 | */ |
| 168 | int nc_connect_ch_client_dispatch(const char *client_name, |
| 169 | void (*session_clb)(const char *client_name, struct nc_session *new_session)); |
| 170 | |
| 171 | #endif /* NC_ENABLED_SSH || NC_ENABLED_TLS */ |
| 172 | |
| 173 | #ifdef NC_ENABLED_SSH |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 174 | |
| 175 | /** |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 176 | * @brief Add Call Home SSH host keys the server will identify itself with. Only the name is set, the key itself |
| 177 | * wil be retrieved using a callback. |
Michal Vasko | e2713da | 2016-08-22 16:06:40 +0200 | [diff] [blame] | 178 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 179 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 180 | * @param[in] name Arbitrary name of the host key. |
Michal Vasko | e2713da | 2016-08-22 16:06:40 +0200 | [diff] [blame] | 181 | * @return 0 on success, -1 on error. |
| 182 | */ |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 183 | int nc_server_ssh_ch_client_add_hostkey(const char *client_name, const char *name); |
Michal Vasko | e2713da | 2016-08-22 16:06:40 +0200 | [diff] [blame] | 184 | |
| 185 | /** |
| 186 | * @brief Delete Call Home SSH host keys. Their order is preserved. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 187 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 188 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 189 | * @param[in] name Name of the host key. NULL matches all the keys. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 190 | * @return 0 on success, -1 on error. |
| 191 | */ |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 192 | int nc_server_ssh_ch_client_del_hostkey(const char *client_name, const char *name); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 193 | |
| 194 | /** |
| 195 | * @brief Set Call Home SSH banner the server will send to every client. |
| 196 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 197 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 198 | * @param[in] banner SSH banner. |
| 199 | * @return 0 on success, -1 on error. |
| 200 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 201 | int nc_server_ssh_ch_client_set_banner(const char *client_name, const char *banner); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 202 | |
| 203 | /** |
| 204 | * @brief Set accepted Call Home SSH authentication methods. All (publickey, password, interactive) |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 205 | * are supported by default. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 206 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 207 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 208 | * @param[in] auth_methods Accepted authentication methods bit field of NC_SSH_AUTH_TYPE. |
| 209 | * @return 0 on success, -1 on error. |
| 210 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 211 | int nc_server_ssh_ch_client_set_auth_methods(const char *client_name, int auth_methods); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 212 | |
| 213 | /** |
| 214 | * @brief Set Call Home SSH authentication attempts of every client. 3 by default. |
| 215 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 216 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 217 | * @param[in] auth_attempts Failed authentication attempts before a client is dropped. |
| 218 | * @return 0 on success, -1 on error. |
| 219 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 220 | int nc_server_ssh_ch_client_set_auth_attempts(const char *client_name, uint16_t auth_attempts); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 221 | |
| 222 | /** |
| 223 | * @brief Set Call Home SSH authentication timeout. 10 seconds by default. |
| 224 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 225 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 226 | * @param[in] auth_timeout Number of seconds before an unauthenticated client is dropped. |
| 227 | * @return 0 on success, -1 on error. |
| 228 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 229 | int nc_server_ssh_ch_client_set_auth_timeout(const char *client_name, uint16_t auth_timeout); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 230 | |
Radek Krejci | 53691be | 2016-02-22 13:58:37 +0100 | [diff] [blame] | 231 | #endif /* NC_ENABLED_SSH */ |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 232 | |
Radek Krejci | 53691be | 2016-02-22 13:58:37 +0100 | [diff] [blame] | 233 | #ifdef NC_ENABLED_TLS |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 234 | |
| 235 | /** |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 236 | * @brief Set the server Call Home TLS certificate. Only the name is set, the certificate itself |
| 237 | * wil be retrieved using a callback. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 238 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 239 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 240 | * @param[in] name Arbitrary certificate name. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 241 | * @return 0 on success, -1 on error. |
| 242 | */ |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 243 | int nc_server_tls_ch_client_set_server_cert(const char *client_name, const char *name); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 244 | |
| 245 | /** |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 246 | * @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] | 247 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 248 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 249 | * @param[in] name Arbitary name identifying this certificate list. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 250 | * @return 0 on success, -1 on error. |
| 251 | */ |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 252 | int nc_server_tls_ch_client_add_trusted_cert_list(const char *client_name, const char *name); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 253 | |
| 254 | /** |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 255 | * @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] | 256 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 257 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 258 | * @param[in] name Name of the certificate list to delete. NULL deletes all the lists. |
| 259 | * @return 0 on success, -1 on not found. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 260 | */ |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 261 | int nc_server_tls_ch_client_del_trusted_cert_list(const char *client_name, const char *name); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 262 | |
| 263 | /** |
| 264 | * @brief Set trusted Call Home Certificate Authority certificate locations. There |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 265 | * 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] | 266 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 267 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | b34b3e8 | 2016-02-26 15:04:58 +0100 | [diff] [blame] | 268 | * @param[in] ca_file Path to a trusted CA cert store file in PEM format. |
| 269 | * Can be NULL. |
| 270 | * @param[in] ca_dir Path to a trusted CA cert store hashed directory |
| 271 | * (c_rehash utility can be used to create hashes) |
| 272 | * with PEM files. Can be NULL. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 273 | * @return 0 on success, -1 on error. |
| 274 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 275 | int nc_server_tls_ch_client_set_trusted_ca_paths(const char *client_name, const char *ca_file, const char *ca_dir); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 276 | |
| 277 | /** |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 278 | * @brief Set Call Home Certificate Revocation List locations. There can only be |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 279 | * one file and one directory, they are replaced if already set. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 280 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 281 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | b34b3e8 | 2016-02-26 15:04:58 +0100 | [diff] [blame] | 282 | * @param[in] crl_file Path to a CRL store file in PEM format. Can be NULL. |
| 283 | * @param[in] crl_dir Path to a CRL store hashed directory (c_rehash utility |
| 284 | * can be used to create hashes) with PEM files. Can be NULL. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 285 | * @return 0 on success, -1 on error. |
| 286 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 287 | int nc_server_tls_ch_client_set_crl_paths(const char *client_name, const char *crl_file, const char *crl_dir); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 288 | |
| 289 | /** |
| 290 | * @brief Destroy and clean Call Home CRLs. Call Home certificates, private keys, |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 291 | * and CTN entries are not affected. |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 292 | * |
| 293 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 294 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 295 | void nc_server_tls_ch_client_clear_crls(const char *client_name); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 296 | |
| 297 | /** |
Michal Vasko | 58c22a2 | 2016-11-23 13:49:53 +0100 | [diff] [blame] | 298 | * @brief Add a Call Home cert-to-name entry. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 299 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 300 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 301 | * @param[in] id Priority of the entry. |
| 302 | * @param[in] fingerprint Matching certificate fingerprint. |
| 303 | * @param[in] map_type Type of username-certificate mapping. |
| 304 | * @param[in] name Specific username if \p map_type == NC_TLS_CTN_SPECIFED. Must be NULL otherwise. |
| 305 | * @return 0 on success, -1 on error. |
| 306 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 307 | int nc_server_tls_ch_client_add_ctn(const char *client_name, uint32_t id, const char *fingerprint, |
| 308 | NC_TLS_CTN_MAPTYPE map_type, const char *name); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 309 | |
| 310 | /** |
Michal Vasko | 58c22a2 | 2016-11-23 13:49:53 +0100 | [diff] [blame] | 311 | * @brief Remove a Call Home cert-to-name entry. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 312 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 313 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 314 | * @param[in] id Priority of the entry. -1 matches all the priorities. |
| 315 | * @param[in] fingerprint Fingerprint fo the entry. NULL matches all the fingerprints. |
| 316 | * @param[in] map_type Mapping type of the entry. 0 matches all the mapping types. |
| 317 | * @param[in] name Specific username for the entry. NULL matches all the usernames. |
| 318 | * @return 0 on success, -1 on not finding any match. |
| 319 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 320 | int nc_server_tls_ch_client_del_ctn(const char *client_name, int64_t id, const char *fingerprint, |
| 321 | NC_TLS_CTN_MAPTYPE map_type, const char *name); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 322 | |
Michal Vasko | df5e6af | 2016-11-23 13:50:56 +0100 | [diff] [blame] | 323 | /** |
| 324 | * @brief Get a Call Home cert-to-name entry. |
| 325 | * |
| 326 | * If a parameter is NULL, it is ignored. If its dereferenced value is NULL, |
| 327 | * it is filled and returned. If the value is set, it is used as a filter. |
| 328 | * Returns first matching entry. |
| 329 | * |
| 330 | * @param[in] client_name Existing Call Home client name. |
| 331 | * @param[in,out] id Priority of the entry. |
| 332 | * @param[in,out] fingerprint Fingerprint fo the entry. |
| 333 | * @param[in,out] map_type Mapping type of the entry. |
| 334 | * @param[in,out] name Specific username for the entry. |
| 335 | * @return 0 on success, -1 on not finding any match. |
| 336 | */ |
Michal Vasko | f585ac7 | 2016-11-25 15:16:38 +0100 | [diff] [blame] | 337 | int nc_server_tls_ch_client_get_ctn(const char *client_name, uint32_t *id, char **fingerprint, |
| 338 | NC_TLS_CTN_MAPTYPE *map_type, char **name); |
Michal Vasko | df5e6af | 2016-11-23 13:50:56 +0100 | [diff] [blame] | 339 | |
Radek Krejci | 53691be | 2016-02-22 13:58:37 +0100 | [diff] [blame] | 340 | #endif /* NC_ENABLED_TLS */ |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 341 | |
| 342 | #endif /* NC_SESSION_SERVER_CH_H_ */ |