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