Skip to content

Commit

Permalink
server NEW initial commit of netopeer2 for new sysrepo
Browse files Browse the repository at this point in the history
TODO: NACM, configuration, notifications, tests
  • Loading branch information
michalvasko committed May 16, 2019
0 parents commit b54367f
Show file tree
Hide file tree
Showing 99 changed files with 20,581 additions and 0 deletions.
49 changes: 49 additions & 0 deletions CMakeModules/FindCMocka.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# - Try to find CMocka
# Once done this will define
#
# CMOCKA_ROOT_DIR - Set this variable to the root installation of CMocka
#
# Read-Only variables:
# CMOCKA_FOUND - system has CMocka
# CMOCKA_INCLUDE_DIR - the CMocka include directory
# CMOCKA_LIBRARIES - Link these to use CMocka
# CMOCKA_DEFINITIONS - Compiler switches required for using CMocka
#
#=============================================================================
# Copyright (c) 2011-2012 Andreas Schneider <[email protected]>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
#

find_path(CMOCKA_INCLUDE_DIR
NAMES
cmocka.h
PATHS
${CMOCKA_ROOT_DIR}/include
)

find_library(CMOCKA_LIBRARY
NAMES
cmocka
PATHS
${CMOCKA_ROOT_DIR}/include
)

if (CMOCKA_LIBRARY)
set(CMOCKA_LIBRARIES
${CMOCKA_LIBRARIES}
${CMOCKA_LIBRARY}
)
endif (CMOCKA_LIBRARY)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(CMocka DEFAULT_MSG CMOCKA_LIBRARIES CMOCKA_INCLUDE_DIR)

# show the CMOCKA_INCLUDE_DIR and CMOCKA_LIBRARIES variables only in the advanced view
mark_as_advanced(CMOCKA_INCLUDE_DIR CMOCKA_LIBRARIES)
90 changes: 90 additions & 0 deletions CMakeModules/FindLibNETCONF2.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# - Try to find LibNETCONF2
# Once done this will define
#
# LIBNETCONF2_FOUND - system has LibNETCONF2
# LIBNETCONF2_INCLUDE_DIRS - the LibNETCONF2 include directory
# LIBNETCONF2_LIBRARIES - Link these to use LibNETCONF2
# LIBNETCONF2_ENABLED_SSH - LibNETCONF2 was compiled with SSH support
# LIBNETCONF2_ENABLED_TLS - LibNETCONF2 was compiled with TLS support
#
# Author Michal Vasko <[email protected]>
# 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 copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#

INCLUDE(CheckSymbolExists)

if (LIBNETCONF2_LIBRARIES AND LIBNETCONF2_INCLUDE_DIRS)
# in cache already
set(LIBNETCONF2_FOUND TRUE)
else (LIBNETCONF2_LIBRARIES AND LIBNETCONF2_INCLUDE_DIRS)

find_path(LIBNETCONF2_INCLUDE_DIR
NAMES
nc_client.h
nc_server.h
PATHS
/usr/include
/usr/local/include
/opt/local/include
/sw/include
${CMAKE_INCLUDE_PATH}
${CMAKE_INSTALL_PREFIX}/include
)

find_library(LIBNETCONF2_LIBRARY
NAMES
netconf2
libnetconf2
PATHS
/usr/lib
/usr/lib64
/usr/local/lib
/usr/local/lib64
/opt/local/lib
/sw/lib
${CMAKE_LIBRARY_PATH}
${CMAKE_INSTALL_PREFIX}/lib
)

if (LIBNETCONF2_INCLUDE_DIR AND LIBNETCONF2_LIBRARY)
set(LIBNETCONF2_FOUND TRUE)
# check the configured options and make them available through cmake
list(INSERT CMAKE_REQUIRED_INCLUDES 0 "${LIBNETCONF2_INCLUDE_DIR}")
check_symbol_exists("NC_ENABLED_SSH" "nc_client.h" LIBNETCONF2_ENABLED_SSH)
check_symbol_exists("NC_ENABLED_TLS" "nc_client.h" LIBNETCONF2_ENABLED_TLS)
list(REMOVE_AT CMAKE_REQUIRED_INCLUDES 0)
else (LIBNETCONF2_INCLUDE_DIR AND LIBNETCONF2_LIBRARY)
set(LIBNETCONF2_FOUND FALSE)
endif (LIBNETCONF2_INCLUDE_DIR AND LIBNETCONF2_LIBRARY)

