blob: 5bf3d3aa5a25f2149964e18cb375838a100f21d5 [file] [log] [blame]
Radek Krejci206fcd62015-10-07 15:42:48 +02001/**
Michal Vaskoc446a382021-06-18 08:54:05 +02002 * @file messages_p.h
3 * @author Radek Krejci <rkrejci@cesnet.cz>
4 * @brief libnetconf2's private functions and structures of NETCONF messages.
Radek Krejci206fcd62015-10-07 15:42:48 +02005 *
Michal Vasko95ea9ff2021-11-09 12:29:14 +01006 * @copyright
Michal Vaskoc446a382021-06-18 08:54:05 +02007 * Copyright (c) 2021 CESNET, z.s.p.o.
Radek Krejci206fcd62015-10-07 15:42:48 +02008 *
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
Radek Krejci206fcd62015-10-07 15:42:48 +020014 */
15
16#ifndef NC_MESSAGES_P_H_
17#define NC_MESSAGES_P_H_
18
roman3f9b65c2023-06-05 14:26:58 +020019#include <stdint.h>
20
Radek Krejci206fcd62015-10-07 15:42:48 +020021#include <libyang/libyang.h>
22
Michal Vasko7bcb48e2016-01-15 10:28:54 +010023#include "messages_client.h"
Michal Vaskob83a3fa2021-05-26 09:53:42 +020024#include "messages_server.h"
roman3f9b65c2023-06-05 14:26:58 +020025#include "netconf.h"
Radek Krejci43390242015-10-08 15:34:04 +020026
Michal Vaskoad928112015-11-25 15:52:10 +010027extern const char *rpcedit_dfltop2str[];
28extern const char *rpcedit_testopt2str[];
29extern const char *rpcedit_erropt2str[];
30
Michal Vasko05ba9df2016-01-13 14:40:27 +010031struct nc_server_reply {
32 NC_RPL type;
33};
34
35struct nc_server_reply_data {
36 NC_RPL type;
37 struct lyd_node *data;
Michal Vasko77367452021-02-16 16:32:18 +010038 int free;
Radek Krejci36dfdb32016-09-01 16:56:35 +020039 NC_WD_MODE wd;
Michal Vasko05ba9df2016-01-13 14:40:27 +010040};
41
42struct nc_server_reply_error {
43 NC_RPL type;
Michal Vasko77367452021-02-16 16:32:18 +010044 struct lyd_node *err;
Michal Vasko05ba9df2016-01-13 14:40:27 +010045};
Radek Krejci695d4fa2015-10-22 13:23:54 +020046
Michal Vaskoad611702015-12-03 13:41:51 +010047struct nc_server_rpc {
Michal Vasko77367452021-02-16 16:32:18 +010048 struct lyd_node *envp; /**< NETCONF-specific RPC envelopes */
49 struct lyd_node *rpc; /**< RPC data tree */
Radek Krejci695d4fa2015-10-22 13:23:54 +020050};
51
Radek Krejci93e80222016-10-03 13:34:25 +020052struct nc_server_notif {
53 char *eventtime; /**< eventTime of the notification */
Michal Vasko77367452021-02-16 16:32:18 +010054 struct lyd_node *ntf; /**< notification data tree of the message */
Michal Vaskofc9dbdd2017-03-17 09:27:57 +010055 int free;
Radek Krejci93e80222016-10-03 13:34:25 +020056};
57
Michal Vasko1a38c862016-01-15 15:50:07 +010058struct nc_client_reply_error {
59 NC_RPL type;
60 struct nc_err *err;
61 uint32_t count;
62 struct ly_ctx *ctx;
63};
64
Michal Vasko2a3eef02015-12-11 14:38:34 +010065struct nc_rpc {
66 NC_RPC_TYPE type;
Michal Vaskoad928112015-11-25 15:52:10 +010067};
68
Michal Vasko90e8e692016-07-13 12:27:57 +020069struct nc_rpc_act_generic {
70 NC_RPC_TYPE type; /**< NC_RPC_ACT_GENERIC */
Michal Vasko2a3eef02015-12-11 14:38:34 +010071 int has_data; /**< 1 for content.data, 0 for content.xml_str */
Michal Vasko6ce8e822022-08-02 15:09:17 +020072
Michal Vasko2a3eef02015-12-11 14:38:34 +010073 union {
74 struct lyd_node *data; /**< parsed RPC data */
75 char *xml_str; /**< raw XML string */
76 } content;
Michal Vaskoad611702015-12-03 13:41:51 +010077 char free;
Radek Krejci926a5742015-10-31 17:50:49 +010078};
79
Radek Krejci695d4fa2015-10-22 13:23:54 +020080struct nc_rpc_getconfig {
81 NC_RPC_TYPE type; /**< NC_RPC_GETCONFIG */
82 NC_DATASTORE source; /**< NETCONF datastore being queried */
Michal Vaskoad611702015-12-03 13:41:51 +010083 char *filter; /**< either XML subtree (starts with '<') or an XPath (starts with '/' or an alpha) */
Michal Vasko807be232015-12-09 15:24:55 +010084 NC_WD_MODE wd_mode;
Michal Vaskoad611702015-12-03 13:41:51 +010085 char free;
Radek Krejci695d4fa2015-10-22 13:23:54 +020086};
87
Michal Vaskoad928112015-11-25 15:52:10 +010088struct nc_rpc_edit {
89 NC_RPC_TYPE type; /**< NC_RPC_EDIT */
90 NC_DATASTORE target;
91 NC_RPC_EDIT_DFLTOP default_op;
92 NC_RPC_EDIT_TESTOPT test_opt;
93 NC_RPC_EDIT_ERROPT error_opt;
94 char *edit_cont; /**< either URL (starts with aplha) or config (starts with '<') */
Michal Vaskoad611702015-12-03 13:41:51 +010095 char free;
Michal Vaskoad928112015-11-25 15:52:10 +010096};
97
98struct nc_rpc_copy {
99 NC_RPC_TYPE type; /**< NC_RPC_COPY */
100 NC_DATASTORE target;
101 char *url_trg;
102 NC_DATASTORE source;
103 char *url_config_src; /**< either URL (starts with aplha) or config (starts with '<') */
Michal Vasko807be232015-12-09 15:24:55 +0100104 NC_WD_MODE wd_mode;
Michal Vaskoad611702015-12-03 13:41:51 +0100105 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100106};
107
108struct nc_rpc_delete {
109 NC_RPC_TYPE type; /**< NC_RPC_DELETE */
110 NC_DATASTORE target;
111 char *url;
Michal Vaskoad611702015-12-03 13:41:51 +0100112 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100113};
114
Radek Krejci695d4fa2015-10-22 13:23:54 +0200115struct nc_rpc_lock {
116 NC_RPC_TYPE type; /**< NC_RPC_LOCK or NC_RPC_UNLOCK */
117 NC_DATASTORE target;
Radek Krejci206fcd62015-10-07 15:42:48 +0200118};
119
Michal Vaskoad928112015-11-25 15:52:10 +0100120struct nc_rpc_get {
121 NC_RPC_TYPE type; /**< NC_RPC_GET */
Michal Vaskoad611702015-12-03 13:41:51 +0100122 char *filter; /**< either XML subtree (starts with '<') or an XPath (starts with '/' or an alpha) */
Michal Vasko807be232015-12-09 15:24:55 +0100123 NC_WD_MODE wd_mode;
Michal Vaskoad611702015-12-03 13:41:51 +0100124 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100125};
126
127struct nc_rpc_kill {
128 NC_RPC_TYPE type; /**< NC_RPC_KILL */
129 uint32_t sid;
130};
131
132struct nc_rpc_commit {
133 NC_RPC_TYPE type; /**< NC_RPC_COMMIT */
134 int confirmed;
135 uint32_t confirm_timeout;
136 char *persist;
137 char *persist_id;
Michal Vaskoad611702015-12-03 13:41:51 +0100138 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100139};
140
141struct nc_rpc_cancel {
142 NC_RPC_TYPE type; /**< NC_RPC_CANCEL */
143 char *persist_id;
Michal Vaskoad611702015-12-03 13:41:51 +0100144 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100145};
146
147struct nc_rpc_validate {
148 NC_RPC_TYPE type; /**< NC_RPC_VALIDATE */
149 NC_DATASTORE source;
150 char *url_config_src; /**< either URL (starts with alpha) or config (starts with '<') */
Michal Vaskoad611702015-12-03 13:41:51 +0100151 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100152};
153
154struct nc_rpc_getschema {
155 NC_RPC_TYPE type; /**< NC_RPC_GETSCHEMA */
156 char *identifier; /**< requested model identifier */
157 char *version; /**< either YANG version (1.0/1.1) or revision date */
158 char *format; /**< model format */
Michal Vaskoad611702015-12-03 13:41:51 +0100159 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100160};
161
162struct nc_rpc_subscribe {
163 NC_RPC_TYPE type; /**< NC_RPC_SUBSCRIBE */
164 char *stream; /**< stream name */
Michal Vaskoad611702015-12-03 13:41:51 +0100165 char *filter; /**< either XML subtree (starts with '<') or an XPath (starts with '/' or an alpha) */
Michal Vaskoad928112015-11-25 15:52:10 +0100166 char *start;
167 char *stop;
Michal Vaskoad611702015-12-03 13:41:51 +0100168 char free;
Radek Krejci5686ff72015-10-09 13:33:56 +0200169};
170
Michal Vaskoc1171a42019-11-05 12:06:46 +0100171struct nc_rpc_getdata {
172 NC_RPC_TYPE type; /**< NC_RPC_GETDATA */
173 char *datastore; /**< target datastore identity */
174 char *filter; /**< either XML subtree (starts with '<') or an XPath (starts with '/' or an alpha) */
175 char *config_filter; /**< config filter ("true"/"false") */
176 char **origin_filter; /**< origin filters */
177 int origin_filter_count; /**< origin filter count */
178 int negated_origin_filter; /**< whether origin filter is negated or not */
179 int max_depth; /**< max depth of returned subtrees, 0 for unlimited */
180 int with_origin; /**< whether to return origin of data */
181 NC_WD_MODE wd_mode;
182 char free;
183};
184
185struct nc_rpc_editdata {
186 NC_RPC_TYPE type; /**< NC_RPC_EDITDATA */
187 char *datastore; /**< target datastore identity */
188 NC_RPC_EDIT_DFLTOP default_op;
189 char *edit_cont; /**< either URL (starts with aplha) or config (starts with '<') */
190 char free;
191};
192
Michal Vasko96f247a2021-03-15 13:32:10 +0100193struct nc_rpc_establishsub {
194 NC_RPC_TYPE type; /**< NC_RPC_ESTABLISHSUB */
195 char *filter; /**< XML subtree (starts with '<'), an XPath (starts with '/'), or reference (start with alpha) */
196 char *stream; /**< stream name */
197 char *start;
198 char *stop;
199 char *encoding;
200 char free;
201};
202
203struct nc_rpc_modifysub {
204 NC_RPC_TYPE type; /**< NC_RPC_MODIFYSUB */
205 uint32_t id;
206 char *filter; /**< XML subtree (starts with '<'), an XPath (starts with '/'), or reference (start with alpha) */
207 char *stop;
208 char free;
209};
210
211struct nc_rpc_deletesub {
212 NC_RPC_TYPE type; /**< NC_RPC_DELETESUB */
213 uint32_t id;
214};
215
216struct nc_rpc_killsub {
217 NC_RPC_TYPE type; /**< NC_RPC_KILLSUB */
218 uint32_t id;
219};
220
Michal Vasko305faca2021-03-25 09:16:02 +0100221struct nc_rpc_establishpush {
222 NC_RPC_TYPE type; /**< NC_RPC_ESTABLISHPUSH */
223 char *datastore;
224 char *filter; /**< XML subtree (starts with '<'), an XPath (starts with '/'), or reference (start with alpha) */
225 char *stop;
226 char *encoding;
227 int periodic;
Michal Vasko6ce8e822022-08-02 15:09:17 +0200228
Michal Vasko305faca2021-03-25 09:16:02 +0100229 union {
230 struct {
231 uint32_t period;
232 char *anchor_time;
233 };
234 struct {
235 uint32_t dampening_period;
236 int sync_on_start;
237 char **excluded_change;
238 };
239 };
240 char free;
241};
242
243struct nc_rpc_modifypush {
244 NC_RPC_TYPE type; /**< NC_RPC_MODIFYPUSH */
245 uint32_t id;
246 char *datastore;
247 char *filter; /**< XML subtree (starts with '<'), an XPath (starts with '/'), or reference (start with alpha) */
248 char *stop;
249 int periodic;
Michal Vasko6ce8e822022-08-02 15:09:17 +0200250
Michal Vasko305faca2021-03-25 09:16:02 +0100251 union {
252 struct {
253 uint32_t period;
254 char *anchor_time;
255 };
256 uint32_t dampening_period;
257 };
258 char free;
259};
260
261struct nc_rpc_resyncsub {
262 NC_RPC_TYPE type; /**< NC_RPC_RESYNCSUB */
263 uint32_t id;
264};
265
Michal Vasko77367452021-02-16 16:32:18 +0100266void nc_server_rpc_free(struct nc_server_rpc *rpc);
Michal Vasko05ba9df2016-01-13 14:40:27 +0100267
Radek Krejci36d2ee42017-10-13 13:55:59 +0200268void nc_client_err_clean(struct nc_err *err, struct ly_ctx *ctx);
269
Radek Krejci206fcd62015-10-07 15:42:48 +0200270#endif /* NC_MESSAGES_P_H_ */