blob: 046e99389838753e78cf5f9a09a4e55e972db7ca [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
109 * functions at all. Server is __MOSTLY__ 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
111 * polling the existing ones. It should even be safe to poll one session in
112 * several threads, but it is definitely discouraged. Generally, servers can
113 * use more threads without any problems as long as they keep their workflow sane
114 * (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
298 * nc_server_set_capab_withdefaults() and nc_server_set_capab_interleave().
299 * 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 Vasko3a889fd2016-09-30 12:16:37 +0200314 * To be able to accept any connections, general endpoints must first be added
315 * with nc_server_add_endpt(). They can then be modified to accept either SSH, TLS,
316 * or both kinds of sessions.
317 *
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()
324 * - nc_server_set_capab_interleave()
325 * - 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()
330 *
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100331 *
332 * SSH
333 * ===
334 *
Michal Vasko3a889fd2016-09-30 12:16:37 +0200335 * To start listening for SSH connections you must set the address
336 * and port to listen on for a particular endpoint using nc_server_ssh_endpt_set_address()
337 * and nc_server_endpt_set_port().
338 * To then successfully accept an SSH session you must also set the host key using
339 * nc_server_ssh_endpt_add_hostkey().
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100340 *
341 * Functions List
342 * --------------
343 *
344 * Available in __nc_server.h__.
345 *
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100346 * - nc_server_ssh_endpt_set_address()
347 * - nc_server_ssh_endpt_set_port()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100348 *
Michal Vasko3a889fd2016-09-30 12:16:37 +0200349 * - nc_server_ssh_endpt_add_hostkey()
350 * - nc_server_ssh_endpt_del_hostkey()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100351 * - nc_server_ssh_endpt_set_banner()
352 * - nc_server_ssh_endpt_set_auth_methods()
353 * - nc_server_ssh_endpt_set_auth_attempts()
354 * - nc_server_ssh_endpt_set_auth_timeout()
355 * - nc_server_ssh_endpt_add_authkey()
356 * - nc_server_ssh_endpt_del_authkey()
357 *
358 *
359 * TLS
360 * ===
361 *
Michal Vasko15b7a982016-03-02 10:53:31 +0100362 * TLS works with endpoints too, but its options differ
363 * significantly from the SSH ones, especially in the _cert-to-name_
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100364 * options that TLS uses to derive usernames from client certificates.
Michal Vasko3a889fd2016-09-30 12:16:37 +0200365 * So, after starting listening on an endpoint by calling nc_server_tls_endpt_set_address()
366 * and nc_server_tls_endpt_set_port(),
Michal Vasko15b7a982016-03-02 10:53:31 +0100367 * you need to set the server certificate (nc_server_tls_endpt_set_cert()
368 * or nc_server_tls_endpt_set_cert_path()) and private key (nc_server_tls_endpt_set_key()
369 * or nc_server_tls_endpt_set_key_path()).
370 *
371 * To accept client certificates, they must first be considered trusted,
372 * which you have three ways of achieving. You can add each of their Certificate Authority
373 * certificates to the trusted ones or mark a specific client certificate
374 * as trusted using nc_server_tls_endpt_add_trusted_cert(). Lastly, you can
375 * set paths with all the trusted CA certificates with nc_server_tls_endpt_set_trusted_ca_paths().
376 *
377 * Then, from each trusted client certificate a username must be derived
378 * for the NETCONF session. This is accomplished by finding a matching
379 * _cert-to-name_ entry. They are added using nc_server_tls_endpt_add_ctn().
380 *
Michal Vasko3a889fd2016-09-30 12:16:37 +0200381 * If you need to remove trusted certificates, you can do so with nc_server_tls_endpt_del_trusted_cert().
382 * To clear all Certificate Revocation Lists use nc_server_tls_endpt_clear_crls().
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100383 *
384 * Functions List
385 * --------------
386 *
387 * Available in __nc_server.h__.
388 *
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100389 * - nc_server_tls_endpt_set_address()
390 * - nc_server_tls_endpt_set_port()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100391 *
392 * - nc_server_tls_endpt_set_cert()
393 * - nc_server_tls_endpt_set_cert_path()
394 * - nc_server_tls_endpt_set_key()
395 * - nc_server_tls_endpt_set_key_path()
396 * - nc_server_tls_endpt_add_trusted_cert()
397 * - nc_server_tls_endpt_add_trusted_cert_path()
398 * - nc_server_tls_endpt_set_trusted_ca_paths()
Michal Vasko3a889fd2016-09-30 12:16:37 +0200399 * - nc_server_tls_endpt_del_trusted_cert();
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100400 * - nc_server_tls_endpt_set_crl_paths()
401 * - nc_server_tls_endpt_clear_crls()
402 * - nc_server_tls_endpt_add_ctn()
403 * - nc_server_tls_endpt_del_ctn()
404 *
405 * FD
406 * ==
407 *
408 * If you used a tunneling software, which does its own authentication,
Michal Vasko15b7a982016-03-02 10:53:31 +0100409 * you can accept a NETCONF session on its file descriptors with
410 * nc_accept_inout().
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100411 *
412 * Functions List
413 * --------------
414 *
415 * Available in __nc_server.h__.
416 *
417 * - nc_accept_inout()
418 *
419 *
420 * Call Home
421 * =========
422 *
423 * Call Home does not work with endpoints like standard sessions.
Michal Vasko15b7a982016-03-02 10:53:31 +0100424 * Connecting is similar to the [client](@ref howtoclient), just call
425 * nc_connect_callhome_ssh() or nc_connect_callhome_tls(). Any options
426 * must be reset manually by nc_server_ssh_ch_clear_opts()
Michal Vasko3a889fd2016-09-30 12:16:37 +0200427 * or using nc_server_tls_ch_del_trusted_cert() and nc_server_tls_ch_clear_crls()
428 * after another Call Home session (with different options than the previous one)
429 * is to be established. Also, monitoring of these sessions is up to the application.
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100430 *
431 * Functions List
432 * --------------
433 *
434 * Available in __nc_server.h__.
435 *
436 * - nc_connect_callhome_ssh()
437 * - nc_connect_callhome_tls()
438 *
Michal Vasko3a889fd2016-09-30 12:16:37 +0200439 * - nc_server_ssh_ch_add_hostkey()
440 * - nc_server_ssh_ch_del_hostkey()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100441 * - nc_server_ssh_ch_set_banner()
442 * - nc_server_ssh_ch_set_auth_methods()
443 * - nc_server_ssh_ch_set_auth_attempts()
444 * - nc_server_ssh_ch_set_auth_timeout()
445 * - nc_server_ssh_ch_add_authkey()
446 * - nc_server_ssh_ch_del_authkey()
447 * - nc_server_ssh_ch_clear_opts()
448 *
449 * - nc_server_tls_ch_set_cert()
450 * - nc_server_tls_ch_set_cert_path()
451 * - nc_server_tls_ch_set_key()
452 * - nc_server_tls_ch_set_key_path()
453 * - nc_server_tls_ch_add_trusted_cert()
454 * - nc_server_tls_ch_add_trusted_cert_path()
455 * - nc_server_tls_ch_set_trusted_ca_paths()
Michal Vasko3a889fd2016-09-30 12:16:37 +0200456 * - nc_server_tls_ch_del_trusted_cert();
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100457 * - nc_server_tls_ch_set_crl_paths()
458 * - nc_server_tls_ch_clear_crls()
459 * - nc_server_tls_ch_add_ctn()
460 * - nc_server_tls_ch_del_ctn()
461 * - nc_server_tls_ch_clear_opts()
462 *
463 *
464 * Connecting And Cleanup
465 * ======================
466 *
Michal Vasko15b7a982016-03-02 10:53:31 +0100467 * When accepting connections with nc_accept(), all the endpoints are examined
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100468 * and the first with a pending connection is used. To remove all
Michal Vasko15b7a982016-03-02 10:53:31 +0100469 * the endpoints and free any used dynamic memory, [destroy](@ref howtoinit) the server.
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100470 *
471 * Functions List
472 * --------------
473 *
474 * Available in __nc_server.h__.
475 *
476 * - nc_accept()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100477 */
478
479/**
480 * @page howtoclientcomm Client communication
481 *
Michal Vasko15b7a982016-03-02 10:53:31 +0100482 * To send RPCs on a session, you simply create an RPC, send it using nc_send_rpc(),
483 * 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 +0100484 * of receiving notifications. Either you wait for them the same way
Michal Vasko15b7a982016-03-02 10:53:31 +0100485 * as for standard replies with nc_recv_notif() or you create a dispatcher
486 * with nc_recv_notif_dispatch() that asynchronously (in a separate thread)
487 * reads notifications and passes them to your callback.
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100488 *
489 * Functions List
490 * --------------
491 *
492 * Available in __nc_client.h__.
493 *
Michal Vasko3a889fd2016-09-30 12:16:37 +0200494 * - nc_rpc_act_generic()
495 * - nc_rpc_act_generic_xml()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100496 * - nc_rpc_getconfig()
497 * - nc_rpc_edit()
498 * - nc_rpc_copy()
499 * - nc_rpc_delete()
500 * - nc_rpc_lock()
501 * - nc_rpc_unlock()
502 * - nc_rpc_get()
503 * - nc_rpc_kill()
504 * - nc_rpc_commit()
505 * - nc_rpc_discard()
506 * - nc_rpc_cancel()
507 * - nc_rpc_validate()
508 * - nc_rpc_getschema()
509 * - nc_rpc_subscribe()
510 *
511 * - nc_send_rpc()
512 * - nc_recv_reply()
513 * - nc_recv_notif()
514 * - nc_recv_notif_dispatch()
515 */
516
517/**
518 * @page howtoservercomm Server communication
519 *
520 * Once at least one session is established, an nc_pollsession structure
Michal Vasko15b7a982016-03-02 10:53:31 +0100521 * should be created with nc_ps_new(), filled with the session using
522 * nc_ps_add_session() and finally polled with nc_ps_poll(). Based on
523 * the return value from the poll, further actions can be taken. More
524 * sessions can be polled at the same time and any requests received on
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100525 * the sessions are [handled internally](@ref howtoserver).
526 *
Michal Vasko15b7a982016-03-02 10:53:31 +0100527 * If an SSH NETCONF session asks for a new channel, you can accept
Michal Vasko3a889fd2016-09-30 12:16:37 +0200528 * this request with nc_ps_accept_ssh_channel() or nc_session_accept_ssh_channel()
529 * depending on the structure you want to use as the argument.
Michal Vasko15b7a982016-03-02 10:53:31 +0100530 *
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100531 * Functions List
532 * --------------
533 *
Michal Vasko15b7a982016-03-02 10:53:31 +0100534 * Available in __nc_server.h__.
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100535 *
536 * - nc_ps_new()
537 * - nc_ps_add_session()
538 * - nc_ps_del_session()
Michal Vasko0fdb7ac2016-03-01 09:03:12 +0100539 * - nc_ps_session_count()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100540 * - nc_ps_free()
541 *
542 * - nc_ps_poll()
543 * - nc_ps_clear()
544 * - nc_ps_accept_ssh_channel()
Michal Vasko3a889fd2016-09-30 12:16:37 +0200545 * - nc_session_accept_ssh_channel()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100546 */
547
Michal Vaskoee087c62017-02-15 11:27:16 +0100548/**
549 * @page howtotimeouts Timeouts
550 *
551 * There are several timeouts which are used throughout _libnetconf2_ to
552 * assure that it will never indefinitely hang on any operation. Normally,
553 * you should not need to worry about them much necause they are set by
554 * default to reasonable values for common systems. However, if your
555 * platform is not common (embedded, ...), adjusting these timeouts may
556 * save a lot of debugging and time.
557 *
558 * Compile Options
559 * ---------------
560 *
561 * You can adjust active and inactive read timeout using `cmake` variables.
562 * For details look into `README.md`.
563 *
564 * API Functions
565 * -------------
566 *
567 * Once a new connection is established including transport protocol negotiations,
568 * _hello_ message is exchanged. You can set how long will the server wait for
569 * receiving this message from a client before dropping it.
570 *
571 * Having a NETCONF session working, it may not communicate for a longer time.
572 * To free up some resources, it is possible to adjust the maximum idle period
573 * of a session before it is disconnected. In _Call Home_, for both a persistent
574 * and periodic connection can this idle timeout be specified separately for each
575 * client using corresponding functions.
576 *
577 * Lastly, SSH user authentication timeout can be also modified. It is the time
578 * a client has to successfully authenticate after connecting before it is disconnected.
579 *
580 * Functions List
581 * --------------
582 *
583 * Available in __nc_server.h__.
584 *
585 * - nc_server_set_hello_timeout()
586 * - nc_server_set_idle_timeout()
587 * - nc_server_ch_client_persist_set_idle_timeout()
588 * - nc_server_ch_client_period_set_idle_timeout()
589 * - nc_server_ch_client_period_set_reconnect_timeout()
590 * - nc_server_ssh_endpt_set_auth_timeout()
591 * - nc_server_ssh_ch_client_set_auth_timeout()
592 */
593
Radek Krejcid0d19522015-09-02 13:49:25 +0200594#endif /* NC_LIBNETCONF_H_ */