Skip to content

Commit 4c353b1

Browse files
committed
cmake UPDATE libyang updates
1 parent 4868c5d commit 4c353b1

8 files changed

Lines changed: 23 additions & 42 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ endif()
4444
set(NP2SRV_VERSION 2.7.7)
4545

4646
# libyang required version
47-
set(LIBYANG_DEP_VERSION 5.0.0)
48-
set(LIBYANG_DEP_SOVERSION 5.0.0)
47+
set(LIBYANG_DEP_VERSION 5.1.0)
48+
set(LIBYANG_DEP_SOVERSION 5.1.0)
4949
set(LIBYANG_DEP_SOVERSION_MAJOR 5)
5050

5151
# libnetconf2 required version

cli/commands.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -359,21 +359,12 @@ cli_send_recv(struct nc_rpc *rpc, FILE *output, NC_WD_MODE wd_mode, int timeout_
359359
fprintf(output, "MODULE\n");
360360
}
361361
any = (struct lyd_node_any *)lyd_child(op);
362-
switch (any->value_type) {
363-
case LYD_ANYDATA_STRING:
364-
case LYD_ANYDATA_XML:
362+
if (any->value) {
365363
fputs(any->value, output);
366-
break;
367-
case LYD_ANYDATA_DATATREE:
364+
} else {
368365
lyd_print_mem(&model_data, any->child, LYD_XML, LYD_PRINT_SIBLINGS);
369366
fputs(model_data, output);
370367
free(model_data);
371-
break;
372-
default:
373-
/* none of the others can appear here */
374-
ERROR(__func__, "Unexpected anydata value format.");
375-
ret = -1;
376-
goto cleanup;
377368
}
378369

379370
if (output == stdout) {

src/common.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ np_send_notif_rpc(sr_session_ctx_t *sr_session, enum np_rpc_exec_stage stage, co
651651

652652
/* filter */
653653
if (filter_subtree) {
654-
if (lyd_new_any(notif, NULL, "subtree-filter", filter_subtree, LYD_ANYDATA_DATATREE, 0, NULL)) {
654+
if (lyd_new_any(notif, NULL, "subtree-filter", filter_subtree, NULL, 0, NULL)) {
655655
rc = -1;
656656
goto cleanup;
657657
}
@@ -1113,15 +1113,12 @@ np_op_parse_config(struct lyd_node_any *node, uint32_t parse_options, struct lyd
11131113
ly_ctx = LYD_CTX(node);
11141114

11151115
/* get/parse the data */
1116-
switch (node->value_type) {
1117-
case LYD_ANYDATA_STRING:
1118-
case LYD_ANYDATA_XML:
1116+
if (node->value) {
11191117
if (lyd_parse_data_mem(ly_ctx, node->value, LYD_XML, parse_options, 0, config)) {
11201118
reply = np_reply_err_op_failed(NULL, ly_ctx, ly_last_logmsg());
11211119
goto cleanup;
11221120
}
1123-
break;
1124-
case LYD_ANYDATA_DATATREE:
1121+
} else {
11251122
if (lyd_dup_siblings(node->child, NULL, LYD_DUP_RECURSIVE, config)) {
11261123
reply = np_reply_err_op_failed(NULL, ly_ctx, ly_last_logmsg());
11271124
goto cleanup;
@@ -1133,11 +1130,6 @@ np_op_parse_config(struct lyd_node_any *node, uint32_t parse_options, struct lyd
11331130
goto cleanup;
11341131
}
11351132
}
1136-
break;
1137-
case LYD_ANYDATA_JSON:
1138-
EINT;
1139-
reply = np_reply_err_op_failed(NULL, ly_ctx, "Internal error.");
1140-
goto cleanup;
11411133
}
11421134

11431135
if (*config) {

src/main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ np_rpc_get_filter(const struct lyd_node *rpc, const struct lyd_node **filter_sub
226226

227227
if (!meta) {
228228
/* subtree */
229-
assert(((struct lyd_node_any *)node)->value_type == LYD_ANYDATA_DATATREE);
230229
*filter_subtree = ((struct lyd_node_any *)node)->child;
231230
} else {
232231
/* xpath */
@@ -962,7 +961,7 @@ server_destroy(void)
962961
/* remove all CH clients so they do not reconnect */
963962
ly_ctx = sr_acquire_context(np2srv.sr_conn);
964963
ly_temp_log_options(&temp_lo);
965-
if (!lyd_new_path2(NULL, ly_ctx, "/ietf-netconf-server:netconf-server/call-home", NULL, 0, 0, 0, &data, &node)) {
964+
if (!lyd_new_path2(NULL, ly_ctx, "/ietf-netconf-server:netconf-server/call-home", NULL, 0, 0, &data, &node)) {
966965
lyd_new_meta(ly_ctx, data, NULL, "yang:operation", "none", 0, NULL);
967966
lyd_new_meta(ly_ctx, node, NULL, "yang:operation", "delete", 0, NULL);
968967
nc_server_config_setup_diff(data);

src/netconf.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -155,14 +155,12 @@ np2srv_rpc_get_cb(const struct lyd_node *rpc, struct np_user_sess *user_sess)
155155

156156
if (!meta) {
157157
/* subtree */
158-
if (((struct lyd_node_any *)node)->value_type == LYD_ANYDATA_DATATREE) {
159-
if (((struct lyd_node_any *)node)->child) {
160-
if (srsn_filter_subtree2xpath(((struct lyd_node_any *)node)->child, user_sess->sess, &xp_filter)) {
161-
reply = np_reply_err_sr(user_sess->sess, LYD_NAME(rpc));
162-
goto cleanup;
163-
}
158+
if (((struct lyd_node_any *)node)->child) {
159+
if (srsn_filter_subtree2xpath(((struct lyd_node_any *)node)->child, user_sess->sess, &xp_filter)) {
160+
reply = np_reply_err_sr(user_sess->sess, LYD_NAME(rpc));
161+
goto cleanup;
164162
}
165-
} else {
163+
} else if (((struct lyd_node_any *)node)->value) {
166164
ERR("Invalid subtree filter:\n %s", ((struct lyd_node_any *)node)->value);
167165
goto cleanup;
168166
}
@@ -197,7 +195,7 @@ np2srv_rpc_get_cb(const struct lyd_node *rpc, struct np_user_sess *user_sess)
197195
reply = np_reply_err_op_failed(NULL, LYD_CTX(rpc), ly_last_logmsg());
198196
goto cleanup;
199197
}
200-
if (lyd_new_any(output, NULL, "data", data_get, LYD_ANYDATA_DATATREE, LYD_NEW_ANY_USE_VALUE | LYD_NEW_VAL_OUTPUT, NULL)) {
198+
if (lyd_new_any(output, NULL, "data", data_get, NULL, LYD_NEW_ANY_USE_VALUE | LYD_NEW_VAL_OUTPUT, NULL)) {
201199
reply = np_reply_err_op_failed(NULL, LYD_CTX(rpc), ly_last_logmsg());
202200
goto cleanup;
203201
}
@@ -835,7 +833,7 @@ np2srv_rpc_subscribe_cb(const struct lyd_node *rpc, struct np_user_sess *user_se
835833

836834
if (!meta) {
837835
/* subtree */
838-
if (((struct lyd_node_any *)node)->value_type == LYD_ANYDATA_DATATREE) {
836+
if (((struct lyd_node_any *)node)->child) {
839837
if (srsn_filter_subtree2xpath(((struct lyd_node_any *)node)->child, user_sess->sess, &xp_filter)) {
840838
reply = np_reply_err_sr(user_sess->sess, LYD_NAME(rpc));
841839
goto cleanup;

src/netconf_monitoring.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ np2srv_rpc_getschema_cb(const struct lyd_node *rpc, struct np_user_sess *UNUSED(
499499
reply = np_reply_err_op_failed(NULL, LYD_CTX(rpc), ly_last_logmsg());
500500
goto cleanup;
501501
}
502-
if (lyd_new_any(output, NULL, "data", model_data, LYD_ANYDATA_STRING, LYD_NEW_ANY_USE_VALUE | LYD_NEW_VAL_OUTPUT, NULL)) {
502+
if (lyd_new_any(output, NULL, "data", NULL, model_data, LYD_NEW_ANY_USE_VALUE | LYD_NEW_VAL_OUTPUT, NULL)) {
503503
reply = np_reply_err_op_failed(NULL, LYD_CTX(rpc), ly_last_logmsg());
504504
goto cleanup;
505505
}

src/netconf_nmda.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ np2srv_rpc_getdata_cb(const struct lyd_node *rpc, struct np_user_sess *user_sess
203203
reply = np_reply_err_op_failed(NULL, LYD_CTX(rpc), ly_last_logmsg());
204204
goto cleanup;
205205
}
206-
if (lyd_new_any(output, NULL, "data", data, LYD_ANYDATA_DATATREE, LYD_NEW_ANY_USE_VALUE | LYD_NEW_VAL_OUTPUT, NULL)) {
206+
if (lyd_new_any(output, NULL, "data", data, NULL, LYD_NEW_ANY_USE_VALUE | LYD_NEW_VAL_OUTPUT, NULL)) {
207207
reply = np_reply_err_op_failed(NULL, LYD_CTX(rpc), ly_last_logmsg());
208208
goto cleanup;
209209
}

src/netconf_subscribed_notifications.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ sub_ntf_filter2xpath(sr_session_ctx_t *session, const char *filter_name_search_f
445445

446446
if (subtree_filter) {
447447
/* subtree */
448-
if (((struct lyd_node_any *)subtree_filter)->value_type == LYD_ANYDATA_DATATREE) {
448+
if (((struct lyd_node_any *)subtree_filter)->child) {
449449
if (srsn_filter_subtree2xpath(((struct lyd_node_any *)subtree_filter)->child, session, xpath)) {
450450
if (err_reply) {
451451
*err_reply = np_reply_err_sr(session, "get");
@@ -752,6 +752,7 @@ sub_ntf_append_params_filter(struct lyd_node *parent, const struct np2srv_sub_nt
752752
{
753753
int rc = 0;
754754
struct lyd_node_any *any;
755+
struct lyd_node *node;
755756
const struct lys_module *yp_mod;
756757

757758
yp_mod = ly_ctx_get_module_implemented(LYD_CTX(parent), "ietf-yang-push");
@@ -766,11 +767,11 @@ sub_ntf_append_params_filter(struct lyd_node *parent, const struct np2srv_sub_nt
766767
} else if (sub->subtree_filter) {
767768
/* stream-subtree-filter */
768769
any = (struct lyd_node_any *)sub->subtree_filter;
769-
if (lyd_new_any(parent, NULL, "stream-subtree-filter", any->child ? any->child : (void *)any->value,
770-
any->value_type, 0, NULL)) {
770+
if (lyd_new_any(parent, NULL, "stream-subtree-filter", any->child, any->value, 0, &node)) {
771771
rc = -1;
772772
goto cleanup;
773773
}
774+
((struct lyd_node_any *)node)->hints = any->hints;
774775
} else if (sub->xpath_filter) {
775776
/* stream-xpath-filter */
776777
if (lyd_new_term(parent, NULL, "stream-xpath-filter", sub->xpath_filter, 0, NULL)) {
@@ -788,11 +789,11 @@ sub_ntf_append_params_filter(struct lyd_node *parent, const struct np2srv_sub_nt
788789
} else if (sub->subtree_filter) {
789790
/* datastore-subtree-filter */
790791
any = (struct lyd_node_any *)sub->subtree_filter;
791-
if (lyd_new_any(parent, yp_mod, "datastore-subtree-filter", any->child ? any->child : (void *)any->value,
792-
any->value_type, 0, NULL)) {
792+
if (lyd_new_any(parent, yp_mod, "datastore-subtree-filter", any->child, any->value, 0, &node)) {
793793
rc = -1;
794794
goto cleanup;
795795
}
796+
((struct lyd_node_any *)node)->hints = any->hints;
796797
} else if (sub->xpath_filter) {
797798
/* datastore-xpath-filter */
798799
if (lyd_new_term(parent, yp_mod, "datastore-xpath-filter", sub->xpath_filter, 0, NULL)) {

0 commit comments

Comments
 (0)