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 | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame^] | 67 | |
| 68 | /* ietf-subscribed-notifications */ |
| 69 | NC_RPC_ESTABLISHSUB, /**< \<establish-subscription\> RPC. */ |
| 70 | NC_RPC_MODIFYSUB, /**< \<modify-subscription\> RPC. */ |
| 71 | NC_RPC_DELETESUB, /**< \<delete-subscription\> RPC. */ |
| 72 | NC_RPC_KILLSUB, /**< \<kill-subscription\> RPC. */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 73 | } NC_RPC_TYPE; |
| 74 | |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 75 | /** |
| 76 | * @brief Enumeration of \<edit-config\> default operation |
| 77 | */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 78 | typedef enum { |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 79 | NC_RPC_EDIT_DFLTOP_UNKNOWN = 0, /**< unknown default operation */ |
| 80 | NC_RPC_EDIT_DFLTOP_MERGE, /**< default operation merge */ |
| 81 | NC_RPC_EDIT_DFLTOP_REPLACE, /**< default operation replace */ |
| 82 | NC_RPC_EDIT_DFLTOP_NONE /**< default operation none */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 83 | } NC_RPC_EDIT_DFLTOP; |
| 84 | |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 85 | /** |
| 86 | * @brief Enumeration of \<edit-config\> test option |
| 87 | */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 88 | typedef enum { |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 89 | NC_RPC_EDIT_TESTOPT_UNKNOWN = 0, /**< unknown test option */ |
| 90 | NC_RPC_EDIT_TESTOPT_TESTSET, /**< test-then-set option */ |
| 91 | NC_RPC_EDIT_TESTOPT_SET, /**< set option */ |
| 92 | NC_RPC_EDIT_TESTOPT_TEST /**< test-only option */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 93 | } NC_RPC_EDIT_TESTOPT; |
| 94 | |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 95 | /** |
| 96 | * @brief Enumeration of \<edit-config\> error option |
| 97 | */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 98 | typedef enum { |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 99 | NC_RPC_EDIT_ERROPT_UNKNOWN = 0, /**< unknown error option */ |
| 100 | NC_RPC_EDIT_ERROPT_STOP, /**< stop-on-error option */ |
| 101 | NC_RPC_EDIT_ERROPT_CONTINUE, /**< continue-on-error option */ |
| 102 | NC_RPC_EDIT_ERROPT_ROLLBACK /**< rollback-on-error option */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 103 | } NC_RPC_EDIT_ERROPT; |
| 104 | |
| 105 | /** |
| 106 | * @brief NETCONF error structure representation |
| 107 | */ |
| 108 | struct nc_err { |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 109 | /** @brief \<error-type\>, error layer where the error occurred. */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 110 | const char *type; |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 111 | /** @brief \<error-tag\>. */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 112 | const char *tag; |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 113 | /** @brief \<error-severity\>. */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 114 | const char *severity; |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 115 | /** @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] | 116 | const char *apptag; |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 117 | /** @brief \<error-path\>, XPATH expression identifying the element with the error. */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 118 | const char *path; |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 119 | /** @brief \<error-message\>, Human-readable description of the error. */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 120 | const char *message; |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 121 | /** @brief xml:lang attribute of the error-message. */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 122 | const char *message_lang; |
| 123 | |
| 124 | /* <error-info> */ |
| 125 | |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 126 | /** @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] | 127 | const char *sid; |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 128 | /** @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] | 129 | const char **attr; |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 130 | /** @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] | 131 | const char **elem; |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 132 | /** @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] | 133 | const char **ns; |
Michal Vasko | 7736745 | 2021-02-16 16:32:18 +0100 | [diff] [blame] | 134 | /** @brief List of the remaining non-standard opaque nodes. */ |
| 135 | struct lyd_node *other; |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 136 | |
| 137 | /** @brief Number of items in the attr array */ |
| 138 | uint16_t attr_count; |
| 139 | /** @brief Number of items in the elem array */ |
| 140 | uint16_t elem_count; |
| 141 | /** @brief Number of items in the ns array */ |
| 142 | uint16_t ns_count; |
| 143 | /** @brief Number of items in the other array */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 144 | uint16_t other_count; |
| 145 | }; |
| 146 | |
| 147 | /** |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame^] | 148 | * @struct nc_rpc |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 149 | * @brief NETCONF client RPC object |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame^] | 150 | * |
| 151 | * Note that any stored parameters are not checked for validity because it is performed later, |
| 152 | * while sending the RPC via a specific NETCONF session (::nc_send_rpc()) since the NETCONF |
| 153 | * capabilities of the session are needed for such a check. An RPC object can be sent via any |
| 154 | * NETCONF session which supports all the needed NETCONF capabilities for the RPC. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 155 | */ |
| 156 | struct nc_rpc; |
| 157 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 158 | /** |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 159 | * @brief Get the type of the RPC |
| 160 | * |
| 161 | * @param[in] rpc RPC to check the type of. |
| 162 | * @return Type of \p rpc. |
| 163 | */ |
| 164 | NC_RPC_TYPE nc_rpc_get_type(const struct nc_rpc *rpc); |
| 165 | |
| 166 | /** |
Michal Vasko | 90e8e69 | 2016-07-13 12:27:57 +0200 | [diff] [blame] | 167 | * @brief Create a generic NETCONF RPC or action |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 168 | * |
| 169 | * Note that created object can be sent via any NETCONF session that shares the context |
| 170 | * of the \p data. |
| 171 | * |
| 172 | * @param[in] data NETCONF RPC data as a data tree. |
| 173 | * @param[in] paramtype How to further manage data parameters. |
| 174 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 175 | */ |
Michal Vasko | 90e8e69 | 2016-07-13 12:27:57 +0200 | [diff] [blame] | 176 | 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] | 177 | |
| 178 | /** |
Michal Vasko | 90e8e69 | 2016-07-13 12:27:57 +0200 | [diff] [blame] | 179 | * @brief Create a generic NETCONF RPC or action from an XML string |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 180 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame^] | 181 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 182 | * |
| 183 | * @param[in] xml_str NETCONF RPC data as an XML string. |
| 184 | * @param[in] paramtype How to further manage data parameters. |
| 185 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 186 | */ |
Michal Vasko | 90e8e69 | 2016-07-13 12:27:57 +0200 | [diff] [blame] | 187 | 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] | 188 | |
| 189 | /** |
| 190 | * @brief Create NETCONF RPC \<get-config\> |
| 191 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame^] | 192 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 193 | * |
| 194 | * @param[in] source Source datastore being queried. |
Michal Vasko | c238970 | 2017-08-09 10:16:49 +0200 | [diff] [blame] | 195 | * @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] | 196 | * @param[in] wd_mode Optional with-defaults capability mode. |
| 197 | * @param[in] paramtype How to further manage data parameters. |
| 198 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 199 | */ |
| 200 | struct nc_rpc *nc_rpc_getconfig(NC_DATASTORE source, const char *filter, NC_WD_MODE wd_mode, |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame^] | 201 | NC_PARAMTYPE paramtype); |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 202 | |
| 203 | /** |
| 204 | * @brief Create NETCONF RPC \<edit-config\> |
| 205 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame^] | 206 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 207 | * |
| 208 | * @param[in] target Target datastore being edited. |
| 209 | * @param[in] default_op Optional default operation. |
| 210 | * @param[in] test_opt Optional test option. |
| 211 | * @param[in] error_opt Optional error option. |
| 212 | * @param[in] edit_content Config or URL where the config to perform is to be found. |
| 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 | */ |
| 216 | struct nc_rpc *nc_rpc_edit(NC_DATASTORE target, NC_RPC_EDIT_DFLTOP default_op, NC_RPC_EDIT_TESTOPT test_opt, |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame^] | 217 | NC_RPC_EDIT_ERROPT error_opt, const char *edit_content, NC_PARAMTYPE paramtype); |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 218 | |
| 219 | /** |
| 220 | * @brief Create NETCONF RPC \<copy-config\> |
| 221 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame^] | 222 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 223 | * |
| 224 | * @param[in] target Target datastore. |
| 225 | * @param[in] url_trg Used instead \p target if the target is an URL. |
| 226 | * @param[in] source Source datastore. |
| 227 | * @param[in] url_or_config_src Used instead \p source if the source is an URL or a config. |
| 228 | * @param[in] wd_mode Optional with-defaults capability mode. |
| 229 | * @param[in] paramtype How to further manage data parameters. |
| 230 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 231 | */ |
| 232 | struct nc_rpc *nc_rpc_copy(NC_DATASTORE target, const char *url_trg, NC_DATASTORE source, |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame^] | 233 | const char *url_or_config_src, NC_WD_MODE wd_mode, NC_PARAMTYPE paramtype); |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 234 | |
| 235 | /** |
| 236 | * @brief Create NETCONF RPC \<delete-config\> |
| 237 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame^] | 238 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 239 | * |
| 240 | * @param[in] target Target datastore to delete. |
| 241 | * @param[in] url Used instead \p target if the target is an URL. |
| 242 | * @param[in] paramtype How to further manage data parameters. |
| 243 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 244 | */ |
| 245 | struct nc_rpc *nc_rpc_delete(NC_DATASTORE target, const char *url, NC_PARAMTYPE paramtype); |
| 246 | |
| 247 | /** |
| 248 | * @brief Create NETCONF RPC \<lock\> |
| 249 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame^] | 250 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 251 | * |
| 252 | * @param[in] target Target datastore of the operation. |
| 253 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 254 | */ |
| 255 | struct nc_rpc *nc_rpc_lock(NC_DATASTORE target); |
| 256 | |
| 257 | /** |
| 258 | * @brief Create NETCONF RPC \<unlock\> |
| 259 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame^] | 260 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 261 | * |
| 262 | * @param[in] target Target datastore of the operation. |
| 263 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 264 | */ |
| 265 | struct nc_rpc *nc_rpc_unlock(NC_DATASTORE target); |
| 266 | |
| 267 | /** |
| 268 | * @brief Create NETCONF RPC \<get\> |
| 269 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame^] | 270 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 271 | * |
Michal Vasko | c238970 | 2017-08-09 10:16:49 +0200 | [diff] [blame] | 272 | * @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] | 273 | * @param[in] wd_mode Optional with-defaults capability mode. |
| 274 | * @param[in] paramtype How to further manage data parameters. |
| 275 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 276 | */ |
| 277 | struct nc_rpc *nc_rpc_get(const char *filter, NC_WD_MODE wd_mode, NC_PARAMTYPE paramtype); |
| 278 | |
| 279 | /** |
| 280 | * @brief Create NETCONF RPC \<kill-session\> |
| 281 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame^] | 282 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 283 | * |
| 284 | * @param[in] session_id Session ID of the session to kill. |
| 285 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 286 | */ |
| 287 | struct nc_rpc *nc_rpc_kill(uint32_t session_id); |
| 288 | |
| 289 | /** |
| 290 | * @brief Create NETCONF RPC \<commit\> |
| 291 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame^] | 292 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 293 | * |
| 294 | * @param[in] confirmed Whether the commit is to be confirmed. |
| 295 | * @param[in] confirm_timeout Optional confirm timeout. |
| 296 | * @param[in] persist Optional identification string of a new persistent confirmed commit. |
| 297 | * @param[in] persist_id Optional identification string of a persistent confirmed commit to be commited. |
| 298 | * @param[in] paramtype How to further manage data parameters. |
| 299 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 300 | */ |
| 301 | struct nc_rpc *nc_rpc_commit(int confirmed, uint32_t confirm_timeout, const char *persist, const char *persist_id, |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame^] | 302 | NC_PARAMTYPE paramtype); |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 303 | |
| 304 | /** |
| 305 | * @brief Create NETCONF RPC \<discard-changes\> |
| 306 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame^] | 307 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 308 | * |
| 309 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 310 | */ |
| 311 | struct nc_rpc *nc_rpc_discard(void); |
| 312 | |
| 313 | /** |
| 314 | * @brief Create NETCONF RPC \<cancel-commit\> |
| 315 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame^] | 316 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 317 | * |
| 318 | * @param[in] persist_id Optional identification string of a persistent confirmed commit. |
| 319 | * @param[in] paramtype How to further manage data parameters. |
| 320 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 321 | */ |
| 322 | struct nc_rpc *nc_rpc_cancel(const char *persist_id, NC_PARAMTYPE paramtype); |
| 323 | |
| 324 | /** |
| 325 | * @brief Create NETCONF RPC \<validate\> |
| 326 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame^] | 327 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 328 | * |
| 329 | * @param[in] source Source datastore being validated. |
Michal Vasko | 4aade75 | 2016-02-18 13:24:38 +0100 | [diff] [blame] | 330 | * @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] | 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_validate(NC_DATASTORE source, const char *url_or_config, NC_PARAMTYPE paramtype); |
| 335 | |
| 336 | /** |
| 337 | * @brief Create NETCONF RPC \<get-schema\> |
| 338 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame^] | 339 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 340 | * |
| 341 | * @param[in] identifier Requested model identifier. |
| 342 | * @param[in] version Optional model version, either YANG version (1.0/1.1) or revision date. |
| 343 | * @param[in] format Optional format of the model (default is YANG). |
| 344 | * @param[in] paramtype How to further manage data parameters. |
| 345 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 346 | */ |
| 347 | struct nc_rpc *nc_rpc_getschema(const char *identifier, const char *version, const char *format, NC_PARAMTYPE paramtype); |
| 348 | |
| 349 | /** |
| 350 | * @brief Create NETCONF RPC \<create-subscription\> |
| 351 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame^] | 352 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 353 | * |
| 354 | * @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] | 355 | * @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] | 356 | * @param[in] start_time Optional YANG datetime identifying the start of the subscription. |
| 357 | * @param[in] stop_time Optional YANG datetime identifying the end of the subscription. |
| 358 | * @param[in] paramtype How to further manage data parameters. |
| 359 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 360 | */ |
| 361 | struct nc_rpc *nc_rpc_subscribe(const char *stream_name, const char *filter, const char *start_time, |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame^] | 362 | const char *stop_time, NC_PARAMTYPE paramtype); |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 363 | |
| 364 | /** |
Michal Vasko | c1171a4 | 2019-11-05 12:06:46 +0100 | [diff] [blame] | 365 | * @brief Create NETCONF RPC \<get-data\> |
| 366 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame^] | 367 | * For details, see ::nc_rpc. |
Michal Vasko | c1171a4 | 2019-11-05 12:06:46 +0100 | [diff] [blame] | 368 | * |
| 369 | * @param[in] datastore Source datastore, foreign identity so a module name prefix is required. |
| 370 | * @param[in] filter Optional filter data, an XML subtree or XPath expression (with JSON prefixes). |
| 371 | * @param[in] config_filter Optional config filter, "true" for config-only data, "false" for state-only data. |
| 372 | * @param[in] origin_filter Optional origin filter array, selects only nodes of this or derived origin. |
| 373 | * @param[in] origin_filter_count Count of filters is \p origin_filter. |
| 374 | * @param[in] neg_origin_filter Whether origin filters are negated or not. |
| 375 | * @param[in] max_depth Maximum depth of returned subtrees, 0 for unlimited. |
| 376 | * @param[in] with_origin Whether return data origin. |
| 377 | * @param[in] wd_mode Optional with-defaults capability mode. |
| 378 | * @param[in] paramtype How to further manage data parameters. |
| 379 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 380 | */ |
| 381 | struct nc_rpc *nc_rpc_getdata(const char *datastore, const char *filter, const char *config_filter, char **origin_filter, |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame^] | 382 | int origin_filter_count, int neg_origin_filter, uint16_t max_depth, int with_origin, NC_WD_MODE wd_mode, |
| 383 | NC_PARAMTYPE paramtype); |
Michal Vasko | c1171a4 | 2019-11-05 12:06:46 +0100 | [diff] [blame] | 384 | |
| 385 | /** |
| 386 | * @brief Create NETCONF RPC \<get-data\> |
| 387 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame^] | 388 | * For details, see ::nc_rpc. |
Michal Vasko | c1171a4 | 2019-11-05 12:06:46 +0100 | [diff] [blame] | 389 | * |
| 390 | * @param[in] datastore Source datastore, foreign identity so a module name prefix is required. |
| 391 | * @param[in] default_op Optional default operation. |
| 392 | * @param[in] edit_content Config or URL where the config to perform is to be found. |
| 393 | * @param[in] paramtype How to further manage data parameters. |
| 394 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 395 | */ |
| 396 | struct nc_rpc *nc_rpc_editdata(const char *datastore, NC_RPC_EDIT_DFLTOP default_op, const char *edit_content, |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame^] | 397 | NC_PARAMTYPE paramtype); |
| 398 | |
| 399 | /** |
| 400 | * @brief Create NETCONF RPC \<establish-subscription\> |
| 401 | * |
| 402 | * For details, see ::nc_rpc. |
| 403 | * |
| 404 | * @param[in] filter Optional filter data, an XML subtree, XPath expression (with JSON prefixes), |
| 405 | * or filter reference, selected based on the first character. |
| 406 | * @param[in] stream_name Name of a NETCONF stream to subscribe to. |
| 407 | * @param[in] start_time Optional YANG datetime identifying the start of the subscription. |
| 408 | * @param[in] stop_time Optional YANG datetime identifying the end of the subscription. |
| 409 | * @param[in] encoding Optional specific encoding to use. |
| 410 | * @param[in] paramtype How to further manage data parameters. |
| 411 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 412 | */ |
| 413 | struct nc_rpc *nc_rpc_establishsub(const char *filter, const char *stream_name, const char *start_time, |
| 414 | const char *stop_time, const char *encoding, NC_PARAMTYPE paramtype); |
| 415 | |
| 416 | /** |
| 417 | * @brief Create NETCONF RPC \<modify-subscription\> |
| 418 | * |
| 419 | * For details, see ::nc_rpc. |
| 420 | * |
| 421 | * @param[in] id Subscription ID to modify. |
| 422 | * @param[in] filter Optional new filter data, an XML subtree, XPath expression (with JSON prefixes), |
| 423 | * or filter reference, selected based on the first character. |
| 424 | * @param[in] stop_time Optional new YANG datetime identifying the end of the subscription. |
| 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_modifysub(uint32_t id, const char *filter, const char *stop_time, NC_PARAMTYPE paramtype); |
| 429 | |
| 430 | /** |
| 431 | * @brief Create NETCONF RPC \<delete-subscription\> |
| 432 | * |
| 433 | * For details, see ::nc_rpc. |
| 434 | * |
| 435 | * @param[in] id Subscription ID to delete. |
| 436 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 437 | */ |
| 438 | struct nc_rpc *nc_rpc_deletesub(uint32_t id); |
| 439 | |
| 440 | /** |
| 441 | * @brief Create NETCONF RPC \<kill-subscription\> |
| 442 | * |
| 443 | * For details, see ::nc_rpc. |
| 444 | * |
| 445 | * @param[in] id Subscription ID to kill. |
| 446 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 447 | */ |
| 448 | struct nc_rpc *nc_rpc_killsub(uint32_t id); |
Michal Vasko | c1171a4 | 2019-11-05 12:06:46 +0100 | [diff] [blame] | 449 | |
| 450 | /** |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 451 | * @brief Free the NETCONF RPC object. |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 452 | * |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 453 | * @param[in] rpc Object to free. |
| 454 | */ |
| 455 | void nc_rpc_free(struct nc_rpc *rpc); |
| 456 | |
Michal Vasko | 7736745 | 2021-02-16 16:32:18 +0100 | [diff] [blame] | 457 | /** @} Client Messages */ |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 458 | |
Michal Vasko | c09730e | 2019-01-17 10:07:26 +0100 | [diff] [blame] | 459 | #ifdef __cplusplus |
| 460 | } |
| 461 | #endif |
| 462 | |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 463 | #endif /* NC_MESSAGES_CLIENT_H_ */ |