Radek Krejci | d0d1952 | 2015-09-02 13:49:25 +0200 | [diff] [blame] | 1 | /** |
| 2 | * \file libnetconf.h |
| 3 | * \author Radek Krejci <rkrejci@cesnet.cz> |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 4 | * \author Michal Vasko <mvasko@cesnet.cz> |
Radek Krejci | d0d1952 | 2015-09-02 13:49:25 +0200 | [diff] [blame] | 5 | * \brief libnetconf2 main internal header. |
| 6 | * |
| 7 | * Copyright (c) 2015 CESNET, z.s.p.o. |
| 8 | * |
Radek Krejci | 9b81f5b | 2016-02-24 13:14:49 +0100 | [diff] [blame] | 9 | * This source code is licensed under BSD 3-Clause License (the "License"). |
| 10 | * You may not use this file except in compliance with the License. |
| 11 | * You may obtain a copy of the License at |
Michal Vasko | afd416b | 2016-02-25 14:51:46 +0100 | [diff] [blame] | 12 | * |
Radek Krejci | 9b81f5b | 2016-02-24 13:14:49 +0100 | [diff] [blame] | 13 | * https://opensource.org/licenses/BSD-3-Clause |
Radek Krejci | d0d1952 | 2015-09-02 13:49:25 +0200 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #ifndef NC_LIBNETCONF_H_ |
| 17 | #define NC_LIBNETCONF_H_ |
| 18 | |
| 19 | #include "config.h" |
| 20 | #include "log_p.h" |
Radek Krejci | ac6d347 | 2015-10-22 15:47:18 +0200 | [diff] [blame] | 21 | #include "messages_p.h" |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 22 | #include "netconf.h" |
| 23 | #include "session_p.h" |
Radek Krejci | ac6d347 | 2015-10-22 15:47:18 +0200 | [diff] [blame] | 24 | |
| 25 | /* Tests whether string is empty or non-empty. */ |
| 26 | #define strisempty(str) ((str)[0] == '\0') |
| 27 | #define strnonempty(str) ((str)[0] != '\0') |
Radek Krejci | d0d1952 | 2015-09-02 13:49:25 +0200 | [diff] [blame] | 28 | |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 29 | /** |
| 30 | * @mainpage About |
| 31 | * |
| 32 | * libnetconf2 is a NETCONF library in C handling NETCONF authentication and all NETCONF |
Radek Krejci | b62d5b4 | 2017-05-19 10:20:00 +0200 | [diff] [blame] | 33 | * RPC communication both server and client-side. Note that NETCONF datastore implementation |
| 34 | * is not a part of this library. The library supports both NETCONF 1.0 |
| 35 | * ([RFC 4741](https://tools.ietf.org/html/rfc4741)) as well as NETCONF 1.1 |
| 36 | * ([RFC 6241](https://tools.ietf.org/html/rfc6241)). |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 37 | * |
| 38 | * @section about-features Main Features |
| 39 | * |
Radek Krejci | b62d5b4 | 2017-05-19 10:20:00 +0200 | [diff] [blame] | 40 | * - Creating SSH ([RFC 4742](https://tools.ietf.org/html/rfc4742), [RFC 6242](https://tools.ietf.org/html/rfc6242)), |
| 41 | * using [libssh](https://www.libssh.org/), or TLS ([RFC 7589](https://tools.ietf.org/html/rfc7589)), |
| 42 | * using [OpenSSL](https://www.openssl.org/), authenticated NETCONF sessions. |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 43 | * - Creating NETCONF sessions with a pre-established transport protocol |
| 44 | * (using this mechanism the communication can be tunneled through sshd(8), for instance). |
Radek Krejci | b62d5b4 | 2017-05-19 10:20:00 +0200 | [diff] [blame] | 45 | * - Creating NETCONF Call Home sessions ([RFC 8071](https://tools.ietf.org/html/rfc8071)). |
| 46 | * - Creating, sending, receiving, and replying to RPCs ([RFC 4741](https://tools.ietf.org/html/rfc4741), |
| 47 | * [RFC 6241](https://tools.ietf.org/html/rfc6241)). |
| 48 | * - Creating, sending and receiving NETCONF Event Notifications ([RFC 5277](https://tools.ietf.org/html/rfc5277)), |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 49 | * |
| 50 | * @section about-license License |
| 51 | * |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 52 | * Copyright (c) 2015-2021 CESNET, z.s.p.o. |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 53 | * |
| 54 | * (The BSD 3-Clause License) |
| 55 | * |
| 56 | * Redistribution and use in source and binary forms, with or without |
| 57 | * modification, are permitted provided that the following conditions |
| 58 | * are met: |
| 59 | * 1. Redistributions of source code must retain the above copyright |
| 60 | * notice, this list of conditions and the following disclaimer. |
| 61 | * 2. Redistributions in binary form must reproduce the above copyright |
| 62 | * notice, this list of conditions and the following disclaimer in |
| 63 | * the documentation and/or other materials provided with the |
| 64 | * distribution. |
| 65 | * 3. Neither the name of the Company nor the names of its contributors |
| 66 | * may be used to endorse or promote products derived from this |
| 67 | * software without specific prior written permission. |
| 68 | */ |
| 69 | |
| 70 | /** |
| 71 | * @page howto How To ... |
| 72 | * |
| 73 | * - @subpage howtoinit |
| 74 | * - @subpage howtoclient |
| 75 | * - @subpage howtoserver |
| 76 | * - @subpage howtoclientcomm |
| 77 | * - @subpage howtoservercomm |
Michal Vasko | ee087c6 | 2017-02-15 11:27:16 +0100 | [diff] [blame] | 78 | * - @subpage howtotimeouts |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 79 | */ |
| 80 | |
| 81 | /** |
| 82 | * @page howtoinit Init and Thread-safety Information |
| 83 | * |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 84 | * Before working with the library, it must be initialized using ::nc_client_init() |
| 85 | * or ::nc_server_init(). Based on how the library was compiled, also _libssh_ and/or |
Radek Krejci | 5cebc6b | 2017-05-26 13:24:38 +0200 | [diff] [blame] | 86 | * _libssh_/_libcrypto_ are initialized (for multi-threaded use) too. To prevent |
| 87 | * any reachable memory at the end of your application, there are complementary |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 88 | * destroy functions (::nc_server_destroy() and ::nc_client_destroy() available. If your |
Radek Krejci | 5cebc6b | 2017-05-26 13:24:38 +0200 | [diff] [blame] | 89 | * application is multi-threaded, call the destroy functions in the main thread, |
| 90 | * after all the other threads have ended. In every other thread you should call |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 91 | * ::nc_thread_destroy() just before it exits. |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 92 | * |
Michal Vasko | 15b7a98 | 2016-03-02 10:53:31 +0100 | [diff] [blame] | 93 | * If _libnetconf2_ is used in accordance with this information, there should |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 94 | * not be memory leaks of any kind at program exit. For thread-safety details |
Michal Vasko | 15b7a98 | 2016-03-02 10:53:31 +0100 | [diff] [blame] | 95 | * of _libssh_, _libssl_, and _libcrypto_, please refer to the corresponding project |
| 96 | * documentation. _libnetconf2_ thread-safety information is below. |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 97 | * |
Radek Krejci | 5cebc6b | 2017-05-26 13:24:38 +0200 | [diff] [blame] | 98 | * Client |
| 99 | * ------ |
| 100 | * |
Radek Krejci | fd5b668 | 2017-06-13 15:52:53 +0200 | [diff] [blame] | 101 | * Optionally, a client can specify two alternative ways to get schemas needed when connecting |
| 102 | * with a server. The primary way is to read local files in searchpath (and its subdirectories) |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 103 | * specified via ::nc_client_set_schema_searchpath(). Alternatively, _libnetconf2_ can use callback |
| 104 | * provided via ::nc_client_set_schema_callback(). If these ways do not succeed and the server |
Radek Krejci | fd5b668 | 2017-06-13 15:52:53 +0200 | [diff] [blame] | 105 | * implements NETCONF \<get-schema\> operation, the schema is retrieved from the server and stored |
| 106 | * localy into the searchpath (if specified) for a future use. If none of these methods succeed to |
| 107 | * load particular schema, the data from this schema are ignored during the communication with the |
| 108 | * server. |
Radek Krejci | 5cebc6b | 2017-05-26 13:24:38 +0200 | [diff] [blame] | 109 | * |
Radek Krejci | fd5b668 | 2017-06-13 15:52:53 +0200 | [diff] [blame] | 110 | * Besides the mentioned setters, there are many other @ref howtoclientssh "SSH", @ref howtoclienttls "TLS" |
| 111 | * and @ref howtoclientch "Call Home" getter/setter functions to manipulate with various settings. All these |
| 112 | * settings are internally placed in a thread-specific context so they are independent and |
Radek Krejci | 5cebc6b | 2017-05-26 13:24:38 +0200 | [diff] [blame] | 113 | * initialized to the default values within each new thread. However, the context can be shared among |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 114 | * the threads using ::nc_client_get_thread_context() and ::nc_client_set_thread_context() functions. In such |
Radek Krejci | 5cebc6b | 2017-05-26 13:24:38 +0200 | [diff] [blame] | 115 | * a case, be careful and avoid concurrent execution of the mentioned setters/getters and functions |
| 116 | * creating connection (no matter if it is a standard NETCONF connection or Call Home). |
| 117 | * |
| 118 | * In the client, it is thread-safe to work with distinguish NETCONF sessions since the client |
| 119 | * settings are thread-specific as described above. |
| 120 | * |
| 121 | * Server |
| 122 | * ------ |
| 123 | * |
| 124 | * Server is __FULLY__ thread-safe meaning you can set all the (thread-shared in contrast to |
| 125 | * client) options simultaneously while listening for or accepting new sessions or |
Michal Vasko | ade892d | 2017-02-22 13:40:35 +0100 | [diff] [blame] | 126 | * polling the existing ones. It is even safe to poll one session in several |
| 127 | * pollsession structures or one pollsession structure in several threads. Generally, |
| 128 | * servers can use more threads without any problems as long as they keep their workflow sane |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 129 | * (behavior such as freeing sessions only after no thread uses them or similar). |
| 130 | * |
| 131 | * Functions List |
| 132 | * -------------- |
| 133 | * |
Michal Vasko | a7b8ca5 | 2016-03-01 12:09:29 +0100 | [diff] [blame] | 134 | * Available in __nc_client.h__. |
| 135 | * |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 136 | * - ::nc_client_init() |
| 137 | * - ::nc_client_destroy() |
Michal Vasko | a7b8ca5 | 2016-03-01 12:09:29 +0100 | [diff] [blame] | 138 | * |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 139 | * - ::nc_client_set_schema_searchpath() |
| 140 | * - ::nc_client_get_schema_searchpath() |
| 141 | * - ::nc_client_set_schema_callback() |
| 142 | * - ::nc_client_get_schema_callback() |
Radek Krejci | 5cebc6b | 2017-05-26 13:24:38 +0200 | [diff] [blame] | 143 | * |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 144 | * - ::nc_client_set_thread_context() |
| 145 | * - ::nc_client_get_thread_context() |
Michal Vasko | 2639469 | 2016-03-17 16:24:55 +0100 | [diff] [blame] | 146 | * |
Michal Vasko | a7b8ca5 | 2016-03-01 12:09:29 +0100 | [diff] [blame] | 147 | * Available in __nc_server.h__. |
| 148 | * |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 149 | * - ::nc_server_init() |
| 150 | * - ::nc_server_destroy() |
Michal Vasko | a7b8ca5 | 2016-03-01 12:09:29 +0100 | [diff] [blame] | 151 | * |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 152 | * Available in both __nc_client.h__ and __nc_server.h__. |
| 153 | * |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 154 | * - ::nc_thread_destroy() |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 155 | */ |
| 156 | |
| 157 | /** |
| 158 | * @page howtoclient Client sessions |
| 159 | * |
Michal Vasko | 15b7a98 | 2016-03-02 10:53:31 +0100 | [diff] [blame] | 160 | * To connect to a NETCONF server, a NETCONF session must be established, |
| 161 | * which requires a working transport session. It is possible to create |
| 162 | * NETCONF sessions with SSH (using _libssh_) or TLS (using _libssl/libcrypto_) |
| 163 | * as the underlying transport protocol. It is also possible to establish |
| 164 | * the transport protocol outside _libnetconf2_ and then provide these file |
| 165 | * descriptors (FD) for full NETCONF session creation. |
| 166 | * |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 167 | * There are a lot of options for both an SSH and a TLS client. All of them |
| 168 | * have setters and getters so that there is no need to duplicate them in |
| 169 | * a client. |
| 170 | * |
Radek Krejci | 5cebc6b | 2017-05-26 13:24:38 +0200 | [diff] [blame] | 171 | * @anchor howtoclientssh |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 172 | * SSH |
| 173 | * === |
| 174 | * |
Michal Vasko | 15b7a98 | 2016-03-02 10:53:31 +0100 | [diff] [blame] | 175 | * Connecting to a server using SSH does not strictly require to set any |
| 176 | * options, there are sensible default values for all the basic ones. |
| 177 | * Except all the SSH options, optionally some authetication callbacks can be set, |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 178 | * which are particulary useful in automated clients (passwords cannot be |
| 179 | * asked a user) or simply if any additional information is retrieved some |
| 180 | * other way than from standard terminal input. |
| 181 | * |
Michal Vasko | 15b7a98 | 2016-03-02 10:53:31 +0100 | [diff] [blame] | 182 | * Having the default options or changing any unsuitable ones, there are 2 functions |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 183 | * to use for a new server connection. ::nc_connect_ssh() is the standard function |
Michal Vasko | 15b7a98 | 2016-03-02 10:53:31 +0100 | [diff] [blame] | 184 | * that creates sessions using the set options. If there are some options, which |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 185 | * cannot be changed with the provided API, there is ::nc_connect_libssh() available. |
Michal Vasko | 15b7a98 | 2016-03-02 10:53:31 +0100 | [diff] [blame] | 186 | * It requires a _libssh_ session, in which all the SSH options can be modified |
| 187 | * and even the connection established. This allows for full customization and |
| 188 | * should fit any specific situation. |
| 189 | * |
| 190 | * New NETCONF sessions can also be created on existing authenticated SSH sessions. |
| 191 | * There is a new SSH channel needed, on which the NETCONF session is then created. |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 192 | * Use ::nc_connect_ssh_channel() for this purpose. |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 193 | * |
| 194 | * Functions List |
| 195 | * -------------- |
| 196 | * |
| 197 | * Available in __nc_client.h__. |
| 198 | * |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 199 | * - ::nc_client_ssh_set_auth_hostkey_check_clb() |
| 200 | * - ::nc_client_ssh_get_auth_hostkey_check_clb() |
| 201 | * - ::nc_client_ssh_set_auth_password_clb() |
| 202 | * - ::nc_client_ssh_get_auth_password_clb() |
| 203 | * - ::nc_client_ssh_set_auth_interactive_clb() |
| 204 | * - ::nc_client_ssh_get_auth_interactive_clb() |
| 205 | * - ::nc_client_ssh_set_auth_privkey_passphrase_clb() |
| 206 | * - ::nc_client_ssh_get_auth_privkey_passphrase_clb() |
| 207 | * - ::nc_client_ssh_add_keypair() |
| 208 | * - ::nc_client_ssh_del_keypair() |
| 209 | * - ::nc_client_ssh_get_keypair_count() |
| 210 | * - ::nc_client_ssh_get_keypair() |
| 211 | * - ::nc_client_ssh_set_auth_pref() |
| 212 | * - ::nc_client_ssh_get_auth_pref() |
| 213 | * - ::nc_client_ssh_set_username() |
| 214 | * - ::nc_client_ssh_get_username() |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 215 | * |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 216 | * - ::nc_connect_ssh() |
| 217 | * - ::nc_connect_libssh() |
| 218 | * - ::nc_connect_ssh_channel() |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 219 | * |
Radek Krejci | 5cebc6b | 2017-05-26 13:24:38 +0200 | [diff] [blame] | 220 | * @anchor howtoclienttls |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 221 | * TLS |
| 222 | * === |
| 223 | * |
Michal Vasko | 15b7a98 | 2016-03-02 10:53:31 +0100 | [diff] [blame] | 224 | * To connect to a server using TLS, there must be some client identification |
| 225 | * options set. Client must specify its certificate with a private key using |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 226 | * ::nc_client_tls_set_cert_key_paths(). Also, the Certificate Authority of |
Michal Vasko | 15b7a98 | 2016-03-02 10:53:31 +0100 | [diff] [blame] | 227 | * a server certificate must be considered trusted. Paths to all the trusted |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 228 | * CA certificates can be set by ::nc_client_tls_set_trusted_ca_paths(). |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 229 | * |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 230 | * Then there are again 2 functions for connecting, ::nc_connect_tls() being |
| 231 | * the standard way of connecting. ::nc_connect_libssl() again enables |
Michal Vasko | 15b7a98 | 2016-03-02 10:53:31 +0100 | [diff] [blame] | 232 | * to customize the TLS session in every way _libssl_ allows. |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 233 | * |
| 234 | * Functions List |
| 235 | * -------------- |
| 236 | * |
| 237 | * Available in __nc_client.h__. |
| 238 | * |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 239 | * - ::nc_client_tls_set_cert_key_paths() |
| 240 | * - ::nc_client_tls_get_cert_key_paths() |
| 241 | * - ::nc_client_tls_set_trusted_ca_paths() |
| 242 | * - ::nc_client_tls_get_trusted_ca_paths() |
| 243 | * - ::nc_client_tls_set_crl_paths() |
| 244 | * - ::nc_client_tls_get_crl_paths() |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 245 | * |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 246 | * - ::nc_connect_tls() |
| 247 | * - ::nc_connect_libssl() |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 248 | * |
| 249 | * |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 250 | * FD and UNIX socket |
| 251 | * ================== |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 252 | * |
| 253 | * If you authenticated the connection using some tunneling software, you |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 254 | * can pass its file descriptors to _libnetconf2_ using ::nc_connect_inout(), |
| 255 | * which will continue to establish a full NETCONF session. To connect locally |
| 256 | * on a UNIX socket avoiding all cryptography use ::nc_connect_unix(). |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 257 | * |
| 258 | * Funtions List |
| 259 | * ------------- |
| 260 | * |
| 261 | * Available in __nc_client.h__. |
| 262 | * |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 263 | * - ::nc_connect_inout() |
| 264 | * - ::nc_connect_unix() |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 265 | * |
| 266 | * |
Radek Krejci | 5cebc6b | 2017-05-26 13:24:38 +0200 | [diff] [blame] | 267 | * @anchor howtoclientch |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 268 | * Call Home |
| 269 | * ========= |
| 270 | * |
| 271 | * Call Home needs the same options set as standard SSH or TLS and the functions |
| 272 | * reflect it exactly. However, to accept a connection, the client must first |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 273 | * specify addresses and ports, which to listen on by ::nc_client_ssh_ch_add_bind_listen() |
| 274 | * and ::nc_client_tls_ch_add_bind_listen(). Then connections can be |
| 275 | * accepted using ::nc_accept_callhome(). |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 276 | * |
| 277 | * Functions List |
| 278 | * -------------- |
| 279 | * |
| 280 | * Available in __nc_client.h__. |
| 281 | * |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 282 | * - ::nc_client_ssh_ch_set_auth_hostkey_check_clb() |
| 283 | * - ::nc_client_ssh_ch_set_auth_password_clb() |
| 284 | * - ::nc_client_ssh_ch_set_auth_interactive_clb() |
| 285 | * - ::nc_client_ssh_ch_set_auth_privkey_passphrase_clb() |
| 286 | * - ::nc_client_ssh_ch_add_bind_listen() |
| 287 | * - ::nc_client_ssh_ch_del_bind() |
| 288 | * - ::nc_client_ssh_ch_add_keypair() |
| 289 | * - ::nc_client_ssh_ch_del_keypair() |
| 290 | * - ::nc_client_ssh_ch_get_keypair_count() |
| 291 | * - ::nc_client_ssh_ch_get_keypair() |
| 292 | * - ::nc_client_ssh_ch_set_auth_pref() |
| 293 | * - ::nc_client_ssh_ch_get_auth_pref() |
| 294 | * - ::nc_client_ssh_ch_set_username() |
| 295 | * - ::nc_client_ssh_ch_get_username() |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 296 | * |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 297 | * - ::nc_client_tls_ch_add_bind_listen() |
| 298 | * - ::nc_client_tls_ch_del_bind() |
| 299 | * - ::nc_client_tls_ch_set_cert_key_paths() |
| 300 | * - ::nc_client_tls_ch_get_cert_key_paths() |
| 301 | * - ::nc_client_tls_ch_set_trusted_ca_paths() |
| 302 | * - ::nc_client_tls_ch_get_trusted_ca_paths() |
| 303 | * - ::nc_client_tls_ch_set_crl_paths() |
| 304 | * - ::nc_client_tls_ch_get_crl_paths() |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 305 | * |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 306 | * - ::nc_accept_callhome() |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 307 | * |
| 308 | * |
| 309 | * Cleanup |
| 310 | * ======= |
| 311 | * |
| 312 | * These options and the schema searchpath are stored in dynamically |
Michal Vasko | 15b7a98 | 2016-03-02 10:53:31 +0100 | [diff] [blame] | 313 | * allocated memory. They are freed as a part of [destroying the client](@ref howtoinit). |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 314 | */ |
| 315 | |
| 316 | /** |
| 317 | * @page howtoserver Server sessions |
| 318 | * |
| 319 | * Init |
| 320 | * ==== |
| 321 | * |
Michal Vasko | a7b8ca5 | 2016-03-01 12:09:29 +0100 | [diff] [blame] | 322 | * Server takes an argument for its [initialization function](@ref howtoinit). |
| 323 | * In it, you set the server context, which determines what modules it |
| 324 | * supports and what capabilities to advertise. Few capabilities that |
Michal Vasko | 15b7a98 | 2016-03-02 10:53:31 +0100 | [diff] [blame] | 325 | * cannot be learnt from the context are set with separate functions |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 326 | * ::nc_server_set_capab_withdefaults() and generally ::nc_server_set_capability(). |
Michal Vasko | 15b7a98 | 2016-03-02 10:53:31 +0100 | [diff] [blame] | 327 | * Timeout for receiving the _hello_ message on a new session can be set |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 328 | * by ::nc_server_set_hello_timeout() and the timeout for disconnecting |
| 329 | * an inactive session by ::nc_server_set_idle_timeout(). |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 330 | * |
| 331 | * Context does not only determine server modules, but its overall |
| 332 | * functionality as well. For every RPC the server should support, |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 333 | * an nc_rpc_clb callback should be set on that node in the context using ::nc_set_rpc_callback(). |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 334 | * Server then calls these as appropriate [during poll](@ref howtoservercomm). |
| 335 | * |
Michal Vasko | 15b7a98 | 2016-03-02 10:53:31 +0100 | [diff] [blame] | 336 | * Just like in the [client](@ref howtoclient), you can let _libnetconf2_ |
| 337 | * establish SSH or TLS transport or do it yourself and only provide the file |
| 338 | * descriptors of the connection. |
| 339 | * |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 340 | * Server options can be only set, there are no getters. |
| 341 | * |
Michal Vasko | d31b76e | 2017-02-15 12:18:06 +0100 | [diff] [blame] | 342 | * To be able to accept any connections, endpoints must first be added |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 343 | * with ::nc_server_add_endpt() and configured with ::nc_server_endpt_set_address() |
| 344 | * and ::nc_server_endpt_set_port(). For unix sockets, ::nc_server_endpt_set_perms() |
| 345 | * is available to set the unix socket file permissions, and ::nc_server_endpt_set_port() |
Olivier Matz | ac7fa2f | 2018-10-11 10:02:04 +0200 | [diff] [blame] | 346 | * is invalid. |
Michal Vasko | 3a889fd | 2016-09-30 12:16:37 +0200 | [diff] [blame] | 347 | * |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 348 | * Functions List |
| 349 | * -------------- |
| 350 | * |
| 351 | * Available in __nc_server.h__. |
| 352 | * |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 353 | * - ::nc_server_set_capab_withdefaults() |
| 354 | * - ::nc_server_set_capability() |
| 355 | * - ::nc_server_set_hello_timeout() |
| 356 | * - ::nc_server_set_idle_timeout() |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 357 | * |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 358 | * - ::nc_server_add_endpt() |
| 359 | * - ::nc_server_del_endpt() |
| 360 | * - ::nc_server_endpt_set_address() |
| 361 | * - ::nc_server_endpt_set_port() |
| 362 | * - ::nc_server_endpt_set_perms() |
Michal Vasko | 3a889fd | 2016-09-30 12:16:37 +0200 | [diff] [blame] | 363 | * |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 364 | * |
| 365 | * SSH |
| 366 | * === |
| 367 | * |
Michal Vasko | d31b76e | 2017-02-15 12:18:06 +0100 | [diff] [blame] | 368 | * To successfully accept an SSH session you must set at least the host key using |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 369 | * ::nc_server_ssh_endpt_add_hostkey(), which are ordered. This way you simply add |
Michal Vasko | d31b76e | 2017-02-15 12:18:06 +0100 | [diff] [blame] | 370 | * some hostkey identifier, but the key itself will be retrieved always when needed |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 371 | * by calling the callback set by ::nc_server_ssh_set_hostkey_clb(). |
Michal Vasko | d31b76e | 2017-02-15 12:18:06 +0100 | [diff] [blame] | 372 | * |
| 373 | * There are also some other optional settings. Note that authorized |
| 374 | * public keys are set for the server as a whole, not endpoint-specifically. |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 375 | * |
| 376 | * Functions List |
| 377 | * -------------- |
| 378 | * |
| 379 | * Available in __nc_server.h__. |
| 380 | * |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 381 | * - ::nc_server_ssh_endpt_add_hostkey() |
| 382 | * - ::nc_server_ssh_endpt_del_hostkey() |
| 383 | * - ::nc_server_ssh_endpt_mov_hostkey() |
| 384 | * - ::nc_server_ssh_endpt_mod_hostkey() |
| 385 | * - ::nc_server_ssh_endpt_set_auth_methods() |
| 386 | * - ::nc_server_ssh_endpt_set_auth_attempts() |
| 387 | * - ::nc_server_ssh_endpt_set_auth_timeout() |
Michal Vasko | d31b76e | 2017-02-15 12:18:06 +0100 | [diff] [blame] | 388 | * |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 389 | * - ::nc_server_ssh_set_hostkey_clb() |
Michal Vasko | d31b76e | 2017-02-15 12:18:06 +0100 | [diff] [blame] | 390 | * |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 391 | * - ::nc_server_ssh_add_authkey() |
| 392 | * - ::nc_server_ssh_add_authkey_path() |
| 393 | * - ::nc_server_ssh_del_authkey() |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 394 | * |
| 395 | * |
| 396 | * TLS |
| 397 | * === |
| 398 | * |
Michal Vasko | 15b7a98 | 2016-03-02 10:53:31 +0100 | [diff] [blame] | 399 | * TLS works with endpoints too, but its options differ |
| 400 | * significantly from the SSH ones, especially in the _cert-to-name_ |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 401 | * options that TLS uses to derive usernames from client certificates. |
Michal Vasko | d31b76e | 2017-02-15 12:18:06 +0100 | [diff] [blame] | 402 | * So, after starting listening on an endpoint you need to set the server |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 403 | * certificate (::nc_server_tls_endpt_set_server_cert()). Its actual content |
Michal Vasko | d31b76e | 2017-02-15 12:18:06 +0100 | [diff] [blame] | 404 | * together with the matching private key will be loaded using a callback |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 405 | * from ::nc_server_tls_set_server_cert_clb(). Additional certificates needed |
Andrew Langefeld | 440b6c7 | 2018-08-27 16:26:20 -0500 | [diff] [blame] | 406 | * for the client to verify the server's certificate chain can be loaded using |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 407 | * a callback from ::nc_server_tls_set_server_cert_chain_clb(). |
Michal Vasko | 15b7a98 | 2016-03-02 10:53:31 +0100 | [diff] [blame] | 408 | * |
| 409 | * To accept client certificates, they must first be considered trusted, |
| 410 | * which you have three ways of achieving. You can add each of their Certificate Authority |
| 411 | * certificates to the trusted ones or mark a specific client certificate |
Michal Vasko | d31b76e | 2017-02-15 12:18:06 +0100 | [diff] [blame] | 412 | * as trusted. Lastly, you can set paths with all the trusted CA certificates |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 413 | * with ::nc_server_tls_endpt_set_trusted_ca_paths(). Adding specific certificates |
Michal Vasko | d31b76e | 2017-02-15 12:18:06 +0100 | [diff] [blame] | 414 | * is also performed only as an arbitrary identificator and later retrieved from |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 415 | * callback set by ::nc_server_tls_set_trusted_cert_list_clb(). But, you can add |
Michal Vasko | d31b76e | 2017-02-15 12:18:06 +0100 | [diff] [blame] | 416 | * certficates as whole lists, not one-by-one. |
Michal Vasko | 15b7a98 | 2016-03-02 10:53:31 +0100 | [diff] [blame] | 417 | * |
| 418 | * Then, from each trusted client certificate a username must be derived |
| 419 | * for the NETCONF session. This is accomplished by finding a matching |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 420 | * _cert-to-name_ entry. They are added using ::nc_server_tls_endpt_add_ctn(). |
Michal Vasko | 15b7a98 | 2016-03-02 10:53:31 +0100 | [diff] [blame] | 421 | * |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 422 | * If you need to remove trusted certificates, you can do so with ::nc_server_tls_endpt_del_trusted_cert_list(). |
| 423 | * To clear all Certificate Revocation Lists use ::nc_server_tls_endpt_clear_crls(). |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 424 | * |
| 425 | * Functions List |
| 426 | * -------------- |
| 427 | * |
| 428 | * Available in __nc_server.h__. |
| 429 | * |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 430 | * - ::nc_server_tls_endpt_set_server_cert() |
| 431 | * - ::nc_server_tls_endpt_add_trusted_cert_list() |
| 432 | * - ::nc_server_tls_endpt_del_trusted_cert_list() |
| 433 | * - ::nc_server_tls_endpt_set_trusted_ca_paths() |
| 434 | * - ::nc_server_tls_endpt_set_crl_paths() |
| 435 | * - ::nc_server_tls_endpt_clear_crls() |
| 436 | * - ::nc_server_tls_endpt_add_ctn() |
| 437 | * - ::nc_server_tls_endpt_del_ctn() |
| 438 | * - ::nc_server_tls_endpt_get_ctn() |
Michal Vasko | d31b76e | 2017-02-15 12:18:06 +0100 | [diff] [blame] | 439 | * |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 440 | * - ::nc_server_tls_set_server_cert_clb() |
| 441 | * - ::nc_server_tls_set_server_cert_chain_clb() |
| 442 | * - ::nc_server_tls_set_trusted_cert_list_clb() |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 443 | * |
| 444 | * FD |
| 445 | * == |
| 446 | * |
| 447 | * If you used a tunneling software, which does its own authentication, |
Michal Vasko | 15b7a98 | 2016-03-02 10:53:31 +0100 | [diff] [blame] | 448 | * you can accept a NETCONF session on its file descriptors with |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 449 | * ::nc_accept_inout(). |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 450 | * |
| 451 | * Functions List |
| 452 | * -------------- |
| 453 | * |
| 454 | * Available in __nc_server.h__. |
| 455 | * |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 456 | * - ::nc_accept_inout() |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 457 | * |
| 458 | * |
| 459 | * Call Home |
| 460 | * ========= |
| 461 | * |
Michal Vasko | d31b76e | 2017-02-15 12:18:06 +0100 | [diff] [blame] | 462 | * _Call Home_ works with endpoints just like standard sessions, but |
| 463 | * the options are organized a bit differently and endpoints are added |
| 464 | * for CH clients. However, one important difference is that |
| 465 | * once all the mandatory options are set, _libnetconf2_ __will not__ |
| 466 | * immediately start connecting to a client. It will do so only after |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 467 | * calling ::nc_connect_ch_client_dispatch() in a separate thread. |
Michal Vasko | d31b76e | 2017-02-15 12:18:06 +0100 | [diff] [blame] | 468 | * |
| 469 | * Lastly, monitoring of these sessions is up to the application. |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 470 | * |
| 471 | * Functions List |
| 472 | * -------------- |
| 473 | * |
| 474 | * Available in __nc_server.h__. |
| 475 | * |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 476 | * - ::nc_server_ch_add_client() |
| 477 | * - ::nc_server_ch_del_client() |
| 478 | * - ::nc_server_ch_is_client() |
| 479 | * - ::nc_server_ch_client_add_endpt() |
| 480 | * - ::nc_server_ch_client_del_endpt() |
| 481 | * - ::nc_server_ch_client_is_endpt() |
| 482 | * - ::nc_server_ch_client_endpt_set_address() |
| 483 | * - ::nc_server_ch_client_endpt_set_port() |
| 484 | * - ::nc_server_ch_client_endpt_enable_keepalives() |
| 485 | * - ::nc_server_ch_client_endpt_set_keepalives() |
| 486 | * - ::nc_server_ch_client_set_conn_type() |
| 487 | * - ::nc_server_ch_client_periodic_set_period() |
| 488 | * - ::nc_server_ch_client_periodic_set_anchor_time() |
| 489 | * - ::nc_server_ch_client_periodic_set_idle_timeout() |
| 490 | * - ::nc_server_ch_client_set_start_with() |
| 491 | * - ::nc_server_ch_client_set_max_attempts() |
| 492 | * - ::nc_connect_ch_client_dispatch() |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 493 | * |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 494 | * - ::nc_server_ssh_ch_client_endpt_add_hostkey() |
| 495 | * - ::nc_server_ssh_ch_client_endpt_del_hostkey() |
| 496 | * - ::nc_server_ssh_ch_client_endpt_mov_hostkey() |
| 497 | * - ::nc_server_ssh_ch_client_endpt_set_auth_methods() |
| 498 | * - ::nc_server_ssh_ch_client_endpt_get_auth_methods() |
| 499 | * - ::nc_server_ssh_ch_client_endpt_set_auth_attempts() |
| 500 | * - ::nc_server_ssh_ch_client_endpt_set_auth_timeout() |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 501 | * |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 502 | * - ::nc_server_tls_ch_client_endpt_set_server_cert() |
| 503 | * - ::nc_server_tls_ch_client_endpt_add_trusted_cert_list() |
| 504 | * - ::nc_server_tls_ch_client_endpt_del_trusted_cert_list() |
| 505 | * - ::nc_server_tls_ch_client_endpt_set_trusted_ca_paths() |
| 506 | * - ::nc_server_tls_ch_client_endpt_set_crl_paths() |
| 507 | * - ::nc_server_tls_ch_client_endpt_clear_crls() |
| 508 | * - ::nc_server_tls_ch_client_endpt_add_ctn() |
| 509 | * - ::nc_server_tls_ch_client_endpt_del_ctn() |
| 510 | * - ::nc_server_tls_ch_client_endpt_get_ctn() |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 511 | * |
| 512 | * |
| 513 | * Connecting And Cleanup |
| 514 | * ====================== |
| 515 | * |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 516 | * When accepting connections with ::nc_accept(), all the endpoints are examined |
Michal Vasko | d31b76e | 2017-02-15 12:18:06 +0100 | [diff] [blame] | 517 | * and the first with a pending connection is used. To remove all CH clients, |
| 518 | * endpoints, and free any used dynamic memory, [destroy](@ref howtoinit) the server. |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 519 | * |
| 520 | * Functions List |
| 521 | * -------------- |
| 522 | * |
| 523 | * Available in __nc_server.h__. |
| 524 | * |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 525 | * - ::nc_accept() |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 526 | */ |
| 527 | |
| 528 | /** |
| 529 | * @page howtoclientcomm Client communication |
| 530 | * |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 531 | * To send RPCs on a session, you simply create an RPC, send it using ::nc_send_rpc(), |
| 532 | * and then wait for a reply using ::nc_recv_reply(). If you are subscribed, there are 2 ways |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 533 | * of receiving notifications. Either you wait for them the same way |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 534 | * as for standard replies with ::nc_recv_notif() or you create a dispatcher |
| 535 | * with ::nc_recv_notif_dispatch() that asynchronously (in a separate thread) |
Michal Vasko | 15b7a98 | 2016-03-02 10:53:31 +0100 | [diff] [blame] | 536 | * reads notifications and passes them to your callback. |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 537 | * |
| 538 | * Functions List |
| 539 | * -------------- |
| 540 | * |
| 541 | * Available in __nc_client.h__. |
| 542 | * |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 543 | * - ::nc_rpc_act_generic() |
| 544 | * - ::nc_rpc_act_generic_xml() |
| 545 | * - ::nc_rpc_getconfig() |
| 546 | * - ::nc_rpc_edit() |
| 547 | * - ::nc_rpc_copy() |
| 548 | * - ::nc_rpc_delete() |
| 549 | * - ::nc_rpc_lock() |
| 550 | * - ::nc_rpc_unlock() |
| 551 | * - ::nc_rpc_get() |
| 552 | * - ::nc_rpc_kill() |
| 553 | * - ::nc_rpc_commit() |
| 554 | * - ::nc_rpc_discard() |
| 555 | * - ::nc_rpc_cancel() |
| 556 | * - ::nc_rpc_validate() |
| 557 | * - ::nc_rpc_getschema() |
| 558 | * - ::nc_rpc_subscribe() |
| 559 | * - ::nc_rpc_getdata() |
| 560 | * - ::nc_rpc_editdata() |
| 561 | * - ::nc_rpc_establishsub() |
| 562 | * - ::nc_rpc_modifysub() |
| 563 | * - ::nc_rpc_deletesub() |
| 564 | * - ::nc_rpc_killsub() |
| 565 | * - ::nc_rpc_establishpush_periodic() |
| 566 | * - ::nc_rpc_establishpush_onchange() |
| 567 | * - ::nc_rpc_modifypush_periodic() |
| 568 | * - ::nc_rpc_modifypush_onchange() |
| 569 | * - ::nc_rpc_resyncsub() |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 570 | * |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 571 | * - ::nc_send_rpc() |
| 572 | * - ::nc_recv_reply() |
| 573 | * - ::nc_recv_notif() |
| 574 | * - ::nc_recv_notif_dispatch() |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 575 | */ |
| 576 | |
| 577 | /** |
| 578 | * @page howtoservercomm Server communication |
| 579 | * |
| 580 | * Once at least one session is established, an nc_pollsession structure |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 581 | * should be created with ::nc_ps_new(), filled with the session using |
| 582 | * ::nc_ps_add_session() and finally polled with ::nc_ps_poll(). Based on |
Michal Vasko | 15b7a98 | 2016-03-02 10:53:31 +0100 | [diff] [blame] | 583 | * the return value from the poll, further actions can be taken. More |
| 584 | * sessions can be polled at the same time and any requests received on |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 585 | * the sessions are [handled internally](@ref howtoserver). |
| 586 | * |
Michal Vasko | 15b7a98 | 2016-03-02 10:53:31 +0100 | [diff] [blame] | 587 | * If an SSH NETCONF session asks for a new channel, you can accept |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 588 | * this request with ::nc_ps_accept_ssh_channel() or ::nc_session_accept_ssh_channel() |
Michal Vasko | 3a889fd | 2016-09-30 12:16:37 +0200 | [diff] [blame] | 589 | * depending on the structure you want to use as the argument. |
Michal Vasko | 15b7a98 | 2016-03-02 10:53:31 +0100 | [diff] [blame] | 590 | * |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 591 | * Functions List |
| 592 | * -------------- |
| 593 | * |
Michal Vasko | 15b7a98 | 2016-03-02 10:53:31 +0100 | [diff] [blame] | 594 | * Available in __nc_server.h__. |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 595 | * |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 596 | * - ::nc_ps_new() |
| 597 | * - ::nc_ps_add_session() |
| 598 | * - ::nc_ps_del_session() |
| 599 | * - ::nc_ps_session_count() |
| 600 | * - ::nc_ps_free() |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 601 | * |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 602 | * - ::nc_ps_poll() |
| 603 | * - ::nc_ps_clear() |
| 604 | * - ::nc_ps_accept_ssh_channel() |
| 605 | * - ::nc_session_accept_ssh_channel() |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 606 | */ |
| 607 | |
Michal Vasko | ee087c6 | 2017-02-15 11:27:16 +0100 | [diff] [blame] | 608 | /** |
| 609 | * @page howtotimeouts Timeouts |
| 610 | * |
| 611 | * There are several timeouts which are used throughout _libnetconf2_ to |
| 612 | * assure that it will never indefinitely hang on any operation. Normally, |
| 613 | * you should not need to worry about them much necause they are set by |
| 614 | * default to reasonable values for common systems. However, if your |
| 615 | * platform is not common (embedded, ...), adjusting these timeouts may |
| 616 | * save a lot of debugging and time. |
| 617 | * |
| 618 | * Compile Options |
| 619 | * --------------- |
| 620 | * |
| 621 | * You can adjust active and inactive read timeout using `cmake` variables. |
| 622 | * For details look into `README.md`. |
| 623 | * |
| 624 | * API Functions |
| 625 | * ------------- |
| 626 | * |
| 627 | * Once a new connection is established including transport protocol negotiations, |
| 628 | * _hello_ message is exchanged. You can set how long will the server wait for |
| 629 | * receiving this message from a client before dropping it. |
| 630 | * |
| 631 | * Having a NETCONF session working, it may not communicate for a longer time. |
| 632 | * To free up some resources, it is possible to adjust the maximum idle period |
| 633 | * of a session before it is disconnected. In _Call Home_, for both a persistent |
| 634 | * and periodic connection can this idle timeout be specified separately for each |
| 635 | * client using corresponding functions. |
| 636 | * |
| 637 | * Lastly, SSH user authentication timeout can be also modified. It is the time |
| 638 | * a client has to successfully authenticate after connecting before it is disconnected. |
| 639 | * |
| 640 | * Functions List |
| 641 | * -------------- |
| 642 | * |
| 643 | * Available in __nc_server.h__. |
| 644 | * |
Michal Vasko | 4e6d324 | 2021-05-26 09:13:24 +0200 | [diff] [blame] | 645 | * - ::nc_server_set_hello_timeout() |
| 646 | * - ::nc_server_get_hello_timeout() |
| 647 | * - ::nc_server_set_idle_timeout() |
| 648 | * - ::nc_server_get_idle_timeout() |
| 649 | * - ::nc_server_ch_client_periodic_set_idle_timeout() |
| 650 | * - ::nc_server_ssh_ch_client_endpt_set_auth_timeout() |
| 651 | * - ::nc_server_ssh_ch_client_endpt_set_auth_timeout() |
Michal Vasko | ee087c6 | 2017-02-15 11:27:16 +0100 | [diff] [blame] | 652 | */ |
| 653 | |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 654 | /** |
| 655 | * @defgroup misc Miscellaneous |
| 656 | * @brief Miscellaneous macros, types, structure and functions for a generic use by both server and client applications. |
| 657 | */ |
| 658 | |
| 659 | /** |
| 660 | * @defgroup client Client |
| 661 | * @brief NETCONF client functionality. |
| 662 | */ |
| 663 | |
| 664 | /** |
| 665 | * @defgroup server Server |
| 666 | * @brief NETCONF server functionality. |
| 667 | */ |
| 668 | |
Radek Krejci | d0d1952 | 2015-09-02 13:49:25 +0200 | [diff] [blame] | 669 | #endif /* NC_LIBNETCONF_H_ */ |