Skip to content

Commit 4d13eca

Browse files
committed
Merge branch 'devel'
2 parents d460dea + 42887fa commit 4d13eca

32 files changed

+4915
-2146
lines changed

.travis.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ before_install:
2626
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then bash .travis-deps-osx.sh; fi
2727

2828
script:
29-
- cd $TRAVIS_BUILD_DIR && mkdir build_none && cd build_none ; cmake -DENABLE_TLS=OFF -DENABLE_SSH=OFF -DENABLE_DNSSEC=OFF .. && make -j2 && make test
30-
- cd $TRAVIS_BUILD_DIR && mkdir build_tls && cd build_tls ; cmake -DENABLE_TLS=ON -DENABLE_SSH=OFF -DENABLE_DNSSEC=OFF .. && make -j2 && make test
31-
- cd $TRAVIS_BUILD_DIR && mkdir build_ssh && cd build_ssh ; cmake -DENABLE_TLS=OFF -DENABLE_SSH=ON -DENABLE_DNSSEC=OFF .. && make -j2 && make test
32-
- 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
33-
- cd $TRAVIS_BUILD_DIR && mkdir build_all && cd build_all ; cmake -DENABLE_TLS=ON -DENABLE_SSH=ON -DENABLE_DNSSEC=ON .. && make -j2 && make test
29+
- cd $TRAVIS_BUILD_DIR && mkdir build_none && cd build_none ; cmake -DENABLE_TLS=OFF -DENABLE_SSH=OFF -DENABLE_DNSSEC=OFF .. && make -j2 && ctest -V
30+
- cd $TRAVIS_BUILD_DIR && mkdir build_tls && cd build_tls ; cmake -DENABLE_TLS=ON -DENABLE_SSH=OFF -DENABLE_DNSSEC=OFF .. && make -j2 && ctest -V
31+
- cd $TRAVIS_BUILD_DIR && mkdir build_ssh && cd build_ssh ; cmake -DENABLE_TLS=OFF -DENABLE_SSH=ON -DENABLE_DNSSEC=OFF .. && make -j2 && ctest -V
32+
- 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
33+
- cd $TRAVIS_BUILD_DIR && mkdir build_all && cd build_all ; cmake -DENABLE_TLS=ON -DENABLE_SSH=ON -DENABLE_DNSSEC=ON .. && make -j2 && ctest -V
3434

3535
after_success:
3636
- if [ "$TRAVIS_OS_NAME" = "linux" -a "$CC" = "gcc" ]; then codecov; fi

CMakeLists.txt

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,20 @@
11
cmake_minimum_required(VERSION 2.6)
2+
project(libnetconf2 C)
3+
include(GNUInstallDirs)
24
include (CheckFunctionExists)
35

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

7-
project(libnetconf2 C)
89
set(LIBNETCONF2_DESCRIPTION "NETCONF server and client library in C.")
910

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

15-
if(NOT LIB_INSTALL_DIR)
16-
set(LIB_INSTALL_DIR lib)
17-
endif()
18-
19-
if(NOT INCLUDE_INSTALL_DIR)
20-
set(INCLUDE_INSTALL_DIR include)
21-
endif()
22-
23-
set(INCLUDE_INSTALL_SUBDIR ${INCLUDE_INSTALL_DIR}/libnetconf2)
24-
25-
if(NOT DATA_INSTALL_DIR)
26-
set(DATA_INSTALL_DIR share/libnetconf2)
27-
endif()
16+
set(INCLUDE_INSTALL_SUBDIR ${CMAKE_INSTALL_INCLUDEDIR}/libnetconf2)
17+
set(DATA_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/libnetconf2)
2818

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

