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 | 95ea9ff | 2021-11-09 12:29:14 +0100 | [diff] [blame] | 7 | * @copyright |
Michal Vasko | c446a38 | 2021-06-18 08:54:05 +0200 | [diff] [blame] | 8 | * Copyright (c) 2015 - 2021 CESNET, z.s.p.o. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 9 | * |
Radek Krejci | 9b81f5b | 2016-02-24 13:14:49 +0100 | [diff] [blame] | 10 | * This source code is licensed under BSD 3-Clause License (the "License"). |
| 11 | * You may not use this file except in compliance with the License. |
| 12 | * You may obtain a copy of the License at |
Michal Vasko | afd416b | 2016-02-25 14:51:46 +0100 | [diff] [blame] | 13 | * |
Radek Krejci | 9b81f5b | 2016-02-24 13:14:49 +0100 | [diff] [blame] | 14 | * https://opensource.org/licenses/BSD-3-Clause |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #ifndef NC_MESSAGES_CLIENT_H_ |
| 18 | #define NC_MESSAGES_CLIENT_H_ |
| 19 | |
Michal Vasko | c09730e | 2019-01-17 10:07:26 +0100 | [diff] [blame] | 20 | #ifdef __cplusplus |
| 21 | extern "C" { |
| 22 | #endif |
| 23 | |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 24 | #include <stdint.h> |
| 25 | |
| 26 | #include "netconf.h" |
| 27 | |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 28 | /** |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 29 | * @defgroup client_msg Client Messages |
| 30 | * @ingroup client |
| 31 | * |
| 32 | * @brief Functions to create NETCONF RPCs (or actions) and process replies received from the server. |
| 33 | * @{ |
| 34 | */ |
| 35 | |
| 36 | /** |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 37 | * @brief Enumeration of RPC types |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 38 | * |
| 39 | * 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] | 40 | */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 41 | typedef enum { |
Michal Vasko | 7f1c78b | 2016-01-19 09:52:14 +0100 | [diff] [blame] | 42 | NC_RPC_UNKNOWN = 0, /**< invalid RPC. */ |
Michal Vasko | 90e8e69 | 2016-07-13 12:27:57 +0200 | [diff] [blame] | 43 | NC_RPC_ACT_GENERIC, /**< user-defined generic RPC/action. */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 44 | |
| 45 | /* ietf-netconf */ |
| 46 | NC_RPC_GETCONFIG, /**< \<get-config\> RPC. */ |
| 47 | NC_RPC_EDIT, /**< \<edit-config\> RPC. */ |
| 48 | NC_RPC_COPY, /**< \<copy-config\> RPC. */ |
| 49 | NC_RPC_DELETE, /**< \<delete-config\> RPC. */ |
| 50 | NC_RPC_LOCK, /**< \<lock\> RPC. */ |
| 51 | NC_RPC_UNLOCK, /**< \<unlock\> RPC. */ |
| 52 | NC_RPC_GET, /**< \<get\> RPC. */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 53 | NC_RPC_KILL, /**< \<kill-session\> RPC. */ |
| 54 | NC_RPC_COMMIT, /**< \<commit\> RPC. */ |
| 55 | NC_RPC_DISCARD, /**< \<discard-changes\> RPC. */ |
| 56 | NC_RPC_CANCEL, /**< \<cancel-commit\> RPC. */ |
| 57 | NC_RPC_VALIDATE, /**< \<validate\> RPC. */ |
| 58 | |
| 59 | /* ietf-netconf-monitoring */ |
| 60 | NC_RPC_GETSCHEMA, /**< \<get-schema\> RPC. */ |
| 61 | |
| 62 | /* notifications */ |
Michal Vasko | c1171a4 | 2019-11-05 12:06:46 +0100 | [diff] [blame] | 63 | NC_RPC_SUBSCRIBE, /**< \<create-subscription\> RPC. */ |
| 64 | |
| 65 | /* ietf-netconf-nmda */ |
| 66 | NC_RPC_GETDATA, /**< \<get-data\> RPC. */ |
| 67 | NC_RPC_EDITDATA, /**< \<edit-data\> RPC. */ |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame] | 68 | |
| 69 | /* ietf-subscribed-notifications */ |
| 70 | NC_RPC_ESTABLISHSUB, /**< \<establish-subscription\> RPC. */ |
| 71 | NC_RPC_MODIFYSUB, /**< \<modify-subscription\> RPC. */ |
| 72 | NC_RPC_DELETESUB, /**< \<delete-subscription\> RPC. */ |
| 73 | NC_RPC_KILLSUB, /**< \<kill-subscription\> RPC. */ |
Michal Vasko | 305faca | 2021-03-25 09:16:02 +0100 | [diff] [blame] | 74 | |
| 75 | /* ietf-yang-push */ |
| 76 | NC_RPC_ESTABLISHPUSH, /**< \<establish-subscription\> RPC with augments. */ |
| 77 | NC_RPC_MODIFYPUSH, /**< \<modify-subscription\> RPC with augments. */ |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 78 | NC_RPC_RESYNCSUB /**< \<resync-subscription\> RPC. */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 79 | } NC_RPC_TYPE; |
| 80 | |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 81 | /** |
| 82 | * @brief Enumeration of \<edit-config\> default operation |
| 83 | */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 84 | typedef enum { |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 85 | NC_RPC_EDIT_DFLTOP_UNKNOWN = 0, /**< unknown default operation */ |
| 86 | NC_RPC_EDIT_DFLTOP_MERGE, /**< default operation merge */ |
| 87 | NC_RPC_EDIT_DFLTOP_REPLACE, /**< default operation replace */ |
| 88 | NC_RPC_EDIT_DFLTOP_NONE /**< default operation none */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 89 | } NC_RPC_EDIT_DFLTOP; |
| 90 | |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 91 | /** |
| 92 | * @brief Enumeration of \<edit-config\> test option |
| 93 | */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 94 | typedef enum { |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 95 | NC_RPC_EDIT_TESTOPT_UNKNOWN = 0, /**< unknown test option */ |
| 96 | NC_RPC_EDIT_TESTOPT_TESTSET, /**< test-then-set option */ |
| 97 | NC_RPC_EDIT_TESTOPT_SET, /**< set option */ |
| 98 | NC_RPC_EDIT_TESTOPT_TEST /**< test-only option */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 99 | } NC_RPC_EDIT_TESTOPT; |
| 100 | |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 101 | /** |
| 102 | * @brief Enumeration of \<edit-config\> error option |
| 103 | */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 104 | typedef enum { |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 105 | NC_RPC_EDIT_ERROPT_UNKNOWN = 0, /**< unknown error option */ |
| 106 | NC_RPC_EDIT_ERROPT_STOP, /**< stop-on-error option */ |
| 107 | NC_RPC_EDIT_ERROPT_CONTINUE, /**< continue-on-error option */ |
| 108 | NC_RPC_EDIT_ERROPT_ROLLBACK /**< rollback-on-error option */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 109 | } NC_RPC_EDIT_ERROPT; |
| 110 | |
| 111 | /** |
| 112 | * @brief NETCONF error structure representation |
| 113 | */ |
| 114 | struct nc_err { |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 115 | /** @brief \<error-type\>, error layer where the error occurred. */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 116 | const char *type; |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 117 | /** @brief \<error-tag\>. */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 118 | const char *tag; |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 119 | /** @brief \<error-severity\>. */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 120 | const char *severity; |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 121 | /** @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] | 122 | const char *apptag; |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 123 | /** @brief \<error-path\>, XPATH expression identifying the element with the error. */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 124 | const char *path; |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 125 | /** @brief \<error-message\>, Human-readable description of the error. */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 126 | const char *message; |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 127 | /** @brief xml:lang attribute of the error-message. */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 128 | const char *message_lang; |
| 129 | |
| 130 | /* <error-info> */ |
| 131 | |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 132 | /** @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] | 133 | const char *sid; |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 134 | /** @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] | 135 | const char **attr; |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 136 | /** @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] | 137 | const char **elem; |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 138 | /** @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] | 139 | const char **ns; |
Michal Vasko | 7736745 | 2021-02-16 16:32:18 +0100 | [diff] [blame] | 140 | /** @brief List of the remaining non-standard opaque nodes. */ |
| 141 | struct lyd_node *other; |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 142 | |
| 143 | /** @brief Number of items in the attr array */ |
| 144 | uint16_t attr_count; |
| 145 | /** @brief Number of items in the elem array */ |
| 146 | uint16_t elem_count; |
| 147 | /** @brief Number of items in the ns array */ |
| 148 | uint16_t ns_count; |
| 149 | /** @brief Number of items in the other array */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 150 | uint16_t other_count; |
| 151 | }; |
| 152 | |
| 153 | /** |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame] | 154 | * @struct nc_rpc |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 155 | * @brief NETCONF client RPC object |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame] | 156 | * |
| 157 | * Note that any stored parameters are not checked for validity because it is performed later, |
| 158 | * while sending the RPC via a specific NETCONF session (::nc_send_rpc()) since the NETCONF |
| 159 | * capabilities of the session are needed for such a check. An RPC object can be sent via any |
| 160 | * NETCONF session which supports all the needed NETCONF capabilities for the RPC. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 161 | */ |
| 162 | struct nc_rpc; |
| 163 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 164 | /** |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 165 | * @brief Get the type of the RPC |
| 166 | * |
| 167 | * @param[in] rpc RPC to check the type of. |
Michal Vasko | c446a38 | 2021-06-18 08:54:05 +0200 | [diff] [blame] | 168 | * @return Type of @p rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 169 | */ |
| 170 | NC_RPC_TYPE nc_rpc_get_type(const struct nc_rpc *rpc); |
| 171 | |
| 172 | /** |
Michal Vasko | 90e8e69 | 2016-07-13 12:27:57 +0200 | [diff] [blame] | 173 | * @brief Create a generic NETCONF RPC or action |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 174 | * |
| 175 | * 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] | 176 | * of the @p data. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 177 | * |
Michal Vasko | 70bf222 | 2021-10-26 10:45:15 +0200 | [diff] [blame] | 178 | * @note In case of action, the \<action\> element is added automatically and should not be in @p data. |
| 179 | * |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 180 | * @param[in] data NETCONF RPC data as a data tree. |
| 181 | * @param[in] paramtype How to further manage data parameters. |
| 182 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 183 | */ |
Michal Vasko | 90e8e69 | 2016-07-13 12:27:57 +0200 | [diff] [blame] | 184 | 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] | 185 | |
| 186 | /** |
Michal Vasko | 90e8e69 | 2016-07-13 12:27:57 +0200 | [diff] [blame] | 187 | * @brief Create a generic NETCONF RPC or action from an XML string |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 188 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame] | 189 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 190 | * |
Michal Vasko | 70bf222 | 2021-10-26 10:45:15 +0200 | [diff] [blame] | 191 | * @note In case of action, the \<action\> element is added automatically and should not be in @p xml_str. |
| 192 | * |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 193 | * @param[in] xml_str NETCONF RPC data as an XML string. |
| 194 | * @param[in] paramtype How to further manage data parameters. |
| 195 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 196 | */ |
Michal Vasko | 90e8e69 | 2016-07-13 12:27:57 +0200 | [diff] [blame] | 197 | 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] | 198 | |
| 199 | /** |
| 200 | * @brief Create NETCONF RPC \<get-config\> |
| 201 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame] | 202 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 203 | * |
| 204 | * @param[in] source Source datastore being queried. |
Michal Vasko | c238970 | 2017-08-09 10:16:49 +0200 | [diff] [blame] | 205 | * @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] | 206 | * @param[in] wd_mode Optional with-defaults capability mode. |
| 207 | * @param[in] paramtype How to further manage data parameters. |
| 208 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 209 | */ |
| 210 | 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] | 211 | NC_PARAMTYPE paramtype); |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 212 | |
| 213 | /** |
| 214 | * @brief Create NETCONF RPC \<edit-config\> |
| 215 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame] | 216 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 217 | * |
| 218 | * @param[in] target Target datastore being edited. |
| 219 | * @param[in] default_op Optional default operation. |
| 220 | * @param[in] test_opt Optional test option. |
| 221 | * @param[in] error_opt Optional error option. |
| 222 | * @param[in] edit_content Config or URL where the config to perform is to be found. |
| 223 | * @param[in] paramtype How to further manage data parameters. |
| 224 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 225 | */ |
| 226 | 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] | 227 | 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] | 228 | |
| 229 | /** |
| 230 | * @brief Create NETCONF RPC \<copy-config\> |
| 231 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame] | 232 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 233 | * |
| 234 | * @param[in] target Target datastore. |
Michal Vasko | c446a38 | 2021-06-18 08:54:05 +0200 | [diff] [blame] | 235 | * @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] | 236 | * @param[in] source Source datastore. |
Michal Vasko | c446a38 | 2021-06-18 08:54:05 +0200 | [diff] [blame] | 237 | * @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] | 238 | * @param[in] wd_mode Optional with-defaults capability mode. |
| 239 | * @param[in] paramtype How to further manage data parameters. |
| 240 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 241 | */ |
| 242 | 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] | 243 | 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] | 244 | |
| 245 | /** |
| 246 | * @brief Create NETCONF RPC \<delete-config\> |
| 247 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame] | 248 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 249 | * |
| 250 | * @param[in] target Target datastore to delete. |
Michal Vasko | c446a38 | 2021-06-18 08:54:05 +0200 | [diff] [blame] | 251 | * @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] | 252 | * @param[in] paramtype How to further manage data parameters. |
| 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_delete(NC_DATASTORE target, const char *url, NC_PARAMTYPE paramtype); |
| 256 | |
| 257 | /** |
| 258 | * @brief Create NETCONF RPC \<lock\> |
| 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_lock(NC_DATASTORE target); |
| 266 | |
| 267 | /** |
| 268 | * @brief Create NETCONF RPC \<unlock\> |
| 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 | * |
| 272 | * @param[in] target Target datastore of the operation. |
| 273 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 274 | */ |
| 275 | struct nc_rpc *nc_rpc_unlock(NC_DATASTORE target); |
| 276 | |
| 277 | /** |
| 278 | * @brief Create NETCONF RPC \<get\> |
| 279 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame] | 280 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 281 | * |
Michal Vasko | c238970 | 2017-08-09 10:16:49 +0200 | [diff] [blame] | 282 | * @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] | 283 | * @param[in] wd_mode Optional with-defaults capability mode. |
| 284 | * @param[in] paramtype How to further manage data parameters. |
| 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_get(const char *filter, NC_WD_MODE wd_mode, NC_PARAMTYPE paramtype); |
| 288 | |
| 289 | /** |
| 290 | * @brief Create NETCONF RPC \<kill-session\> |
| 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] session_id Session ID of the session to kill. |
| 295 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 296 | */ |
| 297 | struct nc_rpc *nc_rpc_kill(uint32_t session_id); |
| 298 | |
| 299 | /** |
| 300 | * @brief Create NETCONF RPC \<commit\> |
| 301 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame] | 302 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 303 | * |
| 304 | * @param[in] confirmed Whether the commit is to be confirmed. |
| 305 | * @param[in] confirm_timeout Optional confirm timeout. |
| 306 | * @param[in] persist Optional identification string of a new persistent confirmed commit. |
| 307 | * @param[in] persist_id Optional identification string of a persistent confirmed commit to be commited. |
| 308 | * @param[in] paramtype How to further manage data parameters. |
| 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_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] | 312 | NC_PARAMTYPE paramtype); |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 313 | |
| 314 | /** |
| 315 | * @brief Create NETCONF RPC \<discard-changes\> |
| 316 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame] | 317 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 318 | * |
| 319 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 320 | */ |
| 321 | struct nc_rpc *nc_rpc_discard(void); |
| 322 | |
| 323 | /** |
| 324 | * @brief Create NETCONF RPC \<cancel-commit\> |
| 325 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame] | 326 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 327 | * |
| 328 | * @param[in] persist_id Optional identification string of a persistent confirmed commit. |
| 329 | * @param[in] paramtype How to further manage data parameters. |
| 330 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 331 | */ |
| 332 | struct nc_rpc *nc_rpc_cancel(const char *persist_id, NC_PARAMTYPE paramtype); |
| 333 | |
| 334 | /** |
| 335 | * @brief Create NETCONF RPC \<validate\> |
| 336 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame] | 337 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 338 | * |
| 339 | * @param[in] source Source datastore being validated. |
Michal Vasko | c446a38 | 2021-06-18 08:54:05 +0200 | [diff] [blame] | 340 | * @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] | 341 | * @param[in] paramtype How to further manage data parameters. |
| 342 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 343 | */ |
| 344 | struct nc_rpc *nc_rpc_validate(NC_DATASTORE source, const char *url_or_config, NC_PARAMTYPE paramtype); |
| 345 | |
| 346 | /** |
| 347 | * @brief Create NETCONF RPC \<get-schema\> |
| 348 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame] | 349 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 350 | * |
| 351 | * @param[in] identifier Requested model identifier. |
| 352 | * @param[in] version Optional model version, either YANG version (1.0/1.1) or revision date. |
| 353 | * @param[in] format Optional format of the model (default is YANG). |
| 354 | * @param[in] paramtype How to further manage data parameters. |
| 355 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 356 | */ |
| 357 | struct nc_rpc *nc_rpc_getschema(const char *identifier, const char *version, const char *format, NC_PARAMTYPE paramtype); |
| 358 | |
| 359 | /** |
| 360 | * @brief Create NETCONF RPC \<create-subscription\> |
| 361 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame] | 362 | * For details, see ::nc_rpc. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 363 | * |
| 364 | * @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] | 365 | * @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] | 366 | * @param[in] start_time Optional YANG datetime identifying the start of the subscription. |
| 367 | * @param[in] stop_time Optional YANG datetime identifying the end of the subscription. |
| 368 | * @param[in] paramtype How to further manage data parameters. |
| 369 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 370 | */ |
| 371 | struct nc_rpc *nc_rpc_subscribe(const char *stream_name, const char *filter, const char *start_time, |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame] | 372 | const char *stop_time, NC_PARAMTYPE paramtype); |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 373 | |
| 374 | /** |
Michal Vasko | c1171a4 | 2019-11-05 12:06:46 +0100 | [diff] [blame] | 375 | * @brief Create NETCONF RPC \<get-data\> |
| 376 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame] | 377 | * For details, see ::nc_rpc. |
Michal Vasko | c1171a4 | 2019-11-05 12:06:46 +0100 | [diff] [blame] | 378 | * |
| 379 | * @param[in] datastore Source datastore, foreign identity so a module name prefix is required. |
| 380 | * @param[in] filter Optional filter data, an XML subtree or XPath expression (with JSON prefixes). |
| 381 | * @param[in] config_filter Optional config filter, "true" for config-only data, "false" for state-only data. |
| 382 | * @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] | 383 | * @param[in] origin_filter_count Count of filters is @p origin_filter. |
Michal Vasko | c1171a4 | 2019-11-05 12:06:46 +0100 | [diff] [blame] | 384 | * @param[in] neg_origin_filter Whether origin filters are negated or not. |
| 385 | * @param[in] max_depth Maximum depth of returned subtrees, 0 for unlimited. |
| 386 | * @param[in] with_origin Whether return data origin. |
| 387 | * @param[in] wd_mode Optional with-defaults capability mode. |
| 388 | * @param[in] paramtype How to further manage data parameters. |
| 389 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 390 | */ |
| 391 | 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] | 392 | int origin_filter_count, int neg_origin_filter, uint16_t max_depth, int with_origin, NC_WD_MODE wd_mode, |
| 393 | NC_PARAMTYPE paramtype); |
Michal Vasko | c1171a4 | 2019-11-05 12:06:46 +0100 | [diff] [blame] | 394 | |
| 395 | /** |
| 396 | * @brief Create NETCONF RPC \<get-data\> |
| 397 | * |
Michal Vasko | 96f247a | 2021-03-15 13:32:10 +0100 | [diff] [blame] | 398 | * For details, see ::nc_rpc. |
Michal Vasko | c1171a4 | 2019-11-05 12:06:46 +0100 | [diff] [blame] | 399 | * |
| 400 | * @param[in] datastore Source datastore, foreign identity so a module name prefix is required. |
| 401 | * @param[in] default_op Optional default operation. |
| 402 | * @param[in] edit_content Config or URL where the config to perform is to be found. |
| 403 | * @param[in] paramtype How to further manage data parameters. |
| 404 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 405 | */ |
| 406 | 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] | 407 | NC_PARAMTYPE paramtype); |
| 408 | |
| 409 | /** |
| 410 | * @brief Create NETCONF RPC \<establish-subscription\> |
| 411 | * |
| 412 | * For details, see ::nc_rpc. |
| 413 | * |
| 414 | * @param[in] filter Optional filter data, an XML subtree, XPath expression (with JSON prefixes), |
| 415 | * or filter reference, selected based on the first character. |
| 416 | * @param[in] stream_name Name of a NETCONF stream to subscribe to. |
| 417 | * @param[in] start_time Optional YANG datetime identifying the start of the subscription. |
| 418 | * @param[in] stop_time Optional YANG datetime identifying the end of the subscription. |
| 419 | * @param[in] encoding Optional specific encoding to use. |
| 420 | * @param[in] paramtype How to further manage data parameters. |
| 421 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 422 | */ |
| 423 | struct nc_rpc *nc_rpc_establishsub(const char *filter, const char *stream_name, const char *start_time, |
| 424 | const char *stop_time, const char *encoding, NC_PARAMTYPE paramtype); |
| 425 | |
| 426 | /** |
| 427 | * @brief Create NETCONF RPC \<modify-subscription\> |
| 428 | * |
| 429 | * For details, see ::nc_rpc. |
| 430 | * |
| 431 | * @param[in] id Subscription ID to modify. |
| 432 | * @param[in] filter Optional new filter data, an XML subtree, XPath expression (with JSON prefixes), |
| 433 | * or filter reference, selected based on the first character. |
| 434 | * @param[in] stop_time Optional new YANG datetime identifying the end of the subscription. |
| 435 | * @param[in] paramtype How to further manage data parameters. |
| 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_modifysub(uint32_t id, const char *filter, const char *stop_time, NC_PARAMTYPE paramtype); |
| 439 | |
| 440 | /** |
| 441 | * @brief Create NETCONF RPC \<delete-subscription\> |
| 442 | * |
| 443 | * For details, see ::nc_rpc. |
| 444 | * |
| 445 | * @param[in] id Subscription ID to delete. |
| 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_deletesub(uint32_t id); |
| 449 | |
| 450 | /** |
| 451 | * @brief Create NETCONF RPC \<kill-subscription\> |
| 452 | * |
| 453 | * For details, see ::nc_rpc. |
| 454 | * |
| 455 | * @param[in] id Subscription ID to kill. |
| 456 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 457 | */ |
| 458 | struct nc_rpc *nc_rpc_killsub(uint32_t id); |
Michal Vasko | c1171a4 | 2019-11-05 12:06:46 +0100 | [diff] [blame] | 459 | |
| 460 | /** |
Michal Vasko | 305faca | 2021-03-25 09:16:02 +0100 | [diff] [blame] | 461 | * @brief Create NETCONF RPC \<establish-subscription\> with augments from ietf-yang-push for a periodic subscription |
| 462 | * |
| 463 | * For details, see ::nc_rpc. |
| 464 | * |
| 465 | * @param[in] datastore Source datastore, foreign identity so a module name prefix is required. |
| 466 | * @param[in] filter Optional filter data, an XML subtree, XPath expression (with JSON prefixes), |
| 467 | * or filter reference, selected based on the first character. |
| 468 | * @param[in] stop_time Optional YANG datetime identifying the end of the subscription. |
| 469 | * @param[in] encoding Optional specific encoding to use. |
| 470 | * @param[in] period Subscription period in centiseconds (0.01s). |
| 471 | * @param[in] anchor_time Optional anchor datetime for the period. |
| 472 | * @param[in] paramtype How to further manage data parameters. |
| 473 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 474 | */ |
| 475 | struct nc_rpc *nc_rpc_establishpush_periodic(const char *datastore, const char *filter, const char *stop_time, |
| 476 | const char *encoding, uint32_t period, const char *anchor_time, NC_PARAMTYPE paramtype); |
| 477 | |
| 478 | /** |
| 479 | * @brief Create NETCONF RPC \<establish-subscription\> with augments from ietf-yang-push for an on-change subscription |
| 480 | * |
| 481 | * For details, see ::nc_rpc. |
| 482 | * |
| 483 | * @param[in] datastore Source datastore, foreign identity so a module name prefix is required. |
| 484 | * @param[in] filter Optional filter data, an XML subtree, XPath expression (with JSON prefixes), |
| 485 | * or filter reference, selected based on the first character. |
| 486 | * @param[in] stop_time Optional YANG datetime identifying the end of the subscription. |
| 487 | * @param[in] encoding Optional specific encoding to use. |
| 488 | * @param[in] dampening_period Optional dampening period of the notifications. |
| 489 | * @param[in] sync_on_start Whether to send a full push-update notification on subscription start. |
| 490 | * @param[in] excluded_change Optional NULL-terminated array of excluded changes. |
| 491 | * @param[in] paramtype How to further manage data parameters. |
| 492 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 493 | */ |
| 494 | struct nc_rpc *nc_rpc_establishpush_onchange(const char *datastore, const char *filter, const char *stop_time, |
| 495 | const char *encoding, uint32_t dampening_period, int sync_on_start, const char **excluded_change, |
| 496 | NC_PARAMTYPE paramtype); |
| 497 | |
| 498 | /** |
| 499 | * @brief Create NETCONF RPC \<modify-subscription\> with augments from ietf-yang-push for a periodic subscription |
| 500 | * |
| 501 | * For details, see ::nc_rpc. |
| 502 | * |
| 503 | * @param[in] id Subscription ID to modify. |
| 504 | * @param[in] datastore Source datastore, foreign identity so a module name prefix is required. |
| 505 | * @param[in] filter Optional filter data, an XML subtree, XPath expression (with JSON prefixes), |
| 506 | * or filter reference, selected based on the first character. |
| 507 | * @param[in] stop_time Optional YANG datetime identifying the end of the subscription. |
| 508 | * @param[in] period Subscription period in centiseconds (0.01s). |
| 509 | * @param[in] anchor_time Optional anchor datetime for the period. |
| 510 | * @param[in] paramtype How to further manage data parameters. |
| 511 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 512 | */ |
| 513 | struct nc_rpc *nc_rpc_modifypush_periodic(uint32_t id, const char *datastore, const char *filter, const char *stop_time, |
| 514 | uint32_t period, const char *anchor_time, NC_PARAMTYPE paramtype); |
| 515 | |
| 516 | /** |
| 517 | * @brief Create NETCONF RPC \<modify-subscription\> with augments from ietf-yang-push for an on-change subscription |
| 518 | * |
| 519 | * For details, see ::nc_rpc. |
| 520 | * |
| 521 | * @param[in] id Subscription ID to modify. |
| 522 | * @param[in] datastore Source datastore, foreign identity so a module name prefix is required. |
| 523 | * @param[in] filter Optional filter data, an XML subtree, XPath expression (with JSON prefixes), |
| 524 | * or filter reference, selected based on the first character. |
| 525 | * @param[in] stop_time Optional YANG datetime identifying the end of the subscription. |
| 526 | * @param[in] dampening_period Optional dampening period of the notifications. |
| 527 | * @param[in] paramtype How to further manage data parameters. |
| 528 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 529 | */ |
| 530 | struct nc_rpc *nc_rpc_modifypush_onchange(uint32_t id, const char *datastore, const char *filter, const char *stop_time, |
| 531 | uint32_t dampening_period, NC_PARAMTYPE paramtype); |
| 532 | |
| 533 | /** |
| 534 | * @brief Create NETCONF RPC \<resync-subscription\> |
| 535 | * |
| 536 | * For details, see ::nc_rpc. |
| 537 | * |
| 538 | * @param[in] id Subscription ID to resync. |
| 539 | * @return Created RPC object to send via a NETCONF session or NULL in case of (memory allocation) error. |
| 540 | */ |
| 541 | struct nc_rpc *nc_rpc_resyncsub(uint32_t id); |
| 542 | |
| 543 | /** |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 544 | * @brief Free the NETCONF RPC object. |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 545 | * |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 546 | * @param[in] rpc Object to free. |
| 547 | */ |
| 548 | void nc_rpc_free(struct nc_rpc *rpc); |
| 549 | |
Michal Vasko | 7736745 | 2021-02-16 16:32:18 +0100 | [diff] [blame] | 550 | /** @} Client Messages */ |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 551 | |
Michal Vasko | c09730e | 2019-01-17 10:07:26 +0100 | [diff] [blame] | 552 | #ifdef __cplusplus |
| 553 | } |
| 554 | #endif |
| 555 | |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 556 | #endif /* NC_MESSAGES_CLIENT_H_ */ |