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 |
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 |
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 | 90e8e69 | 2016-07-13 12:27:57 +0200 | [diff] [blame] | 28 | NC_RPC_ACT_GENERIC, /**< user-defined generic RPC/action. */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 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 { |
Michal Vasko | 12257e9 | 2016-11-22 09:30:37 +0100 | [diff] [blame] | 156 | NC_RPL type; /**< NC_RPL_DATA */ |
Michal Vasko | 4a73f34 | 2016-11-22 09:32:10 +0100 | [diff] [blame] | 157 | struct lyd_node *data; /**< libyang RPC reply data tree (output of an RPC), |
Michal Vasko | 12257e9 | 2016-11-22 09:30:37 +0100 | [diff] [blame] | 158 | \<get\> and \<get-config\> replies are special, |
| 159 | in those cases there is the configuration itself |
Michal Vasko | 50d2a5c | 2017-02-14 10:29:49 +0100 | [diff] [blame] | 160 | and it should be validated as such (using \b LYD_OPT_GET or \b LYD_OPT_GETCONFIG). */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 161 | }; |
| 162 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 163 | /** |
| 164 | * @brief NETCONF client error rpc-reply object |
| 165 | */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 166 | struct nc_reply_error { |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 167 | NC_RPL type; /**< NC_RPL_ERROR */ |
| 168 | const struct nc_err *err; /**< errors, any of the values inside can be NULL */ |
| 169 | uint32_t count; /**< number of error structures */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 170 | }; |
| 171 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 172 | /** |
| 173 | * @brief NETCONF client notification object |
| 174 | */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 175 | struct nc_notif { |
| 176 | NC_RPL type; /**< NC_RPL_NOTIF */ |
| 177 | const char *datetime; /**< eventTime of the notification */ |
| 178 | struct lyd_node *tree; /**< libyang data tree of the message */ |
| 179 | }; |
| 180 | |
| 181 | /** |
| 182 | * @brief Get the type of the RPC |
| 183 | * |
| 184 | * @param[in] rpc RPC to check the type of. |
| 185 | * @return Type of \p rpc. |
| 186 | */ |
| 187 | NC_RPC_TYPE nc_rpc_get_type(const struct nc_rpc *rpc); |
| 188 | |
| 189 | /** |
Michal Vasko | 90e8e69 | 2016-07-13 12:27:57 +0200 | [diff] [blame] | 190 | * @brief Create a generic NETCONF RPC or action |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 191 | * |
| 192 | * Note that created object can be sent via any NETCONF session that shares the context |
| 193 | * of the \p data. |
| 194 | * |
| 195 | * @param[in] data NETCONF RPC data as a data tree. |
| 196 | * @param[in] paramtype How to further manage data parameters. |
| 197 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 198 | */ |
Michal Vasko | 90e8e69 | 2016-07-13 12:27:57 +0200 | [diff] [blame] | 199 | struct nc_rpc *nc_rpc_act_generic(const struct lyd_node *data, NC_PARAMTYPE paramtype); |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 200 | |
| 201 | /** |
Michal Vasko | 90e8e69 | 2016-07-13 12:27:57 +0200 | [diff] [blame] | 202 | * @brief Create a generic NETCONF RPC or action from an XML string |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 203 | * |
| 204 | * Note that functions to create any RPC object do not check validity of the provided |
| 205 | * 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] | 206 | * (#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] | 207 | * check. Created object can be sent via any NETCONF session which supports all the |
| 208 | * needed NETCONF capabilities for the RPC. |
| 209 | * |
| 210 | * @param[in] xml_str NETCONF RPC data as an XML string. |
| 211 | * @param[in] paramtype How to further manage data parameters. |
| 212 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 213 | */ |
Michal Vasko | 90e8e69 | 2016-07-13 12:27:57 +0200 | [diff] [blame] | 214 | struct nc_rpc *nc_rpc_act_generic_xml(const char *xml_str, NC_PARAMTYPE paramtype); |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 215 | |
| 216 | /** |
| 217 | * @brief Create NETCONF RPC \<get-config\> |
| 218 | * |
| 219 | * Note that functions to create any RPC object do not check validity of the provided |
| 220 | * 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] | 221 | * (#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] | 222 | * check. Created object can be sent via any NETCONF session which supports all the |
| 223 | * needed NETCONF capabilities for the RPC. |
| 224 | * |
| 225 | * @param[in] source Source datastore being queried. |
| 226 | * @param[in] filter Optional filter data, an XML subtree or XPath expression. |
| 227 | * @param[in] wd_mode Optional with-defaults capability mode. |
| 228 | * @param[in] paramtype How to further manage data parameters. |
| 229 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 230 | */ |
| 231 | struct nc_rpc *nc_rpc_getconfig(NC_DATASTORE source, const char *filter, NC_WD_MODE wd_mode, |
| 232 | NC_PARAMTYPE paramtype); |
| 233 | |
| 234 | /** |
| 235 | * @brief Create NETCONF RPC \<edit-config\> |
| 236 | * |
| 237 | * Note that functions to create any RPC object do not check validity of the provided |
| 238 | * 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] | 239 | * (#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] | 240 | * check. Created object can be sent via any NETCONF session which supports all the |
| 241 | * needed NETCONF capabilities for the RPC. |
| 242 | * |
| 243 | * @param[in] target Target datastore being edited. |
| 244 | * @param[in] default_op Optional default operation. |
| 245 | * @param[in] test_opt Optional test option. |
| 246 | * @param[in] error_opt Optional error option. |
| 247 | * @param[in] edit_content Config or URL where the config to perform is to be found. |
| 248 | * @param[in] paramtype How to further manage data parameters. |
| 249 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 250 | */ |
| 251 | struct nc_rpc *nc_rpc_edit(NC_DATASTORE target, NC_RPC_EDIT_DFLTOP default_op, NC_RPC_EDIT_TESTOPT test_opt, |
| 252 | NC_RPC_EDIT_ERROPT error_opt, const char *edit_content, NC_PARAMTYPE paramtype); |
| 253 | |
| 254 | /** |
| 255 | * @brief Create NETCONF RPC \<copy-config\> |
| 256 | * |
| 257 | * Note that functions to create any RPC object do not check validity of the provided |
| 258 | * 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] | 259 | * (#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] | 260 | * check. Created object can be sent via any NETCONF session which supports all the |
| 261 | * needed NETCONF capabilities for the RPC. |
| 262 | * |
| 263 | * @param[in] target Target datastore. |
| 264 | * @param[in] url_trg Used instead \p target if the target is an URL. |
| 265 | * @param[in] source Source datastore. |
| 266 | * @param[in] url_or_config_src Used instead \p source if the source is an URL or a config. |
| 267 | * @param[in] wd_mode Optional with-defaults capability mode. |
| 268 | * @param[in] paramtype How to further manage data parameters. |
| 269 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 270 | */ |
| 271 | struct nc_rpc *nc_rpc_copy(NC_DATASTORE target, const char *url_trg, NC_DATASTORE source, |
| 272 | const char *url_or_config_src, NC_WD_MODE wd_mode, NC_PARAMTYPE paramtype); |
| 273 | |
| 274 | /** |
| 275 | * @brief Create NETCONF RPC \<delete-config\> |
| 276 | * |
| 277 | * Note that functions to create any RPC object do not check validity of the provided |
| 278 | * 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] | 279 | * (#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] | 280 | * check. Created object can be sent via any NETCONF session which supports all the |
| 281 | * needed NETCONF capabilities for the RPC. |
| 282 | * |
| 283 | * @param[in] target Target datastore to delete. |
| 284 | * @param[in] url Used instead \p target if the target is an URL. |
| 285 | * @param[in] paramtype How to further manage data parameters. |
| 286 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 287 | */ |
| 288 | struct nc_rpc *nc_rpc_delete(NC_DATASTORE target, const char *url, NC_PARAMTYPE paramtype); |
| 289 | |
| 290 | /** |
| 291 | * @brief Create NETCONF RPC \<lock\> |
| 292 | * |
| 293 | * Note that functions to create any RPC object do not check validity of the provided |
| 294 | * 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] | 295 | * (#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] | 296 | * check. Created object can be sent via any NETCONF session which supports all the |
| 297 | * needed NETCONF capabilities for the RPC. |
| 298 | * |
| 299 | * @param[in] target Target datastore of the operation. |
| 300 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 301 | */ |
| 302 | struct nc_rpc *nc_rpc_lock(NC_DATASTORE target); |
| 303 | |
| 304 | /** |
| 305 | * @brief Create NETCONF RPC \<unlock\> |
| 306 | * |
| 307 | * Note that functions to create any RPC object do not check validity of the provided |
| 308 | * 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] | 309 | * (#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] | 310 | * check. Created object can be sent via any NETCONF session which supports all the |
| 311 | * needed NETCONF capabilities for the RPC. |
| 312 | * |
| 313 | * @param[in] target Target datastore of the operation. |
| 314 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 315 | */ |
| 316 | struct nc_rpc *nc_rpc_unlock(NC_DATASTORE target); |
| 317 | |
| 318 | /** |
| 319 | * @brief Create NETCONF RPC \<get\> |
| 320 | * |
| 321 | * Note that functions to create any RPC object do not check validity of the provided |
| 322 | * 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] | 323 | * (#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] | 324 | * check. Created object can be sent via any NETCONF session which supports all the |
| 325 | * needed NETCONF capabilities for the RPC. |
| 326 | * |
| 327 | * @param[in] filter Optional filter data, an XML subtree or XPath expression. |
| 328 | * @param[in] wd_mode Optional with-defaults capability mode. |
| 329 | * @param[in] paramtype How to further manage data parameters. |
| 330 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 331 | */ |
| 332 | struct nc_rpc *nc_rpc_get(const char *filter, NC_WD_MODE wd_mode, NC_PARAMTYPE paramtype); |
| 333 | |
| 334 | /** |
| 335 | * @brief Create NETCONF RPC \<kill-session\> |
| 336 | * |
| 337 | * Note that functions to create any RPC object do not check validity of the provided |
| 338 | * 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] | 339 | * (#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] | 340 | * check. Created object can be sent via any NETCONF session which supports all the |
| 341 | * needed NETCONF capabilities for the RPC. |
| 342 | * |
| 343 | * @param[in] session_id Session ID of the session to kill. |
| 344 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 345 | */ |
| 346 | struct nc_rpc *nc_rpc_kill(uint32_t session_id); |
| 347 | |
| 348 | /** |
| 349 | * @brief Create NETCONF RPC \<commit\> |
| 350 | * |
| 351 | * Note that functions to create any RPC object do not check validity of the provided |
| 352 | * 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] | 353 | * (#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] | 354 | * check. Created object can be sent via any NETCONF session which supports all the |
| 355 | * needed NETCONF capabilities for the RPC. |
| 356 | * |
| 357 | * @param[in] confirmed Whether the commit is to be confirmed. |
| 358 | * @param[in] confirm_timeout Optional confirm timeout. |
| 359 | * @param[in] persist Optional identification string of a new persistent confirmed commit. |
| 360 | * @param[in] persist_id Optional identification string of a persistent confirmed commit to be commited. |
| 361 | * @param[in] paramtype How to further manage data parameters. |
| 362 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 363 | */ |
| 364 | struct nc_rpc *nc_rpc_commit(int confirmed, uint32_t confirm_timeout, const char *persist, const char *persist_id, |
| 365 | NC_PARAMTYPE paramtype); |
| 366 | |
| 367 | /** |
| 368 | * @brief Create NETCONF RPC \<discard-changes\> |
| 369 | * |
| 370 | * Note that functions to create any RPC object do not check validity of the provided |
| 371 | * 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] | 372 | * (#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] | 373 | * check. Created object can be sent via any NETCONF session which supports all the |
| 374 | * needed NETCONF capabilities for the RPC. |
| 375 | * |
| 376 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 377 | */ |
| 378 | struct nc_rpc *nc_rpc_discard(void); |
| 379 | |
| 380 | /** |
| 381 | * @brief Create NETCONF RPC \<cancel-commit\> |
| 382 | * |
| 383 | * Note that functions to create any RPC object do not check validity of the provided |
| 384 | * 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] | 385 | * (#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] | 386 | * check. Created object can be sent via any NETCONF session which supports all the |
| 387 | * needed NETCONF capabilities for the RPC. |
| 388 | * |
| 389 | * @param[in] persist_id Optional identification string of a persistent confirmed commit. |
| 390 | * @param[in] paramtype How to further manage data parameters. |
| 391 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 392 | */ |
| 393 | struct nc_rpc *nc_rpc_cancel(const char *persist_id, NC_PARAMTYPE paramtype); |
| 394 | |
| 395 | /** |
| 396 | * @brief Create NETCONF RPC \<validate\> |
| 397 | * |
| 398 | * Note that functions to create any RPC object do not check validity of the provided |
| 399 | * 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] | 400 | * (#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] | 401 | * check. Created object can be sent via any NETCONF session which supports all the |
| 402 | * needed NETCONF capabilities for the RPC. |
| 403 | * |
| 404 | * @param[in] source Source datastore being validated. |
Michal Vasko | 4aade75 | 2016-02-18 13:24:38 +0100 | [diff] [blame] | 405 | * @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] | 406 | * @param[in] paramtype How to further manage data parameters. |
| 407 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 408 | */ |
| 409 | struct nc_rpc *nc_rpc_validate(NC_DATASTORE source, const char *url_or_config, NC_PARAMTYPE paramtype); |
| 410 | |
| 411 | /** |
| 412 | * @brief Create NETCONF RPC \<get-schema\> |
| 413 | * |
| 414 | * Note that functions to create any RPC object do not check validity of the provided |
| 415 | * 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] | 416 | * (#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] | 417 | * check. Created object can be sent via any NETCONF session which supports all the |
| 418 | * needed NETCONF capabilities for the RPC. |
| 419 | * |
| 420 | * @param[in] identifier Requested model identifier. |
| 421 | * @param[in] version Optional model version, either YANG version (1.0/1.1) or revision date. |
| 422 | * @param[in] format Optional format of the model (default is YANG). |
| 423 | * @param[in] paramtype How to further manage data parameters. |
| 424 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 425 | */ |
| 426 | struct nc_rpc *nc_rpc_getschema(const char *identifier, const char *version, const char *format, NC_PARAMTYPE paramtype); |
| 427 | |
| 428 | /** |
| 429 | * @brief Create NETCONF RPC \<create-subscription\> |
| 430 | * |
| 431 | * Note that functions to create any RPC object do not check validity of the provided |
| 432 | * 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] | 433 | * (#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] | 434 | * check. Created object can be sent via any NETCONF session which supports all the |
| 435 | * needed NETCONF capabilities for the RPC. |
| 436 | * |
| 437 | * @param[in] stream_name Optional name of a NETCONF stream to subscribe to. |
| 438 | * @param[in] filter Optional filter data, an XML subtree or XPath expression. |
| 439 | * @param[in] start_time Optional YANG datetime identifying the start of the subscription. |
| 440 | * @param[in] stop_time Optional YANG datetime identifying the end of the subscription. |
| 441 | * @param[in] paramtype How to further manage data parameters. |
| 442 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 443 | */ |
| 444 | struct nc_rpc *nc_rpc_subscribe(const char *stream_name, const char *filter, const char *start_time, |
Michal Vasko | 12257e9 | 2016-11-22 09:30:37 +0100 | [diff] [blame] | 445 | const char *stop_time, NC_PARAMTYPE paramtype); |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 446 | |
| 447 | /** |
| 448 | * @brief Free the NETCONF RPC object. |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 449 | * |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 450 | * @param[in] rpc Object to free. |
| 451 | */ |
| 452 | void nc_rpc_free(struct nc_rpc *rpc); |
| 453 | |
| 454 | /** |
| 455 | * @brief Free the NETCONF RPC reply object. |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 456 | * |
| 457 | * @param[in] reply Object to free. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 458 | */ |
| 459 | void nc_reply_free(struct nc_reply *reply); |
| 460 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 461 | /** |
| 462 | * @brief Free the NETCONF Notification object. |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 463 | * |
| 464 | * @param[in] notif Object to free. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 465 | */ |
| 466 | void nc_notif_free(struct nc_notif *notif); |
| 467 | |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 468 | #endif /* NC_MESSAGES_CLIENT_H_ */ |