blob: feac6c9f2074ba37b31d72f0da2048b3756d882f [file] [log] [blame]
Radek Krejcid0d19522015-09-02 13:49:25 +02001/**
Michal Vaskofdfd9dd2016-02-29 10:18:46 +01002 * @mainpage About
3 *
4 * libnetconf2 is a NETCONF library in C handling NETCONF authentication and all NETCONF
Radek Krejcib62d5b42017-05-19 10:20:00 +02005 * RPC communication both server and client-side. Note that NETCONF datastore implementation
6 * is not a part of this library. The library supports both NETCONF 1.0
7 * ([RFC 4741](https://tools.ietf.org/html/rfc4741)) as well as NETCONF 1.1
8 * ([RFC 6241](https://tools.ietf.org/html/rfc6241)).
Michal Vaskofdfd9dd2016-02-29 10:18:46 +01009 *
10 * @section about-features Main Features
11 *
Radek Krejcib62d5b42017-05-19 10:20:00 +020012 * - Creating SSH ([RFC 4742](https://tools.ietf.org/html/rfc4742), [RFC 6242](https://tools.ietf.org/html/rfc6242)),
13 * using [libssh](https://www.libssh.org/), or TLS ([RFC 7589](https://tools.ietf.org/html/rfc7589)),
14 * using [OpenSSL](https://www.openssl.org/), authenticated NETCONF sessions.
Michal Vaskofdfd9dd2016-02-29 10:18:46 +010015 * - Creating NETCONF sessions with a pre-established transport protocol
16 * (using this mechanism the communication can be tunneled through sshd(8), for instance).
Radek Krejcib62d5b42017-05-19 10:20:00 +020017 * - Creating NETCONF Call Home sessions ([RFC 8071](https://tools.ietf.org/html/rfc8071)).
18 * - Creating, sending, receiving, and replying to RPCs ([RFC 4741](https://tools.ietf.org/html/rfc4741),
19 * [RFC 6241](https://tools.ietf.org/html/rfc6241)).
Roytak09e426c2023-09-29 15:25:55 +020020 * - Creating, sending and receiving NETCONF Event Notifications ([RFC 5277](https://tools.ietf.org/html/rfc5277)).
romand348b942023-10-13 14:32:19 +020021 * - Configuring the NETCONF server based on the [ietf-netconf-server](https://datatracker.ietf.org/doc/html/draft-ietf-netconf-netconf-client-server-29) YANG module
Michal Vaskofdfd9dd2016-02-29 10:18:46 +010022 *
23 * @section about-license License
24 *
Michal Vasko4e6d3242021-05-26 09:13:24 +020025 * Copyright (c) 2015-2021 CESNET, z.s.p.o.
Michal Vaskofdfd9dd2016-02-29 10:18:46 +010026 *
27 * (The BSD 3-Clause License)
28 *
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
31 * are met:
32 * 1. Redistributions of source code must retain the above copyright
33 * notice, this list of conditions and the following disclaimer.
34 * 2. Redistributions in binary form must reproduce the above copyright
35 * notice, this list of conditions and the following disclaimer in
36 * the documentation and/or other materials provided with the
37 * distribution.
38 * 3. Neither the name of the Company nor the names of its contributors
39 * may be used to endorse or promote products derived from this
40 * software without specific prior written permission.
41 */
42
43/**
44 * @page howto How To ...
45 *
46 * - @subpage howtoinit
47 * - @subpage howtoclient
48 * - @subpage howtoserver
49 * - @subpage howtoclientcomm
50 * - @subpage howtoservercomm
Michal Vaskoee087c62017-02-15 11:27:16 +010051 * - @subpage howtotimeouts
Michal Vaskofdfd9dd2016-02-29 10:18:46 +010052 */
53
54/**
55 * @page howtoinit Init and Thread-safety Information
56 *
Michal Vasko4e6d3242021-05-26 09:13:24 +020057 * Before working with the library, it must be initialized using ::nc_client_init()
roman694979e2023-11-02 15:00:09 +010058 * and/or ::nc_server_init(). To prevent any reachable memory at the end of your
59 * application, there are complementary destroy functions
60 * (::nc_server_destroy() and ::nc_client_destroy() available). If your
Radek Krejci5cebc6b2017-05-26 13:24:38 +020061 * application is multi-threaded, call the destroy functions in the main thread,
Roytak09e426c2023-09-29 15:25:55 +020062 * after all the other threads have ended.
Michal Vaskofdfd9dd2016-02-29 10:18:46 +010063 *
Michal Vasko15b7a982016-03-02 10:53:31 +010064 * If _libnetconf2_ is used in accordance with this information, there should
Michal Vaskofdfd9dd2016-02-29 10:18:46 +010065 * not be memory leaks of any kind at program exit. For thread-safety details
Michal Vasko15b7a982016-03-02 10:53:31 +010066 * of _libssh_, _libssl_, and _libcrypto_, please refer to the corresponding project
67 * documentation. _libnetconf2_ thread-safety information is below.
Michal Vaskofdfd9dd2016-02-29 10:18:46 +010068 *
Radek Krejci5cebc6b2017-05-26 13:24:38 +020069 * Client
70 * ------
71 *
Radek Krejcifd5b6682017-06-13 15:52:53 +020072 * Optionally, a client can specify two alternative ways to get schemas needed when connecting
73 * with a server. The primary way is to read local files in searchpath (and its subdirectories)
Michal Vasko4e6d3242021-05-26 09:13:24 +020074 * specified via ::nc_client_set_schema_searchpath(). Alternatively, _libnetconf2_ can use callback
75 * provided via ::nc_client_set_schema_callback(). If these ways do not succeed and the server
Radek Krejcifd5b6682017-06-13 15:52:53 +020076 * implements NETCONF \<get-schema\> operation, the schema is retrieved from the server and stored
Roytak09e426c2023-09-29 15:25:55 +020077 * locally into the searchpath (if specified) for a future use. If none of these methods succeed to
Radek Krejcifd5b6682017-06-13 15:52:53 +020078 * load particular schema, the data from this schema are ignored during the communication with the
79 * server.
Radek Krejci5cebc6b2017-05-26 13:24:38 +020080 *
Radek Krejcifd5b6682017-06-13 15:52:53 +020081 * Besides the mentioned setters, there are many other @ref howtoclientssh "SSH", @ref howtoclienttls "TLS"
82 * and @ref howtoclientch "Call Home" getter/setter functions to manipulate with various settings. All these
83 * settings are internally placed in a thread-specific context so they are independent and
Radek Krejci5cebc6b2017-05-26 13:24:38 +020084 * initialized to the default values within each new thread. However, the context can be shared among
Michal Vasko4e6d3242021-05-26 09:13:24 +020085 * the threads using ::nc_client_get_thread_context() and ::nc_client_set_thread_context() functions. In such
Radek Krejci5cebc6b2017-05-26 13:24:38 +020086 * a case, be careful and avoid concurrent execution of the mentioned setters/getters and functions
87 * creating connection (no matter if it is a standard NETCONF connection or Call Home).
88 *
Michal Vasko2d1e8d32023-03-15 07:29:09 +010089 * In the client, it is always thread-safe to work with a NETCONF session in a single thread since the client
90 * settings are thread-specific as described above. Generally, one can access a session in several threads
91 * as well but there is little incentive to do so.
Radek Krejci5cebc6b2017-05-26 13:24:38 +020092 *
93 * Server
94 * ------
95 *
96 * Server is __FULLY__ thread-safe meaning you can set all the (thread-shared in contrast to
97 * client) options simultaneously while listening for or accepting new sessions or
Michal Vaskoade892d2017-02-22 13:40:35 +010098 * polling the existing ones. It is even safe to poll one session in several
99 * pollsession structures or one pollsession structure in several threads. Generally,
100 * servers can use more threads without any problems as long as they keep their workflow sane
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100101 * (behavior such as freeing sessions only after no thread uses them or similar).
102 *
103 * Functions List
104 * --------------
105 *
Michal Vaskoa7b8ca52016-03-01 12:09:29 +0100106 * Available in __nc_client.h__.
107 *
Michal Vasko4e6d3242021-05-26 09:13:24 +0200108 * - ::nc_client_init()
109 * - ::nc_client_destroy()
Michal Vaskoa7b8ca52016-03-01 12:09:29 +0100110 *
Michal Vasko4e6d3242021-05-26 09:13:24 +0200111 * - ::nc_client_set_schema_searchpath()
112 * - ::nc_client_get_schema_searchpath()
113 * - ::nc_client_set_schema_callback()
114 * - ::nc_client_get_schema_callback()
Radek Krejci5cebc6b2017-05-26 13:24:38 +0200115 *
Michal Vasko4e6d3242021-05-26 09:13:24 +0200116 * - ::nc_client_set_thread_context()
117 * - ::nc_client_get_thread_context()
Michal Vasko26394692016-03-17 16:24:55 +0100118 *
Michal Vaskoa7b8ca52016-03-01 12:09:29 +0100119 * Available in __nc_server.h__.
120 *
Michal Vasko4e6d3242021-05-26 09:13:24 +0200121 * - ::nc_server_init()
122 * - ::nc_server_destroy()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100123 */
124
125/**
126 * @page howtoclient Client sessions
127 *
Michal Vasko15b7a982016-03-02 10:53:31 +0100128 * To connect to a NETCONF server, a NETCONF session must be established,
129 * which requires a working transport session. It is possible to create
130 * NETCONF sessions with SSH (using _libssh_) or TLS (using _libssl/libcrypto_)
131 * as the underlying transport protocol. It is also possible to establish
132 * the transport protocol outside _libnetconf2_ and then provide these file
133 * descriptors (FD) for full NETCONF session creation.
134 *
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100135 * There are a lot of options for both an SSH and a TLS client. All of them
136 * have setters and getters so that there is no need to duplicate them in
137 * a client.
138 *
Radek Krejci5cebc6b2017-05-26 13:24:38 +0200139 * @anchor howtoclientssh
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100140 * SSH
141 * ===
142 *
Michal Vasko15b7a982016-03-02 10:53:31 +0100143 * Connecting to a server using SSH does not strictly require to set any
144 * options, there are sensible default values for all the basic ones.
145 * Except all the SSH options, optionally some authetication callbacks can be set,
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100146 * which are particulary useful in automated clients (passwords cannot be
147 * asked a user) or simply if any additional information is retrieved some
148 * other way than from standard terminal input.
149 *
Michal Vasko15b7a982016-03-02 10:53:31 +0100150 * Having the default options or changing any unsuitable ones, there are 2 functions
Michal Vasko4e6d3242021-05-26 09:13:24 +0200151 * to use for a new server connection. ::nc_connect_ssh() is the standard function
Michal Vasko15b7a982016-03-02 10:53:31 +0100152 * that creates sessions using the set options. If there are some options, which
Michal Vasko4e6d3242021-05-26 09:13:24 +0200153 * cannot be changed with the provided API, there is ::nc_connect_libssh() available.
Michal Vasko15b7a982016-03-02 10:53:31 +0100154 * It requires a _libssh_ session, in which all the SSH options can be modified
155 * and even the connection established. This allows for full customization and
156 * should fit any specific situation.
157 *
158 * New NETCONF sessions can also be created on existing authenticated SSH sessions.
159 * There is a new SSH channel needed, on which the NETCONF session is then created.
Michal Vasko4e6d3242021-05-26 09:13:24 +0200160 * Use ::nc_connect_ssh_channel() for this purpose.
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100161 *
162 * Functions List
163 * --------------
164 *
165 * Available in __nc_client.h__.
166 *
Michal Vasko4e6d3242021-05-26 09:13:24 +0200167 * - ::nc_client_ssh_set_auth_password_clb()
168 * - ::nc_client_ssh_get_auth_password_clb()
169 * - ::nc_client_ssh_set_auth_interactive_clb()
170 * - ::nc_client_ssh_get_auth_interactive_clb()
171 * - ::nc_client_ssh_set_auth_privkey_passphrase_clb()
172 * - ::nc_client_ssh_get_auth_privkey_passphrase_clb()
173 * - ::nc_client_ssh_add_keypair()
174 * - ::nc_client_ssh_del_keypair()
175 * - ::nc_client_ssh_get_keypair_count()
176 * - ::nc_client_ssh_get_keypair()
177 * - ::nc_client_ssh_set_auth_pref()
178 * - ::nc_client_ssh_get_auth_pref()
179 * - ::nc_client_ssh_set_username()
180 * - ::nc_client_ssh_get_username()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100181 *
Michal Vasko4e6d3242021-05-26 09:13:24 +0200182 * - ::nc_connect_ssh()
183 * - ::nc_connect_libssh()
184 * - ::nc_connect_ssh_channel()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100185 *
Radek Krejci5cebc6b2017-05-26 13:24:38 +0200186 * @anchor howtoclienttls
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100187 * TLS
188 * ===
189 *
Michal Vasko15b7a982016-03-02 10:53:31 +0100190 * To connect to a server using TLS, there must be some client identification
191 * options set. Client must specify its certificate with a private key using
Michal Vasko4e6d3242021-05-26 09:13:24 +0200192 * ::nc_client_tls_set_cert_key_paths(). Also, the Certificate Authority of
Michal Vasko15b7a982016-03-02 10:53:31 +0100193 * a server certificate must be considered trusted. Paths to all the trusted
Michal Vasko4e6d3242021-05-26 09:13:24 +0200194 * CA certificates can be set by ::nc_client_tls_set_trusted_ca_paths().
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100195 *
Michal Vasko4e6d3242021-05-26 09:13:24 +0200196 * Then there are again 2 functions for connecting, ::nc_connect_tls() being
197 * the standard way of connecting. ::nc_connect_libssl() again enables
Michal Vasko15b7a982016-03-02 10:53:31 +0100198 * to customize the TLS session in every way _libssl_ allows.
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100199 *
200 * Functions List
201 * --------------
202 *
203 * Available in __nc_client.h__.
204 *
Michal Vasko4e6d3242021-05-26 09:13:24 +0200205 * - ::nc_client_tls_set_cert_key_paths()
206 * - ::nc_client_tls_get_cert_key_paths()
207 * - ::nc_client_tls_set_trusted_ca_paths()
208 * - ::nc_client_tls_get_trusted_ca_paths()
209 * - ::nc_client_tls_set_crl_paths()
210 * - ::nc_client_tls_get_crl_paths()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100211 *
Michal Vasko4e6d3242021-05-26 09:13:24 +0200212 * - ::nc_connect_tls()
213 * - ::nc_connect_libssl()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100214 *
215 *
Michal Vasko4e6d3242021-05-26 09:13:24 +0200216 * FD and UNIX socket
217 * ==================
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100218 *
219 * If you authenticated the connection using some tunneling software, you
Michal Vasko4e6d3242021-05-26 09:13:24 +0200220 * can pass its file descriptors to _libnetconf2_ using ::nc_connect_inout(),
221 * which will continue to establish a full NETCONF session. To connect locally
romand348b942023-10-13 14:32:19 +0200222 * on a UNIX socket avoiding all cryptography use ::nc_connect_unix().
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100223 *
224 * Funtions List
225 * -------------
226 *
227 * Available in __nc_client.h__.
228 *
Michal Vasko4e6d3242021-05-26 09:13:24 +0200229 * - ::nc_connect_inout()
230 * - ::nc_connect_unix()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100231 *
232 *
Radek Krejci5cebc6b2017-05-26 13:24:38 +0200233 * @anchor howtoclientch
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100234 * Call Home
235 * =========
236 *
237 * Call Home needs the same options set as standard SSH or TLS and the functions
238 * reflect it exactly. However, to accept a connection, the client must first
Michal Vasko4e6d3242021-05-26 09:13:24 +0200239 * specify addresses and ports, which to listen on by ::nc_client_ssh_ch_add_bind_listen()
240 * and ::nc_client_tls_ch_add_bind_listen(). Then connections can be
241 * accepted using ::nc_accept_callhome().
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100242 *
243 * Functions List
244 * --------------
245 *
246 * Available in __nc_client.h__.
247 *
Michal Vasko4e6d3242021-05-26 09:13:24 +0200248 * - ::nc_client_ssh_ch_set_auth_password_clb()
249 * - ::nc_client_ssh_ch_set_auth_interactive_clb()
250 * - ::nc_client_ssh_ch_set_auth_privkey_passphrase_clb()
251 * - ::nc_client_ssh_ch_add_bind_listen()
252 * - ::nc_client_ssh_ch_del_bind()
253 * - ::nc_client_ssh_ch_add_keypair()
254 * - ::nc_client_ssh_ch_del_keypair()
255 * - ::nc_client_ssh_ch_get_keypair_count()
256 * - ::nc_client_ssh_ch_get_keypair()
257 * - ::nc_client_ssh_ch_set_auth_pref()
258 * - ::nc_client_ssh_ch_get_auth_pref()
259 * - ::nc_client_ssh_ch_set_username()
260 * - ::nc_client_ssh_ch_get_username()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100261 *
Michal Vasko4e6d3242021-05-26 09:13:24 +0200262 * - ::nc_client_tls_ch_add_bind_listen()
263 * - ::nc_client_tls_ch_del_bind()
264 * - ::nc_client_tls_ch_set_cert_key_paths()
265 * - ::nc_client_tls_ch_get_cert_key_paths()
266 * - ::nc_client_tls_ch_set_trusted_ca_paths()
267 * - ::nc_client_tls_ch_get_trusted_ca_paths()
268 * - ::nc_client_tls_ch_set_crl_paths()
269 * - ::nc_client_tls_ch_get_crl_paths()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100270 *
Michal Vasko4e6d3242021-05-26 09:13:24 +0200271 * - ::nc_accept_callhome()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100272 *
273 *
274 * Cleanup
275 * =======
276 *
277 * These options and the schema searchpath are stored in dynamically
Michal Vasko15b7a982016-03-02 10:53:31 +0100278 * allocated memory. They are freed as a part of [destroying the client](@ref howtoinit).
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100279 */
280
281/**
282 * @page howtoserver Server sessions
283 *
284 * Init
285 * ====
286 *
Michal Vasko93224072021-11-09 12:14:28 +0100287 * Server must start with [initialization](@ref howtoinit). Its capabilities are
288 * determined by the context used when accepting new NETCONF sessions. Few capabilities that
Michal Vasko15b7a982016-03-02 10:53:31 +0100289 * cannot be learnt from the context are set with separate functions
Michal Vasko4e6d3242021-05-26 09:13:24 +0200290 * ::nc_server_set_capab_withdefaults() and generally ::nc_server_set_capability().
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100291 *
292 * Context does not only determine server modules, but its overall
293 * functionality as well. For every RPC the server should support,
Michal Vasko4e6d3242021-05-26 09:13:24 +0200294 * an nc_rpc_clb callback should be set on that node in the context using ::nc_set_rpc_callback().
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100295 * Server then calls these as appropriate [during poll](@ref howtoservercomm).
296 *
Michal Vasko15b7a982016-03-02 10:53:31 +0100297 * Just like in the [client](@ref howtoclient), you can let _libnetconf2_
298 * establish SSH or TLS transport or do it yourself and only provide the file
299 * descriptors of the connection.
300 *
Roytak09e426c2023-09-29 15:25:55 +0200301 * To be able to accept any connections, the server must first be configured.
Michal Vasko3a889fd2016-09-30 12:16:37 +0200302 *
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100303 * Functions List
304 * --------------
305 *
306 * Available in __nc_server.h__.
307 *
Michal Vasko4e6d3242021-05-26 09:13:24 +0200308 * - ::nc_server_set_capab_withdefaults()
309 * - ::nc_server_set_capability()
romanfb3f7cf2023-11-30 16:10:09 +0100310 * - ::nc_server_endpt_count()
311 * - ::nc_server_add_endpt_unix_socket_listen()
312 * - ::nc_server_del_endpt_unix_socket()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100313 *
Roytak09e426c2023-09-29 15:25:55 +0200314 * Server Configuration
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100315 * ===
316 *
Roytak09e426c2023-09-29 15:25:55 +0200317 * To successfully accept connections on a server, you first need to configure it.
Roytakb2794852023-10-18 14:30:22 +0200318 * The *libnetconf2* server natively supports the *ietf-netconf-server YANG* module.
319 * This allows for a bigger scaling and flexibility of the *NETCONF* server.
320 * By using *ietf-netconf-server YANG* data you can express network configurations
321 * in a standardized and hierarchical format, enabling you to define complex network
322 * structures with greater ease.
Michal Vaskod31b76e2017-02-15 12:18:06 +0100323 *
Roytakb2794852023-10-18 14:30:22 +0200324 * The process of configuring a server is comprised of two steps. The first step is creating the
325 * configuration data and the second is applying it. The server supports two forms of the configuration
326 * data - *YANG data* and *YANG diff*.
Roytak09e426c2023-09-29 15:25:55 +0200327 *
Roytakb2794852023-10-18 14:30:22 +0200328 * YANG data
roman694979e2023-11-02 15:00:09 +0100329 * ---
Roytakb2794852023-10-18 14:30:22 +0200330 * Configuring the server using YANG data simplifies the management of network services.
331 * With YANG data, you build a structured configuration tree and apply it as a whole.
332 * This approach is user-friendly, allowing you to modify the configuration by adding or deleting nodes,
333 * and then deploying the updated configuration tree in its entirety, providing a way to manage your server's settings.
334 * The *libnetconf2* library exports API functions that can help you with creation or deletion of the *YANG* data.
Roytakb2794852023-10-18 14:30:22 +0200335 *
336 * YANG diff
roman694979e2023-11-02 15:00:09 +0100337 * ---
Roytakb2794852023-10-18 14:30:22 +0200338 * YANG diff, enriched with operation attributes, offers advanced configuration control.
339 * It empowers the user to make precise changes within the configuration tree,
340 * enabling operations like specific node deletions, additions, and modifications.
341 * On the other hand, unlike YANG data, YANG diff represents only a subtree of the
342 * changes expecting the whole configuration to be managed externally.
romand348b942023-10-13 14:32:19 +0200343 * For example this is done by the tool [sysrepo](https://www.sysrepo.org/).
Roytakb2794852023-10-18 14:30:22 +0200344 *
345 * Usage
roman694979e2023-11-02 15:00:09 +0100346 * ---
Roytakb2794852023-10-18 14:30:22 +0200347 * To be able to configure the server, the required models first need to be implemented.
348 * To do this, see ::nc_server_config_load_modules().
349 * Not all of the *ietf-netconf-server* (and all of its associated modules) features are enabled.
350 * If you wish to see which features are enabled, extract them from the context after calling the mentioned function.
351 *
352 * If you wish not to create the __YANG data__ yourself, you may use the library's functions to do this for you.
353 * For example ::nc_server_config_add_address_port() creates __YANG data__ corresponding to an SSH/TLS endpoint.
roman50566972023-11-30 16:41:25 +0100354 * You can then apply this data by calling ::nc_server_config_setup_data() (or ::nc_server_config_setup_diff() for diff).
Roytakb2794852023-10-18 14:30:22 +0200355 * See *examples/server.c* for a simple example.
356 *
357 * You may also create entries in the keystore or truststore. For example the asymmetric key and certificate entries
Roytak09e426c2023-09-29 15:25:55 +0200358 * in the keystore can be then referenced as the SSH hostkeys or TLS server certificates, respectively.
359 * As for the truststore, you may create public key and certificate entries, which can then be used
360 * as SSH user's public keys or TLS server's end-entity/trust-anchor certificates, respectively.
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100361 *
362 * Functions List
363 * --------------
364 *
365 * Available in __nc_server.h__.
366 *
Roytak09e426c2023-09-29 15:25:55 +0200367 * - ::nc_server_config_load_modules()
368 * - ::nc_server_config_setup_diff()
369 * - ::nc_server_config_setup_data()
370 * - ::nc_server_config_setup_path()
Michal Vaskod31b76e2017-02-15 12:18:06 +0100371 *
Roytakb2794852023-10-18 14:30:22 +0200372 * - ::nc_server_config_add_address_port()
Roytakb2794852023-10-18 14:30:22 +0200373 * - ::nc_server_config_del_endpt()
Roytakb2794852023-10-18 14:30:22 +0200374 * - ::nc_server_config_add_keystore_asym_key()
375 * - ::nc_server_config_del_keystore_asym_key()
376 * - ::nc_server_config_add_keystore_cert()
377 * - ::nc_server_config_del_keystore_cert()
378 * - ::nc_server_config_add_truststore_pubkey()
379 * - ::nc_server_config_del_truststore_pubkey()
380 * - ::nc_server_config_add_truststore_cert()
381 * - ::nc_server_config_del_truststore_cert()
Michal Vaskod31b76e2017-02-15 12:18:06 +0100382 *
Roytak09e426c2023-09-29 15:25:55 +0200383 * SSH
384 * ===
385 *
386 * To successfully accept an SSH session you must configure at least one host key.
Roytakb2794852023-10-18 14:30:22 +0200387 * You may create this data yourself or by using ::nc_server_config_add_ssh_hostkey().
Roytak09e426c2023-09-29 15:25:55 +0200388 *
389 * On top of that, each SSH endpoint can define it's own authorized clients and their authentication methods.
Roytakb2794852023-10-18 14:30:22 +0200390 * For example if you wish to create an SSH user that can authenticate using a password, use ::nc_server_config_add_ssh_user_password().
Roytak09e426c2023-09-29 15:25:55 +0200391 * Another option for authorized clients is to reference another endpoint's clients, however be careful not to create a cyclic reference
Roytakb2794852023-10-18 14:30:22 +0200392 * (see ::nc_server_config_add_ssh_endpoint_client_ref()). An authorized client MUST authenticate to all of it's configured authentication methods.
Roytak09e426c2023-09-29 15:25:55 +0200393 *
roman50566972023-11-30 16:41:25 +0100394 * \anchor ln2doc_kbdint
395 * The Keyboard Interactive authentication method is also supported. It can be done in three ways.
396 * If libpam is found, Linux PAM is used to handle the authentication. You need to specify the service name using ::nc_server_ssh_set_pam_conf_filename().
397 * Else if the standard functions for accessing local users are found on the system, they are used. The only Keyboard Interactive challenge will be the given
398 * user's password (that is if he's found on the system).
399 * Either way, you can always define your own callback to perform the authentication, see ::nc_server_ssh_set_interactive_auth_clb().
400 * The callback has a higher priority than the other two methods.
401 *
romand348b942023-10-13 14:32:19 +0200402 * There are also some other optional settings.
Roytak09e426c2023-09-29 15:25:55 +0200403 *
404 * Functions List
405 * --------------
406 *
407 * Available in __nc_server.h__.
408 *
Roytakb2794852023-10-18 14:30:22 +0200409 * - ::nc_server_config_add_ssh_hostkey()
410 * - ::nc_server_config_del_ssh_hostkey()
romand348b942023-10-13 14:32:19 +0200411 * - ::nc_server_config_add_ssh_keystore_ref()
412 * - ::nc_server_config_del_ssh_keystore_ref()
Roytak09e426c2023-09-29 15:25:55 +0200413 *
Roytakb2794852023-10-18 14:30:22 +0200414 * - ::nc_server_config_add_ssh_user_pubkey()
415 * - ::nc_server_config_del_ssh_user_pubkey()
416 * - ::nc_server_config_add_ssh_user_password()
417 * - ::nc_server_config_del_ssh_user_password()
418 * - ::nc_server_config_add_ssh_user_interactive()
419 * - ::nc_server_config_del_ssh_user_interactive()
420 * - ::nc_server_config_del_ssh_user()
romand348b942023-10-13 14:32:19 +0200421 * - ::nc_server_config_add_ssh_truststore_ref()
422 * - ::nc_server_config_del_ssh_truststore_ref()
Roytakb2794852023-10-18 14:30:22 +0200423 * - ::nc_server_config_add_ssh_endpoint_client_ref()
424 * - ::nc_server_config_del_ssh_endpoint_client_ref()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100425 *
roman50566972023-11-30 16:41:25 +0100426 * - ::nc_server_ssh_set_pam_conf_filename()
427 * - ::nc_server_ssh_set_interactive_auth_clb()
428 *
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100429 * TLS
430 * ===
431 *
Michal Vasko15b7a982016-03-02 10:53:31 +0100432 * TLS works with endpoints too, but its options differ
433 * significantly from the SSH ones, especially in the _cert-to-name_
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100434 * options that TLS uses to derive usernames from client certificates.
Michal Vasko15b7a982016-03-02 10:53:31 +0100435 *
Roytak09e426c2023-09-29 15:25:55 +0200436 * If you wish to listen on a TLS endpoint, you need to configure the endpoint's
romane6ec60e2023-10-19 15:21:52 +0200437 * server certificate (see ::nc_server_config_add_tls_server_cert()).
Roytak09e426c2023-09-29 15:25:55 +0200438 *
439 * To accept client certificates, they must first be considered trusted.
440 * For each TLS endpoint you may configure two types of client certificates.
441 * The first type are end-entity (client) certificates. These are certificates that belong
442 * to given clients. These certificates need to be trusted.
443 * The second type are trust-anchor (certificate authority) certificates,
444 * which carry over the trust (a chain of trust).
445 * Another option is to reference another TLS endpoint's end-entity certificates, however be careful not to create a cyclic reference
Roytakb2794852023-10-18 14:30:22 +0200446 * (see ::nc_server_config_add_tls_endpoint_client_ref()).
Michal Vasko15b7a982016-03-02 10:53:31 +0100447 *
448 * Then, from each trusted client certificate a username must be derived
449 * for the NETCONF session. This is accomplished by finding a matching
Roytak09e426c2023-09-29 15:25:55 +0200450 * _cert-to-name_ entry.
Michal Vasko15b7a982016-03-02 10:53:31 +0100451 *
Roytak09e426c2023-09-29 15:25:55 +0200452 * There are some further options. For example you can configure the TLS
romand348b942023-10-13 14:32:19 +0200453 * version and ciphers to be used. You may also choose to use a Certificate
romane6ec60e2023-10-19 15:21:52 +0200454 * Revocation List.
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100455 *
456 * Functions List
457 * --------------
458 *
459 * Available in __nc_server.h__.
460 *
romane6ec60e2023-10-19 15:21:52 +0200461 * - ::nc_server_config_add_tls_server_cert()
462 * - ::nc_server_config_del_tls_server_cert()
romand348b942023-10-13 14:32:19 +0200463 * - ::nc_server_config_add_tls_keystore_ref()
464 * - ::nc_server_config_del_tls_keystore_ref()
Michal Vaskod31b76e2017-02-15 12:18:06 +0100465 *
romane6ec60e2023-10-19 15:21:52 +0200466 * - ::nc_server_config_add_tls_client_cert()
467 * - ::nc_server_config_del_tls_client_cert()
romand348b942023-10-13 14:32:19 +0200468 * - ::nc_server_config_add_tls_client_cert_truststore_ref()
469 * - ::nc_server_config_del_tls_client_cert_truststore_ref()
romane6ec60e2023-10-19 15:21:52 +0200470 * - ::nc_server_config_add_tls_ca_cert()
471 * - ::nc_server_config_del_tls_ca_cert()
472 * - ::nc_server_config_add_tls_ca_cert_truststore_ref()
473 * - ::nc_server_config_del_tls_ca_cert_truststore_ref()
Roytakb2794852023-10-18 14:30:22 +0200474 * - ::nc_server_config_add_tls_endpoint_client_ref()
475 * - ::nc_server_config_del_tls_endpoint_client_ref()
476 * - ::nc_server_config_add_tls_ctn()
477 * - ::nc_server_config_del_tls_ctn()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100478 *
479 * FD
480 * ==
481 *
482 * If you used a tunneling software, which does its own authentication,
Michal Vasko15b7a982016-03-02 10:53:31 +0100483 * you can accept a NETCONF session on its file descriptors with
Michal Vasko4e6d3242021-05-26 09:13:24 +0200484 * ::nc_accept_inout().
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100485 *
486 * Functions List
487 * --------------
488 *
489 * Available in __nc_server.h__.
490 *
Michal Vasko4e6d3242021-05-26 09:13:24 +0200491 * - ::nc_accept_inout()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100492 *
493 *
494 * Call Home
495 * =========
496 *
Michal Vaskod31b76e2017-02-15 12:18:06 +0100497 * _Call Home_ works with endpoints just like standard sessions, but
498 * the options are organized a bit differently and endpoints are added
roman450c00b2023-11-02 10:31:45 +0100499 * for CH clients.
500 * You may choose one of two approaches for creating a new Call Home
501 * session (or in other words making a server connect to a client).
502 * The first is to set all the required callbacks
503 * by calling ::nc_server_ch_set_dispatch_data(). By setting the callbacks,
504 * the server will automatically start connecting to a client, whenever
505 * a new Call Home client is created.
506 * The second approach is to create the Call Home thread manually.
507 * To do this, you need to call ::nc_connect_ch_client_dispatch(),
508 * which then creates a new thread and the server will start to connect.
Roytak09e426c2023-09-29 15:25:55 +0200509 * Unix socket _Call Home_ sessions are not supported.
Michal Vaskod31b76e2017-02-15 12:18:06 +0100510 *
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100511 * Functions List
512 * --------------
513 *
514 * Available in __nc_server.h__.
515 *
Roytakb2794852023-10-18 14:30:22 +0200516 * - ::nc_server_config_add_ch_address_port()
517 * - ::nc_server_config_del_ch_client()
518 * - ::nc_server_config_del_ch_endpt()
519 * - ::nc_server_config_add_ch_persistent()
520 * - ::nc_server_config_add_ch_period()
521 * - ::nc_server_config_del_ch_period()
522 * - ::nc_server_config_add_ch_anchor_time()
523 * - ::nc_server_config_del_ch_anchor_time()
524 * - ::nc_server_config_add_ch_idle_timeout()
525 * - ::nc_server_config_del_ch_idle_timeout()
526 * - ::nc_server_config_add_ch_reconnect_strategy()
527 * - ::nc_server_config_del_ch_reconnect_strategy()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100528 *
Roytakb2794852023-10-18 14:30:22 +0200529 * - ::nc_server_config_add_ch_ssh_hostkey()
530 * - ::nc_server_config_del_ch_ssh_hostkey()
romand348b942023-10-13 14:32:19 +0200531 * - ::nc_server_config_add_ch_ssh_keystore_ref()
532 * - ::nc_server_config_del_ch_ssh_keystore_ref()
Roytakb2794852023-10-18 14:30:22 +0200533 * - ::nc_server_config_add_ch_ssh_user_pubkey()
534 * - ::nc_server_config_del_ch_ssh_user_pubkey()
535 * - ::nc_server_config_add_ch_ssh_user_password()
536 * - ::nc_server_config_del_ch_ssh_user_password()
537 * - ::nc_server_config_add_ch_ssh_user_interactive()
538 * - ::nc_server_config_del_ch_ssh_user_interactive()
539 * - ::nc_server_config_del_ch_ssh_user()
romand348b942023-10-13 14:32:19 +0200540 * - ::nc_server_config_add_ch_ssh_truststore_ref()
541 * - ::nc_server_config_del_ch_ssh_truststore_ref()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100542 *
romane6ec60e2023-10-19 15:21:52 +0200543 * - ::nc_server_config_add_ch_tls_server_cert()
544 * - ::nc_server_config_del_ch_tls_server_cert()
romand348b942023-10-13 14:32:19 +0200545 * - ::nc_server_config_add_ch_tls_keystore_ref()
546 * - ::nc_server_config_del_ch_tls_keystore_ref()
romane6ec60e2023-10-19 15:21:52 +0200547 * - ::nc_server_config_add_ch_tls_client_cert()
548 * - ::nc_server_config_del_ch_tls_client_cert()
romand348b942023-10-13 14:32:19 +0200549 * - ::nc_server_config_add_ch_tls_client_cert_truststore_ref()
550 * - ::nc_server_config_del_ch_tls_client_cert_truststore_ref()
romane6ec60e2023-10-19 15:21:52 +0200551 * - ::nc_server_config_add_ch_tls_ca_cert()
552 * - ::nc_server_config_del_ch_tls_ca_cert()
553 * - ::nc_server_config_add_ch_tls_ca_cert_truststore_ref()
554 * - ::nc_server_config_del_ch_tls_ca_cert_truststore_ref()
Roytakb2794852023-10-18 14:30:22 +0200555 * - ::nc_server_config_add_ch_tls_ctn()
556 * - ::nc_server_config_del_ch_tls_ctn()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100557 *
558 * Connecting And Cleanup
559 * ======================
560 *
Michal Vasko4e6d3242021-05-26 09:13:24 +0200561 * When accepting connections with ::nc_accept(), all the endpoints are examined
Michal Vaskod31b76e2017-02-15 12:18:06 +0100562 * and the first with a pending connection is used. To remove all CH clients,
563 * endpoints, and free any used dynamic memory, [destroy](@ref howtoinit) the server.
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100564 *
565 * Functions List
566 * --------------
567 *
568 * Available in __nc_server.h__.
569 *
Michal Vasko4e6d3242021-05-26 09:13:24 +0200570 * - ::nc_accept()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100571 */
572
573/**
574 * @page howtoclientcomm Client communication
575 *
Michal Vasko4e6d3242021-05-26 09:13:24 +0200576 * To send RPCs on a session, you simply create an RPC, send it using ::nc_send_rpc(),
577 * and then wait for a reply using ::nc_recv_reply(). If you are subscribed, there are 2 ways
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100578 * of receiving notifications. Either you wait for them the same way
Michal Vasko4e6d3242021-05-26 09:13:24 +0200579 * as for standard replies with ::nc_recv_notif() or you create a dispatcher
580 * with ::nc_recv_notif_dispatch() that asynchronously (in a separate thread)
Michal Vasko15b7a982016-03-02 10:53:31 +0100581 * reads notifications and passes them to your callback.
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100582 *
583 * Functions List
584 * --------------
585 *
586 * Available in __nc_client.h__.
587 *
Michal Vasko4e6d3242021-05-26 09:13:24 +0200588 * - ::nc_rpc_act_generic()
589 * - ::nc_rpc_act_generic_xml()
590 * - ::nc_rpc_getconfig()
591 * - ::nc_rpc_edit()
592 * - ::nc_rpc_copy()
593 * - ::nc_rpc_delete()
594 * - ::nc_rpc_lock()
595 * - ::nc_rpc_unlock()
596 * - ::nc_rpc_get()
597 * - ::nc_rpc_kill()
598 * - ::nc_rpc_commit()
599 * - ::nc_rpc_discard()
600 * - ::nc_rpc_cancel()
601 * - ::nc_rpc_validate()
602 * - ::nc_rpc_getschema()
603 * - ::nc_rpc_subscribe()
604 * - ::nc_rpc_getdata()
605 * - ::nc_rpc_editdata()
606 * - ::nc_rpc_establishsub()
607 * - ::nc_rpc_modifysub()
608 * - ::nc_rpc_deletesub()
609 * - ::nc_rpc_killsub()
610 * - ::nc_rpc_establishpush_periodic()
611 * - ::nc_rpc_establishpush_onchange()
612 * - ::nc_rpc_modifypush_periodic()
613 * - ::nc_rpc_modifypush_onchange()
614 * - ::nc_rpc_resyncsub()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100615 *
Michal Vasko4e6d3242021-05-26 09:13:24 +0200616 * - ::nc_send_rpc()
617 * - ::nc_recv_reply()
618 * - ::nc_recv_notif()
619 * - ::nc_recv_notif_dispatch()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100620 */
621
622/**
623 * @page howtoservercomm Server communication
624 *
625 * Once at least one session is established, an nc_pollsession structure
Michal Vasko4e6d3242021-05-26 09:13:24 +0200626 * should be created with ::nc_ps_new(), filled with the session using
627 * ::nc_ps_add_session() and finally polled with ::nc_ps_poll(). Based on
Michal Vasko15b7a982016-03-02 10:53:31 +0100628 * the return value from the poll, further actions can be taken. More
629 * sessions can be polled at the same time and any requests received on
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100630 * the sessions are [handled internally](@ref howtoserver).
631 *
Michal Vasko15b7a982016-03-02 10:53:31 +0100632 * If an SSH NETCONF session asks for a new channel, you can accept
Michal Vasko4e6d3242021-05-26 09:13:24 +0200633 * this request with ::nc_ps_accept_ssh_channel() or ::nc_session_accept_ssh_channel()
Michal Vasko3a889fd2016-09-30 12:16:37 +0200634 * depending on the structure you want to use as the argument.
Michal Vasko15b7a982016-03-02 10:53:31 +0100635 *
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100636 * Functions List
637 * --------------
638 *
Michal Vasko15b7a982016-03-02 10:53:31 +0100639 * Available in __nc_server.h__.
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100640 *
Michal Vasko4e6d3242021-05-26 09:13:24 +0200641 * - ::nc_ps_new()
642 * - ::nc_ps_add_session()
643 * - ::nc_ps_del_session()
644 * - ::nc_ps_session_count()
645 * - ::nc_ps_free()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100646 *
Michal Vasko4e6d3242021-05-26 09:13:24 +0200647 * - ::nc_ps_poll()
648 * - ::nc_ps_clear()
649 * - ::nc_ps_accept_ssh_channel()
650 * - ::nc_session_accept_ssh_channel()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100651 */
652
Michal Vaskoee087c62017-02-15 11:27:16 +0100653/**
654 * @page howtotimeouts Timeouts
655 *
656 * There are several timeouts which are used throughout _libnetconf2_ to
657 * assure that it will never indefinitely hang on any operation. Normally,
Roytak09e426c2023-09-29 15:25:55 +0200658 * you should not need to worry about them much because they are set by
Michal Vaskoee087c62017-02-15 11:27:16 +0100659 * default to reasonable values for common systems. However, if your
660 * platform is not common (embedded, ...), adjusting these timeouts may
661 * save a lot of debugging and time.
662 *
663 * Compile Options
664 * ---------------
665 *
666 * You can adjust active and inactive read timeout using `cmake` variables.
667 * For details look into `README.md`.
668 *
romaneaf84c72023-10-19 14:38:05 +0200669 * Configurable timeouts
670 * ---------------------
Michal Vaskoee087c62017-02-15 11:27:16 +0100671 *
672 * Once a new connection is established including transport protocol negotiations,
673 * _hello_ message is exchanged. You can set how long will the server wait for
674 * receiving this message from a client before dropping it.
675 *
676 * Having a NETCONF session working, it may not communicate for a longer time.
677 * To free up some resources, it is possible to adjust the maximum idle period
678 * of a session before it is disconnected. In _Call Home_, for both a persistent
679 * and periodic connection can this idle timeout be specified separately for each
romaneaf84c72023-10-19 14:38:05 +0200680 * client. Lastly, SSH user authentication timeout can be also modified. It is the time
Michal Vaskoee087c62017-02-15 11:27:16 +0100681 * a client has to successfully authenticate after connecting before it is disconnected.
682 *
romaneaf84c72023-10-19 14:38:05 +0200683 * These timeouts can be toggled by applying corresponding configuration data.
Michal Vaskoee087c62017-02-15 11:27:16 +0100684 */
685
Radek Krejci6799a052017-05-19 14:23:23 +0200686/**
687 * @defgroup misc Miscellaneous
688 * @brief Miscellaneous macros, types, structure and functions for a generic use by both server and client applications.
689 */
690
691/**
692 * @defgroup client Client
693 * @brief NETCONF client functionality.
694 */
695
696/**
697 * @defgroup server Server
698 * @brief NETCONF server functionality.
roman35120972023-08-08 10:39:12 +0200699 * @{
700 * @} Server
Radek Krejci6799a052017-05-19 14:23:23 +0200701 */