Skip to content

Commit

Permalink
session client BUGFIX remove notifications expectation
Browse files Browse the repository at this point in the history
If NETCONF server supports RFC5277 notification capability and
libnetconf2 required notifications and nc-notifications are not present
on the NETCONF server (which it is not obligated to support), then the
libyang context needs to be initialized using client side local YANG
schema files.

This change assumes that notifications and nc-notifications models are
present in searchpath directory set via nc_client_set_schema_searchpath
or in the default YANG_MODULE_DIR set via build time configuration.

Signed-off-by: Siddharth Sharma <[email protected]>
  • Loading branch information
esmasth authored and michalvasko committed Jul 26, 2024
1 parent ddb60ab commit 01614f3
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/session_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,8 @@ build_module_info_yl(struct nc_session *session, int get_data_sup, int xpath_sup
struct lyd_node *iter, *child, *oper_data = NULL;
struct lys_module *mod;
int ret = 0;
uint8_t notifications_found = 0;
uint8_t nc_notifications_found = 0;

/* get yang-library operational data */
if (xpath_sup) {
Expand Down Expand Up @@ -952,6 +954,11 @@ build_module_info_yl(struct nc_session *session, int get_data_sup, int xpath_sup
}
if (!strcmp(iter->schema->name, "name")) {
(*result)[u].name = strdup(lyd_get_value(iter));
if (!strcmp((*result)[u].name, "notifications")) {
notifications_found = 1;
} else if (!strcmp((*result)[u].name, "nc-notifications")) {
nc_notifications_found = 1;
}
} else if (!strcmp(iter->schema->name, "revision")) {
(*result)[u].revision = strdup(lyd_get_value(iter));
} else if (!strcmp(iter->schema->name, "conformance-type")) {
Expand Down Expand Up @@ -988,6 +995,26 @@ build_module_info_yl(struct nc_session *session, int get_data_sup, int xpath_sup
}
}

/* If NETCONF server supports RFC5277 notification capability and libnetconf2
* required notifications and nc-notifications are not present on the NETCONF
* server (which it is not obligated to support), then the libyang context
* needs to be initialized using client side local YANG schema files */
if (nc_session_cpblt(session, "urn:ietf:params:netconf:capability:notification:1.0") &&
!notifications_found && !nc_notifications_found) {

(*result) = nc_realloc(*result, (modules->count + 3) * sizeof **result);
NC_CHECK_ERRMEM_GOTO(!(*result), ret = -1, cleanup);

(*result)[u].name = strdup("notifications");
(*result)[u].revision = strdup("2008-07-14");
(*result)[u].implemented = 1;
u++;

(*result)[u].name = strdup("nc-notifications");
(*result)[u].revision = strdup("2008-07-14");
(*result)[u].implemented = 1;
}

cleanup:
lyd_free_siblings(oper_data);
ly_set_free(modules, NULL);
Expand Down

0 comments on commit 01614f3

Please sign in to comment.