@@ -1920,7 +1920,8 @@ lyd_new_ext_path(struct lyd_node *parent, const struct lysc_ext_instance *ext, c
19201920LY_ERR
19211921lyd_new_implicit (struct lyd_node * parent , struct lyd_node * * first , const struct lysc_node * sparent ,
19221922 const struct lys_module * mod , const struct lysc_ext_instance * top_ext , struct ly_set * node_when ,
1923- struct ly_set * node_types , uint32_t impl_opts , struct ly_ht * getnext_ht , struct lyd_node * * diff )
1923+ struct ly_set * node_types , struct ly_set * ext_val , uint32_t impl_opts , struct ly_ht * getnext_ht ,
1924+ struct lyd_node * * diff )
19241925{
19251926 const struct lysc_node * snode , * * choices , * * snodes ;
19261927 struct lyd_node * node = NULL ;
@@ -1954,12 +1955,12 @@ lyd_new_implicit(struct lyd_node *parent, struct lyd_node **first, const struct
19541955 if (!node && ((struct lysc_node_choice * )snode )-> dflt ) {
19551956 /* create default case data */
19561957 LY_CHECK_RET (lyd_new_implicit (parent , first , & ((struct lysc_node_choice * )snode )-> dflt -> node ,
1957- NULL , top_ext , node_when , node_types , impl_opts , getnext_ht , diff ));
1958+ NULL , top_ext , node_when , node_types , ext_val , impl_opts , getnext_ht , diff ));
19581959 } else if (node ) {
19591960 /* create any default data in the existing case */
19601961 assert (node -> schema -> parent -> nodetype == LYS_CASE );
19611962 LY_CHECK_RET (lyd_new_implicit (parent , first , node -> schema -> parent , NULL , top_ext , node_when , node_types ,
1962- impl_opts , getnext_ht , diff ));
1963+ ext_val , impl_opts , getnext_ht , diff ));
19631964 }
19641965 }
19651966
@@ -1987,6 +1988,10 @@ lyd_new_implicit(struct lyd_node *parent, struct lyd_node **first, const struct
19871988 /* remember to resolve when */
19881989 LY_CHECK_RET (ly_set_add (node_when , node , 1 , NULL ));
19891990 }
1991+ if (ext_val ) {
1992+ /* store for ext instance node validation, if needed */
1993+ LY_CHECK_RET (lyd_validate_node_ext (node , ext_val ));
1994+ }
19901995 if (diff ) {
19911996 /* add into diff */
19921997 LY_CHECK_RET (lyd_val_diff_add (node , LYD_DIFF_OP_CREATE , diff ));
@@ -2011,6 +2016,10 @@ lyd_new_implicit(struct lyd_node *parent, struct lyd_node **first, const struct
20112016 /* remember to resolve when */
20122017 LY_CHECK_RET (ly_set_add (node_when , node , 1 , NULL ));
20132018 }
2019+ if (ext_val ) {
2020+ /* store for ext instance node validation, if needed */
2021+ LY_CHECK_RET (lyd_validate_node_ext (node , ext_val ));
2022+ }
20142023 if (diff ) {
20152024 /* add into diff */
20162025 LY_CHECK_RET (lyd_val_diff_add (node , LYD_DIFF_OP_CREATE , diff ));
@@ -2036,6 +2045,10 @@ lyd_new_implicit(struct lyd_node *parent, struct lyd_node **first, const struct
20362045 /* remember to resolve when */
20372046 LY_CHECK_RET (ly_set_add (node_when , node , 1 , NULL ));
20382047 }
2048+ if (ext_val ) {
2049+ /* store for ext instance node validation, if needed */
2050+ LY_CHECK_RET (lyd_validate_node_ext (node , ext_val ));
2051+ }
20392052 if (diff ) {
20402053 /* add into diff */
20412054 LY_CHECK_RET (lyd_val_diff_add (node , LYD_DIFF_OP_CREATE , diff ));
@@ -2055,18 +2068,20 @@ lyd_new_implicit(struct lyd_node *parent, struct lyd_node **first, const struct
20552068LY_ERR
20562069lyd_new_implicit_r (struct lyd_node * parent , struct lyd_node * * first , const struct lysc_node * sparent ,
20572070 const struct lys_module * mod , const struct lysc_ext_instance * top_ext , struct ly_set * node_when ,
2058- struct ly_set * node_types , uint32_t impl_opts , struct ly_ht * getnext_ht , struct lyd_node * * diff )
2071+ struct ly_set * node_types , struct ly_set * ext_val , uint32_t impl_opts , struct ly_ht * getnext_ht ,
2072+ struct lyd_node * * diff )
20592073{
20602074 struct lyd_node * child ;
20612075
20622076 /* parent children */
2063- LY_CHECK_RET (lyd_new_implicit (parent , first , sparent , mod , top_ext , node_when , node_types , impl_opts , getnext_ht , diff ));
2077+ LY_CHECK_RET (lyd_new_implicit (parent , first , sparent , mod , top_ext , node_when , node_types , ext_val , impl_opts ,
2078+ getnext_ht , diff ));
20642079
20652080 LY_LIST_FOR (parent ? lyd_child_no_keys (parent ) : * first , child ) {
20662081 /* recursively for all the containers */
20672082 if ((child -> flags & LYD_DEFAULT ) && (child -> schema -> nodetype == LYS_CONTAINER )) {
20682083 LY_CHECK_RET (lyd_new_implicit_r (child , lyd_node_child_p (child ), NULL , mod , top_ext , node_when , node_types ,
2069- impl_opts , getnext_ht , diff ));
2084+ ext_val , impl_opts , getnext_ht , diff ));
20702085 }
20712086 }
20722087
@@ -2091,7 +2106,7 @@ lyd_new_implicit_tree(struct lyd_node *tree, uint32_t implicit_options, struct l
20912106
20922107 LYD_TREE_DFS_BEGIN (tree , node ) {
20932108 if (node -> schema && (node -> schema -> nodetype & LYD_NODE_INNER )) {
2094- LY_CHECK_GOTO (rc = lyd_new_implicit (node , lyd_node_child_p (node ), NULL , NULL , NULL , & node_when , NULL ,
2109+ LY_CHECK_GOTO (rc = lyd_new_implicit (node , lyd_node_child_p (node ), NULL , NULL , NULL , & node_when , NULL , NULL ,
20952110 implicit_options , getnext_ht , diff ), cleanup );
20962111 }
20972112
@@ -2171,7 +2186,7 @@ lyd_new_implicit_module(struct lyd_node **tree, const struct lys_module *module,
21712186 LY_CHECK_GOTO (rc = lyd_val_getnext_ht_new (& getnext_ht ), cleanup );
21722187
21732188 /* add all top-level defaults for this module */
2174- rc = lyd_new_implicit (NULL , tree , NULL , module , NULL , & node_when , NULL , implicit_options , getnext_ht , diff );
2189+ rc = lyd_new_implicit (NULL , tree , NULL , module , NULL , & node_when , NULL , NULL , implicit_options , getnext_ht , diff );
21752190 LY_CHECK_GOTO (rc , cleanup );
21762191
21772192 /* resolve when and remove any invalid defaults */
0 commit comments