blob: 6feecab900b969c783e28af7e42e4e7b243d407c [file] [log] [blame]
Michal Vasko7bcb48e2016-01-15 10:28:54 +01001/**
2 * \file messages_client.h
3 * \author Radek Krejci <rkrejci@cesnet.cz>
4 * \author Michal Vasko <mvasko@cesnet.cz>
5 * \brief libnetconf2's public functions and structures of NETCONF client messages.
6 *
7 * Copyright (c) 2015 CESNET, z.s.p.o.
8 *
Radek Krejci9b81f5b2016-02-24 13:14:49 +01009 * This source code is licensed under BSD 3-Clause License (the "License").
10 * You may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
Michal Vaskoafd416b2016-02-25 14:51:46 +010012 *
Radek Krejci9b81f5b2016-02-24 13:14:49 +010013 * https://opensource.org/licenses/BSD-3-Clause
Michal Vasko7bcb48e2016-01-15 10:28:54 +010014 */
15
16#ifndef NC_MESSAGES_CLIENT_H_
17#define NC_MESSAGES_CLIENT_H_
18
Michal Vaskoc09730e2019-01-17 10:07:26 +010019#ifdef __cplusplus
20extern "C" {
21#endif
22
Michal Vasko7bcb48e2016-01-15 10:28:54 +010023#include <stdint.h>
24
25#include "netconf.h"
26
Michal Vaskof0537d82016-01-29 14:42:38 +010027/**
Radek Krejci6799a052017-05-19 14:23:23 +020028 * @defgroup client_msg Client Messages
29 * @ingroup client
30 *
31 * @brief Functions to create NETCONF RPCs (or actions) and process replies received from the server.
32 * @{
33 */
34
35/**
Michal Vaskof0537d82016-01-29 14:42:38 +010036 * @brief Enumeration of RPC types
Radek Krejci6799a052017-05-19 14:23:23 +020037 *
38 * Note that NC_RPC_CLOSE is not defined since sending \<close-session\> is done implicitly by nc_session_free()
Michal Vaskof0537d82016-01-29 14:42:38 +010039 */
Michal Vasko7bcb48e2016-01-15 10:28:54 +010040typedef enum {
Michal Vasko7f1c78b2016-01-19 09:52:14 +010041 NC_RPC_UNKNOWN = 0, /**< invalid RPC. */
Michal Vasko90e8e692016-07-13 12:27:57 +020042 NC_RPC_ACT_GENERIC, /**< user-defined generic RPC/action. */
Michal Vasko7bcb48e2016-01-15 10:28:54 +010043
44 /* ietf-netconf */
45 NC_RPC_GETCONFIG, /**< \<get-config\> RPC. */
46 NC_RPC_EDIT, /**< \<edit-config\> RPC. */
47 NC_RPC_COPY, /**< \<copy-config\> RPC. */
48 NC_RPC_DELETE, /**< \<delete-config\> RPC. */
49 NC_RPC_LOCK, /**< \<lock\> RPC. */
50 NC_RPC_UNLOCK, /**< \<unlock\> RPC. */
51 NC_RPC_GET, /**< \<get\> RPC. */
Michal Vasko7bcb48e2016-01-15 10:28:54 +010052 NC_RPC_KILL, /**< \<kill-session\> RPC. */
53 NC_RPC_COMMIT, /**< \<commit\> RPC. */
54 NC_RPC_DISCARD, /**< \<discard-changes\> RPC. */
55 NC_RPC_CANCEL, /**< \<cancel-commit\> RPC. */
56 NC_RPC_VALIDATE, /**< \<validate\> RPC. */
57
58 /* ietf-netconf-monitoring */
59 NC_RPC_GETSCHEMA, /**< \<get-schema\> RPC. */
60
61 /* notifications */
Michal Vaskoc1171a42019-11-05 12:06:46 +010062 NC_RPC_SUBSCRIBE, /**< \<create-subscription\> RPC. */
63
64 /* ietf-netconf-nmda */
65 NC_RPC_GETDATA, /**< \<get-data\> RPC. */
66 NC_RPC_EDITDATA, /**< \<edit-data\> RPC. */
Michal Vasko96f247a2021-03-15 13:32:10 +010067
68 /* ietf-subscribed-notifications */
69 NC_RPC_ESTABLISHSUB, /**< \<establish-subscription\> RPC. */
70 NC_RPC_MODIFYSUB, /**< \<modify-subscription\> RPC. */
71 NC_RPC_DELETESUB, /**< \<delete-subscription\> RPC. */
72 NC_RPC_KILLSUB, /**< \<kill-subscription\> RPC. */
Michal Vasko305faca2021-03-25 09:16:02 +010073
74 /* ietf-yang-push */
75 NC_RPC_ESTABLISHPUSH, /**< \<establish-subscription\> RPC with augments. */
76 NC_RPC_MODIFYPUSH, /**< \<modify-subscription\> RPC with augments. */
77 NC_RPC_RESYNCSUB, /**< \<resync-subscription\> RPC. */
Michal Vasko7bcb48e2016-01-15 10:28:54 +010078} NC_RPC_TYPE;
79
Michal Vaskof0537d82016-01-29 14:42:38 +010080/**
81 * @brief Enumeration of \<edit-config\> default operation
82 */
Michal Vasko7bcb48e2016-01-15 10:28:54 +010083typedef enum {
Michal Vaskof0537d82016-01-29 14:42:38 +010084 NC_RPC_EDIT_DFLTOP_UNKNOWN = 0, /**< unknown default operation */
85 NC_RPC_EDIT_DFLTOP_MERGE, /**< default operation merge */
86 NC_RPC_EDIT_DFLTOP_REPLACE, /**< default operation replace */
87 NC_RPC_EDIT_DFLTOP_NONE /**< default operation none */
Michal Vasko7bcb48e2016-01-15 10:28:54 +010088} NC_RPC_EDIT_DFLTOP;
89
Michal Vaskof0537d82016-01-29 14:42:38 +010090/**
91 * @brief Enumeration of \<edit-config\> test option
92 */
Michal Vasko7bcb48e2016-01-15 10:28:54 +010093typedef enum {
Michal Vaskof0537d82016-01-29 14:42:38 +010094 NC_RPC_EDIT_TESTOPT_UNKNOWN = 0, /**< unknown test option */
95 NC_RPC_EDIT_TESTOPT_TESTSET, /**< test-then-set option */
96 NC_RPC_EDIT_TESTOPT_SET, /**< set option */
97 NC_RPC_EDIT_TESTOPT_TEST /**< test-only option */
Michal Vasko7bcb48e2016-01-15 10:28:54 +010098} NC_RPC_EDIT_TESTOPT;
99
Michal Vaskof0537d82016-01-29 14:42:38 +0100100/**
101 * @brief Enumeration of \<edit-config\> error option
102 */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100103typedef enum {
Michal Vaskof0537d82016-01-29 14:42:38 +0100104 NC_RPC_EDIT_ERROPT_UNKNOWN = 0, /**< unknown error option */
105 NC_RPC_EDIT_ERROPT_STOP, /**< stop-on-error option */
106 NC_RPC_EDIT_ERROPT_CONTINUE, /**< continue-on-error option */
107 NC_RPC_EDIT_ERROPT_ROLLBACK /**< rollback-on-error option */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100108} NC_RPC_EDIT_ERROPT;
109
110/**
111 * @brief NETCONF error structure representation
112 */
113struct nc_err {
Radek Krejci6799a052017-05-19 14:23:23 +0200114 /** @brief \<error-type\>, error layer where the error occurred. */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100115 const char *type;
Radek Krejci6799a052017-05-19 14:23:23 +0200116 /** @brief \<error-tag\>. */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100117 const char *tag;
Radek Krejci6799a052017-05-19 14:23:23 +0200118 /** @brief \<error-severity\>. */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100119 const char *severity;
Radek Krejci6799a052017-05-19 14:23:23 +0200120 /** @brief \<error-app-tag\>, the data-model-specific or implementation-specific error condition, if one exists. */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100121 const char *apptag;
Radek Krejci6799a052017-05-19 14:23:23 +0200122 /** @brief \<error-path\>, XPATH expression identifying the element with the error. */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100123 const char *path;
Radek Krejci6799a052017-05-19 14:23:23 +0200124 /** @brief \<error-message\>, Human-readable description of the error. */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100125 const char *message;
Radek Krejci6799a052017-05-19 14:23:23 +0200126 /** @brief xml:lang attribute of the error-message. */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100127 const char *message_lang;
128
129 /* <error-info> */
130
Radek Krejci6799a052017-05-19 14:23:23 +0200131 /** @brief \<session-id\>, session ID of the session holding the requested lock. Part of \<error-info\>. */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100132 const char *sid;
Radek Krejci6799a052017-05-19 14:23:23 +0200133 /** @brief \<bad-attr\>, array of the names of the data-model-specific XML attributes that caused the error. Part of \<error-info\>. */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100134 const char **attr;
Radek Krejci6799a052017-05-19 14:23:23 +0200135 /** @brief \<bad-element\>, array of the names of the data-model-specific XML element that caused the error. Part of \<error-info\>. */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100136 const char **elem;
Radek Krejci6799a052017-05-19 14:23:23 +0200137 /** @brief \<bad-namespace\>, array of the unexpected XML namespaces that caused the error. Part of \<error-info\>. */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100138 const char **ns;
Michal Vasko77367452021-02-16 16:32:18 +0100139 /** @brief List of the remaining non-standard opaque nodes. */
140 struct lyd_node *other;
Radek Krejci6799a052017-05-19 14:23:23 +0200141
142 /** @brief Number of items in the attr array */
143 uint16_t attr_count;
144 /** @brief Number of items in the elem array */
145 uint16_t elem_count;
146 /** @brief Number of items in the ns array */
147 uint16_t ns_count;
148 /** @brief Number of items in the other array */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100149 uint16_t other_count;
150};
151
152/**
Michal Vasko96f247a2021-03-15 13:32:10 +0100153 * @struct nc_rpc
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100154 * @brief NETCONF client RPC object
Michal Vasko96f247a2021-03-15 13:32:10 +0100155 *
156 * Note that any stored parameters are not checked for validity because it is performed later,
157 * while sending the RPC via a specific NETCONF session (::nc_send_rpc()) since the NETCONF
158 * capabilities of the session are needed for such a check. An RPC object can be sent via any
159 * NETCONF session which supports all the needed NETCONF capabilities for the RPC.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100160 */
161struct nc_rpc;
162
Michal Vasko1a38c862016-01-15 15:50:07 +0100163/**
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100164 * @brief Get the type of the RPC
165 *
166 * @param[in] rpc RPC to check the type of.
167 * @return Type of \p rpc.
168 */
169NC_RPC_TYPE nc_rpc_get_type(const struct nc_rpc *rpc);
170
171/**
Michal Vasko90e8e692016-07-13 12:27:57 +0200172 * @brief Create a generic NETCONF RPC or action
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100173 *
174 * Note that created object can be sent via any NETCONF session that shares the context
175 * of the \p data.
176 *
177 * @param[in] data NETCONF RPC data as a data tree.
178 * @param[in] paramtype How to further manage data parameters.
179 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
180 */
Michal Vasko90e8e692016-07-13 12:27:57 +0200181struct nc_rpc *nc_rpc_act_generic(const struct lyd_node *data, NC_PARAMTYPE paramtype);
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100182
183/**
Michal Vasko90e8e692016-07-13 12:27:57 +0200184 * @brief Create a generic NETCONF RPC or action from an XML string
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100185 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100186 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100187 *
188 * @param[in] xml_str NETCONF RPC data as an XML string.
189 * @param[in] paramtype How to further manage data parameters.
190 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
191 */
Michal Vasko90e8e692016-07-13 12:27:57 +0200192struct nc_rpc *nc_rpc_act_generic_xml(const char *xml_str, NC_PARAMTYPE paramtype);
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100193
194/**
195 * @brief Create NETCONF RPC \<get-config\>
196 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100197 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100198 *
199 * @param[in] source Source datastore being queried.
Michal Vaskoc2389702017-08-09 10:16:49 +0200200 * @param[in] filter Optional filter data, an XML subtree or XPath expression (with JSON prefixes).
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100201 * @param[in] wd_mode Optional with-defaults capability mode.
202 * @param[in] paramtype How to further manage data parameters.
203 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
204 */
205struct nc_rpc *nc_rpc_getconfig(NC_DATASTORE source, const char *filter, NC_WD_MODE wd_mode,
Michal Vasko96f247a2021-03-15 13:32:10 +0100206 NC_PARAMTYPE paramtype);
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100207
208/**
209 * @brief Create NETCONF RPC \<edit-config\>
210 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100211 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100212 *
213 * @param[in] target Target datastore being edited.
214 * @param[in] default_op Optional default operation.
215 * @param[in] test_opt Optional test option.
216 * @param[in] error_opt Optional error option.
217 * @param[in] edit_content Config or URL where the config to perform is to be found.
218 * @param[in] paramtype How to further manage data parameters.
219 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
220 */
221struct nc_rpc *nc_rpc_edit(NC_DATASTORE target, NC_RPC_EDIT_DFLTOP default_op, NC_RPC_EDIT_TESTOPT test_opt,
Michal Vasko96f247a2021-03-15 13:32:10 +0100222 NC_RPC_EDIT_ERROPT error_opt, const char *edit_content, NC_PARAMTYPE paramtype);
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100223
224/**
225 * @brief Create NETCONF RPC \<copy-config\>
226 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100227 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100228 *
229 * @param[in] target Target datastore.
230 * @param[in] url_trg Used instead \p target if the target is an URL.
231 * @param[in] source Source datastore.
232 * @param[in] url_or_config_src Used instead \p source if the source is an URL or a config.
233 * @param[in] wd_mode Optional with-defaults capability mode.
234 * @param[in] paramtype How to further manage data parameters.
235 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
236 */
237struct nc_rpc *nc_rpc_copy(NC_DATASTORE target, const char *url_trg, NC_DATASTORE source,
Michal Vasko96f247a2021-03-15 13:32:10 +0100238 const char *url_or_config_src, NC_WD_MODE wd_mode, NC_PARAMTYPE paramtype);
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100239
240/**
241 * @brief Create NETCONF RPC \<delete-config\>
242 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100243 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100244 *
245 * @param[in] target Target datastore to delete.
246 * @param[in] url Used instead \p target if the target is an URL.
247 * @param[in] paramtype How to further manage data parameters.
248 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
249 */
250struct nc_rpc *nc_rpc_delete(NC_DATASTORE target, const char *url, NC_PARAMTYPE paramtype);
251
252/**
253 * @brief Create NETCONF RPC \<lock\>
254 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100255 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100256 *
257 * @param[in] target Target datastore of the operation.
258 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
259 */
260struct nc_rpc *nc_rpc_lock(NC_DATASTORE target);
261
262/**
263 * @brief Create NETCONF RPC \<unlock\>
264 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100265 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100266 *
267 * @param[in] target Target datastore of the operation.
268 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
269 */
270struct nc_rpc *nc_rpc_unlock(NC_DATASTORE target);
271
272/**
273 * @brief Create NETCONF RPC \<get\>
274 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100275 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100276 *
Michal Vaskoc2389702017-08-09 10:16:49 +0200277 * @param[in] filter Optional filter data, an XML subtree or XPath expression (with JSON prefixes).
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100278 * @param[in] wd_mode Optional with-defaults capability mode.
279 * @param[in] paramtype How to further manage data parameters.
280 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
281 */
282struct nc_rpc *nc_rpc_get(const char *filter, NC_WD_MODE wd_mode, NC_PARAMTYPE paramtype);
283
284/**
285 * @brief Create NETCONF RPC \<kill-session\>
286 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100287 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100288 *
289 * @param[in] session_id Session ID of the session to kill.
290 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
291 */
292struct nc_rpc *nc_rpc_kill(uint32_t session_id);
293
294/**
295 * @brief Create NETCONF RPC \<commit\>
296 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100297 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100298 *
299 * @param[in] confirmed Whether the commit is to be confirmed.
300 * @param[in] confirm_timeout Optional confirm timeout.
301 * @param[in] persist Optional identification string of a new persistent confirmed commit.
302 * @param[in] persist_id Optional identification string of a persistent confirmed commit to be commited.
303 * @param[in] paramtype How to further manage data parameters.
304 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
305 */
306struct nc_rpc *nc_rpc_commit(int confirmed, uint32_t confirm_timeout, const char *persist, const char *persist_id,
Michal Vasko96f247a2021-03-15 13:32:10 +0100307 NC_PARAMTYPE paramtype);
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100308
309/**
310 * @brief Create NETCONF RPC \<discard-changes\>
311 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100312 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100313 *
314 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
315 */
316struct nc_rpc *nc_rpc_discard(void);
317
318/**
319 * @brief Create NETCONF RPC \<cancel-commit\>
320 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100321 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100322 *
323 * @param[in] persist_id Optional identification string of a persistent confirmed commit.
324 * @param[in] paramtype How to further manage data parameters.
325 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
326 */
327struct nc_rpc *nc_rpc_cancel(const char *persist_id, NC_PARAMTYPE paramtype);
328
329/**
330 * @brief Create NETCONF RPC \<validate\>
331 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100332 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100333 *
334 * @param[in] source Source datastore being validated.
Michal Vasko4aade752016-02-18 13:24:38 +0100335 * @param[in] url_or_config Used instead \p source if the source is an URL or a config.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100336 * @param[in] paramtype How to further manage data parameters.
337 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
338 */
339struct nc_rpc *nc_rpc_validate(NC_DATASTORE source, const char *url_or_config, NC_PARAMTYPE paramtype);
340
341/**
342 * @brief Create NETCONF RPC \<get-schema\>
343 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100344 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100345 *
346 * @param[in] identifier Requested model identifier.
347 * @param[in] version Optional model version, either YANG version (1.0/1.1) or revision date.
348 * @param[in] format Optional format of the model (default is YANG).
349 * @param[in] paramtype How to further manage data parameters.
350 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
351 */
352struct nc_rpc *nc_rpc_getschema(const char *identifier, const char *version, const char *format, NC_PARAMTYPE paramtype);
353
354/**
355 * @brief Create NETCONF RPC \<create-subscription\>
356 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100357 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100358 *
359 * @param[in] stream_name Optional name of a NETCONF stream to subscribe to.
Michal Vaskoc2389702017-08-09 10:16:49 +0200360 * @param[in] filter Optional filter data, an XML subtree or XPath expression (with JSON prefixes).
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100361 * @param[in] start_time Optional YANG datetime identifying the start of the subscription.
362 * @param[in] stop_time Optional YANG datetime identifying the end of the subscription.
363 * @param[in] paramtype How to further manage data parameters.
364 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
365 */
366struct nc_rpc *nc_rpc_subscribe(const char *stream_name, const char *filter, const char *start_time,
Michal Vasko96f247a2021-03-15 13:32:10 +0100367 const char *stop_time, NC_PARAMTYPE paramtype);
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100368
369/**
Michal Vaskoc1171a42019-11-05 12:06:46 +0100370 * @brief Create NETCONF RPC \<get-data\>
371 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100372 * For details, see ::nc_rpc.
Michal Vaskoc1171a42019-11-05 12:06:46 +0100373 *
374 * @param[in] datastore Source datastore, foreign identity so a module name prefix is required.
375 * @param[in] filter Optional filter data, an XML subtree or XPath expression (with JSON prefixes).
376 * @param[in] config_filter Optional config filter, "true" for config-only data, "false" for state-only data.
377 * @param[in] origin_filter Optional origin filter array, selects only nodes of this or derived origin.
378 * @param[in] origin_filter_count Count of filters is \p origin_filter.
379 * @param[in] neg_origin_filter Whether origin filters are negated or not.
380 * @param[in] max_depth Maximum depth of returned subtrees, 0 for unlimited.
381 * @param[in] with_origin Whether return data origin.
382 * @param[in] wd_mode Optional with-defaults capability mode.
383 * @param[in] paramtype How to further manage data parameters.
384 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
385 */
386struct nc_rpc *nc_rpc_getdata(const char *datastore, const char *filter, const char *config_filter, char **origin_filter,
Michal Vasko96f247a2021-03-15 13:32:10 +0100387 int origin_filter_count, int neg_origin_filter, uint16_t max_depth, int with_origin, NC_WD_MODE wd_mode,
388 NC_PARAMTYPE paramtype);
Michal Vaskoc1171a42019-11-05 12:06:46 +0100389
390/**
391 * @brief Create NETCONF RPC \<get-data\>
392 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100393 * For details, see ::nc_rpc.
Michal Vaskoc1171a42019-11-05 12:06:46 +0100394 *
395 * @param[in] datastore Source datastore, foreign identity so a module name prefix is required.
396 * @param[in] default_op Optional default operation.
397 * @param[in] edit_content Config or URL where the config to perform is to be found.
398 * @param[in] paramtype How to further manage data parameters.
399 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
400 */
401struct nc_rpc *nc_rpc_editdata(const char *datastore, NC_RPC_EDIT_DFLTOP default_op, const char *edit_content,
Michal Vasko96f247a2021-03-15 13:32:10 +0100402 NC_PARAMTYPE paramtype);
403
404/**
405 * @brief Create NETCONF RPC \<establish-subscription\>
406 *
407 * For details, see ::nc_rpc.
408 *
409 * @param[in] filter Optional filter data, an XML subtree, XPath expression (with JSON prefixes),
410 * or filter reference, selected based on the first character.
411 * @param[in] stream_name Name of a NETCONF stream to subscribe to.
412 * @param[in] start_time Optional YANG datetime identifying the start of the subscription.
413 * @param[in] stop_time Optional YANG datetime identifying the end of the subscription.
414 * @param[in] encoding Optional specific encoding to use.
415 * @param[in] paramtype How to further manage data parameters.
416 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
417 */
418struct nc_rpc *nc_rpc_establishsub(const char *filter, const char *stream_name, const char *start_time,
419 const char *stop_time, const char *encoding, NC_PARAMTYPE paramtype);
420
421/**
422 * @brief Create NETCONF RPC \<modify-subscription\>
423 *
424 * For details, see ::nc_rpc.
425 *
426 * @param[in] id Subscription ID to modify.
427 * @param[in] filter Optional new filter data, an XML subtree, XPath expression (with JSON prefixes),
428 * or filter reference, selected based on the first character.
429 * @param[in] stop_time Optional new YANG datetime identifying the end of the subscription.
430 * @param[in] paramtype How to further manage data parameters.
431 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
432 */
433struct nc_rpc *nc_rpc_modifysub(uint32_t id, const char *filter, const char *stop_time, NC_PARAMTYPE paramtype);
434
435/**
436 * @brief Create NETCONF RPC \<delete-subscription\>
437 *
438 * For details, see ::nc_rpc.
439 *
440 * @param[in] id Subscription ID to delete.
441 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
442 */
443struct nc_rpc *nc_rpc_deletesub(uint32_t id);
444
445/**
446 * @brief Create NETCONF RPC \<kill-subscription\>
447 *
448 * For details, see ::nc_rpc.
449 *
450 * @param[in] id Subscription ID to kill.
451 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
452 */
453struct nc_rpc *nc_rpc_killsub(uint32_t id);
Michal Vaskoc1171a42019-11-05 12:06:46 +0100454
455/**
Michal Vasko305faca2021-03-25 09:16:02 +0100456 * @brief Create NETCONF RPC \<establish-subscription\> with augments from ietf-yang-push for a periodic subscription
457 *
458 * For details, see ::nc_rpc.
459 *
460 * @param[in] datastore Source datastore, foreign identity so a module name prefix is required.
461 * @param[in] filter Optional filter data, an XML subtree, XPath expression (with JSON prefixes),
462 * or filter reference, selected based on the first character.
463 * @param[in] stop_time Optional YANG datetime identifying the end of the subscription.
464 * @param[in] encoding Optional specific encoding to use.
465 * @param[in] period Subscription period in centiseconds (0.01s).
466 * @param[in] anchor_time Optional anchor datetime for the period.
467 * @param[in] paramtype How to further manage data parameters.
468 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
469 */
470struct nc_rpc *nc_rpc_establishpush_periodic(const char *datastore, const char *filter, const char *stop_time,
471 const char *encoding, uint32_t period, const char *anchor_time, NC_PARAMTYPE paramtype);
472
473/**
474 * @brief Create NETCONF RPC \<establish-subscription\> with augments from ietf-yang-push for an on-change subscription
475 *
476 * For details, see ::nc_rpc.
477 *
478 * @param[in] datastore Source datastore, foreign identity so a module name prefix is required.
479 * @param[in] filter Optional filter data, an XML subtree, XPath expression (with JSON prefixes),
480 * or filter reference, selected based on the first character.
481 * @param[in] stop_time Optional YANG datetime identifying the end of the subscription.
482 * @param[in] encoding Optional specific encoding to use.
483 * @param[in] dampening_period Optional dampening period of the notifications.
484 * @param[in] sync_on_start Whether to send a full push-update notification on subscription start.
485 * @param[in] excluded_change Optional NULL-terminated array of excluded changes.
486 * @param[in] paramtype How to further manage data parameters.
487 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
488 */
489struct nc_rpc *nc_rpc_establishpush_onchange(const char *datastore, const char *filter, const char *stop_time,
490 const char *encoding, uint32_t dampening_period, int sync_on_start, const char **excluded_change,
491 NC_PARAMTYPE paramtype);
492
493/**
494 * @brief Create NETCONF RPC \<modify-subscription\> with augments from ietf-yang-push for a periodic subscription
495 *
496 * For details, see ::nc_rpc.
497 *
498 * @param[in] id Subscription ID to modify.
499 * @param[in] datastore Source datastore, foreign identity so a module name prefix is required.
500 * @param[in] filter Optional filter data, an XML subtree, XPath expression (with JSON prefixes),
501 * or filter reference, selected based on the first character.
502 * @param[in] stop_time Optional YANG datetime identifying the end of the subscription.
503 * @param[in] period Subscription period in centiseconds (0.01s).
504 * @param[in] anchor_time Optional anchor datetime for the period.
505 * @param[in] paramtype How to further manage data parameters.
506 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
507 */
508struct nc_rpc *nc_rpc_modifypush_periodic(uint32_t id, const char *datastore, const char *filter, const char *stop_time,
509 uint32_t period, const char *anchor_time, NC_PARAMTYPE paramtype);
510
511/**
512 * @brief Create NETCONF RPC \<modify-subscription\> with augments from ietf-yang-push for an on-change subscription
513 *
514 * For details, see ::nc_rpc.
515 *
516 * @param[in] id Subscription ID to modify.
517 * @param[in] datastore Source datastore, foreign identity so a module name prefix is required.
518 * @param[in] filter Optional filter data, an XML subtree, XPath expression (with JSON prefixes),
519 * or filter reference, selected based on the first character.
520 * @param[in] stop_time Optional YANG datetime identifying the end of the subscription.
521 * @param[in] dampening_period Optional dampening period of the notifications.
522 * @param[in] paramtype How to further manage data parameters.
523 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
524 */
525struct nc_rpc *nc_rpc_modifypush_onchange(uint32_t id, const char *datastore, const char *filter, const char *stop_time,
526 uint32_t dampening_period, NC_PARAMTYPE paramtype);
527
528/**
529 * @brief Create NETCONF RPC \<resync-subscription\>
530 *
531 * For details, see ::nc_rpc.
532 *
533 * @param[in] id Subscription ID to resync.
534 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
535 */
536struct nc_rpc *nc_rpc_resyncsub(uint32_t id);
537
538/**
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100539 * @brief Free the NETCONF RPC object.
Michal Vaskof0537d82016-01-29 14:42:38 +0100540 *
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100541 * @param[in] rpc Object to free.
542 */
543void nc_rpc_free(struct nc_rpc *rpc);
544
Michal Vasko77367452021-02-16 16:32:18 +0100545/** @} Client Messages */
Radek Krejci6799a052017-05-19 14:23:23 +0200546
Michal Vaskoc09730e2019-01-17 10:07:26 +0100547#ifdef __cplusplus
548}
549#endif
550
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100551#endif /* NC_MESSAGES_CLIENT_H_ */