FEATURE creating and sending all standard RPCs
diff --git a/src/messages_p.h b/src/messages_p.h
index 2e2e0c0..599f080 100644
--- a/src/messages_p.h
+++ b/src/messages_p.h
@@ -27,24 +27,42 @@
#include "messages.h"
+extern const char *rpcedit_dfltop2str[];
+extern const char *rpcedit_testopt2str[];
+extern const char *rpcedit_erropt2str[];
+
typedef enum {
- NC_RPC_SERVER, /**< server-side RPC object, see #nc_rpc_server. All other values define client-side RPC object. */
- NC_RPC_GETCONFIG, /**< \<get-config\> RPC, see #nc_rpc_getconfig. */
- NC_RPC_EDIT, /**< \<edit-config\> RPC, see #nc_rpc_edit. */
- NC_RPC_COPY, /**< \<copy-config\> RPC, see #nc_rpc_copy. */
- NC_RPC_DELETE, /**< \<delete-config\> RPC, see #nc_rpc_delete. */
- NC_RPC_LOCK, /**< \<lock\> RPC, see #nc_rpc_lock. */
- NC_RPC_UNLOCK, /**< \<unlock\> RPC, see #nc_rpc_lock. */
- NC_RPC_GET, /**< \<get\> RPC, see #nc_rpc_get. */
+ NC_RPC_SERVER, /**< server-side RPC object, see #nc_rpc_server. All other values define client-side RPC object. */
+ NC_RPC_GENERIC, /**< user-defined generic RPC with content as data, see #nc_rpc_generic. */
+ NC_RPC_GENERIC_XML, /**< user-defined generic RPC with content as an XML string, see #nc_rpc_generic_xml. */
+
+ /* ietf-netconf */
+ NC_RPC_GETCONFIG, /**< \<get-config\> RPC, see #nc_rpc_getconfig. */
+ NC_RPC_EDIT, /**< \<edit-config\> RPC, see #nc_rpc_edit. */
+ NC_RPC_COPY, /**< \<copy-config\> RPC, see #nc_rpc_copy. */
+ NC_RPC_DELETE, /**< \<delete-config\> RPC, see #nc_rpc_delete. */
+ NC_RPC_LOCK, /**< \<lock\> RPC, see #nc_rpc_lock. */
+ NC_RPC_UNLOCK, /**< \<unlock\> RPC, see #nc_rpc_lock. */
+ NC_RPC_GET, /**< \<get\> RPC, see #nc_rpc_get. */
/* NC_RPC_CLOSE is not defined since sending \<close-session\> is done by nc_session_free() */
- NC_RPC_KILL, /**< \<kill-session\> RPC, see #nc_rpc_kill. */
- NC_RPC_GENERIC /**< user-defined generic RPC */
+ NC_RPC_KILL, /**< \<kill-session\> RPC, see #nc_rpc_kill. */
+ NC_RPC_COMMIT, /**< \<commit\> RPC, see #nc_rpc_commit. */
+ NC_RPC_DISCARD, /**< \<discard-changes\> RPC, #nc_rpc with this type. */
+ NC_RPC_CANCEL, /**< \<cancel-commit\> RPC, see #c_rpc_cancel. */
+ NC_RPC_VALIDATE, /**< \<validate\> RPC, see #nc_rpc_validate. */
+
+ /* ietf-netconf-monitoring */
+ NC_RPC_GETSCHEMA, /**< \<get-schema\> RPC, see #nc_rpc_getschema. */
+
+ /* notifications */
+ NC_RPC_SUBSCRIBE /**< \<create-subscription\> RPC, see #nc_rpc_subscribe. */
} NC_RPC_TYPE;
typedef enum {
NC_REPLY_ERROR,
NC_REPLY_OK,
NC_REPLY_DATA,
+ NC_REPLY_NOTIF
} NC_REPLY_TYPE;
struct nc_filter {
@@ -59,14 +77,18 @@
struct nc_rpc_server {
NC_RPC_TYPE type; /**< NC_RPC_SERVER */
- struct ly_ctx *ctx; /**< context of the received RPC data */
struct lyxml_elem *root; /**< RPC element of the received XML message */
struct lyd_node *tree; /**< libyang data tree of the message (NETCONF operation) */
};
-struct nc_rpc_get {
- NC_RPC_TYPE type; /**< NC_RPC_GET */
- struct nc_filter *filter;/**< data filter */
+struct nc_rpc_generic {
+ NC_RPC_TYPE type; /**< NC_RPC_GENERIC */
+ struct lyd_node *data; /**< RPC data */
+};
+
+struct nc_rpc_generic_xml {
+ NC_RPC_TYPE type; /**< NC_RPC_GENERIC_XML */
+ char *xml_str;
};
struct nc_rpc_getconfig {
@@ -75,35 +97,105 @@
struct nc_filter *filter;/**< data filter */
};
+struct nc_rpc_edit {
+ NC_RPC_TYPE type; /**< NC_RPC_EDIT */
+ NC_DATASTORE target;
+ NC_RPC_EDIT_DFLTOP default_op;
+ NC_RPC_EDIT_TESTOPT test_opt;
+ NC_RPC_EDIT_ERROPT error_opt;
+ char *edit_cont; /**< either URL (starts with aplha) or config (starts with '<') */
+};
+
+struct nc_rpc_copy {
+ NC_RPC_TYPE type; /**< NC_RPC_COPY */
+ NC_DATASTORE target;
+ char *url_trg;
+ NC_DATASTORE source;
+ char *url_config_src; /**< either URL (starts with aplha) or config (starts with '<') */
+};
+
+struct nc_rpc_delete {
+ NC_RPC_TYPE type; /**< NC_RPC_DELETE */
+ NC_DATASTORE target;
+ char *url;
+};
+
struct nc_rpc_lock {
NC_RPC_TYPE type; /**< NC_RPC_LOCK or NC_RPC_UNLOCK */
NC_DATASTORE target;
};
+struct nc_rpc_get {
+ NC_RPC_TYPE type; /**< NC_RPC_GET */
+ struct nc_filter *filter;/**< data filter */
+};
+
+struct nc_rpc_kill {
+ NC_RPC_TYPE type; /**< NC_RPC_KILL */
+ uint32_t sid;
+};
+
+struct nc_rpc_commit {
+ NC_RPC_TYPE type; /**< NC_RPC_COMMIT */
+ int confirmed;
+ uint32_t confirm_timeout;
+ char *persist;
+ char *persist_id;
+};
+
+struct nc_rpc_cancel {
+ NC_RPC_TYPE type; /**< NC_RPC_CANCEL */
+ char *persist_id;
+};
+
+struct nc_rpc_validate {
+ NC_RPC_TYPE type; /**< NC_RPC_VALIDATE */
+ NC_DATASTORE source;
+ char *url_config_src; /**< either URL (starts with alpha) or config (starts with '<') */
+};
+
+struct nc_rpc_getschema {
+ NC_RPC_TYPE type; /**< NC_RPC_GETSCHEMA */
+ char *identifier; /**< requested model identifier */
+ char *version; /**< either YANG version (1.0/1.1) or revision date */
+ char *format; /**< model format */
+};
+
+struct nc_rpc_subscribe {
+ NC_RPC_TYPE type; /**< NC_RPC_SUBSCRIBE */
+ char *stream; /**< stream name */
+ struct nc_filter *filter;
+ char *start;
+ char *stop;
+};
+
struct nc_reply {
NC_REPLY_TYPE type;
- struct ly_ctx *ctx;
struct lyxml_elem *root;
};
struct nc_reply_error {
- NC_REPLY_TYPE type; /**< NC_REPLY_ERROR */
- struct ly_ctx *ctx;
+ NC_REPLY_TYPE type; /**< NC_REPLY_ERROR */
struct lyxml_elem *root;
/* TODO */
};
-struct nc_reply_data {
- NC_REPLY_TYPE type; /**< NC_REPLY_DATA */
- struct ly_ctx *ctx;
+struct nc_reply_ok {
+ NC_REPLY_TYPE type; /**< NC_REPLY_OK */
struct lyxml_elem *root;
- struct lyd_node *data; /**< libyang data tree */
+ struct ly_ctx *ctx;
+};
+
+struct nc_reply_data {
+ NC_REPLY_TYPE type; /**< NC_REPLY_DATA */
+ struct lyxml_elem *root; /**< only the top reply element */
+ struct lyd_node *data; /**< libyang data tree */
};
struct nc_notif {
- struct ly_ctx *ctx;
- struct lyxml_elem *root;
- struct lyd_node *tree; /**< libyang data tree of the message */
+ NC_REPLY_TYPE type; /**< NC_REPLY_NOTIF */
+ struct lyxml_elem *root; /**< only the top notification element */
+ struct lyd_node *tree; /**< libyang data tree of the message */
};
#endif /* NC_MESSAGES_P_H_ */