Michal Vasko | 086311b | 2016-01-08 09:53:11 +0100 | [diff] [blame] | 1 | /** |
| 2 | * \file session_server.h |
| 3 | * \author Michal Vasko <mvasko@cesnet.cz> |
| 4 | * \brief libnetconf2 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 | 086311b | 2016-01-08 09:53:11 +0100 | [diff] [blame] | 13 | */ |
| 14 | |
| 15 | #ifndef NC_SESSION_SERVER_H_ |
| 16 | #define NC_SESSION_SERVER_H_ |
| 17 | |
| 18 | #include <stdint.h> |
Michal Vasko | 05ba9df | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 19 | #include <libyang/libyang.h> |
Michal Vasko | 086311b | 2016-01-08 09:53:11 +0100 | [diff] [blame] | 20 | |
| 21 | #include "session.h" |
Michal Vasko | 086311b | 2016-01-08 09:53:11 +0100 | [diff] [blame] | 22 | #include "netconf.h" |
| 23 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 24 | /** |
| 25 | * @brief Prototype of callbacks that are called if some RPCs are received. |
| 26 | * |
| 27 | * If \p session termination reason is changed in the callback, one last reply |
| 28 | * is sent and then the session is considered invalid. |
| 29 | * |
| 30 | * @param[in] rpc Parsed client RPC request. |
| 31 | * @param[in] session Session the RPC arrived on. |
| 32 | * @return Server reply. If NULL, an operation-failed error will be sent to the client. |
| 33 | */ |
Michal Vasko | 05ba9df | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 34 | typedef struct nc_server_reply *(*nc_rpc_clb)(struct lyd_node *rpc, struct nc_session *session); |
| 35 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 36 | /** |
Michal Vasko | 7b09624 | 2016-01-29 15:55:10 +0100 | [diff] [blame] | 37 | * @brief Set the termination reason for a session. Use only in #nc_rpc_clb callbacks. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 38 | * |
| 39 | * @param[in] session Session to modify. |
| 40 | * @param[in] reason Reason of termination. |
| 41 | */ |
| 42 | void nc_session_set_term_reason(struct nc_session *session, NC_SESSION_TERM_REASON reason); |
| 43 | |
| 44 | /** |
Michal Vasko | a7b8ca5 | 2016-03-01 12:09:29 +0100 | [diff] [blame^] | 45 | * @brief Initialize libssh and/or libssl/libcrypto and the server using a libyang context. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 46 | * |
| 47 | * The context is not modified internally, only its dictionary is used for holding |
Michal Vasko | a43589b | 2016-02-17 13:24:59 +0100 | [diff] [blame] | 48 | * all the strings, which is thread-safe. Reading models is considered thread-safe |
| 49 | * as models cannot be removed and are rarely modified (augments or deviations). |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 50 | * |
| 51 | * Server capabilities are generated based on its content. Changing the context |
| 52 | * in ways that result in changed capabilities (adding models, changing features) |
| 53 | * is discouraged after sessions are established as it is not possible to change |
| 54 | * capabilities of a session. |
| 55 | * |
| 56 | * This context can safely be destroyed only after calling the last libnetconf2 |
| 57 | * function in an application. |
| 58 | * |
| 59 | * Supported RPCs of models in the context are expected to have the private field |
| 60 | * in the corresponding RPC schema node set to a nc_rpc_clb function callback. |
| 61 | * This callback is called by nc_ps_poll() if the particular RPC request is |
| 62 | * received. Callbacks for ietf-netconf:get-schema (supporting YANG and YIN format |
| 63 | * only) and ietf-netconf:close-session are set internally if left unset. |
| 64 | * |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 65 | * @param[in] ctx Core NETCONF server context. |
| 66 | * @return 0 on success, -1 on error. |
| 67 | */ |
Michal Vasko | 086311b | 2016-01-08 09:53:11 +0100 | [diff] [blame] | 68 | int nc_server_init(struct ly_ctx *ctx); |
| 69 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 70 | /** |
Michal Vasko | a7b8ca5 | 2016-03-01 12:09:29 +0100 | [diff] [blame^] | 71 | * @brief Destroy any dynamically allocated libssh and/or libssl/libcrypto and |
| 72 | * server resources. |
Michal Vasko | b48aa81 | 2016-01-18 14:13:09 +0100 | [diff] [blame] | 73 | */ |
| 74 | void nc_server_destroy(void); |
| 75 | |
| 76 | /** |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 77 | * @brief Set the with-defaults capability extra parameters. |
| 78 | * |
| 79 | * For the capability to be actually advertised, the server context must also |
| 80 | * include the ietf-netconf-with-defaults model. |
| 81 | * |
| 82 | * Changing this option has the same ill effects as changing capabilities while |
| 83 | * sessions are already established. |
| 84 | * |
| 85 | * @param[in] basic_mode basic-mode with-defaults parameter. |
| 86 | * @param[in] also_supported NC_WD_MODE bit array, also-supported with-defaults |
| 87 | * parameter. |
| 88 | * @return 0 on success, -1 on error. |
| 89 | */ |
Michal Vasko | 086311b | 2016-01-08 09:53:11 +0100 | [diff] [blame] | 90 | int nc_server_set_capab_withdefaults(NC_WD_MODE basic_mode, int also_supported); |
| 91 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 92 | /** |
| 93 | * @brief Set the interleave capability. |
| 94 | * |
| 95 | * For the capability to be actually advertised, the server context must also |
| 96 | * include the nc-notifications model. |
| 97 | * |
| 98 | * Changing this option has the same ill effects as changing capabilities while |
| 99 | * sessions are already established. |
| 100 | * |
| 101 | * @param[in] interleave_support 1 to suport interleave, 0 to not. |
| 102 | */ |
| 103 | void nc_server_set_capab_interleave(int interleave_support); |
Michal Vasko | 086311b | 2016-01-08 09:53:11 +0100 | [diff] [blame] | 104 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 105 | /** |
| 106 | * @brief Set server timeout for receiving a hello message. |
| 107 | * |
| 108 | * @param[in] hello_timeout Hello message timeout. 0 for infinite waiting. |
| 109 | */ |
| 110 | void nc_server_set_hello_timeout(uint16_t hello_timeout); |
Michal Vasko | 086311b | 2016-01-08 09:53:11 +0100 | [diff] [blame] | 111 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 112 | /** |
| 113 | * @brief Set server timeout for dropping an idle session. |
| 114 | * |
| 115 | * @param[in] idle_timeout Idle session timeout. 0 to never drop a session |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 116 | * because of inactivity. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 117 | */ |
| 118 | void nc_server_set_idle_timeout(uint16_t idle_timeout); |
Michal Vasko | 086311b | 2016-01-08 09:53:11 +0100 | [diff] [blame] | 119 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 120 | /** |
| 121 | * @brief Accept a new session on a pre-established transport session. |
| 122 | * |
| 123 | * @param[in] fdin File descriptor to read (unencrypted) XML data from. |
| 124 | * @param[in] fdout File descriptor to write (unencrypted) XML data to. |
| 125 | * @param[in] username NETCONF username as provided by the transport protocol. |
| 126 | * @param[out] session New session on success. |
| 127 | * @return 0 on success, -1 on error. |
| 128 | */ |
| 129 | int nc_accept_inout(int fdin, int fdout, const char *username, struct nc_session **session); |
Michal Vasko | 086311b | 2016-01-08 09:53:11 +0100 | [diff] [blame] | 130 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 131 | /** |
| 132 | * @brief Create an empty structure for polling sessions. |
| 133 | * |
| 134 | * @return Empty pollsession structure, NULL on error. |
| 135 | */ |
Michal Vasko | 05ba9df | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 136 | struct nc_pollsession *nc_ps_new(void); |
Michal Vasko | fb89d77 | 2016-01-08 12:25:35 +0100 | [diff] [blame] | 137 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 138 | /** |
| 139 | * @brief Free a pollsession structure. |
| 140 | * |
| 141 | * @param[in] ps Pollsession structure to free. |
| 142 | */ |
Michal Vasko | 05ba9df | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 143 | void nc_ps_free(struct nc_pollsession *ps); |
Michal Vasko | fb89d77 | 2016-01-08 12:25:35 +0100 | [diff] [blame] | 144 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 145 | /** |
| 146 | * @brief Add a session to a pollsession structure. |
| 147 | * |
| 148 | * @param[in] ps Pollsession structure to modify. |
| 149 | * @param[in] session Session to add to \p ps. |
| 150 | * @return 0 on success, -1 on error. |
| 151 | */ |
Michal Vasko | 05ba9df | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 152 | int nc_ps_add_session(struct nc_pollsession *ps, struct nc_session *session); |
Michal Vasko | fb89d77 | 2016-01-08 12:25:35 +0100 | [diff] [blame] | 153 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 154 | /** |
| 155 | * @brief Remove a session from a pollsession structure. |
| 156 | * |
| 157 | * @param[in] ps Pollsession structure to modify. |
| 158 | * @param[in] session Session to remove from \p ps. |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 159 | * @return 0 on success, -1 on not found. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 160 | */ |
Michal Vasko | 05ba9df | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 161 | int nc_ps_del_session(struct nc_pollsession *ps, struct nc_session *session); |
| 162 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 163 | /** |
Michal Vasko | 0fdb7ac | 2016-03-01 09:03:12 +0100 | [diff] [blame] | 164 | * @brief Learn the number of sessions in a pollsession structure. |
| 165 | * |
| 166 | * @param[in] ps Pollsession structure to check. |
| 167 | * @return Number of sessions (even invalid ones) in \p ps. |
| 168 | */ |
| 169 | uint16_t nc_ps_session_count(struct nc_pollsession *ps); |
| 170 | |
| 171 | /** |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 172 | * @brief Poll sessions and process any received RPCs. |
| 173 | * |
| 174 | * All the sessions must be running. If a session fails causing it to change its |
Michal Vasko | 96164bf | 2016-01-21 15:41:58 +0100 | [diff] [blame] | 175 | * status, it can be learnt from the return value. Only one event on one session |
| 176 | * is handled in one function call. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 177 | * |
| 178 | * @param[in] ps Pollsession structure to use. |
Michal Vasko | 11d142a | 2016-01-19 15:58:24 +0100 | [diff] [blame] | 179 | * @param[in] timeout Poll timeout in milliseconds. 0 for non-blocking call, -1 for |
Michal Vasko | 96830e3 | 2016-02-01 10:54:18 +0100 | [diff] [blame] | 180 | * infinite waiting. |
Michal Vasko | bd8ef26 | 2016-01-20 11:09:27 +0100 | [diff] [blame] | 181 | * @return 0 on elapsed timeout, |
Michal Vasko | ca4a242 | 2016-02-02 12:17:14 +0100 | [diff] [blame] | 182 | * 1 if an RPC was processed (even if it was not known - it failed to be |
| 183 | * parsed into session ctx), |
Michal Vasko | bd8ef26 | 2016-01-20 11:09:27 +0100 | [diff] [blame] | 184 | * 2 if an RPC was processed and there are unhandled events on other sessions, |
| 185 | * 3 if a session from \p ps changed its status (was invalidated), |
Michal Vasko | 8c74883 | 2016-02-03 15:32:16 +0100 | [diff] [blame] | 186 | * -1 on error (a session likely changed its status as well). |
Michal Vasko | 96164bf | 2016-01-21 15:41:58 +0100 | [diff] [blame] | 187 | * |
| 188 | * Only with SSH support: |
| 189 | * 4 if an SSH message was processed, |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 190 | * 5 if a new NETCONF SSH channel was created; call nc_ps_accept_ssh_channel() |
Michal Vasko | 96164bf | 2016-01-21 15:41:58 +0100 | [diff] [blame] | 191 | * to establish a new NETCONF session. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 192 | */ |
Michal Vasko | 05ba9df | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 193 | int nc_ps_poll(struct nc_pollsession *ps, int timeout); |
Michal Vasko | 086311b | 2016-01-08 09:53:11 +0100 | [diff] [blame] | 194 | |
Michal Vasko | 11d142a | 2016-01-19 15:58:24 +0100 | [diff] [blame] | 195 | /** |
Michal Vasko | cad3ac4 | 2016-03-01 09:06:01 +0100 | [diff] [blame] | 196 | * @brief Remove sessions from a pollsession structure and |
| 197 | * call nc_session_free() on them. |
Michal Vasko | d09eae6 | 2016-02-01 10:32:52 +0100 | [diff] [blame] | 198 | * |
Michal Vasko | cad3ac4 | 2016-03-01 09:06:01 +0100 | [diff] [blame] | 199 | * Calling this function with \p all false makes sense if nc_ps_poll() returned 3. |
Michal Vasko | d09eae6 | 2016-02-01 10:32:52 +0100 | [diff] [blame] | 200 | * |
| 201 | * @param[in] ps Pollsession structure to clear. |
Michal Vasko | cad3ac4 | 2016-03-01 09:06:01 +0100 | [diff] [blame] | 202 | * @param[in] all Whether to free all sessions, or only the invalid ones. |
Michal Vasko | d09eae6 | 2016-02-01 10:32:52 +0100 | [diff] [blame] | 203 | */ |
Michal Vasko | cad3ac4 | 2016-03-01 09:06:01 +0100 | [diff] [blame] | 204 | void nc_ps_clear(struct nc_pollsession *ps, int all); |
Michal Vasko | d09eae6 | 2016-02-01 10:32:52 +0100 | [diff] [blame] | 205 | |
Radek Krejci | 53691be | 2016-02-22 13:58:37 +0100 | [diff] [blame] | 206 | #if defined(NC_ENABLED_SSH) || defined(NC_ENABLED_TLS) |
Michal Vasko | 9e036d5 | 2016-01-08 10:49:26 +0100 | [diff] [blame] | 207 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 208 | /** |
Michal Vasko | 3031aae | 2016-01-27 16:07:18 +0100 | [diff] [blame] | 209 | * @brief Accept new sessions on all the listening endpoints. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 210 | * |
Michal Vasko | 11d142a | 2016-01-19 15:58:24 +0100 | [diff] [blame] | 211 | * @param[in] timeout Timeout for receiving a new connection in milliseconds, 0 for |
| 212 | * non-blocking call, -1 for infinite waiting. |
Michal Vasko | 96164bf | 2016-01-21 15:41:58 +0100 | [diff] [blame] | 213 | * @param[out] session New session. |
Michal Vasko | c61c449 | 2016-01-25 11:13:34 +0100 | [diff] [blame] | 214 | * @return 1 on success, 0 on timeout, -1 on error. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 215 | */ |
| 216 | int nc_accept(int timeout, struct nc_session **session); |
Michal Vasko | 9e036d5 | 2016-01-08 10:49:26 +0100 | [diff] [blame] | 217 | |
Radek Krejci | 53691be | 2016-02-22 13:58:37 +0100 | [diff] [blame] | 218 | #endif /* NC_ENABLED_SSH || NC_ENABLED_TLS */ |
Michal Vasko | 9e036d5 | 2016-01-08 10:49:26 +0100 | [diff] [blame] | 219 | |
Radek Krejci | 53691be | 2016-02-22 13:58:37 +0100 | [diff] [blame] | 220 | #ifdef NC_ENABLED_SSH |
Michal Vasko | 086311b | 2016-01-08 09:53:11 +0100 | [diff] [blame] | 221 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 222 | /** |
Michal Vasko | 96164bf | 2016-01-21 15:41:58 +0100 | [diff] [blame] | 223 | * @brief Accept a new NETCONF session on an SSH session of a running NETCONF session |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 224 | * that was polled in \p ps. Call this function only when nc_ps_poll() on \p ps returns 5. |
Michal Vasko | c0fde01 | 2016-03-01 09:07:23 +0100 | [diff] [blame] | 225 | * The new session is only returned in \p session, it is not added to \p ps. |
Michal Vasko | 96164bf | 2016-01-21 15:41:58 +0100 | [diff] [blame] | 226 | * |
| 227 | * @param[in] ps Unmodified pollsession structure from the previous nc_ps_poll() call. |
| 228 | * @param[out] session New session. |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 229 | * @return 0 on success, -1 on error. |
Michal Vasko | 96164bf | 2016-01-21 15:41:58 +0100 | [diff] [blame] | 230 | */ |
| 231 | int nc_ps_accept_ssh_channel(struct nc_pollsession *ps, struct nc_session **session); |
| 232 | |
| 233 | /** |
Michal Vasko | 3031aae | 2016-01-27 16:07:18 +0100 | [diff] [blame] | 234 | * @brief Add a new SSH endpoint and start listening on it. |
| 235 | * |
| 236 | * @param[in] name Arbitrary unique endpoint name. There can be a TLS endpoint with |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 237 | * the same name. |
Michal Vasko | 3031aae | 2016-01-27 16:07:18 +0100 | [diff] [blame] | 238 | * @param[in] address IP address to listen on. |
| 239 | * @param[in] port Port to listen on. |
| 240 | * @return 0 on success, -1 on error. |
| 241 | */ |
| 242 | int nc_server_ssh_add_endpt_listen(const char *name, const char *address, uint16_t port); |
| 243 | |
| 244 | /** |
Michal Vasko | da51477 | 2016-02-01 11:32:01 +0100 | [diff] [blame] | 245 | * @brief Change SSH endpoint listening address. |
| 246 | * |
| 247 | * On error the previous listening socket is left untouched. |
| 248 | * |
| 249 | * @param[in] endpt_name Existing endpoint name. |
| 250 | * @param[in] address New listening address. |
| 251 | * @return 0 on success, -1 on error. |
| 252 | */ |
| 253 | int nc_server_ssh_endpt_set_address(const char *endpt_name, const char *address); |
| 254 | |
| 255 | /** |
| 256 | * @brief Change SSH endpoint listening port. |
| 257 | * |
| 258 | * On error the previous listening socket is left untouched. |
| 259 | * |
| 260 | * @param[in] endpt_name Existing endpoint name. |
| 261 | * @param[in] port New listening port. |
| 262 | * @return 0 on success, -1 on error. |
| 263 | */ |
| 264 | int nc_server_ssh_endpt_set_port(const char *endpt_name, uint16_t port); |
| 265 | |
| 266 | /** |
Michal Vasko | 3031aae | 2016-01-27 16:07:18 +0100 | [diff] [blame] | 267 | * @brief Stop listening on and remove an SSH endpoint. |
| 268 | * |
| 269 | * @param[in] name Endpoint name. NULL matches all (SSH) endpoints. |
| 270 | * @return 0 on success, -1 on not finding any match. |
| 271 | */ |
| 272 | int nc_server_ssh_del_endpt(const char *name); |
| 273 | |
| 274 | /** |
| 275 | * @brief Set endpoint SSH host keys the server will identify itself with. Each of RSA, DSA, and |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 276 | * ECDSA keys can be set. If the particular type was already set, it is replaced. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 277 | * |
Michal Vasko | da51477 | 2016-02-01 11:32:01 +0100 | [diff] [blame] | 278 | * @param[in] endpt_name Existing endpoint name. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 279 | * @param[in] privkey_path Path to a private key. |
| 280 | * @return 0 on success, -1 on error. |
| 281 | */ |
Michal Vasko | 3031aae | 2016-01-27 16:07:18 +0100 | [diff] [blame] | 282 | int nc_server_ssh_endpt_set_hostkey(const char *endpt_name, const char *privkey_path); |
Michal Vasko | 086311b | 2016-01-08 09:53:11 +0100 | [diff] [blame] | 283 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 284 | /** |
Michal Vasko | 3031aae | 2016-01-27 16:07:18 +0100 | [diff] [blame] | 285 | * @brief Set endpoint SSH banner the server will send to every client. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 286 | * |
Michal Vasko | da51477 | 2016-02-01 11:32:01 +0100 | [diff] [blame] | 287 | * @param[in] endpt_name Existing endpoint name. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 288 | * @param[in] banner SSH banner. |
| 289 | * @return 0 on success, -1 on error. |
| 290 | */ |
Michal Vasko | 3031aae | 2016-01-27 16:07:18 +0100 | [diff] [blame] | 291 | int nc_server_ssh_endpt_set_banner(const char *endpt_name, const char *banner); |
Michal Vasko | 086311b | 2016-01-08 09:53:11 +0100 | [diff] [blame] | 292 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 293 | /** |
Michal Vasko | 3031aae | 2016-01-27 16:07:18 +0100 | [diff] [blame] | 294 | * @brief Set endpoint accepted SSH authentication methods. All (publickey, password, interactive) |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 295 | * are supported by default. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 296 | * |
Michal Vasko | da51477 | 2016-02-01 11:32:01 +0100 | [diff] [blame] | 297 | * @param[in] endpt_name Existing endpoint name. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 298 | * @param[in] auth_methods Accepted authentication methods bit field of NC_SSH_AUTH_TYPE. |
| 299 | * @return 0 on success, -1 on error. |
| 300 | */ |
Michal Vasko | 3031aae | 2016-01-27 16:07:18 +0100 | [diff] [blame] | 301 | int nc_server_ssh_endpt_set_auth_methods(const char *endpt_name, int auth_methods); |
Michal Vasko | 086311b | 2016-01-08 09:53:11 +0100 | [diff] [blame] | 302 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 303 | /** |
Michal Vasko | 3031aae | 2016-01-27 16:07:18 +0100 | [diff] [blame] | 304 | * @brief Set endpoint SSH authentication attempts of every client. 3 by default. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 305 | * |
Michal Vasko | da51477 | 2016-02-01 11:32:01 +0100 | [diff] [blame] | 306 | * @param[in] endpt_name Existing endpoint name. |
Michal Vasko | 5e6f4cc | 2016-01-20 13:27:44 +0100 | [diff] [blame] | 307 | * @param[in] auth_attempts Failed authentication attempts before a client is dropped. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 308 | * @return 0 on success, -1 on error. |
| 309 | */ |
Michal Vasko | 3031aae | 2016-01-27 16:07:18 +0100 | [diff] [blame] | 310 | int nc_server_ssh_endpt_set_auth_attempts(const char *endpt_name, uint16_t auth_attempts); |
Michal Vasko | 086311b | 2016-01-08 09:53:11 +0100 | [diff] [blame] | 311 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 312 | /** |
Michal Vasko | 3031aae | 2016-01-27 16:07:18 +0100 | [diff] [blame] | 313 | * @brief Set endpoint SSH authentication timeout. 10 seconds by default. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 314 | * |
Michal Vasko | da51477 | 2016-02-01 11:32:01 +0100 | [diff] [blame] | 315 | * @param[in] endpt_name Existing endpoint name. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 316 | * @param[in] auth_timeout Number of seconds before an unauthenticated client is dropped. |
| 317 | * @return 0 on success, -1 on error. |
| 318 | */ |
Michal Vasko | 3031aae | 2016-01-27 16:07:18 +0100 | [diff] [blame] | 319 | int nc_server_ssh_endpt_set_auth_timeout(const char *endpt_name, uint16_t auth_timeout); |
Michal Vasko | 086311b | 2016-01-08 09:53:11 +0100 | [diff] [blame] | 320 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 321 | /** |
Michal Vasko | 3031aae | 2016-01-27 16:07:18 +0100 | [diff] [blame] | 322 | * @brief Add an endpoint authorized client SSH public key. This public key can be used for |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 323 | * publickey authentication afterwards. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 324 | * |
Michal Vasko | da51477 | 2016-02-01 11:32:01 +0100 | [diff] [blame] | 325 | * @param[in] endpt_name Existing endpoint name. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 326 | * @param[in] pubkey_path Path to the public key. |
| 327 | * @param[in] username Username that the client with the public key must use. |
| 328 | * @return 0 on success, -1 on error. |
| 329 | */ |
Michal Vasko | 3031aae | 2016-01-27 16:07:18 +0100 | [diff] [blame] | 330 | int nc_server_ssh_endpt_add_authkey(const char *endpt_name, const char *pubkey_path, const char *username); |
Michal Vasko | 086311b | 2016-01-08 09:53:11 +0100 | [diff] [blame] | 331 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 332 | /** |
Michal Vasko | 3031aae | 2016-01-27 16:07:18 +0100 | [diff] [blame] | 333 | * @brief Remove an endpoint authorized client SSH public key. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 334 | * |
Michal Vasko | da51477 | 2016-02-01 11:32:01 +0100 | [diff] [blame] | 335 | * @param[in] endpt_name Existing endpoint name. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 336 | * @param[in] pubkey_path Path to an authorized public key. NULL matches all the keys. |
| 337 | * @param[in] username Username for an authorized public key. NULL matches all the usernames. |
| 338 | * @return 0 on success, -1 on not finding any match. |
| 339 | */ |
Michal Vasko | 3031aae | 2016-01-27 16:07:18 +0100 | [diff] [blame] | 340 | int nc_server_ssh_endpt_del_authkey(const char *endpt_name, const char *pubkey_path, const char *username); |
| 341 | |
Radek Krejci | 53691be | 2016-02-22 13:58:37 +0100 | [diff] [blame] | 342 | #endif /* NC_ENABLED_SSH */ |
Michal Vasko | 086311b | 2016-01-08 09:53:11 +0100 | [diff] [blame] | 343 | |
Radek Krejci | 53691be | 2016-02-22 13:58:37 +0100 | [diff] [blame] | 344 | #ifdef NC_ENABLED_TLS |
Michal Vasko | 086311b | 2016-01-08 09:53:11 +0100 | [diff] [blame] | 345 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 346 | /** |
Michal Vasko | 3031aae | 2016-01-27 16:07:18 +0100 | [diff] [blame] | 347 | * @brief Add a new TLS endpoint and start listening on it. |
| 348 | * |
| 349 | * @param[in] name Arbitrary unique endpoint name. There can be an SSH endpoint with |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 350 | * the same name. |
Michal Vasko | 3031aae | 2016-01-27 16:07:18 +0100 | [diff] [blame] | 351 | * @param[in] address IP address to listen on. |
| 352 | * @param[in] port Port to listen on. |
| 353 | * @return 0 on success, -1 on error. |
| 354 | */ |
| 355 | int nc_server_tls_add_endpt_listen(const char *name, const char *address, uint16_t port); |
| 356 | |
| 357 | /** |
Michal Vasko | da51477 | 2016-02-01 11:32:01 +0100 | [diff] [blame] | 358 | * @brief Change TLS endpoint listening address. |
| 359 | * |
| 360 | * On error the previous listening socket is left untouched. |
| 361 | * |
| 362 | * @param[in] endpt_name Existing endpoint name. |
| 363 | * @param[in] address New listening address. |
| 364 | * @return 0 on success, -1 on error. |
| 365 | */ |
| 366 | int nc_server_tls_endpt_set_address(const char *endpt_name, const char *address); |
| 367 | |
| 368 | /** |
| 369 | * @brief Change TLS endpoint listening port. |
| 370 | * |
| 371 | * On error the previous listening socket is left untouched. |
| 372 | * |
| 373 | * @param[in] endpt_name Existing endpoint name. |
| 374 | * @param[in] port New listening port. |
| 375 | * @return 0 on success, -1 on error. |
| 376 | */ |
| 377 | int nc_server_tls_endpt_set_port(const char *endpt_name, uint16_t port); |
| 378 | |
| 379 | /** |
Michal Vasko | 3031aae | 2016-01-27 16:07:18 +0100 | [diff] [blame] | 380 | * @brief Stop listening on and remove a TLS endpoint. |
| 381 | * |
| 382 | * @param[in] name Endpoint name. NULL matches all (TLS) endpoints. |
| 383 | * @return 0 on success, -1 on not finding any match. |
| 384 | */ |
| 385 | int nc_server_tls_del_endpt(const char *name); |
| 386 | |
| 387 | /** |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 388 | * @brief Set server TLS certificate. Alternative to nc_tls_server_set_cert_path(). |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 389 | * There can only be one certificate for each key type, it is replaced if |
| 390 | * already set. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 391 | * |
Michal Vasko | da51477 | 2016-02-01 11:32:01 +0100 | [diff] [blame] | 392 | * @param[in] endpt_name Existing endpoint name. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 393 | * @param[in] cert Base64-encoded certificate in ASN.1 DER encoding. |
| 394 | * @return 0 on success, -1 on error. |
| 395 | */ |
Michal Vasko | 3031aae | 2016-01-27 16:07:18 +0100 | [diff] [blame] | 396 | int nc_server_tls_endpt_set_cert(const char *endpt_name, const char *cert); |
Michal Vasko | 086311b | 2016-01-08 09:53:11 +0100 | [diff] [blame] | 397 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 398 | /** |
| 399 | * @brief Set server TLS certificate. Alternative to nc_tls_server_set_cert(). |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 400 | * There can only be one certificate for each key type, it is replaced if |
| 401 | * already set. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 402 | * |
Michal Vasko | da51477 | 2016-02-01 11:32:01 +0100 | [diff] [blame] | 403 | * @param[in] endpt_name Existing endpoint name. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 404 | * @param[in] cert_path Path to a certificate file in PEM format. |
| 405 | * @return 0 on success, -1 on error. |
| 406 | */ |
Michal Vasko | 3031aae | 2016-01-27 16:07:18 +0100 | [diff] [blame] | 407 | int nc_server_tls_endpt_set_cert_path(const char *endpt_name, const char *cert_path); |
Michal Vasko | 0457bb4 | 2016-01-08 15:49:13 +0100 | [diff] [blame] | 408 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 409 | /** |
| 410 | * @brief Set server TLS private key matching the certificate. |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 411 | * Alternative to nc_tls_server_set_key_path(). There can only be one of |
| 412 | * every key type, it is replaced if already set. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 413 | * |
Michal Vasko | da51477 | 2016-02-01 11:32:01 +0100 | [diff] [blame] | 414 | * @param[in] endpt_name Existing endpoint name. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 415 | * @param[in] privkey Base64-encoded certificate in ASN.1 DER encoding. |
| 416 | * @param[in] is_rsa Whether \p privkey are the data of an RSA (1) or DSA (0) key. |
| 417 | * @return 0 on success, -1 on error. |
| 418 | */ |
Michal Vasko | 3031aae | 2016-01-27 16:07:18 +0100 | [diff] [blame] | 419 | int nc_server_tls_endpt_set_key(const char *endpt_name, const char *privkey, int is_rsa); |
Michal Vasko | c14e3c8 | 2016-01-11 16:14:30 +0100 | [diff] [blame] | 420 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 421 | /** |
| 422 | * @brief Set server TLS private key matching the certificate. |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 423 | * Alternative to nc_tls_server_set_key_path(). There can only be one of |
| 424 | * every key type, it is replaced if already set. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 425 | * |
Michal Vasko | da51477 | 2016-02-01 11:32:01 +0100 | [diff] [blame] | 426 | * @param[in] endpt_name Existing endpoint name. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 427 | * @param[in] privkey_path Path to a private key file in PEM format. |
| 428 | * @return 0 on success, -1 on error. |
| 429 | */ |
Michal Vasko | 3031aae | 2016-01-27 16:07:18 +0100 | [diff] [blame] | 430 | int nc_server_tls_endpt_set_key_path(const char *endpt_name, const char *privkey_path); |
Michal Vasko | 0457bb4 | 2016-01-08 15:49:13 +0100 | [diff] [blame] | 431 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 432 | /** |
Michal Vasko | 5d2ad08 | 2016-02-09 11:47:59 +0100 | [diff] [blame] | 433 | * @brief Add a trusted certificate. Can be both a CA or a client one. Can be |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 434 | * safely used together with nc_server_tls_endpt_set_trusted_ca_paths(). |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 435 | * |
Michal Vasko | da51477 | 2016-02-01 11:32:01 +0100 | [diff] [blame] | 436 | * @param[in] endpt_name Existing endpoint name. |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 437 | * @param[in] cert Base64-enocded certificate in ASN.1 DER encoding. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 438 | * @return 0 on success, -1 on error. |
| 439 | */ |
Michal Vasko | 3031aae | 2016-01-27 16:07:18 +0100 | [diff] [blame] | 440 | int nc_server_tls_endpt_add_trusted_cert(const char *endpt_name, const char *cert); |
Michal Vasko | 0457bb4 | 2016-01-08 15:49:13 +0100 | [diff] [blame] | 441 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 442 | /** |
Michal Vasko | 5d2ad08 | 2016-02-09 11:47:59 +0100 | [diff] [blame] | 443 | * @brief Add a trusted certificate. Can be both a CA or a client one. Can be |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 444 | * safely used together with nc_server_tls_endpt_set_trusted_ca_paths(). |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 445 | * |
Michal Vasko | da51477 | 2016-02-01 11:32:01 +0100 | [diff] [blame] | 446 | * @param[in] endpt_name Existing endpoint name. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 447 | * @param[in] cert_path Path to a trusted certificate file in PEM format. |
| 448 | * @return 0 on success, -1 on error. |
| 449 | */ |
Michal Vasko | 3031aae | 2016-01-27 16:07:18 +0100 | [diff] [blame] | 450 | int nc_server_tls_endpt_add_trusted_cert_path(const char *endpt_name, const char *cert_path); |
Michal Vasko | 0457bb4 | 2016-01-08 15:49:13 +0100 | [diff] [blame] | 451 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 452 | /** |
| 453 | * @brief Set trusted Certificate Authority certificate locations. There can only be |
Michal Vasko | 5d2ad08 | 2016-02-09 11:47:59 +0100 | [diff] [blame] | 454 | * one file and one directory, they are replaced if already set. Can be safely |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 455 | * used with nc_server_tls_endpt_add_trusted_cert() or its _path variant. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 456 | * |
Michal Vasko | da51477 | 2016-02-01 11:32:01 +0100 | [diff] [blame] | 457 | * @param[in] endpt_name Existing endpoint name. |
Michal Vasko | 96830e3 | 2016-02-01 10:54:18 +0100 | [diff] [blame] | 458 | * @param[in] ca_file Path to a trusted CA cert store file in PEM format. Can be NULL. |
| 459 | * @param[in] ca_dir Path to a trusted CA cert store hashed directory (c_rehash utility |
| 460 | * can be used to create hashes) with PEM files. Can be NULL. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 461 | * @return 0 on success, -1 on error. |
| 462 | */ |
Michal Vasko | 96830e3 | 2016-02-01 10:54:18 +0100 | [diff] [blame] | 463 | int nc_server_tls_endpt_set_trusted_ca_paths(const char *endpt_name, const char *ca_file, const char *ca_dir); |
Michal Vasko | 0457bb4 | 2016-01-08 15:49:13 +0100 | [diff] [blame] | 464 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 465 | /** |
| 466 | * @brief Destroy and clean all the set certificates and private keys. CRLs and |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 467 | * CTN entries are not affected. |
Michal Vasko | da51477 | 2016-02-01 11:32:01 +0100 | [diff] [blame] | 468 | * |
| 469 | * @param[in] endpt_name Existing endpoint name. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 470 | */ |
Michal Vasko | c6b9c7b | 2016-01-28 11:10:08 +0100 | [diff] [blame] | 471 | void nc_server_tls_endpt_clear_certs(const char *endpt_name); |
Michal Vasko | 0457bb4 | 2016-01-08 15:49:13 +0100 | [diff] [blame] | 472 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 473 | /** |
| 474 | * @brief Set Certificate Revocation List locations. There can only be one file |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 475 | * and one directory, they are replaced if already set. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 476 | * |
Michal Vasko | da51477 | 2016-02-01 11:32:01 +0100 | [diff] [blame] | 477 | * @param[in] endpt_name Existing endpoint name. |
Michal Vasko | 96830e3 | 2016-02-01 10:54:18 +0100 | [diff] [blame] | 478 | * @param[in] crl_file Path to a CRL store file in PEM format. Can be NULL. |
| 479 | * @param[in] crl_dir Path to a CRL store hashed directory (c_rehash utility |
| 480 | * can be used to create hashes) with PEM files. Can be NULL. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 481 | * @return 0 on success, -1 on error. |
| 482 | */ |
Michal Vasko | 96830e3 | 2016-02-01 10:54:18 +0100 | [diff] [blame] | 483 | int nc_server_tls_endpt_set_crl_paths(const char *endpt_name, const char *crl_file, const char *crl_dir); |
Michal Vasko | 0457bb4 | 2016-01-08 15:49:13 +0100 | [diff] [blame] | 484 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 485 | /** |
Michal Vasko | 96830e3 | 2016-02-01 10:54:18 +0100 | [diff] [blame] | 486 | * @brief Destroy and clean CRLs. Certificates, private keys, and CTN entries are |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 487 | * not affected. |
Michal Vasko | da51477 | 2016-02-01 11:32:01 +0100 | [diff] [blame] | 488 | * |
| 489 | * @param[in] endpt_name Existing endpoint name. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 490 | */ |
Michal Vasko | c6b9c7b | 2016-01-28 11:10:08 +0100 | [diff] [blame] | 491 | void nc_server_tls_endpt_clear_crls(const char *endpt_name); |
Michal Vasko | 0457bb4 | 2016-01-08 15:49:13 +0100 | [diff] [blame] | 492 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 493 | /** |
| 494 | * @brief Add a Cert-to-name entry. |
| 495 | * |
Michal Vasko | da51477 | 2016-02-01 11:32:01 +0100 | [diff] [blame] | 496 | * @param[in] endpt_name Existing endpoint name. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 497 | * @param[in] id Priority of the entry. |
| 498 | * @param[in] fingerprint Matching certificate fingerprint. |
| 499 | * @param[in] map_type Type of username-certificate mapping. |
| 500 | * @param[in] name Specific username if \p map_type == NC_TLS_CTN_SPECIFED. Must be NULL otherwise. |
| 501 | * @return 0 on success, -1 on error. |
| 502 | */ |
Michal Vasko | 3031aae | 2016-01-27 16:07:18 +0100 | [diff] [blame] | 503 | int nc_server_tls_endpt_add_ctn(const char *endpt_name, uint32_t id, const char *fingerprint, NC_TLS_CTN_MAPTYPE map_type, const char *name); |
Michal Vasko | c14e3c8 | 2016-01-11 16:14:30 +0100 | [diff] [blame] | 504 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 505 | /** |
| 506 | * @brief Remove a Cert-to-name entry. |
| 507 | * |
Michal Vasko | da51477 | 2016-02-01 11:32:01 +0100 | [diff] [blame] | 508 | * @param[in] endpt_name Existing endpoint name. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 509 | * @param[in] id Priority of the entry. -1 matches all the priorities. |
| 510 | * @param[in] fingerprint Fingerprint fo the entry. NULL matches all the fingerprints. |
| 511 | * @param[in] map_type Mapping type of the entry. 0 matches all the mapping types. |
| 512 | * @param[in] name Specific username for the entry. NULL matches all the usernames. |
| 513 | * @return 0 on success, -1 on not finding any match. |
| 514 | */ |
Michal Vasko | 3031aae | 2016-01-27 16:07:18 +0100 | [diff] [blame] | 515 | int nc_server_tls_endpt_del_ctn(const char *endpt_name, int64_t id, const char *fingerprint, NC_TLS_CTN_MAPTYPE map_type, const char *name); |
Michal Vasko | 0457bb4 | 2016-01-08 15:49:13 +0100 | [diff] [blame] | 516 | |
Radek Krejci | 53691be | 2016-02-22 13:58:37 +0100 | [diff] [blame] | 517 | #endif /* NC_ENABLED_TLS */ |
Michal Vasko | 086311b | 2016-01-08 09:53:11 +0100 | [diff] [blame] | 518 | |
| 519 | #endif /* NC_SESSION_SERVER_H_ */ |