Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
michalvasko committed May 3, 2017
2 parents d460dea + 42887fa commit 4d13eca
Show file tree
Hide file tree
Showing 32 changed files with 4,915 additions and 2,146 deletions.
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ before_install:
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then bash .travis-deps-osx.sh; fi

script:
- cd $TRAVIS_BUILD_DIR && mkdir build_none && cd build_none ; cmake -DENABLE_TLS=OFF -DENABLE_SSH=OFF -DENABLE_DNSSEC=OFF .. && make -j2 && make test
- cd $TRAVIS_BUILD_DIR && mkdir build_tls && cd build_tls ; cmake -DENABLE_TLS=ON -DENABLE_SSH=OFF -DENABLE_DNSSEC=OFF .. && make -j2 && make test
- cd $TRAVIS_BUILD_DIR && mkdir build_ssh && cd build_ssh ; cmake -DENABLE_TLS=OFF -DENABLE_SSH=ON -DENABLE_DNSSEC=OFF .. && make -j2 && make test
- cd $TRAVIS_BUILD_DIR && mkdir build_ssh_tls && cd build_ssh_tls ; cmake -DENABLE_TLS=ON -DENABLE_SSH=ON -DENABLE_DNSSEC=OFF .. && make -j2 && make test
- cd $TRAVIS_BUILD_DIR && mkdir build_all && cd build_all ; cmake -DENABLE_TLS=ON -DENABLE_SSH=ON -DENABLE_DNSSEC=ON .. && make -j2 && make test
- cd $TRAVIS_BUILD_DIR && mkdir build_none && cd build_none ; cmake -DENABLE_TLS=OFF -DENABLE_SSH=OFF -DENABLE_DNSSEC=OFF .. && make -j2 && ctest -V
- cd $TRAVIS_BUILD_DIR && mkdir build_tls && cd build_tls ; cmake -DENABLE_TLS=ON -DENABLE_SSH=OFF -DENABLE_DNSSEC=OFF .. && make -j2 && ctest -V
- cd $TRAVIS_BUILD_DIR && mkdir build_ssh && cd build_ssh ; cmake -DENABLE_TLS=OFF -DENABLE_SSH=ON -DENABLE_DNSSEC=OFF .. && make -j2 && ctest -V
- cd $TRAVIS_BUILD_DIR && mkdir build_ssh_tls && cd build_ssh_tls ; cmake -DENABLE_TLS=ON -DENABLE_SSH=ON -DENABLE_DNSSEC=OFF .. && make -j2 && ctest -V
- cd $TRAVIS_BUILD_DIR && mkdir build_all && cd build_all ; cmake -DENABLE_TLS=ON -DENABLE_SSH=ON -DENABLE_DNSSEC=ON .. && make -j2 && ctest -V

after_success:
- if [ "$TRAVIS_OS_NAME" = "linux" -a "$CC" = "gcc" ]; then codecov; fi
42 changes: 15 additions & 27 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,30 +1,20 @@
cmake_minimum_required(VERSION 2.6)
project(libnetconf2 C)
include(GNUInstallDirs)
include (CheckFunctionExists)

# include custom Modules
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeModules/")

project(libnetconf2 C)
set(LIBNETCONF2_DESCRIPTION "NETCONF server and client library in C.")

# check the supported platform
if(NOT UNIX)
message(FATAL_ERROR "Only *nix like systems are supported.")
endif()

if(NOT LIB_INSTALL_DIR)
set(LIB_INSTALL_DIR lib)
endif()

if(NOT INCLUDE_INSTALL_DIR)
set(INCLUDE_INSTALL_DIR include)
endif()

set(INCLUDE_INSTALL_SUBDIR ${INCLUDE_INSTALL_DIR}/libnetconf2)

if(NOT DATA_INSTALL_DIR)
set(DATA_INSTALL_DIR share/libnetconf2)
endif()
set(INCLUDE_INSTALL_SUBDIR ${CMAKE_INSTALL_INCLUDEDIR}/libnetconf2)
set(DATA_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/libnetconf2)

# set default build type if not specified by user
if(NOT CMAKE_BUILD_TYPE)
Expand All @@ -37,15 +27,18 @@ set(CMAKE_C_FLAGS_DEBUG "-g -O0")

