error += nb_node_validate_cb(nb_node, NB_CB_APPLY_FINISH,
!!nb_node->cbs.apply_finish, true);
error += nb_node_validate_cb(nb_node, NB_CB_GET_ELEM,
- !!nb_node->cbs.get_elem, false);
+ (nb_node->cbs.get_elem || nb_node->cbs.get), false);
error += nb_node_validate_cb(nb_node, NB_CB_GET_NEXT,
- !!nb_node->cbs.get_next, false);
+ (nb_node->cbs.get_next ||
+ (nb_node->snode->nodetype == LYS_LEAFLIST && nb_node->cbs.get)),
+ false);
error += nb_node_validate_cb(nb_node, NB_CB_GET_KEYS,
!!nb_node->cbs.get_keys, false);
error += nb_node_validate_cb(nb_node, NB_CB_LOOKUP_ENTRY,
/* Forward declaration(s). */
struct vty;
struct debug;
+struct nb_node;
struct nb_yang_xpath_tag {
uint32_t ns;
NB_CB_NOTIFY,
};
+/* Northbound error codes. */
+enum nb_error {
+ NB_OK = 0,
+ NB_ERR,
+ NB_ERR_NO_CHANGES,
+ NB_ERR_NOT_FOUND,
+ NB_ERR_EXISTS,
+ NB_ERR_LOCKED,
+ NB_ERR_VALIDATION,
+ NB_ERR_RESOURCE,
+ NB_ERR_INCONSISTENCY,
+ NB_YIELD,
+};
+
union nb_resource {
int fd;
void *ptr;
*/
void (*apply_finish)(struct nb_cb_apply_finish_args *args);
+ /*
+ * Operational data callback (new direct tree add method).
+ *
+ * The callback function should create a new lyd_node (leaf) or
+ * lyd_node's (leaf list) for the value and attach to parent.
+ *
+ * nb_node
+ * The node representing the leaf or leaf list
+ * list_entry
+ * List entry from get_next (or NULL).
+ * parent
+ * The parent lyd_node to attach the leaf data to.
+ *
+ * Returns:
+ * Returns an nb_error if the data could not be added to the tree.
+ */
+ enum nb_error (*get)(const struct nb_node *nb_node, const void *list_entry,
+ struct lyd_node *parent);
+
/*
* Operational data callback.
*
#endif
};
-/* Northbound error codes. */
-enum nb_error {
- NB_OK = 0,
- NB_ERR,
- NB_ERR_NO_CHANGES,
- NB_ERR_NOT_FOUND,
- NB_ERR_EXISTS,
- NB_ERR_LOCKED,
- NB_ERR_VALIDATION,
- NB_ERR_RESOURCE,
- NB_ERR_INCONSISTENCY,
- NB_YIELD,
-};
-
/* Default priority. */
#define NB_DFLT_PRIORITY (UINT32_MAX / 2)
extern struct nb_config *running_config;
/* Wrappers for the northbound callbacks. */
-extern struct yang_data *nb_callback_get_elem(const struct nb_node *nb_node,
- const char *xpath,
+extern struct yang_data *nb_callback_has_new_get_elem(const struct nb_node *nb_node);
+
+extern struct yang_data *nb_callback_get_elem(const struct nb_node *nb_node, const char *xpath,
const void *list_entry);
extern const void *nb_callback_get_next(const struct nb_node *nb_node,
const void *parent_list_entry,
if (lysc_is_key(snode))
return NB_OK;
+ /* Check for new simple get */
+ if (nb_node->cbs.get)
+ return nb_node->cbs.get(nb_node, ni->list_entry, ni->inner);
+
data = nb_callback_get_elem(nb_node, xpath, ni->list_entry);
if (data == NULL)
return NB_OK;
if (CHECK_FLAG(snode->flags, LYS_CONFIG_W))
return NB_OK;
+ /* Check for new simple get */
+ if (nb_node->cbs.get)
+ return nb_node->cbs.get(nb_node, ni->list_entry, ni->inner);
+
do {
struct yang_data *data;