Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 1 | /** |
| 2 | * \file messages_server.h |
| 3 | * \author Michal Vasko <mvasko@cesnet.cz> |
| 4 | * \brief libnetconf2's functions and structures of server NETCONF messages. |
| 5 | * |
Michal Vasko | fc9dbdd | 2017-03-17 09:27:57 +0100 | [diff] [blame^] | 6 | * Copyright (c) 2015-2017 CESNET, z.s.p.o. |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 7 | * |
Radek Krejci | 9b81f5b | 2016-02-24 13:14:49 +0100 | [diff] [blame] | 8 | * This source code is licensed under BSD 3-Clause License (the "License"). |
| 9 | * You may not use this file except in compliance with the License. |
| 10 | * You may obtain a copy of the License at |
Michal Vasko | afd416b | 2016-02-25 14:51:46 +0100 | [diff] [blame] | 11 | * |
Radek Krejci | 9b81f5b | 2016-02-24 13:14:49 +0100 | [diff] [blame] | 12 | * https://opensource.org/licenses/BSD-3-Clause |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 13 | */ |
| 14 | |
| 15 | #ifndef NC_MESSAGES_SERVER_H_ |
| 16 | #define NC_MESSAGES_SERVER_H_ |
| 17 | |
| 18 | #include <stdint.h> |
| 19 | |
| 20 | #include "netconf.h" |
Radek Krejci | 93e8022 | 2016-10-03 13:34:25 +0200 | [diff] [blame] | 21 | #include "session.h" |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 22 | |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 23 | /** |
| 24 | * @brief Enumeration of NETCONF errors |
| 25 | */ |
Michal Vasko | 495c946 | 2016-01-15 11:27:43 +0100 | [diff] [blame] | 26 | typedef enum NC_ERROR { |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 27 | NC_ERR_UNKNOWN = 0, /**< unknown error */ |
| 28 | NC_ERR_IN_USE, /**< in-use error */ |
| 29 | NC_ERR_INVALID_VALUE, /**< invalid-value error */ |
| 30 | NC_ERR_TOO_BIG, /**< too-big error */ |
| 31 | NC_ERR_MISSING_ATTR, /**< missing-attribute error */ |
| 32 | NC_ERR_BAD_ATTR, /**< bad-attribute error */ |
| 33 | NC_ERR_UNKNOWN_ATTR, /**< unknown-attribute error */ |
| 34 | NC_ERR_MISSING_ELEM, /**< missing-element error */ |
| 35 | NC_ERR_BAD_ELEM, /**< bad-element error */ |
| 36 | NC_ERR_UNKNOWN_ELEM, /**< unknown-element error */ |
| 37 | NC_ERR_UNKNOWN_NS, /**< unknown-namespace error */ |
| 38 | NC_ERR_ACCESS_DENIED, /**< access-denied error */ |
| 39 | NC_ERR_LOCK_DENIED, /**< lock-denied error */ |
| 40 | NC_ERR_RES_DENIED, /**< resource-denied error */ |
| 41 | NC_ERR_ROLLBACK_FAILED, /**< rollback-failed error */ |
| 42 | NC_ERR_DATA_EXISTS, /**< data-exists error */ |
| 43 | NC_ERR_DATA_MISSING, /**< data-missing error */ |
| 44 | NC_ERR_OP_NOT_SUPPORTED, /**< operation-not-supported error */ |
| 45 | NC_ERR_OP_FAILED, /**< operation-failed error */ |
| 46 | NC_ERR_MALFORMED_MSG /**< malformed-message error */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 47 | } NC_ERR; |
| 48 | |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 49 | /** |
| 50 | * @brief Enumeration of NETCONF error type (layer) |
| 51 | */ |
Michal Vasko | 495c946 | 2016-01-15 11:27:43 +0100 | [diff] [blame] | 52 | typedef enum NC_ERROR_TYPE { |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 53 | NC_ERR_TYPE_UNKNOWN = 0, /**< unknown layer */ |
| 54 | NC_ERR_TYPE_TRAN, /**< transport layer */ |
| 55 | NC_ERR_TYPE_RPC, /**< RPC layer */ |
| 56 | NC_ERR_TYPE_PROT, /**< protocol layer */ |
| 57 | NC_ERR_TYPE_APP /**< application layer */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 58 | } NC_ERR_TYPE; |
| 59 | |
| 60 | /** |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 61 | * @brief NETCONF server rpc-reply object |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 62 | */ |
| 63 | struct nc_server_reply; |
| 64 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 65 | /** |
Radek Krejci | 93e8022 | 2016-10-03 13:34:25 +0200 | [diff] [blame] | 66 | * @brief NETCONF server Event Notification object |
| 67 | */ |
| 68 | struct nc_server_notif; |
| 69 | |
| 70 | /** |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 71 | * @brief NETCONF server error structure |
| 72 | */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 73 | struct nc_server_error; |
| 74 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 75 | /** |
| 76 | * @brief Create an OK rpc-reply object. |
| 77 | * |
| 78 | * @return rpc-reply object, NULL on error. |
| 79 | */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 80 | struct nc_server_reply *nc_server_reply_ok(void); |
| 81 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 82 | /** |
| 83 | * @brief Create a DATA rpc-reply object. |
| 84 | * |
Michal Vasko | b08743b | 2016-04-13 14:23:49 +0200 | [diff] [blame] | 85 | * @param[in] data Reply data tree. This tree must be valid according to |
| 86 | * the RPC output of the RPC this is a reply to. |
Radek Krejci | 36dfdb3 | 2016-09-01 16:56:35 +0200 | [diff] [blame] | 87 | * @param[in] wd with-default mode if applicable |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 88 | * @param[in] paramtype Determines how the \p data parameter is treated. |
| 89 | * @return rpc-reply object, NULL on error. |
| 90 | */ |
Radek Krejci | 36dfdb3 | 2016-09-01 16:56:35 +0200 | [diff] [blame] | 91 | struct nc_server_reply *nc_server_reply_data(struct lyd_node *data, NC_WD_MODE wd, NC_PARAMTYPE paramtype); |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 92 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 93 | /** |
| 94 | * @brief Create an ERROR rpc-reply object. |
| 95 | * |
| 96 | * @param[in] err Structure holding the error information. It will be freed with the returned object. |
| 97 | * @return rpc-reply object, NULL on error. |
| 98 | */ |
| 99 | struct nc_server_reply *nc_server_reply_err(struct nc_server_error *err); |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 100 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 101 | /** |
| 102 | * @brief Add another error to an ERROR rpc-reply object. It will be freed with the returned object. |
| 103 | * |
| 104 | * @param[in] reply ERROR reply to add to. |
| 105 | * @param[in] err Structure holding the additional error information. |
| 106 | * @return 0 on success, -1 on errror. |
| 107 | */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 108 | int nc_server_reply_add_err(struct nc_server_reply *reply, struct nc_server_error *err); |
| 109 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 110 | /** |
Michal Vasko | aa2e5a7 | 2017-03-16 09:48:44 +0100 | [diff] [blame] | 111 | * @brief Get last error from an ERROR rpy-reply object. |
| 112 | * |
| 113 | * @param[in] reply ERROR reply to read from. |
| 114 | * @return Last error, NULL on failure. |
| 115 | */ |
| 116 | const struct nc_server_error *nc_server_reply_get_last_err(const struct nc_server_reply *reply); |
| 117 | |
| 118 | /** |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 119 | * @brief Create a server error structure. Its \<error-message\> is filled with |
| 120 | * a general description of the specific error. |
| 121 | * |
Radek Krejci | 127f895 | 2016-10-12 14:57:16 +0200 | [diff] [blame] | 122 | * @param[in] tag \<error-tag\> of the server error specified as #NC_ERR value. According to the tag, the |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 123 | * specific additional parameters are required: |
| 124 | * - #NC_ERR_IN_USE |
| 125 | * - #NC_ERR_INVALID_VALUE |
| 126 | * - #NC_ERR_ACCESS_DENIED |
| 127 | * - #NC_ERR_ROLLBACK_FAILED |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 128 | * - #NC_ERR_OP_NOT_SUPPORTED |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 129 | * - #NC_ERR_TOO_BIG |
| 130 | * - #NC_ERR_RES_DENIED |
| 131 | * - #NC_ERR_OP_FAILED |
| 132 | * - `NC_ERR_TYPE type;` - type (layer) of the error. |
| 133 | * - #NC_ERR_MISSING_ATTR |
| 134 | * - #NC_ERR_BAD_ATTR |
| 135 | * - #NC_ERR_UNKNOWN_ATTR |
| 136 | * - `NC_ERR_TYPE type;` - type (layer) of the error. |
| 137 | * - `const char *attr_name;` - error \<bad-attribute\> value. |
| 138 | * - `const char *elem_name;` - error \<bad-element\> value. |
| 139 | * - #NC_ERR_MISSING_ELEM |
| 140 | * - #NC_ERR_BAD_ELEM |
| 141 | * - #NC_ERR_UNKNOWN_ELEM |
| 142 | * - `NC_ERR_TYPE type;` - type (layer) of the error. |
| 143 | * - `const char *elem_name;` - error \<bad-element\> value. |
| 144 | * - #NC_ERR_UNKNOWN_NS |
| 145 | * - `NC_ERR_TYPE type;` - type (layer) of the error. |
| 146 | * - `const char *elem_name;` - error \<bad-element\> value. |
| 147 | * - `const char *nc_name;` - error \<bad-namespace\> value. |
| 148 | * - #NC_ERR_LOCK_DENIED |
| 149 | * - `uint32_t session_id;` - error \<session-id\> value. |
| 150 | * - #NC_ERR_DATA_EXISTS |
| 151 | * - #NC_ERR_DATA_MISSING |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 152 | * - #NC_ERR_MALFORMED_MSG |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 153 | * - no additional arguments |
| 154 | * @return Server error structure, NULL on error. |
| 155 | */ |
Radek Krejci | 127f895 | 2016-10-12 14:57:16 +0200 | [diff] [blame] | 156 | struct nc_server_error *nc_err(int tag, ...); |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 157 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 158 | /** |
Radek Krejci | 877e182 | 2016-04-06 16:37:43 +0200 | [diff] [blame] | 159 | * @brief Create a server error structure based on libyang error. |
| 160 | * |
| 161 | * The function should be used immediately when a libyang function fails to generate |
| 162 | * NETCONF error structure based on internal libyang error information (ly_errno, ly_errmsg, ...) |
| 163 | * |
| 164 | * @return Server error structure, NULL on error. |
| 165 | */ |
Michal Vasko | 7d9b495 | 2016-04-08 10:44:26 +0200 | [diff] [blame] | 166 | struct nc_server_error *nc_err_libyang(void); |
Radek Krejci | 877e182 | 2016-04-06 16:37:43 +0200 | [diff] [blame] | 167 | |
| 168 | /** |
Michal Vasko | 8f3198f | 2016-05-04 10:45:28 +0200 | [diff] [blame] | 169 | * @brief Get the \<error-type\> of a server error. |
| 170 | * |
| 171 | * @param[in] err Server error to read from. |
| 172 | * @return Server error type, 0 on error. |
| 173 | */ |
Michal Vasko | ea20178 | 2017-03-16 09:49:54 +0100 | [diff] [blame] | 174 | NC_ERR_TYPE nc_err_get_type(const struct nc_server_error *err); |
Michal Vasko | 8f3198f | 2016-05-04 10:45:28 +0200 | [diff] [blame] | 175 | |
| 176 | /** |
| 177 | * @brief Get the \<error-tag\> of a server error. |
| 178 | * |
| 179 | * @param[in] err Server error to read from. |
| 180 | * @return Server error tag, 0 on error. |
| 181 | */ |
Michal Vasko | ea20178 | 2017-03-16 09:49:54 +0100 | [diff] [blame] | 182 | NC_ERR nc_err_get_tag(const struct nc_server_error *err); |
Michal Vasko | 8f3198f | 2016-05-04 10:45:28 +0200 | [diff] [blame] | 183 | |
| 184 | /** |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 185 | * @brief Set the \<error-app-tag\> element of an error. Any previous value will be overwritten. |
| 186 | * |
| 187 | * @param[in] err Error to modify. |
| 188 | * @param[in] error_app_tag New value of \<error-app-tag\>. |
| 189 | * @return 0 on success, -1 on error. |
| 190 | */ |
| 191 | int nc_err_set_app_tag(struct nc_server_error *err, const char *error_app_tag); |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 192 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 193 | /** |
Michal Vasko | 8f3198f | 2016-05-04 10:45:28 +0200 | [diff] [blame] | 194 | * @brief Get the \<error-app-tag\> of a server error. |
| 195 | * |
| 196 | * @param[in] err Server error to read from. |
| 197 | * @return Server error app tag, NULL on error. |
| 198 | */ |
Michal Vasko | ea20178 | 2017-03-16 09:49:54 +0100 | [diff] [blame] | 199 | const char *nc_err_get_app_tag(const struct nc_server_error *err); |
Michal Vasko | 8f3198f | 2016-05-04 10:45:28 +0200 | [diff] [blame] | 200 | |
| 201 | /** |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 202 | * @brief Set the \<error-path\> element of an error. Any previous value will be overwritten. |
| 203 | * |
| 204 | * @param[in] err Error to modify. |
| 205 | * @param[in] error_path New value of \<error-path\>. |
| 206 | * @return 0 on success, -1 on error. |
| 207 | */ |
| 208 | int nc_err_set_path(struct nc_server_error *err, const char *error_path); |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 209 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 210 | /** |
Michal Vasko | 8f3198f | 2016-05-04 10:45:28 +0200 | [diff] [blame] | 211 | * @brief Get the \<error-path\> of a server error. |
| 212 | * |
| 213 | * @param[in] err Server error to read from. |
| 214 | * @return Server error path, NULL on error. |
| 215 | */ |
Michal Vasko | ea20178 | 2017-03-16 09:49:54 +0100 | [diff] [blame] | 216 | const char *nc_err_get_path(const struct nc_server_error *err); |
Michal Vasko | 8f3198f | 2016-05-04 10:45:28 +0200 | [diff] [blame] | 217 | |
| 218 | /** |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 219 | * @brief Set the \<error-message\> element of an error. Any previous value will be overwritten. |
| 220 | * |
| 221 | * @param[in] err Error to modify. |
| 222 | * @param[in] error_message New value of \<error-message\>. |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 223 | * @param[in] lang Optional language of \p error_message. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 224 | * @return 0 on success, -1 on error. |
| 225 | */ |
| 226 | int nc_err_set_msg(struct nc_server_error *err, const char *error_message, const char *lang); |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 227 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 228 | /** |
Michal Vasko | 8f3198f | 2016-05-04 10:45:28 +0200 | [diff] [blame] | 229 | * @brief Get the \<error-message\> of a server error. |
| 230 | * |
| 231 | * @param[in] err Server error to read from. |
| 232 | * @return Server error message, NULL on error. |
| 233 | */ |
Michal Vasko | ea20178 | 2017-03-16 09:49:54 +0100 | [diff] [blame] | 234 | const char *nc_err_get_msg(const struct nc_server_error *err); |
Michal Vasko | 8f3198f | 2016-05-04 10:45:28 +0200 | [diff] [blame] | 235 | |
| 236 | /** |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 237 | * @brief Set the \<session-id\> element of an error. Any previous value will be overwritten. |
| 238 | * |
| 239 | * @param[in] err Error to modify. |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 240 | * @param[in] session_id New value of \<session-id\>. |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 241 | * @return 0 on success, -1 on error. |
| 242 | */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 243 | int nc_err_set_sid(struct nc_server_error *err, uint32_t session_id); |
| 244 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 245 | /** |
| 246 | * @brief Add a \<bad-attribute\> element to an error. |
| 247 | * |
| 248 | * @param[in] err Error to modify. |
| 249 | * @param[in] attr_name Value of the new \<bad-attribute\> element. |
| 250 | * @return 0 on success, -1 on error. |
| 251 | */ |
| 252 | int nc_err_add_bad_attr(struct nc_server_error *err, const char *attr_name); |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 253 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 254 | /** |
| 255 | * @brief Add a \<bad-element\> element to an error. |
| 256 | * |
| 257 | * @param[in] err Error to modify. |
| 258 | * @param[in] elem_name Value of the new \<bad-element\> element. |
| 259 | * @return 0 on success, -1 on error. |
| 260 | */ |
| 261 | int nc_err_add_bad_elem(struct nc_server_error *err, const char *elem_name); |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 262 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 263 | /** |
| 264 | * @brief Add a \<bad-namespace\> element to an error. |
| 265 | * |
| 266 | * @param[in] err Error to modify. |
| 267 | * @param[in] ns_name Value of the new \<bad-namespace\> element. |
| 268 | * @return 0 on success, -1 on error. |
| 269 | */ |
| 270 | int nc_err_add_bad_ns(struct nc_server_error *err, const char *ns_name); |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 271 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 272 | /** |
| 273 | * @brief Add an additional custom element to an error. |
| 274 | * |
| 275 | * @param[in] err Error to modify. |
| 276 | * @param[in] other New custom XML element. |
| 277 | * @return 0 on success, -1 on error. |
| 278 | */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 279 | int nc_err_add_info_other(struct nc_server_error *err, struct lyxml_elem *other); |
| 280 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 281 | /** |
| 282 | * @brief Free a server rpc-reply object. |
| 283 | * |
| 284 | * @param[in] reply Server rpc-reply object to free. |
| 285 | */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 286 | void nc_server_reply_free(struct nc_server_reply *reply); |
| 287 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 288 | /** |
| 289 | * @brief Free a server error structure. |
| 290 | * |
| 291 | * @param[in] err Error structure to free. |
| 292 | */ |
| 293 | void nc_err_free(struct nc_server_error *err); |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 294 | |
Radek Krejci | 93e8022 | 2016-10-03 13:34:25 +0200 | [diff] [blame] | 295 | /** |
| 296 | * @brief Create Event Notification object to be sent to the subscribed client(s). |
| 297 | * |
| 298 | * @param[in] event Notification data tree (valid as LYD_OPT_NOTIF) from libyang. The tree is directly used in created |
| 299 | * object, so the caller is supposed to not free the tree on its own, but only via freeng the created object. |
| 300 | * @param[in] eventtime YANG dateTime format value of the time when the event was generated by the event source. |
Michal Vasko | fc9dbdd | 2017-03-17 09:27:57 +0100 | [diff] [blame^] | 301 | * Caller can use nc_time2datetime() to create the value from the time_t value. |
| 302 | * @param[in] paramtype How to further manage data parameters. |
Radek Krejci | 93e8022 | 2016-10-03 13:34:25 +0200 | [diff] [blame] | 303 | * @return Newly created structure of the Event Notification object to be sent to the clients via nc_server_send_notif() |
| 304 | * and freed using nc_server_notif_free(). |
| 305 | */ |
Michal Vasko | fc9dbdd | 2017-03-17 09:27:57 +0100 | [diff] [blame^] | 306 | struct nc_server_notif *nc_server_notif_new(struct lyd_node* event, char *eventtime, NC_PARAMTYPE paramtype); |
Radek Krejci | 93e8022 | 2016-10-03 13:34:25 +0200 | [diff] [blame] | 307 | |
| 308 | /** |
| 309 | * @brief Send NETCONF Event Notification via the session. |
| 310 | * |
| 311 | * @param[in] session NETCONF session where the Event Notification will be written. |
| 312 | * @param[in] notif NETCOFN Notification object to send via specified session. Object can be created by |
| 313 | * nc_notif_new() function. |
| 314 | * @param[in] timeout Timeout for writing in milliseconds. Use negative value for infinite |
| 315 | * waiting and 0 for return if data cannot be sent immediately. |
| 316 | * @return #NC_MSG_NOTIF on success, |
| 317 | * #NC_MSG_WOULDBLOCK in case of a busy session, and |
| 318 | * #NC_MSG_ERROR on error. |
| 319 | */ |
| 320 | NC_MSG_TYPE nc_server_notif_send(struct nc_session *session, struct nc_server_notif *notif, int timeout); |
| 321 | |
| 322 | /** |
| 323 | * @brief Free a server Event Notification object. |
| 324 | * |
| 325 | * @param[in] notif Server Event Notification object to free. |
| 326 | */ |
| 327 | void nc_server_notif_free(struct nc_server_notif *notif); |
| 328 | |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 329 | #endif /* NC_MESSAGES_SERVER_H_ */ |