Radek Krejci | 206fcd6 | 2015-10-07 15:42:48 +0200 | [diff] [blame] | 1 | /** |
| 2 | * \file messages_p.h |
| 3 | * \author Radek Krejci <rkrejci@cesnet.cz> |
| 4 | * \brief libnetconf2's private functions and structures of NETCONF messages. |
| 5 | * |
| 6 | * Copyright (c) 2015 CESNET, z.s.p.o. |
| 7 | * |
Radek Krejci | 9b81f5b | 2016-02-24 13:14:49 +0100 | [diff] [blame] | 8 | * 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 Vasko | afd416b | 2016-02-25 14:51:46 +0100 | [diff] [blame] | 11 | * |
Radek Krejci | 9b81f5b | 2016-02-24 13:14:49 +0100 | [diff] [blame] | 12 | * https://opensource.org/licenses/BSD-3-Clause |
Radek Krejci | 206fcd6 | 2015-10-07 15:42:48 +0200 | [diff] [blame] | 13 | */ |
| 14 | |
| 15 | #ifndef NC_MESSAGES_P_H_ |
| 16 | #define NC_MESSAGES_P_H_ |
| 17 | |
| 18 | #include <libyang/libyang.h> |
| 19 | |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 20 | #include "messages_server.h" |
| 21 | #include "messages_client.h" |
Radek Krejci | 4339024 | 2015-10-08 15:34:04 +0200 | [diff] [blame] | 22 | |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 23 | extern const char *rpcedit_dfltop2str[]; |
| 24 | extern const char *rpcedit_testopt2str[]; |
| 25 | extern const char *rpcedit_erropt2str[]; |
| 26 | |
Michal Vasko | 05ba9df | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 27 | struct nc_server_error { |
| 28 | NC_ERR_TYPE type; |
| 29 | NC_ERR tag; |
| 30 | //NC_ERR_SEV severity; |
| 31 | const char *apptag; |
| 32 | const char *path; |
| 33 | const char *message; |
| 34 | const char *message_lang; |
| 35 | |
| 36 | /* <error-info> */ |
Michal Vasko | 90920b0 | 2016-05-20 14:07:00 +0200 | [diff] [blame] | 37 | int64_t sid; /* -1 for not set */ |
Michal Vasko | 05ba9df | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 38 | const char **attr; |
| 39 | uint16_t attr_count; |
| 40 | const char **elem; |
| 41 | uint16_t elem_count; |
| 42 | const char **ns; |
| 43 | uint16_t ns_count; |
| 44 | struct lyxml_elem **other; |
| 45 | uint16_t other_count; |
| 46 | }; |
| 47 | |
| 48 | struct nc_server_reply { |
| 49 | NC_RPL type; |
| 50 | }; |
| 51 | |
| 52 | struct nc_server_reply_data { |
| 53 | NC_RPL type; |
| 54 | struct lyd_node *data; |
| 55 | char free; |
Radek Krejci | 36dfdb3 | 2016-09-01 16:56:35 +0200 | [diff] [blame] | 56 | NC_WD_MODE wd; |
Michal Vasko | 05ba9df | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | struct nc_server_reply_error { |
| 60 | NC_RPL type; |
| 61 | struct ly_ctx *ctx; |
| 62 | struct nc_server_error **err; |
| 63 | uint32_t count; |
| 64 | }; |
Radek Krejci | 695d4fa | 2015-10-22 13:23:54 +0200 | [diff] [blame] | 65 | |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 66 | struct nc_server_rpc { |
Radek Krejci | 695d4fa | 2015-10-22 13:23:54 +0200 | [diff] [blame] | 67 | struct lyxml_elem *root; /**< RPC element of the received XML message */ |
| 68 | struct lyd_node *tree; /**< libyang data tree of the message (NETCONF operation) */ |
| 69 | }; |
| 70 | |
Radek Krejci | 93e8022 | 2016-10-03 13:34:25 +0200 | [diff] [blame] | 71 | struct nc_server_notif { |
| 72 | char *eventtime; /**< eventTime of the notification */ |
| 73 | struct lyd_node *tree; /**< libyang data tree of the message */ |
Michal Vasko | fc9dbdd | 2017-03-17 09:27:57 +0100 | [diff] [blame] | 74 | int free; |
Radek Krejci | 93e8022 | 2016-10-03 13:34:25 +0200 | [diff] [blame] | 75 | }; |
| 76 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 77 | struct nc_client_reply_error { |
| 78 | NC_RPL type; |
| 79 | struct nc_err *err; |
| 80 | uint32_t count; |
| 81 | struct ly_ctx *ctx; |
| 82 | }; |
| 83 | |
Michal Vasko | 2a3eef0 | 2015-12-11 14:38:34 +0100 | [diff] [blame] | 84 | struct nc_rpc { |
| 85 | NC_RPC_TYPE type; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 86 | }; |
| 87 | |
Michal Vasko | 90e8e69 | 2016-07-13 12:27:57 +0200 | [diff] [blame] | 88 | struct nc_rpc_act_generic { |
| 89 | NC_RPC_TYPE type; /**< NC_RPC_ACT_GENERIC */ |
Michal Vasko | 2a3eef0 | 2015-12-11 14:38:34 +0100 | [diff] [blame] | 90 | int has_data; /**< 1 for content.data, 0 for content.xml_str */ |
| 91 | union { |
| 92 | struct lyd_node *data; /**< parsed RPC data */ |
| 93 | char *xml_str; /**< raw XML string */ |
| 94 | } content; |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 95 | char free; |
Radek Krejci | 926a574 | 2015-10-31 17:50:49 +0100 | [diff] [blame] | 96 | }; |
| 97 | |
Radek Krejci | 695d4fa | 2015-10-22 13:23:54 +0200 | [diff] [blame] | 98 | struct nc_rpc_getconfig { |
| 99 | NC_RPC_TYPE type; /**< NC_RPC_GETCONFIG */ |
| 100 | NC_DATASTORE source; /**< NETCONF datastore being queried */ |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 101 | 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] | 102 | NC_WD_MODE wd_mode; |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 103 | char free; |
Radek Krejci | 695d4fa | 2015-10-22 13:23:54 +0200 | [diff] [blame] | 104 | }; |
| 105 | |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 106 | struct nc_rpc_edit { |
| 107 | NC_RPC_TYPE type; /**< NC_RPC_EDIT */ |
| 108 | NC_DATASTORE target; |
| 109 | NC_RPC_EDIT_DFLTOP default_op; |
| 110 | NC_RPC_EDIT_TESTOPT test_opt; |
| 111 | NC_RPC_EDIT_ERROPT error_opt; |
| 112 | char *edit_cont; /**< either URL (starts with aplha) or config (starts with '<') */ |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 113 | char free; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 114 | }; |
| 115 | |
| 116 | struct nc_rpc_copy { |
| 117 | NC_RPC_TYPE type; /**< NC_RPC_COPY */ |
| 118 | NC_DATASTORE target; |
| 119 | char *url_trg; |
| 120 | NC_DATASTORE source; |
| 121 | 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] | 122 | NC_WD_MODE wd_mode; |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 123 | char free; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 124 | }; |
| 125 | |
| 126 | struct nc_rpc_delete { |
| 127 | NC_RPC_TYPE type; /**< NC_RPC_DELETE */ |
| 128 | NC_DATASTORE target; |
| 129 | char *url; |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 130 | char free; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 131 | }; |
| 132 | |
Radek Krejci | 695d4fa | 2015-10-22 13:23:54 +0200 | [diff] [blame] | 133 | struct nc_rpc_lock { |
| 134 | NC_RPC_TYPE type; /**< NC_RPC_LOCK or NC_RPC_UNLOCK */ |
| 135 | NC_DATASTORE target; |
Radek Krejci | 206fcd6 | 2015-10-07 15:42:48 +0200 | [diff] [blame] | 136 | }; |
| 137 | |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 138 | struct nc_rpc_get { |
| 139 | NC_RPC_TYPE type; /**< NC_RPC_GET */ |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 140 | 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] | 141 | NC_WD_MODE wd_mode; |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 142 | char free; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 143 | }; |
| 144 | |
| 145 | struct nc_rpc_kill { |
| 146 | NC_RPC_TYPE type; /**< NC_RPC_KILL */ |
| 147 | uint32_t sid; |
| 148 | }; |
| 149 | |
| 150 | struct nc_rpc_commit { |
| 151 | NC_RPC_TYPE type; /**< NC_RPC_COMMIT */ |
| 152 | int confirmed; |
| 153 | uint32_t confirm_timeout; |
| 154 | char *persist; |
| 155 | char *persist_id; |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 156 | char free; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 157 | }; |
| 158 | |
| 159 | struct nc_rpc_cancel { |
| 160 | NC_RPC_TYPE type; /**< NC_RPC_CANCEL */ |
| 161 | char *persist_id; |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 162 | char free; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 163 | }; |
| 164 | |
| 165 | struct nc_rpc_validate { |
| 166 | NC_RPC_TYPE type; /**< NC_RPC_VALIDATE */ |
| 167 | NC_DATASTORE source; |
| 168 | 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] | 169 | char free; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 170 | }; |
| 171 | |
| 172 | struct nc_rpc_getschema { |
| 173 | NC_RPC_TYPE type; /**< NC_RPC_GETSCHEMA */ |
| 174 | char *identifier; /**< requested model identifier */ |
| 175 | char *version; /**< either YANG version (1.0/1.1) or revision date */ |
| 176 | char *format; /**< model format */ |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 177 | char free; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 178 | }; |
| 179 | |
| 180 | struct nc_rpc_subscribe { |
| 181 | NC_RPC_TYPE type; /**< NC_RPC_SUBSCRIBE */ |
| 182 | char *stream; /**< stream name */ |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 183 | 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] | 184 | char *start; |
| 185 | char *stop; |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 186 | char free; |
Radek Krejci | 5686ff7 | 2015-10-09 13:33:56 +0200 | [diff] [blame] | 187 | }; |
| 188 | |
Michal Vasko | c1171a4 | 2019-11-05 12:06:46 +0100 | [diff] [blame] | 189 | struct nc_rpc_getdata { |
| 190 | NC_RPC_TYPE type; /**< NC_RPC_GETDATA */ |
| 191 | char *datastore; /**< target datastore identity */ |
| 192 | char *filter; /**< either XML subtree (starts with '<') or an XPath (starts with '/' or an alpha) */ |
| 193 | char *config_filter; /**< config filter ("true"/"false") */ |
| 194 | char **origin_filter; /**< origin filters */ |
| 195 | int origin_filter_count; /**< origin filter count */ |
| 196 | int negated_origin_filter; /**< whether origin filter is negated or not */ |
| 197 | int max_depth; /**< max depth of returned subtrees, 0 for unlimited */ |
| 198 | int with_origin; /**< whether to return origin of data */ |
| 199 | NC_WD_MODE wd_mode; |
| 200 | char free; |
| 201 | }; |
| 202 | |
| 203 | struct nc_rpc_editdata { |
| 204 | NC_RPC_TYPE type; /**< NC_RPC_EDITDATA */ |
| 205 | char *datastore; /**< target datastore identity */ |
| 206 | NC_RPC_EDIT_DFLTOP default_op; |
| 207 | char *edit_cont; /**< either URL (starts with aplha) or config (starts with '<') */ |
| 208 | char free; |
| 209 | }; |
| 210 | |
Michal Vasko | ca4a242 | 2016-02-02 12:17:14 +0100 | [diff] [blame] | 211 | void nc_server_rpc_free(struct nc_server_rpc *rpc, struct ly_ctx *ctx); |
Michal Vasko | 05ba9df | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 212 | |
Radek Krejci | 36d2ee4 | 2017-10-13 13:55:59 +0200 | [diff] [blame] | 213 | void nc_client_err_clean(struct nc_err *err, struct ly_ctx *ctx); |
| 214 | |
Radek Krejci | 206fcd6 | 2015-10-07 15:42:48 +0200 | [diff] [blame] | 215 | #endif /* NC_MESSAGES_P_H_ */ |