Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configured subscription integration #1440

Open
wants to merge 8 commits into
base: udp_notif
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 29 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,23 +125,29 @@ if(NOT SERVER_DIR)
endif()
endif()

include(ExternalProject)
set(UDP_NOTIF_BIN ${CMAKE_CURRENT_BINARY_DIR}/lib)
set(UDP_NOTIF_STATIC_LIB ${UDP_NOTIF_BIN}/lib/libunyte-udp-notif.a)
set(UDP_NOTIF_INCLUDES ${UDP_NOTIF_BIN}/include)

ExternalProject_Add(udp-notif-c-collector
PREFIX ${UDP_NOTIF_BIN}
GIT_REPOSITORY https://github.com/network-analytics/udp-notif-c-collector
GIT_TAG main
BUILD_IN_SOURCE 1
UPDATE_DISCONNECTED true
PATCH_COMMAND patch -p1 < ${CMAKE_CURRENT_SOURCE_DIR}/patches/0001-feat-add-local-address-to-sender.patch
CONFIGURE_COMMAND ./bootstrap && ./configure --prefix=${UDP_NOTIF_BIN}
BUILD_COMMAND make
INSTALL_COMMAND make install
BUILD_BYPRODUCTS ${UDP_NOTIF_STATIC_LIB}
)
if (NOT UDP_NOTIF_STATIC_LIB)
include(ExternalProject)
set(UDP_NOTIF_BIN ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
set(UDP_NOTIF_STATIC_LIB ${UDP_NOTIF_BIN}/${CMAKE_INSTALL_LIBDIR}/libunyte-udp-notif.a)
set(UDP_NOTIF_INCLUDES ${UDP_NOTIF_BIN}/${CMAKE_INSTALL_INCLUDEDIR})

ExternalProject_Add(udp-notif-c-collector
PREFIX ${UDP_NOTIF_BIN}
GIT_REPOSITORY https://github.com/network-analytics/udp-notif-c-collector
GIT_TAG main
BUILD_IN_SOURCE 1
UPDATE_DISCONNECTED true
PATCH_COMMAND patch -p1 < ${CMAKE_CURRENT_SOURCE_DIR}/patches/0001-feat-add-local-address-to-sender.patch
CONFIGURE_COMMAND ./bootstrap && ./configure --prefix=${UDP_NOTIF_BIN}
BUILD_COMMAND make
INSTALL_COMMAND make install
BUILD_BYPRODUCTS ${UDP_NOTIF_STATIC_LIB}
)
else()
if (NOT UDP_NOTIF_INCLUDES)
message(FATAL_ERROR "Missing UDP_NOTIF_INCLUDES")
endif()
endif()

#
# sources
Expand Down Expand Up @@ -267,7 +273,9 @@ use_compat()

# netopeer2-server
add_library(serverobj OBJECT ${SERVER_SRC})
add_dependencies(serverobj udp-notif-c-collector)
if(UDP_NOTIF_BIN)
add_dependencies(serverobj udp-notif-c-collector)
endif()
add_executable(netopeer2-server $<TARGET_OBJECTS:serverobj> src/main.c ${compatsrc})

#
Expand All @@ -286,7 +294,9 @@ set_target_properties(netopeer2-server PROPERTIES IMPORTED_LOCATION ${UDP_NOTIF_
set_target_properties(netopeer2-server PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${UDP_NOTIF_INCLUDES})
target_link_libraries(netopeer2-server ${UDP_NOTIF_STATIC_LIB})
include_directories(${UDP_NOTIF_INCLUDES})
add_dependencies(netopeer2-server udp-notif-c-collector)
if(UDP_NOTIF_BIN)
add_dependencies(netopeer2-server udp-notif-c-collector)
endif()

# libssh (was already found, if exists)
if(LIBSSH_FOUND AND LIBNETCONF2_ENABLED_SSH)
Expand Down
15 changes: 12 additions & 3 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -860,15 +860,24 @@ server_data_subscribe(void)
SR_CONFIG_SUBSCR(mod_name, "/ietf-subscribed-notifications:subscriptions/receiver-instances/receiver-instance",
np2srv_config_receivers_cb);

SR_CONFIG_SUBSCR(mod_name, "/ietf-subscribed-notifications:subscriptions/subscription",
np2srv_config_subscriptions_cb);
rc = sr_module_change_subscribe(np2srv.sr_sess, mod_name, "/ietf-subscribed-notifications:subscriptions/subscription",
np2srv_config_subscriptions_cb, NULL, 0, SR_SUBSCR_ENABLED, &np2srv.sr_data_sub);
if (rc != SR_ERR_OK) {
ERR("Subscribing for \"%s\" data changes failed (%s).", mod_name, sr_strerror(rc));
goto error;
}

SR_CONFIG_SUBSCR(mod_name, "/ietf-subscribed-notifications:subscriptions/subscription/receivers/receiver",
np2srv_config_subscriptions_receivers_cb);

/* operational data */
SR_OPER_SUBSCR(mod_name, "/ietf-subscribed-notifications:streams", np2srv_oper_sub_ntf_streams_cb);
SR_OPER_SUBSCR(mod_name, "/ietf-subscribed-notifications:subscriptions", np2srv_oper_sub_ntf_subscriptions_cb);
rc = sr_oper_get_subscribe(np2srv.sr_sess, mod_name, "/ietf-subscribed-notifications:subscriptions",
np2srv_oper_sub_ntf_subscriptions_cb, NULL, SR_SUBSCR_OPER_MERGE, &np2srv.sr_data_sub);
if (rc != SR_ERR_OK) {
ERR("Subscribing for providing \"%s\" state data failed (%s).", mod_name, sr_strerror(rc));
goto error;
}

/*
* ietf-netconf-server
Expand Down
Loading