3828
# set version
3929
set(LIBNETCONF2_MAJOR_VERSION 0)
40-
set(LIBNETCONF2_MINOR_VERSION 7)
41-
set(LIBNETCONF2_MICRO_VERSION 49)
30+
set(LIBNETCONF2_MINOR_VERSION 8)
31+
set(LIBNETCONF2_MICRO_VERSION 56)
4232
set(LIBNETCONF2_VERSION ${LIBNETCONF2_MAJOR_VERSION}.${LIBNETCONF2_MINOR_VERSION}.${LIBNETCONF2_MICRO_VERSION})
4333
set(LIBNETCONF2_SOVERSION ${LIBNETCONF2_MAJOR_VERSION}.${LIBNETCONF2_MINOR_VERSION})
4434

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

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

154-
# option - partial message read timeout in seconds (also used for internal <get-schema> RPC reply wait)
155-
if(NOT READ_TIMEOUT)
156-
set(READ_TIMEOUT 30)
157-
endif()
158-
159147
# install library
160-
install(TARGETS netconf2 DESTINATION ${LIB_INSTALL_DIR})
148+
install(TARGETS netconf2 DESTINATION ${CMAKE_INSTALL_LIBDIR})
161149

162150
# install headers
163-
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/nc_client.h DESTINATION ${INCLUDE_INSTALL_DIR})
164-
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/nc_server.h DESTINATION ${INCLUDE_INSTALL_DIR})
151+
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/nc_client.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
152+
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/nc_server.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
165153
install(FILES ${headers} DESTINATION ${INCLUDE_INSTALL_SUBDIR})
166154

167155
# install schemas
@@ -174,14 +162,14 @@ install(
174162
find_package(PkgConfig)
175163
if(PKG_CONFIG_FOUND)
176164
configure_file("libnetconf2.pc.in" "libnetconf2.pc" @ONLY)
177-
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libnetconf2.pc" DESTINATION "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/pkgconfig")
165+
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libnetconf2.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
178166
# check that pkg-config includes the used path
179167
execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable pc_path pkg-config RESULT_VARIABLE RETURN OUTPUT_VARIABLE PC_PATH ERROR_QUIET)
180168
if(RETURN EQUAL 0)
181-
string(REGEX MATCH "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/pkgconfig" SUBSTR "${PC_PATH}")
169+
string(REGEX MATCH "${CMAKE_INSTALL_LIBDIR}/pkgconfig" SUBSTR "${PC_PATH}")
182170
string(LENGTH "${SUBSTR}" SUBSTR_LEN)
183171
if(SUBSTR_LEN EQUAL 0)
184-
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\".")
172+
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\".")
185173
endif()
186174
endif()
187175
endif()

README.md

