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 | |
Radek Krejci | 695d4fa | 2015-10-22 13:23:54 +0200 | [diff] [blame] | 34 | typedef enum { |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 35 | NC_RPC_GENERIC, /**< user-defined generic RPC with content as data. */ |
| 36 | NC_RPC_GENERIC_XML, /**< user-defined generic RPC with content as an XML string. */ |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 37 | |
| 38 | /* ietf-netconf */ |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 39 | NC_RPC_GETCONFIG, /**< \<get-config\> RPC. */ |
| 40 | NC_RPC_EDIT, /**< \<edit-config\> RPC. */ |
| 41 | NC_RPC_COPY, /**< \<copy-config\> RPC. */ |
| 42 | NC_RPC_DELETE, /**< \<delete-config\> RPC. */ |
| 43 | NC_RPC_LOCK, /**< \<lock\> RPC. */ |
| 44 | NC_RPC_UNLOCK, /**< \<unlock\> RPC. */ |
| 45 | NC_RPC_GET, /**< \<get\> RPC. */ |
Radek Krejci | 695d4fa | 2015-10-22 13:23:54 +0200 | [diff] [blame] | 46 | /* NC_RPC_CLOSE is not defined since sending \<close-session\> is done by nc_session_free() */ |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 47 | NC_RPC_KILL, /**< \<kill-session\> RPC. */ |
| 48 | NC_RPC_COMMIT, /**< \<commit\> RPC. */ |
| 49 | NC_RPC_DISCARD, /**< \<discard-changes\> RPC. */ |
| 50 | NC_RPC_CANCEL, /**< \<cancel-commit\> RPC. */ |
| 51 | NC_RPC_VALIDATE, /**< \<validate\> RPC. */ |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 52 | |
| 53 | /* ietf-netconf-monitoring */ |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 54 | NC_RPC_GETSCHEMA, /**< \<get-schema\> RPC. */ |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 55 | |
| 56 | /* notifications */ |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 57 | NC_RPC_SUBSCRIBE /**< \<create-subscription\> RPC. */ |
Radek Krejci | 695d4fa | 2015-10-22 13:23:54 +0200 | [diff] [blame] | 58 | } NC_RPC_TYPE; |
| 59 | |
Radek Krejci | 8800a49 | 2015-10-31 17:51:27 +0100 | [diff] [blame] | 60 | typedef enum { |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 61 | NC_ERR_EMPTY, |
| 62 | NC_ERR_IN_USE, |
| 63 | NC_ERR_INVALID_VALUE, |
| 64 | NC_ERR_TOO_BIG, |
| 65 | NC_ERR_MISSING_ATTR, |
| 66 | NC_ERR_BAD_ATTR, |
| 67 | NC_ERR_UNKNOWN_ATTR, |
| 68 | NC_ERR_MISSING_ELEM, |
| 69 | NC_ERR_BAD_ELEM, |
| 70 | NC_ERR_UNKNOWN_ELEM, |
| 71 | NC_ERR_UNKNOWN_NS, |
| 72 | NC_ERR_ACCESS_DENIED, |
| 73 | NC_ERR_LOCK_DENIED, |
| 74 | NC_ERR_RES_DENIED, |
| 75 | NC_ERR_ROLLBACK_FAILED, |
| 76 | NC_ERR_DATA_EXISTS, |
| 77 | NC_ERR_DATA_MISSING, |
| 78 | NC_ERR_OP_NOT_SUPPORTED, |
| 79 | NC_ERR_OP_FAILED, |
| 80 | NC_ERR_MALFORMED_MSG |
| 81 | } NC_ERR; |
Radek Krejci | 695d4fa | 2015-10-22 13:23:54 +0200 | [diff] [blame] | 82 | |
Radek Krejci | 206fcd6 | 2015-10-07 15:42:48 +0200 | [diff] [blame] | 83 | struct nc_rpc { |
Radek Krejci | 695d4fa | 2015-10-22 13:23:54 +0200 | [diff] [blame] | 84 | NC_RPC_TYPE type; |
| 85 | }; |
| 86 | |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 87 | struct nc_server_rpc { |
Radek Krejci | 695d4fa | 2015-10-22 13:23:54 +0200 | [diff] [blame] | 88 | struct lyxml_elem *root; /**< RPC element of the received XML message */ |
| 89 | struct lyd_node *tree; /**< libyang data tree of the message (NETCONF operation) */ |
| 90 | }; |
| 91 | |
Michal Vasko | 2a3eef0 | 2015-12-11 14:38:34 +0100 | [diff] [blame^] | 92 | struct nc_rpc { |
| 93 | NC_RPC_TYPE type; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 94 | }; |
| 95 | |
Michal Vasko | 2a3eef0 | 2015-12-11 14:38:34 +0100 | [diff] [blame^] | 96 | struct nc_rpc_generic { |
| 97 | NC_RPC_TYPE type; /**< NC_RPC_GENERIC */ |
| 98 | int has_data; /**< 1 for content.data, 0 for content.xml_str */ |
| 99 | union { |
| 100 | struct lyd_node *data; /**< parsed RPC data */ |
| 101 | char *xml_str; /**< raw XML string */ |
| 102 | } content; |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 103 | char free; |
Radek Krejci | 926a574 | 2015-10-31 17:50:49 +0100 | [diff] [blame] | 104 | }; |
| 105 | |
Radek Krejci | 695d4fa | 2015-10-22 13:23:54 +0200 | [diff] [blame] | 106 | struct nc_rpc_getconfig { |
| 107 | NC_RPC_TYPE type; /**< NC_RPC_GETCONFIG */ |
| 108 | NC_DATASTORE source; /**< NETCONF datastore being queried */ |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 109 | 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] | 110 | NC_WD_MODE wd_mode; |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 111 | char free; |
Radek Krejci | 695d4fa | 2015-10-22 13:23:54 +0200 | [diff] [blame] | 112 | }; |
| 113 | |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 114 | struct nc_rpc_edit { |
| 115 | NC_RPC_TYPE type; /**< NC_RPC_EDIT */ |
| 116 | NC_DATASTORE target; |
| 117 | NC_RPC_EDIT_DFLTOP default_op; |
| 118 | NC_RPC_EDIT_TESTOPT test_opt; |
| 119 | NC_RPC_EDIT_ERROPT error_opt; |
| 120 | char *edit_cont; /**< either URL (starts with aplha) or config (starts with '<') */ |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 121 | char free; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 122 | }; |
| 123 | |
| 124 | struct nc_rpc_copy { |
| 125 | NC_RPC_TYPE type; /**< NC_RPC_COPY */ |
| 126 | NC_DATASTORE target; |
| 127 | char *url_trg; |
| 128 | NC_DATASTORE source; |
| 129 | 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] | 130 | NC_WD_MODE wd_mode; |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 131 | char free; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 132 | }; |
| 133 | |
| 134 | struct nc_rpc_delete { |
| 135 | NC_RPC_TYPE type; /**< NC_RPC_DELETE */ |
| 136 | NC_DATASTORE target; |
| 137 | char *url; |
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 | |
Radek Krejci | 695d4fa | 2015-10-22 13:23:54 +0200 | [diff] [blame] | 141 | struct nc_rpc_lock { |
| 142 | NC_RPC_TYPE type; /**< NC_RPC_LOCK or NC_RPC_UNLOCK */ |
| 143 | NC_DATASTORE target; |
Radek Krejci | 206fcd6 | 2015-10-07 15:42:48 +0200 | [diff] [blame] | 144 | }; |
| 145 | |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 146 | struct nc_rpc_get { |
| 147 | NC_RPC_TYPE type; /**< NC_RPC_GET */ |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 148 | 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] | 149 | NC_WD_MODE wd_mode; |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 150 | char free; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 151 | }; |
| 152 | |
| 153 | struct nc_rpc_kill { |
| 154 | NC_RPC_TYPE type; /**< NC_RPC_KILL */ |
| 155 | uint32_t sid; |
| 156 | }; |
| 157 | |
| 158 | struct nc_rpc_commit { |
| 159 | NC_RPC_TYPE type; /**< NC_RPC_COMMIT */ |
| 160 | int confirmed; |
| 161 | uint32_t confirm_timeout; |
| 162 | char *persist; |
| 163 | char *persist_id; |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 164 | char free; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 165 | }; |
| 166 | |
| 167 | struct nc_rpc_cancel { |
| 168 | NC_RPC_TYPE type; /**< NC_RPC_CANCEL */ |
| 169 | char *persist_id; |
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_validate { |
| 174 | NC_RPC_TYPE type; /**< NC_RPC_VALIDATE */ |
| 175 | NC_DATASTORE source; |
| 176 | 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] | 177 | char free; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 178 | }; |
| 179 | |
| 180 | struct nc_rpc_getschema { |
| 181 | NC_RPC_TYPE type; /**< NC_RPC_GETSCHEMA */ |
| 182 | char *identifier; /**< requested model identifier */ |
| 183 | char *version; /**< either YANG version (1.0/1.1) or revision date */ |
| 184 | char *format; /**< model format */ |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 185 | char free; |
Michal Vasko | ad92811 | 2015-11-25 15:52:10 +0100 | [diff] [blame] | 186 | }; |
| 187 | |
| 188 | struct nc_rpc_subscribe { |
| 189 | NC_RPC_TYPE type; /**< NC_RPC_SUBSCRIBE */ |
| 190 | char *stream; /**< stream name */ |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 191 | 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] | 192 | char *start; |
| 193 | char *stop; |
Michal Vasko | ad61170 | 2015-12-03 13:41:51 +0100 | [diff] [blame] | 194 | char free; |
Radek Krejci | 5686ff7 | 2015-10-09 13:33:56 +0200 | [diff] [blame] | 195 | }; |
| 196 | |
Radek Krejci | 206fcd6 | 2015-10-07 15:42:48 +0200 | [diff] [blame] | 197 | #endif /* NC_MESSAGES_P_H_ */ |