blob: e43c4280b5647f6a56632e5b3eeeaee8cfa46bf4 [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 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 * 3. Neither the name of the Company nor the names of its contributors
18 * may be used to endorse or promote products derived from this
19 * software without specific prior written permission.
20 *
21 */
22
23#ifndef NC_MESSAGES_P_H_
24#define NC_MESSAGES_P_H_
25
26#include <libyang/libyang.h>
27
Michal Vasko7bcb48e2016-01-15 10:28:54 +010028#include "messages_server.h"
29#include "messages_client.h"
Radek Krejci43390242015-10-08 15:34:04 +020030
Michal Vaskoad928112015-11-25 15:52:10 +010031extern const char *rpcedit_dfltop2str[];
32extern const char *rpcedit_testopt2str[];
33extern const char *rpcedit_erropt2str[];
34
Michal Vasko05ba9df2016-01-13 14:40:27 +010035struct nc_server_error {
36 NC_ERR_TYPE type;
37 NC_ERR tag;
38 //NC_ERR_SEV severity;
39 const char *apptag;
40 const char *path;
41 const char *message;
42 const char *message_lang;
43
44 /* <error-info> */
45 uint32_t sid;
46 const char **attr;
47 uint16_t attr_count;
48 const char **elem;
49 uint16_t elem_count;
50 const char **ns;
51 uint16_t ns_count;
52 struct lyxml_elem **other;
53 uint16_t other_count;
54};
55
56struct nc_server_reply {
57 NC_RPL type;
58};
59
60struct nc_server_reply_data {
61 NC_RPL type;
62 struct lyd_node *data;
63 char free;
64};
65
66struct nc_server_reply_error {
67 NC_RPL type;
68 struct ly_ctx *ctx;
69 struct nc_server_error **err;
70 uint32_t count;
71};
Radek Krejci695d4fa2015-10-22 13:23:54 +020072
Michal Vaskoad611702015-12-03 13:41:51 +010073struct nc_server_rpc {
Radek Krejci695d4fa2015-10-22 13:23:54 +020074 struct lyxml_elem *root; /**< RPC element of the received XML message */
75 struct lyd_node *tree; /**< libyang data tree of the message (NETCONF operation) */
76};
77
Michal Vasko1a38c862016-01-15 15:50:07 +010078struct nc_client_reply_error {
79 NC_RPL type;
80 struct nc_err *err;
81 uint32_t count;
82 struct ly_ctx *ctx;
83};
84
Michal Vasko2a3eef02015-12-11 14:38:34 +010085struct nc_rpc {
86 NC_RPC_TYPE type;
Michal Vaskoad928112015-11-25 15:52:10 +010087};
88
Michal Vasko2a3eef02015-12-11 14:38:34 +010089struct nc_rpc_generic {
90 NC_RPC_TYPE type; /**< NC_RPC_GENERIC */
91 int has_data; /**< 1 for content.data, 0 for content.xml_str */
92 union {
93 struct lyd_node *data; /**< parsed RPC data */
94 char *xml_str; /**< raw XML string */
95 } content;
Michal Vaskoad611702015-12-03 13:41:51 +010096 char free;
Radek Krejci926a5742015-10-31 17:50:49 +010097};
98
Radek Krejci695d4fa2015-10-22 13:23:54 +020099struct nc_rpc_getconfig {
100 NC_RPC_TYPE type; /**< NC_RPC_GETCONFIG */
101 NC_DATASTORE source; /**< NETCONF datastore being queried */
Michal Vaskoad611702015-12-03 13:41:51 +0100102 char *filter; /**< either XML subtree (starts with '<') or an XPath (starts with '/' or an alpha) */
Michal Vasko807be232015-12-09 15:24:55 +0100103 NC_WD_MODE wd_mode;
Michal Vaskoad611702015-12-03 13:41:51 +0100104 char free;
Radek Krejci695d4fa2015-10-22 13:23:54 +0200105};
106
Michal Vaskoad928112015-11-25 15:52:10 +0100107struct nc_rpc_edit {
108 NC_RPC_TYPE type; /**< NC_RPC_EDIT */
109 NC_DATASTORE target;
110 NC_RPC_EDIT_DFLTOP default_op;
111 NC_RPC_EDIT_TESTOPT test_opt;
112 NC_RPC_EDIT_ERROPT error_opt;
113 char *edit_cont; /**< either URL (starts with aplha) or config (starts with '<') */
Michal Vaskoad611702015-12-03 13:41:51 +0100114 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100115};
116
117struct nc_rpc_copy {
118 NC_RPC_TYPE type; /**< NC_RPC_COPY */
119 NC_DATASTORE target;
120 char *url_trg;
121 NC_DATASTORE source;
122 char *url_config_src; /**< either URL (starts with aplha) or config (starts with '<') */
Michal Vasko807be232015-12-09 15:24:55 +0100123 NC_WD_MODE wd_mode;
Michal Vaskoad611702015-12-03 13:41:51 +0100124 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100125};
126
127struct nc_rpc_delete {
128 NC_RPC_TYPE type; /**< NC_RPC_DELETE */
129 NC_DATASTORE target;
130 char *url;
Michal Vaskoad611702015-12-03 13:41:51 +0100131 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100132};
133
Radek Krejci695d4fa2015-10-22 13:23:54 +0200134struct nc_rpc_lock {
135 NC_RPC_TYPE type; /**< NC_RPC_LOCK or NC_RPC_UNLOCK */
136 NC_DATASTORE target;
Radek Krejci206fcd62015-10-07 15:42:48 +0200137};
138
Michal Vaskoad928112015-11-25 15:52:10 +0100139struct nc_rpc_get {
140 NC_RPC_TYPE type; /**< NC_RPC_GET */
Michal Vaskoad611702015-12-03 13:41:51 +0100141 char *filter; /**< either XML subtree (starts with '<') or an XPath (starts with '/' or an alpha) */
Michal Vasko807be232015-12-09 15:24:55 +0100142 NC_WD_MODE wd_mode;
Michal Vaskoad611702015-12-03 13:41:51 +0100143 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100144};
145
146struct nc_rpc_kill {
147 NC_RPC_TYPE type; /**< NC_RPC_KILL */
148 uint32_t sid;
149};
150
151struct nc_rpc_commit {
152 NC_RPC_TYPE type; /**< NC_RPC_COMMIT */
153 int confirmed;
154 uint32_t confirm_timeout;
155 char *persist;
156 char *persist_id;
Michal Vaskoad611702015-12-03 13:41:51 +0100157 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100158};
159
160struct nc_rpc_cancel {
161 NC_RPC_TYPE type; /**< NC_RPC_CANCEL */
162 char *persist_id;
Michal Vaskoad611702015-12-03 13:41:51 +0100163 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100164};
165
166struct nc_rpc_validate {
167 NC_RPC_TYPE type; /**< NC_RPC_VALIDATE */
168 NC_DATASTORE source;
169 char *url_config_src; /**< either URL (starts with alpha) or config (starts with '<') */
Michal Vaskoad611702015-12-03 13:41:51 +0100170 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100171};
172
173struct nc_rpc_getschema {
174 NC_RPC_TYPE type; /**< NC_RPC_GETSCHEMA */
175 char *identifier; /**< requested model identifier */
176 char *version; /**< either YANG version (1.0/1.1) or revision date */
177 char *format; /**< model format */
Michal Vaskoad611702015-12-03 13:41:51 +0100178 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100179};
180
181struct nc_rpc_subscribe {
182 NC_RPC_TYPE type; /**< NC_RPC_SUBSCRIBE */
183 char *stream; /**< stream name */
Michal Vaskoad611702015-12-03 13:41:51 +0100184 char *filter; /**< either XML subtree (starts with '<') or an XPath (starts with '/' or an alpha) */
Michal Vaskoad928112015-11-25 15:52:10 +0100185 char *start;
186 char *stop;
Michal Vaskoad611702015-12-03 13:41:51 +0100187 char free;
Radek Krejci5686ff72015-10-09 13:33:56 +0200188};
189
Michal Vasko05ba9df2016-01-13 14:40:27 +0100190void nc_server_rpc_free(struct nc_server_rpc *rpc);
191
Radek Krejci206fcd62015-10-07 15:42:48 +0200192#endif /* NC_MESSAGES_P_H_ */