set(LIBNETCONF2_INCLUDE_DIRS ${LIBNETCONF2_INCLUDE_DIR})
set(LIBNETCONF2_LIBRARIES ${LIBNETCONF2_LIBRARY})

# show the LIBNETCONF2_INCLUDE_DIRS and LIBNETCONF2_LIBRARIES variables only in the advanced view
mark_as_advanced(LIBNETCONF2_INCLUDE_DIRS LIBNETCONF2_LIBRARIES)

endif (LIBNETCONF2_LIBRARIES AND LIBNETCONF2_INCLUDE_DIRS)

80 changes: 80 additions & 0 deletions CMakeModules/FindLibYANG.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# - Try to find LibYANG
# Once done this will define
#
# LIBYANG_FOUND - system has LibYANG
# LIBYANG_INCLUDE_DIRS - the LibYANG include directory
# LIBYANG_LIBRARIES - Link these to use LibYANG
#
# Author Radek Krejci <[email protected]>
# 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 copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#

if (LIBYANG_LIBRARIES AND LIBYANG_INCLUDE_DIRS)
# in cache already
set(LIBYANG_FOUND TRUE)
else (LIBYANG_LIBRARIES AND LIBYANG_INCLUDE_DIRS)

find_path(LIBYANG_INCLUDE_DIR
NAMES
libyang/libyang.h
PATHS
/usr/include
/usr/local/include
/opt/local/include
/sw/include
${CMAKE_INCLUDE_PATH}
${CMAKE_INSTALL_PREFIX}/include
)

find_library(LIBYANG_LIBRARY
NAMES
yang
libyang
PATHS
/usr/lib
/usr/lib64
/usr/local/lib
/usr/local/lib64
/opt/local/lib
/sw/lib
${CMAKE_LIBRARY_PATH}
${CMAKE_INSTALL_PREFIX}/lib
)

if (LIBYANG_INCLUDE_DIR AND LIBYANG_LIBRARY)
set(LIBYANG_FOUND TRUE)
else (LIBYANG_INCLUDE_DIR AND LIBYANG_LIBRARY)
set(LIBYANG_FOUND FALSE)
endif (LIBYANG_INCLUDE_DIR AND LIBYANG_LIBRARY)

set(LIBYANG_INCLUDE_DIRS ${LIBYANG_INCLUDE_DIR})
set(LIBYANG_LIBRARIES ${LIBYANG_LIBRARY})

# show the LIBYANG_INCLUDE_DIRS and LIBYANG_LIBRARIES variables only in the advanced view
mark_as_advanced(LIBYANG_INCLUDE_DIRS LIBYANG_LIBRARIES)

endif (LIBYANG_LIBRARIES AND LIBYANG_INCLUDE_DIRS)

89 changes: 89 additions & 0 deletions CMakeModules/FindPackageVersionCheck.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# FIND_PACKAGE_VERSION_CHECK(NAME (DEFAULT_MSG|"Custom failure message"))
# This function is intended to be used in FindXXX.cmake modules files.
# It handles NAME_FIND_VERSION and NAME_VERSION variables in a Module.
#
# Example:
# find_package(LibSSH 0.3.2)
#
# # check for the version and set it
# set(LibSSH_VERSION 0.3.0)
# find_package_version_check(LibSSH DEFAULT_MSG)
#
#
# Copyright (c) 2009 Andreas Schneider <[email protected]>
#
# 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 copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#

function(FIND_PACKAGE_VERSION_CHECK _NAME _FAIL_MSG)
string(TOUPPER ${_NAME} _NAME_UPPER)
set(_AGE "old")

