blob: e832b08e38581bd72ecf83af67a00074f845ccd0 [file] [log] [blame]
Radek Krejci206fcd62015-10-07 15:42:48 +02001/**
2 * \file messages_p.h
3 * \author Radek Krejci <rkrejci@cesnet.cz>
4 * \brief libnetconf2's private functions and structures of NETCONF messages.
5 *
6 * Copyright (c) 2015 CESNET, z.s.p.o.
7 *
Radek Krejci9b81f5b2016-02-24 13:14:49 +01008 * 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 Vaskoafd416b2016-02-25 14:51:46 +010011 *
Radek Krejci9b81f5b2016-02-24 13:14:49 +010012 * https://opensource.org/licenses/BSD-3-Clause
Radek Krejci206fcd62015-10-07 15:42:48 +020013 */
14
15#ifndef NC_MESSAGES_P_H_
16#define NC_MESSAGES_P_H_
17
18#include <libyang/libyang.h>
19
Michal Vasko7bcb48e2016-01-15 10:28:54 +010020#include "messages_server.h"
21#include "messages_client.h"
Radek Krejci43390242015-10-08 15:34:04 +020022
Michal Vaskoad928112015-11-25 15:52:10 +010023extern const char *rpcedit_dfltop2str[];
24extern const char *rpcedit_testopt2str[];
25extern const char *rpcedit_erropt2str[];
26
Michal Vasko05ba9df2016-01-13 14:40:27 +010027struct nc_server_error {
28 NC_ERR_TYPE type;
29 NC_ERR tag;
30 //NC_ERR_SEV severity;
31 const char *apptag;
32 const char *path;
33 const char *message;
34 const char *message_lang;
35
36 /* <error-info> */
Michal Vasko90920b02016-05-20 14:07:00 +020037 int64_t sid; /* -1 for not set */
Michal Vasko05ba9df2016-01-13 14:40:27 +010038 const char **attr;
39 uint16_t attr_count;
40 const char **elem;
41 uint16_t elem_count;
42 const char **ns;
43 uint16_t ns_count;
44 struct lyxml_elem **other;
45 uint16_t other_count;
46};
47
48struct nc_server_reply {
49 NC_RPL type;
50};
51
52struct nc_server_reply_data {
53 NC_RPL type;
54 struct lyd_node *data;
55 char free;
Radek Krejci36dfdb32016-09-01 16:56:35 +020056 NC_WD_MODE wd;
Michal Vasko05ba9df2016-01-13 14:40:27 +010057};
58
59struct nc_server_reply_error {
60 NC_RPL type;
61 struct ly_ctx *ctx;
62 struct nc_server_error **err;
63 uint32_t count;
64};
Radek Krejci695d4fa2015-10-22 13:23:54 +020065
Michal Vaskoad611702015-12-03 13:41:51 +010066struct nc_server_rpc {
Radek Krejci695d4fa2015-10-22 13:23:54 +020067 struct lyxml_elem *root; /**< RPC element of the received XML message */
68 struct lyd_node *tree; /**< libyang data tree of the message (NETCONF operation) */
69};
70
Radek Krejci93e80222016-10-03 13:34:25 +020071struct nc_server_notif {
72 char *eventtime; /**< eventTime of the notification */
73 struct lyd_node *tree; /**< libyang data tree of the message */
74};
75
Michal Vasko1a38c862016-01-15 15:50:07 +010076struct nc_client_reply_error {
77 NC_RPL type;
78 struct nc_err *err;
79 uint32_t count;
80 struct ly_ctx *ctx;
81};
82
Michal Vasko2a3eef02015-12-11 14:38:34 +010083struct nc_rpc {
84 NC_RPC_TYPE type;
Michal Vaskoad928112015-11-25 15:52:10 +010085};
86
Michal Vasko90e8e692016-07-13 12:27:57 +020087struct nc_rpc_act_generic {
88 NC_RPC_TYPE type; /**< NC_RPC_ACT_GENERIC */
Michal Vasko2a3eef02015-12-11 14:38:34 +010089 int has_data; /**< 1 for content.data, 0 for content.xml_str */
90 union {
91 struct lyd_node *data; /**< parsed RPC data */
92 char *xml_str; /**< raw XML string */
93 } content;
Michal Vaskoad611702015-12-03 13:41:51 +010094 char free;
Radek Krejci926a5742015-10-31 17:50:49 +010095};
96
Radek Krejci695d4fa2015-10-22 13:23:54 +020097struct nc_rpc_getconfig {
98 NC_RPC_TYPE type; /**< NC_RPC_GETCONFIG */
99 NC_DATASTORE source; /**< NETCONF datastore being queried */
Michal Vaskoad611702015-12-03 13:41:51 +0100100 char *filter; /**< either XML subtree (starts with '<') or an XPath (starts with '/' or an alpha) */
Michal Vasko807be232015-12-09 15:24:55 +0100101 NC_WD_MODE wd_mode;
Michal Vaskoad611702015-12-03 13:41:51 +0100102 char free;
Radek Krejci695d4fa2015-10-22 13:23:54 +0200103};
104
Michal Vaskoad928112015-11-25 15:52:10 +0100105struct nc_rpc_edit {
106 NC_RPC_TYPE type; /**< NC_RPC_EDIT */
107 NC_DATASTORE target;
108 NC_RPC_EDIT_DFLTOP default_op;
109 NC_RPC_EDIT_TESTOPT test_opt;
110 NC_RPC_EDIT_ERROPT error_opt;
111 char *edit_cont; /**< either URL (starts with aplha) or config (starts with '<') */
Michal Vaskoad611702015-12-03 13:41:51 +0100112 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100113};
114
115struct nc_rpc_copy {
116 NC_RPC_TYPE type; /**< NC_RPC_COPY */
117 NC_DATASTORE target;
118 char *url_trg;
119 NC_DATASTORE source;
120 char *url_config_src; /**< either URL (starts with aplha) or config (starts with '<') */
Michal Vasko807be232015-12-09 15:24:55 +0100121 NC_WD_MODE wd_mode;
Michal Vaskoad611702015-12-03 13:41:51 +0100122 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100123};
124
125struct nc_rpc_delete {
126 NC_RPC_TYPE type; /**< NC_RPC_DELETE */
127 NC_DATASTORE target;
128 char *url;
Michal Vaskoad611702015-12-03 13:41:51 +0100129 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100130};
131
Radek Krejci695d4fa2015-10-22 13:23:54 +0200132struct nc_rpc_lock {
133 NC_RPC_TYPE type; /**< NC_RPC_LOCK or NC_RPC_UNLOCK */
134 NC_DATASTORE target;
Radek Krejci206fcd62015-10-07 15:42:48 +0200135};
136
Michal Vaskoad928112015-11-25 15:52:10 +0100137struct nc_rpc_get {
138 NC_RPC_TYPE type; /**< NC_RPC_GET */
Michal Vaskoad611702015-12-03 13:41:51 +0100139 char *filter; /**< either XML subtree (starts with '<') or an XPath (starts with '/' or an alpha) */
Michal Vasko807be232015-12-09 15:24:55 +0100140 NC_WD_MODE wd_mode;
Michal Vaskoad611702015-12-03 13:41:51 +0100141 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100142};
143
144struct nc_rpc_kill {
145 NC_RPC_TYPE type; /**< NC_RPC_KILL */
146 uint32_t sid;
147};
148
149struct nc_rpc_commit {
150 NC_RPC_TYPE type; /**< NC_RPC_COMMIT */
151 int confirmed;
152 uint32_t confirm_timeout;
153 char *persist;
154 char *persist_id;
Michal Vaskoad611702015-12-03 13:41:51 +0100155 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100156};
157
158struct nc_rpc_cancel {
159 NC_RPC_TYPE type; /**< NC_RPC_CANCEL */
160 char *persist_id;
Michal Vaskoad611702015-12-03 13:41:51 +0100161 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100162};
163
164struct nc_rpc_validate {
165 NC_RPC_TYPE type; /**< NC_RPC_VALIDATE */
166 NC_DATASTORE source;
167 char *url_config_src; /**< either URL (starts with alpha) or config (starts with '<') */
Michal Vaskoad611702015-12-03 13:41:51 +0100168 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100169};
170
171struct nc_rpc_getschema {
172 NC_RPC_TYPE type; /**< NC_RPC_GETSCHEMA */
173 char *identifier; /**< requested model identifier */
174 char *version; /**< either YANG version (1.0/1.1) or revision date */
175 char *format; /**< model format */
Michal Vaskoad611702015-12-03 13:41:51 +0100176 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100177};
178
179struct nc_rpc_subscribe {
180 NC_RPC_TYPE type; /**< NC_RPC_SUBSCRIBE */
181 char *stream; /**< stream name */
Michal Vaskoad611702015-12-03 13:41:51 +0100182 char *filter; /**< either XML subtree (starts with '<') or an XPath (starts with '/' or an alpha) */
Michal Vaskoad928112015-11-25 15:52:10 +0100183 char *start;
184 char *stop;
Michal Vaskoad611702015-12-03 13:41:51 +0100185 char free;
Radek Krejci5686ff72015-10-09 13:33:56 +0200186};
187
Michal Vaskoca4a2422016-02-02 12:17:14 +0100188void nc_server_rpc_free(struct nc_server_rpc *rpc, struct ly_ctx *ctx);
Michal Vasko05ba9df2016-01-13 14:40:27 +0100189
Radek Krejci206fcd62015-10-07 15:42:48 +0200190#endif /* NC_MESSAGES_P_H_ */