From 70520f54d65186fbbc11c53578c2c5eb12e7a31e Mon Sep 17 00:00:00 2001 From: roman Date: Tue, 23 Jan 2024 12:21:55 +0100 Subject: [PATCH 1/2] main UPDATE add ssh algs oper data cb --- CMakeLists.txt | 4 ++-- src/main.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 82c0b902..bf99f0bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,8 +54,8 @@ set(LIBYANG_DEP_SOVERSION 2.46.1) set(LIBYANG_DEP_SOVERSION_MAJOR 2) # libnetconf2 required version -set(LIBNETCONF2_DEP_VERSION 3.0.8) -set(LIBNETCONF2_DEP_SOVERSION 4.1.5) +set(LIBNETCONF2_DEP_VERSION 3.0.10) +set(LIBNETCONF2_DEP_SOVERSION 4.1.7) set(LIBNETCONF2_DEP_SOVERSION_MAJOR 4) # sysrepo required version diff --git a/src/main.c b/src/main.c index 781533ff..9acff862 100644 --- a/src/main.c +++ b/src/main.c @@ -16,6 +16,7 @@ #define _GNU_SOURCE +#include #include #include #include @@ -769,6 +770,49 @@ np2srv_libnetconf2_config_cb(sr_session_ctx_t *session, uint32_t UNUSED(sub_id), return SR_ERR_OK; } +#ifdef NC_ENABLED_SSH_TLS + +static int +np2srv_ssh_algs_oper_cb(sr_session_ctx_t *session, uint32_t UNUSED(sub_id), const char *module_name, + const char *path, const char *UNUSED(request_xpath), uint32_t UNUSED(request_id), + struct lyd_node **parent, void *UNUSED(private_data)) +{ + int ret = 0; + const struct ly_ctx *ly_ctx; + + (void) path; + + /* context is locked by the callback anyway */ + ly_ctx = sr_session_acquire_context(session); + sr_session_release_context(session); + + /* get oper data based on the module */ + if (!strcmp(module_name, "iana-ssh-public-key-algs")) { + assert(!strcmp(path, "/iana-ssh-public-key-algs:supported-algorithms")); + ret = nc_server_config_oper_get_hostkey_algs(ly_ctx, parent); + } else if (!strcmp(module_name, "iana-ssh-key-exchange-algs")) { + assert(!strcmp(path, "/iana-ssh-key-exchange-algs:supported-algorithms")); + ret = nc_server_config_oper_get_kex_algs(ly_ctx, parent); + } else if (!strcmp(module_name, "iana-ssh-encryption-algs")) { + assert(!strcmp(path, "/iana-ssh-encryption-algs:supported-algorithms")); + ret = nc_server_config_oper_get_encryption_algs(ly_ctx, parent); + } else if (!strcmp(module_name, "iana-ssh-mac-algs")) { + assert(!strcmp(path, "/iana-ssh-mac-algs:supported-algorithms")); + ret = nc_server_config_oper_get_mac_algs(ly_ctx, parent); + } else { + ERR("Unable to get supported SSH algorithms (module %s not supported).", module_name); + return SR_ERR_INTERNAL; + } + if (ret) { + ERR("Getting supported SSH algorithms failed."); + return SR_ERR_INTERNAL; + } + + return SR_ERR_OK; +} + +#endif /* NC_ENABLED_SSH_TLS */ + /** * @brief Subscribe to all the handled RPCs of the server. * @@ -876,6 +920,21 @@ server_data_subscribe(void) mod_name = "nc-notifications"; SR_OPER_SUBSCR(mod_name, "/nc-notifications:netconf", np2srv_nc_ntf_oper_cb); +#ifdef NC_ENABLED_SSH_TLS + /* set callbacks for supported algorithms oper data */ + mod_name = "iana-ssh-public-key-algs"; + SR_OPER_SUBSCR(mod_name, "/iana-ssh-public-key-algs:supported-algorithms", np2srv_ssh_algs_oper_cb); + + mod_name = "iana-ssh-key-exchange-algs"; + SR_OPER_SUBSCR(mod_name, "/iana-ssh-key-exchange-algs:supported-algorithms", np2srv_ssh_algs_oper_cb); + + mod_name = "iana-ssh-encryption-algs"; + SR_OPER_SUBSCR(mod_name, "/iana-ssh-encryption-algs:supported-algorithms", np2srv_ssh_algs_oper_cb); + + mod_name = "iana-ssh-mac-algs"; + SR_OPER_SUBSCR(mod_name, "/iana-ssh-mac-algs:supported-algorithms", np2srv_ssh_algs_oper_cb); +#endif /* NC_ENABLED_SSH_TLS */ + /* * ietf-subscribed-notifications */ From 80738428d81658ef20cde85de22d2d2c734ca293 Mon Sep 17 00:00:00 2001 From: roman Date: Tue, 23 Jan 2024 12:22:36 +0100 Subject: [PATCH 2/2] VERSION bump to version 2.2.14 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bf99f0bd..80124b87 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,7 +46,7 @@ endif() # Generic version of not only the library. Major version is reserved for really big changes of the project, # minor version changes with added functionality (new tool, functionality of the tool or library, ...) and # micro version is changed with a set of small changes or bugfixes anywhere in the project. -set(NP2SRV_VERSION 2.2.13) +set(NP2SRV_VERSION 2.2.14) # libyang required version set(LIBYANG_DEP_VERSION 2.1.146)