yumapro  24.10-3
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#define RPC_MSG_IN_DELETE_CHILDREN_FIRST(MSG) \
139 (MSG)->rpc_in_delete_children_first
140
141
142/********************************************************************
143* *
144* T Y P E S *
145* *
146*********************************************************************/
147
160typedef enum rpc_data_t_ {
167
173
174
176typedef enum rpc_rpytyp_t_ {
182
183
185typedef struct rpc_msg_t_ {
189 dlq_hdr_t qhdr;
190
199
205 xml_attrs_t *rpc_in_attrs; /* borrowed from <rpc> elem */
206
215 struct obj_template_t_ *rpc_method;
216
221
226
231
239
241 struct sil_sa_cb_t_ *rpc_sil_sa_cb;
242
248 dlq_hdr_t rpc_inputQ;
256
259
262
277
284
291 dlq_hdr_t rpc_dataQ;
292
297
301 struct agt_cfg_transaction_t_ *rpc_txcb;
302
307
313
318 xmlChar *rpc_trace_id;
319
322
325
330 dlq_hdr_t hook_inputQ;
331
336
342
345
348
351
356 const xmlChar *subrpc_filespec;
357
363
364} rpc_msg_t;
365
366
367/********************************************************************
368* *
369* F U N C T I O N S *
370* *
371*********************************************************************/
372
373
379extern rpc_msg_t *
380 rpc_new_msg (void);
381
382
389extern rpc_msg_t *
390 rpc_new_out_msg (void);
391
392
398extern void
399 rpc_free_msg (rpc_msg_t *msg);
400
401
414extern void rpc_msg_add_error_data (rpc_msg_t *msg,
415 val_value_t *val);
416
417
424extern const xmlChar *
426
427
431#ifdef __cplusplus
432} /* end extern 'C' */
433#endif
434
435#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:160
rpc_rpytyp_t
Type of the <rpc-reply> sent to client.
Definition: rpc.h:176
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:171
@ RPC_DATA_STD
STD is used by <get> and <get-config> to force a <data> container in the NETCONF namespace.
Definition: rpc.h:166
@ RPC_DATA_NONE
not set
Definition: rpc.h:161
@ RPC_RPYTYP_DATA
reply is data
Definition: rpc.h:180
@ RPC_RPYTYP_ERROR
reply is error
Definition: rpc.h:179
@ RPC_RPYTYP_OK
reply is ok
Definition: rpc.h:178
@ RPC_RPYTYP_NONE
not set
Definition: rpc.h:177
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:185
op_errop_t rpc_err_option
Enum value for the <error-option> parameter.
Definition: rpc.h:225
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:255
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:341
op_editop_t rpc_top_editop
Enum value for the <default-operation> parameter.
Definition: rpc.h:230
boolean rpc_replay_config
TRUE if this RPC is being called in replay config mode.
Definition: rpc.h:321
boolean rpc_in_delete_children_first
set to TRUE for a EDIT2 SIL callback when a nested child node is being deleted because of sil-delete-...
Definition: rpc.h:362
xmlChar * rpc_message_id
debugging and audit message string.
Definition: rpc.h:312
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:198
dlq_hdr_t hook_inputQ
points to add_edit_value node comming from the users freed in the end of transaction.
Definition: rpc.h:330
dlq_hdr_t qhdr
Queue header to store RPC messages in a queue (within the session header)
Definition: rpc.h:189
val_value_t * rpc_input
Value tree representing the container of 'input' parameters for this RPC operation.
Definition: rpc.h:238
struct sil_sa_cb_t_ * rpc_sil_sa_cb
backptr to SIL-SA edit control block if WITH_YCONTROL=1
Definition: rpc.h:241
void * rpc_datacb
For operations that return streamed data, this pointer is set to the desired callback function to use...
Definition: rpc.h:283
op_filter_t rpc_filter
Internal structure for optimizing subtree and XPath retrieval operations.
Definition: rpc.h:296
void * rpc_user2
Same use as rpc_user1.
Definition: rpc.h:258
time_t rpc_start_time
saved timestamp when started for audit record
Definition: rpc.h:350
rpc_rpytyp_t rpc_reply_type
saved reply type needed for audit record
Definition: rpc.h:344
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:205
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:356
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:335
uint32 rpc_returncode
Internal return code used to control nested callbacks.
Definition: rpc.h:261
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:291
boolean rpc_with_template
–with-template parameter was seen in the validate phase
Definition: rpc.h:324
xmlChar * rpc_trace_id
debugging and audit message string.
Definition: rpc.h:318
rpc_data_t rpc_data_type
incoming: get method reply handling builtin For RPC operations that return data, this enumeration MUS...
Definition: rpc.h:276
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:306
int rpc_agt_state
incoming: SERVER RPC processing state Enum value (0, 1, 2) for the current RPC callback phase.
Definition: rpc.h:220
status_t rpc_status
saved processing status for audit record
Definition: rpc.h:347
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:248
struct obj_template_t_ * rpc_method
incoming: Back-pointer to the object template for this RPC operation.
Definition: rpc.h:215
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:301
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.