blob: 2c38dc2f71dc8e680519de038150cfcf57fe563b [file] [log] [blame]
Radek Krejcid0d19522015-09-02 13:49:25 +02001/**
2 * \file libnetconf.h
3 * \author Radek Krejci <rkrejci@cesnet.cz>
Michal Vaskofdfd9dd2016-02-29 10:18:46 +01004 * \author Michal Vasko <mvasko@cesnet.cz>
Radek Krejcid0d19522015-09-02 13:49:25 +02005 * \brief libnetconf2 main internal header.
6 *
7 * Copyright (c) 2015 CESNET, z.s.p.o.
8 *
Radek Krejci9b81f5b2016-02-24 13:14:49 +01009 * 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 Vaskoafd416b2016-02-25 14:51:46 +010012 *
Radek Krejci9b81f5b2016-02-24 13:14:49 +010013 * https://opensource.org/licenses/BSD-3-Clause
Radek Krejcid0d19522015-09-02 13:49:25 +020014 */
15
16#ifndef NC_LIBNETCONF_H_
17#define NC_LIBNETCONF_H_
18
19#include "config.h"
Radek Krejci206fcd62015-10-07 15:42:48 +020020#include "netconf.h"
Radek Krejcid0d19522015-09-02 13:49:25 +020021#include "log_p.h"
Radek Krejciac6d3472015-10-22 15:47:18 +020022#include "session_p.h"
23#include "messages_p.h"
Radek Krejciac6d3472015-10-22 15:47:18 +020024
25/* Tests whether string is empty or non-empty. */
26#define strisempty(str) ((str)[0] == '\0')
27#define strnonempty(str) ((str)[0] != '\0')
Radek Krejcid0d19522015-09-02 13:49:25 +020028
Michal Vaskofdfd9dd2016-02-29 10:18:46 +010029/**
30 * @mainpage About
31 *
32 * libnetconf2 is a NETCONF library in C handling NETCONF authentication and all NETCONF
33 * RPC communication both server and client-side. NETCONF datastore and session management is not a part of this library,
34 * but it helps a lot with the sessions.
35 *
36 * @section about-features Main Features
37 *
38 * - Creating SSH (using libssh) or TLS (using OpenSSL) authenticated NETCONF sessions.
39 * - Creating NETCONF sessions with a pre-established transport protocol
40 * (using this mechanism the communication can be tunneled through sshd(8), for instance).
41 * - Creating NETCONF Call Home sessions.
42 * - Creating, sending, receiving, and replying to RPCs.
43 * - Receiving notifications.
44 *
45 * - \todo Creating and sending notifications.
46 *
47 * @section about-license License
48 *
Michal Vaskoee087c62017-02-15 11:27:16 +010049 * Copyright (c) 2015-2017 CESNET, z.s.p.o.
Michal Vaskofdfd9dd2016-02-29 10:18:46 +010050 *
51 * (The BSD 3-Clause License)
52 *
53 * Redistribution and use in source and binary forms, with or without
54 * modification, are permitted provided that the following conditions
55 * are met:
56 * 1. Redistributions of source code must retain the above copyright
57 * notice, this list of conditions and the following disclaimer.
58 * 2. Redistributions in binary form must reproduce the above copyright
59 * notice, this list of conditions and the following disclaimer in
60 * the documentation and/or other materials provided with the
61 * distribution.
62 * 3. Neither the name of the Company nor the names of its contributors
63 * may be used to endorse or promote products derived from this
64 * software without specific prior written permission.
65 */
66
67/**
68 * @page howto How To ...
69 *
70 * - @subpage howtoinit
71 * - @subpage howtoclient
72 * - @subpage howtoserver
73 * - @subpage howtoclientcomm
74 * - @subpage howtoservercomm
Michal Vaskoee087c62017-02-15 11:27:16 +010075 * - @subpage howtotimeouts
Michal Vaskofdfd9dd2016-02-29 10:18:46 +010076 */
77
78/**
79 * @page howtoinit Init and Thread-safety Information
80 *
Michal Vaskoa7b8ca52016-03-01 12:09:29 +010081 * Before working with the library, it must be initialized using nc_client_init()
Michal Vasko26394692016-03-17 16:24:55 +010082 * or nc_server_init(). Optionally, a client can use nc_client_set_schema_searchpath()
83 * to set the path to a directory with modules that will be loaded from there if they
84 * could not be downloaded from the server (it does not support \<get-schema\>).
85 * However, to be able to create at least the \<get-schema\> RPC, this directory must
86 * contain the module _ietf-netconf-monitoring_. If this directory is not set,
87 * the default _libnetconf2_ schema directory is used that includes this module
88 * and a few others.
89 *
90 * Based on how the library was compiled, also _libssh_ and/or
Michal Vasko15b7a982016-03-02 10:53:31 +010091 * _libssh_/_libcrypto_ are initialized (for multi-threaded use) too. It is advised
92 * to compile _libnetconf2_, for instance, with TLS support even if you do not want
93 * to use _lnc2_ TLS functions, but only use _libssl/libcrypto_ functions in your
94 * application. You can then use _libnetconf2_ cleanup function and do not
Michal Vaskoa7b8ca52016-03-01 12:09:29 +010095 * trouble yourself with the cleanup.
Michal Vaskofdfd9dd2016-02-29 10:18:46 +010096 *
97 * To prevent any reachable memory at the end of your application, there
98 * are complementary destroy functions available. If your application is
99 * multi-threaded, call the destroy functions in the last thread, after all
100 * the other threads have ended. In every other thread you should call
101 * nc_thread_destroy() just before it exits.
102 *
Michal Vasko15b7a982016-03-02 10:53:31 +0100103 * If _libnetconf2_ is used in accordance with this information, there should
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100104 * not be memory leaks of any kind at program exit. For thread-safety details
Michal Vasko15b7a982016-03-02 10:53:31 +0100105 * of _libssh_, _libssl_, and _libcrypto_, please refer to the corresponding project
106 * documentation. _libnetconf2_ thread-safety information is below.
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100107 *
Michal Vasko15b7a982016-03-02 10:53:31 +0100108 * Client is __NOT__ thread-safe and there is no access control in the client
Michal Vaskoade892d2017-02-22 13:40:35 +0100109 * functions at all. Server is __FULLY__ thread-safe meaning you can set all the
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100110 * options simultaneously while listening for or accepting new sessions or
Michal Vaskoade892d2017-02-22 13:40:35 +0100111 * polling the existing ones. It is even safe to poll one session in several
112 * pollsession structures or one pollsession structure in several threads. Generally,
113 * servers can use more threads without any problems as long as they keep their workflow sane
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100114 * (behavior such as freeing sessions only after no thread uses them or similar).
115 *
116 * Functions List
117 * --------------
118 *
Michal Vaskoa7b8ca52016-03-01 12:09:29 +0100119 * Available in __nc_client.h__.
120 *
121 * - nc_client_init()
122 * - nc_client_destroy()
123 *
Michal Vasko26394692016-03-17 16:24:55 +0100124 * - nc_client_set_schema_searchpath()
125 * - nc_client_get_schema_searchpath()
126 *
Michal Vaskoa7b8ca52016-03-01 12:09:29 +0100127 * Available in __nc_server.h__.
128 *
129 * - nc_server_init()
130 * - nc_server_destroy()
131 *
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100132 * Available in both __nc_client.h__ and __nc_server.h__.
133 *
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100134 * - nc_thread_destroy()
135 */
136
137/**
138 * @page howtoclient Client sessions
139 *
Michal Vasko15b7a982016-03-02 10:53:31 +0100140 * To connect to a NETCONF server, a NETCONF session must be established,
141 * which requires a working transport session. It is possible to create
142 * NETCONF sessions with SSH (using _libssh_) or TLS (using _libssl/libcrypto_)
143 * as the underlying transport protocol. It is also possible to establish
144 * the transport protocol outside _libnetconf2_ and then provide these file
145 * descriptors (FD) for full NETCONF session creation.
146 *
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100147 * There are a lot of options for both an SSH and a TLS client. All of them
148 * have setters and getters so that there is no need to duplicate them in
149 * a client.
150 *
151 * SSH
152 * ===
153 *
Michal Vasko15b7a982016-03-02 10:53:31 +0100154 * Connecting to a server using SSH does not strictly require to set any
155 * options, there are sensible default values for all the basic ones.
156 * Except all the SSH options, optionally some authetication callbacks can be set,
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100157 * which are particulary useful in automated clients (passwords cannot be
158 * asked a user) or simply if any additional information is retrieved some
159 * other way than from standard terminal input.
160 *
Michal Vasko15b7a982016-03-02 10:53:31 +0100161 * Having the default options or changing any unsuitable ones, there are 2 functions
162 * to use for a new server connection. nc_connect_ssh() is the standard function
163 * that creates sessions using the set options. If there are some options, which
164 * cannot be changed with the provided API, there is nc_connect_libssh() available.
165 * It requires a _libssh_ session, in which all the SSH options can be modified
166 * and even the connection established. This allows for full customization and
167 * should fit any specific situation.
168 *
169 * New NETCONF sessions can also be created on existing authenticated SSH sessions.
170 * There is a new SSH channel needed, on which the NETCONF session is then created.
171 * Use nc_connect_ssh_channel() for this purpose.
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100172 *
173 * Functions List
174 * --------------
175 *
176 * Available in __nc_client.h__.
177 *
178 * - nc_client_ssh_set_auth_hostkey_check_clb()
179 * - nc_client_ssh_set_auth_password_clb()
180 * - nc_client_ssh_set_auth_interactive_clb()
181 * - nc_client_ssh_set_auth_privkey_passphrase_clb()
182 * - nc_client_ssh_add_keypair()
183 * - nc_client_ssh_del_keypair()
184 * - nc_client_ssh_get_keypair_count()
185 * - nc_client_ssh_get_keypair()
186 * - nc_client_ssh_set_auth_pref()
187 * - nc_client_ssh_get_auth_pref()
188 * - nc_client_ssh_set_username()
189 * - nc_client_ssh_get_username()
190 *
191 * - nc_connect_ssh()
192 * - nc_connect_libssh()
193 * - nc_connect_ssh_channel()
194 *
195 *
196 * TLS
197 * ===
198 *
Michal Vasko15b7a982016-03-02 10:53:31 +0100199 * To connect to a server using TLS, there must be some client identification
200 * options set. Client must specify its certificate with a private key using
201 * nc_client_tls_set_cert_key_paths(). Also, the Certificate Authority of
202 * a server certificate must be considered trusted. Paths to all the trusted
203 * CA certificates can be set by nc_client_tls_set_trusted_ca_paths().
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100204 *
Michal Vasko15b7a982016-03-02 10:53:31 +0100205 * Then there are again 2 functions for connecting, nc_connect_tls() being
206 * the standard way of connecting. nc_connect_libssl() again enables
207 * to customize the TLS session in every way _libssl_ allows.
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100208 *
209 * Functions List
210 * --------------
211 *
212 * Available in __nc_client.h__.
213 *
214 * - nc_client_tls_set_cert_key_paths()
215 * - nc_client_tls_get_cert_key_paths()
216 * - nc_client_tls_set_trusted_ca_paths()
217 * - nc_client_tls_get_trusted_ca_paths()
218 * - nc_client_tls_set_crl_paths()
219 * - nc_client_tls_get_crl_paths()
220 *
221 * - nc_connect_tls()
222 * - nc_connect_libssl()
223 *
224 *
225 * FD
226 * ==
227 *
228 * If you authenticated the connection using some tunneling software, you
Michal Vasko15b7a982016-03-02 10:53:31 +0100229 * can pass its file descriptors to _libnetconf2_ using nc_connect_inout(),
230 * which will continue to establish a full NETCONF session.
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100231 *
232 * Funtions List
233 * -------------
234 *
235 * Available in __nc_client.h__.
236 *
237 * - nc_connect_inout()
238 *
239 *
240 * Call Home
241 * =========
242 *
243 * Call Home needs the same options set as standard SSH or TLS and the functions
244 * reflect it exactly. However, to accept a connection, the client must first
Michal Vasko15b7a982016-03-02 10:53:31 +0100245 * specify addresses and ports, which to listen on by nc_client_ssh_ch_add_bind_listen()
246 * and nc_client_tls_ch_add_bind_listen(). Then connections can be
247 * accepted using nc_accept_callhome().
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100248 *
249 * Functions List
250 * --------------
251 *
252 * Available in __nc_client.h__.
253 *
254 * - nc_client_ssh_ch_set_auth_hostkey_check_clb()
255 * - nc_client_ssh_ch_set_auth_password_clb()
256 * - nc_client_ssh_ch_set_auth_interactive_clb()
257 * - nc_client_ssh_ch_set_auth_privkey_passphrase_clb()
258 * - nc_client_ssh_ch_add_bind_listen()
259 * - nc_client_ssh_ch_del_bind()
260 * - nc_client_ssh_ch_add_keypair()
261 * - nc_client_ssh_ch_del_keypair()
262 * - nc_client_ssh_ch_get_keypair_count()
263 * - nc_client_ssh_ch_get_keypair()
264 * - nc_client_ssh_ch_set_auth_pref()
265 * - nc_client_ssh_ch_get_auth_pref()
266 * - nc_client_ssh_ch_set_username()
267 * - nc_client_ssh_ch_get_username()
268 *
269 * - nc_client_tls_ch_add_bind_listen()
270 * - nc_client_tls_ch_del_bind()
271 * - nc_client_tls_ch_set_cert_key_paths()
272 * - nc_client_tls_ch_get_cert_key_paths()
273 * - nc_client_tls_ch_set_trusted_ca_paths()
274 * - nc_client_tls_ch_get_trusted_ca_paths()
275 * - nc_client_tls_ch_set_crl_paths()
276 * - nc_client_tls_ch_get_crl_paths()
277 *
278 * - nc_accept_callhome()
279 *
280 *
281 * Cleanup
282 * =======
283 *
284 * These options and the schema searchpath are stored in dynamically
Michal Vasko15b7a982016-03-02 10:53:31 +0100285 * allocated memory. They are freed as a part of [destroying the client](@ref howtoinit).
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100286 */
287
288/**
289 * @page howtoserver Server sessions
290 *
291 * Init
292 * ====
293 *
Michal Vaskoa7b8ca52016-03-01 12:09:29 +0100294 * Server takes an argument for its [initialization function](@ref howtoinit).
295 * In it, you set the server context, which determines what modules it
296 * supports and what capabilities to advertise. Few capabilities that
Michal Vasko15b7a982016-03-02 10:53:31 +0100297 * cannot be learnt from the context are set with separate functions
Michal Vaskod31b76e2017-02-15 12:18:06 +0100298 * nc_server_set_capab_withdefaults() and generally nc_server_set_capability().
Michal Vasko15b7a982016-03-02 10:53:31 +0100299 * Timeout for receiving the _hello_ message on a new session can be set
300 * by nc_server_set_hello_timeout() and the timeout for disconnecting
301 * an inactive session by nc_server_set_idle_timeout().
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100302 *
303 * Context does not only determine server modules, but its overall
304 * functionality as well. For every RPC the server should support,
Michal Vasko3a889fd2016-09-30 12:16:37 +0200305 * 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 +0100306 * Server then calls these as appropriate [during poll](@ref howtoservercomm).
307 *
Michal Vasko15b7a982016-03-02 10:53:31 +0100308 * Just like in the [client](@ref howtoclient), you can let _libnetconf2_
309 * establish SSH or TLS transport or do it yourself and only provide the file
310 * descriptors of the connection.
311 *
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100312 * Server options can be only set, there are no getters.
313 *
Michal Vaskod31b76e2017-02-15 12:18:06 +0100314 * To be able to accept any connections, endpoints must first be added
315 * with nc_server_add_endpt() and configured with nc_server_endpt_set_address()
316 * and nc_server_endpt_set_port().
Michal Vasko3a889fd2016-09-30 12:16:37 +0200317 *
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100318 * Functions List
319 * --------------
320 *
321 * Available in __nc_server.h__.
322 *
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100323 * - nc_server_set_capab_withdefaults()
Michal Vaskod31b76e2017-02-15 12:18:06 +0100324 * - nc_server_set_capability()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100325 * - nc_server_set_hello_timeout()
326 * - nc_server_set_idle_timeout()
327 *
Michal Vasko3a889fd2016-09-30 12:16:37 +0200328 * - nc_server_add_endpt()
329 * - nc_server_del_endpt()
Michal Vaskod31b76e2017-02-15 12:18:06 +0100330 * - nc_server_endpt_set_address()
331 * - nc_server_endpt_set_port()
Michal Vasko3a889fd2016-09-30 12:16:37 +0200332 *
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100333 *
334 * SSH
335 * ===
336 *
Michal Vaskod31b76e2017-02-15 12:18:06 +0100337 * To successfully accept an SSH session you must set at least the host key using
338 * nc_server_ssh_endpt_add_hostkey(), which are ordered. This way you simply add
339 * some hostkey identifier, but the key itself will be retrieved always when needed
340 * by calling the callback set by nc_server_ssh_set_hostkey_clb().
341 *
342 * There are also some other optional settings. Note that authorized
343 * public keys are set for the server as a whole, not endpoint-specifically.
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100344 *
345 * Functions List
346 * --------------
347 *
348 * Available in __nc_server.h__.
349 *
Michal Vasko3a889fd2016-09-30 12:16:37 +0200350 * - nc_server_ssh_endpt_add_hostkey()
351 * - nc_server_ssh_endpt_del_hostkey()
Michal Vaskod31b76e2017-02-15 12:18:06 +0100352 * - nc_server_ssh_endpt_mov_hostkey()
353 * - nc_server_ssh_endpt_mod_hostkey()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100354 * - nc_server_ssh_endpt_set_banner()
355 * - nc_server_ssh_endpt_set_auth_methods()
356 * - nc_server_ssh_endpt_set_auth_attempts()
357 * - nc_server_ssh_endpt_set_auth_timeout()
Michal Vaskod31b76e2017-02-15 12:18:06 +0100358 *
359 * - nc_server_ssh_set_hostkey_clb()
360 *
361 * - nc_server_ssh_add_authkey()
362 * - nc_server_ssh_add_authkey_path()
363 * - nc_server_ssh_del_authkey()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100364 *
365 *
366 * TLS
367 * ===
368 *
Michal Vasko15b7a982016-03-02 10:53:31 +0100369 * TLS works with endpoints too, but its options differ
370 * significantly from the SSH ones, especially in the _cert-to-name_
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100371 * options that TLS uses to derive usernames from client certificates.
Michal Vaskod31b76e2017-02-15 12:18:06 +0100372 * So, after starting listening on an endpoint you need to set the server
373 * certificate (nc_server_tls_endpt_set_server_cert()). Its actual content
374 * together with the matching private key will be loaded using a callback
375 * from nc_server_tls_set_server_cert_clb().
Michal Vasko15b7a982016-03-02 10:53:31 +0100376 *
377 * To accept client certificates, they must first be considered trusted,
378 * which you have three ways of achieving. You can add each of their Certificate Authority
379 * certificates to the trusted ones or mark a specific client certificate
Michal Vaskod31b76e2017-02-15 12:18:06 +0100380 * as trusted. Lastly, you can set paths with all the trusted CA certificates
381 * with nc_server_tls_endpt_set_trusted_ca_paths(). Adding specific certificates
382 * is also performed only as an arbitrary identificator and later retrieved from
383 * callback set by nc_server_tls_set_trusted_cert_list_clb(). But, you can add
384 * certficates as whole lists, not one-by-one.
Michal Vasko15b7a982016-03-02 10:53:31 +0100385 *
386 * Then, from each trusted client certificate a username must be derived
387 * for the NETCONF session. This is accomplished by finding a matching
388 * _cert-to-name_ entry. They are added using nc_server_tls_endpt_add_ctn().
389 *
Michal Vaskod31b76e2017-02-15 12:18:06 +0100390 * If you need to remove trusted certificates, you can do so with nc_server_tls_endpt_del_trusted_cert_list().
Michal Vasko3a889fd2016-09-30 12:16:37 +0200391 * To clear all Certificate Revocation Lists use nc_server_tls_endpt_clear_crls().
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100392 *
393 * Functions List
394 * --------------
395 *
396 * Available in __nc_server.h__.
397 *
Michal Vaskod31b76e2017-02-15 12:18:06 +0100398 * - nc_server_tls_endpt_set_server_cert()
399 * - nc_server_tls_endpt_add_trusted_cert_list()
400 * - nc_server_tls_endpt_del_trusted_cert_list()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100401 * - nc_server_tls_endpt_set_trusted_ca_paths()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100402 * - nc_server_tls_endpt_set_crl_paths()
403 * - nc_server_tls_endpt_clear_crls()
404 * - nc_server_tls_endpt_add_ctn()
405 * - nc_server_tls_endpt_del_ctn()
Michal Vaskod31b76e2017-02-15 12:18:06 +0100406 * - nc_server_tls_endpt_get_ctn()
407 *
408 * - nc_server_tls_set_server_cert_clb()
409 * - nc_server_tls_set_trusted_cert_list_clb()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100410 *
411 * FD
412 * ==
413 *
414 * If you used a tunneling software, which does its own authentication,
Michal Vasko15b7a982016-03-02 10:53:31 +0100415 * you can accept a NETCONF session on its file descriptors with
416 * nc_accept_inout().
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100417 *
418 * Functions List
419 * --------------
420 *
421 * Available in __nc_server.h__.
422 *
423 * - nc_accept_inout()
424 *
425 *
426 * Call Home
427 * =========
428 *
Michal Vaskod31b76e2017-02-15 12:18:06 +0100429 * _Call Home_ works with endpoints just like standard sessions, but
430 * the options are organized a bit differently and endpoints are added
431 * for CH clients. However, one important difference is that
432 * once all the mandatory options are set, _libnetconf2_ __will not__
433 * immediately start connecting to a client. It will do so only after
434 * calling nc_connect_ch_client_dispatch() in a separate thread.
435 *
436 * Lastly, monitoring of these sessions is up to the application.
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100437 *
438 * Functions List
439 * --------------
440 *
441 * Available in __nc_server.h__.
442 *
Michal Vaskod31b76e2017-02-15 12:18:06 +0100443 * - nc_server_ch_add_client()
444 * - nc_server_ch_del_client()
445 * - nc_server_ch_client_add_endpt()
446 * - nc_server_ch_client_del_endpt()
447 * - nc_server_ch_client_endpt_set_address()
448 * - nc_server_ch_client_endpt_set_port()
449 * - nc_server_ch_client_set_conn_type()
450 * - nc_server_ch_client_persist_set_idle_timeout()
451 * - nc_server_ch_client_persist_set_keep_alive_max_wait()
452 * - nc_server_ch_client_persist_set_keep_alive_max_attempts()
453 * - nc_server_ch_client_period_set_idle_timeout()
454 * - nc_server_ch_client_period_set_reconnect_timeout()
455 * - nc_server_ch_client_set_start_with()
456 * - nc_server_ch_client_set_max_attempts()
457 * - nc_connect_ch_client_dispatch()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100458 *
Michal Vaskod31b76e2017-02-15 12:18:06 +0100459 * - nc_server_ssh_ch_client_add_hostkey()
460 * - nc_server_ssh_ch_client_del_hostkey()
461 * - nc_server_ssh_ch_client_mov_hostkey()
462 * - nc_server_ssh_ch_client_mod_hostkey()
463 * - nc_server_ssh_ch_client_set_banner()
464 * - nc_server_ssh_ch_client_set_auth_methods()
465 * - nc_server_ssh_ch_client_set_auth_attempts()
466 * - nc_server_ssh_ch_client_set_auth_timeout()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100467 *
Michal Vaskod31b76e2017-02-15 12:18:06 +0100468 * - nc_server_tls_ch_client_set_server_cert()
469 * - nc_server_tls_ch_client_add_trusted_cert_list()
470 * - nc_server_tls_ch_client_del_trusted_cert_list()
471 * - nc_server_tls_ch_client_set_trusted_ca_paths()
472 * - nc_server_tls_ch_client_set_crl_paths()
473 * - nc_server_tls_ch_client_clear_crls()
474 * - nc_server_tls_ch_client_add_ctn()
475 * - nc_server_tls_ch_client_del_ctn()
476 * - nc_server_tls_ch_client_get_ctn()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100477 *
478 *
479 * Connecting And Cleanup
480 * ======================
481 *
Michal Vasko15b7a982016-03-02 10:53:31 +0100482 * When accepting connections with nc_accept(), all the endpoints are examined
Michal Vaskod31b76e2017-02-15 12:18:06 +0100483 * and the first with a pending connection is used. To remove all CH clients,
484 * endpoints, and free any used dynamic memory, [destroy](@ref howtoinit) the server.
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100485 *
486 * Functions List
487 * --------------
488 *
489 * Available in __nc_server.h__.
490 *
491 * - nc_accept()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100492 */
493
494/**
495 * @page howtoclientcomm Client communication
496 *
Michal Vasko15b7a982016-03-02 10:53:31 +0100497 * To send RPCs on a session, you simply create an RPC, send it using nc_send_rpc(),
498 * 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 +0100499 * of receiving notifications. Either you wait for them the same way
Michal Vasko15b7a982016-03-02 10:53:31 +0100500 * as for standard replies with nc_recv_notif() or you create a dispatcher
501 * with nc_recv_notif_dispatch() that asynchronously (in a separate thread)
502 * reads notifications and passes them to your callback.
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100503 *
504 * Functions List
505 * --------------
506 *
507 * Available in __nc_client.h__.
508 *
Michal Vasko3a889fd2016-09-30 12:16:37 +0200509 * - nc_rpc_act_generic()
510 * - nc_rpc_act_generic_xml()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100511 * - nc_rpc_getconfig()
512 * - nc_rpc_edit()
513 * - nc_rpc_copy()
514 * - nc_rpc_delete()
515 * - nc_rpc_lock()
516 * - nc_rpc_unlock()
517 * - nc_rpc_get()
518 * - nc_rpc_kill()
519 * - nc_rpc_commit()
520 * - nc_rpc_discard()
521 * - nc_rpc_cancel()
522 * - nc_rpc_validate()
523 * - nc_rpc_getschema()
524 * - nc_rpc_subscribe()
525 *
526 * - nc_send_rpc()
527 * - nc_recv_reply()
528 * - nc_recv_notif()
529 * - nc_recv_notif_dispatch()
530 */
531
532/**
533 * @page howtoservercomm Server communication
534 *
535 * Once at least one session is established, an nc_pollsession structure
Michal Vasko15b7a982016-03-02 10:53:31 +0100536 * should be created with nc_ps_new(), filled with the session using
537 * nc_ps_add_session() and finally polled with nc_ps_poll(). Based on
538 * the return value from the poll, further actions can be taken. More
539 * sessions can be polled at the same time and any requests received on
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100540 * the sessions are [handled internally](@ref howtoserver).
541 *
Michal Vasko15b7a982016-03-02 10:53:31 +0100542 * If an SSH NETCONF session asks for a new channel, you can accept
Michal Vasko3a889fd2016-09-30 12:16:37 +0200543 * this request with nc_ps_accept_ssh_channel() or nc_session_accept_ssh_channel()
544 * depending on the structure you want to use as the argument.
Michal Vasko15b7a982016-03-02 10:53:31 +0100545 *
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100546 * Functions List
547 * --------------
548 *
Michal Vasko15b7a982016-03-02 10:53:31 +0100549 * Available in __nc_server.h__.
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100550 *
551 * - nc_ps_new()
552 * - nc_ps_add_session()
553 * - nc_ps_del_session()
Michal Vasko0fdb7ac2016-03-01 09:03:12 +0100554 * - nc_ps_session_count()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100555 * - nc_ps_free()
556 *
557 * - nc_ps_poll()
558 * - nc_ps_clear()
559 * - nc_ps_accept_ssh_channel()
Michal Vasko3a889fd2016-09-30 12:16:37 +0200560 * - nc_session_accept_ssh_channel()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100561 */
562
Michal Vaskoee087c62017-02-15 11:27:16 +0100563/**
564 * @page howtotimeouts Timeouts
565 *
566 * There are several timeouts which are used throughout _libnetconf2_ to
567 * assure that it will never indefinitely hang on any operation. Normally,
568 * you should not need to worry about them much necause they are set by
569 * default to reasonable values for common systems. However, if your
570 * platform is not common (embedded, ...), adjusting these timeouts may
571 * save a lot of debugging and time.
572 *
573 * Compile Options
574 * ---------------
575 *
576 * You can adjust active and inactive read timeout using `cmake` variables.
577 * For details look into `README.md`.
578 *
579 * API Functions
580 * -------------
581 *
582 * Once a new connection is established including transport protocol negotiations,
583 * _hello_ message is exchanged. You can set how long will the server wait for
584 * receiving this message from a client before dropping it.
585 *
586 * Having a NETCONF session working, it may not communicate for a longer time.
587 * To free up some resources, it is possible to adjust the maximum idle period
588 * of a session before it is disconnected. In _Call Home_, for both a persistent
589 * and periodic connection can this idle timeout be specified separately for each
590 * client using corresponding functions.
591 *
592 * Lastly, SSH user authentication timeout can be also modified. It is the time
593 * a client has to successfully authenticate after connecting before it is disconnected.
594 *
595 * Functions List
596 * --------------
597 *
598 * Available in __nc_server.h__.
599 *
600 * - nc_server_set_hello_timeout()
601 * - nc_server_set_idle_timeout()
602 * - nc_server_ch_client_persist_set_idle_timeout()
603 * - nc_server_ch_client_period_set_idle_timeout()
604 * - nc_server_ch_client_period_set_reconnect_timeout()
605 * - nc_server_ssh_endpt_set_auth_timeout()
606 * - nc_server_ssh_ch_client_set_auth_timeout()
607 */
608
Radek Krejcid0d19522015-09-02 13:49:25 +0200609#endif /* NC_LIBNETCONF_H_ */