FEATURE base of functions to read data from wire
diff --git a/src/session_p.h b/src/session_p.h
new file mode 100644
index 0000000..8b24294
--- /dev/null
+++ b/src/session_p.h
@@ -0,0 +1,127 @@
+/**
+ * \file session_p.h
+ * \author Radek Krejci <rkrejci@cesnet.cz>
+ * \brief libnetconf2 session manipulation
+ *
+ * Copyright (c) 2015 CESNET, z.s.p.o.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of the Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ */
+
+#ifndef NC_SESSION_PRIVATE_H_
+#define NC_SESSION_PRIVATE_H_
+
+#include <pthread.h>
+
+#ifdef ENABLE_LIBSSH
+# include <libssh/libssh.h>
+# include <libssh/callbacks.h>
+#endif
+
+#ifdef ENABLE_TLS
+# include <openssl/bio.h>
+# include <openssl/ssl.h>
+#endif
+
+#include <libyang/libyang.h>
+
+/**
+ * Sleep time in microseconds to wait between unsuccessful reading due to EAGAIN or EWOULDBLOCK
+ */
+#define NC_READ_SLEEP 100
+
+/**
+ * @brief Enumeration of transport implementations (ways how libnetconf implements NETCONF transport protocol)
+ */
+typedef enum {
+ NC_TI_FD, /**< file descriptors - use standard input/output, transport protocol is implemented
+ outside the current application (only for NETCONF over SSH transport) */
+#ifdef ENABLE_LIBSSH
+ NC_TI_LIBSSH, /**< libssh - use libssh library, only for NETCONF over SSH transport */
+#endif
+#ifdef ENABLE_TLS
+ NC_TI_OPENSSL /**< OpenSSL - use OpenSSK library, only for NETCONF over TLS transport */
+#endif
+} NC_TRANSPORT_IMPL;
+
+/**
+ * @brief Enumeration of possible session types (communication sides)
+ */
+typedef enum {
+ NC_SIDE_SERVER, /**< server side */
+ NC_SIDE_CLIENT /**< client side */
+} NC_SIDE;
+
+/**
+ * @brief Enumeration of the supported NETCONF protocol versions
+ */
+typedef enum {
+ NC_VERSION_10 = 0, /**< NETCONV 1.0 - RFC 4741, 4742 */
+ NC_VERSION_11 = 1 /**< NETCONF 1.1 - RFC 6241, 6242 */
+} NC_VERSION;
+
+#define NC_VERSION_10_ENDTAG "]]>]]>"
+#define NC_VERSION_10_ENDTAG_LEN 6
+
+/**
+ * @brief NETCONF session structure
+ */
+struct nc_session {
+ NC_SIDE side; /**< type of the session: client or server */
+ uint32_t id; /**< NETCONF session ID (session-id-type) */
+ NC_VERSION version; /**< NETCONF protocol version */
+ NC_TRANSPORT_IMPL ti_type; /**< transport implementation type to select items from ti union */
+ pthread_mutex_t ti_lock; /**< lock to access ti */
+ union {
+ struct {
+ int in; /**< input file descriptor */
+ int out; /**< output file descriptor */
+ char c; /**< internal buffer (ungetc() simulation */
+ } fd; /**< NC_TI_FD transport implementation structure */
+#ifdef ENABLE_LIBSSH
+ struct {
+ ssh_session session;
+ ssh_channel channel;
+ } libssh;
+#endif
+#ifdef ENABLE_TLS
+ SSL *tls;
+#endif
+ } ti;
+ struct ly_ctx *ctx;
+};
+
+/**
+ * Functions
+ * - io.c
+ */
+
+/**
+ * @brief Read message from the wire.
+ *
+ * Accepts hello, rpc, rpc-reply and notification. Received string is transformed into
+ * libyang XML tree and the message type is detected from the top level element.
+ *
+ * @param[in] session NETCONF session from which the message is being read.
+ * @param[in] timeout Timeout in milliseconds. Negative value means infinite timeout,
+ * zero value causes to return immediately.
+ * @param[out] data XML tree built from the read data.
+ * @return Type of the read message. #NC_MSG_WOULDBLOCK is returned if timeout is positive
+ * (or zero) value and it passed out without any data on the wire. #NC_MSG_UNKNOWN is
+ * returned on error and #NC_MSG_NONE is never returned by this function.
+ */
+NC_MSG_TYPE nc_read_msg(struct nc_session* session, int timeout, struct lyxml_elem **data);
+
+#endif /* NC_SESSION_PRIVATE_H_ */