Skip to content

Commit

Permalink
Update to the new netopeer2 release
Browse files Browse the repository at this point in the history
  • Loading branch information
igortern committed May 11, 2020
1 parent 8c4c666 commit b0e1e6e
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 55 deletions.
23 changes: 23 additions & 0 deletions netconf_server/bcmolt_netconf_server.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
/*
* <:copyright-BRCM:2016-2020:Apache:standard
*
* Copyright (c) 2016-2020 Broadcom. All Rights Reserved
*
* The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* :>
*
*****************************************************************************/

#include <bcmos_system.h>
#include <bcmcli.h>
#include <bcmolt_daemon.h>
Expand Down
40 changes: 22 additions & 18 deletions netconf_server/modules/bcmolt_netconf_module_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,13 @@ void nc_cfg_copy(sr_session_ctx_t *srs, const char *model, nc_datastore_type fro
{
char *src_path = NULL;
char *cmd = NULL;
int n1, n2;

asprintf(&src_path, SR_DATA_SEARCH_DIR "/%s.%s", model, nc_ds_suffix[from]);
asprintf(&cmd, "cp -f " SR_DATA_SEARCH_DIR "/%s.%s " SR_DATA_SEARCH_DIR "/%s.%s",
n1 = asprintf(&src_path, SR_DATA_SEARCH_DIR "/%s.%s", model, nc_ds_suffix[from]);
n2 = asprintf(&cmd, "cp -f " SR_DATA_SEARCH_DIR "/%s.%s " SR_DATA_SEARCH_DIR "/%s.%s",
model, nc_ds_suffix[from], model, nc_ds_suffix[to]);

if (!cmd || !src_path)
if (!cmd || !src_path || n1 < 0 || n2 < 0)
{
NC_LOG_ERR("%s: failed to copy configuration from %s to %s: no memory\n",
model, nc_ds_suffix[from], nc_ds_suffix[to]);
Expand Down Expand Up @@ -186,18 +187,11 @@ void nc_cfg_reset(sr_session_ctx_t *srs, const char *model, nc_datastore_type ds
{
char *fname = NULL, *cmd = NULL;
int rc = -1;
int n1, n2;

asprintf(&fname, SR_DATA_SEARCH_DIR "/%s.%s", model, nc_ds_suffix[ds]);

/* Do nothing if file doesn't exist */
if (!nc_file_exist(fname))
{
free(fname);
return;
}

asprintf(&cmd, "touch %s", fname);
if (!fname || !cmd)
n1 = asprintf(&fname, SR_DATA_SEARCH_DIR "/%s.%s", model, nc_ds_suffix[ds]);
n2 = asprintf(&cmd, "touch %s", fname);
if (!fname || !cmd || n1 < 0 || n2 < 0)
{
NC_LOG_ERR("%s: failed to reset %s configuration: no memory\n", model, nc_ds_suffix[ds]);
if (fname)
Expand All @@ -206,6 +200,15 @@ void nc_cfg_reset(sr_session_ctx_t *srs, const char *model, nc_datastore_type ds
free(cmd);
return;
}

/* Do nothing if file doesn't exist */
if (!nc_file_exist(fname))
{
free(fname);
free(cmd);
return;
}

if (!unlink(fname))
rc = system(cmd);
free(fname);
Expand All @@ -225,11 +228,12 @@ void nc_error_reply(sr_session_ctx_t *srs, const char *xpath, const char *format
{
va_list args;
char *msg = NULL;
int n;

va_start(args, format);
vasprintf(&msg, format, args);
n = vasprintf(&msg, format, args);
va_end(args);
if (msg)
if (msg && n > 0)
{
sr_set_error(srs, xpath, msg);
free(msg);
Expand Down Expand Up @@ -345,7 +349,7 @@ int nc_sr_sub_value_add(

if (snprintf(xpath, sizeof(xpath_buf), "%s/%s", xpath_base, value_name) > sizeof(xpath_buf) - 1)
{
if (!asprintf(&xpath, "%s/%s", xpath_base, value_name))
if (asprintf(&xpath, "%s/%s", xpath_base, value_name) <= 0)
return SR_ERR_NOMEM;
}
sr_rc = nc_sr_value_add(xpath, type, string_val, values, values_cnt);
Expand Down Expand Up @@ -375,7 +379,7 @@ struct lyd_node *nc_ly_sub_value_add(

if (snprintf(xpath, sizeof(xpath_buf), "%s/%s", xpath_base, value_name) > sizeof(xpath_buf) - 1)
{
if (!asprintf(&xpath, "%s/%s", xpath_base, value_name))
if (asprintf(&xpath, "%s/%s", xpath_base, value_name) <= 0)
return parent;
}
result = lyd_new_path(parent, ctx, xpath, (void *)(long)string_val, LYD_ANYDATA_CONSTSTRING, 0);
Expand Down
4 changes: 2 additions & 2 deletions third_party/libnetconf2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
#
include(third_party)

bcm_make_debug_option(NETCONF_TOOLS_FROM_DEVEL BOOL "Take netopeer2, sysrepo, libyang and libnetconf2 from devel" y)
bcm_make_debug_option(NETCONF_TOOLS_FROM_DEVEL BOOL "Take netopeer2, sysrepo, libyang and libnetconf2 from devel" n)
if(NETCONF_TOOLS_FROM_DEVEL)
set(_VERSION "devel")
else()
set(_VERSION "1.1.7")
set(_VERSION "1.1.24")
endif()
bcm_3rdparty_module_name(libnetconf2 ${_VERSION})

Expand Down
Binary file removed third_party/libnetconf2/devel.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion third_party/libyang/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ include(third_party)
if(NETCONF_TOOLS_FROM_DEVEL)
set(_VERSION "devel")
else()
set(_VERSION "1.0.130")
set(_VERSION "1.0.167")
endif()

bcm_3rdparty_module_name(libyang "${_VERSION}")
Expand Down
Binary file removed third_party/libyang/devel.zip
Binary file not shown.
24 changes: 6 additions & 18 deletions third_party/netopeer2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ bcm_make_normal_option(NETOPEER_SSH_PORT STRING "Default SSH port netopeer liste
if(NETCONF_TOOLS_FROM_DEVEL)
set(_VERSION "devel")
else()
set(_VERSION "1.1.7")
set(_VERSION "1.1.27")
endif()

# Netopeer2 consists from multiple components
Expand All @@ -19,7 +19,7 @@ if("${NETOPEER2_VERSION}" STREQUAL "devel")
else()
bcm_3rdparty_download_wget("https://github.com/CESNET/Netopeer2/archive" "v${NETOPEER2_VERSION}.tar.gz" "Netopeer2-${NETOPEER2_VERSION}")
endif()
bcm_3rdparty_add_dependencies(netopeer2-server-configured netopeer2-cli netopeer2-commands)
bcm_3rdparty_add_dependencies(netopeer2-server-configured netopeer2-commands)
bcm_3rdparty_build_dummy()
set(_NETOPEER2_TYPE PACKAGE)
set(NETOPEER2_BASE_DIR ${_${_MOD_NAME_UPPER}_SRC_DIR})
Expand All @@ -40,16 +40,17 @@ bcm_3rdparty_add_dependencies(libyang libnetconf2 libssh sysrepo)
bcm_3rdparty_add_build_options(-DSYSREPOCTL="${_SYSREPO_TOOLS_DIR}/sysrepoctl")
bcm_3rdparty_add_build_options(-DSYSREPOCFG="${_SYSREPO_TOOLS_DIR}/sysrepocfg")
bcm_3rdparty_add_build_options(-DPIDFILE_PREFIX=/tmp)
bcm_3rdparty_add_build_options(-DENABLE_BUILD_TESTS=OFF -DENABLE_VALGRIND_TESTS=OFF)
bcm_3rdparty_add_build_options(-DBUILD_TESTS:bool=OFF -DVALGRIND_TESTS:bool=OFF)
#bcm_3rdparty_add_build_options(-DGENERATE_HOSTKEY=OFF)
bcm_3rdparty_add_build_options(-DLIBNETCONF2_ENABLED_SSH=ON)
bcm_3rdparty_add_build_options(-DLIBNETCONF2_ENABLED_SSH:bool=ON)
bcm_3rdparty_add_build_options(-DPOLL_IO_TIMEOUT=100)
bcm_3rdparty_add_build_options(-DBUILD_CLI:bool=ON)
#bcm_3rdparty_add_build_options(-DDATA_CHANGE_TIMEOUT=10)
bcm_3rdparty_add_env_variables(SYSREPO_REPOSITORY_PATH=${CMAKE_BINARY_DIR}/fs/sysrepo)
if(BCM_CONFIG_HOST MATCHES "x86")
bcm_3rdparty_add_env_variables(PATH=${CMAKE_BINARY_DIR}/fs/bin:$ENV{PATH})
endif()
set(_NETOPEER2-SERVER_SRC_DIR ${NETOPEER2_BASE_DIR}/server)
set(_NETOPEER2-SERVER_SRC_DIR ${NETOPEER2_BASE_DIR})
set(_NETOPEER2-SERVER_TYPE APPLICATION)
add_custom_command(OUTPUT ${_${_MOD_NAME_UPPER}_LOADED_FILE}
COMMAND mkdir -p build
Expand Down Expand Up @@ -77,19 +78,6 @@ add_custom_target(netopeer2-server-configured
unset(_DISABLE_NACM_COMMAND)
unset(_NETOPEER2_CONFIGURED_FILE)

# CLI
bcm_3rdparty_module_name(netopeer2-cli ${NETOPEER2_VERSION})
bcm_3rdparty_add_dependencies(netopeer2-server)
set(_NETOPEER2-CLI_SRC_DIR ${NETOPEER2_BASE_DIR}/cli)
set(_NETOPEER2-CLI_TYPE APPLICATION)
add_custom_command(OUTPUT ${_${_MOD_NAME_UPPER}_LOADED_FILE}
COMMAND mkdir -p build
COMMAND touch ${_${_MOD_NAME_UPPER}_LOADED_FILE}
DEPENDS ${NETOPEER2_LOADED}
WORKING_DIRECTORY ${_${_MOD_NAME_UPPER}_SRC_DIR})
bcm_3rdparty_build_cmake()
bcm_3rdparty_export()

add_custom_target(netopeer2-commands
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/fs/bin
COMMAND cp -af ${CMAKE_CURRENT_SOURCE_DIR}/*.sh ${CMAKE_BINARY_DIR}/fs/bin/)
Expand Down
Binary file removed third_party/netopeer2/devel-server.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion third_party/sysrepo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ include(third_party)
if(NETCONF_TOOLS_FROM_DEVEL)
set(_VERSION "devel")
else()
set(_VERSION "1.4.2")
set(_VERSION "1.4.58")
endif()
bcm_3rdparty_module_name(sysrepo ${_VERSION})

Expand Down
Binary file removed third_party/sysrepo/devel.zip
Binary file not shown.
15 changes: 0 additions & 15 deletions third_party/sysrepo/sysrepo_devel.patch

This file was deleted.

0 comments on commit b0e1e6e

Please sign in to comment.