# set version
set(LIBNETCONF2_MAJOR_VERSION 0)
set(LIBNETCONF2_MINOR_VERSION 7)
set(LIBNETCONF2_MICRO_VERSION 49)
set(LIBNETCONF2_MINOR_VERSION 8)
set(LIBNETCONF2_MICRO_VERSION 56)
set(LIBNETCONF2_VERSION ${LIBNETCONF2_MAJOR_VERSION}.${LIBNETCONF2_MINOR_VERSION}.${LIBNETCONF2_MICRO_VERSION})
set(LIBNETCONF2_SOVERSION ${LIBNETCONF2_MAJOR_VERSION}.${LIBNETCONF2_MINOR_VERSION})

# build options
option(ENABLE_SSH "Enable NETCONF over SSH support (via libssh)" ON)
option(ENABLE_TLS "Enable NETCONF over TLS support (via OpenSSL)" ON)
option(ENABLE_DNSSEC "Enable support for SSHFP retrieval using DNSSEC for SSH (requires OpenSSL and libval)" OFF)
set(READ_INACTIVE_TIMEOUT 20 CACHE STRING "Maximum number of seconds waiting for new data once some data have arrived")
set(READ_ACTIVE_TIMEOUT 300 CACHE STRING "Maximum number of seconds for receiving a full message")
set(MAX_PSPOLL_THREAD_COUNT 6 CACHE STRING "Maximum number of threads that could simultaneously access a ps_poll structure")

if(ENABLE_DNSSEC AND NOT ENABLE_SSH)
message(WARNING "DNSSEC SSHFP retrieval cannot be used without SSH support.")
Expand Down Expand Up @@ -151,17 +144,12 @@ if(DOXYGEN_FOUND)
configure_file(Doxyfile.in Doxyfile)
endif()

# option - partial message read timeout in seconds (also used for internal <get-schema> RPC reply wait)
if(NOT READ_TIMEOUT)
set(READ_TIMEOUT 30)
endif()

# install library
install(TARGETS netconf2 DESTINATION ${LIB_INSTALL_DIR})
install(TARGETS netconf2 DESTINATION ${CMAKE_INSTALL_LIBDIR})

