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