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 | * |
| 8 | * Redistribution and use in source and binary forms, with or without |
| 9 | * modification, are permitted provided that the following conditions |
| 10 | * are met: |
| 11 | * 1. Redistributions of source code must retain the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer. |
| 13 | * 2. Redistributions in binary form must reproduce the above copyright |
| 14 | * notice, this list of conditions and the following disclaimer in |
| 15 | * the documentation and/or other materials provided with the |
| 16 | * distribution. |
| 17 | * 3. Neither the name of the Company nor the names of its contributors |
| 18 | * may be used to endorse or promote products derived from this |
| 19 | * software without specific prior written permission. |
| 20 | * |
| 21 | */ |
| 22 | |
| 23 | #ifndef NC_MESSAGES_P_H_ |
| 24 | #define NC_MESSAGES_P_H_ |
| 25 | |
| 26 | #include <libyang/libyang.h> |
| 27 | |
Radek Krejci | 4339024 | 2015-10-08 15:34:04 +0200 | [diff] [blame] | 28 | #include "messages.h" |
| 29 | |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 30 | extern const char *rpcedit_dfltop2str[]; |
| 31 | extern const char *rpcedit_testopt2str[]; |
| 32 | extern const char *rpcedit_erropt2str[]; |
| 33 | |
Michal Vasko | 05ba9df | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 34 | struct nc_server_error { |
| 35 | NC_ERR_TYPE type; |
| 36 | NC_ERR tag; |
| 37 | //NC_ERR_SEV severity; |
| 38 | const char *apptag; |
| 39 | const char *path; |
| 40 | const char *message; |
| 41 | const char *message_lang; |
| 42 | |
| 43 | /* <error-info> */ |
| 44 | uint32_t sid; |
| 45 | const char **attr; |
| 46 | uint16_t attr_count; |
| 47 | const char **elem; |
| 48 | uint16_t elem_count; |
| 49 | const char **ns; |
| 50 | uint16_t ns_count; |
| 51 | struct lyxml_elem **other; |
| 52 | uint16_t other_count; |
| 53 | }; |
| 54 | |
| 55 | struct nc_server_reply { |
| 56 | NC_RPL type; |
| 57 | }; |
| 58 | |
| 59 | struct nc_server_reply_data { |
| 60 | NC_RPL type; |
| 61 | struct lyd_node *data; |
| 62 | char free; |
| 63 | }; |
| 64 | |
| 65 | struct nc_server_reply_error { |
| 66 | NC_RPL type; |
| 67 | struct ly_ctx *ctx; |
| 68 | struct nc_server_error **err; |
| 69 | uint32_t count; |
| 70 | }; |
Radek Krejci | 695d4fa | 2015-10-22 13:23:54 +0200 | [diff] [blame] | 71 | |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 72 | struct nc_server_rpc { |
Radek Krejci | 695d4fa | 2015-10-22 13:23:54 +0200 | [diff] [blame] | 73 | struct lyxml_elem *root; /**< RPC element of the received XML message */ |
| 74 | struct lyd_node *tree; /**< libyang data tree of the message (NETCONF operation) */ |
| 75 | }; |
| 76 | |
Michal Vasko | 2a3eef0 | 2015-12-11 14:38:34 +0100 | [diff] [blame] | 77 | struct nc_rpc { |
| 78 | NC_RPC_TYPE type; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 79 | }; |
| 80 | |
Michal Vasko | 2a3eef0 | 2015-12-11 14:38:34 +0100 | [diff] [blame] | 81 | struct nc_rpc_generic { |
| 82 | NC_RPC_TYPE type; /**< NC_RPC_GENERIC */ |
| 83 | int has_data; /**< 1 for content.data, 0 for content.xml_str */ |
| 84 | union { |
| 85 | struct lyd_node *data; /**< parsed RPC data */ |
| 86 | char *xml_str; /**< raw XML string */ |
| 87 | } content; |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 88 | char free; |
Radek Krejci | 926a574 | 2015-10-31 17:50:49 +0100 | [diff] [blame] | 89 | }; |
| 90 | |
Radek Krejci | 695d4fa | 2015-10-22 13:23:54 +0200 | [diff] [blame] | 91 | struct nc_rpc_getconfig { |
| 92 | NC_RPC_TYPE type; /**< NC_RPC_GETCONFIG */ |
| 93 | NC_DATASTORE source; /**< NETCONF datastore being queried */ |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 94 | 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] | 95 | NC_WD_MODE wd_mode; |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 96 | char free; |
Radek Krejci | 695d4fa | 2015-10-22 13:23:54 +0200 | [diff] [blame] | 97 | }; |
| 98 | |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 99 | struct nc_rpc_edit { |
| 100 | NC_RPC_TYPE type; /**< NC_RPC_EDIT */ |
| 101 | NC_DATASTORE target; |
| 102 | NC_RPC_EDIT_DFLTOP default_op; |
| 103 | NC_RPC_EDIT_TESTOPT test_opt; |
| 104 | NC_RPC_EDIT_ERROPT error_opt; |
| 105 | char *edit_cont; /**< either URL (starts with aplha) or config (starts with '<') */ |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 106 | char free; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 107 | }; |
| 108 | |
| 109 | struct nc_rpc_copy { |
| 110 | NC_RPC_TYPE type; /**< NC_RPC_COPY */ |
| 111 | NC_DATASTORE target; |
| 112 | char *url_trg; |
| 113 | NC_DATASTORE source; |
| 114 | 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] | 115 | NC_WD_MODE wd_mode; |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 116 | char free; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 117 | }; |
| 118 | |
| 119 | struct nc_rpc_delete { |
| 120 | NC_RPC_TYPE type; /**< NC_RPC_DELETE */ |
| 121 | NC_DATASTORE target; |
| 122 | char *url; |
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 | |
Radek Krejci | 695d4fa | 2015-10-22 13:23:54 +0200 | [diff] [blame] | 126 | struct nc_rpc_lock { |
| 127 | NC_RPC_TYPE type; /**< NC_RPC_LOCK or NC_RPC_UNLOCK */ |
| 128 | NC_DATASTORE target; |
Radek Krejci | 206fcd6 | 2015-10-07 15:42:48 +0200 | [diff] [blame] | 129 | }; |
| 130 | |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 131 | struct nc_rpc_get { |
| 132 | NC_RPC_TYPE type; /**< NC_RPC_GET */ |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 133 | 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] | 134 | NC_WD_MODE wd_mode; |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 135 | char free; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 136 | }; |
| 137 | |
| 138 | struct nc_rpc_kill { |
| 139 | NC_RPC_TYPE type; /**< NC_RPC_KILL */ |
| 140 | uint32_t sid; |
| 141 | }; |
| 142 | |
| 143 | struct nc_rpc_commit { |
| 144 | NC_RPC_TYPE type; /**< NC_RPC_COMMIT */ |
| 145 | int confirmed; |
| 146 | uint32_t confirm_timeout; |
| 147 | char *persist; |
| 148 | char *persist_id; |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 149 | char free; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 150 | }; |
| 151 | |
| 152 | struct nc_rpc_cancel { |
| 153 | NC_RPC_TYPE type; /**< NC_RPC_CANCEL */ |
| 154 | char *persist_id; |
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_validate { |
| 159 | NC_RPC_TYPE type; /**< NC_RPC_VALIDATE */ |
| 160 | NC_DATASTORE source; |
| 161 | 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] | 162 | char free; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 163 | }; |
| 164 | |
| 165 | struct nc_rpc_getschema { |
| 166 | NC_RPC_TYPE type; /**< NC_RPC_GETSCHEMA */ |
| 167 | char *identifier; /**< requested model identifier */ |
| 168 | char *version; /**< either YANG version (1.0/1.1) or revision date */ |
| 169 | char *format; /**< model format */ |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 170 | char free; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 171 | }; |
| 172 | |
| 173 | struct nc_rpc_subscribe { |
| 174 | NC_RPC_TYPE type; /**< NC_RPC_SUBSCRIBE */ |
| 175 | char *stream; /**< stream name */ |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 176 | 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] | 177 | char *start; |
| 178 | char *stop; |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 179 | char free; |
Radek Krejci | 5686ff7 | 2015-10-09 13:33:56 +0200 | [diff] [blame] | 180 | }; |
| 181 | |
Michal Vasko | 05ba9df | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 182 | void nc_server_rpc_free(struct nc_server_rpc *rpc); |
| 183 | |
Radek Krejci | 206fcd6 | 2015-10-07 15:42:48 +0200 | [diff] [blame] | 184 | #endif /* NC_MESSAGES_P_H_ */ |