blob: 177331f82ada297dfd21722ff6e60054616922cd [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 Vaskoc446a382021-06-18 08:54:05 +02006 * Copyright (c) 2021 CESNET, z.s.p.o.
Radek Krejci206fcd62015-10-07 15:42:48 +02007 *
Radek Krejci9b81f5b2016-02-24 13:14:49 +01008 * This source code is licensed under BSD 3-Clause License (the "License").
9 * You may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
Michal Vaskoafd416b2016-02-25 14:51:46 +010011 *
Radek Krejci9b81f5b2016-02-24 13:14:49 +010012 * https://opensource.org/licenses/BSD-3-Clause
Radek Krejci206fcd62015-10-07 15:42:48 +020013 */
14
15#ifndef NC_MESSAGES_P_H_
16#define NC_MESSAGES_P_H_
17
18#include <libyang/libyang.h>
19
Michal Vasko7bcb48e2016-01-15 10:28:54 +010020#include "messages_client.h"
Michal Vaskob83a3fa2021-05-26 09:53:42 +020021#include "messages_server.h"
Radek Krejci43390242015-10-08 15:34:04 +020022
Michal Vaskoad928112015-11-25 15:52:10 +010023extern const char *rpcedit_dfltop2str[];
24extern const char *rpcedit_testopt2str[];
25extern const char *rpcedit_erropt2str[];
26
Michal Vasko05ba9df2016-01-13 14:40:27 +010027struct nc_server_reply {
28 NC_RPL type;
29};
30
31struct nc_server_reply_data {
32 NC_RPL type;
33 struct lyd_node *data;
Michal Vasko77367452021-02-16 16:32:18 +010034 int free;
Radek Krejci36dfdb32016-09-01 16:56:35 +020035 NC_WD_MODE wd;
Michal Vasko05ba9df2016-01-13 14:40:27 +010036};
37
38struct nc_server_reply_error {
39 NC_RPL type;
Michal Vasko77367452021-02-16 16:32:18 +010040 struct lyd_node *err;
Michal Vasko05ba9df2016-01-13 14:40:27 +010041};
Radek Krejci695d4fa2015-10-22 13:23:54 +020042
Michal Vaskoad611702015-12-03 13:41:51 +010043struct nc_server_rpc {
Michal Vasko77367452021-02-16 16:32:18 +010044 struct lyd_node *envp; /**< NETCONF-specific RPC envelopes */
45 struct lyd_node *rpc; /**< RPC data tree */
Radek Krejci695d4fa2015-10-22 13:23:54 +020046};
47
Radek Krejci93e80222016-10-03 13:34:25 +020048struct nc_server_notif {
49 char *eventtime; /**< eventTime of the notification */
Michal Vasko77367452021-02-16 16:32:18 +010050 struct lyd_node *ntf; /**< notification data tree of the message */
Michal Vaskofc9dbdd2017-03-17 09:27:57 +010051 int free;
Radek Krejci93e80222016-10-03 13:34:25 +020052};
53
Michal Vasko1a38c862016-01-15 15:50:07 +010054struct nc_client_reply_error {
55 NC_RPL type;
56 struct nc_err *err;
57 uint32_t count;
58 struct ly_ctx *ctx;
59};
60
Michal Vasko2a3eef02015-12-11 14:38:34 +010061struct nc_rpc {
62 NC_RPC_TYPE type;
Michal Vaskoad928112015-11-25 15:52:10 +010063};
64
Michal Vasko90e8e692016-07-13 12:27:57 +020065struct nc_rpc_act_generic {
66 NC_RPC_TYPE type; /**< NC_RPC_ACT_GENERIC */
Michal Vasko2a3eef02015-12-11 14:38:34 +010067 int has_data; /**< 1 for content.data, 0 for content.xml_str */
68 union {
69 struct lyd_node *data; /**< parsed RPC data */
70 char *xml_str; /**< raw XML string */
71 } content;
Michal Vaskoad611702015-12-03 13:41:51 +010072 char free;
Radek Krejci926a5742015-10-31 17:50:49 +010073};
74
Radek Krejci695d4fa2015-10-22 13:23:54 +020075struct nc_rpc_getconfig {
76 NC_RPC_TYPE type; /**< NC_RPC_GETCONFIG */
77 NC_DATASTORE source; /**< NETCONF datastore being queried */
Michal Vaskoad611702015-12-03 13:41:51 +010078 char *filter; /**< either XML subtree (starts with '<') or an XPath (starts with '/' or an alpha) */
Michal Vasko807be232015-12-09 15:24:55 +010079 NC_WD_MODE wd_mode;
Michal Vaskoad611702015-12-03 13:41:51 +010080 char free;
Radek Krejci695d4fa2015-10-22 13:23:54 +020081};
82
Michal Vaskoad928112015-11-25 15:52:10 +010083struct nc_rpc_edit {
84 NC_RPC_TYPE type; /**< NC_RPC_EDIT */
85 NC_DATASTORE target;
86 NC_RPC_EDIT_DFLTOP default_op;
87 NC_RPC_EDIT_TESTOPT test_opt;
88 NC_RPC_EDIT_ERROPT error_opt;
89 char *edit_cont; /**< either URL (starts with aplha) or config (starts with '<') */
Michal Vaskoad611702015-12-03 13:41:51 +010090 char free;
Michal Vaskoad928112015-11-25 15:52:10 +010091};
92
93struct nc_rpc_copy {
94 NC_RPC_TYPE type; /**< NC_RPC_COPY */
95 NC_DATASTORE target;
96 char *url_trg;
97 NC_DATASTORE source;
98 char *url_config_src; /**< either URL (starts with aplha) or config (starts with '<') */
Michal Vasko807be232015-12-09 15:24:55 +010099 NC_WD_MODE wd_mode;
Michal Vaskoad611702015-12-03 13:41:51 +0100100 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100101};
102
103struct nc_rpc_delete {
104 NC_RPC_TYPE type; /**< NC_RPC_DELETE */
105 NC_DATASTORE target;
106 char *url;
Michal Vaskoad611702015-12-03 13:41:51 +0100107 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100108};
109
Radek Krejci695d4fa2015-10-22 13:23:54 +0200110struct nc_rpc_lock {
111 NC_RPC_TYPE type; /**< NC_RPC_LOCK or NC_RPC_UNLOCK */
112 NC_DATASTORE target;
Radek Krejci206fcd62015-10-07 15:42:48 +0200113};
114
Michal Vaskoad928112015-11-25 15:52:10 +0100115struct nc_rpc_get {
116 NC_RPC_TYPE type; /**< NC_RPC_GET */
Michal Vaskoad611702015-12-03 13:41:51 +0100117 char *filter; /**< either XML subtree (starts with '<') or an XPath (starts with '/' or an alpha) */
Michal Vasko807be232015-12-09 15:24:55 +0100118 NC_WD_MODE wd_mode;
Michal Vaskoad611702015-12-03 13:41:51 +0100119 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100120};
121
122struct nc_rpc_kill {
123 NC_RPC_TYPE type; /**< NC_RPC_KILL */
124 uint32_t sid;
125};
126
127struct nc_rpc_commit {
128 NC_RPC_TYPE type; /**< NC_RPC_COMMIT */
129 int confirmed;
130 uint32_t confirm_timeout;
131 char *persist;
132 char *persist_id;
Michal Vaskoad611702015-12-03 13:41:51 +0100133 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100134};
135
136struct nc_rpc_cancel {
137 NC_RPC_TYPE type; /**< NC_RPC_CANCEL */
138 char *persist_id;
Michal Vaskoad611702015-12-03 13:41:51 +0100139 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100140};
141
142struct nc_rpc_validate {
143 NC_RPC_TYPE type; /**< NC_RPC_VALIDATE */
144 NC_DATASTORE source;
145 char *url_config_src; /**< either URL (starts with alpha) or config (starts with '<') */
Michal Vaskoad611702015-12-03 13:41:51 +0100146 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100147};
148
149struct nc_rpc_getschema {
150 NC_RPC_TYPE type; /**< NC_RPC_GETSCHEMA */
151 char *identifier; /**< requested model identifier */
152 char *version; /**< either YANG version (1.0/1.1) or revision date */
153 char *format; /**< model format */
Michal Vaskoad611702015-12-03 13:41:51 +0100154 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100155};
156
157struct nc_rpc_subscribe {
158 NC_RPC_TYPE type; /**< NC_RPC_SUBSCRIBE */
159 char *stream; /**< stream name */
Michal Vaskoad611702015-12-03 13:41:51 +0100160 char *filter; /**< either XML subtree (starts with '<') or an XPath (starts with '/' or an alpha) */
Michal Vaskoad928112015-11-25 15:52:10 +0100161 char *start;
162 char *stop;
Michal Vaskoad611702015-12-03 13:41:51 +0100163 char free;
Radek Krejci5686ff72015-10-09 13:33:56 +0200164};
165
Michal Vaskoc1171a42019-11-05 12:06:46 +0100166struct nc_rpc_getdata {
167 NC_RPC_TYPE type; /**< NC_RPC_GETDATA */
168 char *datastore; /**< target datastore identity */
169 char *filter; /**< either XML subtree (starts with '<') or an XPath (starts with '/' or an alpha) */
170 char *config_filter; /**< config filter ("true"/"false") */
171 char **origin_filter; /**< origin filters */
172 int origin_filter_count; /**< origin filter count */
173 int negated_origin_filter; /**< whether origin filter is negated or not */
174 int max_depth; /**< max depth of returned subtrees, 0 for unlimited */
175 int with_origin; /**< whether to return origin of data */
176 NC_WD_MODE wd_mode;
177 char free;
178};
179
180struct nc_rpc_editdata {
181 NC_RPC_TYPE type; /**< NC_RPC_EDITDATA */
182 char *datastore; /**< target datastore identity */
183 NC_RPC_EDIT_DFLTOP default_op;
184 char *edit_cont; /**< either URL (starts with aplha) or config (starts with '<') */
185 char free;
186};
187
Michal Vasko96f247a2021-03-15 13:32:10 +0100188struct nc_rpc_establishsub {
189 NC_RPC_TYPE type; /**< NC_RPC_ESTABLISHSUB */
190 char *filter; /**< XML subtree (starts with '<'), an XPath (starts with '/'), or reference (start with alpha) */
191 char *stream; /**< stream name */
192 char *start;
193 char *stop;
194 char *encoding;
195 char free;
196};
197
198struct nc_rpc_modifysub {
199 NC_RPC_TYPE type; /**< NC_RPC_MODIFYSUB */
200 uint32_t id;
201 char *filter; /**< XML subtree (starts with '<'), an XPath (starts with '/'), or reference (start with alpha) */
202 char *stop;
203 char free;
204};
205
206struct nc_rpc_deletesub {
207 NC_RPC_TYPE type; /**< NC_RPC_DELETESUB */
208 uint32_t id;
209};
210
211struct nc_rpc_killsub {
212 NC_RPC_TYPE type; /**< NC_RPC_KILLSUB */
213 uint32_t id;
214};
215
Michal Vasko305faca2021-03-25 09:16:02 +0100216struct nc_rpc_establishpush {
217 NC_RPC_TYPE type; /**< NC_RPC_ESTABLISHPUSH */
218 char *datastore;
219 char *filter; /**< XML subtree (starts with '<'), an XPath (starts with '/'), or reference (start with alpha) */
220 char *stop;
221 char *encoding;
222 int periodic;
223 union {
224 struct {
225 uint32_t period;
226 char *anchor_time;
227 };
228 struct {
229 uint32_t dampening_period;
230 int sync_on_start;
231 char **excluded_change;
232 };
233 };
234 char free;
235};
236
237struct nc_rpc_modifypush {
238 NC_RPC_TYPE type; /**< NC_RPC_MODIFYPUSH */
239 uint32_t id;
240 char *datastore;
241 char *filter; /**< XML subtree (starts with '<'), an XPath (starts with '/'), or reference (start with alpha) */
242 char *stop;
243 int periodic;
244 union {
245 struct {
246 uint32_t period;
247 char *anchor_time;
248 };
249 uint32_t dampening_period;
250 };
251 char free;
252};
253
254struct nc_rpc_resyncsub {
255 NC_RPC_TYPE type; /**< NC_RPC_RESYNCSUB */
256 uint32_t id;
257};
258
Michal Vasko77367452021-02-16 16:32:18 +0100259void nc_server_rpc_free(struct nc_server_rpc *rpc);
Michal Vasko05ba9df2016-01-13 14:40:27 +0100260
Radek Krejci36d2ee42017-10-13 13:55:59 +0200261void nc_client_err_clean(struct nc_err *err, struct ly_ctx *ctx);
262
Radek Krejci206fcd62015-10-07 15:42:48 +0200263#endif /* NC_MESSAGES_P_H_ */