Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 1 | /** |
Michal Vasko | c446a38 | 2021-06-18 08:54:05 +0200 | [diff] [blame] | 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. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 6 | * |
Michal Vasko | c446a38 | 2021-06-18 08:54:05 +0200 | [diff] [blame] | 7 | * Copyright (c) 2015 - 2021 CESNET, z.s.p.o. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 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. */ |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 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. |
Michal Vasko | c446a38 | 2021-06-18 08:54:05 +0200 | [diff] [blame] | 167 | * @return Type of @p rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 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 |
Michal Vasko | c446a38 | 2021-06-18 08:54:05 +0200 | [diff] [blame] | 175 | * of the @p data. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 176 | * |
Michal Vasko | 70bf222 | 2021-10-26 10:45:15 +0200 | [diff] [blame^] | 177 | * @note In case of action, the \<action\> element is added automatically and should not be in @p data. |
| 178 | * |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 179 | * @param[in] data NETCONF RPC data as a data tree. |
| 180 | * @param[in] paramtype How to further manage data parameters. |
| 181 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 182 | */ |
Michal Vasko | 90e8e69 | 2016-07-13 12:27:57 +0200 | [diff] [blame] | 183 | 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] | 184 | |
| 185 | /** |
Michal Vasko | 90e8e69 | 2016-07-13 12:27:57 +0200 | [diff] [blame] | 186 | * @brief Create a generic NETCONF RPC or action from an XML string |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 187 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame] | 188 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 189 | * |
Michal Vasko | 70bf222 | 2021-10-26 10:45:15 +0200 | [diff] [blame^] | 190 | * @note In case of action, the \<action\> element is added automatically and should not be in @p xml_str. |
| 191 | * |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 192 | * @param[in] xml_str NETCONF RPC data as an XML string. |
| 193 | * @param[in] paramtype How to further manage data parameters. |
| 194 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 195 | */ |
Michal Vasko | 90e8e69 | 2016-07-13 12:27:57 +0200 | [diff] [blame] | 196 | 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] | 197 | |
| 198 | /** |
| 199 | * @brief Create NETCONF RPC \<get-config\> |
| 200 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame] | 201 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 202 | * |
| 203 | * @param[in] source Source datastore being queried. |
Michal Vasko | c238970 | 2017-08-09 10:16:49 +0200 | [diff] [blame] | 204 | * @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] | 205 | * @param[in] wd_mode Optional with-defaults capability mode. |
| 206 | * @param[in] paramtype How to further manage data parameters. |
| 207 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 208 | */ |
| 209 | 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] | 210 | NC_PARAMTYPE paramtype); |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 211 | |
| 212 | /** |
| 213 | * @brief Create NETCONF RPC \<edit-config\> |
| 214 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame] | 215 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 216 | * |
| 217 | * @param[in] target Target datastore being edited. |
| 218 | * @param[in] default_op Optional default operation. |
| 219 | * @param[in] test_opt Optional test option. |
| 220 | * @param[in] error_opt Optional error option. |
| 221 | * @param[in] edit_content Config or URL where the config to perform is to be found. |
| 222 | * @param[in] paramtype How to further manage data parameters. |
| 223 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 224 | */ |
| 225 | 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] | 226 | 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] | 227 | |
| 228 | /** |
| 229 | * @brief Create NETCONF RPC \<copy-config\> |
| 230 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame] | 231 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 232 | * |
| 233 | * @param[in] target Target datastore. |
Michal Vasko | c446a38 | 2021-06-18 08:54:05 +0200 | [diff] [blame] | 234 | * @param[in] url_trg Used instead @p target if the target is an URL. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 235 | * @param[in] source Source datastore. |
Michal Vasko | c446a38 | 2021-06-18 08:54:05 +0200 | [diff] [blame] | 236 | * @param[in] url_or_config_src 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] | 237 | * @param[in] wd_mode Optional with-defaults capability mode. |
| 238 | * @param[in] paramtype How to further manage data parameters. |
| 239 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 240 | */ |
| 241 | 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] | 242 | 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] | 243 | |
| 244 | /** |
| 245 | * @brief Create NETCONF RPC \<delete-config\> |
| 246 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame] | 247 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 248 | * |
| 249 | * @param[in] target Target datastore to delete. |
Michal Vasko | c446a38 | 2021-06-18 08:54:05 +0200 | [diff] [blame] | 250 | * @param[in] url Used instead @p target if the target is an URL. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 251 | * @param[in] paramtype How to further manage data parameters. |
| 252 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 253 | */ |
| 254 | struct nc_rpc *nc_rpc_delete(NC_DATASTORE target, const char *url, NC_PARAMTYPE paramtype); |
| 255 | |
| 256 | /** |
| 257 | * @brief Create NETCONF RPC \<lock\> |
| 258 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame] | 259 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 260 | * |
| 261 | * @param[in] target Target datastore of the operation. |
| 262 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 263 | */ |
| 264 | struct nc_rpc *nc_rpc_lock(NC_DATASTORE target); |
| 265 | |
| 266 | /** |
| 267 | * @brief Create NETCONF RPC \<unlock\> |
| 268 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame] | 269 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 270 | * |
| 271 | * @param[in] target Target datastore of the operation. |
| 272 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 273 | */ |
| 274 | struct nc_rpc *nc_rpc_unlock(NC_DATASTORE target); |
| 275 | |
| 276 | /** |
| 277 | * @brief Create NETCONF RPC \<get\> |
| 278 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame] | 279 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 280 | * |
Michal Vasko | c238970 | 2017-08-09 10:16:49 +0200 | [diff] [blame] | 281 | * @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] | 282 | * @param[in] wd_mode Optional with-defaults capability mode. |
| 283 | * @param[in] paramtype How to further manage data parameters. |
| 284 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 285 | */ |
| 286 | struct nc_rpc *nc_rpc_get(const char *filter, NC_WD_MODE wd_mode, NC_PARAMTYPE paramtype); |
| 287 | |
| 288 | /** |
| 289 | * @brief Create NETCONF RPC \<kill-session\> |
| 290 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame] | 291 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 292 | * |
| 293 | * @param[in] session_id Session ID of the session to kill. |
| 294 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 295 | */ |
| 296 | struct nc_rpc *nc_rpc_kill(uint32_t session_id); |
| 297 | |
| 298 | /** |
| 299 | * @brief Create NETCONF RPC \<commit\> |
| 300 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame] | 301 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 302 | * |
| 303 | * @param[in] confirmed Whether the commit is to be confirmed. |
| 304 | * @param[in] confirm_timeout Optional confirm timeout. |
| 305 | * @param[in] persist Optional identification string of a new persistent confirmed commit. |
| 306 | * @param[in] persist_id Optional identification string of a persistent confirmed commit to be commited. |
| 307 | * @param[in] paramtype How to further manage data parameters. |
| 308 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 309 | */ |
| 310 | 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] | 311 | NC_PARAMTYPE paramtype); |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 312 | |
| 313 | /** |
| 314 | * @brief Create NETCONF RPC \<discard-changes\> |
| 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 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 319 | */ |
| 320 | struct nc_rpc *nc_rpc_discard(void); |
| 321 | |
| 322 | /** |
| 323 | * @brief Create NETCONF RPC \<cancel-commit\> |
| 324 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame] | 325 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 326 | * |
| 327 | * @param[in] persist_id Optional identification string of a persistent confirmed commit. |
| 328 | * @param[in] paramtype How to further manage data parameters. |
| 329 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 330 | */ |
| 331 | struct nc_rpc *nc_rpc_cancel(const char *persist_id, NC_PARAMTYPE paramtype); |
| 332 | |
| 333 | /** |
| 334 | * @brief Create NETCONF RPC \<validate\> |
| 335 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame] | 336 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 337 | * |
| 338 | * @param[in] source Source datastore being validated. |
Michal Vasko | c446a38 | 2021-06-18 08:54:05 +0200 | [diff] [blame] | 339 | * @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] | 340 | * @param[in] paramtype How to further manage data parameters. |
| 341 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 342 | */ |
| 343 | struct nc_rpc *nc_rpc_validate(NC_DATASTORE source, const char *url_or_config, NC_PARAMTYPE paramtype); |
| 344 | |
| 345 | /** |
| 346 | * @brief Create NETCONF RPC \<get-schema\> |
| 347 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame] | 348 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 349 | * |
| 350 | * @param[in] identifier Requested model identifier. |
| 351 | * @param[in] version Optional model version, either YANG version (1.0/1.1) or revision date. |
| 352 | * @param[in] format Optional format of the model (default is YANG). |
| 353 | * @param[in] paramtype How to further manage data parameters. |
| 354 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 355 | */ |
| 356 | struct nc_rpc *nc_rpc_getschema(const char *identifier, const char *version, const char *format, NC_PARAMTYPE paramtype); |
| 357 | |
| 358 | /** |
| 359 | * @brief Create NETCONF RPC \<create-subscription\> |
| 360 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame] | 361 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 362 | * |
| 363 | * @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] | 364 | * @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] | 365 | * @param[in] start_time Optional YANG datetime identifying the start of the subscription. |
| 366 | * @param[in] stop_time Optional YANG datetime identifying the end of the subscription. |
| 367 | * @param[in] paramtype How to further manage data parameters. |
| 368 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 369 | */ |
| 370 | 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] | 371 | const char *stop_time, NC_PARAMTYPE paramtype); |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 372 | |
| 373 | /** |
Michal Vasko | c1171a4 | 2019-11-05 12:06:46 +0100 | [diff] [blame] | 374 | * @brief Create NETCONF RPC \<get-data\> |
| 375 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame] | 376 | * For details, see ::nc_rpc. |
Michal Vasko | c1171a4 | 2019-11-05 12:06:46 +0100 | [diff] [blame] | 377 | * |
| 378 | * @param[in] datastore Source datastore, foreign identity so a module name prefix is required. |
| 379 | * @param[in] filter Optional filter data, an XML subtree or XPath expression (with JSON prefixes). |
| 380 | * @param[in] config_filter Optional config filter, "true" for config-only data, "false" for state-only data. |
| 381 | * @param[in] origin_filter Optional origin filter array, selects only nodes of this or derived origin. |
Michal Vasko | c446a38 | 2021-06-18 08:54:05 +0200 | [diff] [blame] | 382 | * @param[in] origin_filter_count Count of filters is @p origin_filter. |
Michal Vasko | c1171a4 | 2019-11-05 12:06:46 +0100 | [diff] [blame] | 383 | * @param[in] neg_origin_filter Whether origin filters are negated or not. |
| 384 | * @param[in] max_depth Maximum depth of returned subtrees, 0 for unlimited. |
| 385 | * @param[in] with_origin Whether return data origin. |
| 386 | * @param[in] wd_mode Optional with-defaults capability mode. |
| 387 | * @param[in] paramtype How to further manage data parameters. |
| 388 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 389 | */ |
| 390 | 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] | 391 | int origin_filter_count, int neg_origin_filter, uint16_t max_depth, int with_origin, NC_WD_MODE wd_mode, |
| 392 | NC_PARAMTYPE paramtype); |
Michal Vasko | c1171a4 | 2019-11-05 12:06:46 +0100 | [diff] [blame] | 393 | |
| 394 | /** |
| 395 | * @brief Create NETCONF RPC \<get-data\> |
| 396 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame] | 397 | * For details, see ::nc_rpc. |
Michal Vasko | c1171a4 | 2019-11-05 12:06:46 +0100 | [diff] [blame] | 398 | * |
| 399 | * @param[in] datastore Source datastore, foreign identity so a module name prefix is required. |
| 400 | * @param[in] default_op Optional default operation. |
| 401 | * @param[in] edit_content Config or URL where the config to perform is to be found. |
| 402 | * @param[in] paramtype How to further manage data parameters. |
| 403 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 404 | */ |
| 405 | 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] | 406 | NC_PARAMTYPE paramtype); |
| 407 | |
| 408 | /** |
| 409 | * @brief Create NETCONF RPC \<establish-subscription\> |
| 410 | * |
| 411 | * For details, see ::nc_rpc. |
| 412 | * |
| 413 | * @param[in] filter Optional filter data, an XML subtree, XPath expression (with JSON prefixes), |
| 414 | * or filter reference, selected based on the first character. |
| 415 | * @param[in] stream_name Name of a NETCONF stream to subscribe to. |
| 416 | * @param[in] start_time Optional YANG datetime identifying the start of the subscription. |
| 417 | * @param[in] stop_time Optional YANG datetime identifying the end of the subscription. |
| 418 | * @param[in] encoding Optional specific encoding to use. |
| 419 | * @param[in] paramtype How to further manage data parameters. |
| 420 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 421 | */ |
| 422 | struct nc_rpc *nc_rpc_establishsub(const char *filter, const char *stream_name, const char *start_time, |
| 423 | const char *stop_time, const char *encoding, NC_PARAMTYPE paramtype); |
| 424 | |
| 425 | /** |
| 426 | * @brief Create NETCONF RPC \<modify-subscription\> |
| 427 | * |
| 428 | * For details, see ::nc_rpc. |
| 429 | * |
| 430 | * @param[in] id Subscription ID to modify. |
| 431 | * @param[in] filter Optional new filter data, an XML subtree, XPath expression (with JSON prefixes), |
| 432 | * or filter reference, selected based on the first character. |
| 433 | * @param[in] stop_time Optional new YANG datetime identifying the end of the subscription. |
| 434 | * @param[in] paramtype How to further manage data parameters. |
| 435 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 436 | */ |
| 437 | struct nc_rpc *nc_rpc_modifysub(uint32_t id, const char *filter, const char *stop_time, NC_PARAMTYPE paramtype); |
| 438 | |
| 439 | /** |
| 440 | * @brief Create NETCONF RPC \<delete-subscription\> |
| 441 | * |
| 442 | * For details, see ::nc_rpc. |
| 443 | * |
| 444 | * @param[in] id Subscription ID to delete. |
| 445 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 446 | */ |
| 447 | struct nc_rpc *nc_rpc_deletesub(uint32_t id); |
| 448 | |
| 449 | /** |
| 450 | * @brief Create NETCONF RPC \<kill-subscription\> |
| 451 | * |
| 452 | * For details, see ::nc_rpc. |
| 453 | * |
| 454 | * @param[in] id Subscription ID to kill. |
| 455 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 456 | */ |
| 457 | struct nc_rpc *nc_rpc_killsub(uint32_t id); |
Michal Vasko | c1171a4 | 2019-11-05 12:06:46 +0100 | [diff] [blame] | 458 | |
| 459 | /** |
Michal Vasko | 305faca | 2021-03-25 09:16:02 +0100 | [diff] [blame] | 460 | * @brief Create NETCONF RPC \<establish-subscription\> with augments from ietf-yang-push for a periodic subscription |
| 461 | * |
| 462 | * For details, see ::nc_rpc. |
| 463 | * |
| 464 | * @param[in] datastore Source datastore, foreign identity so a module name prefix is required. |
| 465 | * @param[in] filter Optional filter data, an XML subtree, XPath expression (with JSON prefixes), |
| 466 | * or filter reference, selected based on the first character. |
| 467 | * @param[in] stop_time Optional YANG datetime identifying the end of the subscription. |
| 468 | * @param[in] encoding Optional specific encoding to use. |
| 469 | * @param[in] period Subscription period in centiseconds (0.01s). |
| 470 | * @param[in] anchor_time Optional anchor datetime for the period. |
| 471 | * @param[in] paramtype How to further manage data parameters. |
| 472 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 473 | */ |
| 474 | struct nc_rpc *nc_rpc_establishpush_periodic(const char *datastore, const char *filter, const char *stop_time, |
| 475 | const char *encoding, uint32_t period, const char *anchor_time, NC_PARAMTYPE paramtype); |
| 476 | |
| 477 | /** |
| 478 | * @brief Create NETCONF RPC \<establish-subscription\> with augments from ietf-yang-push for an on-change subscription |
| 479 | * |
| 480 | * For details, see ::nc_rpc. |
| 481 | * |
| 482 | * @param[in] datastore Source datastore, foreign identity so a module name prefix is required. |
| 483 | * @param[in] filter Optional filter data, an XML subtree, XPath expression (with JSON prefixes), |
| 484 | * or filter reference, selected based on the first character. |
| 485 | * @param[in] stop_time Optional YANG datetime identifying the end of the subscription. |
| 486 | * @param[in] encoding Optional specific encoding to use. |
| 487 | * @param[in] dampening_period Optional dampening period of the notifications. |
| 488 | * @param[in] sync_on_start Whether to send a full push-update notification on subscription start. |
| 489 | * @param[in] excluded_change Optional NULL-terminated array of excluded changes. |
| 490 | * @param[in] paramtype How to further manage data parameters. |
| 491 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 492 | */ |
| 493 | struct nc_rpc *nc_rpc_establishpush_onchange(const char *datastore, const char *filter, const char *stop_time, |
| 494 | const char *encoding, uint32_t dampening_period, int sync_on_start, const char **excluded_change, |
| 495 | NC_PARAMTYPE paramtype); |
| 496 | |
| 497 | /** |
| 498 | * @brief Create NETCONF RPC \<modify-subscription\> with augments from ietf-yang-push for a periodic subscription |
| 499 | * |
| 500 | * For details, see ::nc_rpc. |
| 501 | * |
| 502 | * @param[in] id Subscription ID to modify. |
| 503 | * @param[in] datastore Source datastore, foreign identity so a module name prefix is required. |
| 504 | * @param[in] filter Optional filter data, an XML subtree, XPath expression (with JSON prefixes), |
| 505 | * or filter reference, selected based on the first character. |
| 506 | * @param[in] stop_time Optional YANG datetime identifying the end of the subscription. |
| 507 | * @param[in] period Subscription period in centiseconds (0.01s). |
| 508 | * @param[in] anchor_time Optional anchor datetime for the period. |
| 509 | * @param[in] paramtype How to further manage data parameters. |
| 510 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 511 | */ |
| 512 | struct nc_rpc *nc_rpc_modifypush_periodic(uint32_t id, const char *datastore, const char *filter, const char *stop_time, |
| 513 | uint32_t period, const char *anchor_time, NC_PARAMTYPE paramtype); |
| 514 | |
| 515 | /** |
| 516 | * @brief Create NETCONF RPC \<modify-subscription\> with augments from ietf-yang-push for an on-change subscription |
| 517 | * |
| 518 | * For details, see ::nc_rpc. |
| 519 | * |
| 520 | * @param[in] id Subscription ID to modify. |
| 521 | * @param[in] datastore Source datastore, foreign identity so a module name prefix is required. |
| 522 | * @param[in] filter Optional filter data, an XML subtree, XPath expression (with JSON prefixes), |
| 523 | * or filter reference, selected based on the first character. |
| 524 | * @param[in] stop_time Optional YANG datetime identifying the end of the subscription. |
| 525 | * @param[in] dampening_period Optional dampening period of the notifications. |
| 526 | * @param[in] paramtype How to further manage data parameters. |
| 527 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 528 | */ |
| 529 | struct nc_rpc *nc_rpc_modifypush_onchange(uint32_t id, const char *datastore, const char *filter, const char *stop_time, |
| 530 | uint32_t dampening_period, NC_PARAMTYPE paramtype); |
| 531 | |
| 532 | /** |
| 533 | * @brief Create NETCONF RPC \<resync-subscription\> |
| 534 | * |
| 535 | * For details, see ::nc_rpc. |
| 536 | * |
| 537 | * @param[in] id Subscription ID to resync. |
| 538 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 539 | */ |
| 540 | struct nc_rpc *nc_rpc_resyncsub(uint32_t id); |
| 541 | |
| 542 | /** |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 543 | * @brief Free the NETCONF RPC object. |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 544 | * |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 545 | * @param[in] rpc Object to free. |
| 546 | */ |
| 547 | void nc_rpc_free(struct nc_rpc *rpc); |
| 548 | |
Michal Vasko | 7736745 | 2021-02-16 16:32:18 +0100 | [diff] [blame] | 549 | /** @} Client Messages */ |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 550 | |
Michal Vasko | c09730e | 2019-01-17 10:07:26 +0100 | [diff] [blame] | 551 | #ifdef __cplusplus |
| 552 | } |
| 553 | #endif |
| 554 | |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 555 | #endif /* NC_MESSAGES_CLIENT_H_ */ |