blob: 2c759e595f37ef54f56b9831a3f3d508b5268769 [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 *
49 * Copyright (c) 2015-2016 CESNET, z.s.p.o.
50 *
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
75 */
76
77/**
78 * @page howtoinit Init and Thread-safety Information
79 *
Michal Vaskoa7b8ca52016-03-01 12:09:29 +010080 * Before working with the library, it must be initialized using nc_client_init()
Michal Vasko26394692016-03-17 16:24:55 +010081 * or nc_server_init(). Optionally, a client can use nc_client_set_schema_searchpath()
82 * to set the path to a directory with modules that will be loaded from there if they
83 * could not be downloaded from the server (it does not support \<get-schema\>).
84 * However, to be able to create at least the \<get-schema\> RPC, this directory must
85 * contain the module _ietf-netconf-monitoring_. If this directory is not set,
86 * the default _libnetconf2_ schema directory is used that includes this module
87 * and a few others.
88 *
89 * Based on how the library was compiled, also _libssh_ and/or
Michal Vasko15b7a982016-03-02 10:53:31 +010090 * _libssh_/_libcrypto_ are initialized (for multi-threaded use) too. It is advised
91 * to compile _libnetconf2_, for instance, with TLS support even if you do not want
92 * to use _lnc2_ TLS functions, but only use _libssl/libcrypto_ functions in your
93 * application. You can then use _libnetconf2_ cleanup function and do not
Michal Vaskoa7b8ca52016-03-01 12:09:29 +010094 * trouble yourself with the cleanup.
Michal Vaskofdfd9dd2016-02-29 10:18:46 +010095 *
96 * To prevent any reachable memory at the end of your application, there
97 * are complementary destroy functions available. If your application is
98 * multi-threaded, call the destroy functions in the last thread, after all
99 * the other threads have ended. In every other thread you should call
100 * nc_thread_destroy() just before it exits.
101 *
Michal Vasko15b7a982016-03-02 10:53:31 +0100102 * If _libnetconf2_ is used in accordance with this information, there should
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100103 * not be memory leaks of any kind at program exit. For thread-safety details
Michal Vasko15b7a982016-03-02 10:53:31 +0100104 * of _libssh_, _libssl_, and _libcrypto_, please refer to the corresponding project
105 * documentation. _libnetconf2_ thread-safety information is below.
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100106 *
Michal Vasko15b7a982016-03-02 10:53:31 +0100107 * Client is __NOT__ thread-safe and there is no access control in the client
108 * functions at all. Server is __MOSTLY__ thread-safe meaning you can set all the
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100109 * options simultaneously while listening for or accepting new sessions or
110 * polling the existing ones. It should even be safe to poll one session in
111 * several threads, but it is definitely discouraged. Generally, servers can
112 * use more threads without any problems as long as they keep their workflow sane
113 * (behavior such as freeing sessions only after no thread uses them or similar).
114 *
115 * Functions List
116 * --------------
117 *
Michal Vaskoa7b8ca52016-03-01 12:09:29 +0100118 * Available in __nc_client.h__.
119 *
120 * - nc_client_init()
121 * - nc_client_destroy()
122 *
Michal Vasko26394692016-03-17 16:24:55 +0100123 * - nc_client_set_schema_searchpath()
124 * - nc_client_get_schema_searchpath()
125 *
Michal Vaskoa7b8ca52016-03-01 12:09:29 +0100126 * Available in __nc_server.h__.
127 *
128 * - nc_server_init()
129 * - nc_server_destroy()
130 *
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100131 * Available in both __nc_client.h__ and __nc_server.h__.
132 *
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100133 * - nc_thread_destroy()
134 */
135
136/**
137 * @page howtoclient Client sessions
138 *
Michal Vasko15b7a982016-03-02 10:53:31 +0100139 * To connect to a NETCONF server, a NETCONF session must be established,
140 * which requires a working transport session. It is possible to create
141 * NETCONF sessions with SSH (using _libssh_) or TLS (using _libssl/libcrypto_)
142 * as the underlying transport protocol. It is also possible to establish
143 * the transport protocol outside _libnetconf2_ and then provide these file
144 * descriptors (FD) for full NETCONF session creation.
145 *
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100146 * There are a lot of options for both an SSH and a TLS client. All of them
147 * have setters and getters so that there is no need to duplicate them in
148 * a client.
149 *
150 * SSH
151 * ===
152 *
Michal Vasko15b7a982016-03-02 10:53:31 +0100153 * Connecting to a server using SSH does not strictly require to set any
154 * options, there are sensible default values for all the basic ones.
155 * Except all the SSH options, optionally some authetication callbacks can be set,
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100156 * which are particulary useful in automated clients (passwords cannot be
157 * asked a user) or simply if any additional information is retrieved some
158 * other way than from standard terminal input.
159 *
Michal Vasko15b7a982016-03-02 10:53:31 +0100160 * Having the default options or changing any unsuitable ones, there are 2 functions
161 * to use for a new server connection. nc_connect_ssh() is the standard function
162 * that creates sessions using the set options. If there are some options, which
163 * cannot be changed with the provided API, there is nc_connect_libssh() available.
164 * It requires a _libssh_ session, in which all the SSH options can be modified
165 * and even the connection established. This allows for full customization and
166 * should fit any specific situation.
167 *
168 * New NETCONF sessions can also be created on existing authenticated SSH sessions.
169 * There is a new SSH channel needed, on which the NETCONF session is then created.
170 * Use nc_connect_ssh_channel() for this purpose.
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100171 *
172 * Functions List
173 * --------------
174 *
175 * Available in __nc_client.h__.
176 *
177 * - nc_client_ssh_set_auth_hostkey_check_clb()
178 * - nc_client_ssh_set_auth_password_clb()
179 * - nc_client_ssh_set_auth_interactive_clb()
180 * - nc_client_ssh_set_auth_privkey_passphrase_clb()
181 * - nc_client_ssh_add_keypair()
182 * - nc_client_ssh_del_keypair()
183 * - nc_client_ssh_get_keypair_count()
184 * - nc_client_ssh_get_keypair()
185 * - nc_client_ssh_set_auth_pref()
186 * - nc_client_ssh_get_auth_pref()
187 * - nc_client_ssh_set_username()
188 * - nc_client_ssh_get_username()
189 *
190 * - nc_connect_ssh()
191 * - nc_connect_libssh()
192 * - nc_connect_ssh_channel()
193 *
194 *
195 * TLS
196 * ===
197 *
Michal Vasko15b7a982016-03-02 10:53:31 +0100198 * To connect to a server using TLS, there must be some client identification
199 * options set. Client must specify its certificate with a private key using
200 * nc_client_tls_set_cert_key_paths(). Also, the Certificate Authority of
201 * a server certificate must be considered trusted. Paths to all the trusted
202 * CA certificates can be set by nc_client_tls_set_trusted_ca_paths().
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100203 *
Michal Vasko15b7a982016-03-02 10:53:31 +0100204 * Then there are again 2 functions for connecting, nc_connect_tls() being
205 * the standard way of connecting. nc_connect_libssl() again enables
206 * to customize the TLS session in every way _libssl_ allows.
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100207 *
208 * Functions List
209 * --------------
210 *
211 * Available in __nc_client.h__.
212 *
213 * - nc_client_tls_set_cert_key_paths()
214 * - nc_client_tls_get_cert_key_paths()
215 * - nc_client_tls_set_trusted_ca_paths()
216 * - nc_client_tls_get_trusted_ca_paths()
217 * - nc_client_tls_set_crl_paths()
218 * - nc_client_tls_get_crl_paths()
219 *
220 * - nc_connect_tls()
221 * - nc_connect_libssl()
222 *
223 *
224 * FD
225 * ==
226 *
227 * If you authenticated the connection using some tunneling software, you
Michal Vasko15b7a982016-03-02 10:53:31 +0100228 * can pass its file descriptors to _libnetconf2_ using nc_connect_inout(),
229 * which will continue to establish a full NETCONF session.
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100230 *
231 * Funtions List
232 * -------------
233 *
234 * Available in __nc_client.h__.
235 *
236 * - nc_connect_inout()
237 *
238 *
239 * Call Home
240 * =========
241 *
242 * Call Home needs the same options set as standard SSH or TLS and the functions
243 * reflect it exactly. However, to accept a connection, the client must first
Michal Vasko15b7a982016-03-02 10:53:31 +0100244 * specify addresses and ports, which to listen on by nc_client_ssh_ch_add_bind_listen()
245 * and nc_client_tls_ch_add_bind_listen(). Then connections can be
246 * accepted using nc_accept_callhome().
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100247 *
248 * Functions List
249 * --------------
250 *
251 * Available in __nc_client.h__.
252 *
253 * - nc_client_ssh_ch_set_auth_hostkey_check_clb()
254 * - nc_client_ssh_ch_set_auth_password_clb()
255 * - nc_client_ssh_ch_set_auth_interactive_clb()
256 * - nc_client_ssh_ch_set_auth_privkey_passphrase_clb()
257 * - nc_client_ssh_ch_add_bind_listen()
258 * - nc_client_ssh_ch_del_bind()
259 * - nc_client_ssh_ch_add_keypair()
260 * - nc_client_ssh_ch_del_keypair()
261 * - nc_client_ssh_ch_get_keypair_count()
262 * - nc_client_ssh_ch_get_keypair()
263 * - nc_client_ssh_ch_set_auth_pref()
264 * - nc_client_ssh_ch_get_auth_pref()
265 * - nc_client_ssh_ch_set_username()
266 * - nc_client_ssh_ch_get_username()
267 *
268 * - nc_client_tls_ch_add_bind_listen()
269 * - nc_client_tls_ch_del_bind()
270 * - nc_client_tls_ch_set_cert_key_paths()
271 * - nc_client_tls_ch_get_cert_key_paths()
272 * - nc_client_tls_ch_set_trusted_ca_paths()
273 * - nc_client_tls_ch_get_trusted_ca_paths()
274 * - nc_client_tls_ch_set_crl_paths()
275 * - nc_client_tls_ch_get_crl_paths()
276 *
277 * - nc_accept_callhome()
278 *
279 *
280 * Cleanup
281 * =======
282 *
283 * These options and the schema searchpath are stored in dynamically
Michal Vasko15b7a982016-03-02 10:53:31 +0100284 * allocated memory. They are freed as a part of [destroying the client](@ref howtoinit).
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100285 */
286
287/**
288 * @page howtoserver Server sessions
289 *
290 * Init
291 * ====
292 *
Michal Vaskoa7b8ca52016-03-01 12:09:29 +0100293 * Server takes an argument for its [initialization function](@ref howtoinit).
294 * In it, you set the server context, which determines what modules it
295 * supports and what capabilities to advertise. Few capabilities that
Michal Vasko15b7a982016-03-02 10:53:31 +0100296 * cannot be learnt from the context are set with separate functions
297 * nc_server_set_capab_withdefaults() and nc_server_set_capab_interleave().
298 * Timeout for receiving the _hello_ message on a new session can be set
299 * by nc_server_set_hello_timeout() and the timeout for disconnecting
300 * an inactive session by nc_server_set_idle_timeout().
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100301 *
302 * Context does not only determine server modules, but its overall
303 * functionality as well. For every RPC the server should support,
Michal Vasko3a889fd2016-09-30 12:16:37 +0200304 * 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 +0100305 * Server then calls these as appropriate [during poll](@ref howtoservercomm).
306 *
Michal Vasko15b7a982016-03-02 10:53:31 +0100307 * Just like in the [client](@ref howtoclient), you can let _libnetconf2_
308 * establish SSH or TLS transport or do it yourself and only provide the file
309 * descriptors of the connection.
310 *
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100311 * Server options can be only set, there are no getters.
312 *
Michal Vasko3a889fd2016-09-30 12:16:37 +0200313 * To be able to accept any connections, general endpoints must first be added
314 * with nc_server_add_endpt(). They can then be modified to accept either SSH, TLS,
315 * or both kinds of sessions.
316 *
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100317 * Functions List
318 * --------------
319 *
320 * Available in __nc_server.h__.
321 *
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100322 * - nc_server_set_capab_withdefaults()
323 * - nc_server_set_capab_interleave()
324 * - nc_server_set_hello_timeout()
325 * - nc_server_set_idle_timeout()
326 *
Michal Vasko3a889fd2016-09-30 12:16:37 +0200327 * - nc_server_add_endpt()
328 * - nc_server_del_endpt()
329 *
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100330 *
331 * SSH
332 * ===
333 *
Michal Vasko3a889fd2016-09-30 12:16:37 +0200334 * To start listening for SSH connections you must set the address
335 * and port to listen on for a particular endpoint using nc_server_ssh_endpt_set_address()
336 * and nc_server_endpt_set_port().
337 * To then successfully accept an SSH session you must also set the host key using
338 * nc_server_ssh_endpt_add_hostkey().
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100339 *
340 * Functions List
341 * --------------
342 *
343 * Available in __nc_server.h__.
344 *
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100345 * - nc_server_ssh_endpt_set_address()
346 * - nc_server_ssh_endpt_set_port()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100347 *
Michal Vasko3a889fd2016-09-30 12:16:37 +0200348 * - nc_server_ssh_endpt_add_hostkey()
349 * - nc_server_ssh_endpt_del_hostkey()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100350 * - nc_server_ssh_endpt_set_banner()
351 * - nc_server_ssh_endpt_set_auth_methods()
352 * - nc_server_ssh_endpt_set_auth_attempts()
353 * - nc_server_ssh_endpt_set_auth_timeout()
354 * - nc_server_ssh_endpt_add_authkey()
355 * - nc_server_ssh_endpt_del_authkey()
356 *
357 *
358 * TLS
359 * ===
360 *
Michal Vasko15b7a982016-03-02 10:53:31 +0100361 * TLS works with endpoints too, but its options differ
362 * significantly from the SSH ones, especially in the _cert-to-name_
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100363 * options that TLS uses to derive usernames from client certificates.
Michal Vasko3a889fd2016-09-30 12:16:37 +0200364 * So, after starting listening on an endpoint by calling nc_server_tls_endpt_set_address()
365 * and nc_server_tls_endpt_set_port(),
Michal Vasko15b7a982016-03-02 10:53:31 +0100366 * you need to set the server certificate (nc_server_tls_endpt_set_cert()
367 * or nc_server_tls_endpt_set_cert_path()) and private key (nc_server_tls_endpt_set_key()
368 * or nc_server_tls_endpt_set_key_path()).
369 *
370 * To accept client certificates, they must first be considered trusted,
371 * which you have three ways of achieving. You can add each of their Certificate Authority
372 * certificates to the trusted ones or mark a specific client certificate
373 * as trusted using nc_server_tls_endpt_add_trusted_cert(). Lastly, you can
374 * set paths with all the trusted CA certificates with nc_server_tls_endpt_set_trusted_ca_paths().
375 *
376 * Then, from each trusted client certificate a username must be derived
377 * for the NETCONF session. This is accomplished by finding a matching
378 * _cert-to-name_ entry. They are added using nc_server_tls_endpt_add_ctn().
379 *
Michal Vasko3a889fd2016-09-30 12:16:37 +0200380 * If you need to remove trusted certificates, you can do so with nc_server_tls_endpt_del_trusted_cert().
381 * To clear all Certificate Revocation Lists use nc_server_tls_endpt_clear_crls().
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100382 *
383 * Functions List
384 * --------------
385 *
386 * Available in __nc_server.h__.
387 *
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100388 * - nc_server_tls_endpt_set_address()
389 * - nc_server_tls_endpt_set_port()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100390 *
391 * - nc_server_tls_endpt_set_cert()
392 * - nc_server_tls_endpt_set_cert_path()
393 * - nc_server_tls_endpt_set_key()
394 * - nc_server_tls_endpt_set_key_path()
395 * - nc_server_tls_endpt_add_trusted_cert()
396 * - nc_server_tls_endpt_add_trusted_cert_path()
397 * - nc_server_tls_endpt_set_trusted_ca_paths()
Michal Vasko3a889fd2016-09-30 12:16:37 +0200398 * - nc_server_tls_endpt_del_trusted_cert();
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100399 * - nc_server_tls_endpt_set_crl_paths()
400 * - nc_server_tls_endpt_clear_crls()
401 * - nc_server_tls_endpt_add_ctn()
402 * - nc_server_tls_endpt_del_ctn()
403 *
404 * FD
405 * ==
406 *
407 * If you used a tunneling software, which does its own authentication,
Michal Vasko15b7a982016-03-02 10:53:31 +0100408 * you can accept a NETCONF session on its file descriptors with
409 * nc_accept_inout().
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100410 *
411 * Functions List
412 * --------------
413 *
414 * Available in __nc_server.h__.
415 *
416 * - nc_accept_inout()
417 *
418 *
419 * Call Home
420 * =========
421 *
422 * Call Home does not work with endpoints like standard sessions.
Michal Vasko15b7a982016-03-02 10:53:31 +0100423 * Connecting is similar to the [client](@ref howtoclient), just call
424 * nc_connect_callhome_ssh() or nc_connect_callhome_tls(). Any options
425 * must be reset manually by nc_server_ssh_ch_clear_opts()
Michal Vasko3a889fd2016-09-30 12:16:37 +0200426 * or using nc_server_tls_ch_del_trusted_cert() and nc_server_tls_ch_clear_crls()
427 * after another Call Home session (with different options than the previous one)
428 * is to be established. Also, monitoring of these sessions is up to the application.
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100429 *
430 * Functions List
431 * --------------
432 *
433 * Available in __nc_server.h__.
434 *
435 * - nc_connect_callhome_ssh()
436 * - nc_connect_callhome_tls()
437 *
Michal Vasko3a889fd2016-09-30 12:16:37 +0200438 * - nc_server_ssh_ch_add_hostkey()
439 * - nc_server_ssh_ch_del_hostkey()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100440 * - nc_server_ssh_ch_set_banner()
441 * - nc_server_ssh_ch_set_auth_methods()
442 * - nc_server_ssh_ch_set_auth_attempts()
443 * - nc_server_ssh_ch_set_auth_timeout()
444 * - nc_server_ssh_ch_add_authkey()
445 * - nc_server_ssh_ch_del_authkey()
446 * - nc_server_ssh_ch_clear_opts()
447 *
448 * - nc_server_tls_ch_set_cert()
449 * - nc_server_tls_ch_set_cert_path()
450 * - nc_server_tls_ch_set_key()
451 * - nc_server_tls_ch_set_key_path()
452 * - nc_server_tls_ch_add_trusted_cert()
453 * - nc_server_tls_ch_add_trusted_cert_path()
454 * - nc_server_tls_ch_set_trusted_ca_paths()
Michal Vasko3a889fd2016-09-30 12:16:37 +0200455 * - nc_server_tls_ch_del_trusted_cert();
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100456 * - nc_server_tls_ch_set_crl_paths()
457 * - nc_server_tls_ch_clear_crls()
458 * - nc_server_tls_ch_add_ctn()
459 * - nc_server_tls_ch_del_ctn()
460 * - nc_server_tls_ch_clear_opts()
461 *
462 *
463 * Connecting And Cleanup
464 * ======================
465 *
Michal Vasko15b7a982016-03-02 10:53:31 +0100466 * When accepting connections with nc_accept(), all the endpoints are examined
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100467 * and the first with a pending connection is used. To remove all
Michal Vasko15b7a982016-03-02 10:53:31 +0100468 * the endpoints and free any used dynamic memory, [destroy](@ref howtoinit) the server.
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100469 *
470 * Functions List
471 * --------------
472 *
473 * Available in __nc_server.h__.
474 *
475 * - nc_accept()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100476 */
477
478/**
479 * @page howtoclientcomm Client communication
480 *
Michal Vasko15b7a982016-03-02 10:53:31 +0100481 * To send RPCs on a session, you simply create an RPC, send it using nc_send_rpc(),
482 * 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 +0100483 * of receiving notifications. Either you wait for them the same way
Michal Vasko15b7a982016-03-02 10:53:31 +0100484 * as for standard replies with nc_recv_notif() or you create a dispatcher
485 * with nc_recv_notif_dispatch() that asynchronously (in a separate thread)
486 * reads notifications and passes them to your callback.
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100487 *
488 * Functions List
489 * --------------
490 *
491 * Available in __nc_client.h__.
492 *
Michal Vasko3a889fd2016-09-30 12:16:37 +0200493 * - nc_rpc_act_generic()
494 * - nc_rpc_act_generic_xml()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100495 * - nc_rpc_getconfig()
496 * - nc_rpc_edit()
497 * - nc_rpc_copy()
498 * - nc_rpc_delete()
499 * - nc_rpc_lock()
500 * - nc_rpc_unlock()
501 * - nc_rpc_get()
502 * - nc_rpc_kill()
503 * - nc_rpc_commit()
504 * - nc_rpc_discard()
505 * - nc_rpc_cancel()
506 * - nc_rpc_validate()
507 * - nc_rpc_getschema()
508 * - nc_rpc_subscribe()
509 *
510 * - nc_send_rpc()
511 * - nc_recv_reply()
512 * - nc_recv_notif()
513 * - nc_recv_notif_dispatch()
514 */
515
516/**
517 * @page howtoservercomm Server communication
518 *
519 * Once at least one session is established, an nc_pollsession structure
Michal Vasko15b7a982016-03-02 10:53:31 +0100520 * should be created with nc_ps_new(), filled with the session using
521 * nc_ps_add_session() and finally polled with nc_ps_poll(). Based on
522 * the return value from the poll, further actions can be taken. More
523 * sessions can be polled at the same time and any requests received on
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100524 * the sessions are [handled internally](@ref howtoserver).
525 *
Michal Vasko15b7a982016-03-02 10:53:31 +0100526 * If an SSH NETCONF session asks for a new channel, you can accept
Michal Vasko3a889fd2016-09-30 12:16:37 +0200527 * this request with nc_ps_accept_ssh_channel() or nc_session_accept_ssh_channel()
528 * depending on the structure you want to use as the argument.
Michal Vasko15b7a982016-03-02 10:53:31 +0100529 *
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100530 * Functions List
531 * --------------
532 *
Michal Vasko15b7a982016-03-02 10:53:31 +0100533 * Available in __nc_server.h__.
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100534 *
535 * - nc_ps_new()
536 * - nc_ps_add_session()
537 * - nc_ps_del_session()
Michal Vasko0fdb7ac2016-03-01 09:03:12 +0100538 * - nc_ps_session_count()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100539 * - nc_ps_free()
540 *
541 * - nc_ps_poll()
542 * - nc_ps_clear()
543 * - nc_ps_accept_ssh_channel()
Michal Vasko3a889fd2016-09-30 12:16:37 +0200544 * - nc_session_accept_ssh_channel()
Michal Vaskofdfd9dd2016-02-29 10:18:46 +0100545 */
546
Radek Krejcid0d19522015-09-02 13:49:25 +0200547#endif /* NC_LIBNETCONF_H_ */