# install headers
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/nc_client.h DESTINATION ${INCLUDE_INSTALL_DIR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/nc_server.h DESTINATION ${INCLUDE_INSTALL_DIR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/nc_client.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/nc_server.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(FILES ${headers} DESTINATION ${INCLUDE_INSTALL_SUBDIR})

# install schemas
Expand All @@ -174,14 +162,14 @@ install(
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
configure_file("libnetconf2.pc.in" "libnetconf2.pc" @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libnetconf2.pc" DESTINATION "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/pkgconfig")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libnetconf2.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
# check that pkg-config includes the used path
execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable pc_path pkg-config RESULT_VARIABLE RETURN OUTPUT_VARIABLE PC_PATH ERROR_QUIET)
if(RETURN EQUAL 0)
string(REGEX MATCH "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/pkgconfig" SUBSTR "${PC_PATH}")
string(REGEX MATCH "${CMAKE_INSTALL_LIBDIR}/pkgconfig" SUBSTR "${PC_PATH}")
string(LENGTH "${SUBSTR}" SUBSTR_LEN)
if(SUBSTR_LEN EQUAL 0)
message(WARNING "pkg-config will not detect the new package after installation, adjust PKG_CONFIG_PATH using \"export PKG_CONFIG_PATH=\${PKG_CONFIG_PATH}:${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/pkgconfig\".")
message(WARNING "pkg-config will not detect the new package after installation, adjust PKG_CONFIG_PATH using \"export PKG_CONFIG_PATH=\${PKG_CONFIG_PATH}:${CMAKE_INSTALL_LIBDIR}/pkgconfig\".")
endif()
endif()
endif()
Expand Down
119 changes: 99 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,79 @@ and servers. NETCONF is the [NETwork CONFiguration protocol]
(http://trac.tools.ietf.org/wg/netconf/trac/wiki) introduced by IETF.

The library provides functions to connect NETCONF client and server to each
other via SSH and to send, receive and process NETCONF messages. In contrast
to the [previous libnetconf library](https://github.com/CESNET/libnetconf),
**libnetconf2** does not include NETCONF datastore implementation. This
functionality is left specific to the NETCONF server implementation.
other via SSH and to send, receive and process NETCONF messages.

**libnetconf2** is maintained and further developed by the [Tools for
Monitoring and Configuration](https://www.liberouter.org/) department of
[CESNET](http://www.ces.net/). Any testing of the library is welcome. Please
inform us about your experiences with using **libnetconf2** via the
[issue tracker](https://github.com/CESNET/libnetconf/issues).
[CESNET](http://www.ces.net/). Any testing or improving/fixing the library
is welcome. Please inform us about your experiences with using **libnetconf2**
via the [issue tracker](https://github.com/CESNET/libnetconf/issues).

Besides the [**libyang**](https://github.com/CESNET/libyang), **libnetconf2** is
another basic building block for the [**Netopeer2** toolset]
(https://github.com/CESNET/Netopeer2). For a reference implementation of NETCONF
client and server, check the **Netopeer2** project.

## libnetconf vs libnetconf2

**libnetconf2** is being developed with experiences gained from the development
of the [libnetconf](https://github.com/CESNET/libnetconf) library. This
previous generation of our NETCONF library is built on libxml2, used to
internally represent all the data. In **libnetconf2**, we have completely
replaced libxml2 by [libyang](https://github.com/CESNET/libyang). The libyang
library is much more efficient in work with YANG modeled data (which is the
case of NETCONF messages) and this advantage then applies also to
**libnetconf2**. The library is connected with YANG, so for example data
validation according to the provided YANG schemas is done internally instead
of using external DSDL tools (as it was in the first generation of libnetconf).

**libnetconf2** is currently being developed, and some (server-side) functions
are not yet implemented. Feedback and bug reports concerning problems not
mentioned here are appreciated via the issue tracker.
of the [**libnetconf**](https://github.com/CESNET/libnetconf) library. Here are the
main differences between the both libraries that would help you to decide which
of them is more suitable for your needs.

### libxml2 vs libyang

To represent the schema and data trees, **libnetconf** uses libxml2, which is
intended for different purposes - schema and data trees connected with YANG
have specific needs and restrictions in comparison to more generic XML.
Therefore, in **libnetconf2**, we have completely replaced libxml2 by [libyang]
(https://github.com/CESNET/libyang). It is much more efficient in work with
YANG modeled data (which is the case of NETCONF messages) and this advantage
then applies also to **libnetconf2**. The library connects data with the YANG
schemas, so for example the data validation according to the provided YANG
schemas is done internally by libyang instead of using external and extremely
slow DSDL tools (as it was in the first generation of libnetconf).

### Datastore

**libnetconf** was trying to be all-in-one, so besides the NETCONF transport,
it also implements configuration datastores, NETCONF Access Control Module or
the NETCONF Event Notification storage. In contrast, to allow better design of
the NETCONF servers, **libnetconf2** is focused strictly to the NETCONF
transport and message manipulation.

Therefore, all the features from **libnetconf** that are connected to the
datastore implementation are not available in **libnetconf2**. In the case of
the Netopeer2 server, all these features (and much more) are implemented as
part of the server itself or its datastore implementation -
[**sysrepo**](https://github.com/sysrepo/sysrepo).

### Notifications

While **libnetconf2** is able to send (on the server side) and receive (on the
client side) the NETCONF Event Notification messages, its generation and storage
is left up to the server implementation. In case of the Netopeer2 server, the
Notifications implementation is split between the server itself (managing
subscriptions) and sysrepo (Events storage).

### Call Home

Similarly as in case of Notifications, **libnetconf2** provides supporting
functions implementing the Call Home mechanism, but its management (setting the
connection parameters) is supposed to be done in the server. Again, as a
reference implementation, you can check the Netopeer2 server.

In contrast to **libnetconf**, **libnetconf2** actually implements more of the
Call Home functionality.

## Features

* NETCONF v1.0 and v1.1 compliant ([RFC 6241](https://tools.ietf.org/html/rfc6241))
* NETCONF over SSH ([RFC 6242](https://tools.ietf.org/html/rfc6242)) including Chunked Framing Mechanism
* DNSSEC SSH Key Fingerprints ([RFC 4255](https://tools.ietf.org/html/rfc4255))
* NETCONF over TLS ([RFC 5539bis](https://tools.ietf.org/html/draft-ietf-netconf-rfc5539bis-05))
* Transport support for NETCONF Event Notifications ([RFC 5277](https://tools.ietf.org/html/rfc5277))
* NETCONF Call Home ([NETCONF Call Home Draft](https://tools.ietf.org/html/draft-ietf-netconf-call-home-17))

# Installation

Expand Down Expand Up @@ -173,6 +221,37 @@ The `Debug` mode is currently used as the default one. to switch to the
```
$ cmake -D CMAKE_BUILD_TYPE:String="Release" ..
```

### Inactive Read Timeout

It is possible to adjust inactive read timeout. It is used when a new message is
being read and no new data had arrived for this amount of seconds. 20 is the default value.

```
$ cmake -D READ_INACTIVE_TIMEOUT:String="20" ..
```

### Active Read Timeout

Active read timeout is used to limit the maximum number of seconds a message is given
to arrive in its entirety once a beginning is read. The default is 300 (5 minutes).

```
$ cmake -D READ_ACTIVE_TIMEOUT:String="300" ..
```

### PSPoll Thread Count

This value limits the maximum number of threads that can concurrently access
(wait for access) a single pspoll structure. To simplify, how many threads could
simultaneously call a function whose parameter is one and the same pspoll structure.
If using **netopeer2-server**, it will warn that this value needs to be adjusted if
too small.

```
$ cmake -D MAX_PSPOLL_THREAD_COUNT:String="6" ..
```

### CMake Notes

Note that, with CMake, if you want to change the compiler or its options after
Expand Down
6 changes: 4 additions & 2 deletions libnetconf2.pc.in
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
prefix=@CMAKE_INSTALL_PREFIX@
includedir=${prefix}/@INCLUDE_INSTALL_DIR@
libdir=${prefix}/@LIB_INSTALL_DIR@
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@

Name: @PROJECT_NAME@
Description: @LIBNETCONF2_DESCRIPTION@
Version: @LIBNETCONF2_VERSION@
Libs: -L${libdir} -lnetconf2
Cflags: -I${includedir}

LNC2_MAX_THREAD_COUNT=@MAX_PSPOLL_THREAD_COUNT@
4 changes: 2 additions & 2 deletions nc_server.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
* \author Radek Krejci <[email protected]>
* \brief libnetconf2's main public header for NETCONF servers.
*
* Copyright (c) 2015 CESNET, z.s.p.o.
* Copyright (c) 2015 - 2017 CESNET, z.s.p.o.
*
* This source code is licensed under BSD 3-Clause License (the "License").
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* https://opensource.org/licenses/BSD-3-Clause
*/

Expand Down
18 changes: 14 additions & 4 deletions src/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* \author Radek Krejci <[email protected]>
* \brief libnetconf2 various configuration settings.
*
* Copyright (c) 2015 CESNET, z.s.p.o.
* Copyright (c) 2015 - 2017 CESNET, z.s.p.o.
*
* This source code is licensed under BSD 3-Clause License (the "License").
* You may not use this file except in compliance with the License.
Expand Down Expand Up @@ -50,9 +50,19 @@
#define SCHEMAS_DIR "@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@"

/*
* Partial message read timeout in seconds
* (also used as nc_pollsession lock timeout and internal <get-schema> RPC reply timeout)
* Inactive read timeout
*/
#define NC_READ_TIMEOUT @READ_TIMEOUT@
#define NC_READ_INACT_TIMEOUT @READ_INACTIVE_TIMEOUT@

/*
* Active read timeout in seconds
* (also used for internal <get-schema> RPC reply timeout)
*/
#define NC_READ_ACT_TIMEOUT @READ_ACTIVE_TIMEOUT@

/*
* pspoll structure queue size (also found in nc_server.h)
*/
#define NC_PS_QUEUE_SIZE @MAX_PSPOLL_THREAD_COUNT@

#endif /* NC_CONFIG_H_ */
Loading

0 comments on commit 4d13eca

Please sign in to comment.