blob: 87429cc5229ad0b6961706464e450bd5840dad35 [file] [log] [blame]
Radek Krejci206fcd62015-10-07 15:42:48 +02001/**
2 * \file session_p.h
3 * \author Radek Krejci <rkrejci@cesnet.cz>
Michal Vaskob48aa812016-01-18 14:13:09 +01004 * \author Michal Vasko <mvasko@cesnet.cz>
Radek Krejci206fcd62015-10-07 15:42:48 +02005 * \brief libnetconf2 session manipulation
6 *
7 * Copyright (c) 2015 CESNET, z.s.p.o.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
17 * distribution.
18 * 3. Neither the name of the Company nor the names of its contributors
19 * may be used to endorse or promote products derived from this
20 * software without specific prior written permission.
21 *
22 */
23
24#ifndef NC_SESSION_PRIVATE_H_
25#define NC_SESSION_PRIVATE_H_
26
Radek Krejcife0b3472015-10-12 13:43:42 +020027#include <stdint.h>
Radek Krejci206fcd62015-10-07 15:42:48 +020028#include <pthread.h>
29
Michal Vasko4ef14932015-12-04 11:09:10 +010030#include <libyang/libyang.h>
Michal Vasko7bcb48e2016-01-15 10:28:54 +010031
Michal Vasko4ef14932015-12-04 11:09:10 +010032#include "libnetconf.h"
Michal Vasko7bcb48e2016-01-15 10:28:54 +010033#include "netconf.h"
Michal Vasko4ef14932015-12-04 11:09:10 +010034#include "session.h"
35
Michal Vaskofb2fb762015-10-27 11:44:32 +010036#ifdef ENABLE_SSH
Michal Vasko4ef14932015-12-04 11:09:10 +010037
Radek Krejci206fcd62015-10-07 15:42:48 +020038# include <libssh/libssh.h>
39# include <libssh/callbacks.h>
Michal Vasko086311b2016-01-08 09:53:11 +010040# include <libssh/server.h>
Michal Vasko7b62fed2015-10-26 15:39:46 +010041
42/* seconds */
Michal Vaskoc111ac52015-12-08 14:36:36 +010043# define NC_SSH_TIMEOUT 10
Michal Vaskob48aa812016-01-18 14:13:09 +010044
Michal Vaskoc111ac52015-12-08 14:36:36 +010045# define NC_SSH_AUTH_COUNT 3
Michal Vasko7b62fed2015-10-26 15:39:46 +010046
Michal Vasko086311b2016-01-08 09:53:11 +010047struct nc_ssh_client_opts {
Michal Vasko7b62fed2015-10-26 15:39:46 +010048 /* SSH authentication method preferences */
49 struct {
50 NC_SSH_AUTH_TYPE type;
51 short int value;
Michal Vaskoc111ac52015-12-08 14:36:36 +010052 } auth_pref[NC_SSH_AUTH_COUNT];
Michal Vasko7b62fed2015-10-26 15:39:46 +010053
54 /* SSH key pairs */
55 struct {
56 char *pubkey_path;
57 char *privkey_path;
58 int privkey_crypt;
59 } *keys;
60 int key_count;
61};
62
Michal Vasko086311b2016-01-08 09:53:11 +010063struct nc_ssh_server_opts {
Michal Vasko086311b2016-01-08 09:53:11 +010064 ssh_bind sshbind;
Michal Vaskob48aa812016-01-18 14:13:09 +010065 pthread_mutex_t sshbind_lock;
Michal Vasko086311b2016-01-08 09:53:11 +010066
67 struct {
Michal Vasko76e3a352016-01-18 09:07:00 +010068 const char *path;
69 const char *username;
Michal Vasko086311b2016-01-08 09:53:11 +010070 } *authkeys;
71 uint16_t authkey_count;
Michal Vaskob48aa812016-01-18 14:13:09 +010072 pthread_mutex_t authkey_lock;
Michal Vasko086311b2016-01-08 09:53:11 +010073
74 int auth_methods;
75 uint16_t auth_attempts;
76 uint16_t auth_timeout;
77};
78
Michal Vasko4ef14932015-12-04 11:09:10 +010079#endif /* ENABLE_SSH */
Radek Krejci206fcd62015-10-07 15:42:48 +020080
81#ifdef ENABLE_TLS
Michal Vasko4ef14932015-12-04 11:09:10 +010082
Michal Vaskoc111ac52015-12-08 14:36:36 +010083# include <openssl/bio.h>
84# include <openssl/ssl.h>
Michal Vasko11d4cdb2015-10-29 11:42:52 +010085
Michal Vasko086311b2016-01-08 09:53:11 +010086struct nc_tls_client_opts {
Michal Vasko11d4cdb2015-10-29 11:42:52 +010087 SSL_CTX *tls_ctx;
88 X509_STORE *tls_store;
89};
90
Michal Vasko0457bb42016-01-08 15:49:13 +010091struct nc_tls_server_opts {
92 SSL_CTX *tls_ctx;
Michal Vaskob48aa812016-01-18 14:13:09 +010093 pthread_mutex_t tls_ctx_lock;
94
Michal Vasko0457bb42016-01-08 15:49:13 +010095 X509_STORE *crl_store;
Michal Vaskob48aa812016-01-18 14:13:09 +010096 pthread_mutex_t crl_lock;
Michal Vasko0457bb42016-01-08 15:49:13 +010097
Michal Vasko5e3f3392016-01-20 11:13:01 +010098 struct nc_ctn {
Michal Vasko0457bb42016-01-08 15:49:13 +010099 uint32_t id;
100 const char *fingerprint;
Michal Vaskoc14e3c82016-01-11 16:14:30 +0100101 NC_TLS_CTN_MAPTYPE map_type;
Michal Vasko0457bb42016-01-08 15:49:13 +0100102 const char *name;
Michal Vasko5e3f3392016-01-20 11:13:01 +0100103 struct nc_ctn *next;
Michal Vasko0457bb42016-01-08 15:49:13 +0100104 } *ctn;
Michal Vaskob48aa812016-01-18 14:13:09 +0100105 pthread_mutex_t ctn_lock;
Michal Vasko6d292992016-01-18 09:42:38 +0100106
107 pthread_key_t verify_key;
108 pthread_once_t verify_once;
Michal Vasko0457bb42016-01-08 15:49:13 +0100109};
110
Michal Vasko4ef14932015-12-04 11:09:10 +0100111#endif /* ENABLE_TLS */
Radek Krejci43390242015-10-08 15:34:04 +0200112
Michal Vasko0457bb42016-01-08 15:49:13 +0100113struct nc_server_opts {
114 struct ly_ctx *ctx;
Michal Vasko11d142a2016-01-19 15:58:24 +0100115 pthread_mutex_t ctx_lock;
Michal Vasko0457bb42016-01-08 15:49:13 +0100116
117 NC_WD_MODE wd_basic_mode;
118 int wd_also_supported;
119 int interleave_capab;
120
121 uint16_t hello_timeout;
122 uint16_t idle_timeout;
Michal Vasko0457bb42016-01-08 15:49:13 +0100123
124 struct nc_bind {
Michal Vasko11d142a2016-01-19 15:58:24 +0100125 const char *address;
Michal Vasko0457bb42016-01-08 15:49:13 +0100126 uint16_t port;
127 int sock;
128 NC_TRANSPORT_IMPL ti;
129 } *binds;
130 uint16_t bind_count;
Michal Vaskob48aa812016-01-18 14:13:09 +0100131 pthread_mutex_t bind_lock;
132
133 uint32_t new_session_id;
134 pthread_spinlock_t sid_lock;
Michal Vasko0457bb42016-01-08 15:49:13 +0100135};
136
Radek Krejci206fcd62015-10-07 15:42:48 +0200137/**
Michal Vaskoc111ac52015-12-08 14:36:36 +0100138 * Sleep time in microseconds to wait between unsuccessful reading due to EAGAIN or EWOULDBLOCK.
Radek Krejci206fcd62015-10-07 15:42:48 +0200139 */
140#define NC_READ_SLEEP 100
141
142/**
Michal Vasko80cad7f2015-12-08 14:42:27 +0100143 * Number of sockets kept waiting to be accepted.
144 */
145#define NC_REVERSE_QUEUE 1
146
147/**
Radek Krejci695d4fa2015-10-22 13:23:54 +0200148 * @brief type of the session
Radek Krejci206fcd62015-10-07 15:42:48 +0200149 */
150typedef enum {
Radek Krejci695d4fa2015-10-22 13:23:54 +0200151 NC_CLIENT, /**< client side */
152 NC_SERVER /**< server side */
Radek Krejci206fcd62015-10-07 15:42:48 +0200153} NC_SIDE;
154
155/**
156 * @brief Enumeration of the supported NETCONF protocol versions
157 */
158typedef enum {
159 NC_VERSION_10 = 0, /**< NETCONV 1.0 - RFC 4741, 4742 */
160 NC_VERSION_11 = 1 /**< NETCONF 1.1 - RFC 6241, 6242 */
161} NC_VERSION;
162
163#define NC_VERSION_10_ENDTAG "]]>]]>"
164#define NC_VERSION_10_ENDTAG_LEN 6
165
166/**
Michal Vaskoad611702015-12-03 13:41:51 +0100167 * @brief Container to serialize PRC messages
Radek Krejci5686ff72015-10-09 13:33:56 +0200168 */
Michal Vaskoad611702015-12-03 13:41:51 +0100169struct nc_msg_cont {
170 struct lyxml_elem *msg;
171 struct nc_msg_cont *next;
Radek Krejci5686ff72015-10-09 13:33:56 +0200172};
173
174/**
Radek Krejci206fcd62015-10-07 15:42:48 +0200175 * @brief NETCONF session structure
176 */
177struct nc_session {
Radek Krejci695d4fa2015-10-22 13:23:54 +0200178 NC_STATUS status; /**< status of the session */
Michal Vasko428087d2016-01-14 16:04:28 +0100179 NC_SESSION_TERM_REASON term_reason; /**< reason of termination, if status is NC_STATUS_INVALID */
Radek Krejci695d4fa2015-10-22 13:23:54 +0200180 NC_SIDE side; /**< side of the session: client or server */
Radek Krejci5686ff72015-10-09 13:33:56 +0200181
182 /* NETCONF data */
Radek Krejci206fcd62015-10-07 15:42:48 +0200183 uint32_t id; /**< NETCONF session ID (session-id-type) */
184 NC_VERSION version; /**< NETCONF protocol version */
Radek Krejci695d4fa2015-10-22 13:23:54 +0200185 pthread_t *notif; /**< running notifications thread - TODO server-side only? */
Radek Krejci5686ff72015-10-09 13:33:56 +0200186
187 /* Transport implementation */
Radek Krejci206fcd62015-10-07 15:42:48 +0200188 NC_TRANSPORT_IMPL ti_type; /**< transport implementation type to select items from ti union */
Radek Krejci695d4fa2015-10-22 13:23:54 +0200189 pthread_mutex_t *ti_lock; /**< lock to access ti. Note that in case of libssh TI, it can be shared with other
Michal Vaskob7ea2432015-10-26 15:38:40 +0100190 NETCONF sessions on the same SSH session (but different SSH channel) */
Radek Krejci206fcd62015-10-07 15:42:48 +0200191 union {
192 struct {
193 int in; /**< input file descriptor */
194 int out; /**< output file descriptor */
Radek Krejci206fcd62015-10-07 15:42:48 +0200195 } fd; /**< NC_TI_FD transport implementation structure */
Michal Vaskofb2fb762015-10-27 11:44:32 +0100196#ifdef ENABLE_SSH
Radek Krejci206fcd62015-10-07 15:42:48 +0200197 struct {
Radek Krejci206fcd62015-10-07 15:42:48 +0200198 ssh_channel channel;
Radek Krejci695d4fa2015-10-22 13:23:54 +0200199 ssh_session session;
200 struct nc_session *next; /**< pointer to the next NETCONF session on the same
201 SSH session, but different SSH channel. If no such session exists, it is NULL.
202 otherwise there is a ring list of the NETCONF sessions */
Radek Krejci206fcd62015-10-07 15:42:48 +0200203 } libssh;
204#endif
205#ifdef ENABLE_TLS
206 SSL *tls;
207#endif
Radek Krejci5686ff72015-10-09 13:33:56 +0200208 } ti; /**< transport implementation data */
Radek Krejciac6d3472015-10-22 15:47:18 +0200209 const char *username;
210 const char *host;
Michal Vasko38a7c6c2015-12-04 12:29:20 +0100211 uint16_t port;
Radek Krejci5686ff72015-10-09 13:33:56 +0200212
213 /* other */
214 struct ly_ctx *ctx; /**< libyang context of the session */
Radek Krejci695d4fa2015-10-22 13:23:54 +0200215 uint8_t flags; /**< various flags of the session - TODO combine with status and/or side */
Michal Vasko086311b2016-01-08 09:53:11 +0100216#define NC_SESSION_SHAREDCTX 0x01
Radek Krejci5686ff72015-10-09 13:33:56 +0200217
218 /* client side only data */
Radek Krejcife0b3472015-10-12 13:43:42 +0200219 uint64_t msgid;
Radek Krejci695d4fa2015-10-22 13:23:54 +0200220 const char **cpblts; /**< list of server's capabilities on client side */
Michal Vaskoad611702015-12-03 13:41:51 +0100221 struct nc_msg_cont *replies; /**< queue for RPC replies received instead of notifications */
222 struct nc_msg_cont *notifs; /**< queue for notifications received instead of RPC reply */
Michal Vasko086311b2016-01-08 09:53:11 +0100223
224 /* server side only data */
Michal Vasko5e6f4cc2016-01-20 13:27:44 +0100225 time_t last_rpc;
Michal Vaskoc14e3c82016-01-11 16:14:30 +0100226#ifdef ENABLE_SSH
Michal Vasko96164bf2016-01-21 15:41:58 +0100227 /* SSH session authenticated */
Michal Vasko06e22432016-01-15 10:30:06 +0100228# define NC_SESSION_SSH_AUTHENTICATED 0x02
Michal Vasko96164bf2016-01-21 15:41:58 +0100229 /* netconf subsystem requested */
Michal Vasko06e22432016-01-15 10:30:06 +0100230# define NC_SESSION_SSH_SUBSYS_NETCONF 0x04
Michal Vasko96164bf2016-01-21 15:41:58 +0100231 /* new SSH message arrived */
232# define NC_SESSION_SSH_NEW_MSG 0x08
233 /* this session is passed to nc_sshcb_msg() */
234# define NC_SESSION_SSH_MSG_CB 0x10
Michal Vasko06e22432016-01-15 10:30:06 +0100235
Michal Vaskoc14e3c82016-01-11 16:14:30 +0100236 uint16_t ssh_auth_attempts;
237#endif
238#ifdef ENABLE_TLS
Michal Vasko06e22432016-01-15 10:30:06 +0100239 X509 *tls_cert;
Michal Vaskoc14e3c82016-01-11 16:14:30 +0100240#endif
Radek Krejci206fcd62015-10-07 15:42:48 +0200241};
242
Michal Vaskofb89d772016-01-08 12:25:35 +0100243struct nc_pollsession {
Michal Vasko3a715132016-01-21 15:40:31 +0100244 struct pollfd *pfds;
245 struct nc_session **sessions;
Michal Vaskofb89d772016-01-08 12:25:35 +0100246 uint16_t session_count;
247};
248
Michal Vasko086311b2016-01-08 09:53:11 +0100249NC_MSG_TYPE nc_send_msg(struct nc_session *session, struct lyd_node *op);
250
Michal Vasko7f1c78b2016-01-19 09:52:14 +0100251int nc_timedlock(pthread_mutex_t *lock, int timeout, int *elapsed);
Michal Vasko086311b2016-01-08 09:53:11 +0100252
Michal Vasko96164bf2016-01-21 15:41:58 +0100253void nc_subtract_elapsed(int *timeout, struct timespec *old_ts);
254
Radek Krejci206fcd62015-10-07 15:42:48 +0200255/**
Michal Vasko9e2d3a32015-11-10 13:09:18 +0100256 * @brief Fill libyang context in \p session. Context models are based on the stored session
257 * capabilities. If the server does not support \<get-schema\>, the models are searched
258 * for in the directory set using nc_schema_searchpath().
259 *
260 * @param[in] session Session to create the context for.
261 * @return 0 on success, non-zero on failure.
262 */
Michal Vasko57eb9402015-12-08 14:38:12 +0100263int nc_ctx_check_and_fill(struct nc_session *session);
Michal Vasko9e2d3a32015-11-10 13:09:18 +0100264
265/**
Michal Vasko9e2d3a32015-11-10 13:09:18 +0100266 * @brief Perform NETCONF handshake on \p session.
267 *
268 * @param[in] session NETCONF session to use.
269 * @return 0 on success, non-zero on failure.
270 */
271int nc_handshake(struct nc_session *session);
272
273/**
Michal Vaskof05562c2016-01-20 12:06:43 +0100274 * @brief Create a socket connection.
275 *
276 * @param[in] host Hostname to connect to.
277 * @param[in] port Port to connect on.
278 * @return Connected socket or -1 on error.
279 */
280int nc_sock_connect(const char *host, uint16_t port);
281
282/**
283 * @brief Accept a new socket connection.
Michal Vasko80cad7f2015-12-08 14:42:27 +0100284 *
285 * @param[in] port Port to listen on.
Michal Vaskof05562c2016-01-20 12:06:43 +0100286 * @param[in] timeout Timeout in milliseconds.
287 * @param[out] peer_host Host the new connection was initiated from. Can be NULL.
288 * @param[out] peer_port Port the new connection is connected on. Can be NULL.
Michal Vasko80cad7f2015-12-08 14:42:27 +0100289 * @return Connected socket with the new connection, -1 on error.
290 */
Michal Vaskof05562c2016-01-20 12:06:43 +0100291int nc_sock_accept(uint16_t port, int timeout, char **peer_host, uint16_t *peer_port);
Michal Vasko80cad7f2015-12-08 14:42:27 +0100292
Michal Vasko1a38c862016-01-15 15:50:07 +0100293/**
294 * @brief Create a listening socket.
295 *
296 * @param[in] address IP address to listen on.
297 * @param[in] port Port to listen on.
298 * @return Listening socket, -1 on error.
299 */
Michal Vaskof05562c2016-01-20 12:06:43 +0100300int nc_sock_listen(const char *address, uint16_t port);
Michal Vaskofb89d772016-01-08 12:25:35 +0100301
Michal Vasko1a38c862016-01-15 15:50:07 +0100302/**
303 * @brief Accept a new connection on a listening socket.
304 *
305 * @param[in] binds Structure with the listening sockets.
306 * @param[in] bind_count Number of \p binds.
307 * @param[in] timeout Timeout for accepting.
308 * @param[out] ti Type of transport of the accepted connection. Can be NULL.
309 * @param[out] host Host of the remote peer. Can be NULL.
310 * @param[out] port Port of the new connection. Can be NULL.
311 * @return Accepted socket of the new connection, -1 on error.
312 */
Michal Vaskof05562c2016-01-20 12:06:43 +0100313int nc_sock_accept_binds(struct nc_bind *binds, uint16_t bind_count, int timeout, NC_TRANSPORT_IMPL *ti, char **host, uint16_t *port);
Michal Vaskofb89d772016-01-08 12:25:35 +0100314
Michal Vasko9e036d52016-01-08 10:49:26 +0100315#ifdef ENABLE_SSH
316
Michal Vasko1a38c862016-01-15 15:50:07 +0100317/**
318 * @brief Establish SSH transport on a socket.
319 *
320 * @param[in] session Session structure of the new connection.
321 * @param[in] sock Socket of the new connection.
322 * @param[in] timeout Timeout for all the related tasks.
323 * @return 1 on success, 0 on timeout, -1 on error.
324 */
Michal Vasko9e036d52016-01-08 10:49:26 +0100325int nc_accept_ssh_session(struct nc_session *session, int sock, int timeout);
326
Michal Vasko96164bf2016-01-21 15:41:58 +0100327/**
328 * @brief Callback called when a new SSH message is received.
329 *
330 * @param[in] sshsession SSH session the message arrived on.
331 * @param[in] msg SSH message itself.
332 * @param[in] data NETCONF session running on \p sshsession.
333 * @return 0 if the message was handled, 1 if it is left up to libssh.
334 */
335int nc_sshcb_msg(ssh_session sshsession, ssh_message msg, void *data);
336
337/**
338 * @brief Inspect what exactly happened if a SSH session socket poll
339 * returned POLLIN.
340 *
341 * @param[in] session NETCONF session communicating on the socket.
342 * @param[in,out] timeout Timeout for locking ti_lock, gets updated.
343 * @return 0 - timeout,
344 * 1 if \p session channel has data,
345 * 2 if some other channel has data,
346 * 3 on \p session status change,
347 * 4 on new SSH message,
348 * 5 on new NETCONF SSH channel,
349 * -1 on error.
350 */
351int nc_ssh_pollin(struct nc_session *session, int *timeout);
352
Michal Vasko9e036d52016-01-08 10:49:26 +0100353#endif
354
355#ifdef ENABLE_TLS
356
Michal Vasko1a38c862016-01-15 15:50:07 +0100357/**
358 * @brief Establish TLS transport on a socket.
359 *
360 * @param[in] session Session structure of the new connection.
361 * @param[in] sock Socket of the new connection.
362 * @param[in] timeout Timeout for all the related tasks.
363 * @return 1 on success, 0 on timeout, -1 on error.
364 */
Michal Vasko9e036d52016-01-08 10:49:26 +0100365int nc_accept_tls_session(struct nc_session *session, int sock, int timeout);
366
367#endif
368
Michal Vasko80cad7f2015-12-08 14:42:27 +0100369/**
Radek Krejci206fcd62015-10-07 15:42:48 +0200370 * Functions
371 * - io.c
372 */
373
374/**
375 * @brief Read message from the wire.
376 *
377 * Accepts hello, rpc, rpc-reply and notification. Received string is transformed into
378 * libyang XML tree and the message type is detected from the top level element.
379 *
380 * @param[in] session NETCONF session from which the message is being read.
381 * @param[in] timeout Timeout in milliseconds. Negative value means infinite timeout,
382 * zero value causes to return immediately.
383 * @param[out] data XML tree built from the read data.
384 * @return Type of the read message. #NC_MSG_WOULDBLOCK is returned if timeout is positive
Radek Krejci5686ff72015-10-09 13:33:56 +0200385 * (or zero) value and it passed out without any data on the wire. #NC_MSG_ERROR is
Radek Krejci206fcd62015-10-07 15:42:48 +0200386 * returned on error and #NC_MSG_NONE is never returned by this function.
387 */
Michal Vasko05ba9df2016-01-13 14:40:27 +0100388NC_MSG_TYPE nc_read_msg_poll(struct nc_session* session, int timeout, struct lyxml_elem **data);
389
390/**
391 * @brief Read message from the wire.
392 *
393 * Accepts hello, rpc, rpc-reply and notification. Received string is transformed into
394 * libyang XML tree and the message type is detected from the top level element.
395 *
396 * @param[in] session NETCONF session from which the message is being read.
397 * @param[out] data XML tree built from the read data.
398 * @return Type of the read message. #NC_MSG_WOULDBLOCK is returned if timeout is positive
399 * (or zero) value and it passed out without any data on the wire. #NC_MSG_ERROR is
400 * returned on error and #NC_MSG_NONE is never returned by this function.
401 */
402NC_MSG_TYPE nc_read_msg(struct nc_session* session, struct lyxml_elem **data);
Radek Krejci206fcd62015-10-07 15:42:48 +0200403
Radek Krejcife0b3472015-10-12 13:43:42 +0200404/**
405 * @brief Write message into wire.
406 *
407 * @param[in] session NETCONF session to which the message will be written.
408 * @param[in] type Type of the message to write. According to the type, the
409 * specific additional parameters are required or accepted:
410 * - #NC_MSG_RPC
411 * - `struct lyd_node *op;` - operation (content of the \<rpc/\> to be sent. Required parameter.
412 * - `const char *attrs;` - additional attributes to be added into the \<rpc/\> element.
Michal Vasko05ba9df2016-01-13 14:40:27 +0100413 * Required parameter.
414 * `message-id` attribute is added automatically and default namespace is set to #NC_NS_BASE.
415 * Optional parameter.
Radek Krejcife0b3472015-10-12 13:43:42 +0200416 * - #NC_MSG_REPLY
Michal Vasko05ba9df2016-01-13 14:40:27 +0100417 * - `struct lyxml_node *rpc_elem;` - root of the RPC object to reply to. Required parameter.
418 * - `struct nc_server_reply *reply;` - RPC reply. Required parameter.
Radek Krejcife0b3472015-10-12 13:43:42 +0200419 * - #NC_MSG_NOTIF
420 * - TODO: content
421 * @return 0 on success
422 */
423int nc_write_msg(struct nc_session *session, NC_MSG_TYPE type, ...);
424
Michal Vasko1a38c862016-01-15 15:50:07 +0100425/**
426 * @brief Check whether a session is still connected (on transport layer).
427 *
428 * @param[in] session Session to check.
429 * @return 1 if connected, 0 if not.
430 */
Michal Vasko428087d2016-01-14 16:04:28 +0100431int nc_session_is_connected(struct nc_session *session);
432
Radek Krejci206fcd62015-10-07 15:42:48 +0200433#endif /* NC_SESSION_PRIVATE_H_ */