Lines changed: 99 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,79 @@ and servers. NETCONF is the [NETwork CONFiguration protocol]
99
(http://trac.tools.ietf.org/wg/netconf/trac/wiki) introduced by IETF.
1010

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

1714
**libnetconf2** is maintained and further developed by the [Tools for
1815
Monitoring and Configuration](https://www.liberouter.org/) department of
19-
[CESNET](http://www.ces.net/). Any testing of the library is welcome. Please
20-
inform us about your experiences with using **libnetconf2** via the
21-
[issue tracker](https://github.com/CESNET/libnetconf/issues).
16+
[CESNET](http://www.ces.net/). Any testing or improving/fixing the library
17+
is welcome. Please inform us about your experiences with using **libnetconf2**
18+
via the [issue tracker](https://github.com/CESNET/libnetconf/issues).
19+
20+
Besides the [**libyang**](https://github.com/CESNET/libyang), **libnetconf2** is
21+
another basic building block for the [**Netopeer2** toolset]
22+
(https://github.com/CESNET/Netopeer2). For a reference implementation of NETCONF
23+
client and server, check the **Netopeer2** project.
24+
25+
## libnetconf vs libnetconf2
2226

2327
**libnetconf2** is being developed with experiences gained from the development
24-
of the [libnetconf](https://github.com/CESNET/libnetconf) library. This
25-
previous generation of our NETCONF library is built on libxml2, used to
26-
internally represent all the data. In **libnetconf2**, we have completely
27-
replaced libxml2 by [libyang](https://github.com/CESNET/libyang). The libyang
28-
library is much more efficient in work with YANG modeled data (which is the
29-
case of NETCONF messages) and this advantage then applies also to
30-
**libnetconf2**. The library is connected with YANG, so for example data
31-
validation according to the provided YANG schemas is done internally instead
32-
of using external DSDL tools (as it was in the first generation of libnetconf).
33-
34-
**libnetconf2** is currently being developed, and some (server-side) functions
35-
are not yet implemented. Feedback and bug reports concerning problems not
36-
mentioned here are appreciated via the issue tracker.
28+
of the [**libnetconf**](https://github.com/CESNET/libnetconf) library. Here are the
29+
main differences between the both libraries that would help you to decide which
30+
of them is more suitable for your needs.
31+
32+
### libxml2 vs libyang
33+
34+
To represent the schema and data trees, **libnetconf** uses libxml2, which is
35+
intended for different purposes - schema and data trees connected with YANG
36+
have specific needs and restrictions in comparison to more generic XML.
37+
Therefore, in **libnetconf2**, we have completely replaced libxml2 by [libyang]
38+
(https://github.com/CESNET/libyang). It is much more efficient in work with
39+
YANG modeled data (which is the case of NETCONF messages) and this advantage
40+
then applies also to **libnetconf2**. The library connects data with the YANG
41+
schemas, so for example the data validation according to the provided YANG
42+
schemas is done internally by libyang instead of using external and extremely
43+
slow DSDL tools (as it was in the first generation of libnetconf).
44+
45+
### Datastore
46+
47+
**libnetconf** was trying to be all-in-one, so besides the NETCONF transport,
48+
it also implements configuration datastores, NETCONF Access Control Module or
49+
the NETCONF Event Notification storage. In contrast, to allow better design of
50+
the NETCONF servers, **libnetconf2** is focused strictly to the NETCONF
51+
transport and message manipulation.
52+
53+
Therefore, all the features from **libnetconf** that are connected to the
54+
datastore implementation are not available in **libnetconf2**. In the case of
55+
the Netopeer2 server, all these features (and much more) are implemented as
56+
part of the server itself or its datastore implementation -
57+
[**sysrepo**](https://github.com/sysrepo/sysrepo).
58+
59+
### Notifications
60+
61+
While **libnetconf2** is able to send (on the server side) and receive (on the
62+
client side) the NETCONF Event Notification messages, its generation and storage
63+
is left up to the server implementation. In case of the Netopeer2 server, the
64+
Notifications implementation is split between the server itself (managing
65+
subscriptions) and sysrepo (Events storage).
66+
67+
### Call Home
68+
69+
Similarly as in case of Notifications, **libnetconf2** provides supporting
70+
functions implementing the Call Home mechanism, but its management (setting the
71+
connection parameters) is supposed to be done in the server. Again, as a
72+
reference implementation, you can check the Netopeer2 server.
73+
74+
In contrast to **libnetconf**, **libnetconf2** actually implements more of the
75+
Call Home functionality.
76+
77+
## Features
78+
79+
* NETCONF v1.0 and v1.1 compliant ([RFC 6241](https://tools.ietf.org/html/rfc6241))
80+
* NETCONF over SSH ([RFC 6242](https://tools.ietf.org/html/rfc6242)) including Chunked Framing Mechanism
81+
* DNSSEC SSH Key Fingerprints ([RFC 4255](https://tools.ietf.org/html/rfc4255))
82+
* NETCONF over TLS ([RFC 5539bis](https://tools.ietf.org/html/draft-ietf-netconf-rfc5539bis-05))
83+
* Transport support for NETCONF Event Notifications ([RFC 5277](https://tools.ietf.org/html/rfc5277))
84+
* NETCONF Call Home ([NETCONF Call Home Draft](https://tools.ietf.org/html/draft-ietf-netconf-call-home-17))
3785

3886
# Installation
3987

@@ -173,6 +221,37 @@ The `Debug` mode is currently used as the default one. to switch to the
173221
```
174222
$ cmake -D CMAKE_BUILD_TYPE:String="Release" ..
175223
```
224+
225+
### Inactive Read Timeout
226+
227+
It is possible to adjust inactive read timeout. It is used when a new message is
228+
being read and no new data had arrived for this amount of seconds. 20 is the default value.
229+
230+
```
231+
$ cmake -D READ_INACTIVE_TIMEOUT:String="20" ..
232+
```
233+
234+
### Active Read Timeout
235+
236+
Active read timeout is used to limit the maximum number of seconds a message is given
237+
to arrive in its entirety once a beginning is read. The default is 300 (5 minutes).
238+
239+
```
240+
$ cmake -D READ_ACTIVE_TIMEOUT:String="300" ..
241+
```
242+
243+
### PSPoll Thread Count
244+
245+
This value limits the maximum number of threads that can concurrently access
246+
(wait for access) a single pspoll structure. To simplify, how many threads could
247+
simultaneously call a function whose parameter is one and the same pspoll structure.
248+
If using **netopeer2-server**, it will warn that this value needs to be adjusted if
249+
too small.
250+
251+
```
252+
$ cmake -D MAX_PSPOLL_THREAD_COUNT:String="6" ..
253+
```
254+
176255
### CMake Notes
177256

178257
Note that, with CMake, if you want to change the compiler or its options after

libnetconf2.pc.in

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
prefix=@CMAKE_INSTALL_PREFIX@
2-
includedir=${prefix}/@INCLUDE_INSTALL_DIR@
3-
libdir=${prefix}/@LIB_INSTALL_DIR@
2+
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
3+
libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
44

55
Name: @PROJECT_NAME@
66
Description: @LIBNETCONF2_DESCRIPTION@
77
Version: @LIBNETCONF2_VERSION@
88
Libs: -L${libdir} -lnetconf2
99
Cflags: -I${includedir}
10+
11+
LNC2_MAX_THREAD_COUNT=@MAX_PSPOLL_THREAD_COUNT@

nc_server.h.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
* \author Radek Krejci <[email protected]>
44
* \brief libnetconf2's main public header for NETCONF servers.
55
*
6-
* Copyright (c) 2015 CESNET, z.s.p.o.
6+
* Copyright (c) 2015 - 2017 CESNET, z.s.p.o.
77
*
88
* This source code is licensed under BSD 3-Clause License (the "License").
99
* You may not use this file except in compliance with the License.
1010
* You may obtain a copy of the License at
11-
*
11+
*
1212
* https://opensource.org/licenses/BSD-3-Clause
1313
*/
1414

src/config.h.in

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* \author Radek Krejci <[email protected]>
44
* \brief libnetconf2 various configuration settings.
55
*
6-
* Copyright (c) 2015 CESNET, z.s.p.o.
6+
* Copyright (c) 2015 - 2017 CESNET, z.s.p.o.
77
*
88
* This source code is licensed under BSD 3-Clause License (the "License").
99
* You may not use this file except in compliance with the License.
@@ -50,9 +50,19 @@
5050
#define SCHEMAS_DIR "@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@"
5151

5252
/*
53-
* Partial message read timeout in seconds
54-
* (also used as nc_pollsession lock timeout and internal <get-schema> RPC reply timeout)
53+
* Inactive read timeout
5554
*/
56-
#define NC_READ_TIMEOUT @READ_TIMEOUT@
55+
#define NC_READ_INACT_TIMEOUT @READ_INACTIVE_TIMEOUT@
56+
57+
/*
58+
* Active read timeout in seconds
59+
* (also used for internal <get-schema> RPC reply timeout)
60+
*/
61+
#define NC_READ_ACT_TIMEOUT @READ_ACTIVE_TIMEOUT@
62+
63+
/*
64+
* pspoll structure queue size (also found in nc_server.h)
65+
*/
66+
#define NC_PS_QUEUE_SIZE @MAX_PSPOLL_THREAD_COUNT@
5767

5868
#endif /* NC_CONFIG_H_ */

0 commit comments

Comments
 (0)