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