if (CHECK_FLAG(snode->nodetype, LYS_CONTAINER | LYS_LIST)) {
bool config_only = true;
- yang_snodes_iterate_subtree(snode, nb_node_check_config_only,
- YANG_ITER_ALLOW_AUGMENTATIONS,
+ yang_snodes_iterate_subtree(snode, NULL,
+ nb_node_check_config_only, 0,
&config_only);
if (config_only)
SET_FLAG(nb_node->flags, F_NB_NODE_CONFIG_ONLY);
* another.
*/
nb_node->snode = snode;
+ assert(snode->priv == NULL);
lys_set_private(snode, nb_node);
return YANG_ITER_CONTINUE;
}
int yang_snodes_iterate_subtree(const struct lys_node *snode,
+ const struct lys_module *module,
yang_iterate_cb cb, uint16_t flags, void *arg)
{
struct lys_node *child;
int ret = YANG_ITER_CONTINUE;
+ if (module && snode->module != module)
+ goto next;
+
if (CHECK_FLAG(flags, YANG_ITER_FILTER_IMPLICIT)) {
switch (snode->nodetype) {
case LYS_CASE:
return YANG_ITER_CONTINUE;
LY_TREE_FOR (snode->child, child) {
- if (!CHECK_FLAG(flags, YANG_ITER_ALLOW_AUGMENTATIONS)
- && child->parent != snode)
- continue;
-
- ret = yang_snodes_iterate_subtree(child, cb, flags, arg);
+ ret = yang_snodes_iterate_subtree(child, module, cb, flags,
+ arg);
if (ret == YANG_ITER_STOP)
return ret;
}
int ret = YANG_ITER_CONTINUE;
LY_TREE_FOR (module->data, snode) {
- ret = yang_snodes_iterate_subtree(snode, cb, flags, arg);
+ ret = yang_snodes_iterate_subtree(snode, module, cb, flags,
+ arg);
if (ret == YANG_ITER_STOP)
return ret;
}
for (uint8_t i = 0; i < module->augment_size; i++) {
ret = yang_snodes_iterate_subtree(
- (const struct lys_node *)&module->augment[i], cb, flags,
- arg);
+ (const struct lys_node *)&module->augment[i], module,
+ cb, flags, arg);
if (ret == YANG_ITER_STOP)
return ret;
}
int ret = YANG_ITER_CONTINUE;
RB_FOREACH (module, yang_modules, &yang_modules) {
- ret = yang_snodes_iterate_module(module->info, cb, flags, arg);
- if (ret == YANG_ITER_STOP)
- return ret;
+ struct lys_node *snode;
+
+ LY_TREE_FOR (module->info->data, snode) {
+ ret = yang_snodes_iterate_subtree(snode, NULL, cb,
+ flags, arg);
+ if (ret == YANG_ITER_STOP)
+ return ret;
+ }
}
return ret;
/* Filter implicitely created nodes. */
YANG_ITER_FILTER_IMPLICIT = (1<<3),
-
- /* Allow iteration over augmentations. */
- YANG_ITER_ALLOW_AUGMENTATIONS = (1<<4),
};
/* Callback used by the yang_snodes_iterate_*() family of functions. */
* snode
* YANG schema node to operate on.
*
+ * module
+ * When set, iterate over all nodes of the specified module only.
+ *
* cb
* Function to call with each schema node.
*
* The return value of the last called callback.
*/
extern int yang_snodes_iterate_subtree(const struct lys_node *snode,
+ const struct lys_module *module,
yang_iterate_cb cb, uint16_t flags,
void *arg);