blob: f597ee60745fa3b5618bd691f657c6028a04e0b7 [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 */
62 NC_RPC_SUBSCRIBE /**< \<create-subscription\> RPC. */
63} NC_RPC_TYPE;
64
Michal Vaskof0537d82016-01-29 14:42:38 +010065/**
66 * @brief Enumeration of \<edit-config\> default operation
67 */
Michal Vasko7bcb48e2016-01-15 10:28:54 +010068typedef enum {
Michal Vaskof0537d82016-01-29 14:42:38 +010069 NC_RPC_EDIT_DFLTOP_UNKNOWN = 0, /**< unknown default operation */
70 NC_RPC_EDIT_DFLTOP_MERGE, /**< default operation merge */
71 NC_RPC_EDIT_DFLTOP_REPLACE, /**< default operation replace */
72 NC_RPC_EDIT_DFLTOP_NONE /**< default operation none */
Michal Vasko7bcb48e2016-01-15 10:28:54 +010073} NC_RPC_EDIT_DFLTOP;
74
Michal Vaskof0537d82016-01-29 14:42:38 +010075/**
76 * @brief Enumeration of \<edit-config\> test option
77 */
Michal Vasko7bcb48e2016-01-15 10:28:54 +010078typedef enum {
Michal Vaskof0537d82016-01-29 14:42:38 +010079 NC_RPC_EDIT_TESTOPT_UNKNOWN = 0, /**< unknown test option */
80 NC_RPC_EDIT_TESTOPT_TESTSET, /**< test-then-set option */
81 NC_RPC_EDIT_TESTOPT_SET, /**< set option */
82 NC_RPC_EDIT_TESTOPT_TEST /**< test-only option */
Michal Vasko7bcb48e2016-01-15 10:28:54 +010083} NC_RPC_EDIT_TESTOPT;
84
Michal Vaskof0537d82016-01-29 14:42:38 +010085/**
86 * @brief Enumeration of \<edit-config\> error option
87 */
Michal Vasko7bcb48e2016-01-15 10:28:54 +010088typedef enum {
Michal Vaskof0537d82016-01-29 14:42:38 +010089 NC_RPC_EDIT_ERROPT_UNKNOWN = 0, /**< unknown error option */
90 NC_RPC_EDIT_ERROPT_STOP, /**< stop-on-error option */
91 NC_RPC_EDIT_ERROPT_CONTINUE, /**< continue-on-error option */
92 NC_RPC_EDIT_ERROPT_ROLLBACK /**< rollback-on-error option */
Michal Vasko7bcb48e2016-01-15 10:28:54 +010093} NC_RPC_EDIT_ERROPT;
94
95/**
96 * @brief NETCONF error structure representation
97 */
98struct nc_err {
Radek Krejci6799a052017-05-19 14:23:23 +020099 /** @brief \<error-type\>, error layer where the error occurred. */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100100 const char *type;
Radek Krejci6799a052017-05-19 14:23:23 +0200101 /** @brief \<error-tag\>. */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100102 const char *tag;
Radek Krejci6799a052017-05-19 14:23:23 +0200103 /** @brief \<error-severity\>. */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100104 const char *severity;
Radek Krejci6799a052017-05-19 14:23:23 +0200105 /** @brief \<error-app-tag\>, the data-model-specific or implementation-specific error condition, if one exists. */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100106 const char *apptag;
Radek Krejci6799a052017-05-19 14:23:23 +0200107 /** @brief \<error-path\>, XPATH expression identifying the element with the error. */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100108 const char *path;
Radek Krejci6799a052017-05-19 14:23:23 +0200109 /** @brief \<error-message\>, Human-readable description of the error. */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100110 const char *message;
Radek Krejci6799a052017-05-19 14:23:23 +0200111 /** @brief xml:lang attribute of the error-message. */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100112 const char *message_lang;
113
114 /* <error-info> */
115
Radek Krejci6799a052017-05-19 14:23:23 +0200116 /** @brief \<session-id\>, session ID of the session holding the requested lock. Part of \<error-info\>. */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100117 const char *sid;
Radek Krejci6799a052017-05-19 14:23:23 +0200118 /** @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 +0100119 const char **attr;
Radek Krejci6799a052017-05-19 14:23:23 +0200120 /** @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 +0100121 const char **elem;
Radek Krejci6799a052017-05-19 14:23:23 +0200122 /** @brief \<bad-namespace\>, array of the unexpected XML namespaces that caused the error. Part of \<error-info\>. */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100123 const char **ns;
Radek Krejci6799a052017-05-19 14:23:23 +0200124 /** @brief Array of the remaining non-standard elements. */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100125 struct lyxml_elem **other;
Radek Krejci6799a052017-05-19 14:23:23 +0200126
127 /** @brief Number of items in the attr array */
128 uint16_t attr_count;
129 /** @brief Number of items in the elem array */
130 uint16_t elem_count;
131 /** @brief Number of items in the ns array */
132 uint16_t ns_count;
133 /** @brief Number of items in the other array */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100134 uint16_t other_count;
135};
136
137/**
138 * @brief NETCONF client RPC object
139 */
140struct nc_rpc;
141
Michal Vasko1a38c862016-01-15 15:50:07 +0100142/**
143 * @brief NETCONF client rpc-reply object
144 */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100145struct nc_reply {
Michal Vaskof0537d82016-01-29 14:42:38 +0100146 NC_RPL type; /**< reply type */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100147};
148
Michal Vasko1a38c862016-01-15 15:50:07 +0100149/**
150 * @brief NETCONF client data rpc-reply object
151 */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100152struct nc_reply_data {
Michal Vasko12257e92016-11-22 09:30:37 +0100153 NC_RPL type; /**< NC_RPL_DATA */
Michal Vasko4a73f342016-11-22 09:32:10 +0100154 struct lyd_node *data; /**< libyang RPC reply data tree (output of an RPC),
Michal Vasko12257e92016-11-22 09:30:37 +0100155 \<get\> and \<get-config\> replies are special,
Michal Vasko1c042702018-11-29 08:27:51 +0100156 in those cases there is the configuration itself,
157 it should be validated as such (using \b LYD_OPT_GET or \b LYD_OPT_GETCONFIG),
158 and it can be NULL in a valid reply. */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100159};
160
Michal Vasko1a38c862016-01-15 15:50:07 +0100161/**
162 * @brief NETCONF client error rpc-reply object
163 */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100164struct nc_reply_error {
Michal Vasko1a38c862016-01-15 15:50:07 +0100165 NC_RPL type; /**< NC_RPL_ERROR */
166 const struct nc_err *err; /**< errors, any of the values inside can be NULL */
167 uint32_t count; /**< number of error structures */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100168};
169
Michal Vasko1a38c862016-01-15 15:50:07 +0100170/**
171 * @brief NETCONF client notification object
172 */
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100173struct nc_notif {
174 NC_RPL type; /**< NC_RPL_NOTIF */
175 const char *datetime; /**< eventTime of the notification */
176 struct lyd_node *tree; /**< libyang data tree of the message */
177};
178
179/**
180 * @brief Get the type of the RPC
181 *
182 * @param[in] rpc RPC to check the type of.
183 * @return Type of \p rpc.
184 */
185NC_RPC_TYPE nc_rpc_get_type(const struct nc_rpc *rpc);
186
187/**
Michal Vasko90e8e692016-07-13 12:27:57 +0200188 * @brief Create a generic NETCONF RPC or action
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100189 *
190 * Note that created object can be sent via any NETCONF session that shares the context
191 * of the \p data.
192 *
193 * @param[in] data NETCONF RPC data as a data tree.
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(const struct lyd_node *data, NC_PARAMTYPE paramtype);
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100198
199/**
Michal Vasko90e8e692016-07-13 12:27:57 +0200200 * @brief Create a generic NETCONF RPC or action from an XML string
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100201 *
202 * Note that functions to create any RPC object do not check validity of the provided
203 * parameters. It is checked later while sending the RPC via a specific NETCONF session
Michal Vaskof0537d82016-01-29 14:42:38 +0100204 * (#nc_send_rpc()) since the NETCONF capabilities of the session are needed for such a
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100205 * check. Created object can be sent via any NETCONF session which supports all the
206 * needed NETCONF capabilities for the RPC.
207 *
208 * @param[in] xml_str NETCONF RPC data as an XML string.
209 * @param[in] paramtype How to further manage data parameters.
210 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
211 */
Michal Vasko90e8e692016-07-13 12:27:57 +0200212struct nc_rpc *nc_rpc_act_generic_xml(const char *xml_str, NC_PARAMTYPE paramtype);
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100213
214/**
215 * @brief Create NETCONF RPC \<get-config\>
216 *
217 * Note that functions to create any RPC object do not check validity of the provided
218 * parameters. It is checked later while sending the RPC via a specific NETCONF session
Michal Vaskof0537d82016-01-29 14:42:38 +0100219 * (#nc_send_rpc()) since the NETCONF capabilities of the session are needed for such a
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100220 * check. Created object can be sent via any NETCONF session which supports all the
221 * needed NETCONF capabilities for the RPC.
222 *
223 * @param[in] source Source datastore being queried.
Michal Vaskoc2389702017-08-09 10:16:49 +0200224 * @param[in] filter Optional filter data, an XML subtree or XPath expression (with JSON prefixes).
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100225 * @param[in] wd_mode Optional with-defaults capability mode.
226 * @param[in] paramtype How to further manage data parameters.
227 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
228 */
229struct nc_rpc *nc_rpc_getconfig(NC_DATASTORE source, const char *filter, NC_WD_MODE wd_mode,
230 NC_PARAMTYPE paramtype);
231
232/**
233 * @brief Create NETCONF RPC \<edit-config\>
234 *
235 * Note that functions to create any RPC object do not check validity of the provided
236 * parameters. It is checked later while sending the RPC via a specific NETCONF session
Michal Vaskof0537d82016-01-29 14:42:38 +0100237 * (#nc_send_rpc()) since the NETCONF capabilities of the session are needed for such a
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100238 * check. Created object can be sent via any NETCONF session which supports all the
239 * needed NETCONF capabilities for the RPC.
240 *
241 * @param[in] target Target datastore being edited.
242 * @param[in] default_op Optional default operation.
243 * @param[in] test_opt Optional test option.
244 * @param[in] error_opt Optional error option.
245 * @param[in] edit_content Config or URL where the config to perform is to be found.
246 * @param[in] paramtype How to further manage data parameters.
247 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
248 */
249struct nc_rpc *nc_rpc_edit(NC_DATASTORE target, NC_RPC_EDIT_DFLTOP default_op, NC_RPC_EDIT_TESTOPT test_opt,
250 NC_RPC_EDIT_ERROPT error_opt, const char *edit_content, NC_PARAMTYPE paramtype);
251
252/**
253 * @brief Create NETCONF RPC \<copy-config\>
254 *
255 * Note that functions to create any RPC object do not check validity of the provided
256 * parameters. It is checked later while sending the RPC via a specific NETCONF session
Michal Vaskof0537d82016-01-29 14:42:38 +0100257 * (#nc_send_rpc()) since the NETCONF capabilities of the session are needed for such a
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100258 * check. Created object can be sent via any NETCONF session which supports all the
259 * needed NETCONF capabilities for the RPC.
260 *
261 * @param[in] target Target datastore.
262 * @param[in] url_trg Used instead \p target if the target is an URL.
263 * @param[in] source Source datastore.
264 * @param[in] url_or_config_src Used instead \p source if the source is an URL or a config.
265 * @param[in] wd_mode Optional with-defaults capability mode.
266 * @param[in] paramtype How to further manage data parameters.
267 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
268 */
269struct nc_rpc *nc_rpc_copy(NC_DATASTORE target, const char *url_trg, NC_DATASTORE source,
270 const char *url_or_config_src, NC_WD_MODE wd_mode, NC_PARAMTYPE paramtype);
271
272/**
273 * @brief Create NETCONF RPC \<delete-config\>
274 *
275 * Note that functions to create any RPC object do not check validity of the provided
276 * parameters. It is checked later while sending the RPC via a specific NETCONF session
Michal Vaskof0537d82016-01-29 14:42:38 +0100277 * (#nc_send_rpc()) since the NETCONF capabilities of the session are needed for such a
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100278 * check. Created object can be sent via any NETCONF session which supports all the
279 * needed NETCONF capabilities for the RPC.
280 *
281 * @param[in] target Target datastore to delete.
282 * @param[in] url Used instead \p target if the target is an URL.
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_delete(NC_DATASTORE target, const char *url, NC_PARAMTYPE paramtype);
287
288/**
289 * @brief Create NETCONF RPC \<lock\>
290 *
291 * Note that functions to create any RPC object do not check validity of the provided
292 * parameters. It is checked later while sending the RPC via a specific NETCONF session
Michal Vaskof0537d82016-01-29 14:42:38 +0100293 * (#nc_send_rpc()) since the NETCONF capabilities of the session are needed for such a
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100294 * check. Created object can be sent via any NETCONF session which supports all the
295 * needed NETCONF capabilities for the RPC.
296 *
297 * @param[in] target Target datastore of the operation.
298 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
299 */
300struct nc_rpc *nc_rpc_lock(NC_DATASTORE target);
301
302/**
303 * @brief Create NETCONF RPC \<unlock\>
304 *
305 * Note that functions to create any RPC object do not check validity of the provided
306 * parameters. It is checked later while sending the RPC via a specific NETCONF session
Michal Vaskof0537d82016-01-29 14:42:38 +0100307 * (#nc_send_rpc()) since the NETCONF capabilities of the session are needed for such a
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100308 * check. Created object can be sent via any NETCONF session which supports all the
309 * needed NETCONF capabilities for the RPC.
310 *
311 * @param[in] target Target datastore of the operation.
312 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
313 */
314struct nc_rpc *nc_rpc_unlock(NC_DATASTORE target);
315
316/**
317 * @brief Create NETCONF RPC \<get\>
318 *
319 * Note that functions to create any RPC object do not check validity of the provided
320 * parameters. It is checked later while sending the RPC via a specific NETCONF session
Michal Vaskof0537d82016-01-29 14:42:38 +0100321 * (#nc_send_rpc()) since the NETCONF capabilities of the session are needed for such a
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100322 * check. Created object can be sent via any NETCONF session which supports all the
323 * needed NETCONF capabilities for the RPC.
324 *
Michal Vaskoc2389702017-08-09 10:16:49 +0200325 * @param[in] filter Optional filter data, an XML subtree or XPath expression (with JSON prefixes).
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100326 * @param[in] wd_mode Optional with-defaults capability mode.
327 * @param[in] paramtype How to further manage data parameters.
328 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
329 */
330struct nc_rpc *nc_rpc_get(const char *filter, NC_WD_MODE wd_mode, NC_PARAMTYPE paramtype);
331
332/**
333 * @brief Create NETCONF RPC \<kill-session\>
334 *
335 * Note that functions to create any RPC object do not check validity of the provided
336 * parameters. It is checked later while sending the RPC via a specific NETCONF session
Michal Vaskof0537d82016-01-29 14:42:38 +0100337 * (#nc_send_rpc()) since the NETCONF capabilities of the session are needed for such a
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100338 * check. Created object can be sent via any NETCONF session which supports all the
339 * needed NETCONF capabilities for the RPC.
340 *
341 * @param[in] session_id Session ID of the session to kill.
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_kill(uint32_t session_id);
345
346/**
347 * @brief Create NETCONF RPC \<commit\>
348 *
349 * Note that functions to create any RPC object do not check validity of the provided
350 * parameters. It is checked later while sending the RPC via a specific NETCONF session
Michal Vaskof0537d82016-01-29 14:42:38 +0100351 * (#nc_send_rpc()) since the NETCONF capabilities of the session are needed for such a
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100352 * check. Created object can be sent via any NETCONF session which supports all the
353 * needed NETCONF capabilities for the RPC.
354 *
355 * @param[in] confirmed Whether the commit is to be confirmed.
356 * @param[in] confirm_timeout Optional confirm timeout.
357 * @param[in] persist Optional identification string of a new persistent confirmed commit.
358 * @param[in] persist_id Optional identification string of a persistent confirmed commit to be commited.
359 * @param[in] paramtype How to further manage data parameters.
360 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
361 */
362struct nc_rpc *nc_rpc_commit(int confirmed, uint32_t confirm_timeout, const char *persist, const char *persist_id,
363 NC_PARAMTYPE paramtype);
364
365/**
366 * @brief Create NETCONF RPC \<discard-changes\>
367 *
368 * Note that functions to create any RPC object do not check validity of the provided
369 * parameters. It is checked later while sending the RPC via a specific NETCONF session
Michal Vaskof0537d82016-01-29 14:42:38 +0100370 * (#nc_send_rpc()) since the NETCONF capabilities of the session are needed for such a
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100371 * check. Created object can be sent via any NETCONF session which supports all the
372 * needed NETCONF capabilities for the RPC.
373 *
374 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
375 */
376struct nc_rpc *nc_rpc_discard(void);
377
378/**
379 * @brief Create NETCONF RPC \<cancel-commit\>
380 *
381 * Note that functions to create any RPC object do not check validity of the provided
382 * parameters. It is checked later while sending the RPC via a specific NETCONF session
Michal Vaskof0537d82016-01-29 14:42:38 +0100383 * (#nc_send_rpc()) since the NETCONF capabilities of the session are needed for such a
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100384 * check. Created object can be sent via any NETCONF session which supports all the
385 * needed NETCONF capabilities for the RPC.
386 *
387 * @param[in] persist_id Optional identification string of a persistent confirmed commit.
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_cancel(const char *persist_id, NC_PARAMTYPE paramtype);
392
393/**
394 * @brief Create NETCONF RPC \<validate\>
395 *
396 * Note that functions to create any RPC object do not check validity of the provided
397 * parameters. It is checked later while sending the RPC via a specific NETCONF session
Michal Vaskof0537d82016-01-29 14:42:38 +0100398 * (#nc_send_rpc()) since the NETCONF capabilities of the session are needed for such a
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100399 * check. Created object can be sent via any NETCONF session which supports all the
400 * needed NETCONF capabilities for the RPC.
401 *
402 * @param[in] source Source datastore being validated.
Michal Vasko4aade752016-02-18 13:24:38 +0100403 * @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 +0100404 * @param[in] paramtype How to further manage data parameters.
405 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
406 */
407struct nc_rpc *nc_rpc_validate(NC_DATASTORE source, const char *url_or_config, NC_PARAMTYPE paramtype);
408
409/**
410 * @brief Create NETCONF RPC \<get-schema\>
411 *
412 * Note that functions to create any RPC object do not check validity of the provided
413 * parameters. It is checked later while sending the RPC via a specific NETCONF session
Michal Vaskof0537d82016-01-29 14:42:38 +0100414 * (#nc_send_rpc()) since the NETCONF capabilities of the session are needed for such a
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100415 * check. Created object can be sent via any NETCONF session which supports all the
416 * needed NETCONF capabilities for the RPC.
417 *
418 * @param[in] identifier Requested model identifier.
419 * @param[in] version Optional model version, either YANG version (1.0/1.1) or revision date.
420 * @param[in] format Optional format of the model (default is YANG).
421 * @param[in] paramtype How to further manage data parameters.
422 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
423 */
424struct nc_rpc *nc_rpc_getschema(const char *identifier, const char *version, const char *format, NC_PARAMTYPE paramtype);
425
426/**
427 * @brief Create NETCONF RPC \<create-subscription\>
428 *
429 * Note that functions to create any RPC object do not check validity of the provided
430 * parameters. It is checked later while sending the RPC via a specific NETCONF session
Michal Vaskof0537d82016-01-29 14:42:38 +0100431 * (#nc_send_rpc()) since the NETCONF capabilities of the session are needed for such a
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100432 * check. Created object can be sent via any NETCONF session which supports all the
433 * needed NETCONF capabilities for the RPC.
434 *
435 * @param[in] stream_name Optional name of a NETCONF stream to subscribe to.
Michal Vaskoc2389702017-08-09 10:16:49 +0200436 * @param[in] filter Optional filter data, an XML subtree or XPath expression (with JSON prefixes).
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100437 * @param[in] start_time Optional YANG datetime identifying the start of the subscription.
438 * @param[in] stop_time Optional YANG datetime identifying the end of the subscription.
439 * @param[in] paramtype How to further manage data parameters.
440 * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error.
441 */
442struct nc_rpc *nc_rpc_subscribe(const char *stream_name, const char *filter, const char *start_time,
Michal Vasko12257e92016-11-22 09:30:37 +0100443 const char *stop_time, NC_PARAMTYPE paramtype);
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100444
445/**
446 * @brief Free the NETCONF RPC object.
Michal Vaskof0537d82016-01-29 14:42:38 +0100447 *
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100448 * @param[in] rpc Object to free.
449 */
450void nc_rpc_free(struct nc_rpc *rpc);
451
452/**
453 * @brief Free the NETCONF RPC reply object.
Michal Vaskof0537d82016-01-29 14:42:38 +0100454 *
455 * @param[in] reply Object to free.
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100456 */
457void nc_reply_free(struct nc_reply *reply);
458
Michal Vasko1a38c862016-01-15 15:50:07 +0100459/**
460 * @brief Free the NETCONF Notification object.
Michal Vaskof0537d82016-01-29 14:42:38 +0100461 *
462 * @param[in] notif Object to free.
Michal Vasko1a38c862016-01-15 15:50:07 +0100463 */
464void nc_notif_free(struct nc_notif *notif);
465
Radek Krejci6799a052017-05-19 14:23:23 +0200466/**@} Client Messages */
467
Michal Vaskoc09730e2019-01-17 10:07:26 +0100468#ifdef __cplusplus
469}
470#endif
471
Michal Vasko7bcb48e2016-01-15 10:28:54 +0100472#endif /* NC_MESSAGES_CLIENT_H_ */