blob: 0ea41885996a767455e4c34cb3cbadfee6d30682 [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
19#include <libyang/libyang.h>
20
Michal Vasko7bcb48e2016-01-15 10:28:54 +010021#include "messages_client.h"
Michal Vaskob83a3fa2021-05-26 09:53:42 +020022#include "messages_server.h"
Radek Krejci43390242015-10-08 15:34:04 +020023
Michal Vaskoad928112015-11-25 15:52:10 +010024extern const char *rpcedit_dfltop2str[];
25extern const char *rpcedit_testopt2str[];
26extern const char *rpcedit_erropt2str[];
27
Michal Vasko05ba9df2016-01-13 14:40:27 +010028struct nc_server_reply {
29 NC_RPL type;
30};
31
32struct nc_server_reply_data {
33 NC_RPL type;
34 struct lyd_node *data;
Michal Vasko77367452021-02-16 16:32:18 +010035 int free;
Radek Krejci36dfdb32016-09-01 16:56:35 +020036 NC_WD_MODE wd;
Michal Vasko05ba9df2016-01-13 14:40:27 +010037};
38
39struct nc_server_reply_error {
40 NC_RPL type;
Michal Vasko77367452021-02-16 16:32:18 +010041 struct lyd_node *err;
Michal Vasko05ba9df2016-01-13 14:40:27 +010042};
Radek Krejci695d4fa2015-10-22 13:23:54 +020043
Michal Vaskoad611702015-12-03 13:41:51 +010044struct nc_server_rpc {
Michal Vasko77367452021-02-16 16:32:18 +010045 struct lyd_node *envp; /**< NETCONF-specific RPC envelopes */
46 struct lyd_node *rpc; /**< RPC data tree */
Radek Krejci695d4fa2015-10-22 13:23:54 +020047};
48
Radek Krejci93e80222016-10-03 13:34:25 +020049struct nc_server_notif {
50 char *eventtime; /**< eventTime of the notification */
Michal Vasko77367452021-02-16 16:32:18 +010051 struct lyd_node *ntf; /**< notification data tree of the message */
Michal Vaskofc9dbdd2017-03-17 09:27:57 +010052 int free;
Radek Krejci93e80222016-10-03 13:34:25 +020053};
54
Michal Vasko1a38c862016-01-15 15:50:07 +010055struct nc_client_reply_error {
56 NC_RPL type;
57 struct nc_err *err;
58 uint32_t count;
59 struct ly_ctx *ctx;
60};
61
Michal Vasko2a3eef02015-12-11 14:38:34 +010062struct nc_rpc {
63 NC_RPC_TYPE type;
Michal Vaskoad928112015-11-25 15:52:10 +010064};
65
Michal Vasko90e8e692016-07-13 12:27:57 +020066struct nc_rpc_act_generic {
67 NC_RPC_TYPE type; /**< NC_RPC_ACT_GENERIC */
Michal Vasko2a3eef02015-12-11 14:38:34 +010068 int has_data; /**< 1 for content.data, 0 for content.xml_str */
Michal Vasko6ce8e822022-08-02 15:09:17 +020069
Michal Vasko2a3eef02015-12-11 14:38:34 +010070 union {
71 struct lyd_node *data; /**< parsed RPC data */
72 char *xml_str; /**< raw XML string */
73 } content;
Michal Vaskoad611702015-12-03 13:41:51 +010074 char free;
Radek Krejci926a5742015-10-31 17:50:49 +010075};
76
Radek Krejci695d4fa2015-10-22 13:23:54 +020077struct nc_rpc_getconfig {
78 NC_RPC_TYPE type; /**< NC_RPC_GETCONFIG */
79 NC_DATASTORE source; /**< NETCONF datastore being queried */
Michal Vaskoad611702015-12-03 13:41:51 +010080 char *filter; /**< either XML subtree (starts with '<') or an XPath (starts with '/' or an alpha) */
Michal Vasko807be232015-12-09 15:24:55 +010081 NC_WD_MODE wd_mode;
Michal Vaskoad611702015-12-03 13:41:51 +010082 char free;
Radek Krejci695d4fa2015-10-22 13:23:54 +020083};
84
Michal Vaskoad928112015-11-25 15:52:10 +010085struct nc_rpc_edit {
86 NC_RPC_TYPE type; /**< NC_RPC_EDIT */
87 NC_DATASTORE target;
88 NC_RPC_EDIT_DFLTOP default_op;
89 NC_RPC_EDIT_TESTOPT test_opt;
90 NC_RPC_EDIT_ERROPT error_opt;
91 char *edit_cont; /**< either URL (starts with aplha) or config (starts with '<') */
Michal Vaskoad611702015-12-03 13:41:51 +010092 char free;
Michal Vaskoad928112015-11-25 15:52:10 +010093};
94
95struct nc_rpc_copy {
96 NC_RPC_TYPE type; /**< NC_RPC_COPY */
97 NC_DATASTORE target;
98 char *url_trg;
99 NC_DATASTORE source;
100 char *url_config_src; /**< either URL (starts with aplha) or config (starts with '<') */
Michal Vasko807be232015-12-09 15:24:55 +0100101 NC_WD_MODE wd_mode;
Michal Vaskoad611702015-12-03 13:41:51 +0100102 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100103};
104
105struct nc_rpc_delete {
106 NC_RPC_TYPE type; /**< NC_RPC_DELETE */
107 NC_DATASTORE target;
108 char *url;
Michal Vaskoad611702015-12-03 13:41:51 +0100109 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100110};
111
Radek Krejci695d4fa2015-10-22 13:23:54 +0200112struct nc_rpc_lock {
113 NC_RPC_TYPE type; /**< NC_RPC_LOCK or NC_RPC_UNLOCK */
114 NC_DATASTORE target;
Radek Krejci206fcd62015-10-07 15:42:48 +0200115};
116
Michal Vaskoad928112015-11-25 15:52:10 +0100117struct nc_rpc_get {
118 NC_RPC_TYPE type; /**< NC_RPC_GET */
Michal Vaskoad611702015-12-03 13:41:51 +0100119 char *filter; /**< either XML subtree (starts with '<') or an XPath (starts with '/' or an alpha) */
Michal Vasko807be232015-12-09 15:24:55 +0100120 NC_WD_MODE wd_mode;
Michal Vaskoad611702015-12-03 13:41:51 +0100121 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100122};
123
124struct nc_rpc_kill {
125 NC_RPC_TYPE type; /**< NC_RPC_KILL */
126 uint32_t sid;
127};
128
129struct nc_rpc_commit {
130 NC_RPC_TYPE type; /**< NC_RPC_COMMIT */
131 int confirmed;
132 uint32_t confirm_timeout;
133 char *persist;
134 char *persist_id;
Michal Vaskoad611702015-12-03 13:41:51 +0100135 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100136};
137
138struct nc_rpc_cancel {
139 NC_RPC_TYPE type; /**< NC_RPC_CANCEL */
140 char *persist_id;
Michal Vaskoad611702015-12-03 13:41:51 +0100141 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100142};
143
144struct nc_rpc_validate {
145 NC_RPC_TYPE type; /**< NC_RPC_VALIDATE */
146 NC_DATASTORE source;
147 char *url_config_src; /**< either URL (starts with alpha) or config (starts with '<') */
Michal Vaskoad611702015-12-03 13:41:51 +0100148 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100149};
150
151struct nc_rpc_getschema {
152 NC_RPC_TYPE type; /**< NC_RPC_GETSCHEMA */
153 char *identifier; /**< requested model identifier */
154 char *version; /**< either YANG version (1.0/1.1) or revision date */
155 char *format; /**< model format */
Michal Vaskoad611702015-12-03 13:41:51 +0100156 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100157};
158
159struct nc_rpc_subscribe {
160 NC_RPC_TYPE type; /**< NC_RPC_SUBSCRIBE */
161 char *stream; /**< stream name */
Michal Vaskoad611702015-12-03 13:41:51 +0100162 char *filter; /**< either XML subtree (starts with '<') or an XPath (starts with '/' or an alpha) */
Michal Vaskoad928112015-11-25 15:52:10 +0100163 char *start;
164 char *stop;
Michal Vaskoad611702015-12-03 13:41:51 +0100165 char free;
Radek Krejci5686ff72015-10-09 13:33:56 +0200166};
167
Michal Vaskoc1171a42019-11-05 12:06:46 +0100168struct nc_rpc_getdata {
169 NC_RPC_TYPE type; /**< NC_RPC_GETDATA */
170 char *datastore; /**< target datastore identity */
171 char *filter; /**< either XML subtree (starts with '<') or an XPath (starts with '/' or an alpha) */
172 char *config_filter; /**< config filter ("true"/"false") */
173 char **origin_filter; /**< origin filters */
174 int origin_filter_count; /**< origin filter count */
175 int negated_origin_filter; /**< whether origin filter is negated or not */
176 int max_depth; /**< max depth of returned subtrees, 0 for unlimited */
177 int with_origin; /**< whether to return origin of data */
178 NC_WD_MODE wd_mode;
179 char free;
180};
181
182struct nc_rpc_editdata {
183 NC_RPC_TYPE type; /**< NC_RPC_EDITDATA */
184 char *datastore; /**< target datastore identity */
185 NC_RPC_EDIT_DFLTOP default_op;
186 char *edit_cont; /**< either URL (starts with aplha) or config (starts with '<') */
187 char free;
188};
189
Michal Vasko96f247a2021-03-15 13:32:10 +0100190struct nc_rpc_establishsub {
191 NC_RPC_TYPE type; /**< NC_RPC_ESTABLISHSUB */
192 char *filter; /**< XML subtree (starts with '<'), an XPath (starts with '/'), or reference (start with alpha) */
193 char *stream; /**< stream name */
194 char *start;
195 char *stop;
196 char *encoding;
197 char free;
198};
199
200struct nc_rpc_modifysub {
201 NC_RPC_TYPE type; /**< NC_RPC_MODIFYSUB */
202 uint32_t id;
203 char *filter; /**< XML subtree (starts with '<'), an XPath (starts with '/'), or reference (start with alpha) */
204 char *stop;
205 char free;
206};
207
208struct nc_rpc_deletesub {
209 NC_RPC_TYPE type; /**< NC_RPC_DELETESUB */
210 uint32_t id;
211};
212
213struct nc_rpc_killsub {
214 NC_RPC_TYPE type; /**< NC_RPC_KILLSUB */
215 uint32_t id;
216};
217
Michal Vasko305faca2021-03-25 09:16:02 +0100218struct nc_rpc_establishpush {
219 NC_RPC_TYPE type; /**< NC_RPC_ESTABLISHPUSH */
220 char *datastore;
221 char *filter; /**< XML subtree (starts with '<'), an XPath (starts with '/'), or reference (start with alpha) */
222 char *stop;
223 char *encoding;
224 int periodic;
Michal Vasko6ce8e822022-08-02 15:09:17 +0200225
Michal Vasko305faca2021-03-25 09:16:02 +0100226 union {
227 struct {
228 uint32_t period;
229 char *anchor_time;
230 };
231 struct {
232 uint32_t dampening_period;
233 int sync_on_start;
234 char **excluded_change;
235 };
236 };
237 char free;
238};
239
240struct nc_rpc_modifypush {
241 NC_RPC_TYPE type; /**< NC_RPC_MODIFYPUSH */
242 uint32_t id;
243 char *datastore;
244 char *filter; /**< XML subtree (starts with '<'), an XPath (starts with '/'), or reference (start with alpha) */
245 char *stop;
246 int periodic;
Michal Vasko6ce8e822022-08-02 15:09:17 +0200247
Michal Vasko305faca2021-03-25 09:16:02 +0100248 union {
249 struct {
250 uint32_t period;
251 char *anchor_time;
252 };
253 uint32_t dampening_period;
254 };
255 char free;
256};
257
258struct nc_rpc_resyncsub {
259 NC_RPC_TYPE type; /**< NC_RPC_RESYNCSUB */
260 uint32_t id;
261};
262
Michal Vasko77367452021-02-16 16:32:18 +0100263void nc_server_rpc_free(struct nc_server_rpc *rpc);
Michal Vasko05ba9df2016-01-13 14:40:27 +0100264
Radek Krejci36d2ee42017-10-13 13:55:59 +0200265void nc_client_err_clean(struct nc_err *err, struct ly_ctx *ctx);
266
Radek Krejci206fcd62015-10-07 15:42:48 +0200267#endif /* NC_MESSAGES_P_H_ */