if(${_NAME}_FIND_VERSION_EXACT)
if (${_NAME}_FIND_VERSION VERSION_EQUAL ${_NAME}_VERSION)
# exact version found
set(${_NAME_UPPER}_FOUND TRUE)
else (${_NAME}_FIND_VERSION VERSION_EQUAL ${_NAME}_VERSION)
# exect version not found
set(${_NAME_UPPER}_FOUND FALSE)
# check if newer or older
if (${_NAME}_FIND_VERSION VERSION_LESS ${_NAME}_VERSION)
set(_AGE "new")
else (${_NAME}_FIND_VERSION VERSION_LESS ${_NAME}_VERSION)
set(_AGE "old")
endif (${_NAME}_FIND_VERSION VERSION_LESS ${_NAME}_VERSION)
endif (${_NAME}_FIND_VERSION VERSION_EQUAL ${_NAME}_VERSION)
else (${_NAME}_FIND_VERSION_EXACT)
if (${_NAME}_FIND_VERSION)
if (${_NAME}_VERSION VERSION_LESS ${_NAME}_FIND_VERSION)
set(${_NAME_UPPER}_FOUND FALSE)
set(_AGE "old")
else (${_NAME}_VERSION VERSION_LESS ${_NAME}_FIND_VERSION)
set(${_NAME_UPPER}_FOUND TRUE)
endif (${_NAME}_VERSION VERSION_LESS ${_NAME}_FIND_VERSION)
endif (${_NAME}_FIND_VERSION)
endif(${_NAME}_FIND_VERSION_EXACT)

if ("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG")
if (${_NAME}_FIND_VERSION_EXACT)
set(_FAIL_MESSAGE "The installed ${_NAME} version ${${_NAME}_VERSION} is too ${_AGE}, version ${${_NAME}_FIND_VERSION} is required.")
else (${_NAME}_FIND_VERSION_EXACT)
set(_FAIL_MESSAGE "The installed ${_NAME} version ${${_NAME}_VERSION} is too ${_AGE}, at least version ${${_NAME}_FIND_VERSION} is required.")
endif (${_NAME}_FIND_VERSION_EXACT)
else ("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG")
set(_FAIL_MESSAGE "${_FAIL_MSG}")
endif ("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG")

if (NOT ${_NAME_UPPER}_FOUND)
if (${_NAME}_FIND_REQUIRED)
message(FATAL_ERROR "${_FAIL_MESSAGE}")
else (${_NAME}_FIND_REQUIRED)
if (NOT ${_NAME}_FIND_QUIETLY)
message(STATUS "${_FAIL_MESSAGE}")
endif (NOT ${_NAME}_FIND_QUIETLY)
endif (${_NAME}_FIND_REQUIRED)
endif (NOT ${_NAME_UPPER}_FOUND)

set(${_NAME_UPPER}_FOUND ${${_NAME_UPPER}_FOUND} PARENT_SCOPE)
endfunction(FIND_PACKAGE_VERSION_CHECK)
26 changes: 26 additions & 0 deletions CMakeModules/FindSYSREPO.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# SYSREPO_FOUND - System has SYSREPO
# SYSREPO_INCLUDE_DIRS - The SYSREPO include directories
# SYSREPO_LIBRARIES - The libraries needed to use SYSREPO
# SYSREPO_DEFINITIONS - Compiler switches required for using SYSREPO

find_package(PkgConfig)
pkg_check_modules(PC_SYSREPO QUIET sysrepo)
set(SYSREPO_DEFINITIONS ${PC_SYSREPO_CFLAGS_OTHER})

find_path(SYSREPO_INCLUDE_DIR sysrepo.h
HINTS ${PC_SYSREPO_INCLUDEDIR} ${PC_SYSREPO_INCLUDE_DIRS}
PATH_SUFFIXES sysrepo )

find_library(SYSREPO_LIBRARY NAMES sysrepo
HINTS ${PC_SYSREPO_LIBDIR} ${PC_SYSREPO_LIBRARY_DIRS} )

set(SYSREPO_LIBRARIES ${SYSREPO_LIBRARY} )
set(SYSREPO_INCLUDE_DIRS ${SYSREPO_INCLUDE_DIR} )

include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set SYSREPO_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(sysrepo DEFAULT_MSG
SYSREPO_LIBRARY SYSREPO_INCLUDE_DIR)

mark_as_advanced(SYSREPO_INCLUDE_DIR SYSREPO_LIBRARY )
Loading

0 comments on commit b54367f

Please sign in to comment.