Radek Krejci | 206fcd6 | 2015-10-07 15:42:48 +0200 | [diff] [blame] | 1 | /** |
Michal Vasko | c446a38 | 2021-06-18 08:54:05 +0200 | [diff] [blame] | 2 | * @file messages_p.h |
| 3 | * @author Radek Krejci <rkrejci@cesnet.cz> |
| 4 | * @brief libnetconf2's private functions and structures of NETCONF messages. |
Radek Krejci | 206fcd6 | 2015-10-07 15:42:48 +0200 | [diff] [blame] | 5 | * |
Michal Vasko | 95ea9ff | 2021-11-09 12:29:14 +0100 | [diff] [blame] | 6 | * @copyright |
Michal Vasko | c446a38 | 2021-06-18 08:54:05 +0200 | [diff] [blame] | 7 | * Copyright (c) 2021 CESNET, z.s.p.o. |
Radek Krejci | 206fcd6 | 2015-10-07 15:42:48 +0200 | [diff] [blame] | 8 | * |
Radek Krejci | 9b81f5b | 2016-02-24 13:14:49 +0100 | [diff] [blame] | 9 | * 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 Vasko | afd416b | 2016-02-25 14:51:46 +0100 | [diff] [blame] | 12 | * |
Radek Krejci | 9b81f5b | 2016-02-24 13:14:49 +0100 | [diff] [blame] | 13 | * https://opensource.org/licenses/BSD-3-Clause |
Radek Krejci | 206fcd6 | 2015-10-07 15:42:48 +0200 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #ifndef NC_MESSAGES_P_H_ |
| 17 | #define NC_MESSAGES_P_H_ |
| 18 | |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 19 | #include <stdint.h> |
| 20 | |
Radek Krejci | 206fcd6 | 2015-10-07 15:42:48 +0200 | [diff] [blame] | 21 | #include <libyang/libyang.h> |
| 22 | |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 23 | #include "messages_client.h" |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 24 | #include "messages_server.h" |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 25 | #include "netconf.h" |
Radek Krejci | 4339024 | 2015-10-08 15:34:04 +0200 | [diff] [blame] | 26 | |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 27 | extern const char *rpcedit_dfltop2str[]; |
| 28 | extern const char *rpcedit_testopt2str[]; |
| 29 | extern const char *rpcedit_erropt2str[]; |
| 30 | |
Michal Vasko | 05ba9df | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 31 | struct nc_server_reply { |
| 32 | NC_RPL type; |
| 33 | }; |
| 34 | |
| 35 | struct nc_server_reply_data { |
| 36 | NC_RPL type; |
| 37 | struct lyd_node *data; |
Michal Vasko | 7736745 | 2021-02-16 16:32:18 +0100 | [diff] [blame] | 38 | int free; |
Radek Krejci | 36dfdb3 | 2016-09-01 16:56:35 +0200 | [diff] [blame] | 39 | NC_WD_MODE wd; |
Michal Vasko | 05ba9df | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 40 | }; |
| 41 | |
| 42 | struct nc_server_reply_error { |
| 43 | NC_RPL type; |
Michal Vasko | 7736745 | 2021-02-16 16:32:18 +0100 | [diff] [blame] | 44 | struct lyd_node *err; |
Michal Vasko | 05ba9df | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 45 | }; |
Radek Krejci | 695d4fa | 2015-10-22 13:23:54 +0200 | [diff] [blame] | 46 | |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 47 | struct nc_server_rpc { |
Michal Vasko | 7736745 | 2021-02-16 16:32:18 +0100 | [diff] [blame] | 48 | struct lyd_node *envp; /**< NETCONF-specific RPC envelopes */ |
| 49 | struct lyd_node *rpc; /**< RPC data tree */ |
Radek Krejci | 695d4fa | 2015-10-22 13:23:54 +0200 | [diff] [blame] | 50 | }; |
| 51 | |
Radek Krejci | 93e8022 | 2016-10-03 13:34:25 +0200 | [diff] [blame] | 52 | struct nc_server_notif { |
| 53 | char *eventtime; /**< eventTime of the notification */ |
Michal Vasko | 7736745 | 2021-02-16 16:32:18 +0100 | [diff] [blame] | 54 | struct lyd_node *ntf; /**< notification data tree of the message */ |
Michal Vasko | fc9dbdd | 2017-03-17 09:27:57 +0100 | [diff] [blame] | 55 | int free; |
Radek Krejci | 93e8022 | 2016-10-03 13:34:25 +0200 | [diff] [blame] | 56 | }; |
| 57 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 58 | struct 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 Vasko | 2a3eef0 | 2015-12-11 14:38:34 +0100 | [diff] [blame] | 65 | struct nc_rpc { |
| 66 | NC_RPC_TYPE type; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 67 | }; |
| 68 | |
Michal Vasko | 90e8e69 | 2016-07-13 12:27:57 +0200 | [diff] [blame] | 69 | struct nc_rpc_act_generic { |
| 70 | NC_RPC_TYPE type; /**< NC_RPC_ACT_GENERIC */ |
Michal Vasko | 2a3eef0 | 2015-12-11 14:38:34 +0100 | [diff] [blame] | 71 | int has_data; /**< 1 for content.data, 0 for content.xml_str */ |
Michal Vasko | 6ce8e82 | 2022-08-02 15:09:17 +0200 | [diff] [blame] | 72 | |
Michal Vasko | 2a3eef0 | 2015-12-11 14:38:34 +0100 | [diff] [blame] | 73 | union { |
| 74 | struct lyd_node *data; /**< parsed RPC data */ |
| 75 | char *xml_str; /**< raw XML string */ |
| 76 | } content; |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 77 | char free; |
Radek Krejci | 926a574 | 2015-10-31 17:50:49 +0100 | [diff] [blame] | 78 | }; |
| 79 | |
Radek Krejci | 695d4fa | 2015-10-22 13:23:54 +0200 | [diff] [blame] | 80 | struct nc_rpc_getconfig { |
| 81 | NC_RPC_TYPE type; /**< NC_RPC_GETCONFIG */ |
| 82 | NC_DATASTORE source; /**< NETCONF datastore being queried */ |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 83 | char *filter; /**< either XML subtree (starts with '<') or an XPath (starts with '/' or an alpha) */ |
Michal Vasko | 807be23 | 2015-12-09 15:24:55 +0100 | [diff] [blame] | 84 | NC_WD_MODE wd_mode; |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 85 | char free; |
Radek Krejci | 695d4fa | 2015-10-22 13:23:54 +0200 | [diff] [blame] | 86 | }; |
| 87 | |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 88 | struct 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 Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 95 | char free; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 96 | }; |
| 97 | |
| 98 | struct 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 Vasko | 807be23 | 2015-12-09 15:24:55 +0100 | [diff] [blame] | 104 | NC_WD_MODE wd_mode; |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 105 | char free; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 106 | }; |
| 107 | |
| 108 | struct nc_rpc_delete { |
| 109 | NC_RPC_TYPE type; /**< NC_RPC_DELETE */ |
| 110 | NC_DATASTORE target; |
| 111 | char *url; |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 112 | char free; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 113 | }; |
| 114 | |
Radek Krejci | 695d4fa | 2015-10-22 13:23:54 +0200 | [diff] [blame] | 115 | struct nc_rpc_lock { |
| 116 | NC_RPC_TYPE type; /**< NC_RPC_LOCK or NC_RPC_UNLOCK */ |
| 117 | NC_DATASTORE target; |
Radek Krejci | 206fcd6 | 2015-10-07 15:42:48 +0200 | [diff] [blame] | 118 | }; |
| 119 | |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 120 | struct nc_rpc_get { |
| 121 | NC_RPC_TYPE type; /**< NC_RPC_GET */ |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 122 | char *filter; /**< either XML subtree (starts with '<') or an XPath (starts with '/' or an alpha) */ |
Michal Vasko | 807be23 | 2015-12-09 15:24:55 +0100 | [diff] [blame] | 123 | NC_WD_MODE wd_mode; |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 124 | char free; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 125 | }; |
| 126 | |
| 127 | struct nc_rpc_kill { |
| 128 | NC_RPC_TYPE type; /**< NC_RPC_KILL */ |
| 129 | uint32_t sid; |
| 130 | }; |
| 131 | |
| 132 | struct 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 Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 138 | char free; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 139 | }; |
| 140 | |
| 141 | struct nc_rpc_cancel { |
| 142 | NC_RPC_TYPE type; /**< NC_RPC_CANCEL */ |
| 143 | char *persist_id; |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 144 | char free; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 145 | }; |
| 146 | |
| 147 | struct 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 Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 151 | char free; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 152 | }; |
| 153 | |
| 154 | struct 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 Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 159 | char free; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 160 | }; |
| 161 | |
| 162 | struct nc_rpc_subscribe { |
| 163 | NC_RPC_TYPE type; /**< NC_RPC_SUBSCRIBE */ |
| 164 | char *stream; /**< stream name */ |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 165 | char *filter; /**< either XML subtree (starts with '<') or an XPath (starts with '/' or an alpha) */ |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 166 | char *start; |
| 167 | char *stop; |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 168 | char free; |
Radek Krejci | 5686ff7 | 2015-10-09 13:33:56 +0200 | [diff] [blame] | 169 | }; |
| 170 | |
Michal Vasko | c1171a4 | 2019-11-05 12:06:46 +0100 | [diff] [blame] | 171 | struct 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 | |
| 185 | struct 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 Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame] | 193 | struct 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 | |
| 203 | struct 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 | |
| 211 | struct nc_rpc_deletesub { |
| 212 | NC_RPC_TYPE type; /**< NC_RPC_DELETESUB */ |
| 213 | uint32_t id; |
| 214 | }; |
| 215 | |
| 216 | struct nc_rpc_killsub { |
| 217 | NC_RPC_TYPE type; /**< NC_RPC_KILLSUB */ |
| 218 | uint32_t id; |
| 219 | }; |
| 220 | |
Michal Vasko | 305faca | 2021-03-25 09:16:02 +0100 | [diff] [blame] | 221 | struct 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 Vasko | 6ce8e82 | 2022-08-02 15:09:17 +0200 | [diff] [blame] | 228 | |
Michal Vasko | 305faca | 2021-03-25 09:16:02 +0100 | [diff] [blame] | 229 | 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 | |
| 243 | struct 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 Vasko | 6ce8e82 | 2022-08-02 15:09:17 +0200 | [diff] [blame] | 250 | |
Michal Vasko | 305faca | 2021-03-25 09:16:02 +0100 | [diff] [blame] | 251 | union { |
| 252 | struct { |
| 253 | uint32_t period; |
| 254 | char *anchor_time; |
| 255 | }; |
| 256 | uint32_t dampening_period; |
| 257 | }; |
| 258 | char free; |
| 259 | }; |
| 260 | |
| 261 | struct nc_rpc_resyncsub { |
| 262 | NC_RPC_TYPE type; /**< NC_RPC_RESYNCSUB */ |
| 263 | uint32_t id; |
| 264 | }; |
| 265 | |
Michal Vasko | 7736745 | 2021-02-16 16:32:18 +0100 | [diff] [blame] | 266 | void nc_server_rpc_free(struct nc_server_rpc *rpc); |
Michal Vasko | 05ba9df | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 267 | |
Radek Krejci | 36d2ee4 | 2017-10-13 13:55:59 +0200 | [diff] [blame] | 268 | void nc_client_err_clean(struct nc_err *err, struct ly_ctx *ctx); |
| 269 | |
Radek Krejci | 206fcd6 | 2015-10-07 15:42:48 +0200 | [diff] [blame] | 270 | #endif /* NC_MESSAGES_P_H_ */ |