Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 1 | /** |
| 2 | * \file messages_client.h |
| 3 | * \author Radek Krejci <rkrejci@cesnet.cz> |
| 4 | * \author Michal Vasko <mvasko@cesnet.cz> |
| 5 | * \brief libnetconf2's public functions and structures of NETCONF client messages. |
| 6 | * |
| 7 | * Copyright (c) 2015 CESNET, z.s.p.o. |
| 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 |
| 12 | * |
| 13 | * https://opensource.org/licenses/BSD-3-Clause |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #ifndef NC_MESSAGES_CLIENT_H_ |
| 17 | #define NC_MESSAGES_CLIENT_H_ |
| 18 | |
| 19 | #include <stdint.h> |
| 20 | |
| 21 | #include "netconf.h" |
| 22 | |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 23 | /** |
| 24 | * @brief Enumeration of RPC types |
| 25 | */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 26 | typedef enum { |
Michal Vasko | 7f1c78b | 2016-01-19 09:52:14 +0100 | [diff] [blame] | 27 | NC_RPC_UNKNOWN = 0, /**< invalid RPC. */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 28 | NC_RPC_GENERIC, /**< user-defined generic RPC. */ |
| 29 | |
| 30 | /* ietf-netconf */ |
| 31 | NC_RPC_GETCONFIG, /**< \<get-config\> RPC. */ |
| 32 | NC_RPC_EDIT, /**< \<edit-config\> RPC. */ |
| 33 | NC_RPC_COPY, /**< \<copy-config\> RPC. */ |
| 34 | NC_RPC_DELETE, /**< \<delete-config\> RPC. */ |
| 35 | NC_RPC_LOCK, /**< \<lock\> RPC. */ |
| 36 | NC_RPC_UNLOCK, /**< \<unlock\> RPC. */ |
| 37 | NC_RPC_GET, /**< \<get\> RPC. */ |
| 38 | /* NC_RPC_CLOSE is not defined since sending \<close-session\> is done by nc_session_free() */ |
| 39 | NC_RPC_KILL, /**< \<kill-session\> RPC. */ |
| 40 | NC_RPC_COMMIT, /**< \<commit\> RPC. */ |
| 41 | NC_RPC_DISCARD, /**< \<discard-changes\> RPC. */ |
| 42 | NC_RPC_CANCEL, /**< \<cancel-commit\> RPC. */ |
| 43 | NC_RPC_VALIDATE, /**< \<validate\> RPC. */ |
| 44 | |
| 45 | /* ietf-netconf-monitoring */ |
| 46 | NC_RPC_GETSCHEMA, /**< \<get-schema\> RPC. */ |
| 47 | |
| 48 | /* notifications */ |
| 49 | NC_RPC_SUBSCRIBE /**< \<create-subscription\> RPC. */ |
| 50 | } NC_RPC_TYPE; |
| 51 | |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 52 | /** |
| 53 | * @brief Enumeration of \<edit-config\> default operation |
| 54 | */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 55 | typedef enum { |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 56 | NC_RPC_EDIT_DFLTOP_UNKNOWN = 0, /**< unknown default operation */ |
| 57 | NC_RPC_EDIT_DFLTOP_MERGE, /**< default operation merge */ |
| 58 | NC_RPC_EDIT_DFLTOP_REPLACE, /**< default operation replace */ |
| 59 | NC_RPC_EDIT_DFLTOP_NONE /**< default operation none */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 60 | } NC_RPC_EDIT_DFLTOP; |
| 61 | |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 62 | /** |
| 63 | * @brief Enumeration of \<edit-config\> test option |
| 64 | */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 65 | typedef enum { |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 66 | NC_RPC_EDIT_TESTOPT_UNKNOWN = 0, /**< unknown test option */ |
| 67 | NC_RPC_EDIT_TESTOPT_TESTSET, /**< test-then-set option */ |
| 68 | NC_RPC_EDIT_TESTOPT_SET, /**< set option */ |
| 69 | NC_RPC_EDIT_TESTOPT_TEST /**< test-only option */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 70 | } NC_RPC_EDIT_TESTOPT; |
| 71 | |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 72 | /** |
| 73 | * @brief Enumeration of \<edit-config\> error option |
| 74 | */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 75 | typedef enum { |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 76 | NC_RPC_EDIT_ERROPT_UNKNOWN = 0, /**< unknown error option */ |
| 77 | NC_RPC_EDIT_ERROPT_STOP, /**< stop-on-error option */ |
| 78 | NC_RPC_EDIT_ERROPT_CONTINUE, /**< continue-on-error option */ |
| 79 | NC_RPC_EDIT_ERROPT_ROLLBACK /**< rollback-on-error option */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 80 | } NC_RPC_EDIT_ERROPT; |
| 81 | |
| 82 | /** |
| 83 | * @brief NETCONF error structure representation |
| 84 | */ |
| 85 | struct nc_err { |
| 86 | /** |
| 87 | * @brief \<error-type\>, error layer where the error occurred. |
| 88 | */ |
| 89 | const char *type; |
| 90 | /** |
| 91 | * @brief \<error-tag\>. |
| 92 | */ |
| 93 | const char *tag; |
| 94 | /** |
| 95 | * @brief \<error-severity\>. |
| 96 | */ |
| 97 | const char *severity; |
| 98 | /** |
| 99 | * @brief \<error-app-tag\>, the data-model-specific or implementation-specific error condition, if one exists. |
| 100 | */ |
| 101 | const char *apptag; |
| 102 | /** |
| 103 | * @brief \<error-path\>, XPATH expression identifying the element with the error. |
| 104 | */ |
| 105 | const char *path; |
| 106 | /** |
| 107 | * @brief \<error-message\>, Human-readable description of the error. |
| 108 | */ |
| 109 | const char *message; |
| 110 | const char *message_lang; |
| 111 | |
| 112 | /* <error-info> */ |
| 113 | |
| 114 | /** |
| 115 | * @brief \<session-id\>, session ID of the session holding the requested lock. |
| 116 | */ |
| 117 | const char *sid; |
| 118 | /** |
| 119 | * @brief \<bad-attr\>, the name of the data-model-specific XML attribute that caused the error. |
| 120 | */ |
| 121 | const char **attr; |
| 122 | uint16_t attr_count; |
| 123 | /** |
| 124 | * @brief \<bad-element\>, the name of the data-model-specific XML element that caused the error. |
| 125 | */ |
| 126 | const char **elem; |
| 127 | uint16_t elem_count; |
| 128 | /** |
| 129 | * @brief \<bad-namespace\>, the name of the unexpected XML namespace that caused the error. |
| 130 | */ |
| 131 | const char **ns; |
| 132 | uint16_t ns_count; |
| 133 | /** |
| 134 | * @brief Remaining non-standard elements. |
| 135 | */ |
| 136 | struct lyxml_elem **other; |
| 137 | uint16_t other_count; |
| 138 | }; |
| 139 | |
| 140 | /** |
| 141 | * @brief NETCONF client RPC object |
| 142 | */ |
| 143 | struct nc_rpc; |
| 144 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 145 | /** |
| 146 | * @brief NETCONF client rpc-reply object |
| 147 | */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 148 | struct nc_reply { |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 149 | NC_RPL type; /**< reply type */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 150 | }; |
| 151 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 152 | /** |
| 153 | * @brief NETCONF client data rpc-reply object |
| 154 | */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 155 | struct nc_reply_data { |
| 156 | NC_RPL type; /**< NC_RPL_DATA */ |
| 157 | struct lyd_node *data; /**< libyang data tree */ |
| 158 | }; |
| 159 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 160 | /** |
| 161 | * @brief NETCONF client error rpc-reply object |
| 162 | */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 163 | struct nc_reply_error { |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 164 | NC_RPL type; /**< NC_RPL_ERROR */ |
| 165 | const struct nc_err *err; /**< errors, any of the values inside can be NULL */ |
| 166 | uint32_t count; /**< number of error structures */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 167 | }; |
| 168 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 169 | /** |
| 170 | * @brief NETCONF client notification object |
| 171 | */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 172 | struct nc_notif { |
| 173 | NC_RPL type; /**< NC_RPL_NOTIF */ |
| 174 | const char *datetime; /**< eventTime of the notification */ |
| 175 | struct lyd_node *tree; /**< libyang data tree of the message */ |
| 176 | }; |
| 177 | |
| 178 | /** |
| 179 | * @brief Get the type of the RPC |
| 180 | * |
| 181 | * @param[in] rpc RPC to check the type of. |
| 182 | * @return Type of \p rpc. |
| 183 | */ |
| 184 | NC_RPC_TYPE nc_rpc_get_type(const struct nc_rpc *rpc); |
| 185 | |
| 186 | /** |
| 187 | * @brief Create a generic NETCONF RPC |
| 188 | * |
| 189 | * Note that created object can be sent via any NETCONF session that shares the context |
| 190 | * of the \p data. |
| 191 | * |
| 192 | * @param[in] data NETCONF RPC data as a data tree. |
| 193 | * @param[in] paramtype How to further manage data parameters. |
| 194 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 195 | */ |
| 196 | struct nc_rpc *nc_rpc_generic(const struct lyd_node *data, NC_PARAMTYPE paramtype); |
| 197 | |
| 198 | /** |
| 199 | * @brief Create a generic NETCONF RPC from an XML string |
| 200 | * |
| 201 | * Note that functions to create any RPC object do not check validity of the provided |
| 202 | * parameters. It is checked later while sending the RPC via a specific NETCONF session |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 203 | * (#nc_send_rpc()) since the NETCONF capabilities of the session are needed for such a |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 204 | * check. Created object can be sent via any NETCONF session which supports all the |
| 205 | * needed NETCONF capabilities for the RPC. |
| 206 | * |
| 207 | * @param[in] xml_str NETCONF RPC data as an XML string. |
| 208 | * @param[in] paramtype How to further manage data parameters. |
| 209 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 210 | */ |
| 211 | struct nc_rpc *nc_rpc_generic_xml(const char *xml_str, NC_PARAMTYPE paramtype); |
| 212 | |
| 213 | /** |
| 214 | * @brief Create NETCONF RPC \<get-config\> |
| 215 | * |
| 216 | * Note that functions to create any RPC object do not check validity of the provided |
| 217 | * parameters. It is checked later while sending the RPC via a specific NETCONF session |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 218 | * (#nc_send_rpc()) since the NETCONF capabilities of the session are needed for such a |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 219 | * check. Created object can be sent via any NETCONF session which supports all the |
| 220 | * needed NETCONF capabilities for the RPC. |
| 221 | * |
| 222 | * @param[in] source Source datastore being queried. |
| 223 | * @param[in] filter Optional filter data, an XML subtree or XPath expression. |
| 224 | * @param[in] wd_mode Optional with-defaults capability mode. |
| 225 | * @param[in] paramtype How to further manage data parameters. |
| 226 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 227 | */ |
| 228 | struct nc_rpc *nc_rpc_getconfig(NC_DATASTORE source, const char *filter, NC_WD_MODE wd_mode, |
| 229 | NC_PARAMTYPE paramtype); |
| 230 | |
| 231 | /** |
| 232 | * @brief Create NETCONF RPC \<edit-config\> |
| 233 | * |
| 234 | * Note that functions to create any RPC object do not check validity of the provided |
| 235 | * parameters. It is checked later while sending the RPC via a specific NETCONF session |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 236 | * (#nc_send_rpc()) since the NETCONF capabilities of the session are needed for such a |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 237 | * check. Created object can be sent via any NETCONF session which supports all the |
| 238 | * needed NETCONF capabilities for the RPC. |
| 239 | * |
| 240 | * @param[in] target Target datastore being edited. |
| 241 | * @param[in] default_op Optional default operation. |
| 242 | * @param[in] test_opt Optional test option. |
| 243 | * @param[in] error_opt Optional error option. |
| 244 | * @param[in] edit_content Config or URL where the config to perform is to be found. |
| 245 | * @param[in] paramtype How to further manage data parameters. |
| 246 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 247 | */ |
| 248 | struct nc_rpc *nc_rpc_edit(NC_DATASTORE target, NC_RPC_EDIT_DFLTOP default_op, NC_RPC_EDIT_TESTOPT test_opt, |
| 249 | NC_RPC_EDIT_ERROPT error_opt, const char *edit_content, NC_PARAMTYPE paramtype); |
| 250 | |
| 251 | /** |
| 252 | * @brief Create NETCONF RPC \<copy-config\> |
| 253 | * |
| 254 | * Note that functions to create any RPC object do not check validity of the provided |
| 255 | * parameters. It is checked later while sending the RPC via a specific NETCONF session |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 256 | * (#nc_send_rpc()) since the NETCONF capabilities of the session are needed for such a |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 257 | * check. Created object can be sent via any NETCONF session which supports all the |
| 258 | * needed NETCONF capabilities for the RPC. |
| 259 | * |
| 260 | * @param[in] target Target datastore. |
| 261 | * @param[in] url_trg Used instead \p target if the target is an URL. |
| 262 | * @param[in] source Source datastore. |
| 263 | * @param[in] url_or_config_src Used instead \p source if the source is an URL or a config. |
| 264 | * @param[in] wd_mode Optional with-defaults capability mode. |
| 265 | * @param[in] paramtype How to further manage data parameters. |
| 266 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 267 | */ |
| 268 | struct nc_rpc *nc_rpc_copy(NC_DATASTORE target, const char *url_trg, NC_DATASTORE source, |
| 269 | const char *url_or_config_src, NC_WD_MODE wd_mode, NC_PARAMTYPE paramtype); |
| 270 | |
| 271 | /** |
| 272 | * @brief Create NETCONF RPC \<delete-config\> |
| 273 | * |
| 274 | * Note that functions to create any RPC object do not check validity of the provided |
| 275 | * parameters. It is checked later while sending the RPC via a specific NETCONF session |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 276 | * (#nc_send_rpc()) since the NETCONF capabilities of the session are needed for such a |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 277 | * check. Created object can be sent via any NETCONF session which supports all the |
| 278 | * needed NETCONF capabilities for the RPC. |
| 279 | * |
| 280 | * @param[in] target Target datastore to delete. |
| 281 | * @param[in] url Used instead \p target if the target is an URL. |
| 282 | * @param[in] paramtype How to further manage data parameters. |
| 283 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 284 | */ |
| 285 | struct nc_rpc *nc_rpc_delete(NC_DATASTORE target, const char *url, NC_PARAMTYPE paramtype); |
| 286 | |
| 287 | /** |
| 288 | * @brief Create NETCONF RPC \<lock\> |
| 289 | * |
| 290 | * Note that functions to create any RPC object do not check validity of the provided |
| 291 | * parameters. It is checked later while sending the RPC via a specific NETCONF session |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 292 | * (#nc_send_rpc()) since the NETCONF capabilities of the session are needed for such a |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 293 | * check. Created object can be sent via any NETCONF session which supports all the |
| 294 | * needed NETCONF capabilities for the RPC. |
| 295 | * |
| 296 | * @param[in] target Target datastore of the operation. |
| 297 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 298 | */ |
| 299 | struct nc_rpc *nc_rpc_lock(NC_DATASTORE target); |
| 300 | |
| 301 | /** |
| 302 | * @brief Create NETCONF RPC \<unlock\> |
| 303 | * |
| 304 | * Note that functions to create any RPC object do not check validity of the provided |
| 305 | * parameters. It is checked later while sending the RPC via a specific NETCONF session |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 306 | * (#nc_send_rpc()) since the NETCONF capabilities of the session are needed for such a |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 307 | * check. Created object can be sent via any NETCONF session which supports all the |
| 308 | * needed NETCONF capabilities for the RPC. |
| 309 | * |
| 310 | * @param[in] target Target datastore of the operation. |
| 311 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 312 | */ |
| 313 | struct nc_rpc *nc_rpc_unlock(NC_DATASTORE target); |
| 314 | |
| 315 | /** |
| 316 | * @brief Create NETCONF RPC \<get\> |
| 317 | * |
| 318 | * Note that functions to create any RPC object do not check validity of the provided |
| 319 | * parameters. It is checked later while sending the RPC via a specific NETCONF session |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 320 | * (#nc_send_rpc()) since the NETCONF capabilities of the session are needed for such a |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 321 | * check. Created object can be sent via any NETCONF session which supports all the |
| 322 | * needed NETCONF capabilities for the RPC. |
| 323 | * |
| 324 | * @param[in] filter Optional filter data, an XML subtree or XPath expression. |
| 325 | * @param[in] wd_mode Optional with-defaults capability mode. |
| 326 | * @param[in] paramtype How to further manage data parameters. |
| 327 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 328 | */ |
| 329 | struct nc_rpc *nc_rpc_get(const char *filter, NC_WD_MODE wd_mode, NC_PARAMTYPE paramtype); |
| 330 | |
| 331 | /** |
| 332 | * @brief Create NETCONF RPC \<kill-session\> |
| 333 | * |
| 334 | * Note that functions to create any RPC object do not check validity of the provided |
| 335 | * parameters. It is checked later while sending the RPC via a specific NETCONF session |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 336 | * (#nc_send_rpc()) since the NETCONF capabilities of the session are needed for such a |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 337 | * check. Created object can be sent via any NETCONF session which supports all the |
| 338 | * needed NETCONF capabilities for the RPC. |
| 339 | * |
| 340 | * @param[in] session_id Session ID of the session to kill. |
| 341 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 342 | */ |
| 343 | struct nc_rpc *nc_rpc_kill(uint32_t session_id); |
| 344 | |
| 345 | /** |
| 346 | * @brief Create NETCONF RPC \<commit\> |
| 347 | * |
| 348 | * Note that functions to create any RPC object do not check validity of the provided |
| 349 | * parameters. It is checked later while sending the RPC via a specific NETCONF session |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 350 | * (#nc_send_rpc()) since the NETCONF capabilities of the session are needed for such a |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 351 | * check. Created object can be sent via any NETCONF session which supports all the |
| 352 | * needed NETCONF capabilities for the RPC. |
| 353 | * |
| 354 | * @param[in] confirmed Whether the commit is to be confirmed. |
| 355 | * @param[in] confirm_timeout Optional confirm timeout. |
| 356 | * @param[in] persist Optional identification string of a new persistent confirmed commit. |
| 357 | * @param[in] persist_id Optional identification string of a persistent confirmed commit to be commited. |
| 358 | * @param[in] paramtype How to further manage data parameters. |
| 359 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 360 | */ |
| 361 | struct nc_rpc *nc_rpc_commit(int confirmed, uint32_t confirm_timeout, const char *persist, const char *persist_id, |
| 362 | NC_PARAMTYPE paramtype); |
| 363 | |
| 364 | /** |
| 365 | * @brief Create NETCONF RPC \<discard-changes\> |
| 366 | * |
| 367 | * Note that functions to create any RPC object do not check validity of the provided |
| 368 | * parameters. It is checked later while sending the RPC via a specific NETCONF session |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 369 | * (#nc_send_rpc()) since the NETCONF capabilities of the session are needed for such a |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 370 | * check. Created object can be sent via any NETCONF session which supports all the |
| 371 | * needed NETCONF capabilities for the RPC. |
| 372 | * |
| 373 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 374 | */ |
| 375 | struct nc_rpc *nc_rpc_discard(void); |
| 376 | |
| 377 | /** |
| 378 | * @brief Create NETCONF RPC \<cancel-commit\> |
| 379 | * |
| 380 | * Note that functions to create any RPC object do not check validity of the provided |
| 381 | * parameters. It is checked later while sending the RPC via a specific NETCONF session |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 382 | * (#nc_send_rpc()) since the NETCONF capabilities of the session are needed for such a |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 383 | * check. Created object can be sent via any NETCONF session which supports all the |
| 384 | * needed NETCONF capabilities for the RPC. |
| 385 | * |
| 386 | * @param[in] persist_id Optional identification string of a persistent confirmed commit. |
| 387 | * @param[in] paramtype How to further manage data parameters. |
| 388 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 389 | */ |
| 390 | struct nc_rpc *nc_rpc_cancel(const char *persist_id, NC_PARAMTYPE paramtype); |
| 391 | |
| 392 | /** |
| 393 | * @brief Create NETCONF RPC \<validate\> |
| 394 | * |
| 395 | * Note that functions to create any RPC object do not check validity of the provided |
| 396 | * parameters. It is checked later while sending the RPC via a specific NETCONF session |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 397 | * (#nc_send_rpc()) since the NETCONF capabilities of the session are needed for such a |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 398 | * check. Created object can be sent via any NETCONF session which supports all the |
| 399 | * needed NETCONF capabilities for the RPC. |
| 400 | * |
| 401 | * @param[in] source Source datastore being validated. |
Michal Vasko | 4aade75 | 2016-02-18 13:24:38 +0100 | [diff] [blame] | 402 | * @param[in] url_or_config Used instead \p source if the source is an URL or a config. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 403 | * @param[in] paramtype How to further manage data parameters. |
| 404 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 405 | */ |
| 406 | struct nc_rpc *nc_rpc_validate(NC_DATASTORE source, const char *url_or_config, NC_PARAMTYPE paramtype); |
| 407 | |
| 408 | /** |
| 409 | * @brief Create NETCONF RPC \<get-schema\> |
| 410 | * |
| 411 | * Note that functions to create any RPC object do not check validity of the provided |
| 412 | * parameters. It is checked later while sending the RPC via a specific NETCONF session |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 413 | * (#nc_send_rpc()) since the NETCONF capabilities of the session are needed for such a |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 414 | * check. Created object can be sent via any NETCONF session which supports all the |
| 415 | * needed NETCONF capabilities for the RPC. |
| 416 | * |
| 417 | * @param[in] identifier Requested model identifier. |
| 418 | * @param[in] version Optional model version, either YANG version (1.0/1.1) or revision date. |
| 419 | * @param[in] format Optional format of the model (default is YANG). |
| 420 | * @param[in] paramtype How to further manage data parameters. |
| 421 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 422 | */ |
| 423 | struct nc_rpc *nc_rpc_getschema(const char *identifier, const char *version, const char *format, NC_PARAMTYPE paramtype); |
| 424 | |
| 425 | /** |
| 426 | * @brief Create NETCONF RPC \<create-subscription\> |
| 427 | * |
| 428 | * Note that functions to create any RPC object do not check validity of the provided |
| 429 | * parameters. It is checked later while sending the RPC via a specific NETCONF session |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 430 | * (#nc_send_rpc()) since the NETCONF capabilities of the session are needed for such a |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 431 | * check. Created object can be sent via any NETCONF session which supports all the |
| 432 | * needed NETCONF capabilities for the RPC. |
| 433 | * |
| 434 | * @param[in] stream_name Optional name of a NETCONF stream to subscribe to. |
| 435 | * @param[in] filter Optional filter data, an XML subtree or XPath expression. |
| 436 | * @param[in] start_time Optional YANG datetime identifying the start of the subscription. |
| 437 | * @param[in] stop_time Optional YANG datetime identifying the end of the subscription. |
| 438 | * @param[in] paramtype How to further manage data parameters. |
| 439 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 440 | */ |
| 441 | struct nc_rpc *nc_rpc_subscribe(const char *stream_name, const char *filter, const char *start_time, |
| 442 | const char *stop_time, NC_PARAMTYPE paramtype); |
| 443 | |
| 444 | /** |
| 445 | * @brief Free the NETCONF RPC object. |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 446 | * |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 447 | * @param[in] rpc Object to free. |
| 448 | */ |
| 449 | void nc_rpc_free(struct nc_rpc *rpc); |
| 450 | |
| 451 | /** |
| 452 | * @brief Free the NETCONF RPC reply object. |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 453 | * |
| 454 | * @param[in] reply Object to free. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 455 | */ |
| 456 | void nc_reply_free(struct nc_reply *reply); |
| 457 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 458 | /** |
| 459 | * @brief Free the NETCONF Notification object. |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 460 | * |
| 461 | * @param[in] notif Object to free. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 462 | */ |
| 463 | void nc_notif_free(struct nc_notif *notif); |
| 464 | |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 465 | #endif /* NC_MESSAGES_CLIENT_H_ */ |