blob: dda44dcef36c6a910d513dced7867101f019303a [file] [log] [blame]
Michal Vasko7bcb48e2016-01-15 10:28:54 +01001/**
Michal Vaskoc446a382021-06-18 08:54:05 +02002 * @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.
Michal Vasko7bcb48e2016-01-15 10:28:54 +01006 *
Michal Vaskoc446a382021-06-18 08:54:05 +02007 * Copyright (c) 2015 - 2021 CESNET, z.s.p.o.
Michal Vasko7bcb48e2016-01-15 10:28:54 +01008 *
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. */
Michal Vaskob83a3fa2021-05-26 09:53:42 +020077 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.
Michal Vaskoc446a382021-06-18 08:54:05 +0200167 * @return Type of @p rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100168 */
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
Michal Vaskoc446a382021-06-18 08:54:05 +0200175 * of the @p data.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100176 *
Michal Vasko70bf2222021-10-26 10:45:15 +0200177 * @note In case of action, the \<action\> element is added automatically and should not be in @p data.
178 *
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100179 * @param[in] data NETCONF RPC data as a data tree.
180 * @param[in] paramtype How to further manage data parameters.
181 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
182 */
Michal Vasko90e8e692016-07-13 12:27:57 +0200183struct nc_rpc *nc_rpc_act_generic(const struct lyd_node *data, NC_PARAMTYPE paramtype);
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100184
185/**
Michal Vasko90e8e692016-07-13 12:27:57 +0200186 * @brief Create a generic NETCONF RPC or action from an XML string
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100187 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100188 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100189 *
Michal Vasko70bf2222021-10-26 10:45:15 +0200190 * @note In case of action, the \<action\> element is added automatically and should not be in @p xml_str.
191 *
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100192 * @param[in] xml_str NETCONF RPC data as an XML string.
193 * @param[in] paramtype How to further manage data parameters.
194 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
195 */
Michal Vasko90e8e692016-07-13 12:27:57 +0200196struct nc_rpc *nc_rpc_act_generic_xml(const char *xml_str, NC_PARAMTYPE paramtype);
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100197
198/**
199 * @brief Create NETCONF RPC \<get-config\>
200 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100201 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100202 *
203 * @param[in] source Source datastore being queried.
Michal Vaskoc2389702017-08-09 10:16:49 +0200204 * @param[in] filter Optional filter data, an XML subtree or XPath expression (with JSON prefixes).
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100205 * @param[in] wd_mode Optional with-defaults capability mode.
206 * @param[in] paramtype How to further manage data parameters.
207 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
208 */
209struct nc_rpc *nc_rpc_getconfig(NC_DATASTORE source, const char *filter, NC_WD_MODE wd_mode,
Michal Vasko96f247a2021-03-15 13:32:10 +0100210 NC_PARAMTYPE paramtype);
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100211
212/**
213 * @brief Create NETCONF RPC \<edit-config\>
214 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100215 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100216 *
217 * @param[in] target Target datastore being edited.
218 * @param[in] default_op Optional default operation.
219 * @param[in] test_opt Optional test option.
220 * @param[in] error_opt Optional error option.
221 * @param[in] edit_content Config or URL where the config to perform is to be found.
222 * @param[in] paramtype How to further manage data parameters.
223 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
224 */
225struct 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 +0100226 NC_RPC_EDIT_ERROPT error_opt, const char *edit_content, NC_PARAMTYPE paramtype);
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100227
228/**
229 * @brief Create NETCONF RPC \<copy-config\>
230 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100231 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100232 *
233 * @param[in] target Target datastore.
Michal Vaskoc446a382021-06-18 08:54:05 +0200234 * @param[in] url_trg Used instead @p target if the target is an URL.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100235 * @param[in] source Source datastore.
Michal Vaskoc446a382021-06-18 08:54:05 +0200236 * @param[in] url_or_config_src Used instead @p source if the source is an URL or a config.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100237 * @param[in] wd_mode Optional with-defaults capability mode.
238 * @param[in] paramtype How to further manage data parameters.
239 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
240 */
241struct nc_rpc *nc_rpc_copy(NC_DATASTORE target, const char *url_trg, NC_DATASTORE source,
Michal Vasko96f247a2021-03-15 13:32:10 +0100242 const char *url_or_config_src, NC_WD_MODE wd_mode, NC_PARAMTYPE paramtype);
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100243
244/**
245 * @brief Create NETCONF RPC \<delete-config\>
246 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100247 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100248 *
249 * @param[in] target Target datastore to delete.
Michal Vaskoc446a382021-06-18 08:54:05 +0200250 * @param[in] url Used instead @p target if the target is an URL.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100251 * @param[in] paramtype How to further manage data parameters.
252 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
253 */
254struct nc_rpc *nc_rpc_delete(NC_DATASTORE target, const char *url, NC_PARAMTYPE paramtype);
255
256/**
257 * @brief Create NETCONF RPC \<lock\>
258 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100259 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100260 *
261 * @param[in] target Target datastore of the operation.
262 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
263 */
264struct nc_rpc *nc_rpc_lock(NC_DATASTORE target);
265
266/**
267 * @brief Create NETCONF RPC \<unlock\>
268 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100269 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100270 *
271 * @param[in] target Target datastore of the operation.
272 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
273 */
274struct nc_rpc *nc_rpc_unlock(NC_DATASTORE target);
275
276/**
277 * @brief Create NETCONF RPC \<get\>
278 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100279 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100280 *
Michal Vaskoc2389702017-08-09 10:16:49 +0200281 * @param[in] filter Optional filter data, an XML subtree or XPath expression (with JSON prefixes).
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100282 * @param[in] wd_mode Optional with-defaults capability mode.
283 * @param[in] paramtype How to further manage data parameters.
284 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
285 */
286struct nc_rpc *nc_rpc_get(const char *filter, NC_WD_MODE wd_mode, NC_PARAMTYPE paramtype);
287
288/**
289 * @brief Create NETCONF RPC \<kill-session\>
290 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100291 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100292 *
293 * @param[in] session_id Session ID of the session to kill.
294 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
295 */
296struct nc_rpc *nc_rpc_kill(uint32_t session_id);
297
298/**
299 * @brief Create NETCONF RPC \<commit\>
300 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100301 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100302 *
303 * @param[in] confirmed Whether the commit is to be confirmed.
304 * @param[in] confirm_timeout Optional confirm timeout.
305 * @param[in] persist Optional identification string of a new persistent confirmed commit.
306 * @param[in] persist_id Optional identification string of a persistent confirmed commit to be commited.
307 * @param[in] paramtype How to further manage data parameters.
308 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
309 */
310struct 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 +0100311 NC_PARAMTYPE paramtype);
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100312
313/**
314 * @brief Create NETCONF RPC \<discard-changes\>
315 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100316 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100317 *
318 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
319 */
320struct nc_rpc *nc_rpc_discard(void);
321
322/**
323 * @brief Create NETCONF RPC \<cancel-commit\>
324 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100325 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100326 *
327 * @param[in] persist_id Optional identification string of a persistent confirmed commit.
328 * @param[in] paramtype How to further manage data parameters.
329 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
330 */
331struct nc_rpc *nc_rpc_cancel(const char *persist_id, NC_PARAMTYPE paramtype);
332
333/**
334 * @brief Create NETCONF RPC \<validate\>
335 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100336 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100337 *
338 * @param[in] source Source datastore being validated.
Michal Vaskoc446a382021-06-18 08:54:05 +0200339 * @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 +0100340 * @param[in] paramtype How to further manage data parameters.
341 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
342 */
343struct nc_rpc *nc_rpc_validate(NC_DATASTORE source, const char *url_or_config, NC_PARAMTYPE paramtype);
344
345/**
346 * @brief Create NETCONF RPC \<get-schema\>
347 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100348 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100349 *
350 * @param[in] identifier Requested model identifier.
351 * @param[in] version Optional model version, either YANG version (1.0/1.1) or revision date.
352 * @param[in] format Optional format of the model (default is YANG).
353 * @param[in] paramtype How to further manage data parameters.
354 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
355 */
356struct nc_rpc *nc_rpc_getschema(const char *identifier, const char *version, const char *format, NC_PARAMTYPE paramtype);
357
358/**
359 * @brief Create NETCONF RPC \<create-subscription\>
360 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100361 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100362 *
363 * @param[in] stream_name Optional name of a NETCONF stream to subscribe to.
Michal Vaskoc2389702017-08-09 10:16:49 +0200364 * @param[in] filter Optional filter data, an XML subtree or XPath expression (with JSON prefixes).
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100365 * @param[in] start_time Optional YANG datetime identifying the start of the subscription.
366 * @param[in] stop_time Optional YANG datetime identifying the end of the subscription.
367 * @param[in] paramtype How to further manage data parameters.
368 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
369 */
370struct nc_rpc *nc_rpc_subscribe(const char *stream_name, const char *filter, const char *start_time,
Michal Vasko96f247a2021-03-15 13:32:10 +0100371 const char *stop_time, NC_PARAMTYPE paramtype);
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100372
373/**
Michal Vaskoc1171a42019-11-05 12:06:46 +0100374 * @brief Create NETCONF RPC \<get-data\>
375 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100376 * For details, see ::nc_rpc.
Michal Vaskoc1171a42019-11-05 12:06:46 +0100377 *
378 * @param[in] datastore Source datastore, foreign identity so a module name prefix is required.
379 * @param[in] filter Optional filter data, an XML subtree or XPath expression (with JSON prefixes).
380 * @param[in] config_filter Optional config filter, "true" for config-only data, "false" for state-only data.
381 * @param[in] origin_filter Optional origin filter array, selects only nodes of this or derived origin.
Michal Vaskoc446a382021-06-18 08:54:05 +0200382 * @param[in] origin_filter_count Count of filters is @p origin_filter.
Michal Vaskoc1171a42019-11-05 12:06:46 +0100383 * @param[in] neg_origin_filter Whether origin filters are negated or not.
384 * @param[in] max_depth Maximum depth of returned subtrees, 0 for unlimited.
385 * @param[in] with_origin Whether return data origin.
386 * @param[in] wd_mode Optional with-defaults capability mode.
387 * @param[in] paramtype How to further manage data parameters.
388 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
389 */
390struct 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 +0100391 int origin_filter_count, int neg_origin_filter, uint16_t max_depth, int with_origin, NC_WD_MODE wd_mode,
392 NC_PARAMTYPE paramtype);
Michal Vaskoc1171a42019-11-05 12:06:46 +0100393
394/**
395 * @brief Create NETCONF RPC \<get-data\>
396 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100397 * For details, see ::nc_rpc.
Michal Vaskoc1171a42019-11-05 12:06:46 +0100398 *
399 * @param[in] datastore Source datastore, foreign identity so a module name prefix is required.
400 * @param[in] default_op Optional default operation.
401 * @param[in] edit_content Config or URL where the config to perform is to be found.
402 * @param[in] paramtype How to further manage data parameters.
403 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
404 */
405struct 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 +0100406 NC_PARAMTYPE paramtype);
407
408/**
409 * @brief Create NETCONF RPC \<establish-subscription\>
410 *
411 * For details, see ::nc_rpc.
412 *
413 * @param[in] filter Optional filter data, an XML subtree, XPath expression (with JSON prefixes),
414 * or filter reference, selected based on the first character.
415 * @param[in] stream_name Name of a NETCONF stream to subscribe to.
416 * @param[in] start_time Optional YANG datetime identifying the start of the subscription.
417 * @param[in] stop_time Optional YANG datetime identifying the end of the subscription.
418 * @param[in] encoding Optional specific encoding to use.
419 * @param[in] paramtype How to further manage data parameters.
420 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
421 */
422struct nc_rpc *nc_rpc_establishsub(const char *filter, const char *stream_name, const char *start_time,
423 const char *stop_time, const char *encoding, NC_PARAMTYPE paramtype);
424
425/**
426 * @brief Create NETCONF RPC \<modify-subscription\>
427 *
428 * For details, see ::nc_rpc.
429 *
430 * @param[in] id Subscription ID to modify.
431 * @param[in] filter Optional new filter data, an XML subtree, XPath expression (with JSON prefixes),
432 * or filter reference, selected based on the first character.
433 * @param[in] stop_time Optional new YANG datetime identifying the end of the subscription.
434 * @param[in] paramtype How to further manage data parameters.
435 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
436 */
437struct nc_rpc *nc_rpc_modifysub(uint32_t id, const char *filter, const char *stop_time, NC_PARAMTYPE paramtype);
438
439/**
440 * @brief Create NETCONF RPC \<delete-subscription\>
441 *
442 * For details, see ::nc_rpc.
443 *
444 * @param[in] id Subscription ID to delete.
445 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
446 */
447struct nc_rpc *nc_rpc_deletesub(uint32_t id);
448
449/**
450 * @brief Create NETCONF RPC \<kill-subscription\>
451 *
452 * For details, see ::nc_rpc.
453 *
454 * @param[in] id Subscription ID to kill.
455 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
456 */
457struct nc_rpc *nc_rpc_killsub(uint32_t id);
Michal Vaskoc1171a42019-11-05 12:06:46 +0100458
459/**
Michal Vasko305faca2021-03-25 09:16:02 +0100460 * @brief Create NETCONF RPC \<establish-subscription\> with augments from ietf-yang-push for a periodic subscription
461 *
462 * For details, see ::nc_rpc.
463 *
464 * @param[in] datastore Source datastore, foreign identity so a module name prefix is required.
465 * @param[in] filter Optional filter data, an XML subtree, XPath expression (with JSON prefixes),
466 * or filter reference, selected based on the first character.
467 * @param[in] stop_time Optional YANG datetime identifying the end of the subscription.
468 * @param[in] encoding Optional specific encoding to use.
469 * @param[in] period Subscription period in centiseconds (0.01s).
470 * @param[in] anchor_time Optional anchor datetime for the period.
471 * @param[in] paramtype How to further manage data parameters.
472 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
473 */
474struct nc_rpc *nc_rpc_establishpush_periodic(const char *datastore, const char *filter, const char *stop_time,
475 const char *encoding, uint32_t period, const char *anchor_time, NC_PARAMTYPE paramtype);
476
477/**
478 * @brief Create NETCONF RPC \<establish-subscription\> with augments from ietf-yang-push for an on-change subscription
479 *
480 * For details, see ::nc_rpc.
481 *
482 * @param[in] datastore Source datastore, foreign identity so a module name prefix is required.
483 * @param[in] filter Optional filter data, an XML subtree, XPath expression (with JSON prefixes),
484 * or filter reference, selected based on the first character.
485 * @param[in] stop_time Optional YANG datetime identifying the end of the subscription.
486 * @param[in] encoding Optional specific encoding to use.
487 * @param[in] dampening_period Optional dampening period of the notifications.
488 * @param[in] sync_on_start Whether to send a full push-update notification on subscription start.
489 * @param[in] excluded_change Optional NULL-terminated array of excluded changes.
490 * @param[in] paramtype How to further manage data parameters.
491 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
492 */
493struct nc_rpc *nc_rpc_establishpush_onchange(const char *datastore, const char *filter, const char *stop_time,
494 const char *encoding, uint32_t dampening_period, int sync_on_start, const char **excluded_change,
495 NC_PARAMTYPE paramtype);
496
497/**
498 * @brief Create NETCONF RPC \<modify-subscription\> with augments from ietf-yang-push for a periodic subscription
499 *
500 * For details, see ::nc_rpc.
501 *
502 * @param[in] id Subscription ID to modify.
503 * @param[in] datastore Source datastore, foreign identity so a module name prefix is required.
504 * @param[in] filter Optional filter data, an XML subtree, XPath expression (with JSON prefixes),
505 * or filter reference, selected based on the first character.
506 * @param[in] stop_time Optional YANG datetime identifying the end of the subscription.
507 * @param[in] period Subscription period in centiseconds (0.01s).
508 * @param[in] anchor_time Optional anchor datetime for the period.
509 * @param[in] paramtype How to further manage data parameters.
510 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
511 */
512struct nc_rpc *nc_rpc_modifypush_periodic(uint32_t id, const char *datastore, const char *filter, const char *stop_time,
513 uint32_t period, const char *anchor_time, NC_PARAMTYPE paramtype);
514
515/**
516 * @brief Create NETCONF RPC \<modify-subscription\> with augments from ietf-yang-push for an on-change subscription
517 *
518 * For details, see ::nc_rpc.
519 *
520 * @param[in] id Subscription ID to modify.
521 * @param[in] datastore Source datastore, foreign identity so a module name prefix is required.
522 * @param[in] filter Optional filter data, an XML subtree, XPath expression (with JSON prefixes),
523 * or filter reference, selected based on the first character.
524 * @param[in] stop_time Optional YANG datetime identifying the end of the subscription.
525 * @param[in] dampening_period Optional dampening period of the notifications.
526 * @param[in] paramtype How to further manage data parameters.
527 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
528 */
529struct nc_rpc *nc_rpc_modifypush_onchange(uint32_t id, const char *datastore, const char *filter, const char *stop_time,
530 uint32_t dampening_period, NC_PARAMTYPE paramtype);
531
532/**
533 * @brief Create NETCONF RPC \<resync-subscription\>
534 *
535 * For details, see ::nc_rpc.
536 *
537 * @param[in] id Subscription ID to resync.
538 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
539 */
540struct nc_rpc *nc_rpc_resyncsub(uint32_t id);
541
542/**
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100543 * @brief Free the NETCONF RPC object.
Michal Vaskof0537d82016-01-29 14:42:38 +0100544 *
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100545 * @param[in] rpc Object to free.
546 */
547void nc_rpc_free(struct nc_rpc *rpc);
548
Michal Vasko77367452021-02-16 16:32:18 +0100549/** @} Client Messages */
Radek Krejci6799a052017-05-19 14:23:23 +0200550
Michal Vaskoc09730e2019-01-17 10:07:26 +0100551#ifdef __cplusplus
552}
553#endif
554
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100555#endif /* NC_MESSAGES_CLIENT_H_ */