2 * Copyright (C) 2018 NetDEF, Inc.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the Free
7 * Software Foundation; either version 2 of the License, or (at your option)
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * You should have received a copy of the GNU General Public License along
16 * with this program; see the file COPYING; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #ifndef _FRR_NORTHBOUND_H_
21 #define _FRR_NORTHBOUND_H_
26 #include "openbsd-tree.h"
28 #include "yang_translator.h"
34 /* Forward declaration(s). */
38 /* Northbound events. */
41 * The configuration callback is supposed to verify that the changes are
42 * valid and can be applied.
47 * The configuration callback is supposed to prepare all resources
48 * required to apply the changes.
53 * Transaction has failed, the configuration callback needs to release
54 * all resources previously allocated.
59 * The configuration changes need to be applied. The changes can't be
60 * rejected at this point (errors are logged and ignored).
66 * Northbound operations.
68 * Refer to the documentation comments of nb_callbacks for more details.
90 * Northbound callbacks parameters.
93 struct nb_cb_create_args
{
94 /* Context of the configuration transaction. */
95 struct nb_context
*context
;
98 * The transaction phase. Refer to the documentation comments of
99 * nb_event for more details.
103 /* libyang data node that is being created. */
104 const struct lyd_node
*dnode
;
107 * Pointer to store resource(s) allocated during the NB_EV_PREPARE
108 * phase. The same pointer can be used during the NB_EV_ABORT and
109 * NB_EV_APPLY phases to either release or make use of the allocated
110 * resource(s). It's set to NULL when the event is NB_EV_VALIDATE.
112 union nb_resource
*resource
;
114 /* Buffer to store human-readable error message in case of error. */
117 /* Size of errmsg. */
121 struct nb_cb_modify_args
{
122 /* Context of the configuration transaction. */
123 struct nb_context
*context
;
126 * The transaction phase. Refer to the documentation comments of
127 * nb_event for more details.
131 /* libyang data node that is being modified. */
132 const struct lyd_node
*dnode
;
135 * Pointer to store resource(s) allocated during the NB_EV_PREPARE
136 * phase. The same pointer can be used during the NB_EV_ABORT and
137 * NB_EV_APPLY phases to either release or make use of the allocated
138 * resource(s). It's set to NULL when the event is NB_EV_VALIDATE.
140 union nb_resource
*resource
;
142 /* Buffer to store human-readable error message in case of error. */
145 /* Size of errmsg. */
149 struct nb_cb_destroy_args
{
150 /* Context of the configuration transaction. */
151 struct nb_context
*context
;
154 * The transaction phase. Refer to the documentation comments of
155 * nb_event for more details.
159 /* libyang data node that is being deleted. */
160 const struct lyd_node
*dnode
;
162 /* Buffer to store human-readable error message in case of error. */
165 /* Size of errmsg. */
169 struct nb_cb_move_args
{
170 /* Context of the configuration transaction. */
171 struct nb_context
*context
;
174 * The transaction phase. Refer to the documentation comments of
175 * nb_event for more details.
179 /* libyang data node that is being moved. */
180 const struct lyd_node
*dnode
;
182 /* Buffer to store human-readable error message in case of error. */
185 /* Size of errmsg. */
189 struct nb_cb_pre_validate_args
{
190 /* Context of the configuration transaction. */
191 struct nb_context
*context
;
193 /* libyang data node associated with the 'pre_validate' callback. */
194 const struct lyd_node
*dnode
;
196 /* Buffer to store human-readable error message in case of error. */
199 /* Size of errmsg. */
203 struct nb_cb_apply_finish_args
{
204 /* Context of the configuration transaction. */
205 struct nb_context
*context
;
207 /* libyang data node associated with the 'apply_finish' callback. */
208 const struct lyd_node
*dnode
;
210 /* Buffer to store human-readable error message in case of error. */
213 /* Size of errmsg. */
217 struct nb_cb_get_elem_args
{
218 /* YANG data path of the data we want to get. */
221 /* Pointer to list entry (might be NULL). */
222 const void *list_entry
;
225 struct nb_cb_get_next_args
{
226 /* Pointer to parent list entry. */
227 const void *parent_list_entry
;
229 /* Pointer to (leaf-)list entry. */
230 const void *list_entry
;
233 struct nb_cb_get_keys_args
{
234 /* Pointer to list entry. */
235 const void *list_entry
;
238 * Structure to be filled based on the attributes of the provided list
241 struct yang_list_keys
*keys
;
244 struct nb_cb_lookup_entry_args
{
245 /* Pointer to parent list entry. */
246 const void *parent_list_entry
;
248 /* Structure containing the keys of the list entry. */
249 const struct yang_list_keys
*keys
;
252 struct nb_cb_rpc_args
{
253 /* XPath of the YANG RPC or action. */
256 /* Read-only list of input parameters. */
257 const struct list
*input
;
259 /* List of output parameters to be populated by the callback. */
264 * Set of configuration callbacks that can be associated to a northbound node.
266 struct nb_callbacks
{
268 * Configuration callback.
270 * A presence container, list entry, leaf-list entry or leaf of type
271 * empty has been created.
273 * For presence-containers and list entries, the callback is supposed to
274 * initialize the default values of its children (if any) from the YANG
278 * Refer to the documentation comments of nb_cb_create_args for
282 * - NB_OK on success.
283 * - NB_ERR_VALIDATION when a validation error occurred.
284 * - NB_ERR_RESOURCE when the callback failed to allocate a resource.
285 * - NB_ERR_INCONSISTENCY when an inconsistency was detected.
286 * - NB_ERR for other errors.
288 int (*create
)(struct nb_cb_create_args
*args
);
291 * Configuration callback.
293 * The value of a leaf has been modified.
295 * List keys don't need to implement this callback. When a list key is
296 * modified, the northbound treats this as if the list was deleted and a
297 * new one created with the updated key value.
300 * Refer to the documentation comments of nb_cb_modify_args for
304 * - NB_OK on success.
305 * - NB_ERR_VALIDATION when a validation error occurred.
306 * - NB_ERR_RESOURCE when the callback failed to allocate a resource.
307 * - NB_ERR_INCONSISTENCY when an inconsistency was detected.
308 * - NB_ERR for other errors.
310 int (*modify
)(struct nb_cb_modify_args
*args
);
313 * Configuration callback.
315 * A presence container, list entry, leaf-list entry or optional leaf
318 * The callback is supposed to delete the entire configuration object,
319 * including its children when they exist.
322 * Refer to the documentation comments of nb_cb_destroy_args for
326 * - NB_OK on success.
327 * - NB_ERR_VALIDATION when a validation error occurred.
328 * - NB_ERR_INCONSISTENCY when an inconsistency was detected.
329 * - NB_ERR for other errors.
331 int (*destroy
)(struct nb_cb_destroy_args
*args
);
334 * Configuration callback.
336 * A list entry or leaf-list entry has been moved. Only applicable when
337 * the "ordered-by user" statement is present.
340 * Refer to the documentation comments of nb_cb_move_args for
344 * - NB_OK on success.
345 * - NB_ERR_VALIDATION when a validation error occurred.
346 * - NB_ERR_INCONSISTENCY when an inconsistency was detected.
347 * - NB_ERR for other errors.
349 int (*move
)(struct nb_cb_move_args
*args
);
352 * Optional configuration callback.
354 * This callback can be used to validate subsections of the
355 * configuration being committed before validating the configuration
356 * changes themselves. It's useful to perform more complex validations
357 * that depend on the relationship between multiple nodes.
360 * Refer to the documentation comments of nb_cb_pre_validate_args for
364 * - NB_OK on success.
365 * - NB_ERR_VALIDATION when a validation error occurred.
367 int (*pre_validate
)(struct nb_cb_pre_validate_args
*args
);
370 * Optional configuration callback.
372 * The 'apply_finish' callbacks are called after all other callbacks
373 * during the apply phase (NB_EV_APPLY). These callbacks are called only
374 * under one of the following two cases:
375 * - The data node has been created or modified (but not deleted);
376 * - Any change was made within the descendants of the data node (e.g. a
377 * child leaf was modified, created or deleted).
379 * In the second case above, the 'apply_finish' callback is called only
380 * once even if multiple changes occurred within the descendants of the
384 * Refer to the documentation comments of nb_cb_apply_finish_args for
387 void (*apply_finish
)(struct nb_cb_apply_finish_args
*args
);
390 * Operational data callback.
392 * The callback function should return the value of a specific leaf,
393 * leaf-list entry or inform if a typeless value (presence containers or
394 * leafs of type empty) exists or not.
397 * Refer to the documentation comments of nb_cb_get_elem_args for
401 * Pointer to newly created yang_data structure, or NULL to indicate
402 * the absence of data.
404 struct yang_data
*(*get_elem
)(struct nb_cb_get_elem_args
*args
);
407 * Operational data callback for YANG lists and leaf-lists.
409 * The callback function should return the next entry in the list or
410 * leaf-list. The 'list_entry' parameter will be NULL on the first
414 * Refer to the documentation comments of nb_cb_get_next_args for
418 * Pointer to the next entry in the (leaf-)list, or NULL to signal
419 * that the end of the (leaf-)list was reached.
421 const void *(*get_next
)(struct nb_cb_get_next_args
*args
);
424 * Operational data callback for YANG lists.
426 * The callback function should fill the 'keys' parameter based on the
427 * given list_entry. Keyless lists don't need to implement this
431 * Refer to the documentation comments of nb_cb_get_keys_args for
435 * NB_OK on success, NB_ERR otherwise.
437 int (*get_keys
)(struct nb_cb_get_keys_args
*args
);
440 * Operational data callback for YANG lists.
442 * The callback function should return a list entry based on the list
443 * keys given as a parameter. Keyless lists don't need to implement this
447 * Refer to the documentation comments of nb_cb_lookup_entry_args for
451 * Pointer to the list entry if found, or NULL if not found.
453 const void *(*lookup_entry
)(struct nb_cb_lookup_entry_args
*args
);
456 * RPC and action callback.
458 * Both 'input' and 'output' are lists of 'yang_data' structures. The
459 * callback should fetch all the input parameters from the 'input' list,
460 * and add output parameters to the 'output' list if necessary.
463 * Refer to the documentation comments of nb_cb_rpc_args for details.
466 * NB_OK on success, NB_ERR otherwise.
468 int (*rpc
)(struct nb_cb_rpc_args
*args
);
471 * Optional callback to show the CLI command associated to the given
475 * The vty terminal to dump the configuration to.
478 * libyang data node that should be shown in the form of a CLI
482 * Specify whether to display default configuration values or not.
483 * This parameter can be ignored most of the time since the
484 * northbound doesn't call this callback for default leaves or
485 * non-presence containers that contain only default child nodes.
486 * The exception are commands associated to multiple configuration
487 * nodes, in which case it might be desirable to hide one or more
488 * parts of the command when this parameter is set to false.
490 void (*cli_show
)(struct vty
*vty
, struct lyd_node
*dnode
,
494 * Optional callback to show the CLI node end for lists or containers.
497 * The vty terminal to dump the configuration to.
500 * libyang data node that should be shown in the form of a CLI
503 void (*cli_show_end
)(struct vty
*vty
, struct lyd_node
*dnode
);
507 * Northbound-specific data that is allocated for each schema node of the native
511 /* Back pointer to the libyang schema node. */
512 const struct lys_node
*snode
;
514 /* Data path of this YANG node. */
515 char xpath
[XPATH_MAXLEN
];
517 /* Priority - lower priorities are processed first. */
520 /* Callbacks implemented for this node. */
521 struct nb_callbacks cbs
;
524 * Pointer to the parent node (disconsidering non-presence containers).
526 struct nb_node
*parent
;
528 /* Pointer to the nearest parent list, if any. */
529 struct nb_node
*parent_list
;
535 /* ConfD hash value corresponding to this YANG path. */
539 /* The YANG container or list contains only config data. */
540 #define F_NB_NODE_CONFIG_ONLY 0x01
541 /* The YANG list doesn't contain key leafs. */
542 #define F_NB_NODE_KEYLESS_LIST 0x02
545 * HACK: old gcc versions (< 5.x) have a bug that prevents C99 flexible arrays
546 * from working properly on shared libraries. For those compilers, use a fixed
547 * size array to work around the problem.
549 #define YANG_MODULE_MAX_NODES 1024
551 struct frr_yang_module_info
{
552 /* YANG module name. */
555 /* Northbound callbacks. */
557 /* Data path of this YANG node. */
560 /* Callbacks implemented for this node. */
561 struct nb_callbacks cbs
;
563 /* Priority - lower priorities are processed first. */
565 #if defined(__GNUC__) && ((__GNUC__ - 0) < 5) && !defined(__clang__)
566 } nodes
[YANG_MODULE_MAX_NODES
+ 1];
572 /* Northbound error codes. */
581 NB_ERR_INCONSISTENCY
,
584 /* Default priority. */
585 #define NB_DFLT_PRIORITY (UINT32_MAX / 2)
587 /* Default maximum of configuration rollbacks to store. */
588 #define NB_DLFT_MAX_CONFIG_ROLLBACKS 20
590 /* Northbound clients. */
599 /* Northbound context. */
601 /* Northbound client. */
602 enum nb_client client
;
604 /* Northbound user (can be NULL). */
607 /* Client-specific data. */
622 /* Northbound configuration. */
624 struct lyd_node
*dnode
;
628 /* Northbound configuration callback. */
629 struct nb_config_cb
{
630 RB_ENTRY(nb_config_cb
) entry
;
631 enum nb_operation operation
;
633 const struct nb_node
*nb_node
;
634 const struct lyd_node
*dnode
;
636 RB_HEAD(nb_config_cbs
, nb_config_cb
);
637 RB_PROTOTYPE(nb_config_cbs
, nb_config_cb
, entry
, nb_config_cb_compare
);
639 /* Northbound configuration change. */
640 struct nb_config_change
{
641 struct nb_config_cb cb
;
642 union nb_resource resource
;
646 /* Northbound configuration transaction. */
647 struct nb_transaction
{
648 struct nb_context
*context
;
650 struct nb_config
*config
;
651 struct nb_config_cbs changes
;
654 /* Callback function used by nb_oper_data_iterate(). */
655 typedef int (*nb_oper_data_cb
)(const struct lys_node
*snode
,
656 struct yang_translator
*translator
,
657 struct yang_data
*data
, void *arg
);
659 /* Iterate over direct child nodes only. */
660 #define NB_OPER_DATA_ITER_NORECURSE 0x0001
663 DECLARE_HOOK(nb_notification_send
, (const char *xpath
, struct list
*arguments
),
665 DECLARE_HOOK(nb_client_debug_config_write
, (struct vty
*vty
), (vty
))
666 DECLARE_HOOK(nb_client_debug_set_all
, (uint32_t flags
, bool set
), (flags
, set
))
668 /* Northbound debugging records */
669 extern struct debug nb_dbg_cbs_config
;
670 extern struct debug nb_dbg_cbs_state
;
671 extern struct debug nb_dbg_cbs_rpc
;
672 extern struct debug nb_dbg_notif
;
673 extern struct debug nb_dbg_events
;
675 /* Global running configuration. */
676 extern struct nb_config
*running_config
;
678 /* Wrappers for the northbound callbacks. */
679 extern struct yang_data
*nb_callback_get_elem(const struct nb_node
*nb_node
,
681 const void *list_entry
);
682 extern const void *nb_callback_get_next(const struct nb_node
*nb_node
,
683 const void *parent_list_entry
,
684 const void *list_entry
);
685 extern int nb_callback_get_keys(const struct nb_node
*nb_node
,
686 const void *list_entry
,
687 struct yang_list_keys
*keys
);
688 extern const void *nb_callback_lookup_entry(const struct nb_node
*nb_node
,
689 const void *parent_list_entry
,
690 const struct yang_list_keys
*keys
);
691 extern int nb_callback_rpc(const struct nb_node
*nb_node
, const char *xpath
,
692 const struct list
*input
, struct list
*output
);
695 * Create a northbound node for all YANG schema nodes.
697 void nb_nodes_create(void);
700 * Delete all northbound nodes from all YANG schema nodes.
702 void nb_nodes_delete(void);
705 * Find the northbound node corresponding to a YANG data path.
708 * XPath to search for (with or without predicates).
711 * Pointer to northbound node if found, NULL otherwise.
713 extern struct nb_node
*nb_node_find(const char *xpath
);
716 * Create a new northbound configuration.
719 * Pointer to a libyang data node containing the configuration data. If NULL
720 * is given, an empty configuration will be created.
723 * Pointer to newly created northbound configuration.
725 extern struct nb_config
*nb_config_new(struct lyd_node
*dnode
);
728 * Delete a northbound configuration.
731 * Pointer to the config that is going to be deleted.
733 extern void nb_config_free(struct nb_config
*config
);
736 * Duplicate a northbound configuration.
739 * Northbound configuration to duplicate.
742 * Pointer to duplicated configuration.
744 extern struct nb_config
*nb_config_dup(const struct nb_config
*config
);
747 * Merge one configuration into another.
750 * Configuration to merge to.
753 * Configuration to merge config_dst with.
756 * Specify whether config_src should be deleted or not after the merge
760 * NB_OK on success, NB_ERR otherwise.
762 extern int nb_config_merge(struct nb_config
*config_dst
,
763 struct nb_config
*config_src
, bool preserve_source
);
766 * Replace one configuration by another.
769 * Configuration to be replaced.
772 * Configuration to replace config_dst.
775 * Specify whether config_src should be deleted or not after the replace
778 extern void nb_config_replace(struct nb_config
*config_dst
,
779 struct nb_config
*config_src
,
780 bool preserve_source
);
783 * Edit a candidate configuration.
786 * Candidate configuration to edit.
789 * Northbound node associated to the configuration being edited.
792 * Operation to apply.
795 * XPath of the configuration node being edited.
798 * Previous value of the configuration node. Should be used only when the
799 * operation is NB_OP_MOVE, otherwise this parameter is ignored.
802 * New value of the configuration node.
805 * - NB_OK on success.
806 * - NB_ERR_NOT_FOUND when the element to be deleted was not found.
807 * - NB_ERR for other errors.
809 extern int nb_candidate_edit(struct nb_config
*candidate
,
810 const struct nb_node
*nb_node
,
811 enum nb_operation operation
, const char *xpath
,
812 const struct yang_data
*previous
,
813 const struct yang_data
*data
);
816 * Check if a candidate configuration is outdated and needs to be updated.
819 * Candidate configuration to check.
822 * true if the candidate is outdated, false otherwise.
824 extern bool nb_candidate_needs_update(const struct nb_config
*candidate
);
827 * Update a candidate configuration by rebasing the changes on top of the latest
828 * running configuration. Resolve conflicts automatically by giving preference
829 * to the changes done in the candidate configuration.
832 * Candidate configuration to update.
835 * NB_OK on success, NB_ERR otherwise.
837 extern int nb_candidate_update(struct nb_config
*candidate
);
840 * Validate a candidate configuration. Perform both YANG syntactic/semantic
841 * validation and code-level validation using the northbound callbacks.
843 * WARNING: the candidate can be modified as part of the validation process
844 * (e.g. add default nodes).
847 * Context of the northbound transaction.
850 * Candidate configuration to validate.
853 * Buffer to store human-readable error message in case of error.
859 * NB_OK on success, NB_ERR_VALIDATION otherwise.
861 extern int nb_candidate_validate(struct nb_context
*context
,
862 struct nb_config
*candidate
, char *errmsg
,
866 * Create a new configuration transaction but do not commit it yet. Only
867 * validate the candidate and prepare all resources required to apply the
868 * configuration changes.
871 * Context of the northbound transaction.
874 * Candidate configuration to commit.
877 * Optional comment describing the commit.
880 * Output parameter providing the created transaction when one is created
881 * successfully. In this case, it must be either aborted using
882 * nb_candidate_commit_abort() or committed using
883 * nb_candidate_commit_apply().
886 * Buffer to store human-readable error message in case of error.
892 * - NB_OK on success.
893 * - NB_ERR_NO_CHANGES when the candidate is identical to the running
895 * - NB_ERR_LOCKED when there's already another transaction in progress.
896 * - NB_ERR_VALIDATION when the candidate fails the validation checks.
897 * - NB_ERR_RESOURCE when the system fails to allocate resources to apply
898 * the candidate configuration.
899 * - NB_ERR for other errors.
901 extern int nb_candidate_commit_prepare(struct nb_context
*context
,
902 struct nb_config
*candidate
,
904 struct nb_transaction
**transaction
,
905 char *errmsg
, size_t errmsg_len
);
908 * Abort a previously created configuration transaction, releasing all resources
909 * allocated during the preparation phase.
912 * Candidate configuration to abort. It's consumed by this function.
915 * Buffer to store human-readable error message in case of error.
920 extern void nb_candidate_commit_abort(struct nb_transaction
*transaction
,
921 char *errmsg
, size_t errmsg_len
);
924 * Commit a previously created configuration transaction.
927 * Configuration transaction to commit. It's consumed by this function.
930 * Specify whether the transaction should be recorded in the transactions log
934 * Optional output parameter providing the ID of the committed transaction.
937 * Buffer to store human-readable error message in case of error.
942 extern void nb_candidate_commit_apply(struct nb_transaction
*transaction
,
943 bool save_transaction
,
944 uint32_t *transaction_id
, char *errmsg
,
948 * Create a new transaction to commit a candidate configuration. This is a
949 * convenience function that performs the two-phase commit protocol
950 * transparently to the user. The cost is reduced flexibility, since
951 * network-wide and multi-daemon transactions require the network manager to
952 * take into account the results of the preparation phase of multiple managed
956 * Context of the northbound transaction.
959 * Candidate configuration to commit. It's preserved regardless if the commit
960 * operation fails or not.
963 * Specify whether the transaction should be recorded in the transactions log
967 * Optional comment describing the commit.
970 * Optional output parameter providing the ID of the committed transaction.
973 * Buffer to store human-readable error message in case of error.
979 * - NB_OK on success.
980 * - NB_ERR_NO_CHANGES when the candidate is identical to the running
982 * - NB_ERR_LOCKED when there's already another transaction in progress.
983 * - NB_ERR_VALIDATION when the candidate fails the validation checks.
984 * - NB_ERR_RESOURCE when the system fails to allocate resources to apply
985 * the candidate configuration.
986 * - NB_ERR for other errors.
988 extern int nb_candidate_commit(struct nb_context
*context
,
989 struct nb_config
*candidate
,
990 bool save_transaction
, const char *comment
,
991 uint32_t *transaction_id
, char *errmsg
,
995 * Lock the running configuration.
1001 * Northbound user (can be NULL).
1004 * 0 on success, -1 when the running configuration is already locked.
1006 extern int nb_running_lock(enum nb_client client
, const void *user
);
1009 * Unlock the running configuration.
1012 * Northbound client.
1015 * Northbound user (can be NULL).
1018 * 0 on success, -1 when the running configuration is already unlocked or
1019 * locked by another client/user.
1021 extern int nb_running_unlock(enum nb_client client
, const void *user
);
1024 * Check if the running configuration is locked or not for the given
1028 * Northbound client.
1031 * Northbound user (can be NULL).
1034 * 0 if the running configuration is unlocked or if the client/user owns the
1035 * lock, -1 otherwise.
1037 extern int nb_running_lock_check(enum nb_client client
, const void *user
);
1040 * Iterate over operational data.
1043 * Data path of the YANG data we want to iterate over.
1046 * YANG module translator (might be NULL).
1049 * NB_OPER_DATA_ITER_ flags to control how the iteration is performed.
1052 * Function to call with each data node.
1055 * Arbitrary argument passed as the fourth parameter in each call to 'cb'.
1058 * NB_OK on success, NB_ERR otherwise.
1060 extern int nb_oper_data_iterate(const char *xpath
,
1061 struct yang_translator
*translator
,
1062 uint32_t flags
, nb_oper_data_cb cb
, void *arg
);
1065 * Validate if the northbound operation is valid for the given node.
1068 * Operation we want to check.
1071 * libyang schema node we want to check.
1074 * true if the operation is valid, false otherwise.
1076 extern bool nb_operation_is_valid(enum nb_operation operation
,
1077 const struct lys_node
*snode
);
1080 * Send a YANG notification. This is a no-op unless the 'nb_notification_send'
1081 * hook was registered by a northbound plugin.
1084 * XPath of the YANG notification.
1087 * Linked list containing the arguments that should be sent. This list is
1088 * deleted after being used.
1091 * NB_OK on success, NB_ERR otherwise.
1093 extern int nb_notification_send(const char *xpath
, struct list
*arguments
);
1096 * Associate a user pointer to a configuration node.
1098 * This should be called by northbound 'create' callbacks in the NB_EV_APPLY
1102 * libyang data node - only its XPath is used.
1105 * Arbitrary user-specified pointer.
1107 extern void nb_running_set_entry(const struct lyd_node
*dnode
, void *entry
);
1110 * Move an entire tree of user pointer nodes.
1112 * Suppose we have xpath A/B/C/D, with user pointers associated to C and D. We
1113 * need to move B to be under Z, so the new xpath is Z/B/C/D. Because user
1114 * pointers are indexed with their absolute path, We need to move all user
1115 * pointers at and below B to their new absolute paths; this function does
1119 * base xpath of tree to move (A/B)
1122 * base xpath of new location of tree (Z/B)
1124 extern void nb_running_move_tree(const char *xpath_from
, const char *xpath_to
);
1127 * Unset the user pointer associated to a configuration node.
1129 * This should be called by northbound 'destroy' callbacks in the NB_EV_APPLY
1133 * libyang data node - only its XPath is used.
1136 * The user pointer that was unset.
1138 extern void *nb_running_unset_entry(const struct lyd_node
*dnode
);
1141 * Find the user pointer (if any) associated to a configuration node.
1143 * The XPath associated to the configuration node can be provided directly or
1144 * indirectly through a libyang data node.
1146 * If an user point is not found, this function follows the parent nodes in the
1147 * running configuration until an user pointer is found or until the root node
1151 * libyang data node - only its XPath is used (can be NULL if 'xpath' is
1155 * XPath of the configuration node (can be NULL if 'dnode' is provided).
1157 * abort_if_not_found
1158 * When set to true, abort the program if no user pointer is found.
1160 * As a rule of thumb, this parameter should be set to true in the following
1162 * - Calling this function from any northbound configuration callback during
1163 * the NB_EV_APPLY phase.
1164 * - Calling this function from a 'delete' northbound configuration callback
1167 * In both the above cases, the given configuration node should contain an
1168 * user pointer except when there's a bug in the code, in which case it's
1169 * better to abort the program right away and eliminate the need for
1170 * unnecessary NULL checks.
1172 * In all other cases, this parameter should be set to false and the caller
1173 * should check if the function returned NULL or not.
1176 * User pointer if found, NULL otherwise.
1178 extern void *nb_running_get_entry(const struct lyd_node
*dnode
,
1179 const char *xpath
, bool abort_if_not_found
);
1182 * Same as 'nb_running_get_entry', but doesn't search within parent nodes
1183 * recursively if an user point is not found.
1185 extern void *nb_running_get_entry_non_rec(const struct lyd_node
*dnode
,
1187 bool abort_if_not_found
);
1190 * Return a human-readable string representing a northbound event.
1196 * String representation of the given northbound event.
1198 extern const char *nb_event_name(enum nb_event event
);
1201 * Return a human-readable string representing a northbound operation.
1204 * Northbound operation.
1207 * String representation of the given northbound operation.
1209 extern const char *nb_operation_name(enum nb_operation operation
);
1212 * Return a human-readable string representing a northbound error.
1218 * String representation of the given northbound error.
1220 extern const char *nb_err_name(enum nb_error error
);
1223 * Return a human-readable string representing a northbound client.
1226 * Northbound client.
1229 * String representation of the given northbound client.
1231 extern const char *nb_client_name(enum nb_client client
);
1234 * Initialize the northbound layer. Should be called only once during the
1235 * daemon initialization process.
1238 * Array of YANG modules to parse and initialize.
1241 * Size of the modules array.
1244 * Set this to record the transactions in the transaction log.
1246 extern void nb_init(struct thread_master
*tm
,
1247 const struct frr_yang_module_info
*const modules
[],
1248 size_t nmodules
, bool db_enabled
);
1251 * Finish the northbound layer gracefully. Should be called only when the daemon
1254 extern void nb_terminate(void);
1260 #endif /* _FRR_NORTHBOUND_H_ */