blob: 31ca09c6d7a17c9e3dc9098224f85fb790e4f2c9 [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
Radek Krejci43390242015-10-08 15:34:04 +020028#include "messages.h"
29
Michal Vaskoad928112015-11-25 15:52:10 +010030extern const char *rpcedit_dfltop2str[];
31extern const char *rpcedit_testopt2str[];
32extern const char *rpcedit_erropt2str[];
33
Radek Krejci695d4fa2015-10-22 13:23:54 +020034typedef enum {
Michal Vaskoad611702015-12-03 13:41:51 +010035 NC_RPC_GENERIC, /**< user-defined generic RPC with content as data. */
36 NC_RPC_GENERIC_XML, /**< user-defined generic RPC with content as an XML string. */
Michal Vaskoad928112015-11-25 15:52:10 +010037
38 /* ietf-netconf */
Michal Vaskoad611702015-12-03 13:41:51 +010039 NC_RPC_GETCONFIG, /**< \<get-config\> RPC. */
40 NC_RPC_EDIT, /**< \<edit-config\> RPC. */
41 NC_RPC_COPY, /**< \<copy-config\> RPC. */
42 NC_RPC_DELETE, /**< \<delete-config\> RPC. */
43 NC_RPC_LOCK, /**< \<lock\> RPC. */
44 NC_RPC_UNLOCK, /**< \<unlock\> RPC. */
45 NC_RPC_GET, /**< \<get\> RPC. */
Radek Krejci695d4fa2015-10-22 13:23:54 +020046 /* NC_RPC_CLOSE is not defined since sending \<close-session\> is done by nc_session_free() */
Michal Vaskoad611702015-12-03 13:41:51 +010047 NC_RPC_KILL, /**< \<kill-session\> RPC. */
48 NC_RPC_COMMIT, /**< \<commit\> RPC. */
49 NC_RPC_DISCARD, /**< \<discard-changes\> RPC. */
50 NC_RPC_CANCEL, /**< \<cancel-commit\> RPC. */
51 NC_RPC_VALIDATE, /**< \<validate\> RPC. */
Michal Vaskoad928112015-11-25 15:52:10 +010052
53 /* ietf-netconf-monitoring */
Michal Vaskoad611702015-12-03 13:41:51 +010054 NC_RPC_GETSCHEMA, /**< \<get-schema\> RPC. */
Michal Vaskoad928112015-11-25 15:52:10 +010055
56 /* notifications */
Michal Vaskoad611702015-12-03 13:41:51 +010057 NC_RPC_SUBSCRIBE /**< \<create-subscription\> RPC. */
Radek Krejci695d4fa2015-10-22 13:23:54 +020058} NC_RPC_TYPE;
59
Radek Krejci8800a492015-10-31 17:51:27 +010060typedef enum {
Michal Vaskoad611702015-12-03 13:41:51 +010061 NC_ERR_EMPTY,
62 NC_ERR_IN_USE,
63 NC_ERR_INVALID_VALUE,
64 NC_ERR_TOO_BIG,
65 NC_ERR_MISSING_ATTR,
66 NC_ERR_BAD_ATTR,
67 NC_ERR_UNKNOWN_ATTR,
68 NC_ERR_MISSING_ELEM,
69 NC_ERR_BAD_ELEM,
70 NC_ERR_UNKNOWN_ELEM,
71 NC_ERR_UNKNOWN_NS,
72 NC_ERR_ACCESS_DENIED,
73 NC_ERR_LOCK_DENIED,
74 NC_ERR_RES_DENIED,
75 NC_ERR_ROLLBACK_FAILED,
76 NC_ERR_DATA_EXISTS,
77 NC_ERR_DATA_MISSING,
78 NC_ERR_OP_NOT_SUPPORTED,
79 NC_ERR_OP_FAILED,
80 NC_ERR_MALFORMED_MSG
81} NC_ERR;
Radek Krejci695d4fa2015-10-22 13:23:54 +020082
Radek Krejci206fcd62015-10-07 15:42:48 +020083struct nc_rpc {
Radek Krejci695d4fa2015-10-22 13:23:54 +020084 NC_RPC_TYPE type;
85};
86
Michal Vaskoad611702015-12-03 13:41:51 +010087struct nc_server_rpc {
Radek Krejci695d4fa2015-10-22 13:23:54 +020088 struct lyxml_elem *root; /**< RPC element of the received XML message */
89 struct lyd_node *tree; /**< libyang data tree of the message (NETCONF operation) */
90};
91
Michal Vaskoad928112015-11-25 15:52:10 +010092struct nc_rpc_generic {
93 NC_RPC_TYPE type; /**< NC_RPC_GENERIC */
94 struct lyd_node *data; /**< RPC data */
Michal Vaskoad611702015-12-03 13:41:51 +010095 char free;
Michal Vaskoad928112015-11-25 15:52:10 +010096};
97
98struct nc_rpc_generic_xml {
99 NC_RPC_TYPE type; /**< NC_RPC_GENERIC_XML */
100 char *xml_str;
Michal Vaskoad611702015-12-03 13:41:51 +0100101 char free;
Radek Krejci926a5742015-10-31 17:50:49 +0100102};
103
Radek Krejci695d4fa2015-10-22 13:23:54 +0200104struct nc_rpc_getconfig {
105 NC_RPC_TYPE type; /**< NC_RPC_GETCONFIG */
106 NC_DATASTORE source; /**< NETCONF datastore being queried */
Michal Vaskoad611702015-12-03 13:41:51 +0100107 char *filter; /**< either XML subtree (starts with '<') or an XPath (starts with '/' or an alpha) */
Michal Vasko807be232015-12-09 15:24:55 +0100108 NC_WD_MODE wd_mode;
Michal Vaskoad611702015-12-03 13:41:51 +0100109 char free;
Radek Krejci695d4fa2015-10-22 13:23:54 +0200110};
111
Michal Vaskoad928112015-11-25 15:52:10 +0100112struct nc_rpc_edit {
113 NC_RPC_TYPE type; /**< NC_RPC_EDIT */
114 NC_DATASTORE target;
115 NC_RPC_EDIT_DFLTOP default_op;
116 NC_RPC_EDIT_TESTOPT test_opt;
117 NC_RPC_EDIT_ERROPT error_opt;
118 char *edit_cont; /**< either URL (starts with aplha) or config (starts with '<') */
Michal Vaskoad611702015-12-03 13:41:51 +0100119 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100120};
121
122struct nc_rpc_copy {
123 NC_RPC_TYPE type; /**< NC_RPC_COPY */
124 NC_DATASTORE target;
125 char *url_trg;
126 NC_DATASTORE source;
127 char *url_config_src; /**< either URL (starts with aplha) or config (starts with '<') */
Michal Vasko807be232015-12-09 15:24:55 +0100128 NC_WD_MODE wd_mode;
Michal Vaskoad611702015-12-03 13:41:51 +0100129 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100130};
131
132struct nc_rpc_delete {
133 NC_RPC_TYPE type; /**< NC_RPC_DELETE */
134 NC_DATASTORE target;
135 char *url;
Michal Vaskoad611702015-12-03 13:41:51 +0100136 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100137};
138
Radek Krejci695d4fa2015-10-22 13:23:54 +0200139struct nc_rpc_lock {
140 NC_RPC_TYPE type; /**< NC_RPC_LOCK or NC_RPC_UNLOCK */
141 NC_DATASTORE target;
Radek Krejci206fcd62015-10-07 15:42:48 +0200142};
143
Michal Vaskoad928112015-11-25 15:52:10 +0100144struct nc_rpc_get {
145 NC_RPC_TYPE type; /**< NC_RPC_GET */
Michal Vaskoad611702015-12-03 13:41:51 +0100146 char *filter; /**< either XML subtree (starts with '<') or an XPath (starts with '/' or an alpha) */
Michal Vasko807be232015-12-09 15:24:55 +0100147 NC_WD_MODE wd_mode;
Michal Vaskoad611702015-12-03 13:41:51 +0100148 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100149};
150
151struct nc_rpc_kill {
152 NC_RPC_TYPE type; /**< NC_RPC_KILL */
153 uint32_t sid;
154};
155
156struct nc_rpc_commit {
157 NC_RPC_TYPE type; /**< NC_RPC_COMMIT */
158 int confirmed;
159 uint32_t confirm_timeout;
160 char *persist;
161 char *persist_id;
Michal Vaskoad611702015-12-03 13:41:51 +0100162 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100163};
164
165struct nc_rpc_cancel {
166 NC_RPC_TYPE type; /**< NC_RPC_CANCEL */
167 char *persist_id;
Michal Vaskoad611702015-12-03 13:41:51 +0100168 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100169};
170
171struct nc_rpc_validate {
172 NC_RPC_TYPE type; /**< NC_RPC_VALIDATE */
173 NC_DATASTORE source;
174 char *url_config_src; /**< either URL (starts with alpha) or config (starts with '<') */
Michal Vaskoad611702015-12-03 13:41:51 +0100175 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100176};
177
178struct nc_rpc_getschema {
179 NC_RPC_TYPE type; /**< NC_RPC_GETSCHEMA */
180 char *identifier; /**< requested model identifier */
181 char *version; /**< either YANG version (1.0/1.1) or revision date */
182 char *format; /**< model format */
Michal Vaskoad611702015-12-03 13:41:51 +0100183 char free;
Michal Vaskoad928112015-11-25 15:52:10 +0100184};
185
186struct nc_rpc_subscribe {
187 NC_RPC_TYPE type; /**< NC_RPC_SUBSCRIBE */
188 char *stream; /**< stream name */
Michal Vaskoad611702015-12-03 13:41:51 +0100189 char *filter; /**< either XML subtree (starts with '<') or an XPath (starts with '/' or an alpha) */
Michal Vaskoad928112015-11-25 15:52:10 +0100190 char *start;
191 char *stop;
Michal Vaskoad611702015-12-03 13:41:51 +0100192 char free;
Radek Krejci5686ff72015-10-09 13:33:56 +0200193};
194
Radek Krejci206fcd62015-10-07 15:42:48 +0200195#endif /* NC_MESSAGES_P_H_ */