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