yumapro  24.10-2
YumaPro SDK
Loading...
Searching...
No Matches
rpc.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 - 2012, Andy Bierman, All Rights Reserved.
3 * Copyright (c) 2012 - 2021, YumaWorks, Inc., All Rights Reserved.
4 *
5 * Unless required by applicable law or agreed to in writing,
6 * software distributed under the License is distributed on an
7 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8 * KIND, either express or implied. See the License for the
9 * specific language governing permissions and limitations
10 * under the License.
11 */
12#ifndef _H_rpc
13#define _H_rpc
14/* FILE: rpc.h
15*********************************************************************
16* *
17* P U R P O S E *
18* *
19*********************************************************************/
20
27/*********************************************************************
28* *
29* C H A N G E H I S T O R Y *
30* *
31*********************************************************************
32
33date init comment
34----------------------------------------------------------------------
3501-may-05 abb Begun.
36*/
37
38#include <time.h>
39#include <xmlstring.h>
40
41
42#ifndef _H_dlq
43#include "dlq.h"
44#endif
45
46#ifndef _H_ncxtypes
47#include "ncxtypes.h"
48#endif
49
50#ifndef _H_op
51#include "op.h"
52#endif
53
54#ifndef _H_status
55#include "status.h"
56#endif
57
58#ifndef _H_val
59#include "val.h"
60#endif
61
62#ifndef _H_xmlns
63#include "xmlns.h"
64#endif
65
66#ifndef _H_xml_msg
67#include "xml_msg.h"
68#endif
69
70#ifndef _H_xml_util
71#include "xml_util.h"
72#endif
73
74#ifdef __cplusplus
75extern "C" {
76#endif
77
78/********************************************************************
79* *
80* C O N S T A N T S *
81* *
82*********************************************************************/
83#define RPC_STR_REQ "rpc"
84#define RPC_STR_RPY "rpc-reply"
85#define RPC_STR_ERR "rpc-error"
86#define RPC_STR_MSG_ID "message-id"
87#define RPC_STR_GRP_ID "group-id"
88
89#define RPC_MHDR(MSG) &(MSG)->mhdr
90
91#define RPC_ERR_QUEUE(MSG) &(MSG)->mhdr.errQ
92
93#define RPC_MSG_SET_REPLAY(MSG) (MSG)->rpc_replay_config = true
94
95#define RPC_MSG_IS_REPLAY(MSG) (MSG)->rpc_replay_config
96
97#define RPC_MSG_ID(MSG) (MSG)->rpc_message_id
98
99#define RPC_MSG_SIL_SA_CB(MSG) (MSG)->rpc_sil_sa_cb
100
101#define RPC_MSG_TXCB(MSG) (MSG)->rpc_txcb
102
103#define RPC_MSG_GETBULK(MSG) (MSG)->mhdr.getbulk_cb
104
105#define RPC_MSG_SET_WITH_TEMPLATE(MSG) (MSG)->rpc_with_template = true
106
107#define RPC_MSG_IS_WITH_TEMPLATE(MSG) (MSG)->rpc_with_template
108
109#define RPC_MSG_METHOD(MSG) (MSG)->rpc_method
110
111#define RPC_SET_DEFER_REPLY(MSG) (MSG)->rpc_defer_reply = TRUE
112
113#define RPC_IS_DEFER_REPLY(MSG) ((MSG)->rpc_defer_reply)
114
115/* yp-gnmi control block. Used in restconf processing code */
116#define RPC_MSG_YPGNMI_GETCB(MSG) (MSG)->mhdr.gnmi_getcb
117
118/* yp-gnmi control block. Used in restconf processing code */
119#define RPC_MSG_YPGNMI_EDITCB(MSG) (MSG)->mhdr.gnmi_editcb
120
121#define RPC_MSG_REPLY_TYPE(MSG) (MSG)->rpc_reply_type
122
123#define RPC_MSG_STATUS(MSG) (MSG)->rpc_status
124
125#define RPC_MSG_START_TIME(MSG) (MSG)->rpc_start_time
126
127#define RPC_MSG_SUBRPC_FILESPEC(MSG) (MSG)->subrpc_filespec
128
129#define RPC_MSG_USER1(MSG) (MSG)->rpc_user1
130
131#define RPC_MSG_USER2(MSG) (MSG)->rpc_user2
132
133#define RPC_MSG_DATA_TYPE(MSG) (MSG)->rpc_data_type
134
135#define RPC_MSG_DATACB(MSG) (MSG)->rpc_datacb
136
137
138/********************************************************************
139* *
140* T Y P E S *
141* *
142*********************************************************************/
143
156typedef enum rpc_data_t_ {
163
169
170
172typedef enum rpc_rpytyp_t_ {
178
179
181typedef struct rpc_msg_t_ {
185 dlq_hdr_t qhdr;
186
195
201 xml_attrs_t *rpc_in_attrs; /* borrowed from <rpc> elem */
202
211 struct obj_template_t_ *rpc_method;
212
217
222
227
235
237 struct sil_sa_cb_t_ *rpc_sil_sa_cb;
238
244 dlq_hdr_t rpc_inputQ;
252
255
258
273
280
287 dlq_hdr_t rpc_dataQ;
288
293
297 struct agt_cfg_transaction_t_ *rpc_txcb;
298
303
309
314 xmlChar *rpc_trace_id;
315
318
321
326 dlq_hdr_t hook_inputQ;
327
332
338
341
344
347
352 const xmlChar *subrpc_filespec;
353
354} rpc_msg_t;
355
356
357/********************************************************************
358* *
359* F U N C T I O N S *
360* *
361*********************************************************************/
362
363
369extern rpc_msg_t *
370 rpc_new_msg (void);
371
372
379extern rpc_msg_t *
380 rpc_new_out_msg (void);
381
382
388extern void
389 rpc_free_msg (rpc_msg_t *msg);
390
391
404extern void rpc_msg_add_error_data (rpc_msg_t *msg,
405 val_value_t *val);
406
407
414extern const xmlChar *
416
417
421#ifdef __cplusplus
422} /* end extern 'C' */
423#endif
424
425#endif /* _H_rpc */
dlq provides general double-linked list and queue support:
op_errop_t
NETCONF edit-config error-option types.
Definition: op.h:173
op_editop_t
NETCONF edit-config operation types.
Definition: op.h:122
const xmlChar * rpc_msg_get_reply_type(rpc_rpytyp_t rpytyp)
Get the reply type string from the message type.
Definition: rpc.c:236
rpc_data_t
Type of the <rpc-reply> data source.
Definition: rpc.h:156
rpc_rpytyp_t
Type of the <rpc-reply> sent to client.
Definition: rpc.h:172
void rpc_msg_add_error_data(rpc_msg_t *msg, val_value_t *val)
Add error data to the response message.
Definition: rpc.c:212
void rpc_free_msg(rpc_msg_t *msg)
Free all the memory used by the specified rpc_msg_t.
Definition: rpc.c:151
rpc_msg_t * rpc_new_msg(void)
Malloc and initialize a new rpc_msg_t struct.
Definition: rpc.c:83
rpc_msg_t * rpc_new_out_msg(void)
Malloc and initialize a new rpc_msg_t struct for output or for dummy use.
Definition: rpc.c:125
@ RPC_DATA_YANG
STD is used by YANG rpc or action stmts; no extra <data> container will be added to the <rpc-reply> c...
Definition: rpc.h:167
@ RPC_DATA_STD
STD is used by <get> and <get-config> to force a <data> container in the NETCONF namespace.
Definition: rpc.h:162
@ RPC_DATA_NONE
not set
Definition: rpc.h:157
@ RPC_RPYTYP_DATA
reply is data
Definition: rpc.h:176
@ RPC_RPYTYP_ERROR
reply is error
Definition: rpc.h:175
@ RPC_RPYTYP_OK
reply is ok
Definition: rpc.h:174
@ RPC_RPYTYP_NONE
not set
Definition: rpc.h:173
status_t
global error return code
Definition: status_enum.h:210
dlq_hdr_t xml_attrs_t
queue of xml_attr_t
Definition: xml_util.h:155
YANG module data structures Many internal representations of YANG module constructs.
NETCONF protocol operations.
Global error messages for status code enumerations.
NETCONF protocol operation filter spec.
Definition: op.h:182
NETCONF Server and Client RPC Request/Reply Message Header.
Definition: rpc.h:181
op_errop_t rpc_err_option
Enum value for the <error-option> parameter.
Definition: rpc.h:221
void * rpc_user1
Void pointer that can be used by method routines to save context or whatever to store SIL-specific da...
Definition: rpc.h:251
xml_attrs_t rpc_defer_in_attrs
the top->attrs gets deleted so a deferred rpc-reply needs to save the rpc_in_attrs.
Definition: rpc.h:337
op_editop_t rpc_top_editop
Enum value for the <default-operation> parameter.
Definition: rpc.h:226
boolean rpc_replay_config
TRUE if this RPC is being called in replay config mode.
Definition: rpc.h:317
xmlChar * rpc_message_id
debugging and audit message string.
Definition: rpc.h:308
xml_msg_hdr_t mhdr
generic XML message header Most in-message state is kept in the mhdr There are several places in the ...
Definition: rpc.h:194
dlq_hdr_t hook_inputQ
points to add_edit_value node comming from the users freed in the end of transaction.
Definition: rpc.h:326
dlq_hdr_t qhdr
Queue header to store RPC messages in a queue (within the session header)
Definition: rpc.h:185
val_value_t * rpc_input
Value tree representing the container of 'input' parameters for this RPC operation.
Definition: rpc.h:234
struct sil_sa_cb_t_ * rpc_sil_sa_cb
backptr to SIL-SA edit control block if WITH_YCONTROL=1
Definition: rpc.h:237
void * rpc_datacb
For operations that return streamed data, this pointer is set to the desired callback function to use...
Definition: rpc.h:279
op_filter_t rpc_filter
Internal structure for optimizing subtree and XPath retrieval operations.
Definition: rpc.h:292
void * rpc_user2
Same use as rpc_user1.
Definition: rpc.h:254
time_t rpc_start_time
saved timestamp when started for audit record
Definition: rpc.h:346
rpc_rpytyp_t rpc_reply_type
saved reply type needed for audit record
Definition: rpc.h:340
xml_attrs_t * rpc_in_attrs
incoming: top-level rpc element data Queue of xml_attr_t representing any XML attributes that were pr...
Definition: rpc.h:201
const xmlChar * subrpc_filespec
saved by agt_db_api.c so the ycontrol callback function can generate an external value with the DB-AP...
Definition: rpc.h:352
boolean rpc_defer_reply
YPSERVER mode is skipping the regular rpc-reply phase and will send the reply after doing the remote ...
Definition: rpc.h:331
uint32 rpc_returncode
Internal return code used to control nested callbacks.
Definition: rpc.h:257
dlq_hdr_t rpc_dataQ
For operations that return stored data, this queue of val_value_t structures can be used to provide t...
Definition: rpc.h:287
boolean rpc_with_template
–with-template parameter was seen in the validate phase
Definition: rpc.h:320
xmlChar * rpc_trace_id
debugging and audit message string.
Definition: rpc.h:314
rpc_data_t rpc_data_type
incoming: get method reply handling builtin For RPC operations that return data, this enumeration MUS...
Definition: rpc.h:272
boolean rpc_parse_errors
load-config parse-error and –startup-error=continue flag if the val_purge_errors_from_root function i...
Definition: rpc.h:302
int rpc_agt_state
incoming: SERVER RPC processing state Enum value (0, 1, 2) for the current RPC callback phase.
Definition: rpc.h:216
status_t rpc_status
saved processing status for audit record
Definition: rpc.h:343
dlq_hdr_t rpc_inputQ
the rpc_inputQ is used with JSON encoded input since an array is allowed at the top-level; it is used...
Definition: rpc.h:244
struct obj_template_t_ * rpc_method
incoming: Back-pointer to the object template for this RPC operation.
Definition: rpc.h:211
struct agt_cfg_transaction_t_ * rpc_txcb
incoming: agent database edit transaction control block must be freed by an upper layer if set to mal...
Definition: rpc.h:297
one value to match one type
Definition: val.h:912
Common Encoding Message Header No longer XML specific!! Used by JSON and CBOR parsing as well!...
Definition: xml_msg.h:404
Value Node Basic Support.
XML and JSON Message send and receive support.
XML Utilities.
XML namespace support.