blob: 2e2e0c0ab461472b1f67712a65ff3fc83420631a [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
Radek Krejci695d4fa2015-10-22 13:23:54 +020030typedef enum {
31 NC_RPC_SERVER, /**< server-side RPC object, see #nc_rpc_server. All other values define client-side RPC object. */
32 NC_RPC_GETCONFIG, /**< \<get-config\> RPC, see #nc_rpc_getconfig. */
33 NC_RPC_EDIT, /**< \<edit-config\> RPC, see #nc_rpc_edit. */
34 NC_RPC_COPY, /**< \<copy-config\> RPC, see #nc_rpc_copy. */
35 NC_RPC_DELETE, /**< \<delete-config\> RPC, see #nc_rpc_delete. */
36 NC_RPC_LOCK, /**< \<lock\> RPC, see #nc_rpc_lock. */
37 NC_RPC_UNLOCK, /**< \<unlock\> RPC, see #nc_rpc_lock. */
38 NC_RPC_GET, /**< \<get\> RPC, see #nc_rpc_get. */
39 /* NC_RPC_CLOSE is not defined since sending \<close-session\> is done by nc_session_free() */
40 NC_RPC_KILL, /**< \<kill-session\> RPC, see #nc_rpc_kill. */
41 NC_RPC_GENERIC /**< user-defined generic RPC */
42} NC_RPC_TYPE;
43
Radek Krejci8800a492015-10-31 17:51:27 +010044typedef enum {
45 NC_REPLY_ERROR,
46 NC_REPLY_OK,
47 NC_REPLY_DATA,
48} NC_REPLY_TYPE;
49
Radek Krejci695d4fa2015-10-22 13:23:54 +020050struct nc_filter {
51 NC_FILTER type; /**< filter type */
52 int refs; /**< number of references */
53 char *data; /**< filter data according to type */
54};
55
Radek Krejci206fcd62015-10-07 15:42:48 +020056struct nc_rpc {
Radek Krejci695d4fa2015-10-22 13:23:54 +020057 NC_RPC_TYPE type;
58};
59
60struct nc_rpc_server {
61 NC_RPC_TYPE type; /**< NC_RPC_SERVER */
62 struct ly_ctx *ctx; /**< context of the received RPC data */
63 struct lyxml_elem *root; /**< RPC element of the received XML message */
64 struct lyd_node *tree; /**< libyang data tree of the message (NETCONF operation) */
65};
66
Radek Krejci926a5742015-10-31 17:50:49 +010067struct nc_rpc_get {
68 NC_RPC_TYPE type; /**< NC_RPC_GET */
69 struct nc_filter *filter;/**< data filter */
70};
71
Radek Krejci695d4fa2015-10-22 13:23:54 +020072struct nc_rpc_getconfig {
73 NC_RPC_TYPE type; /**< NC_RPC_GETCONFIG */
74 NC_DATASTORE source; /**< NETCONF datastore being queried */
75 struct nc_filter *filter;/**< data filter */
76};
77
78struct nc_rpc_lock {
79 NC_RPC_TYPE type; /**< NC_RPC_LOCK or NC_RPC_UNLOCK */
80 NC_DATASTORE target;
Radek Krejci206fcd62015-10-07 15:42:48 +020081};
82
Radek Krejci5686ff72015-10-09 13:33:56 +020083struct nc_reply {
Radek Krejci8800a492015-10-31 17:51:27 +010084 NC_REPLY_TYPE type;
Radek Krejcia53b3fe2015-10-19 17:25:04 +020085 struct ly_ctx *ctx;
Radek Krejci5686ff72015-10-09 13:33:56 +020086 struct lyxml_elem *root;
Radek Krejci8800a492015-10-31 17:51:27 +010087};
88
89struct nc_reply_error {
90 NC_REPLY_TYPE type; /**< NC_REPLY_ERROR */
91 struct ly_ctx *ctx;
92 struct lyxml_elem *root;
93 /* TODO */
94};
95
96struct nc_reply_data {
97 NC_REPLY_TYPE type; /**< NC_REPLY_DATA */
98 struct ly_ctx *ctx;
99 struct lyxml_elem *root;
100 struct lyd_node *data; /**< libyang data tree */
Radek Krejci5686ff72015-10-09 13:33:56 +0200101};
102
103struct nc_notif {
Radek Krejcia53b3fe2015-10-19 17:25:04 +0200104 struct ly_ctx *ctx;
Radek Krejci5686ff72015-10-09 13:33:56 +0200105 struct lyxml_elem *root;
106 struct lyd_node *tree; /**< libyang data tree of the message */
107};
108
Radek Krejci206fcd62015-10-07 15:42:48 +0200109#endif /* NC_MESSAGES_P_H_ */