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 | |
| 19 | #include <libyang/libyang.h> |
| 20 | |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 21 | #include "messages_client.h" |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 22 | #include "messages_server.h" |
Radek Krejci | 4339024 | 2015-10-08 15:34:04 +0200 | [diff] [blame] | 23 | |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 24 | extern const char *rpcedit_dfltop2str[]; |
| 25 | extern const char *rpcedit_testopt2str[]; |
| 26 | extern const char *rpcedit_erropt2str[]; |
| 27 | |
Michal Vasko | 05ba9df | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 28 | struct nc_server_reply { |
| 29 | NC_RPL type; |
| 30 | }; |
| 31 | |
| 32 | struct nc_server_reply_data { |
| 33 | NC_RPL type; |
| 34 | struct lyd_node *data; |
Michal Vasko | 7736745 | 2021-02-16 16:32:18 +0100 | [diff] [blame] | 35 | int free; |
Radek Krejci | 36dfdb3 | 2016-09-01 16:56:35 +0200 | [diff] [blame] | 36 | NC_WD_MODE wd; |
Michal Vasko | 05ba9df | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 37 | }; |
| 38 | |
| 39 | struct nc_server_reply_error { |
| 40 | NC_RPL type; |
Michal Vasko | 7736745 | 2021-02-16 16:32:18 +0100 | [diff] [blame] | 41 | struct lyd_node *err; |
Michal Vasko | 05ba9df | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 42 | }; |
Radek Krejci | 695d4fa | 2015-10-22 13:23:54 +0200 | [diff] [blame] | 43 | |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 44 | struct nc_server_rpc { |
Michal Vasko | 7736745 | 2021-02-16 16:32:18 +0100 | [diff] [blame] | 45 | struct lyd_node *envp; /**< NETCONF-specific RPC envelopes */ |
| 46 | struct lyd_node *rpc; /**< RPC data tree */ |
Radek Krejci | 695d4fa | 2015-10-22 13:23:54 +0200 | [diff] [blame] | 47 | }; |
| 48 | |
Radek Krejci | 93e8022 | 2016-10-03 13:34:25 +0200 | [diff] [blame] | 49 | struct nc_server_notif { |
| 50 | char *eventtime; /**< eventTime of the notification */ |
Michal Vasko | 7736745 | 2021-02-16 16:32:18 +0100 | [diff] [blame] | 51 | struct lyd_node *ntf; /**< notification data tree of the message */ |
Michal Vasko | fc9dbdd | 2017-03-17 09:27:57 +0100 | [diff] [blame] | 52 | int free; |
Radek Krejci | 93e8022 | 2016-10-03 13:34:25 +0200 | [diff] [blame] | 53 | }; |
| 54 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 55 | struct 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 Vasko | 2a3eef0 | 2015-12-11 14:38:34 +0100 | [diff] [blame] | 62 | struct nc_rpc { |
| 63 | NC_RPC_TYPE type; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 64 | }; |
| 65 | |
Michal Vasko | 90e8e69 | 2016-07-13 12:27:57 +0200 | [diff] [blame] | 66 | struct nc_rpc_act_generic { |
| 67 | NC_RPC_TYPE type; /**< NC_RPC_ACT_GENERIC */ |
Michal Vasko | 2a3eef0 | 2015-12-11 14:38:34 +0100 | [diff] [blame] | 68 | int has_data; /**< 1 for content.data, 0 for content.xml_str */ |
| 69 | union { |
| 70 | struct lyd_node *data; /**< parsed RPC data */ |
| 71 | char *xml_str; /**< raw XML string */ |
| 72 | } content; |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 73 | char free; |
Radek Krejci | 926a574 | 2015-10-31 17:50:49 +0100 | [diff] [blame] | 74 | }; |
| 75 | |
Radek Krejci | 695d4fa | 2015-10-22 13:23:54 +0200 | [diff] [blame] | 76 | struct nc_rpc_getconfig { |
| 77 | NC_RPC_TYPE type; /**< NC_RPC_GETCONFIG */ |
| 78 | NC_DATASTORE source; /**< NETCONF datastore being queried */ |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 79 | 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] | 80 | NC_WD_MODE wd_mode; |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 81 | char free; |
Radek Krejci | 695d4fa | 2015-10-22 13:23:54 +0200 | [diff] [blame] | 82 | }; |
| 83 | |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 84 | struct nc_rpc_edit { |
| 85 | NC_RPC_TYPE type; /**< NC_RPC_EDIT */ |
| 86 | NC_DATASTORE target; |
| 87 | NC_RPC_EDIT_DFLTOP default_op; |
| 88 | NC_RPC_EDIT_TESTOPT test_opt; |
| 89 | NC_RPC_EDIT_ERROPT error_opt; |
| 90 | char *edit_cont; /**< either URL (starts with aplha) or config (starts with '<') */ |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 91 | char free; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 92 | }; |
| 93 | |
| 94 | struct nc_rpc_copy { |
| 95 | NC_RPC_TYPE type; /**< NC_RPC_COPY */ |
| 96 | NC_DATASTORE target; |
| 97 | char *url_trg; |
| 98 | NC_DATASTORE source; |
| 99 | 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] | 100 | NC_WD_MODE wd_mode; |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 101 | char free; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 102 | }; |
| 103 | |
| 104 | struct nc_rpc_delete { |
| 105 | NC_RPC_TYPE type; /**< NC_RPC_DELETE */ |
| 106 | NC_DATASTORE target; |
| 107 | char *url; |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 108 | char free; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 109 | }; |
| 110 | |
Radek Krejci | 695d4fa | 2015-10-22 13:23:54 +0200 | [diff] [blame] | 111 | struct nc_rpc_lock { |
| 112 | NC_RPC_TYPE type; /**< NC_RPC_LOCK or NC_RPC_UNLOCK */ |
| 113 | NC_DATASTORE target; |
Radek Krejci | 206fcd6 | 2015-10-07 15:42:48 +0200 | [diff] [blame] | 114 | }; |
| 115 | |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 116 | struct nc_rpc_get { |
| 117 | NC_RPC_TYPE type; /**< NC_RPC_GET */ |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 118 | 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] | 119 | NC_WD_MODE wd_mode; |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 120 | char free; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 121 | }; |
| 122 | |
| 123 | struct nc_rpc_kill { |
| 124 | NC_RPC_TYPE type; /**< NC_RPC_KILL */ |
| 125 | uint32_t sid; |
| 126 | }; |
| 127 | |
| 128 | struct nc_rpc_commit { |
| 129 | NC_RPC_TYPE type; /**< NC_RPC_COMMIT */ |
| 130 | int confirmed; |
| 131 | uint32_t confirm_timeout; |
| 132 | char *persist; |
| 133 | char *persist_id; |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 134 | char free; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 135 | }; |
| 136 | |
| 137 | struct nc_rpc_cancel { |
| 138 | NC_RPC_TYPE type; /**< NC_RPC_CANCEL */ |
| 139 | char *persist_id; |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 140 | char free; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 141 | }; |
| 142 | |
| 143 | struct nc_rpc_validate { |
| 144 | NC_RPC_TYPE type; /**< NC_RPC_VALIDATE */ |
| 145 | NC_DATASTORE source; |
| 146 | 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] | 147 | char free; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 148 | }; |
| 149 | |
| 150 | struct nc_rpc_getschema { |
| 151 | NC_RPC_TYPE type; /**< NC_RPC_GETSCHEMA */ |
| 152 | char *identifier; /**< requested model identifier */ |
| 153 | char *version; /**< either YANG version (1.0/1.1) or revision date */ |
| 154 | char *format; /**< model format */ |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 155 | char free; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 156 | }; |
| 157 | |
| 158 | struct nc_rpc_subscribe { |
| 159 | NC_RPC_TYPE type; /**< NC_RPC_SUBSCRIBE */ |
| 160 | char *stream; /**< stream name */ |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 161 | 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] | 162 | char *start; |
| 163 | char *stop; |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 164 | char free; |
Radek Krejci | 5686ff7 | 2015-10-09 13:33:56 +0200 | [diff] [blame] | 165 | }; |
| 166 | |
Michal Vasko | c1171a4 | 2019-11-05 12:06:46 +0100 | [diff] [blame] | 167 | struct nc_rpc_getdata { |
| 168 | NC_RPC_TYPE type; /**< NC_RPC_GETDATA */ |
| 169 | char *datastore; /**< target datastore identity */ |
| 170 | char *filter; /**< either XML subtree (starts with '<') or an XPath (starts with '/' or an alpha) */ |
| 171 | char *config_filter; /**< config filter ("true"/"false") */ |
| 172 | char **origin_filter; /**< origin filters */ |
| 173 | int origin_filter_count; /**< origin filter count */ |
| 174 | int negated_origin_filter; /**< whether origin filter is negated or not */ |
| 175 | int max_depth; /**< max depth of returned subtrees, 0 for unlimited */ |
| 176 | int with_origin; /**< whether to return origin of data */ |
| 177 | NC_WD_MODE wd_mode; |
| 178 | char free; |
| 179 | }; |
| 180 | |
| 181 | struct nc_rpc_editdata { |
| 182 | NC_RPC_TYPE type; /**< NC_RPC_EDITDATA */ |
| 183 | char *datastore; /**< target datastore identity */ |
| 184 | NC_RPC_EDIT_DFLTOP default_op; |
| 185 | char *edit_cont; /**< either URL (starts with aplha) or config (starts with '<') */ |
| 186 | char free; |
| 187 | }; |
| 188 | |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame] | 189 | struct nc_rpc_establishsub { |
| 190 | NC_RPC_TYPE type; /**< NC_RPC_ESTABLISHSUB */ |
| 191 | char *filter; /**< XML subtree (starts with '<'), an XPath (starts with '/'), or reference (start with alpha) */ |
| 192 | char *stream; /**< stream name */ |
| 193 | char *start; |
| 194 | char *stop; |
| 195 | char *encoding; |
| 196 | char free; |
| 197 | }; |
| 198 | |
| 199 | struct nc_rpc_modifysub { |
| 200 | NC_RPC_TYPE type; /**< NC_RPC_MODIFYSUB */ |
| 201 | uint32_t id; |
| 202 | char *filter; /**< XML subtree (starts with '<'), an XPath (starts with '/'), or reference (start with alpha) */ |
| 203 | char *stop; |
| 204 | char free; |
| 205 | }; |
| 206 | |
| 207 | struct nc_rpc_deletesub { |
| 208 | NC_RPC_TYPE type; /**< NC_RPC_DELETESUB */ |
| 209 | uint32_t id; |
| 210 | }; |
| 211 | |
| 212 | struct nc_rpc_killsub { |
| 213 | NC_RPC_TYPE type; /**< NC_RPC_KILLSUB */ |
| 214 | uint32_t id; |
| 215 | }; |
| 216 | |
Michal Vasko | 305faca | 2021-03-25 09:16:02 +0100 | [diff] [blame] | 217 | struct nc_rpc_establishpush { |
| 218 | NC_RPC_TYPE type; /**< NC_RPC_ESTABLISHPUSH */ |
| 219 | char *datastore; |
| 220 | char *filter; /**< XML subtree (starts with '<'), an XPath (starts with '/'), or reference (start with alpha) */ |
| 221 | char *stop; |
| 222 | char *encoding; |
| 223 | int periodic; |
| 224 | union { |
| 225 | struct { |
| 226 | uint32_t period; |
| 227 | char *anchor_time; |
| 228 | }; |
| 229 | struct { |
| 230 | uint32_t dampening_period; |
| 231 | int sync_on_start; |
| 232 | char **excluded_change; |
| 233 | }; |
| 234 | }; |
| 235 | char free; |
| 236 | }; |
| 237 | |
| 238 | struct nc_rpc_modifypush { |
| 239 | NC_RPC_TYPE type; /**< NC_RPC_MODIFYPUSH */ |
| 240 | uint32_t id; |
| 241 | char *datastore; |
| 242 | char *filter; /**< XML subtree (starts with '<'), an XPath (starts with '/'), or reference (start with alpha) */ |
| 243 | char *stop; |
| 244 | int periodic; |
| 245 | union { |
| 246 | struct { |
| 247 | uint32_t period; |
| 248 | char *anchor_time; |
| 249 | }; |
| 250 | uint32_t dampening_period; |
| 251 | }; |
| 252 | char free; |
| 253 | }; |
| 254 | |
| 255 | struct nc_rpc_resyncsub { |
| 256 | NC_RPC_TYPE type; /**< NC_RPC_RESYNCSUB */ |
| 257 | uint32_t id; |
| 258 | }; |
| 259 | |
Michal Vasko | 7736745 | 2021-02-16 16:32:18 +0100 | [diff] [blame] | 260 | void nc_server_rpc_free(struct nc_server_rpc *rpc); |
Michal Vasko | 05ba9df | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 261 | |
Radek Krejci | 36d2ee4 | 2017-10-13 13:55:59 +0200 | [diff] [blame] | 262 | void nc_client_err_clean(struct nc_err *err, struct ly_ctx *ctx); |
| 263 | |
Radek Krejci | 206fcd6 | 2015-10-07 15:42:48 +0200 | [diff] [blame] | 264 | #endif /* NC_MESSAGES_P_H_ */ |