blob: 89d794c164a724aa1eda1f5f6762911cb7490fb6 [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 Vasko95ea9ff2021-11-09 12:29:14 +01007 * @copyright
Michal Vaskoc446a382021-06-18 08:54:05 +02008 * Copyright (c) 2015 - 2021 CESNET, z.s.p.o.
Michal Vasko7bcb48e2016-01-15 10:28:54 +01009 *
Radek Krejci9b81f5b2016-02-24 13:14:49 +010010 * This source code is licensed under BSD 3-Clause License (the "License").
11 * You may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
Michal Vaskoafd416b2016-02-25 14:51:46 +010013 *
Radek Krejci9b81f5b2016-02-24 13:14:49 +010014 * https://opensource.org/licenses/BSD-3-Clause
Michal Vasko7bcb48e2016-01-15 10:28:54 +010015 */
16
17#ifndef NC_MESSAGES_CLIENT_H_
18#define NC_MESSAGES_CLIENT_H_
19
Michal Vaskoc09730e2019-01-17 10:07:26 +010020#ifdef __cplusplus
21extern "C" {
22#endif
23
Michal Vasko7bcb48e2016-01-15 10:28:54 +010024#include <stdint.h>
25
26#include "netconf.h"
27
Michal Vaskof0537d82016-01-29 14:42:38 +010028/**
Radek Krejci6799a052017-05-19 14:23:23 +020029 * @defgroup client_msg Client Messages
30 * @ingroup client
31 *
32 * @brief Functions to create NETCONF RPCs (or actions) and process replies received from the server.
33 * @{
34 */
35
36/**
Michal Vaskof0537d82016-01-29 14:42:38 +010037 * @brief Enumeration of RPC types
Radek Krejci6799a052017-05-19 14:23:23 +020038 *
39 * 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 +010040 */
Michal Vasko7bcb48e2016-01-15 10:28:54 +010041typedef enum {
Michal Vasko7f1c78b2016-01-19 09:52:14 +010042 NC_RPC_UNKNOWN = 0, /**< invalid RPC. */
Michal Vasko90e8e692016-07-13 12:27:57 +020043 NC_RPC_ACT_GENERIC, /**< user-defined generic RPC/action. */
Michal Vasko7bcb48e2016-01-15 10:28:54 +010044
45 /* ietf-netconf */
46 NC_RPC_GETCONFIG, /**< \<get-config\> RPC. */
47 NC_RPC_EDIT, /**< \<edit-config\> RPC. */
48 NC_RPC_COPY, /**< \<copy-config\> RPC. */
49 NC_RPC_DELETE, /**< \<delete-config\> RPC. */
50 NC_RPC_LOCK, /**< \<lock\> RPC. */
51 NC_RPC_UNLOCK, /**< \<unlock\> RPC. */
52 NC_RPC_GET, /**< \<get\> RPC. */
Michal Vasko7bcb48e2016-01-15 10:28:54 +010053 NC_RPC_KILL, /**< \<kill-session\> RPC. */
54 NC_RPC_COMMIT, /**< \<commit\> RPC. */
55 NC_RPC_DISCARD, /**< \<discard-changes\> RPC. */
56 NC_RPC_CANCEL, /**< \<cancel-commit\> RPC. */
57 NC_RPC_VALIDATE, /**< \<validate\> RPC. */
58
59 /* ietf-netconf-monitoring */
60 NC_RPC_GETSCHEMA, /**< \<get-schema\> RPC. */
61
62 /* notifications */
Michal Vaskoc1171a42019-11-05 12:06:46 +010063 NC_RPC_SUBSCRIBE, /**< \<create-subscription\> RPC. */
64
65 /* ietf-netconf-nmda */
66 NC_RPC_GETDATA, /**< \<get-data\> RPC. */
67 NC_RPC_EDITDATA, /**< \<edit-data\> RPC. */
Michal Vasko96f247a2021-03-15 13:32:10 +010068
69 /* ietf-subscribed-notifications */
70 NC_RPC_ESTABLISHSUB, /**< \<establish-subscription\> RPC. */
71 NC_RPC_MODIFYSUB, /**< \<modify-subscription\> RPC. */
72 NC_RPC_DELETESUB, /**< \<delete-subscription\> RPC. */
73 NC_RPC_KILLSUB, /**< \<kill-subscription\> RPC. */
Michal Vasko305faca2021-03-25 09:16:02 +010074
75 /* ietf-yang-push */
76 NC_RPC_ESTABLISHPUSH, /**< \<establish-subscription\> RPC with augments. */
77 NC_RPC_MODIFYPUSH, /**< \<modify-subscription\> RPC with augments. */
Michal Vaskob83a3fa2021-05-26 09:53:42 +020078 NC_RPC_RESYNCSUB /**< \<resync-subscription\> RPC. */
Michal Vasko7bcb48e2016-01-15 10:28:54 +010079} NC_RPC_TYPE;
80
Michal Vaskof0537d82016-01-29 14:42:38 +010081/**
82 * @brief Enumeration of \<edit-config\> default operation
83 */
Michal Vasko7bcb48e2016-01-15 10:28:54 +010084typedef enum {
Michal Vaskof0537d82016-01-29 14:42:38 +010085 NC_RPC_EDIT_DFLTOP_UNKNOWN = 0, /**< unknown default operation */
86 NC_RPC_EDIT_DFLTOP_MERGE, /**< default operation merge */
87 NC_RPC_EDIT_DFLTOP_REPLACE, /**< default operation replace */
88 NC_RPC_EDIT_DFLTOP_NONE /**< default operation none */
Michal Vasko7bcb48e2016-01-15 10:28:54 +010089} NC_RPC_EDIT_DFLTOP;
90
Michal Vaskof0537d82016-01-29 14:42:38 +010091/**
92 * @brief Enumeration of \<edit-config\> test option
93 */
Michal Vasko7bcb48e2016-01-15 10:28:54 +010094typedef enum {
Michal Vaskof0537d82016-01-29 14:42:38 +010095 NC_RPC_EDIT_TESTOPT_UNKNOWN = 0, /**< unknown test option */
96 NC_RPC_EDIT_TESTOPT_TESTSET, /**< test-then-set option */
97 NC_RPC_EDIT_TESTOPT_SET, /**< set option */
98 NC_RPC_EDIT_TESTOPT_TEST /**< test-only option */
Michal Vasko7bcb48e2016-01-15 10:28:54 +010099} NC_RPC_EDIT_TESTOPT;
100
Michal Vaskof0537d82016-01-29 14:42:38 +0100101/**
102 * @brief Enumeration of \<edit-config\> error option
103 */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100104typedef enum {
Michal Vaskof0537d82016-01-29 14:42:38 +0100105 NC_RPC_EDIT_ERROPT_UNKNOWN = 0, /**< unknown error option */
106 NC_RPC_EDIT_ERROPT_STOP, /**< stop-on-error option */
107 NC_RPC_EDIT_ERROPT_CONTINUE, /**< continue-on-error option */
108 NC_RPC_EDIT_ERROPT_ROLLBACK /**< rollback-on-error option */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100109} NC_RPC_EDIT_ERROPT;
110
111/**
112 * @brief NETCONF error structure representation
113 */
114struct nc_err {
Radek Krejci6799a052017-05-19 14:23:23 +0200115 /** @brief \<error-type\>, error layer where the error occurred. */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100116 const char *type;
Radek Krejci6799a052017-05-19 14:23:23 +0200117 /** @brief \<error-tag\>. */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100118 const char *tag;
Radek Krejci6799a052017-05-19 14:23:23 +0200119 /** @brief \<error-severity\>. */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100120 const char *severity;
Radek Krejci6799a052017-05-19 14:23:23 +0200121 /** @brief \<error-app-tag\>, the data-model-specific or implementation-specific error condition, if one exists. */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100122 const char *apptag;
Radek Krejci6799a052017-05-19 14:23:23 +0200123 /** @brief \<error-path\>, XPATH expression identifying the element with the error. */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100124 const char *path;
Radek Krejci6799a052017-05-19 14:23:23 +0200125 /** @brief \<error-message\>, Human-readable description of the error. */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100126 const char *message;
Radek Krejci6799a052017-05-19 14:23:23 +0200127 /** @brief xml:lang attribute of the error-message. */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100128 const char *message_lang;
129
130 /* <error-info> */
131
Radek Krejci6799a052017-05-19 14:23:23 +0200132 /** @brief \<session-id\>, session ID of the session holding the requested lock. Part of \<error-info\>. */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100133 const char *sid;
Radek Krejci6799a052017-05-19 14:23:23 +0200134 /** @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 +0100135 const char **attr;
Radek Krejci6799a052017-05-19 14:23:23 +0200136 /** @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 +0100137 const char **elem;
Radek Krejci6799a052017-05-19 14:23:23 +0200138 /** @brief \<bad-namespace\>, array of the unexpected XML namespaces that caused the error. Part of \<error-info\>. */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100139 const char **ns;
Michal Vasko77367452021-02-16 16:32:18 +0100140 /** @brief List of the remaining non-standard opaque nodes. */
141 struct lyd_node *other;
Radek Krejci6799a052017-05-19 14:23:23 +0200142
143 /** @brief Number of items in the attr array */
144 uint16_t attr_count;
145 /** @brief Number of items in the elem array */
146 uint16_t elem_count;
147 /** @brief Number of items in the ns array */
148 uint16_t ns_count;
149 /** @brief Number of items in the other array */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100150 uint16_t other_count;
151};
152
153/**
Michal Vasko96f247a2021-03-15 13:32:10 +0100154 * @struct nc_rpc
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100155 * @brief NETCONF client RPC object
Michal Vasko96f247a2021-03-15 13:32:10 +0100156 *
157 * Note that any stored parameters are not checked for validity because it is performed later,
158 * while sending the RPC via a specific NETCONF session (::nc_send_rpc()) since the NETCONF
159 * capabilities of the session are needed for such a check. An RPC object can be sent via any
160 * NETCONF session which supports all the needed NETCONF capabilities for the RPC.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100161 */
162struct nc_rpc;
163
Michal Vasko1a38c862016-01-15 15:50:07 +0100164/**
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100165 * @brief Get the type of the RPC
166 *
167 * @param[in] rpc RPC to check the type of.
Michal Vaskoc446a382021-06-18 08:54:05 +0200168 * @return Type of @p rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100169 */
170NC_RPC_TYPE nc_rpc_get_type(const struct nc_rpc *rpc);
171
172/**
Michal Vasko90e8e692016-07-13 12:27:57 +0200173 * @brief Create a generic NETCONF RPC or action
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100174 *
175 * Note that created object can be sent via any NETCONF session that shares the context
Michal Vaskoc446a382021-06-18 08:54:05 +0200176 * of the @p data.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100177 *
Michal Vasko70bf2222021-10-26 10:45:15 +0200178 * @note In case of action, the \<action\> element is added automatically and should not be in @p data.
179 *
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100180 * @param[in] data NETCONF RPC data as a data tree.
181 * @param[in] paramtype How to further manage data parameters.
182 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
183 */
Michal Vasko90e8e692016-07-13 12:27:57 +0200184struct nc_rpc *nc_rpc_act_generic(const struct lyd_node *data, NC_PARAMTYPE paramtype);
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100185
186/**
Michal Vasko90e8e692016-07-13 12:27:57 +0200187 * @brief Create a generic NETCONF RPC or action from an XML string
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100188 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100189 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100190 *
Michal Vasko70bf2222021-10-26 10:45:15 +0200191 * @note In case of action, the \<action\> element is added automatically and should not be in @p xml_str.
192 *
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100193 * @param[in] xml_str NETCONF RPC data as an XML string.
194 * @param[in] paramtype How to further manage data parameters.
195 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
196 */
Michal Vasko90e8e692016-07-13 12:27:57 +0200197struct nc_rpc *nc_rpc_act_generic_xml(const char *xml_str, NC_PARAMTYPE paramtype);
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100198
199/**
200 * @brief Create NETCONF RPC \<get-config\>
201 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100202 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100203 *
204 * @param[in] source Source datastore being queried.
Michal Vaskoc2389702017-08-09 10:16:49 +0200205 * @param[in] filter Optional filter data, an XML subtree or XPath expression (with JSON prefixes).
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100206 * @param[in] wd_mode Optional with-defaults capability mode.
207 * @param[in] paramtype How to further manage data parameters.
208 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
209 */
210struct nc_rpc *nc_rpc_getconfig(NC_DATASTORE source, const char *filter, NC_WD_MODE wd_mode,
Michal Vasko96f247a2021-03-15 13:32:10 +0100211 NC_PARAMTYPE paramtype);
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100212
213/**
214 * @brief Create NETCONF RPC \<edit-config\>
215 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100216 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100217 *
218 * @param[in] target Target datastore being edited.
219 * @param[in] default_op Optional default operation.
220 * @param[in] test_opt Optional test option.
221 * @param[in] error_opt Optional error option.
222 * @param[in] edit_content Config or URL where the config to perform is to be found.
223 * @param[in] paramtype How to further manage data parameters.
224 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
225 */
226struct 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 +0100227 NC_RPC_EDIT_ERROPT error_opt, const char *edit_content, NC_PARAMTYPE paramtype);
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100228
229/**
230 * @brief Create NETCONF RPC \<copy-config\>
231 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100232 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100233 *
234 * @param[in] target Target datastore.
Michal Vaskoc446a382021-06-18 08:54:05 +0200235 * @param[in] url_trg Used instead @p target if the target is an URL.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100236 * @param[in] source Source datastore.
Michal Vaskoc446a382021-06-18 08:54:05 +0200237 * @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 +0100238 * @param[in] wd_mode Optional with-defaults capability mode.
239 * @param[in] paramtype How to further manage data parameters.
240 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
241 */
242struct nc_rpc *nc_rpc_copy(NC_DATASTORE target, const char *url_trg, NC_DATASTORE source,
Michal Vasko96f247a2021-03-15 13:32:10 +0100243 const char *url_or_config_src, NC_WD_MODE wd_mode, NC_PARAMTYPE paramtype);
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100244
245/**
246 * @brief Create NETCONF RPC \<delete-config\>
247 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100248 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100249 *
250 * @param[in] target Target datastore to delete.
Michal Vaskoc446a382021-06-18 08:54:05 +0200251 * @param[in] url Used instead @p target if the target is an URL.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100252 * @param[in] paramtype How to further manage data parameters.
253 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
254 */
255struct nc_rpc *nc_rpc_delete(NC_DATASTORE target, const char *url, NC_PARAMTYPE paramtype);
256
257/**
258 * @brief Create NETCONF RPC \<lock\>
259 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100260 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100261 *
262 * @param[in] target Target datastore of the operation.
263 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
264 */
265struct nc_rpc *nc_rpc_lock(NC_DATASTORE target);
266
267/**
268 * @brief Create NETCONF RPC \<unlock\>
269 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100270 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100271 *
272 * @param[in] target Target datastore of the operation.
273 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
274 */
275struct nc_rpc *nc_rpc_unlock(NC_DATASTORE target);
276
277/**
278 * @brief Create NETCONF RPC \<get\>
279 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100280 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100281 *
Michal Vaskoc2389702017-08-09 10:16:49 +0200282 * @param[in] filter Optional filter data, an XML subtree or XPath expression (with JSON prefixes).
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100283 * @param[in] wd_mode Optional with-defaults capability mode.
284 * @param[in] paramtype How to further manage data parameters.
285 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
286 */
287struct nc_rpc *nc_rpc_get(const char *filter, NC_WD_MODE wd_mode, NC_PARAMTYPE paramtype);
288
289/**
290 * @brief Create NETCONF RPC \<kill-session\>
291 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100292 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100293 *
294 * @param[in] session_id Session ID of the session to kill.
295 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
296 */
297struct nc_rpc *nc_rpc_kill(uint32_t session_id);
298
299/**
300 * @brief Create NETCONF RPC \<commit\>
301 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100302 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100303 *
304 * @param[in] confirmed Whether the commit is to be confirmed.
305 * @param[in] confirm_timeout Optional confirm timeout.
306 * @param[in] persist Optional identification string of a new persistent confirmed commit.
307 * @param[in] persist_id Optional identification string of a persistent confirmed commit to be commited.
308 * @param[in] paramtype How to further manage data parameters.
309 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
310 */
311struct 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 +0100312 NC_PARAMTYPE paramtype);
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100313
314/**
315 * @brief Create NETCONF RPC \<discard-changes\>
316 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100317 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100318 *
319 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
320 */
321struct nc_rpc *nc_rpc_discard(void);
322
323/**
324 * @brief Create NETCONF RPC \<cancel-commit\>
325 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100326 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100327 *
328 * @param[in] persist_id Optional identification string of a persistent confirmed commit.
329 * @param[in] paramtype How to further manage data parameters.
330 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
331 */
332struct nc_rpc *nc_rpc_cancel(const char *persist_id, NC_PARAMTYPE paramtype);
333
334/**
335 * @brief Create NETCONF RPC \<validate\>
336 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100337 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100338 *
339 * @param[in] source Source datastore being validated.
Michal Vaskoc446a382021-06-18 08:54:05 +0200340 * @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 +0100341 * @param[in] paramtype How to further manage data parameters.
342 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
343 */
344struct nc_rpc *nc_rpc_validate(NC_DATASTORE source, const char *url_or_config, NC_PARAMTYPE paramtype);
345
346/**
347 * @brief Create NETCONF RPC \<get-schema\>
348 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100349 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100350 *
351 * @param[in] identifier Requested model identifier.
352 * @param[in] version Optional model version, either YANG version (1.0/1.1) or revision date.
353 * @param[in] format Optional format of the model (default is YANG).
354 * @param[in] paramtype How to further manage data parameters.
355 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
356 */
357struct nc_rpc *nc_rpc_getschema(const char *identifier, const char *version, const char *format, NC_PARAMTYPE paramtype);
358
359/**
360 * @brief Create NETCONF RPC \<create-subscription\>
361 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100362 * For details, see ::nc_rpc.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100363 *
364 * @param[in] stream_name Optional name of a NETCONF stream to subscribe to.
Michal Vaskoc2389702017-08-09 10:16:49 +0200365 * @param[in] filter Optional filter data, an XML subtree or XPath expression (with JSON prefixes).
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100366 * @param[in] start_time Optional YANG datetime identifying the start of the subscription.
367 * @param[in] stop_time Optional YANG datetime identifying the end of the subscription.
368 * @param[in] paramtype How to further manage data parameters.
369 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
370 */
371struct nc_rpc *nc_rpc_subscribe(const char *stream_name, const char *filter, const char *start_time,
Michal Vasko96f247a2021-03-15 13:32:10 +0100372 const char *stop_time, NC_PARAMTYPE paramtype);
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100373
374/**
Michal Vaskoc1171a42019-11-05 12:06:46 +0100375 * @brief Create NETCONF RPC \<get-data\>
376 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100377 * For details, see ::nc_rpc.
Michal Vaskoc1171a42019-11-05 12:06:46 +0100378 *
379 * @param[in] datastore Source datastore, foreign identity so a module name prefix is required.
380 * @param[in] filter Optional filter data, an XML subtree or XPath expression (with JSON prefixes).
381 * @param[in] config_filter Optional config filter, "true" for config-only data, "false" for state-only data.
382 * @param[in] origin_filter Optional origin filter array, selects only nodes of this or derived origin.
Michal Vaskoc446a382021-06-18 08:54:05 +0200383 * @param[in] origin_filter_count Count of filters is @p origin_filter.
Michal Vaskoc1171a42019-11-05 12:06:46 +0100384 * @param[in] neg_origin_filter Whether origin filters are negated or not.
385 * @param[in] max_depth Maximum depth of returned subtrees, 0 for unlimited.
386 * @param[in] with_origin Whether return data origin.
387 * @param[in] wd_mode Optional with-defaults capability mode.
388 * @param[in] paramtype How to further manage data parameters.
389 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
390 */
391struct 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 +0100392 int origin_filter_count, int neg_origin_filter, uint16_t max_depth, int with_origin, NC_WD_MODE wd_mode,
393 NC_PARAMTYPE paramtype);
Michal Vaskoc1171a42019-11-05 12:06:46 +0100394
395/**
396 * @brief Create NETCONF RPC \<get-data\>
397 *
Michal Vasko96f247a2021-03-15 13:32:10 +0100398 * For details, see ::nc_rpc.
Michal Vaskoc1171a42019-11-05 12:06:46 +0100399 *
400 * @param[in] datastore Source datastore, foreign identity so a module name prefix is required.
401 * @param[in] default_op Optional default operation.
402 * @param[in] edit_content Config or URL where the config to perform is to be found.
403 * @param[in] paramtype How to further manage data parameters.
404 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
405 */
406struct 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 +0100407 NC_PARAMTYPE paramtype);
408
409/**
410 * @brief Create NETCONF RPC \<establish-subscription\>
411 *
412 * For details, see ::nc_rpc.
413 *
414 * @param[in] filter Optional filter data, an XML subtree, XPath expression (with JSON prefixes),
415 * or filter reference, selected based on the first character.
416 * @param[in] stream_name Name of a NETCONF stream to subscribe to.
417 * @param[in] start_time Optional YANG datetime identifying the start of the subscription.
418 * @param[in] stop_time Optional YANG datetime identifying the end of the subscription.
419 * @param[in] encoding Optional specific encoding to use.
420 * @param[in] paramtype How to further manage data parameters.
421 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
422 */
423struct nc_rpc *nc_rpc_establishsub(const char *filter, const char *stream_name, const char *start_time,
424 const char *stop_time, const char *encoding, NC_PARAMTYPE paramtype);
425
426/**
427 * @brief Create NETCONF RPC \<modify-subscription\>
428 *
429 * For details, see ::nc_rpc.
430 *
431 * @param[in] id Subscription ID to modify.
432 * @param[in] filter Optional new filter data, an XML subtree, XPath expression (with JSON prefixes),
433 * or filter reference, selected based on the first character.
434 * @param[in] stop_time Optional new YANG datetime identifying the end of the subscription.
435 * @param[in] paramtype How to further manage data parameters.
436 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
437 */
438struct nc_rpc *nc_rpc_modifysub(uint32_t id, const char *filter, const char *stop_time, NC_PARAMTYPE paramtype);
439
440/**
441 * @brief Create NETCONF RPC \<delete-subscription\>
442 *
443 * For details, see ::nc_rpc.
444 *
445 * @param[in] id Subscription ID to delete.
446 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
447 */
448struct nc_rpc *nc_rpc_deletesub(uint32_t id);
449
450/**
451 * @brief Create NETCONF RPC \<kill-subscription\>
452 *
453 * For details, see ::nc_rpc.
454 *
455 * @param[in] id Subscription ID to kill.
456 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
457 */
458struct nc_rpc *nc_rpc_killsub(uint32_t id);
Michal Vaskoc1171a42019-11-05 12:06:46 +0100459
460/**
Michal Vasko305faca2021-03-25 09:16:02 +0100461 * @brief Create NETCONF RPC \<establish-subscription\> with augments from ietf-yang-push for a periodic subscription
462 *
463 * For details, see ::nc_rpc.
464 *
465 * @param[in] datastore Source datastore, foreign identity so a module name prefix is required.
466 * @param[in] filter Optional filter data, an XML subtree, XPath expression (with JSON prefixes),
467 * or filter reference, selected based on the first character.
468 * @param[in] stop_time Optional YANG datetime identifying the end of the subscription.
469 * @param[in] encoding Optional specific encoding to use.
470 * @param[in] period Subscription period in centiseconds (0.01s).
471 * @param[in] anchor_time Optional anchor datetime for the period.
472 * @param[in] paramtype How to further manage data parameters.
473 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
474 */
475struct nc_rpc *nc_rpc_establishpush_periodic(const char *datastore, const char *filter, const char *stop_time,
476 const char *encoding, uint32_t period, const char *anchor_time, NC_PARAMTYPE paramtype);
477
478/**
479 * @brief Create NETCONF RPC \<establish-subscription\> with augments from ietf-yang-push for an on-change subscription
480 *
481 * For details, see ::nc_rpc.
482 *
483 * @param[in] datastore Source datastore, foreign identity so a module name prefix is required.
484 * @param[in] filter Optional filter data, an XML subtree, XPath expression (with JSON prefixes),
485 * or filter reference, selected based on the first character.
486 * @param[in] stop_time Optional YANG datetime identifying the end of the subscription.
487 * @param[in] encoding Optional specific encoding to use.
488 * @param[in] dampening_period Optional dampening period of the notifications.
489 * @param[in] sync_on_start Whether to send a full push-update notification on subscription start.
490 * @param[in] excluded_change Optional NULL-terminated array of excluded changes.
491 * @param[in] paramtype How to further manage data parameters.
492 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
493 */
494struct nc_rpc *nc_rpc_establishpush_onchange(const char *datastore, const char *filter, const char *stop_time,
495 const char *encoding, uint32_t dampening_period, int sync_on_start, const char **excluded_change,
496 NC_PARAMTYPE paramtype);
497
498/**
499 * @brief Create NETCONF RPC \<modify-subscription\> with augments from ietf-yang-push for a periodic subscription
500 *
501 * For details, see ::nc_rpc.
502 *
503 * @param[in] id Subscription ID to modify.
504 * @param[in] datastore Source datastore, foreign identity so a module name prefix is required.
505 * @param[in] filter Optional filter data, an XML subtree, XPath expression (with JSON prefixes),
506 * or filter reference, selected based on the first character.
507 * @param[in] stop_time Optional YANG datetime identifying the end of the subscription.
508 * @param[in] period Subscription period in centiseconds (0.01s).
509 * @param[in] anchor_time Optional anchor datetime for the period.
510 * @param[in] paramtype How to further manage data parameters.
511 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
512 */
513struct nc_rpc *nc_rpc_modifypush_periodic(uint32_t id, const char *datastore, const char *filter, const char *stop_time,
514 uint32_t period, const char *anchor_time, NC_PARAMTYPE paramtype);
515
516/**
517 * @brief Create NETCONF RPC \<modify-subscription\> with augments from ietf-yang-push for an on-change subscription
518 *
519 * For details, see ::nc_rpc.
520 *
521 * @param[in] id Subscription ID to modify.
522 * @param[in] datastore Source datastore, foreign identity so a module name prefix is required.
523 * @param[in] filter Optional filter data, an XML subtree, XPath expression (with JSON prefixes),
524 * or filter reference, selected based on the first character.
525 * @param[in] stop_time Optional YANG datetime identifying the end of the subscription.
526 * @param[in] dampening_period Optional dampening period of the notifications.
527 * @param[in] paramtype How to further manage data parameters.
528 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
529 */
530struct nc_rpc *nc_rpc_modifypush_onchange(uint32_t id, const char *datastore, const char *filter, const char *stop_time,
531 uint32_t dampening_period, NC_PARAMTYPE paramtype);
532
533/**
534 * @brief Create NETCONF RPC \<resync-subscription\>
535 *
536 * For details, see ::nc_rpc.
537 *
538 * @param[in] id Subscription ID to resync.
539 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
540 */
541struct nc_rpc *nc_rpc_resyncsub(uint32_t id);
542
543/**
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100544 * @brief Free the NETCONF RPC object.
Michal Vaskof0537d82016-01-29 14:42:38 +0100545 *
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100546 * @param[in] rpc Object to free.
547 */
548void nc_rpc_free(struct nc_rpc *rpc);
549
Michal Vasko77367452021-02-16 16:32:18 +0100550/** @} Client Messages */
Radek Krejci6799a052017-05-19 14:23:23 +0200551
Michal Vaskoc09730e2019-01-17 10:07:26 +0100552#ifdef __cplusplus
553}
554#endif
555
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100556#endif /* NC_MESSAGES_CLIENT_H_ */