]> git.proxmox.com Git - mirror_frr.git/blame - lib/northbound_cli.h
Merge pull request #12837 from donaldsharp/unlikely_routemap
[mirror_frr.git] / lib / northbound_cli.h
CommitLineData
acddc0ed 1// SPDX-License-Identifier: GPL-2.0-or-later
1c2facd1
RW
2/*
3 * Copyright (C) 2018 NetDEF, Inc.
4 * Renato Westphal
1c2facd1
RW
5 */
6
7#ifndef _FRR_NORTHBOUND_CLI_H_
8#define _FRR_NORTHBOUND_CLI_H_
9
10#include "northbound.h"
11
5e244469
RW
12#ifdef __cplusplus
13extern "C" {
14#endif
15
1c2facd1
RW
16/* Possible formats in which a configuration can be displayed. */
17enum nb_cfg_format {
18 NB_CFG_FMT_CMDS = 0,
19 NB_CFG_FMT_JSON,
20 NB_CFG_FMT_XML,
21};
22
23extern struct nb_config *vty_shared_candidate_config;
24
a6233bfc
RW
25/*
26 * Enqueue change to be applied in the candidate configuration.
27 *
28 * vty
29 * The vty context.
30 *
31 * xpath
32 * XPath (absolute or relative) of the configuration option being edited.
33 *
34 * operation
35 * Operation to apply (either NB_OP_CREATE, NB_OP_MODIFY or NB_OP_DELETE).
36 *
37 * value
38 * New value of the configuration option. Should be NULL for typeless YANG
39 * data (e.g. presence-containers). For convenience, NULL can also be used
40 * to restore a leaf to its default value.
41 */
42extern void nb_cli_enqueue_change(struct vty *vty, const char *xpath,
43 enum nb_operation operation,
44 const char *value);
45
46/*
fd396924
CH
47 * Apply enqueued changes to the candidate configuration, do not batch,
48 * and apply any pending commits along with the currently enqueued.
49 *
50 * vty
51 * The vty context.
52 *
53 * xpath_base_fmt
54 * Prepend the given XPath (absolute or relative) to all enqueued
55 * configuration changes. This is an optional parameter.
56 *
57 * Returns:
58 * CMD_SUCCESS on success, CMD_WARNING_CONFIG_FAILED otherwise.
59 */
60extern int nb_cli_apply_changes_clear_pending(struct vty *vty,
0f9de11a
DL
61 const char *xpath_base_fmt, ...)
62 PRINTFRR(2, 3);
fd396924
CH
63
64/*
65 * Apply enqueued changes to the candidate configuration, this function
66 * may not immediately apply the changes, instead adding them to a pending
67 * queue.
a6233bfc
RW
68 *
69 * vty
70 * The vty context.
71 *
72 * xpath_base_fmt
73 * Prepend the given XPath (absolute or relative) to all enqueued
3cb4162c 74 * configuration changes. This is an optional parameter.
a6233bfc
RW
75 *
76 * Returns:
77 * CMD_SUCCESS on success, CMD_WARNING_CONFIG_FAILED otherwise.
78 */
79extern int nb_cli_apply_changes(struct vty *vty, const char *xpath_base_fmt,
0f9de11a 80 ...) PRINTFRR(2, 3);
a6233bfc
RW
81
82/*
83 * Execute a YANG RPC or Action.
84 *
f63f5f19
CS
85 * vty
86 * The vty terminal to dump any error.
87 *
a6233bfc
RW
88 * xpath
89 * XPath of the YANG RPC or Action node.
90 *
91 * input
92 * List of 'yang_data' structures containing the RPC input parameters. It
93 * can be set to NULL when there are no input parameters.
94 *
95 * output
96 * List of 'yang_data' structures used to retrieve the RPC output parameters.
97 * It can be set to NULL when it's known that the given YANG RPC or Action
98 * doesn't have any output parameters.
99 *
100 * Returns:
101 * CMD_SUCCESS on success, CMD_WARNING otherwise.
102 */
f63f5f19 103extern int nb_cli_rpc(struct vty *vty, const char *xpath, struct list *input,
1c2facd1 104 struct list *output);
a6233bfc
RW
105
106/*
107 * Show CLI commands associated to the given YANG data node.
108 *
109 * vty
110 * The vty terminal to dump the configuration to.
111 *
112 * dnode
113 * libyang data node that should be shown in the form of CLI commands.
114 *
115 * show_defaults
116 * Specify whether to display default configuration values or not.
117 */
25605051
IR
118extern void nb_cli_show_dnode_cmds(struct vty *vty,
119 const struct lyd_node *dnode,
1c2facd1 120 bool show_defaults);
a6233bfc 121
b855e95f
RW
122/*
123 * Perform pending commit, if any.
124 *
125 * vty
126 * The vty context.
fd396924
CH
127 *
128 * Returns
129 * CMD_SUCCESS on success (or no pending), CMD_WARNING_CONFIG_FAILED
130 * otherwise.
b855e95f 131 */
fd396924 132extern int nb_cli_pending_commit_check(struct vty *vty);
b855e95f 133
a6233bfc 134/* Prototypes of internal functions. */
5e6a9350
RW
135extern void nb_cli_show_config_prepare(struct nb_config *config,
136 bool with_defaults);
fbdc1c0a
RW
137extern void nb_cli_confirmed_commit_clean(struct vty *vty);
138extern int nb_cli_confirmed_commit_rollback(struct vty *vty);
1c2facd1 139extern void nb_cli_install_default(int node);
cd9d0537 140extern void nb_cli_init(struct event_loop *tm);
1c2facd1
RW
141extern void nb_cli_terminate(void);
142
5e244469
RW
143#ifdef __cplusplus
144}
145#endif
146
1c2facd1 147#endif /* _FRR_NORTHBOUND_CLI_H_ */